From 2dade38396defc9b2b8cb8d1d8f8487b339ca4c2 Mon Sep 17 00:00:00 2001 From: luisc Date: Wed, 8 Nov 2023 18:21:14 -0600 Subject: [PATCH] Separated out animation, frame, and frame part options in the animation editor. Consolidated less-used animation and frame options into subguis that will later be opened through buttons in the editor. --- .../npcs/client/gui/SubGuiAnimationFrame.java | 59 +++ .../client/gui/SubGuiAnimationOptions.java | 52 +++ .../gui/global/GuiNPCEditAnimation.java | 339 ++++++++---------- 3 files changed, 260 insertions(+), 190 deletions(-) create mode 100644 src/main/java/noppes/npcs/client/gui/SubGuiAnimationFrame.java create mode 100644 src/main/java/noppes/npcs/client/gui/SubGuiAnimationOptions.java diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiAnimationFrame.java b/src/main/java/noppes/npcs/client/gui/SubGuiAnimationFrame.java new file mode 100644 index 000000000..b42aad538 --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/SubGuiAnimationFrame.java @@ -0,0 +1,59 @@ +package noppes.npcs.client.gui; + +import net.minecraft.client.gui.GuiButton; +import noppes.npcs.client.gui.util.*; +import noppes.npcs.controllers.data.Frame; + +public class SubGuiAnimationFrame extends SubGuiInterface implements ITextfieldListener { + private final Frame editingFrame; + + public SubGuiAnimationFrame(Frame editingFrame) { + this.editingFrame = editingFrame; + } + + @Override + public void initGui() { + super.initGui(); + // + //customized - button, enables all the following options. + this.addLabel(new GuiNpcLabel(52, "animation.customized", guiLeft, guiTop + 44, 0xFFFFFF)); + this.addButton(new GuiNpcButton(53, guiLeft + 60, guiTop + 38, 30, 20, new String[]{"gui.yes", "gui.no"}, editingFrame.isCustomized() ? 0 : 1)); + if (editingFrame.isCustomized()) { + // + //speed - textfield + this.addLabel(new GuiNpcLabel(131, "stats.speed", guiLeft, guiTop + 64, 0xFFFFFF)); + this.addTextField(new GuiNpcTextField(132, this, guiLeft + 60, guiTop + 60, 30, 15, editingFrame.speed + "")); + this.getTextField(132).floatsOnly = true; + this.getTextField(132).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 1.0F); + // + //smooth - button + this.addLabel(new GuiNpcLabel(133, "animation.smoothing", guiLeft, guiTop + 84, 0xFFFFFF)); + this.addButton(new GuiNpcButton(134, guiLeft + 55, guiTop + 78, 60, 20, new String[]{"animation.smooth", "animation.linear", "gui.none"}, editingFrame.smooth)); + // + //ticks - button + this.addLabel(new GuiNpcLabel(135, "animation.tickType", guiLeft, guiTop + 104, 0xFFFFFF)); + this.addButton(new GuiNpcButton(136, guiLeft + 55, guiTop + 98, 75, 20, new String[]{"animation.renderTicks", "animation.mcTicks"}, editingFrame.renderTicks ? 0 : 1)); + } + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + int value = ((GuiNpcButton)guibutton).getValue(); + + if (guibutton.id == 53 && editingFrame != null) { + editingFrame.setCustomized(!editingFrame.isCustomized()); + } else if (guibutton.id == 134 && editingFrame != null) { + editingFrame.smooth = (byte) value; + } else if (guibutton.id == 136 && editingFrame != null) { + editingFrame.renderTicks = value == 0; + } + } + + @Override + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 132 && this.editingFrame != null) { + this.editingFrame.speed = textfield.getFloat(); + } + } +} diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiAnimationOptions.java b/src/main/java/noppes/npcs/client/gui/SubGuiAnimationOptions.java new file mode 100644 index 000000000..4da1138d0 --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/SubGuiAnimationOptions.java @@ -0,0 +1,52 @@ +package noppes.npcs.client.gui; + +import net.minecraft.client.gui.GuiButton; +import noppes.npcs.client.gui.util.GuiNpcButton; +import noppes.npcs.client.gui.util.GuiNpcLabel; +import noppes.npcs.client.gui.util.SubGuiInterface; +import noppes.npcs.controllers.data.Animation; + +public class SubGuiAnimationOptions extends SubGuiInterface { + private final Animation animation; + + public SubGuiAnimationOptions(Animation animation) { + this.animation = animation; + } + + @Override + public void initGui() { + super.initGui(); + // + //ticks - button + this.addLabel(new GuiNpcLabel(35, "animation.tickType", guiLeft, guiTop + 86, 0xFFFFFF)); + this.addButton(new GuiNpcButton(36, guiLeft + 55, guiTop + 80, 75, 20, new String[]{"animation.renderTicks", "animation.mcTicks"}, animation.renderTicks ? 0 : 1)); + // + //whileStanding - button + this.addLabel(new GuiNpcLabel(39, "animation.whileStanding", guiLeft, guiTop + 106, 0xFFFFFF)); + this.addButton(new GuiNpcButton(40, guiLeft + 75, guiTop + 100, 30, 20, new String[]{"gui.yes", "gui.no"}, animation.whileStanding ? 0 : 1)); + // + //whileAttacking - button + this.addLabel(new GuiNpcLabel(41, "animation.whileAttacking", guiLeft, guiTop + 126, 0xFFFFFF)); + this.addButton(new GuiNpcButton(42, guiLeft + 75, guiTop + 120, 30, 20, new String[]{"gui.yes", "gui.no"}, animation.whileAttacking ? 0 : 1)); + // + //whileMoving - button + this.addLabel(new GuiNpcLabel(43, "animation.whileMoving", guiLeft, guiTop + 146, 0xFFFFFF)); + this.addButton(new GuiNpcButton(44, guiLeft + 75, guiTop + 140, 30, 20, new String[]{"gui.yes", "gui.no"}, animation.whileMoving ? 0 : 1)); + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + int value = ((GuiNpcButton)guibutton).getValue(); + + if (guibutton.id == 36) { + animation.renderTicks = value == 0; + } else if (guibutton.id == 40) { + animation.whileStanding = value == 0; + } else if (guibutton.id == 42) { + animation.whileAttacking = value == 0; + } else if (guibutton.id == 44) { + animation.whileMoving = value == 0; + } + } +} diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java index d78a4975d..9dca5927f 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java @@ -22,7 +22,6 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield private final Animation animation; private EnumAnimationPart editingPart = EnumAnimationPart.HEAD; - private int editingMode = 0; private int frameIndex = 0; public boolean playingAnimation = false; private Frame prevFrame; @@ -32,7 +31,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield public GuiNPCEditAnimation(GuiScreen parent, Animation animation, EntityNPCInterface npc) { super((EntityCustomNpc) npc); this.parent = parent; - xOffset -= 20; + xOffset = 0; yOffset = -45; this.animation = animation; @@ -97,188 +96,174 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield } } - editingMode %= 3; if (animation.loop >= animation.frames.size()) { animation.loop = -1; } - this.addLabel(new GuiNpcLabel(10, "animation.frames", guiLeft + 9 + 145, guiTop + 180, 0xFFFFFF)); - this.addButton(new GuiNpcButton(11, guiLeft - 45 + 150, guiTop + 189, 45, 20, "gui.add")); + this.addLabel(new GuiNpcLabel(10, "animation.frames", guiLeft + 40, guiTop + 176, 0xFFFFFF)); + this.addButton(new GuiNpcButton(11, guiLeft - 10, guiTop + 189, 45, 20, "gui.add")); if (!animation.frames.isEmpty()) { - this.addButton(new GuiNpcButton(12, guiLeft + 150, guiTop + 189, 45, 20, "gui.remove")); - this.addButton(new GuiNpcButton(13, guiLeft + 45 + 150, guiTop + 189, 45, 20, "gui.copy")); - this.addButton(new GuiNpcButton(14, guiLeft - 8 + 145, guiTop + 210, 20, 20, "<")); - this.addTextField(new GuiNpcTextField(15, this, guiLeft + 17 + 145, guiTop + 212, 20, 17, frameIndex + "")); + this.addButton(new GuiNpcButton(12, guiLeft + 35, guiTop + 189, 45, 20, "gui.remove")); + this.addButton(new GuiNpcButton(13, guiLeft + 80, guiTop + 189, 45, 20, "gui.copy")); + this.addButton(new GuiNpcButton(14, guiLeft + 22, guiTop + 210, 20, 20, "<")); + this.addTextField(new GuiNpcTextField(15, this, guiLeft + 47, guiTop + 212, 20, 17, frameIndex + "")); this.getTextField(15).integersOnly = true; this.getTextField(15).setMinMaxDefault(0, animation.frames.size() - 1, frameIndex); - this.addButton(new GuiNpcButton(16, guiLeft + 42 + 145, guiTop + 210, 20, 20, ">")); + this.addButton(new GuiNpcButton(16, guiLeft + 72, guiTop + 210, 20, 20, ">")); } - this.addButton(new GuiNpcButton(20, guiLeft + 290, guiTop - 5, 75, 20, new String[]{"animation.animation", "animation.frame", "animation.framePart"}, editingMode)); - + int playPauseX = 330; + int playPauseY = 10; String animTexture = "customnpcs:textures/gui/animation.png"; if (data.animation != null && data.animation.frames.size() > 0) { if (!this.playingAnimation || data.animation.paused) {//Play - this.addLabel(new GuiNpcLabel(90, data.animation.paused ? "animation.paused" : "animation.stopped", guiLeft - 15, guiTop + 206, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(90, data.animation.paused ? "animation.paused" : "animation.stopped", guiLeft + playPauseX - 15, guiTop + playPauseY + 206, 0xFFFFFF)); if (data.animation.paused) { - this.addLabel(new GuiNpcLabel(94, "", guiLeft + 21, guiTop + 206, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(94, "", guiLeft + playPauseX + 21, guiTop + playPauseY + 206, 0xFFFFFF)); } - this.addButton(new GuiTexturedButton(91, "", guiLeft + 35, guiTop + 200, 11, 20, animTexture, 18, 71)); + this.addButton(new GuiTexturedButton(91, "", guiLeft + playPauseX + 35, guiTop + playPauseY + 200, 11, 20, animTexture, 18, 71)); } else {//Pause - this.addLabel(new GuiNpcLabel(90, "animation.playing", guiLeft - 15, guiTop + 206, 0xFFFFFF)); - this.addLabel(new GuiNpcLabel(94, "", guiLeft + 20, guiTop + 206, 0xFFFFFF)); - this.addButton(new GuiTexturedButton(92, "", guiLeft + 35, guiTop + 200, 14, 20, animTexture, 0, 71)); + this.addLabel(new GuiNpcLabel(90, "animation.playing", guiLeft + playPauseX - 15, guiTop + playPauseY + 206, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(94, "", guiLeft + playPauseX + 20, guiTop + playPauseY + 206, 0xFFFFFF)); + this.addButton(new GuiTexturedButton(92, "", guiLeft + playPauseX + 35, guiTop + playPauseY + 200, 14, 20, animTexture, 0, 71)); } if (this.playingAnimation) {//Stop - this.addButton(new GuiTexturedButton(93, "", guiLeft + 55, guiTop + 200, 14, 20, animTexture, 33, 71)); + this.addButton(new GuiTexturedButton(93, "", guiLeft + playPauseX + 55, guiTop + playPauseY + 200, 14, 20, animTexture, 33, 71)); } } - if (editingMode == 0) { - //name - textfield - // Send the old animation name (string selected on the scroll). - // On the server side, if the new animation's name is different from the old one but already exists, - // do not change the name (set the name to the old animation name after the animation is read from NBT). - this.addTextField(new GuiNpcTextField(30, this, guiLeft + 270, guiTop + 18, 100, 15, animation.name)); - // - //speed - textfield - this.addLabel(new GuiNpcLabel(31, "stats.speed", guiLeft + 270, guiTop + 44, 0xFFFFFF)); - this.addTextField(new GuiNpcTextField(32, this, guiLeft + 310, guiTop + 40, 30, 15, animation.speed + "")); - this.getTextField(32).floatsOnly = true; - this.getTextField(32).setMinMaxDefaultFloat(0,Float.MAX_VALUE,1.0F); - // - //smooth - button - this.addLabel(new GuiNpcLabel(33, "animation.smoothing", guiLeft + 270, guiTop + 64, 0xFFFFFF)); - this.addButton(new GuiNpcButton(34, guiLeft + 325, guiTop + 58, 60, 20, new String[]{"animation.smooth", "animation.linear", "gui.none"}, animation.smooth)); - // - //ticks - button - this.addLabel(new GuiNpcLabel(35, "animation.tickType", guiLeft + 270, guiTop + 104, 0xFFFFFF)); - this.addButton(new GuiNpcButton(36, guiLeft + 325, guiTop + 98, 75, 20, new String[]{"animation.renderTicks", "animation.mcTicks"}, animation.renderTicks ? 0 : 1)); - // - //loop - button - this.addLabel(new GuiNpcLabel(37, "animation.loopStart", guiLeft + 270, guiTop + 84, 0xFFFFFF)); - this.addButton(new GuiNpcButton(38, guiLeft + 325, guiTop + 78, 75, 20, animation.loop == -1 ? "No Looping" : "Frame " + animation.loop)); - // - //whileStanding - button - this.addLabel(new GuiNpcLabel(39, "animation.whileStanding", guiLeft + 270, guiTop + 124, 0xFFFFFF)); - this.addButton(new GuiNpcButton(40, guiLeft + 345, guiTop + 118, 30, 20, new String[]{"gui.yes", "gui.no"}, animation.whileStanding ? 0 : 1)); - // - //whileAttacking - button - this.addLabel(new GuiNpcLabel(41, "animation.whileAttacking", guiLeft + 270, guiTop + 144, 0xFFFFFF)); - this.addButton(new GuiNpcButton(42, guiLeft + 345, guiTop + 138, 30, 20, new String[]{"gui.yes", "gui.no"}, animation.whileAttacking ? 0 : 1)); - // - //whileMoving - button - this.addLabel(new GuiNpcLabel(43, "animation.whileMoving", guiLeft + 270, guiTop + 164, 0xFFFFFF)); - this.addButton(new GuiNpcButton(44, guiLeft + 345, guiTop + 158, 30, 20, new String[]{"gui.yes", "gui.no"}, animation.whileMoving ? 0 : 1)); + //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - } else if (editingFrame != null) { - if (editingMode == 1) { - // - //duration - textfield - this.addLabel(new GuiNpcLabel(50, "animation.duration", guiLeft + 270, guiTop + 25, 0xFFFFFF)); - this.addTextField(new GuiNpcTextField(51, this, guiLeft + 330, guiTop + 21, 30, 15, editingFrame.duration + "")); - this.getTextField(51).integersOnly = true; - this.getTextField(51).setMinMaxDefaultFloat(0, Integer.MAX_VALUE, 10); - // - //customized - button, enables all the following options. - this.addLabel(new GuiNpcLabel(52, "animation.customized", guiLeft + 270, guiTop + 44, 0xFFFFFF)); - this.addButton(new GuiNpcButton(53, guiLeft + 325, guiTop + 38, 30, 20, new String[]{"gui.yes", "gui.no"}, editingFrame.isCustomized() ? 0 : 1)); - if (editingFrame.isCustomized()) { - // - //speed - textfield - this.addLabel(new GuiNpcLabel(31, "stats.speed", guiLeft + 270, guiTop + 64, 0xFFFFFF)); - this.addTextField(new GuiNpcTextField(32, this, guiLeft + 330, guiTop + 60, 30, 15, editingFrame.speed + "")); - this.getTextField(32).floatsOnly = true; - this.getTextField(32).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 1.0F); - // - //smooth - button - this.addLabel(new GuiNpcLabel(33, "animation.smoothing", guiLeft + 270, guiTop + 84, 0xFFFFFF)); - this.addButton(new GuiNpcButton(34, guiLeft + 325, guiTop + 78, 60, 20, new String[]{"animation.smooth", "animation.linear", "gui.none"}, editingFrame.smooth)); - // - //ticks - button - this.addLabel(new GuiNpcLabel(35, "animation.tickType", guiLeft + 270, guiTop + 104, 0xFFFFFF)); - this.addButton(new GuiNpcButton(36, guiLeft + 325, guiTop + 98, 75, 20, new String[]{"animation.renderTicks", "animation.mcTicks"}, editingFrame.renderTicks ? 0 : 1)); - } - } else if (editingMode == 2) { - // - //6 body part textured buttons - //Add/remove part button - // 6 custom GUI textured buttons for each body part determine "this.currentPart (enum)". - // If the current frame doesn't have that part, the button will say "Add part" - // otherwise, the button will say "Remove", and more options for editing the part become available: - // + int animationX = -10; + int animationY = -2; - //Head - this.addButton(new GuiTexturedButton(60, "",guiLeft + 270, guiTop + 18,22,23, animTexture,0,0)); - //Body - this.addButton(new GuiTexturedButton(61, "",guiLeft + 270, guiTop + 43,22,23, animTexture,24,0)); - //Right Arm - this.addButton(new GuiTexturedButton(62, "",guiLeft + 261, guiTop + 43,8,23, animTexture,48,0)); - //Left Arm - this.addButton(new GuiTexturedButton(63, "",guiLeft + 296, guiTop + 43,8,23, animTexture,48,0)); - //Right Leg - this.addButton(new GuiTexturedButton(64, "",guiLeft + 271, guiTop + 68,10,23, animTexture,58,0)); - //Left Leg - this.addButton(new GuiTexturedButton(65, "",guiLeft + 282, guiTop + 68,10,23, animTexture,58,0)); - //Full Body - this.addButton(new GuiTexturedButton(66, "",guiLeft + 310, guiTop + 20,17,23, animTexture,70,0)); + //name - textfield + // Send the old animation name (string selected on the scroll). + // On the server side, if the new animation's name is different from the old one but already exists, + // do not change the name (set the name to the old animation name after the animation is read from NBT). + this.addTextField(new GuiNpcTextField(30, this, guiLeft + animationX, guiTop + animationY, 100, 15, animation.name)); + // + //speed - textfield + this.addLabel(new GuiNpcLabel(31, "stats.speed", guiLeft + animationX, guiTop + animationY + 24, 0xFFFFFF)); + this.addTextField(new GuiNpcTextField(32, this, guiLeft + animationX + 40, guiTop + animationY + 22, 30, 15, animation.speed + "")); + this.getTextField(32).floatsOnly = true; + this.getTextField(32).setMinMaxDefaultFloat(0,Float.MAX_VALUE,1.0F); + // + //smooth - button + this.addLabel(new GuiNpcLabel(33, "animation.smoothing", guiLeft + animationX, guiTop + animationY + 46, 0xFFFFFF)); + this.addButton(new GuiNpcButton(34, guiLeft + animationX + 55, guiTop + animationY + 40, 60, 20, new String[]{"animation.smooth", "animation.linear", "gui.none"}, animation.smooth)); + // + //loop - button + this.addLabel(new GuiNpcLabel(37, "animation.loopStart", guiLeft + animationX, guiTop + animationY + 66, 0xFFFFFF)); + this.addButton(new GuiNpcButton(38, guiLeft + animationX + 55, guiTop + animationY + 60, 75, 20, animation.loop == -1 ? "No Looping" : "Frame " + animation.loop)); - for (int i = 0; i < 7; i++) { - if (this.buttons.containsKey(60 + i)) { - ((GuiTexturedButton) this.getButton(60 + i)).scale = 1.2F; - if (!editingFrame.frameParts.containsKey(EnumAnimationPart.values()[i])) { - ((GuiTexturedButton) this.getButton(60 + i)).textureX += 96; - } - } - } + //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - if (editingPart != null) { - //remove part button - this.addLabel(new GuiNpcLabel(67, editingPart.part.name(), guiLeft + 320, guiTop + 60, 0xFFFFFF)); - this.addButton(new GuiNpcButton(68, guiLeft + 315, guiTop + 75, 60, 20, "gui.remove")); - // - //rotation - 3 textfields - this.addLabel(new GuiNpcLabel(70, "animation.rotations", guiLeft + 270, guiTop + 105, 0xFFFFFF)); - this.addTextField(new GuiNpcTextField(71, this, guiLeft + 270, guiTop + 117, 35, 15, editingPart.rotation[0] + "")); - this.getTextField(71).floatsOnly = true; - this.getTextField(71).setMinMaxDefaultFloat(-Float.MAX_VALUE, Float.MAX_VALUE, 0); - this.addTextField(new GuiNpcTextField(72, this, guiLeft + 310, guiTop + 117, 35, 15, editingPart.rotation[1] + "")); - this.getTextField(72).floatsOnly = true; - this.getTextField(72).setMinMaxDefaultFloat(-Float.MAX_VALUE, Float.MAX_VALUE, 0); - this.addTextField(new GuiNpcTextField(73, this, guiLeft + 350, guiTop + 117, 35, 15, editingPart.rotation[2] + "")); - this.getTextField(73).floatsOnly = true; - this.getTextField(73).setMinMaxDefaultFloat(-Float.MAX_VALUE, Float.MAX_VALUE, 0); - // - //pivot - 3 textfields - this.addLabel(new GuiNpcLabel(80, "animation.pivots", guiLeft + 270, guiTop + 137, 0xFFFFFF)); - this.addTextField(new GuiNpcTextField(81, this, guiLeft + 270, guiTop + 149, 35, 15, editingPart.pivot[0] + "")); - this.getTextField(81).floatsOnly = true; - this.getTextField(81).setMinMaxDefaultFloat(-Float.MAX_VALUE, Float.MAX_VALUE, 0); - this.addTextField(new GuiNpcTextField(82, this, guiLeft + 310, guiTop + 149, 35, 15, editingPart.pivot[1] + "")); - this.getTextField(82).floatsOnly = true; - this.getTextField(82).setMinMaxDefaultFloat(-Float.MAX_VALUE, Float.MAX_VALUE, 0); - this.addTextField(new GuiNpcTextField(83, this, guiLeft + 350, guiTop + 149, 35, 15, editingPart.pivot[2] + "")); - this.getTextField(83).floatsOnly = true; - this.getTextField(83).setMinMaxDefaultFloat(-Float.MAX_VALUE, Float.MAX_VALUE, 0); - // - //customized - button, enables all the following options. - this.addLabel(new GuiNpcLabel(52, "animation.customized", guiLeft + 270, guiTop + 174, 0xFFFFFF)); - this.addButton(new GuiNpcButton(53, guiLeft + 325, guiTop + 168, 30, 20, new String[]{"gui.yes", "gui.no"}, editingPart.isCustomized() ? 0 : 1)); - if (editingPart.isCustomized()) { - // - //speed - textfield - this.addLabel(new GuiNpcLabel(31, "stats.speed", guiLeft + 270, guiTop + 194, 0xFFFFFF)); - this.addTextField(new GuiNpcTextField(32, this, guiLeft + 330, guiTop + 190, 30, 15, editingPart.speed + "")); - this.getTextField(32).floatsOnly = true; - this.getTextField(32).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 1.0F); - // - //smooth - button - this.addLabel(new GuiNpcLabel(33, "animation.smoothing", guiLeft + 270, guiTop + 214, 0xFFFFFF)); - this.addButton(new GuiNpcButton(34, guiLeft + 325, guiTop + 208, 60, 20, new String[]{"animation.smooth", "animation.linear", "gui.none"}, editingPart.smooth)); + if (editingFrame != null) { + int frameX = animationX; + int frameY = playPauseY + 100; + + this.addLabel(new GuiNpcLabel(49, "animation.frame", guiLeft + frameX + 40, guiTop + frameY, 0xFFFFFF)); + // + //duration - textfield + this.addLabel(new GuiNpcLabel(50, "animation.duration", guiLeft + frameX, guiTop + frameY + 15, 0xFFFFFF)); + this.addTextField(new GuiNpcTextField(51, this, guiLeft + frameX + 60, guiTop + frameY + 11, 30, 15, editingFrame.duration + "")); + this.getTextField(51).integersOnly = true; + this.getTextField(51).setMinMaxDefaultFloat(0, Integer.MAX_VALUE, 10); + + int bodyPartX = 280; + int bodyPartY = -5; + + // + //6 body part textured buttons + //Add/remove part button + // 6 custom GUI textured buttons for each body part determine "this.currentPart (enum)". + // If the current frame doesn't have that part, the button will say "Add part" + // otherwise, the button will say "Remove", and more options for editing the part become available: + // + + //Head + this.addButton(new GuiTexturedButton(60, "",guiLeft + bodyPartX, guiTop + bodyPartY,22,23, animTexture,0,0)); + //Body + this.addButton(new GuiTexturedButton(61, "",guiLeft + bodyPartX, guiTop + bodyPartY + 23,22,23, animTexture,24,0)); + //Right Arm + this.addButton(new GuiTexturedButton(62, "",guiLeft + bodyPartX - 9, guiTop + bodyPartY + 23,8,23, animTexture,48,0)); + //Left Arm + this.addButton(new GuiTexturedButton(63, "",guiLeft + bodyPartX + 26, guiTop + bodyPartY + 23,8,23, animTexture,48,0)); + //Right Leg + this.addButton(new GuiTexturedButton(64, "",guiLeft + bodyPartX + 1, guiTop + bodyPartY + 48,10,23, animTexture,58,0)); + //Left Leg + this.addButton(new GuiTexturedButton(65, "",guiLeft + bodyPartX + 12, guiTop + bodyPartY + 48,10,23, animTexture,58,0)); + //Full Body + this.addButton(new GuiTexturedButton(66, "",guiLeft + bodyPartX + 40, guiTop + bodyPartY + 2,17,23, animTexture,70,0)); + + for (int i = 0; i < 7; i++) { + if (this.buttons.containsKey(60 + i)) { + ((GuiTexturedButton) this.getButton(60 + i)).scale = 1.2F; + if (!editingFrame.frameParts.containsKey(EnumAnimationPart.values()[i])) { + ((GuiTexturedButton) this.getButton(60 + i)).textureX += 96; } } } + + //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + if (editingPart != null) { + //remove part button + this.addLabel(new GuiNpcLabel(67, editingPart.part.name(), guiLeft + bodyPartX + 50, guiTop + bodyPartY + 40, 0xFFFFFF)); + this.addButton(new GuiNpcButton(68, guiLeft + bodyPartX + 45, guiTop + bodyPartY + 55, 60, 20, "gui.remove")); + // + //rotation - 3 textfields + this.addLabel(new GuiNpcLabel(70, "animation.rotations", guiLeft + bodyPartX, guiTop + bodyPartY + 85, 0xFFFFFF)); + this.addTextField(new GuiNpcTextField(71, this, guiLeft + bodyPartX, guiTop + bodyPartY + 97, 35, 15, editingPart.rotation[0] + "")); + this.getTextField(71).floatsOnly = true; + this.getTextField(71).setMinMaxDefaultFloat(-Float.MAX_VALUE, Float.MAX_VALUE, 0); + this.addTextField(new GuiNpcTextField(72, this, guiLeft + bodyPartX + 40, guiTop + bodyPartY + 97, 35, 15, editingPart.rotation[1] + "")); + this.getTextField(72).floatsOnly = true; + this.getTextField(72).setMinMaxDefaultFloat(-Float.MAX_VALUE, Float.MAX_VALUE, 0); + this.addTextField(new GuiNpcTextField(73, this, guiLeft + bodyPartX + 80, guiTop + bodyPartY + 97, 35, 15, editingPart.rotation[2] + "")); + this.getTextField(73).floatsOnly = true; + this.getTextField(73).setMinMaxDefaultFloat(-Float.MAX_VALUE, Float.MAX_VALUE, 0); + // + //pivot - 3 textfields + this.addLabel(new GuiNpcLabel(80, "animation.pivots", guiLeft + bodyPartX, guiTop + bodyPartY + 117, 0xFFFFFF)); + this.addTextField(new GuiNpcTextField(81, this, guiLeft + bodyPartX, guiTop + bodyPartY + 129, 35, 15, editingPart.pivot[0] + "")); + this.getTextField(81).floatsOnly = true; + this.getTextField(81).setMinMaxDefaultFloat(-Float.MAX_VALUE, Float.MAX_VALUE, 0); + this.addTextField(new GuiNpcTextField(82, this, guiLeft + bodyPartX + 40, guiTop + bodyPartY + 129, 35, 15, editingPart.pivot[1] + "")); + this.getTextField(82).floatsOnly = true; + this.getTextField(82).setMinMaxDefaultFloat(-Float.MAX_VALUE, Float.MAX_VALUE, 0); + this.addTextField(new GuiNpcTextField(83, this, guiLeft + bodyPartX + 80, guiTop + bodyPartY + 129, 35, 15, editingPart.pivot[2] + "")); + this.getTextField(83).floatsOnly = true; + this.getTextField(83).setMinMaxDefaultFloat(-Float.MAX_VALUE, Float.MAX_VALUE, 0); + // + //customized - button, enables all the following options. + this.addLabel(new GuiNpcLabel(152, "animation.customized", guiLeft + bodyPartX, guiTop + bodyPartY + 154, 0xFFFFFF)); + this.addButton(new GuiNpcButton(153, guiLeft + bodyPartX + 55, guiTop + bodyPartY + 148, 30, 20, new String[]{"gui.yes", "gui.no"}, editingPart.isCustomized() ? 0 : 1)); + if (editingPart.isCustomized()) { + // + //speed - textfield + this.addLabel(new GuiNpcLabel(231, "stats.speed", guiLeft + bodyPartX, guiTop + bodyPartY + 174, 0xFFFFFF)); + this.addTextField(new GuiNpcTextField(232, this, guiLeft + bodyPartX + 60, guiTop + bodyPartY + 170, 30, 15, editingPart.speed + "")); + this.getTextField(232).floatsOnly = true; + this.getTextField(232).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 1.0F); + // + //smooth - button + this.addLabel(new GuiNpcLabel(233, "animation.smoothing", guiLeft + bodyPartX, guiTop + bodyPartY + 194, 0xFFFFFF)); + this.addButton(new GuiNpcButton(234, guiLeft + bodyPartX + 55, guiTop + bodyPartY + 190, 60, 20, new String[]{"animation.smooth", "animation.linear", "gui.none"}, editingPart.smooth)); + } + } + + //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- } else { this.addLabel(new GuiNpcLabel(50, "animation.addFrame", guiLeft + 270, guiTop + 100, 0xFFFFFF)); } @@ -328,8 +313,6 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield } } else if (guibutton.id == 16) { frameIndex++; - } else if (guibutton.id == 20) { - editingMode++; } else if (guibutton.id >= 60 && guibutton.id <= 66) {//Animation part buttons EnumAnimationPart enumPart = EnumAnimationPart.values()[guibutton.id-60]; if (editingFrame != null && !editingFrame.frameParts.containsKey(enumPart)) { @@ -340,34 +323,14 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield this.editingPart = enumPart; } else if (guibutton.id == 68 && editingFrame != null) { editingFrame.removePart(this.editingPart.name()); - } else if (guibutton.id == 53 && editingFrame != null) { - if (editingMode == 1) { - editingFrame.setCustomized(!editingFrame.isCustomized()); - } else if (editingMode == 2 && part != null) { - part.setCustomized(!part.isCustomized()); - } + } else if (guibutton.id == 153 && editingFrame != null && part != null) { + part.setCustomized(!part.isCustomized()); } else if (guibutton.id == 34) { - if (editingMode == 0) { - animation.smooth = (byte) value; - } else if (editingMode == 1 && editingFrame != null) { - editingFrame.smooth = (byte) value; - } else if (editingMode == 2 && part != null) { - part.smooth = (byte) value; - } - } else if (guibutton.id == 36) { - if (editingMode == 0) { - animation.renderTicks = value == 0; - } else if (editingMode == 1 && editingFrame != null) { - editingFrame.renderTicks = value == 0; - } + animation.smooth = (byte) value; + } else if (guibutton.id == 234 && part != null) { + part.smooth = (byte) value; } else if (guibutton.id == 38) { animation.loop++; - } else if (guibutton.id == 40) { - animation.whileStanding = value == 0; - } else if (guibutton.id == 42) { - animation.whileAttacking = value == 0; - } else if (guibutton.id == 44) { - animation.whileMoving = value == 0; } else if (guibutton.id == 91) { if (!this.playingAnimation || !data.isActive()) { animation.currentFrame = 0; @@ -432,13 +395,9 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield animation.frames.add(textfield.getInteger(),frame); frameIndex = textfield.getInteger(); } else if (textfield.id == 32) { - if (editingMode == 0) { - animation.speed = textfield.getFloat(); - } else if (editingMode == 1 && frame != null) { - frame.speed = textfield.getFloat(); - } else if (editingMode == 2 && part != null) { - part.speed = textfield.getFloat(); - } + animation.speed = textfield.getFloat(); + } else if (textfield.id == 232 && part != null) { + part.speed = textfield.getFloat(); } else if (textfield.id == 51 && frame != null) { frame.duration = textfield.getInteger(); } else if (textfield.id >= 71 && textfield.id <= 73 && part != null) {