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,6 +1,7 @@
package kamkeel.npcs.editorgui;
import noppes.npcs.scripted.gui.ScriptGuiTexturedRect;
import noppes.npcs.client.gui.custom.components.CustomGuiTexturedRect;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
@@ -8,7 +9,8 @@ import java.util.List;
/**
* EditorTexturedRectComponent wraps a ScriptGuiTexturedRect.
* It adds editing buttons for width, height, scale, texture string, texture X/Y offsets, and ID.
* It renders the actual textured rectangle and provides editing buttons for width, height, scale, alpha,
* rotation, texture string, texture X/Y offsets, and ID.
*/
public class EditorTexturedRectComponent extends AbstractEditorComponent {
private ScriptGuiTexturedRect texturedRect;
@@ -16,22 +18,25 @@ public class EditorTexturedRectComponent extends AbstractEditorComponent {
public EditorTexturedRectComponent(ScriptGuiTexturedRect rect) {
super(rect.getPosX(), rect.getPosY(), rect.getWidth(), rect.getHeight());
this.texturedRect = rect;
this.id = rect.getID();
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
drawRect(posX, posY, posX + width, posY + height, 0xFF000088);
String tex = texturedRect.getTexture();
if(tex != null)
fr.drawStringWithShadow(tex, posX + 2, posY + 2, 0xFFFFFF);
CustomGuiTexturedRect renderRect = CustomGuiTexturedRect.fromComponent(texturedRect);
renderRect.x = this.posX;
renderRect.y = this.posY;
renderRect.scale = texturedRect.getScale();
renderRect.alpha = texturedRect.getAlpha();
renderRect.rotation = texturedRect.getRotation();
renderRect.onRender(Minecraft.getMinecraft(), mouseX, mouseY, 0, partialTicks);
renderSelectionOutline();
}
@Override
public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) {
if(mouseX >= posX && mouseX <= posX + width &&
mouseY >= posY && mouseY <= posY + height) {
if(mouseX >= posX && mouseX < posX + width &&
mouseY >= posY && mouseY < posY + height) {
selected = true;
return true;
}
@@ -56,15 +61,17 @@ public class EditorTexturedRectComponent extends AbstractEditorComponent {
@Override
public void addEditorButtons(List<GuiButton> buttonList) {
buttonList.add(new GuiButton(401, 0, 0, 0, 0, "W+"));
buttonList.add(new GuiButton(402, 0, 0, 0, 0, "W-"));
buttonList.add(new GuiButton(403, 0, 0, 0, 0, "H+"));
buttonList.add(new GuiButton(404, 0, 0, 0, 0, "H-"));
buttonList.add(new GuiButton(405, 0, 0, 0, 0, "Sc"));
buttonList.add(new GuiButton(407, 0, 0, 0, 0, "Tex"));
buttonList.add(new GuiButton(408, 0, 0, 0, 0, "TxX"));
buttonList.add(new GuiButton(409, 0, 0, 0, 0, "TxY"));
buttonList.add(new GuiButton(410, 0, 0, 0, 0, "ID"));
buttonList.add(new GuiButton(401, 0, 0, 30, 20, "W+"));
buttonList.add(new GuiButton(402, 0, 0, 30, 20, "W-"));
buttonList.add(new GuiButton(403, 0, 0, 30, 20, "H+"));
buttonList.add(new GuiButton(404, 0, 0, 30, 20, "H-"));
buttonList.add(new GuiButton(405, 0, 0, 30, 20, "Sc"));
buttonList.add(new GuiButton(406, 0, 0, 30, 20, "Al"));
buttonList.add(new GuiButton(407, 0, 0, 30, 20, "Rt"));
buttonList.add(new GuiButton(408, 0, 0, 30, 20, "Tex"));
buttonList.add(new GuiButton(409, 0, 0, 30, 20, "TxX"));
buttonList.add(new GuiButton(410, 0, 0, 30, 20, "TxY"));
buttonList.add(new GuiButton(411, 0, 0, 30, 20, "ID"));
}
@Override
@@ -87,7 +94,7 @@ public class EditorTexturedRectComponent extends AbstractEditorComponent {
texturedRect.setSize(width, height);
break;
case 405:
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty(Minecraft.getMinecraft().currentScreen, "Scale", Float.toString(texturedRect.getScale()), new IPropertyEditorCallback() {
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty("Scale", Float.toString(texturedRect.getScale()), new IPropertyEditorCallback() {
@Override
public void propertyUpdated(String newValue) {
try {
@@ -95,18 +102,52 @@ public class EditorTexturedRectComponent extends AbstractEditorComponent {
texturedRect.setScale(newScale);
} catch (NumberFormatException e) { }
}
}, new ISubGuiCallback() {
@Override
public void onSubGuiClosed() { }
}));
break;
case 406:
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty("Alpha", Float.toString(texturedRect.getAlpha()), new IPropertyEditorCallback() {
@Override
public void propertyUpdated(String newValue) {
try {
float newAlpha = Float.parseFloat(newValue);
texturedRect.setAlpha(newAlpha);
} catch (NumberFormatException e) { }
}
}, new ISubGuiCallback() {
@Override
public void onSubGuiClosed() { }
}));
break;
case 407:
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty(Minecraft.getMinecraft().currentScreen, "Texture", texturedRect.getTexture(), new IPropertyEditorCallback() {
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty("Rotation", Float.toString(texturedRect.getRotation()), new IPropertyEditorCallback() {
@Override
public void propertyUpdated(String newValue) {
try {
float newRot = Float.parseFloat(newValue);
texturedRect.setRotation(newRot);
} catch (NumberFormatException e) { }
}
}, new ISubGuiCallback() {
@Override
public void onSubGuiClosed() { }
}));
break;
case 408:
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty("Texture", texturedRect.getTexture(), new IPropertyEditorCallback() {
@Override
public void propertyUpdated(String newValue) {
texturedRect.setTexture(newValue);
}
}, new ISubGuiCallback() {
@Override
public void onSubGuiClosed() { }
}));
break;
case 408:
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty(Minecraft.getMinecraft().currentScreen, "TxX", Integer.toString(texturedRect.getTextureX()), new IPropertyEditorCallback() {
case 409:
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty("TxX", Integer.toString(texturedRect.getTextureX()), new IPropertyEditorCallback() {
@Override
public void propertyUpdated(String newValue) {
try {
@@ -114,10 +155,13 @@ public class EditorTexturedRectComponent extends AbstractEditorComponent {
texturedRect.setTextureOffset(newX, texturedRect.getTextureY());
} catch (NumberFormatException e) { }
}
}, new ISubGuiCallback() {
@Override
public void onSubGuiClosed() { }
}));
break;
case 409:
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty(Minecraft.getMinecraft().currentScreen, "TxY", Integer.toString(texturedRect.getTextureY()), new IPropertyEditorCallback() {
case 410:
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty("TxY", Integer.toString(texturedRect.getTextureY()), new IPropertyEditorCallback() {
@Override
public void propertyUpdated(String newValue) {
try {
@@ -125,10 +169,13 @@ public class EditorTexturedRectComponent extends AbstractEditorComponent {
texturedRect.setTextureOffset(texturedRect.getTextureX(), newY);
} catch (NumberFormatException e) { }
}
}, new ISubGuiCallback() {
@Override
public void onSubGuiClosed() { }
}));
break;
case 410:
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty(Minecraft.getMinecraft().currentScreen, "ID", Integer.toString(texturedRect.getID()), new IPropertyEditorCallback() {
case 411:
Minecraft.getMinecraft().displayGuiScreen(new SubGuiEditProperty("ID", Integer.toString(texturedRect.getID()), new IPropertyEditorCallback() {
@Override
public void propertyUpdated(String newValue) {
try {
@@ -136,6 +183,9 @@ public class EditorTexturedRectComponent extends AbstractEditorComponent {
texturedRect.setID(newID);
} catch (NumberFormatException e) { }
}
}, new ISubGuiCallback() {
@Override
public void onSubGuiClosed() { }
}));
break;
}