add char descs

This commit is contained in:
Sen 2025-03-28 15:07:32 +01:00
parent c130bb1272
commit 1219616a44
3 changed files with 20 additions and 5 deletions

View file

@ -419,17 +419,22 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
} }
}, "Spieler-Größe", "cm")).enabled = this.gm.thePlayer == null || this.gm.thePlayer.getMinSize() != this.gm.thePlayer.getMaxSize(); }, "Spieler-Größe", "cm")).enabled = this.gm.thePlayer == null || this.gm.thePlayer.getMinSize() != this.gm.thePlayer.getMaxSize();
this.add(new Label(width / 2 - 200, 36, 400, 20, "Name", true)); this.add(new Label(width / 2 - 200, 36, 400, 20, "Name", true));
final Textbox descField = this.add(new Textbox(width - 396, height - 384, 392, 160, Player.MAX_INFO_LENGTH, new Textbox.Callback() {
public void use(Textbox elem, Action value) {
}
}, ""));
this.add(new ActButton(width - 198, height - 28, 194, 24, new ActButton.Callback() { this.add(new ActButton(width - 198, height - 28, 194, 24, new ActButton.Callback() {
public void use(ActButton elem, Mode action) { public void use(ActButton elem, Mode action) {
if(GuiChar.this.gm.thePlayer != null) { if(GuiChar.this.gm.thePlayer != null) {
GuiChar.this.gm.waitForServer(); GuiChar.this.gm.waitForServer();
Dimension dim = // GuiChar.this.dimension == Integer.MAX_VALUE ? Space.INSTANCE : Dimension dim = // GuiChar.this.dimension == Integer.MAX_VALUE ? Space.INSTANCE :
UniverseRegistry.getBaseDimensions().get(GuiChar.this.dimension); UniverseRegistry.getBaseDimensions().get(GuiChar.this.dimension);
GuiChar.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketMessage(CPacketMessage.Type.INFO, descField.getText()));
GuiChar.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_EDITOR, dim.getDimensionId())); GuiChar.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_EDITOR, dim.getDimensionId()));
} }
} }
}, "Charakter erstellen")); }, "Charakter erstellen"));
Textbox nameField = this.add(new Textbox(width / 2 - 200, 36 + 20, 400, 24, Player.MAX_NICK_LENGTH, true, new Textbox.Callback() { this.add(new Textbox(width / 2 - 200, 36 + 20, 400, 24, Player.MAX_NICK_LENGTH, true, new Textbox.Callback() {
public void use(Textbox elem, Action value) { public void use(Textbox elem, Action value) {
if(value == Action.SEND || value == Action.UNFOCUS) { if(value == Action.SEND || value == Action.UNFOCUS) {
String name = elem.getText(); String name = elem.getText();
@ -458,7 +463,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
} }
} }
} }
this.dimButton = this.add(new ActButton(width - 396, height - 300, 392, 24, new ActButton.Callback() { this.dimButton = this.add(new ActButton(width - 396, height - 220, 392, 24, new ActButton.Callback() {
public void use(ActButton elem, Mode mode) { public void use(ActButton elem, Mode mode) {
if(mode == Mode.TERTIARY) { if(mode == Mode.TERTIARY) {
GuiChar.this.dimension = new Random().zrange(UniverseRegistry.getBaseDimensions().size()); GuiChar.this.dimension = new Random().zrange(UniverseRegistry.getBaseDimensions().size());
@ -479,7 +484,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
GuiChar.this.setDimButton(); GuiChar.this.setDimButton();
} }
}, "")); }, ""));
this.descLines = this.add(new TransparentBox(width - 396, height - 300 + 24, 392, 160, "", false)); this.descLines = this.add(new TransparentBox(width - 396, height - 220 + 24, 392, 76, "", false));
this.setDimButton(); this.setDimButton();
} }

View file

@ -1958,7 +1958,7 @@ public class Player extends NetHandler implements ICrafting, Executor
} }
CPacketMessage.Type type = packetIn.getType(); CPacketMessage.Type type = packetIn.getType();
if(this.charEditor != (type == CPacketMessage.Type.DISPLAY)) if(this.charEditor != (type == CPacketMessage.Type.DISPLAY || type == CPacketMessage.Type.INFO))
return; return;
switch(type) { switch(type) {
@ -1978,6 +1978,12 @@ public class Player extends NetHandler implements ICrafting, Executor
this.entity.setCustomNameTag(msg); this.entity.setCustomNameTag(msg);
break; break;
case INFO:
if(msg.length() > MAX_INFO_LENGTH)
throw new IllegalArgumentException("Ungültige Beschreibung");
this.entity.setDescription(msg.isEmpty() ? null : msg);
break;
// case ITEM: // case ITEM:
// if(this.entity.openContainer instanceof ContainerRepair) // if(this.entity.openContainer instanceof ContainerRepair)
// ((ContainerRepair)this.entity.openContainer).updateItemName(msg); // ((ContainerRepair)this.entity.openContainer).updateItemName(msg);

View file

@ -49,7 +49,11 @@ public class CPacketMessage implements Packet<Player>
} }
public static enum Type { public static enum Type {
COMMAND(Player.MAX_CMD_LENGTH), CHAT(Player.MAX_CMD_LENGTH), DISPLAY(Player.MAX_NICK_LENGTH); // , ITEM(30); COMMAND(Player.MAX_CMD_LENGTH),
CHAT(Player.MAX_CMD_LENGTH),
DISPLAY(Player.MAX_NICK_LENGTH),
INFO(Player.MAX_INFO_LENGTH);
// , ITEM(30);
private final int length; private final int length;