allow cancelling character creation
This commit is contained in:
parent
58163db658
commit
53a4f5f1a8
3 changed files with 21 additions and 10 deletions
|
@ -391,10 +391,8 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
}, "Charakter erstellen"));
|
||||
this.cancelButton = this.add(new ActButton(width - 390, height - 30, 193, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
if(GuiChar.this.gm.player != null) {
|
||||
GuiChar.this.gm.displayGuiScreen(GuiLoading.makeWaitTask("Lade Welt ..."));
|
||||
GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.CANCEL_EDITOR));
|
||||
}
|
||||
if(GuiChar.this.gm.player != null)
|
||||
GuiChar.this.gm.displayGuiScreen(GuiCharacters.INSTANCE);
|
||||
}
|
||||
}, "Abbrechen"));
|
||||
this.setCharsAvailable();
|
||||
|
|
|
@ -14,6 +14,7 @@ import client.renderer.Drawing;
|
|||
import common.color.TextColor;
|
||||
import common.entity.npc.PlayerCharacter;
|
||||
import common.packet.CPacketAction;
|
||||
import common.packet.CPacketAction.Action;
|
||||
import common.util.ExtMath;
|
||||
|
||||
public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> implements ButtonCallback
|
||||
|
@ -65,7 +66,7 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> impleme
|
|||
this.descField.setText(entry == null ? "" : (entry.character == null ? "*neuer Charakter*" : String.format(TextColor.GRAY + "[%s%s" + TextColor.GRAY + "]\n" + TextColor.RESET + "%s", entry.character.align().color, entry.character.align().display, entry.character.info() == null ? "*keine Beschreibung vorhanden*" : this.getSelected().character.info())));
|
||||
this.actionButtom.setText(entry != null && entry.character == null ? "Charakter erstellen" : "Charakter spielen");
|
||||
this.actionButtom.enabled = entry != null && !entry.initial;
|
||||
this.deleteButtom.enabled = entry != null && entry.character != null && !entry.initial;
|
||||
this.deleteButtom.enabled = !this.gm.charEditor && entry != null && entry.character != null && !entry.initial;
|
||||
}
|
||||
|
||||
public void init(int width, int height)
|
||||
|
@ -77,17 +78,18 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> impleme
|
|||
for(PlayerCharacter character : this.gm.characterList) {
|
||||
this.elements.add(new CharacterEntry(selected == this.elements.size() ? new PlayerCharacter(character.name(), character.info(), character.align(), this.gm.player.worldObj.dimension.getFormattedName(false), this.gm.player.getPosition(), character.type(), this.gm.player.experienceLevel) : character, selected == this.elements.size()));
|
||||
}
|
||||
if(!this.gm.charEditor)
|
||||
this.elements.add(new CharacterEntry(null, false));
|
||||
this.setSelected(ExtMath.clampi(selected, -1, this.elements.size() - 1));
|
||||
this.descField = this.add(new Area(width - 300, 32, 300, height - 64, ""));
|
||||
this.deleteButtom = this.add(new ActButton(width / 2 - 302, height - 30, 200, 0, this, "Charakter löschen"));
|
||||
this.actionButtom = this.add(new ActButton(width / 2 - 100, height - 30, 200, 0, this, ""));
|
||||
this.add(new NavButton(width / 2 + 102, height - 30, 200, 0, GuiMenu.INSTANCE, "Abbrechen"));
|
||||
this.add(new NavButton(width / 2 + 102, height - 30, 200, 0, this.gm.charEditor ? GuiChar.INSTANCE : GuiMenu.INSTANCE, this.gm.charEditor ? "Zurück" : "Abbrechen"));
|
||||
this.updateButtons();
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return "Charakter anpassen";
|
||||
return "Charakter auswählen";
|
||||
}
|
||||
|
||||
public int getSlotHeight()
|
||||
|
@ -102,7 +104,7 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> impleme
|
|||
if(entry.character == null)
|
||||
this.gm.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.OPEN_EDITOR));
|
||||
else
|
||||
this.gm.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.SELECT_CHARACTER, this.selectedElement));
|
||||
this.gm.getNetHandler().addToSendQueue(new CPacketAction(GuiCharacters.this.gm.charEditor ? Action.CANCEL_EDITOR : CPacketAction.Action.SELECT_CHARACTER, this.selectedElement));
|
||||
}
|
||||
else if(elem == this.deleteButtom && entry.character != null) {
|
||||
this.gm.displayGuiScreen(new GuiConfirm(new GuiConfirm.Callback() {
|
||||
|
|
|
@ -2427,7 +2427,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
NetHandler.checkThread(packetIn, this, this.server);
|
||||
|
||||
CPacketAction.Action action = packetIn.getAction();
|
||||
if(this.charEditor != (action == Action.SET_ALIGN || action == Action.SET_SPECIES || action == Action.SET_CLASS || action == Action.SET_HEIGHT || action == Action.CLOSE_EDITOR)) // {
|
||||
if(this.charEditor != (action == Action.SET_ALIGN || action == Action.SET_SPECIES || action == Action.SET_CLASS || action == Action.SET_HEIGHT || action == Action.CLOSE_EDITOR || action == Action.CANCEL_EDITOR)) // {
|
||||
// if(this.local && action == Action.CLOSE_EDITOR)
|
||||
// this.server.setDone();
|
||||
return;
|
||||
|
@ -2465,6 +2465,17 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
break;
|
||||
}
|
||||
|
||||
case CANCEL_EDITOR: {
|
||||
int index = packetIn.getAuxData();
|
||||
if(index >= this.characters.size() || index < 0)
|
||||
return;
|
||||
this.charEditor = false;
|
||||
this.server.swapPlayer(this, this.characters.get(index), null);
|
||||
this.selected = index;
|
||||
this.sendPacket(new SPacketCharacterList(this.selected));
|
||||
break;
|
||||
}
|
||||
|
||||
case SELECT_CHARACTER: {
|
||||
int index = packetIn.getAuxData();
|
||||
if(index == this.selected || index >= this.characters.size() || index < 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue