GUI's properly implemented, script data still needs work.

This commit is contained in:
luisc committed 2021-10-01 01:17:12 -05:00
1 parent 95d2814651
commit 44bd1692d1
15 files changed
+1538 -595

No files matched your search

@@ -1,6 +1,6 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
// (powered by Fernflower decompiler)
//
package noppes.npcs.client.gui.script;
@@ -16,31 +16,20 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiConfirmOpenLink;
import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.MinecraftServer;
import noppes.npcs.EventDataScript;
import noppes.npcs.EventScriptContainer;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.EventGuiScriptList;
import noppes.npcs.client.gui.swing.GuiJTextArea;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.IScriptHandler;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.PlayerScriptData;
public class GuiScriptInterface extends GuiNPCInterface implements IGuiData, ITextChangeListener, GuiYesNoCallback, ICustomScrollListener, IJTextAreaListener {
public class GuiScriptInterface extends EventGuiNPCInterface implements GuiYesNoCallback, IGuiData, ITextChangeListener {
private int activeTab = 0;
public IScriptHandler handler;
private String activeScriptTab = "init";
public Map<String, List<String>> languages = new HashMap();
public boolean showScript = false;
private static int activeConsole = 0;
public GuiScriptInterface() {
this.drawDefaultBackground = true;
this.closeOnEsc = true;
@@ -49,98 +38,91 @@ public class GuiScriptInterface extends GuiNPCInterface implements IGuiData, ITe
}
public void initGui() {
this.xSize = (int)((double)this.width * 0.88D);
this.ySize = (int)((double)this.xSize * 0.56D);
if((double)this.ySize > (double)this.height * 0.95D) {
this.ySize = (int)((double)this.height * 0.95D);
this.xSize = (int)((double)this.ySize / 0.56D);
}
this.bgScale = (float)this.xSize / 400.0F;
super.initGui();
guiTop += 10;
this.guiTop += 10;
int yoffset = (int)((double)this.ySize * 0.02D);
GuiMenuTopButton top;
addTopButton(top = new GuiMenuTopButton(13, guiLeft + 4, guiTop - 17, "eventscript.playerevent"));
top.active = showScript;
addTopButton(top = new GuiMenuTopButton(14, top, "gui.settings"));
top.active = !showScript;
addTopButton(new GuiMenuTopButton(15, top, "gui.website"));
this.addTopButton(top = new GuiMenuTopButton(0, this.guiLeft + 4, this.guiTop - 17, "gui.settings"));
List<String> list = new ArrayList<String>();
list.add("playerscript.attack");
list.add("playerscript.chat");
list.add("playerscript.containerclosed");
list.add("playerscript.containeropen");
list.add("playerscript.damagedentity");
list.add("playerscript.damaged");
list.add("playerscript.killed");
list.add("playerscript.init");
list.add("playerscript.interact");
list.add("playerscript.keypressed");
list.add("playerscript.kills");
list.add("playerscript.levelup");
list.add("playerscript.login");
list.add("playerscript.logout");
list.add("playerscript.pickup");
list.add("playerscript.rangedlaunched");
list.add("playerscript.toss");
list.add("playerscript.update");
if(showScript) {
addLabel(new GuiNpcLabel(0, "script.hooks", guiLeft + 4, guiTop + 5));
GuiCustomScroll hooks = new GuiCustomScroll(this, 1);
hooks.setSize(68, 198);
hooks.guiLeft = guiLeft + 4;
hooks.guiTop = guiTop + 14;
hooks.setUnsortedList(list);
hooks.selected = activeTab;
addScroll(hooks);
EventScriptContainer container = handler.getScripts().get(activeTab);
addTextField(new GuiNpcTextArea(2, this, guiLeft + 74, guiTop + 4, 239, 208, container == null?"":container.script));
addButton(new GuiNpcButton(102, guiLeft + 315, guiTop + 4, 50, 20, "gui.clear"));
addButton(new GuiNpcButton(101, guiLeft + 366, guiTop + 4, 50, 20, "gui.paste"));
addButton(new GuiNpcButton(100, guiLeft + 315, guiTop + 25, 50, 20, "gui.copy"));
addButton(new GuiNpcButton(108, guiLeft + 315, guiTop + 47, 80, 20, "gui.editor"));
addButton(new GuiNpcButton(107, guiLeft + 315, guiTop + 70, 80, 20, "script.loadscript"));
GuiCustomScroll scroll = new GuiCustomScroll(this, 0).setUnselectable();
scroll.setSize(100, 120);
scroll.guiLeft = guiLeft + 315;
scroll.guiTop = guiTop + 92;
if(container != null)
scroll.setList(container.scripts);
addScroll(scroll);
for(int ta = 0; ta < this.handler.getScripts().size(); ++ta) {
EventScriptContainer var10000 = (EventScriptContainer)this.handler.getScripts().get(ta);
this.addTopButton(top = new GuiMenuTopButton(ta + 1, top, ta + 1 + ""));
}
else{
addLabel(new GuiNpcLabel(0, "script.console", guiLeft + 4, guiTop + 16));
getTopButton(14).active = true;
addTextField(new GuiNpcTextArea(2, this, guiLeft + 4, guiTop + 26, 226, 186, getConsoleText()));
getTextField(2).canEdit = false;
addButton(new GuiNpcButton(100, guiLeft + 232, guiTop + 170, 56, 20, "gui.copy"));
addButton(new GuiNpcButton(102, guiLeft + 232, guiTop + 192, 56, 20, "gui.clear"));
List<String> l = new ArrayList<String>();
l.add("All");
l.addAll(list);
addButton(new GuiNpcButton(105, guiLeft + 60, guiTop + 4, 80, 20, l.toArray(new String[l.size()]), activeConsole));
addLabel(new GuiNpcLabel(1, "script.language", guiLeft + 232, guiTop + 30));
addButton(new GuiNpcButton(103, guiLeft + 294, guiTop + 25, 80, 20, languages.keySet().toArray(new String[languages.keySet().size()]), getScriptIndex()));
getButton(103).enabled = languages.size() > 0;
addLabel(new GuiNpcLabel(2, "gui.enabled", guiLeft + 232, guiTop + 53));
//addButton(new GuiNpcButton(104, guiLeft + 294, guiTop + 48, 50, 20, new String[]{"gui.no","gui.yes"}, handler.enabled?1:0));
if(MinecraftServer.getServer() != null)
addButton(new GuiNpcButton(106, guiLeft + 232, guiTop + 71, 150, 20, "script.openfolder"));
if(this.handler.getScripts().size() < 16) {
this.addTopButton(new GuiMenuTopButton(12, top, "+"));
}
top = this.getTopButton(this.activeTab);
if(top == null) {
this.activeTab = 0;
top = this.getTopButton(0);
}
top.active = true;
if(this.activeTab > 0) {
EventScriptContainer var7 = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
GuiTextArea left = new GuiTextArea(2, this.guiLeft + 1 + yoffset, this.guiTop + yoffset, this.xSize - 108 - yoffset, (int)((double)this.ySize * 0.96D) - yoffset * 2, var7 == null?"":var7.script);
//left.enableCodeHighlighting();
//left.setListener(this);
this.add(left);
int left1 = this.guiLeft + this.xSize - 104;
this.addButton(new GuiNpcButton(102, left1, this.guiTop + yoffset, 60, 20, "gui.clear"));
this.addButton(new GuiNpcButton(101, left1 + 61, this.guiTop + yoffset, 60, 20, "gui.paste"));
this.addButton(new GuiNpcButton(100, left1, this.guiTop + 21 + yoffset, 60, 20, "gui.copy"));
this.addButton(new GuiNpcButton(105, left1 + 61, this.guiTop + 21 + yoffset, 60, 20, "gui.remove"));
this.addButton(new GuiNpcButton(107, left1, this.guiTop + 66 + yoffset, 80, 20, "script.loadscript"));
GuiCustomScroll scroll = (new GuiCustomScroll(this, 0)).setUnselectable();
scroll.setSize(100, (int)((double)this.ySize * 0.54D) - yoffset * 2);
scroll.guiLeft = left1;
scroll.guiTop = this.guiTop + 88 + yoffset;
if(var7 != null) {
scroll.setList(var7.scripts);
}
this.addScroll(scroll);
} else {
GuiTextArea var8 = new GuiTextArea(2, this.guiLeft + 4 + yoffset, this.guiTop + 6 + yoffset, this.xSize - 160 - yoffset, (int)((float)this.ySize * 0.92F) - yoffset * 2, this.getConsoleText());
var8.enabled = false;
this.add(var8);
int var9 = this.guiLeft + this.xSize - 150;
this.addButton(new GuiNpcButton(100, var9, this.guiTop + 125, 60, 20, "gui.copy"));
this.addButton(new GuiNpcButton(102, var9, this.guiTop + 146, 60, 20, "gui.clear"));
this.addLabel(new GuiNpcLabel(1, "script.language", var9, this.guiTop + 15));
this.addButton(new GuiNpcButton(103, var9 + 60, this.guiTop + 10, 80, 20, (String[])this.languages.keySet().toArray(new String[this.languages.keySet().size()]), this.getScriptIndex()));
this.getButton(103).enabled = this.languages.size() > 0;
this.addLabel(new GuiNpcLabel(2, "gui.enabled", var9, this.guiTop + 36));
this.addButton(new GuiNpcButton(104, var9 + 60, this.guiTop + 31, 50, 20, new String[]{"gui.no", "gui.yes"}, this.handler.getEnabled()?1:0));
if(this.player.worldObj.isRemote) {
this.addButton(new GuiNpcButton(106, var9, this.guiTop + 55, 150, 20, "script.openfolder"));
}
this.addButton(new GuiNpcButton(109, var9, this.guiTop + 78, 80, 20, "gui.website"));
this.addButton(new GuiNpcButton(112, var9 + 81, this.guiTop + 78, 80, 20, "gui.forum"));
this.addButton(new GuiNpcButton(110, var9, this.guiTop + 99, 80, 20, "script.apidoc"));
this.addButton(new GuiNpcButton(111, var9 + 81, this.guiTop + 99, 80, 20, "script.apisrc"));
}
this.xSize = 420;
this.ySize = 256;
}
private String getConsoleText() {
Map<Long, String> map = this.handler.getConsoleText();
Map map = this.handler.getConsoleText();
StringBuilder builder = new StringBuilder();
Iterator var3 = map.entrySet().iterator();
while(var3.hasNext()) {
Entry<Long, String> entry = (Entry)var3.next();
builder.insert(0, new Date((Long)entry.getKey()) + (String)entry.getValue() + "\n");
Entry entry = (Entry)var3.next();
builder.insert(0, new Date(((Long)entry.getKey()).longValue()) + (String)entry.getValue() + "\n");
}
return builder.toString();
@@ -151,7 +133,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements IGuiData, ITe
for(Iterator var2 = this.languages.keySet().iterator(); var2.hasNext(); ++i) {
String language = (String)var2.next();
if (language.equalsIgnoreCase(this.handler.getLanguage())) {
if(language.equalsIgnoreCase(this.handler.getLanguage())) {
return i;
}
}
@@ -159,25 +141,25 @@ public class GuiScriptInterface extends GuiNPCInterface implements IGuiData, ITe
return 0;
}
public void func_73878_a(boolean flag, int i) {
if (flag) {
if (i == 0) {
public void confirmClicked(boolean flag, int i) {
if(flag) {
if(i == 0) {
this.openLink("http://www.kodevelopment.nl/minecraft/customnpcs/scripting");
}
if (i == 1) {
if(i == 1) {
this.openLink("http://www.kodevelopment.nl/customnpcs/api/");
}
if (i == 2) {
if(i == 2) {
this.openLink("http://www.kodevelopment.nl/minecraft/customnpcs/scripting");
}
if (i == 3) {
if(i == 3) {
this.openLink("http://www.minecraftforge.net/forum/index.php/board,122.0.html");
}
if (i == 10) {
if(i == 10) {
this.handler.getScripts().remove(this.activeTab - 1);
this.activeTab = 0;
}
@@ -187,79 +169,97 @@ public class GuiScriptInterface extends GuiNPCInterface implements IGuiData, ITe
}
protected void actionPerformed(GuiButton guibutton) {
if(guibutton.id == 13){
showScript = true;
initGui();
if(guibutton.id >= 0 && guibutton.id < 12) {
this.setScript();
this.activeTab = guibutton.id;
this.initGui();
}
if(guibutton.id == 14){
setScript();
showScript = false;
initGui();
if(guibutton.id == 12) {
this.handler.getScripts().add(new EventScriptContainer(this.handler));
this.activeTab = this.handler.getScripts().size();
this.initGui();
}
if(guibutton.id == 15){
GuiConfirmOpenLink guiyesno = new GuiConfirmOpenLink(this, "http://www.kodevelopment.nl/minecraft/customnpcs/scripting", 0, true);
mc.displayGuiScreen(guiyesno);
if(guibutton.id == 109) {
this.displayGuiScreen(new GuiConfirmOpenLink(this, "http://www.kodevelopment.nl/minecraft/customnpcs/scripting", 0, true));
}
if (guibutton.id == 100) {
NoppesStringUtils.setClipboardContents(getTextField(2).getText());
if(guibutton.id == 110) {
this.displayGuiScreen(new GuiConfirmOpenLink(this, "http://www.kodevelopment.nl/customnpcs/api/", 1, true));
}
if (guibutton.id == 101) {
getTextField(2).setText(NoppesStringUtils.getClipboardContents());
if(guibutton.id == 111) {
this.displayGuiScreen(new GuiConfirmOpenLink(this, "https://github.com/Noppes/CustomNPCsAPI", 2, true));
}
if (guibutton.id == 102) {
getTextField(2).setText("");
if(!showScript){
if(activeConsole == 0){
for(EventScriptContainer container : handler.getScripts())
for(Long l : container.console.keySet())
container.console.put(l,"");
}
else{
System.out.println("test");
EventScriptContainer container = handler.getScripts().get(activeConsole - 1);
System.out.println("test2");
if(container != null)
for(Long l : container.console.keySet())
container.console.put(l,"");
}
if(guibutton.id == 112) {
this.displayGuiScreen(new GuiConfirmOpenLink(this, "http://www.minecraftforge.net/forum/index.php/board,122.0.html", 3, true));
}
if(guibutton.id == 100) {
NoppesStringUtils.setClipboardContents(((GuiTextArea)this.get(2)).getText());
}
if(guibutton.id == 101) {
((GuiTextArea)this.get(2)).setText(NoppesStringUtils.getClipboardContents());
}
EventScriptContainer container;
if(guibutton.id == 102) {
if(this.activeTab > 0) {
container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
container.script = "";
} else {
this.handler.clearConsole();
}
this.initGui();
}
if (guibutton.id == 103) {
handler.setLanguage(((GuiNpcButton)guibutton).displayString);
if(guibutton.id == 103) {
this.handler.setLanguage(((GuiNpcButton)guibutton).displayString);
}
if (guibutton.id == 104) {
handler.setEnabled(((GuiNpcButton)guibutton).getValue() == 1);
if(guibutton.id == 104) {
this.handler.setEnabled(((GuiNpcButton)guibutton).getValue() == 1);
}
if (guibutton.id == 105) {
activeConsole = ((GuiNpcButton)guibutton).getValue();
initGui();
if(guibutton.id == 105) {
GuiYesNo container1 = new GuiYesNo(this, "", ((GuiNpcButton)guibutton).displayString, 10);
this.displayGuiScreen(container1);
}
if (guibutton.id == 106) {
if(guibutton.id == 106) {
NoppesUtil.openFolder(ScriptController.Instance.dir);
}
if (guibutton.id == 107) {
EventScriptContainer container = handler.getScripts().get(activeTab);
if(container == null)
handler.getScripts().set(activeTab, container = new EventScriptContainer(new EventDataScript()));
setSubGui(new EventGuiScriptList(languages.get(handler.getLanguage()), container));
}
if (guibutton.id == 108) {
EventScriptContainer container = handler.getScripts().get(activeTab);
if(container != null){
setScript();
this.AWTWindow = new GuiJTextArea(container.script).setListener(this);
}
}
}
private void setScript() {
if (this.activeTab > 0) {
EventScriptContainer container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if (container == null) {
if(guibutton.id == 107) {
container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if(container == null) {
this.handler.getScripts().add(container = new EventScriptContainer(this.handler));
}
String text = this.getConsoleText();
this.setSubGui(new EventGuiScriptList((List)this.languages.get(this.handler.getLanguage()), container));
}
if(guibutton.id == 108) {
container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if(container != null) {
this.setScript();
}
}
}
private void setScript() {
if(this.activeTab > 0) {
EventScriptContainer container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if(container == null) {
this.handler.getScripts().add(container = new EventScriptContainer(this.handler));
}
String text = ((GuiTextArea)this.get(2)).getText();
text = text.replace("\r\n", "\n");
text = text.replace("\r", "\n");
container.script = text;
@@ -269,11 +269,11 @@ public class GuiScriptInterface extends GuiNPCInterface implements IGuiData, ITe
public void setGuiData(NBTTagCompound compound) {
NBTTagList data = compound.getTagList("Languages", 10);
Map<String, List<String>> languages = new HashMap();
HashMap languages = new HashMap();
for(int i = 0; i < data.tagCount(); ++i) {
NBTTagCompound comp = data.getCompoundTagAt(i);
List<String> scripts = new ArrayList();
ArrayList scripts = new ArrayList();
NBTTagList list = comp.getTagList("Scripts", 8);
for(int j = 0; j < list.tagCount(); ++j) {
@@ -293,25 +293,9 @@ public class GuiScriptInterface extends GuiNPCInterface implements IGuiData, ITe
public void textUpdate(String text) {
EventScriptContainer container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if (container != null) {
if(container != null) {
container.script = text;
}
}
@Override
public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) {
if(scroll.id == 1){
setScript();
activeTab = scroll.selected;
initGui();
}
}
@Override
public void saveText(String text) {
EventScriptContainer container = handler.getScripts().get(activeTab);
if(container != null)
container.script = text;
initGui();
}
}