From befb85564d0cf2ff097addab12c96700621cfb1f Mon Sep 17 00:00:00 2001 From: "Luis C.M" <42545778+c0508383@users.noreply.github.com> Date: Wed, 8 Nov 2023 23:10:31 -0600 Subject: [PATCH] Added animation options and frame options subguis --- .../npcs/client/gui/SubGuiAnimationFrame.java | 19 +++++++++------- .../client/gui/SubGuiAnimationOptions.java | 19 +++++++++------- .../gui/global/GuiNPCEditAnimation.java | 22 +++++++++++++++---- .../gui/global/GuiNPCManageAnimations.java | 7 ++++++ .../assets/customnpcs/lang/en_US.lang | 2 ++ 5 files changed, 49 insertions(+), 20 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiAnimationFrame.java b/src/main/java/noppes/npcs/client/gui/SubGuiAnimationFrame.java index 5d7abbb4e..f719b649b 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiAnimationFrame.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiAnimationFrame.java @@ -9,6 +9,7 @@ public class SubGuiAnimationFrame extends SubGuiInterface implements ITextfieldL public SubGuiAnimationFrame(Frame editingFrame) { this.editingFrame = editingFrame; + setBackground("smallbg.png"); } @Override @@ -16,23 +17,23 @@ public class SubGuiAnimationFrame extends SubGuiInterface implements ITextfieldL super.initGui(); // //customized - button, enables all the following options. - this.addLabel(new GuiNpcLabel(10, "animation.customized", guiLeft, guiTop + 44, 0xFFFFFF)); - this.addButton(new GuiNpcButton(10, guiLeft + 60, guiTop + 38, 30, 20, new String[]{"gui.yes", "gui.no"}, editingFrame.isCustomized() ? 0 : 1)); + this.addLabel(new GuiNpcLabel(10, "animation.customized", guiLeft + 5, guiTop + 16)); + this.addButton(new GuiNpcButton(10, guiLeft + 65, guiTop + 10, 30, 20, new String[]{"gui.yes", "gui.no"}, editingFrame.isCustomized() ? 0 : 1)); if (editingFrame.isCustomized()) { // //speed - textfield - this.addLabel(new GuiNpcLabel(11, "stats.speed", guiLeft, guiTop + 64, 0xFFFFFF)); - this.addTextField(new GuiNpcTextField(11, this, guiLeft + 60, guiTop + 60, 30, 15, editingFrame.speed + "")); + this.addLabel(new GuiNpcLabel(11, "stats.speed", guiLeft + 5, guiTop + 36)); + this.addTextField(new GuiNpcTextField(11, this, guiLeft + 65, guiTop + 32, 30, 15, editingFrame.speed + "")); this.getTextField(11).floatsOnly = true; this.getTextField(11).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 1.0F); // //smooth - button - this.addLabel(new GuiNpcLabel(12, "animation.smoothing", guiLeft, guiTop + 84, 0xFFFFFF)); - this.addButton(new GuiNpcButton(12, guiLeft + 55, guiTop + 78, 60, 20, new String[]{"animation.smooth", "animation.linear", "gui.none"}, editingFrame.smooth)); + this.addLabel(new GuiNpcLabel(12, "animation.smoothing", guiLeft + 5, guiTop + 58)); + this.addButton(new GuiNpcButton(12, guiLeft + 65, guiTop + 52, 60, 20, new String[]{"animation.smooth", "animation.linear", "gui.none"}, editingFrame.smooth)); // //ticks - button - this.addLabel(new GuiNpcLabel(13, "animation.tickType", guiLeft, guiTop + 104, 0xFFFFFF)); - this.addButton(new GuiNpcButton(13, guiLeft + 55, guiTop + 98, 75, 20, new String[]{"animation.renderTicks", "animation.mcTicks"}, editingFrame.renderTicks ? 0 : 1)); + this.addLabel(new GuiNpcLabel(13, "animation.tickType", guiLeft + 5, guiTop + 78)); + this.addButton(new GuiNpcButton(13, guiLeft + 65, guiTop + 72, 75, 20, new String[]{"animation.renderTicks", "animation.mcTicks"}, editingFrame.renderTicks ? 0 : 1)); } } @@ -48,6 +49,8 @@ public class SubGuiAnimationFrame extends SubGuiInterface implements ITextfieldL } else if (guibutton.id == 13 && editingFrame != null) { editingFrame.renderTicks = value == 0; } + + initGui(); } @Override diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiAnimationOptions.java b/src/main/java/noppes/npcs/client/gui/SubGuiAnimationOptions.java index a04bd690b..4a0724644 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiAnimationOptions.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiAnimationOptions.java @@ -11,6 +11,7 @@ public class SubGuiAnimationOptions extends SubGuiInterface { public SubGuiAnimationOptions(Animation animation) { this.animation = animation; + setBackground("smallbg.png"); } @Override @@ -18,20 +19,20 @@ public class SubGuiAnimationOptions extends SubGuiInterface { super.initGui(); // //ticks - button - this.addLabel(new GuiNpcLabel(10, "animation.tickType", guiLeft, guiTop + 86, 0xFFFFFF)); - this.addButton(new GuiNpcButton(10, guiLeft + 55, guiTop + 80, 75, 20, new String[]{"animation.renderTicks", "animation.mcTicks"}, animation.renderTicks ? 0 : 1)); + this.addLabel(new GuiNpcLabel(10, "animation.tickType", guiLeft + 5, guiTop + 16)); + this.addButton(new GuiNpcButton(10, guiLeft + 60, guiTop + 10, 75, 20, new String[]{"animation.renderTicks", "animation.mcTicks"}, animation.renderTicks ? 0 : 1)); // //whileStanding - button - this.addLabel(new GuiNpcLabel(11, "animation.whileStanding", guiLeft, guiTop + 106, 0xFFFFFF)); - this.addButton(new GuiNpcButton(11, guiLeft + 75, guiTop + 100, 30, 20, new String[]{"gui.yes", "gui.no"}, animation.whileStanding ? 0 : 1)); + this.addLabel(new GuiNpcLabel(11, "animation.whileStanding", guiLeft + 5, guiTop + 36)); + this.addButton(new GuiNpcButton(11, guiLeft + 80, guiTop + 30, 30, 20, new String[]{"gui.yes", "gui.no"}, animation.whileStanding ? 0 : 1)); // //whileAttacking - button - this.addLabel(new GuiNpcLabel(12, "animation.whileAttacking", guiLeft, guiTop + 126, 0xFFFFFF)); - this.addButton(new GuiNpcButton(12, guiLeft + 75, guiTop + 120, 30, 20, new String[]{"gui.yes", "gui.no"}, animation.whileAttacking ? 0 : 1)); + this.addLabel(new GuiNpcLabel(12, "animation.whileAttacking", guiLeft + 5, guiTop + 56)); + this.addButton(new GuiNpcButton(12, guiLeft + 80, guiTop + 50, 30, 20, new String[]{"gui.yes", "gui.no"}, animation.whileAttacking ? 0 : 1)); // //whileMoving - button - this.addLabel(new GuiNpcLabel(13, "animation.whileMoving", guiLeft, guiTop + 146, 0xFFFFFF)); - this.addButton(new GuiNpcButton(13, guiLeft + 75, guiTop + 140, 30, 20, new String[]{"gui.yes", "gui.no"}, animation.whileMoving ? 0 : 1)); + this.addLabel(new GuiNpcLabel(13, "animation.whileMoving", guiLeft + 5, guiTop + 76)); + this.addButton(new GuiNpcButton(13, guiLeft + 80, guiTop + 70, 30, 20, new String[]{"gui.yes", "gui.no"}, animation.whileMoving ? 0 : 1)); } @Override @@ -48,5 +49,7 @@ public class SubGuiAnimationOptions extends SubGuiInterface { } else if (guibutton.id == 13) { animation.whileMoving = value == 0; } + + initGui(); } } 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 fe11c07f9..dcc0dc76d 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java @@ -3,6 +3,8 @@ package noppes.npcs.client.gui.global; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.client.gui.SubGuiAnimationFrame; +import noppes.npcs.client.gui.SubGuiAnimationOptions; import noppes.npcs.controllers.data.AnimationData; import noppes.npcs.client.Client; import noppes.npcs.client.gui.util.*; @@ -160,6 +162,8 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield this.addLabel(new GuiNpcLabel(33, "animation.loopStart", guiLeft + animationX, guiTop + animationY + 66, 0xFFFFFF)); this.addButton(new GuiNpcButton(33, guiLeft + animationX + 55, guiTop + animationY + 60, 75, 20, animation.loop == -1 ? "No Looping" : "Frame " + animation.loop)); + this.addButton(new GuiNpcButton(34,guiLeft + animationX, guiTop + animationY + 80, 120, 20, "animation.animationOptions")); + //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -168,7 +172,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield int frameX = animationX; int frameY = playPauseY + 100; - this.addLabel(new GuiNpcLabel(50, "animation.frame", guiLeft + frameX + 40, guiTop + frameY, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(50, "animation.frame", guiLeft + frameX + 50, guiTop + frameY, 0xFFFFFF)); // //duration - textfield this.addLabel(new GuiNpcLabel(51, "animation.duration", guiLeft + frameX, guiTop + frameY + 15, 0xFFFFFF)); @@ -176,6 +180,8 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield this.getTextField(51).integersOnly = true; this.getTextField(51).setMinMaxDefaultFloat(0, Integer.MAX_VALUE, 10); + this.addButton(new GuiNpcButton(52,guiLeft + frameX, guiTop + frameY + 29, 120, 20, "animation.frameOptions")); + int bodyPartX = 280; int bodyPartY = -5; @@ -350,6 +356,10 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield } else if (guibutton.id == 93) { this.playingAnimation = false; data.animation.paused = false; + } else if (guibutton.id == 34) { + setSubGui(new SubGuiAnimationOptions(this.animation)); + } else if (guibutton.id == 52) { + setSubGui(new SubGuiAnimationFrame(editingFrame)); } initGui(); @@ -409,9 +419,13 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield @Override public void close() { - if (animation != null) { - Client.sendData(EnumPacketServer.AnimationSave, animation.id, animation.writeToNBT()); + if (!this.hasSubGui()) { + if (animation != null) { + Client.sendData(EnumPacketServer.AnimationSave, animation.id, animation.writeToNBT()); + } + displayGuiScreen(parent); + } else { + closeSubGui(this.getSubGui()); } - displayGuiScreen(parent); } } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java index 80df73260..d8d031bf4 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java @@ -68,6 +68,13 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol data.animation.smooth = animation.smooth; data.animation.renderTicks = animation.renderTicks; data.animation.loop = 0; + + if (this.animation.frames.size() > 0) { + Frame firstFrame = new Frame(); + firstFrame.parent = data.animation; + firstFrame.readFromNBT(this.animation.frames.get(0).writeToNBT()); + data.animation.addFrame(firstFrame); + } } if (animation != null) { diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index f901b4992..52b4b0d21 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -1087,6 +1087,8 @@ animation.addFrame=Add a frame to continue! animation.playing=Playing animation.paused=Paused animation.stopped=Stopped +animation.animationOptions=Animation Options +animation.frameOptions=Frame Options guard.creepers=Attack Creepers guard.animals=Attack Animals