split char gui
This commit is contained in:
parent
1b9ef61599
commit
5e20c6f90d
10 changed files with 105 additions and 29 deletions
77
java/src/game/gui/character/GuiSpecies.java
Normal file
77
java/src/game/gui/character/GuiSpecies.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
package game.gui.character;
|
||||
|
||||
import game.entity.npc.SpeciesInfo;
|
||||
import game.gui.element.ActButton;
|
||||
import game.gui.element.ActButton.Mode;
|
||||
import game.gui.element.GuiList;
|
||||
import game.gui.element.ListEntry;
|
||||
import game.gui.element.NavButton;
|
||||
import game.init.EntityRegistry;
|
||||
import game.init.SpeciesRegistry;
|
||||
import game.packet.CPacketAction;
|
||||
import game.renderer.Drawing;
|
||||
|
||||
public class GuiSpecies extends GuiList<GuiSpecies.SkinEntry> implements ActButton.Callback
|
||||
{
|
||||
protected class SkinEntry implements ListEntry
|
||||
{
|
||||
private final SpeciesInfo species;
|
||||
|
||||
protected SkinEntry(SpeciesInfo species)
|
||||
{
|
||||
this.species = species;
|
||||
}
|
||||
|
||||
public void draw(int x, int y, int mouseX, int mouseY, boolean hovered)
|
||||
{
|
||||
if(GuiSpecies.this.gm.thePlayer != null && this.species == GuiSpecies.this.gm.thePlayer.getSpecies())
|
||||
Drawing.drawRect(x, y, 1, 44, 0xffaf0000);
|
||||
Drawing.drawText(this.species.name, x + 3, y, 0xff000000 | this.species.color1 | this.species.color2);
|
||||
}
|
||||
|
||||
public void select(boolean dclick, int mx, int my)
|
||||
{
|
||||
if((GuiSpecies.this.selectButton.enabled = GuiSpecies.this.gm.thePlayer == null || this.species != GuiSpecies.this.gm.thePlayer.getSpecies()) && dclick)
|
||||
GuiSpecies.this.use(GuiSpecies.this.selectButton, Mode.PRIMARY);
|
||||
}
|
||||
}
|
||||
|
||||
public static final GuiSpecies INSTANCE = new GuiSpecies();
|
||||
|
||||
private ActButton selectButton;
|
||||
|
||||
private GuiSpecies() {
|
||||
}
|
||||
|
||||
public void init(int width, int height)
|
||||
{
|
||||
super.init(width, height);
|
||||
this.setDimensions(400, height, 32, height - 32);
|
||||
this.elements.clear();
|
||||
for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) {
|
||||
this.elements.add(new SkinEntry(species));
|
||||
}
|
||||
this.add(new NavButton(width - 198 * 2, height - 28, 194, 24, GuiChar.INSTANCE, "Zurück"));
|
||||
this.selectButton = this.add(new ActButton(width - 198, height - 28, 194, 24, this, "Spezies ändern"));
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return "Spezies wählen";
|
||||
}
|
||||
|
||||
public int getListWidth()
|
||||
{
|
||||
return 400 - 20;
|
||||
}
|
||||
|
||||
public int getSlotHeight()
|
||||
{
|
||||
return 44 + 4;
|
||||
}
|
||||
|
||||
public void use(ActButton elem, Mode action) {
|
||||
SkinEntry entry = this.getSelected();
|
||||
if(entry != null && GuiSpecies.this.gm.thePlayer != null)
|
||||
GuiSpecies.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_SPECIES, EntityRegistry.getEntityID(entry.species.clazz)));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue