Added the NPC model to the animation middleman GUI, as well as logic for playing/pausing the animation.

This commit is contained in:
luisc committed 2023-11-08 11:58:55 -06:00
1 parent a3a5a4313f
commit 11626de55e
4 files changed
+252 -21

No files matched your search

@@ -6,24 +6,31 @@ import noppes.npcs.client.Client;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.AnimationData;
import noppes.npcs.controllers.data.Frame;
import noppes.npcs.controllers.data.FramePart;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
public class GuiNPCManageAnimations extends GuiNPCInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData, ISubGuiListener
public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData, ISubGuiListener
{
private GuiCustomScroll scrollAnimations;
private HashMap<String,Integer> data = new HashMap<String,Integer>();
private Animation animation = new Animation();
public boolean playingAnimation = false;
private String selected = null;
private String search = "";
public GuiNPCManageAnimations(EntityNPCInterface npc)
{
super(npc);
this.xOffset = -148 + 70;
this.yOffset = -170 + 137;
Client.sendData(EnumPacketServer.AnimationsGet);
}
@@ -46,10 +53,41 @@ public class GuiNPCManageAnimations extends GuiNPCInterface2 implements IScrollD
if (animation.id == -1)
return;
addLabel(new GuiNpcLabel(10,"ID", guiLeft + 178, guiTop + 4));
addLabel(new GuiNpcLabel(11, animation.id + "", guiLeft + 178, guiTop + 14));
addLabel(new GuiNpcLabel(10,"ID", guiLeft + 368, guiTop + 54));
addLabel(new GuiNpcLabel(11, animation.id + "", guiLeft + 368, guiTop + 64));
AnimationData data = npc.display.animationData;
if (!playingAnimation) {
data.animation = new Animation();
data.animation.smooth = animation.smooth;
data.animation.renderTicks = animation.renderTicks;
data.animation.loop = 0;
}
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));
if (data.animation.paused) {
this.addLabel(new GuiNpcLabel(94, "", guiLeft + 21, guiTop + 206, 0xFFFFFF));
}
this.addButton(new GuiTexturedButton(91, "", guiLeft + 35, guiTop + 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));
}
if (this.playingAnimation) {//Stop
this.addButton(new GuiTexturedButton(93, "", guiLeft + 55, guiTop + 200, 14, 20, animTexture, 33, 71));
}
}
}
@Override
public void drawScreen(int i, int j, float f) {
super.drawScreen(i, j, f);
}
@Override
public void keyTyped(char c, int i)
{
@@ -95,14 +133,37 @@ public class GuiNPCManageAnimations extends GuiNPCInterface2 implements IScrollD
initGui();
}
}
AnimationData data = npc.display.animationData;
if (guibutton.id == 91) {
if (!this.playingAnimation || !data.isActive()) {
animation.currentFrame = 0;
animation.currentFrameTime = 0;
for (Frame frame : animation.frames) {
for (FramePart framePart : frame.frameParts.values()) {
framePart.prevRotations = new float[]{0,0,0};
framePart.prevPivots = new float[]{0, 0, 0};
}
}
}
this.playingAnimation = true;
data.animation = animation;
data.animation.paused = false;
} else if (guibutton.id == 92) {
data.animation.paused = true;
} else if (guibutton.id == 93) {
this.playingAnimation = false;
data.animation.paused = false;
}
}
@Override
public void setGuiData(NBTTagCompound compound) {
this.animation = new Animation();
animation.readFromNBT(compound);
setSelected(animation.name);
this.playingAnimation = false;
initGui();
}
@@ -160,5 +221,4 @@ public class GuiNPCManageAnimations extends GuiNPCInterface2 implements IScrollD
@Override
public void subGuiClosed(SubGuiInterface subgui) {
}
}