diff --git a/src/main/java/noppes/npcs/client/gui/GuiNPCFactionSelection.java b/src/main/java/noppes/npcs/client/gui/GuiNPCFactionSelection.java index bba65de94..1b21e3911 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNPCFactionSelection.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNPCFactionSelection.java @@ -6,6 +6,7 @@ import noppes.npcs.client.Client; import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumPacketServer; +import noppes.npcs.controllers.data.Quest; import noppes.npcs.entity.EntityNPCInterface; import java.util.HashMap; @@ -23,12 +24,12 @@ public class GuiNPCFactionSelection extends GuiNPCInterface implements IScrollDa { super(npc); drawDefaultBackground = false; - title = "Select Dialog Category"; + title = "Select Faction Category"; this.parent = parent; this.factionId = dialog; - + Client.sendData(EnumPacketServer.FactionsGet); - + if(parent instanceof GuiSelectionListener){ listener = (GuiSelectionListener) parent; } @@ -40,7 +41,7 @@ public class GuiNPCFactionSelection extends GuiNPCInterface implements IScrollDa Vector list = new Vector(); slot = new GuiNPCStringSlot(list,this,false,18); slot.registerScrollButtons(4, 5); - + this.addButton(new GuiNpcButton(2, width / 2 -100, height - 41,98, 20, "gui.back")); this.addButton(new GuiNpcButton(4, width / 2 + 2, height - 41,98, 20, "gui.select")); } @@ -71,7 +72,7 @@ public class GuiNPCFactionSelection extends GuiNPCInterface implements IScrollDa factionId = data.get(slot.selected); close(); NoppesUtil.openGUI(player, parent); - + } public void save() { if(factionId >= 0){ @@ -92,8 +93,7 @@ public class GuiNPCFactionSelection extends GuiNPCInterface implements IScrollDa @Override public void setSelected(String selected) { - + } - } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java index 467077e6b..3e27199e6 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java @@ -1,15 +1,15 @@ package noppes.npcs.client.gui.global; import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiYesNo; +import net.minecraft.client.gui.GuiYesNoCallback; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; import noppes.npcs.client.Client; import noppes.npcs.client.NoppesUtil; 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.controllers.data.*; import noppes.npcs.entity.EntityNPCInterface; import java.util.ArrayList; @@ -17,7 +17,7 @@ import java.util.HashMap; import java.util.List; import java.util.Vector; -public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData, ISubGuiListener +public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData, ISubGuiListener, GuiYesNoCallback { private GuiCustomScroll scrollAnimations; private HashMap data = new HashMap(); @@ -167,9 +167,8 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol } if(button.id == 1){ if(data.containsKey(scrollAnimations.getSelected())) { - Client.sendData(EnumPacketServer.AnimationRemove, data.get(selected)); - scrollAnimations.clear(); - animation = new Animation(); + GuiYesNo guiyesno = new GuiYesNo(this, scrollAnimations.getSelected(), StatCollector.translateToLocal("gui.delete"), 1); + displayGuiScreen(guiyesno); } } @@ -263,6 +262,20 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol } @Override - public void subGuiClosed(SubGuiInterface subgui) { - } + public void subGuiClosed(SubGuiInterface subgui) {} + + @Override + public void confirmClicked(boolean result, int id) { + NoppesUtil.openGUI(player, this); + if(!result) + return; + if(id == 1) { + if(data.containsKey(scrollAnimations.getSelected())) { + Client.sendData(EnumPacketServer.AnimationRemove, data.get(selected)); + scrollAnimations.clear(); + animation = new Animation(); + initGui(); + } + } + } } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java index 0954a8d8d..e46b6b3bf 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java @@ -1,8 +1,12 @@ package noppes.npcs.client.gui.global; import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiYesNo; +import net.minecraft.client.gui.GuiYesNoCallback; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; import noppes.npcs.client.Client; +import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.SubGuiEditText; import noppes.npcs.client.gui.SubGuiNpcDialog; import noppes.npcs.client.gui.util.*; @@ -16,7 +20,7 @@ import java.util.HashMap; import java.util.List; import java.util.Vector; -public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGroup, IScrollData, ISubGuiListener,ICustomScrollListener, IGuiData +public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGroup, IScrollData, ISubGuiListener,ICustomScrollListener, IGuiData, GuiYesNoCallback { private GuiCustomScroll catScroll; public GuiCustomScroll dialogScroll; @@ -180,8 +184,8 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou // Remove Cat if(id == 5){ if(catData.containsKey(catScroll.getSelected())) { - Client.sendData(EnumPacketServer.DialogCategoryRemove, category.id); - clearCategory(); + GuiYesNo guiyesno = new GuiYesNo(this, catScroll.getSelected(), StatCollector.translateToLocal("gui.delete"), 5); + displayGuiScreen(guiyesno); } } if(category != null && category.id >= 0){ @@ -201,9 +205,8 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou // Remove Dialog if(id == 2) { if (dialogData.containsKey(dialogScroll.getSelected())) { - Client.sendData(EnumPacketServer.DialogRemove, dialog.id, true); - dialog = new Dialog(); - dialogData.clear(); + GuiYesNo guiyesno = new GuiYesNo(this, dialogScroll.getSelected(), StatCollector.translateToLocal("gui.delete"), 2); + displayGuiScreen(guiyesno); } } // Edit Dialog @@ -413,4 +416,25 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou @Override public void setSelectedGroup(String selected) {} + + @Override + public void confirmClicked(boolean result, int id) { + NoppesUtil.openGUI(player, this); + if(!result) + return; + if(id == 5) { + if(catData.containsKey(catScroll.getSelected())) { + Client.sendData(EnumPacketServer.DialogCategoryRemove, category.id); + clearCategory(); + } + } + if(id == 2) { + if (dialogData.containsKey(dialogScroll.getSelected())) { + Client.sendData(EnumPacketServer.DialogRemove, dialog.id, true); + dialog = new Dialog(); + dialogData.clear(); + } + } + updateButtons(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageFactions.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageFactions.java index 269370208..a5525eee4 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageFactions.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageFactions.java @@ -1,25 +1,30 @@ package noppes.npcs.client.gui.global; import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiYesNo; +import net.minecraft.client.gui.GuiYesNoCallback; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; import noppes.npcs.client.Client; +import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.SubGuiColorSelector; import noppes.npcs.client.gui.SubGuiNpcFactionPoints; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.controllers.data.Faction; +import noppes.npcs.controllers.data.Quest; import noppes.npcs.entity.EntityNPCInterface; import java.util.*; -public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData, ISubGuiListener +public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData, ISubGuiListener, GuiYesNoCallback { private GuiCustomScroll scrollFactions; private HashMap data = new HashMap(); private Faction faction = new Faction(); private String selected = null; private String search = ""; - + public GuiNPCManageFactions(EntityNPCInterface npc) { super(npc); @@ -29,10 +34,10 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat public void initGui() { super.initGui(); - + this.addButton(new GuiNpcButton(0,guiLeft + 368, guiTop + 8, 45, 20, "gui.add")); this.addButton(new GuiNpcButton(1,guiLeft + 368, guiTop + 32, 45, 20, "gui.remove")); - + if(scrollFactions == null){ scrollFactions = new GuiCustomScroll(this,0, 0); scrollFactions.setSize(143, 185); @@ -44,7 +49,7 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat if (faction.id == -1) return; - + this.addTextField(new GuiNpcTextField(0, this, guiLeft + 40, guiTop + 4, 136, 20, faction.name)); getTextField(0).setMaxStringLength(20); addLabel(new GuiNpcLabel(0,"gui.name", guiLeft + 8, guiTop + 9)); @@ -68,9 +73,9 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat addLabel(new GuiNpcLabel(4,"faction.attacked", guiLeft + 8, guiTop + 97)); this.addButton(new GuiNpcButton(4,guiLeft + 100, guiTop + 92, 45, 20, new String[]{"gui.no","gui.yes"},faction.getsAttacked?1:0)); - + addLabel(new GuiNpcLabel(6,"faction.hostiles", guiLeft + 8, guiTop + 120)); - + ArrayList hostileList = new ArrayList(scrollFactions.getList()); hostileList.remove(faction.name); @@ -79,7 +84,7 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat if(!s.equals(faction.name) && faction.attackFactions.contains(data.get(s))) set.add(s); } - + GuiCustomScroll scrollHostileFactions = new GuiCustomScroll(this,1,true); scrollHostileFactions.setSize(163, 78); scrollHostileFactions.guiLeft = guiLeft + 4; @@ -98,17 +103,15 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat while(data.containsKey(name)) name += "_"; Faction faction = new Faction(-1, name, 0x00FF00, 1000); - + NBTTagCompound compound = new NBTTagCompound(); faction.writeNBT(compound); Client.sendData(EnumPacketServer.FactionSave, compound); } if(button.id == 1){ if(data.containsKey(scrollFactions.getSelected())) { - Client.sendData(EnumPacketServer.FactionRemove, data.get(selected)); - scrollFactions.clear(); - faction = new Faction(); - initGui(); + GuiYesNo guiyesno = new GuiYesNo(this, scrollFactions.getSelected(), StatCollector.translateToLocal("gui.delete"), 1); + displayGuiScreen(guiyesno); } } if(button.id == 2){ @@ -129,7 +132,7 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat public void setGuiData(NBTTagCompound compound) { this.faction = new Faction(); faction.readNBT(compound); - + setSelected(faction.name); initGui(); } @@ -165,17 +168,17 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat String name = scrollFactions.getSelected(); this.data = data; scrollFactions.setList(getSearchList()); - + if(name != null) scrollFactions.setSelected(name); } - + @Override public void setSelected(String selected) { this.selected = selected; scrollFactions.setSelected(selected); } - + @Override public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { if(guiCustomScroll.id == 0) @@ -195,21 +198,21 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat save(); } } - + public void save() { if(selected != null && data.containsKey(selected) && faction != null){ NBTTagCompound compound = new NBTTagCompound(); faction.writeNBT(compound); - + Client.sendData(EnumPacketServer.FactionSave, compound); } } - + @Override public void unFocused(GuiNpcTextField guiNpcTextField) { - if(faction.id == -1) + if(faction.id == -1) return; - + if(guiNpcTextField.id == 0) { String name = guiNpcTextField.getText(); if(!name.isEmpty() && !data.containsKey(name)){ @@ -230,8 +233,8 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat } faction.color = color; guiNpcTextField.setTextColor(faction.color); - } - + } + } @Override @@ -242,4 +245,19 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat } } + @Override + public void confirmClicked(boolean result, int id) { + NoppesUtil.openGUI(player, this); + if(!result) + return; + if(id == 1) { + if(data.containsKey(scrollFactions.getSelected())) { + Client.sendData(EnumPacketServer.FactionRemove, data.get(selected)); + scrollFactions.clear(); + faction = new Faction(); + initGui(); + } + } + } + } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java index 5343f3665..0005af669 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java @@ -2,12 +2,17 @@ package noppes.npcs.client.gui.global; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiYesNo; +import net.minecraft.client.gui.GuiYesNoCallback; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; import noppes.npcs.client.Client; +import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.SubGuiEditText; import noppes.npcs.client.gui.SubGuiNpcQuest; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumPacketServer; +import noppes.npcs.controllers.data.Dialog; import noppes.npcs.controllers.data.Quest; import noppes.npcs.controllers.data.QuestCategory; import noppes.npcs.entity.EntityNPCInterface; @@ -17,7 +22,7 @@ import java.util.HashMap; import java.util.List; import java.util.Vector; -public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup, IScrollData, ISubGuiListener, ICustomScrollListener, IGuiData +public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup, IScrollData, ISubGuiListener, ICustomScrollListener, IGuiData, GuiYesNoCallback { private GuiCustomScroll catScroll; public GuiCustomScroll questScroll; @@ -184,8 +189,8 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup, // Remove Cat if(id == 5){ if(catData.containsKey(catScroll.getSelected())) { - Client.sendData(EnumPacketServer.QuestCategoryRemove, category.id); - clearCategory(); + GuiYesNo guiyesno = new GuiYesNo(this, catScroll.getSelected(), StatCollector.translateToLocal("gui.delete"), 5); + displayGuiScreen(guiyesno); } } if(category != null && category.id >= 0){ @@ -205,9 +210,8 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup, // Remove Quest if(id == 2) { if (questData.containsKey(questScroll.getSelected())) { - Client.sendData(EnumPacketServer.QuestRemove, quest.id, true); - quest = new Quest(); - questData.clear(); + GuiYesNo guiyesno = new GuiYesNo(this, questScroll.getSelected(), StatCollector.translateToLocal("gui.delete"), 2); + displayGuiScreen(guiyesno); } } // Edit Quest @@ -418,4 +422,22 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup, @Override public void setSelectedGroup(String selected) {} + @Override + public void confirmClicked(boolean result, int id) { + NoppesUtil.openGUI(player, this); + if(!result) + return; + if(id == 5) { + if(catData.containsKey(catScroll.getSelected())) { + Client.sendData(EnumPacketServer.QuestCategoryRemove, category.id); + clearCategory(); + } + } + if(id == 2) { + Client.sendData(EnumPacketServer.QuestRemove, quest.id, true); + quest = new Quest(); + questData.clear(); + } + updateButtons(); + } }