Another Rendition Rewrite

This commit is contained in:
Kam committed 2025-03-05 03:34:30 -05:00
1 parent f94f80ea41
commit 3c1f7f9e60
14 files changed
+378 -147

No files matched your search

@@ -1,13 +1,14 @@
package kamkeel.npcs.editorgui;
import noppes.npcs.scripted.gui.ScriptGuiLabel;
import noppes.npcs.client.gui.custom.components.CustomGuiLabel;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import java.util.List;
/**
* EditorLabelComponent wraps a ScriptGuiLabel and adds editing buttons for width, height, scale, text, and ID.
* EditorLabelComponent wraps a ScriptGuiLabel.
*/
public class EditorLabelComponent extends AbstractEditorComponent {
private ScriptGuiLabel labelComponent;
@@ -15,15 +16,18 @@ public class EditorLabelComponent extends AbstractEditorComponent {
public EditorLabelComponent(ScriptGuiLabel label) {
super(label.getPosX(), label.getPosY(), label.getWidth(), label.getHeight());
this.labelComponent = label;
this.id = label.getID();
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
drawRect(posX, posY, posX + width, posY + height, 0xFFAAAAAA);
String text = labelComponent.getText();
if(text != null)
fr.drawStringWithShadow(text, posX + 2, posY + (height - 8) / 2, labelComponent.getColor());
CustomGuiLabel renderLbl = CustomGuiLabel.fromComponent(labelComponent);
renderLbl.x = this.posX;
renderLbl.y = this.posY;
renderLbl.setScale(labelComponent.getScale());
renderLbl.alpha = labelComponent.getAlpha();
renderLbl.rotation = labelComponent.getRotation();
renderLbl.onRender(Minecraft.getMinecraft(), mouseX, mouseY, 0, partialTicks);
renderSelectionOutline();
}
@@ -55,13 +59,15 @@ public class EditorLabelComponent extends AbstractEditorComponent {
@Override
public void addEditorButtons(List<GuiButton> buttonList) {
buttonList.add(new GuiButton(201, 0, 0, 0, 0, "W+"));
buttonList.add(new GuiButton(202, 0, 0, 0, 0, "W-"));
buttonList.add(new GuiButton(203, 0, 0, 0, 0, "H+"));
buttonList.add(new GuiButton(204, 0, 0, 0, 0, "H-"));
buttonList.add(new GuiButton(205, 0, 0, 0, 0, "Sc"));
buttonList.add(new GuiButton(207, 0, 0, 0, 0, "Txt"));
buttonList.add(new GuiButton(210, 0, 0, 0, 0, "ID"));
buttonList.add(new GuiButton(201, 0, 0, 30, 20, "W+"));
buttonList.add(new GuiButton(202, 0, 0, 30, 20, "W-"));
buttonList.add(new GuiButton(203, 0, 0, 30, 20, "H+"));
buttonList.add(new GuiButton(204, 0, 0, 30, 20, "H-"));
buttonList.add(new GuiButton(205, 0, 0, 30, 20, "Sc"));
buttonList.add(new GuiButton(206, 0, 0, 30, 20, "Al"));
buttonList.add(new GuiButton(207, 0, 0, 30, 20, "Rt"));
buttonList.add(new GuiButton(208, 0, 0, 30, 20, "Txt"));
buttonList.add(new GuiButton(210, 0, 0, 30, 20, "ID"));
}
@Override
@@ -84,7 +90,7 @@ public class EditorLabelComponent extends AbstractEditorComponent {
labelComponent.setSize(width, height);
break;
case 205:
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty(Minecraft.getMinecraft().currentScreen, "Scale", Float.toString(labelComponent.getScale()), new IPropertyEditorCallback() {
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty("Scale", Float.toString(labelComponent.getScale()), new IPropertyEditorCallback() {
@Override
public void propertyUpdated(String newValue) {
try {
@@ -92,18 +98,52 @@ public class EditorLabelComponent extends AbstractEditorComponent {
labelComponent.setScale(newScale);
} catch (NumberFormatException e) { }
}
}, new ISubGuiCallback() {
@Override
public void onSubGuiClosed() { }
}));
break;
case 206:
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty("Alpha", Float.toString(labelComponent.getAlpha()), new IPropertyEditorCallback() {
@Override
public void propertyUpdated(String newValue) {
try {
float newAlpha = Float.parseFloat(newValue);
labelComponent.setAlpha(newAlpha);
} catch (NumberFormatException e) { }
}
}, new ISubGuiCallback() {
@Override
public void onSubGuiClosed() { }
}));
break;
case 207:
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty(Minecraft.getMinecraft().currentScreen, "Text", labelComponent.getText(), new IPropertyEditorCallback() {
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty("Rotation", Float.toString(labelComponent.getRotation()), new IPropertyEditorCallback() {
@Override
public void propertyUpdated(String newValue) {
try {
float newRot = Float.parseFloat(newValue);
labelComponent.setRotation(newRot);
} catch (NumberFormatException e) { }
}
}, new ISubGuiCallback() {
@Override
public void onSubGuiClosed() { }
}));
break;
case 208:
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty("Text", labelComponent.getText(), new IPropertyEditorCallback() {
@Override
public void propertyUpdated(String newValue) {
labelComponent.setText(newValue);
}
}, new ISubGuiCallback() {
@Override
public void onSubGuiClosed() { }
}));
break;
case 210:
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty(Minecraft.getMinecraft().currentScreen, "ID", Integer.toString(labelComponent.getID()), new IPropertyEditorCallback() {
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty("ID", Integer.toString(labelComponent.getID()), new IPropertyEditorCallback() {
@Override
public void propertyUpdated(String newValue) {
try {
@@ -111,6 +151,9 @@ public class EditorLabelComponent extends AbstractEditorComponent {
labelComponent.setID(newID);
} catch (NumberFormatException e) { }
}
}, new ISubGuiCallback() {
@Override
public void onSubGuiClosed() { }
}));
break;
}