2025-03-30 13:35:02 +02:00
|
|
|
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;
|
|
|
|
|
2025-03-30 21:15:22 +02:00
|
|
|
public class GuiSpecies extends GuiList<GuiSpecies.SpeciesEntry> implements ActButton.Callback
|
2025-03-30 13:35:02 +02:00
|
|
|
{
|
2025-03-30 21:15:22 +02:00
|
|
|
protected class SpeciesEntry implements ListEntry
|
2025-03-30 13:35:02 +02:00
|
|
|
{
|
|
|
|
private final SpeciesInfo species;
|
|
|
|
|
2025-03-30 21:15:22 +02:00
|
|
|
protected SpeciesEntry(SpeciesInfo species)
|
2025-03-30 13:35:02 +02:00
|
|
|
{
|
|
|
|
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) {
|
2025-03-30 21:15:22 +02:00
|
|
|
this.elements.add(new SpeciesEntry(species));
|
2025-03-30 13:35:02 +02:00
|
|
|
}
|
|
|
|
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) {
|
2025-03-30 21:15:22 +02:00
|
|
|
SpeciesEntry entry = this.getSelected();
|
2025-03-30 13:35:02 +02:00
|
|
|
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)));
|
|
|
|
}
|
|
|
|
}
|