Implemented frame color markers on the timeline.

This commit is contained in:
luisc committed 2023-11-10 09:16:18 -06:00
1 parent c1cb77e21b
commit fa6dd50d50
2 files changed
+32 -4

No files matched your search

@@ -4,6 +4,7 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import noppes.npcs.client.gui.SubGuiAnimationFrame;
import noppes.npcs.client.gui.SubGuiAnimationOptions;
import noppes.npcs.client.gui.SubGuiColorSelector;
import noppes.npcs.controllers.data.AnimationData;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.util.*;
@@ -19,7 +20,7 @@ import noppes.npcs.util.ValueUtil;
import java.util.HashMap;
import java.util.Map;
public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfieldListener, ISliderListener {
public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfieldListener, ISliderListener, ISubGuiListener {
private final Animation animation;
private EnumAnimationPart editingPart = EnumAnimationPart.HEAD;
@@ -202,7 +203,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 + 31 , 120, 20, "animation.frameOptions"));
this.addButton(new GuiNpcButton(52,guiLeft + frameX, guiTop + frameY + 31 , 80, 20, "animation.frameOptions"));
this.addButton(new GuiNpcButton(53,guiLeft + frameX + getButton(52).width + 5, guiTop + frameY + 31 , 35, 20, "gui.color"));
int bodyPartX = 280;
int bodyPartY = -5;
@@ -472,8 +474,10 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield
data.animation.paused = false;
} else if (guibutton.id == 34) {
setSubGui(new SubGuiAnimationOptions(this.animation));
} else if (guibutton.id == 52) {
} else if (guibutton.id == 52 && editingFrame != null) {
setSubGui(new SubGuiAnimationFrame(editingFrame));
} else if (guibutton.id == 53 && editingFrame != null) {
setSubGui(new SubGuiColorSelector(editingFrame.getColorMarker()));
}
if (guibutton.id >= 300 && guibutton.id < 325) {
@@ -519,8 +523,9 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield
int sliderFrame = i + this.frameOffset;
if (sliderFrame >= this.animation.frames.size()) {
button.color = 0x0;
button.alpha = 0.3F;
} else {
button.color = sliderFrame == this.frameIndex ? 0x00FF00 : 0xFFFFFF;
button.color = this.animation.frames.get(sliderFrame).getColorMarker();
if ((sliderFrame == this.animation.currentFrame && this.playingAnimation) || sliderFrame == this.frameIndex) {
button.yPosition = guiTop + (sliderFrame == this.frameIndex ? 205 : 200);
} else {
@@ -605,4 +610,12 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield
public void mouseReleased(GuiNpcSlider guiNpcSlider) {
}
@Override
public void subGuiClosed(SubGuiInterface subgui) {
Frame editingFrame = this.editingFrame();
if (subgui instanceof SubGuiColorSelector && editingFrame != null) {
editingFrame.setColorMarker(((SubGuiColorSelector) subgui).color);
}
}
}
@@ -20,6 +20,8 @@ public class Frame implements IFrame {
public byte smooth = 0;
public boolean renderTicks = false; // If true, MC ticks are used. If false, render ticks are used.
private int colorMarker = 0xFFFFFF;
public Frame(){}
public Frame(int duration) {
@@ -110,8 +112,19 @@ public class Frame implements IFrame {
return this.renderTicks;
}
public int getColorMarker() {
return this.colorMarker;
}
public void setColorMarker(int color) {
this.colorMarker = color;
}
public void readFromNBT(NBTTagCompound compound){
duration = compound.getInteger("Duration");
if (compound.hasKey("ColorMarker")) {
this.setColorMarker(compound.getInteger("ColorMarker"));
}
// Customized = TRUE if Speed or Smooth Exist
if(compound.hasKey("Speed")){
@@ -151,6 +164,8 @@ public class Frame implements IFrame {
public NBTTagCompound writeToNBT(){
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("Duration", duration);
compound.setInteger("ColorMarker", this.colorMarker);
if(customized){
compound.setFloat("Speed", speed);
compound.setByte("Smooth", smooth);