From 21f9e3bdbc98cc89bd578cdd96722e806b815078 Mon Sep 17 00:00:00 2001 From: Kam Date: Thu, 9 Nov 2023 15:34:12 -0500 Subject: [PATCH 1/7] Fix AnimationSave Packet Error --- .../java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java | 2 +- .../noppes/npcs/client/gui/global/GuiNPCManageAnimations.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) 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 d135ee544..277e95d83 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java @@ -477,7 +477,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield public void close() { if (!this.hasSubGui()) { if (animation != null) { - Client.sendData(EnumPacketServer.AnimationSave, animation.id, animation.writeToNBT()); + Client.sendData(EnumPacketServer.AnimationSave, animation.writeToNBT()); } displayGuiScreen(parent); } else { 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 d8d031bf4..ec814a568 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java @@ -234,7 +234,6 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { if(guiCustomScroll.id == 0) { - save(); selected = scrollAnimations.getSelected(); Client.sendData(EnumPacketServer.AnimationGet, data.get(selected)); } From 1c68a74eb44f11deb500944544923d1a1c606b3a Mon Sep 17 00:00:00 2001 From: Kam Date: Thu, 9 Nov 2023 16:36:29 -0500 Subject: [PATCH 2/7] Reorganize Animation GUI spacing and positioning for everything --- .../gui/global/GuiNPCEditAnimation.java | 108 +++++++++++------- .../assets/customnpcs/lang/en_US.lang | 2 +- 2 files changed, 69 insertions(+), 41 deletions(-) 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 c1d5b63a8..366b64e03 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java @@ -31,6 +31,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield private GuiScreen parent; private long prevTick; private static int partEditMode; + private static int sliderSelection = 0; private GuiNpcSlider[] rotationSliders = new GuiNpcSlider[3]; private GuiNpcSlider[] pivotSliders = new GuiNpcSlider[3]; @@ -39,7 +40,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield super((EntityCustomNpc) npc); this.parent = parent; xOffset = 0; - yOffset = -45; + yOffset = -21; this.animation = animation; AnimationData data = npc.display.animationData; @@ -49,8 +50,12 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield int bodyPartX = 280; int bodyPartY = -5; for (int i = 0; i < 3; i++) { - this.rotationSliders[i] = new GuiNpcSlider(this, 90 + i, guiLeft + bodyPartX, guiTop + bodyPartY + 85 + 20 * i, 0.5F); - this.pivotSliders[i] = new GuiNpcSlider(this, 95 + i, guiLeft + bodyPartX, guiTop + bodyPartY + 150 + 20 * i, 0.5F); + int yOffset = 20; + if(i != 0) + yOffset += 3; + yOffset *= i; + this.rotationSliders[i] = new GuiNpcSlider(this, 90 + i, guiLeft + bodyPartX, guiTop + bodyPartY + 115 + yOffset, 0.5F); + this.pivotSliders[i] = new GuiNpcSlider(this, 95 + i, guiLeft + bodyPartX, guiTop + bodyPartY + 115 + yOffset, 0.5F); } } @@ -115,16 +120,16 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield } - 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")); + this.addLabel(new GuiNpcLabel(10, "animation.frames", guiLeft + 40, guiTop + 176 - 10, 0xFFFFFF)); + this.addButton(new GuiNpcButton(11, guiLeft - 10, guiTop + 189 - 10, 45, 20, "gui.add")); if (!animation.frames.isEmpty()) { - 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.addButton(new GuiNpcButton(12, guiLeft + 35, guiTop + 189 - 10, 45, 20, "gui.remove")); + this.addButton(new GuiNpcButton(13, guiLeft + 80, guiTop + 189 - 10, 45, 20, "gui.copy")); + this.addButton(new GuiNpcButton(14, guiLeft - 10, guiTop + 210 - 3, 20, 20, "<")); + this.addTextField(new GuiNpcTextField(15, this, guiLeft + 15, guiTop + 212 - 3, 20, 17, frameIndex + "")); this.getTextField(15).integersOnly = true; this.getTextField(15).setMinMaxDefault(0, animation.frames.size() - 1, frameIndex); - this.addButton(new GuiNpcButton(16, guiLeft + 72, guiTop + 210, 20, 20, ">")); + this.addButton(new GuiNpcButton(16, guiLeft + 40, guiTop + 210 - 3, 20, 20, ">")); } int playPauseX = 330; @@ -132,18 +137,18 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield 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(210, data.animation.paused ? "animation.paused" : "animation.stopped", guiLeft + playPauseX - 15, guiTop + playPauseY + 206, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(210, data.animation.paused ? "animation.paused" : "animation.stopped", guiLeft + playPauseX - 15, guiTop + playPauseY + 203, 0xFFFFFF)); if (data.animation.paused) { - this.addLabel(new GuiNpcLabel(211, "", guiLeft + playPauseX + 21, guiTop + playPauseY + 206, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(211, "", guiLeft + playPauseX + 21, guiTop + playPauseY + 203, 0xFFFFFF)); } - this.addButton(new GuiTexturedButton(200, "", guiLeft + playPauseX + 35, guiTop + playPauseY + 200, 11, 20, animTexture, 18, 71)); + this.addButton(new GuiTexturedButton(200, "", guiLeft + playPauseX + 35, guiTop + playPauseY + 197, 11, 20, animTexture, 18, 71)); } else {//Pause - this.addLabel(new GuiNpcLabel(212, "animation.playing", guiLeft + playPauseX - 15, guiTop + playPauseY + 206, 0xFFFFFF)); - this.addLabel(new GuiNpcLabel(213, "", guiLeft + playPauseX + 20, guiTop + playPauseY + 206, 0xFFFFFF)); - this.addButton(new GuiTexturedButton(201, "", guiLeft + playPauseX + 35, guiTop + playPauseY + 200, 14, 20, animTexture, 0, 71)); + this.addLabel(new GuiNpcLabel(212, "animation.playing", guiLeft + playPauseX - 15, guiTop + playPauseY + 203, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(213, "", guiLeft + playPauseX + 20, guiTop + playPauseY + 203, 0xFFFFFF)); + this.addButton(new GuiTexturedButton(201, "", guiLeft + playPauseX + 35, guiTop + playPauseY + 197, 14, 20, animTexture, 0, 71)); } if (this.playingAnimation) {//Stop - this.addButton(new GuiTexturedButton(202, "", guiLeft + playPauseX + 55, guiTop + playPauseY + 200, 14, 20, animTexture, 33, 71)); + this.addButton(new GuiTexturedButton(202, "", guiLeft + playPauseX + 55, guiTop + playPauseY + 197, 14, 20, animTexture, 33, 71)); } } @@ -158,7 +163,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield // 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)); + this.addTextField(new GuiNpcTextField(30, this, guiLeft + animationX, guiTop + animationY, 120, 15, animation.name)); // //speed - textfield this.addLabel(new GuiNpcLabel(31, "stats.speed", guiLeft + animationX, guiTop + animationY + 24, 0xFFFFFF)); @@ -168,13 +173,13 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield // //smooth - button this.addLabel(new GuiNpcLabel(32, "animation.smoothing", guiLeft + animationX, guiTop + animationY + 46, 0xFFFFFF)); - this.addButton(new GuiNpcButton(32, guiLeft + animationX + 55, guiTop + animationY + 40, 60, 20, new String[]{"animation.smooth", "animation.linear", "gui.none"}, animation.smooth)); + this.addButton(new GuiNpcButton(32, guiLeft + animationX + 55, guiTop + animationY + 40, 65, 20, new String[]{"animation.smooth", "animation.linear", "gui.none"}, animation.smooth)); // //loop - button - 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.addLabel(new GuiNpcLabel(33, "animation.loop", guiLeft + animationX, guiTop + animationY + 68, 0xFFFFFF)); + this.addButton(new GuiNpcButton(33, guiLeft + animationX + 55, guiTop + animationY + 62, 65, 20, animation.loop == -1 ? "gui.none" : "Frame " + animation.loop)); - this.addButton(new GuiNpcButton(34,guiLeft + animationX, guiTop + animationY + 80, 120, 20, "animation.animationOptions")); + this.addButton(new GuiNpcButton(34,guiLeft + animationX, guiTop + animationY + 84, 120, 20, "animation.animationOptions")); //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -184,7 +189,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield int frameX = animationX; int frameY = playPauseY + 100; - this.addLabel(new GuiNpcLabel(50, "animation.frame", guiLeft + frameX + 50, guiTop + frameY, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(50, "animation.frame", guiLeft + frameX + 50, guiTop + frameY - 3, 0xFFFFFF)); // //duration - textfield this.addLabel(new GuiNpcLabel(51, "animation.duration", guiLeft + frameX, guiTop + frameY + 15, 0xFFFFFF)); @@ -192,7 +197,7 @@ 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")); + this.addButton(new GuiNpcButton(52,guiLeft + frameX, guiTop + frameY + 31 , 120, 20, "animation.frameOptions")); int bodyPartX = 280; int bodyPartY = -5; @@ -238,27 +243,38 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield this.addLabel(new GuiNpcLabel(67, editingPart.part.name(), guiLeft + bodyPartX + 65, guiTop + bodyPartY + 20, 0xFFFFFF)); this.addButton(new GuiNpcButton(67, guiLeft + bodyPartX + 45, guiTop + bodyPartY + 35, 60, 20, "gui.remove")); - this.addButton(new GuiNpcButton(68, guiLeft + bodyPartX + 45, guiTop + bodyPartY + 55, 60, 20, new String[] {"Sliders","Manual"}, partEditMode)); + this.addButton(new GuiNpcButton(68, guiLeft + bodyPartX + 45, guiTop + bodyPartY + 57, 60, 20, new String[] {"Sliders","Manual"}, partEditMode)); if (partEditMode == 0) { - this.addLabel(new GuiNpcLabel(90, "Rot. X", guiLeft + bodyPartX, guiTop + bodyPartY + 92, 0xFFFFFF)); - this.addLabel(new GuiNpcLabel(91, "Rot. Y", guiLeft + bodyPartX, guiTop + bodyPartY + 112, 0xFFFFFF)); - this.addLabel(new GuiNpcLabel(92, "Rot. Z", guiLeft + bodyPartX, guiTop + bodyPartY + 132, 0xFFFFFF)); + this.addButton(new GuiNpcButton(69, guiLeft + bodyPartX, guiTop + bodyPartY + 80, 60, 20, "model.rotate")); + this.addButton(new GuiNpcButton(70, guiLeft + bodyPartX + 62, guiTop + bodyPartY + 80, 60, 20, "model.pivot")); - this.addLabel(new GuiNpcLabel(95, "Pivot X", guiLeft + bodyPartX, guiTop + bodyPartY + 157, 0xFFFFFF)); - this.addLabel(new GuiNpcLabel(96, "Pivot Y", guiLeft + bodyPartX, guiTop + bodyPartY + 177, 0xFFFFFF)); - this.addLabel(new GuiNpcLabel(97, "Pivot Z", guiLeft + bodyPartX, guiTop + bodyPartY + 197, 0xFFFFFF)); + this.getButton(69).setEnabled(sliderSelection == 1); + this.getButton(70).setEnabled(sliderSelection == 0); - for (int i = 0; i < 3; i++) { - this.rotationSliders[i].width = this.pivotSliders[i].width = 80; - this.rotationSliders[i].height = this.pivotSliders[i].height = 20; + if(sliderSelection == 0){ + for (int i = 0; i < 3; i++) { + this.rotationSliders[i].width = 110; + this.rotationSliders[i].height= 20; + this.rotationSliders[i].xPosition = guiLeft + bodyPartX + 10; + this.addSlider(this.rotationSliders[i]); + } - this.rotationSliders[i].xPosition = this.pivotSliders[i].xPosition = guiLeft + bodyPartX + 40; - this.rotationSliders[i].yPosition = guiTop + bodyPartY + 85 + 20 * i; - this.pivotSliders[i].yPosition = guiTop + bodyPartY + 150 + 20 * i; + this.addLabel(new GuiNpcLabel(90, "X", guiLeft + bodyPartX, guiTop + bodyPartY + 112, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(91, "Y", guiLeft + bodyPartX, guiTop + bodyPartY + 135, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(92, "Z", guiLeft + bodyPartX, guiTop + bodyPartY + 157, 0xFFFFFF)); + } + else { + for (int i = 0; i < 3; i++) { + this.pivotSliders[i].width = 110; + this.pivotSliders[i].height = 20; + this.pivotSliders[i].xPosition = guiLeft + bodyPartX + 10; + this.addSlider(this.pivotSliders[i]); + } - this.addSlider(this.rotationSliders[i]); - this.addSlider(this.pivotSliders[i]); + this.addLabel(new GuiNpcLabel(95, "X", guiLeft + bodyPartX, guiTop + bodyPartY + 112, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(96, "Y", guiLeft + bodyPartX, guiTop + bodyPartY + 135, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(97, "Z", guiLeft + bodyPartX, guiTop + bodyPartY + 157, 0xFFFFFF)); } } else { // @@ -385,7 +401,19 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield } partEditMode++; partEditMode %= 2; - } else if (guibutton.id == 83 && editingFrame != null && part != null) { + } else if (guibutton.id == 69 && editingFrame != null) { + if (partEditMode == 1) { + this.updateSliders(); + } + + sliderSelection = 0; + } else if (guibutton.id == 70 && editingFrame != null) { + if (partEditMode == 1) { + this.updateSliders(); + } + + sliderSelection = 1; + } else if (guibutton.id == 83 && editingFrame != null && part != null) { part.setCustomized(!part.isCustomized()); } else if (guibutton.id == 32) { animation.smooth = (byte) value; diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index 52b4b0d21..30985a0ae 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -1072,7 +1072,7 @@ animation.framePart=Frame Part animation.smoothing=Smoothing animation.linear=Linear animation.smooth=Smooth -animation.loopStart=Loop Start +animation.loop=Loop animation.tickType=Tick Type animation.mcTicks=MC Ticks animation.renderTicks=Render Ticks From 7e109200abb5f64780cbf15b2e99be5f3cd7e06b Mon Sep 17 00:00:00 2001 From: Kam Date: Thu, 9 Nov 2023 16:38:35 -0500 Subject: [PATCH 3/7] Text Field Positioning --- .../noppes/npcs/client/gui/global/GuiNPCEditAnimation.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 366b64e03..0c3cce242 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java @@ -167,7 +167,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield // //speed - textfield this.addLabel(new GuiNpcLabel(31, "stats.speed", guiLeft + animationX, guiTop + animationY + 24, 0xFFFFFF)); - this.addTextField(new GuiNpcTextField(31, this, guiLeft + animationX + 40, guiTop + animationY + 22, 30, 15, animation.speed + "")); + this.addTextField(new GuiNpcTextField(31, this, guiLeft + animationX + 88, guiTop + animationY + 22, 30, 15, animation.speed + "")); this.getTextField(31).floatsOnly = true; this.getTextField(31).setMinMaxDefaultFloat(0,Float.MAX_VALUE,1.0F); // @@ -193,7 +193,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield // //duration - textfield this.addLabel(new GuiNpcLabel(51, "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.addTextField(new GuiNpcTextField(51, this, guiLeft + frameX + 88, guiTop + frameY + 11, 30, 15, editingFrame.duration + "")); this.getTextField(51).integersOnly = true; this.getTextField(51).setMinMaxDefaultFloat(0, Integer.MAX_VALUE, 10); From 75e5e1f5418c118fc450a286d19014361c465a50 Mon Sep 17 00:00:00 2001 From: Kam Date: Thu, 9 Nov 2023 18:34:30 -0500 Subject: [PATCH 4/7] Position Fix when resizing GUI --- .../npcs/client/gui/global/GuiNPCEditAnimation.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 0c3cce242..d58cea415 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java @@ -257,6 +257,13 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield this.rotationSliders[i].width = 110; this.rotationSliders[i].height= 20; this.rotationSliders[i].xPosition = guiLeft + bodyPartX + 10; + + int yOffset = 20; + if(i != 0) + yOffset += 3; + yOffset *= i; + this.rotationSliders[i].yPosition = guiTop + bodyPartY + 105 + yOffset; + this.addSlider(this.rotationSliders[i]); } @@ -269,6 +276,12 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield this.pivotSliders[i].width = 110; this.pivotSliders[i].height = 20; this.pivotSliders[i].xPosition = guiLeft + bodyPartX + 10; + + int yOffset = 20; + if(i != 0) + yOffset += 3; + yOffset *= i; + this.pivotSliders[i].yPosition = guiTop + bodyPartY + 105 + yOffset; this.addSlider(this.pivotSliders[i]); } From 22f3fc0dad89086ed5c6e01f493365f744295839 Mon Sep 17 00:00:00 2001 From: Kam Date: Thu, 9 Nov 2023 18:36:12 -0500 Subject: [PATCH 5/7] Unneeded Code --- .../npcs/client/gui/global/GuiNPCEditAnimation.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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 d58cea415..0fc5f87c3 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java @@ -50,12 +50,8 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield int bodyPartX = 280; int bodyPartY = -5; for (int i = 0; i < 3; i++) { - int yOffset = 20; - if(i != 0) - yOffset += 3; - yOffset *= i; - this.rotationSliders[i] = new GuiNpcSlider(this, 90 + i, guiLeft + bodyPartX, guiTop + bodyPartY + 115 + yOffset, 0.5F); - this.pivotSliders[i] = new GuiNpcSlider(this, 95 + i, guiLeft + bodyPartX, guiTop + bodyPartY + 115 + yOffset, 0.5F); + this.rotationSliders[i] = new GuiNpcSlider(this, 90 + i, guiLeft + bodyPartX, guiTop + bodyPartY + 115 + (20 * i), 0.5F); + this.pivotSliders[i] = new GuiNpcSlider(this, 95 + i, guiLeft + bodyPartX, guiTop + bodyPartY + 115 + (20 * i), 0.5F); } } From 851edc2e3b413aa915d69f385b6867dd28ac8b4e Mon Sep 17 00:00:00 2001 From: Kam Date: Thu, 9 Nov 2023 18:36:30 -0500 Subject: [PATCH 6/7] Remove ":" from ID in other GUIs to match proper theme of other ID labels --- .../java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java | 2 +- .../java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java index d56eaf2b0..f75f926d7 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java @@ -78,7 +78,7 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou if(dialog != null) { if(dialog.id != -1){ - addLabel(new GuiNpcLabel(0, "ID:", guiLeft + 358, guiTop + 4 + 3 + 185)); + addLabel(new GuiNpcLabel(0, "ID", guiLeft + 358, guiTop + 4 + 3 + 185)); addLabel(new GuiNpcLabel(1, dialog.id + "", guiLeft + 358, guiTop + 4 + 3 + 195)); } } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java index 98731f5f9..eb8706693 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java @@ -82,7 +82,7 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup, if(quest != null) { if(quest.id != -1){ - addLabel(new GuiNpcLabel(0, "ID:", guiLeft + 358, guiTop + 4 + 3 + 185)); + addLabel(new GuiNpcLabel(0, "ID", guiLeft + 358, guiTop + 4 + 3 + 185)); addLabel(new GuiNpcLabel(1, quest.id + "", guiLeft + 358, guiTop + 4 + 3 + 195)); } } From c66cb942414fd091b61f61d305bf73577335fab2 Mon Sep 17 00:00:00 2001 From: Kam Date: Thu, 9 Nov 2023 20:11:07 -0500 Subject: [PATCH 7/7] Clamp Slider Values to INTs and better positioning --- .../gui/global/GuiNPCEditAnimation.java | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) 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 0fc5f87c3..9afd269b0 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java @@ -250,9 +250,9 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield if(sliderSelection == 0){ for (int i = 0; i < 3; i++) { - this.rotationSliders[i].width = 110; + this.rotationSliders[i].width = 122; this.rotationSliders[i].height= 20; - this.rotationSliders[i].xPosition = guiLeft + bodyPartX + 10; + this.rotationSliders[i].xPosition = guiLeft + bodyPartX; int yOffset = 20; if(i != 0) @@ -263,15 +263,15 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield this.addSlider(this.rotationSliders[i]); } - this.addLabel(new GuiNpcLabel(90, "X", guiLeft + bodyPartX, guiTop + bodyPartY + 112, 0xFFFFFF)); - this.addLabel(new GuiNpcLabel(91, "Y", guiLeft + bodyPartX, guiTop + bodyPartY + 135, 0xFFFFFF)); - this.addLabel(new GuiNpcLabel(92, "Z", guiLeft + bodyPartX, guiTop + bodyPartY + 157, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(90, "X", guiLeft + bodyPartX - 10, guiTop + bodyPartY + 112, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(91, "Y", guiLeft + bodyPartX - 10, guiTop + bodyPartY + 135, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(92, "Z", guiLeft + bodyPartX - 10, guiTop + bodyPartY + 157, 0xFFFFFF)); } else { for (int i = 0; i < 3; i++) { - this.pivotSliders[i].width = 110; + this.pivotSliders[i].width = 122; this.pivotSliders[i].height = 20; - this.pivotSliders[i].xPosition = guiLeft + bodyPartX + 10; + this.pivotSliders[i].xPosition = guiLeft + bodyPartX; int yOffset = 20; if(i != 0) @@ -281,9 +281,9 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield this.addSlider(this.pivotSliders[i]); } - this.addLabel(new GuiNpcLabel(95, "X", guiLeft + bodyPartX, guiTop + bodyPartY + 112, 0xFFFFFF)); - this.addLabel(new GuiNpcLabel(96, "Y", guiLeft + bodyPartX, guiTop + bodyPartY + 135, 0xFFFFFF)); - this.addLabel(new GuiNpcLabel(97, "Z", guiLeft + bodyPartX, guiTop + bodyPartY + 157, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(95, "X", guiLeft + bodyPartX - 10, guiTop + bodyPartY + 112, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(96, "Y", guiLeft + bodyPartX - 10, guiTop + bodyPartY + 135, 0xFFFFFF)); + this.addLabel(new GuiNpcLabel(97, "Z", guiLeft + bodyPartX - 10, guiTop + bodyPartY + 157, 0xFFFFFF)); } } else { // @@ -344,8 +344,13 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield float[] rotations = part.getRotations(); float[] pivots = part.getPivots(); for (int i = 0; i < 3; i++) { - this.rotationSliders[i].sliderValue = ((rotations[i] / 360.0F) + 1) / 2.0F; - this.pivotSliders[i].sliderValue = (((ValueUtil.clamp(pivots[i], -100, 100)) / 100.0F) + 1) / 2.0F; + this.rotationSliders[i].sliderValue = ValueUtil.clamp((((rotations[i] / 360.0F) + 1) / 2.0F), 0.0F, 1.0F); + int label = (int) (360.0F * 2.0F * ((((rotations[i] / 360.0F) + 1) / 2.0F) - 0.5F)); + this.rotationSliders[i].setString(label + ""); + + this.pivotSliders[i].sliderValue = ValueUtil.clamp(((((ValueUtil.clamp(pivots[i], -100, 100)) / 100.0F) + 1) / 2.0F), 0.0F, 1.0F); + int pivotVal = (int)(100.0F * (((((ValueUtil.clamp(pivots[i], -100, 100)) / 100.0F) + 1) / 2.0F) - 0.5F)); + this.pivotSliders[i].setString(pivotVal + ""); } } @@ -405,11 +410,9 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield } else if (guibutton.id == 67 && editingFrame != null) { editingFrame.removePart(this.editingPart.name()); } else if (guibutton.id == 68 && editingFrame != null) { - if (partEditMode == 1) { - this.updateSliders(); - } partEditMode++; partEditMode %= 2; + this.updateSliders(); } else if (guibutton.id == 69 && editingFrame != null) { if (partEditMode == 1) { this.updateSliders(); @@ -532,10 +535,14 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield } int id = guiNpcSlider.id; if (id >= 90 && id < 93) { - part.rotation[id - 90] = 360.0F * 2.0F * (guiNpcSlider.sliderValue - 0.5F); + int value = (int) (360.0F * 2.0F * (guiNpcSlider.sliderValue - 0.5F)); + part.rotation[id - 90] = value; + guiNpcSlider.setString(value + ""); } if (id >= 95 && id < 98) { - part.pivot[id - 95] = 100.0F * (guiNpcSlider.sliderValue - 0.5F); + int value = (int)(100.0F * (guiNpcSlider.sliderValue - 0.5F)); + guiNpcSlider.setString(value + ""); + part.pivot[id - 95] = value; } }