Fix GUI and SubGUI interaction mumbo jumbo

This commit is contained in:
Kam committed 2023-06-08 13:18:09 -04:00
1 parent cce4e7bcc7
commit 48354225a8
13 files changed
+71 -54

No files matched your search

@@ -44,9 +44,11 @@ public class GuiNPCDialogSelection extends GuiNPCInterface implements IScrollDat
{
super.initGui();
Vector<String> list = new Vector<String>();
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, "mco.template.button.select"));
}
@@ -50,7 +50,8 @@ public class GuiNPCLinesEdit extends GuiNPCInterface2 implements IGuiData
{
GuiNpcButton button = (GuiNpcButton) guibutton;
field = getTextField(button.id + 8);
setSubGui(gui = new GuiNpcSoundSelection(this, field.getText()));
gui = new GuiNpcSoundSelection(this, field.getText());
NoppesUtil.openGUI(player, gui);
}
@Override
@@ -8,6 +8,7 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.controllers.MusicController;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.entity.EntityNPCInterface;
@@ -15,12 +16,12 @@ import org.lwjgl.Sys;
import java.util.*;
public class GuiNpcSoundSelection extends SubGuiInterface {
public class GuiNpcSoundSelection extends GuiNPCInterface {
public GuiNPCStringSlot slot;
public String domain;
private final GuiScreen parent;
public GuiSelectionListener listener;
private String up = "..<" + StatCollector.translateToLocal("gui.up") + ">..";
@@ -41,6 +42,8 @@ public class GuiNpcSoundSelection extends SubGuiInterface {
}
drawDefaultBackground = false;
this.parent = parent;
if(parent instanceof GuiSelectionListener)
listener = (GuiSelectionListener) parent;
}
public void initGui()
@@ -88,7 +91,6 @@ public class GuiNpcSoundSelection extends SubGuiInterface {
initGui();
}
else{
System.out.println("OK");
if(parent instanceof GuiNPCInterface){
((GuiNPCInterface)parent).elementClicked();
}
@@ -96,6 +98,7 @@ public class GuiNpcSoundSelection extends SubGuiInterface {
((GuiNPCInterface2)parent).elementClicked();
}
close();
NoppesUtil.openGUI(player, parent);
}
}
@@ -107,7 +110,8 @@ public class GuiNpcSoundSelection extends SubGuiInterface {
MusicController.Instance.playSound(getSelected(), (float)player.posX, (float)player.posY, (float)player.posZ);
}
if(guibutton.id == 2){
displayGuiScreen(parent);
close();
NoppesUtil.openGUI(player, parent);
}
if(guibutton.id == 3){
if(slot.selected == null || slot.selected.equals(up))
@@ -4,6 +4,7 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.global.GuiNPCQuestSelection;
import noppes.npcs.client.gui.player.GuiMailmanWrite;
import noppes.npcs.client.gui.util.*;
@@ -33,7 +34,6 @@ public class SubGuiMailmanSendSetup extends SubGuiInterface implements ITextfiel
addButton(new GuiNpcButton(2, guiLeft + 29, guiTop + 100, "mailbox.write"));
addLabel(new GuiNpcLabel(3, "quest.quest", guiLeft + 13, guiTop + 135));
String title = mail.questTitle;
if(title.isEmpty())
@@ -62,14 +62,15 @@ public class SubGuiMailmanSendSetup extends SubGuiInterface implements ITextfiel
close();
}
if(id == 2){
GuiMailmanWrite.parent = parent;
GuiMailmanWrite.parent = getParent();
GuiMailmanWrite.mail = mail;
Client.sendData(EnumPacketServer.MailOpenSetup, mail.writeNBT());
}
if(id == 3){
this.setSubGui(questSelection = new GuiNPCQuestSelection(getParent(), mail.questId));
questSelection = new GuiNPCQuestSelection(npc, getParent(), mail.questId);
questSelection.listener = this;
NoppesUtil.openGUI(player, questSelection);
}
if(id == 4){
mail.questId = -1;
@@ -3,6 +3,7 @@ package noppes.npcs.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.global.GuiNPCQuestSelection;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumAvailabilityQuest;
@@ -20,7 +21,7 @@ public class SubGuiNpcAvailabilityQuest extends SubGuiInterface implements GuiSe
xSize = 316;
ySize = 216;
closeOnEsc = true;
}
}
@Override
public void initGui(){
@@ -64,6 +65,7 @@ public class SubGuiNpcAvailabilityQuest extends SubGuiInterface implements GuiSe
getButton(11).setDisplayText("availability.selectquest");
getButton(12).setDisplayText("availability.selectquest");
getButton(13).setDisplayText("availability.selectquest");
if(availabitily.questId >= 0){
Client.sendData(EnumPacketServer.QuestGet, availabitily.questId);
}
@@ -106,30 +108,29 @@ public class SubGuiNpcAvailabilityQuest extends SubGuiInterface implements GuiSe
availabitily.quest4Id = -1;
initGui();
}
if(button.id == 10){
slot = 1;
GuiNPCQuestSelection gui = new GuiNPCQuestSelection(getParent(), availabitily.questId);
GuiNPCQuestSelection gui = new GuiNPCQuestSelection(npc, getParent(), availabitily.questId);
gui.listener = this;
this.setSubGui(gui);
NoppesUtil.openGUI(player, gui);
}
if(button.id == 11){
slot = 2;
GuiNPCQuestSelection gui = new GuiNPCQuestSelection(getParent(), availabitily.quest2Id);
GuiNPCQuestSelection gui = new GuiNPCQuestSelection(npc, getParent(), availabitily.quest2Id);
gui.listener = this;
this.setSubGui(gui);
NoppesUtil.openGUI(player, gui);
}
if(button.id == 12){
slot = 3;
GuiNPCQuestSelection gui = new GuiNPCQuestSelection(getParent(), availabitily.quest3Id);
GuiNPCQuestSelection gui = new GuiNPCQuestSelection(npc, getParent(), availabitily.quest3Id);
gui.listener = this;
this.setSubGui(gui);
NoppesUtil.openGUI(player, gui);
}
if(button.id == 13){
slot = 4;
GuiNPCQuestSelection gui = new GuiNPCQuestSelection(getParent(), availabitily.quest4Id);
GuiNPCQuestSelection gui = new GuiNPCQuestSelection(npc, getParent(), availabitily.quest4Id);
gui.listener = this;
this.setSubGui(gui);
NoppesUtil.openGUI(player, gui);
}
if(button.id == 20){
@@ -38,21 +38,21 @@ public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener,
addLabel(new GuiNpcLabel(0,"ID", guiLeft + 178, guiTop + 4));
addLabel(new GuiNpcLabel(2, dialog.id + "", guiLeft + 178, guiTop + 14));
addLabel(new GuiNpcLabel(3, "dialog.dialogtext", guiLeft + 4, guiTop + 30));
addButton(new GuiNpcButton(3, guiLeft + 120, guiTop + 25, 50, 20, "selectServer.edit"));
addLabel(new GuiNpcLabel(4, "availability.options", guiLeft + 4, guiTop + 51));
addButton(new GuiNpcButton(4, guiLeft + 120, guiTop + 46, 50, 20, "selectServer.edit"));
addLabel(new GuiNpcLabel(5, "faction.options", guiLeft + 4, guiTop + 72));
addButton(new GuiNpcButton(5, guiLeft + 120, guiTop + 67, 50, 20, "selectServer.edit"));
addLabel(new GuiNpcLabel(6, "dialog.options", guiLeft + 4, guiTop + 93));
addButton(new GuiNpcButton(6, guiLeft + 120, guiTop + 89, 50, 20, "selectServer.edit"));
addLabel(new GuiNpcLabel(11, "dialog.visualOption", guiLeft + 4, guiTop + 115));
addButton(new GuiNpcButton(11, guiLeft + 120, guiTop + 110, 50, 20, "selectServer.edit"));
addLabel(new GuiNpcLabel(4, "availability.options", guiLeft + 4, guiTop + 51));
addButton(new GuiNpcButton(4, guiLeft + 120, guiTop + 46, 50, 20, "selectServer.edit"));
addLabel(new GuiNpcLabel(5, "faction.options", guiLeft + 4, guiTop + 72));
addButton(new GuiNpcButton(5, guiLeft + 120, guiTop + 67, 50, 20, "selectServer.edit"));
addButton(new GuiNpcButton(7, guiLeft + 4, guiTop + 134, 144, 20, "availability.selectquest"));
addButton(new GuiNpcButton(8, guiLeft + 150, guiTop + 134, 20, 20, "X"));
@@ -85,7 +85,7 @@ public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener,
setSubGui(new SubGuiNpcDialogOptions(dialog));
}
if(id == 7 && dialog.id >= 0){
setSubGui(new GuiNPCQuestSelection(this, dialog.quest));
NoppesUtil.openGUI(player, new GuiNPCQuestSelection(npc, this, dialog.quest));
}
if(id == 8 && dialog.id >= 0){
dialog.quest = -1;
@@ -93,7 +93,8 @@ public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener,
initGui();
}
if(id == 9 && dialog.id >= 0){
setSubGui(gui = new GuiNpcSoundSelection(this, getTextField(2).getText()));
gui = new GuiNpcSoundSelection(this, getTextField(2).getText());
NoppesUtil.openGUI(player, gui);
}
if(id == 10){
setSubGui(new SubGuiNpcDialogExtra(dialog));
@@ -115,8 +115,9 @@ public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfi
int id = guibutton.id;
if(id == 7)
{
setSubGui(gui = new GuiNpcSoundSelection(parent, getTextField(7).getText()));
}
gui = new GuiNpcSoundSelection(parent, getTextField(7).getText());
NoppesUtil.openGUI(player, gui);
}
if(id == 66)
{
close();
@@ -50,7 +50,8 @@ public class GuiNPCSoundsMenu extends GuiNPCInterface2 implements ITextfieldList
npc.advanced.disablePitch =((GuiNpcButton)button).getValue() == 0;
else{
selectedField = getTextField(button.id);
setSubGui(gui = new GuiNpcSoundSelection(this, selectedField.getText()));
gui = new GuiNpcSoundSelection(this, selectedField.getText());
NoppesUtil.openGUI(player, gui);
}
}
@@ -3,31 +3,36 @@ package noppes.npcs.client.gui.global;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashMap;
import java.util.Vector;
public class GuiNPCQuestSelection extends SubGuiInterface implements IScrollData
public class GuiNPCQuestSelection extends GuiNPCInterface implements IScrollData
{
private GuiNPCStringSlot slot;
private HashMap<String,Integer> data;
private GuiScreen parent;
private HashMap<String,Integer> data = new HashMap<String,Integer>();
private int quest;
private boolean selectCategory = true;
public GuiSelectionListener listener;
private int quest;
public GuiNPCQuestSelection(GuiScreen parent, int quest)
public GuiNPCQuestSelection(EntityNPCInterface npc, GuiScreen parent, int quest)
{
super(npc);
drawDefaultBackground = false;
title = "Select Quest Category";
data = new HashMap<String, Integer>();
this.parent = parent;
this.quest = quest;
if(quest >= 0){
Client.sendData(EnumPacketServer.QuestsGetFromQuest, quest);
selectCategory = false;
title = "Select Dialog";
title = "Select Quest";
}else
Client.sendData(EnumPacketServer.QuestCategoriesGet, quest);
@@ -35,6 +40,10 @@ public class GuiNPCQuestSelection extends SubGuiInterface implements IScrollData
listener = (GuiSelectionListener) parent;
}
public String getSelected(){
return slot.selected;
}
public void initGui()
{
super.initGui();
@@ -62,22 +71,19 @@ public class GuiNPCQuestSelection extends SubGuiInterface implements IScrollData
{
if(selectCategory){
close();
NoppesUtil.openGUI(player, parent);
}else{
title = "Select Dialog Category";
title = "Select Quest Category";
selectCategory = true;
Client.sendData(EnumPacketServer.QuestCategoriesGet, quest);
}
}
if(id == 4)
{
if(slot.selected == null || slot.selected.isEmpty())
return;
doubleClicked();
}
}
public String getSelected(){
return slot.selected;
}
public void doubleClicked() {
if(slot.selected == null || slot.selected.isEmpty())
return;
@@ -89,14 +95,8 @@ public class GuiNPCQuestSelection extends SubGuiInterface implements IScrollData
else{
quest = data.get(slot.selected);
close();
NoppesUtil.openGUI(player, parent);
}
}
@Override
public void close() {
this.save();
super.close();
}
public void save() {
@@ -1,6 +1,7 @@
package noppes.npcs.client.gui.global;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.SubGuiMailmanSendSetup;
import noppes.npcs.client.gui.SubGuiNpcCommand;
import noppes.npcs.client.gui.SubGuiNpcFactionOptions;
@@ -54,7 +55,7 @@ public class SubGuiNpcQuestAdvanced extends SubGuiInterface implements ITextfiel
}
if(button.id == 11 && quest.id >= 0){
this.setSubGui(new GuiNPCQuestSelection(getParent(), quest.nextQuestid));
NoppesUtil.openGUI(player, new GuiNPCQuestSelection(npc, getParent(), quest.nextQuestid));
}
if(button.id == 12 && quest.id >= 0){
@@ -65,7 +65,9 @@ public class GuiNpcBard extends GuiNPCInterface2
if(button.id == 0)
{
setSubGui(gui = new GuiNpcSoundSelection(this, job.song));
gui = new GuiNpcSoundSelection(this, job.song);
NoppesUtil.openGUI(player, gui);
job.song = "";
MusicController.Instance.stopMusic();
}
@@ -3,6 +3,7 @@ package noppes.npcs.client.gui.roles;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.SubGuiNpcAvailability;
import noppes.npcs.client.gui.global.GuiNPCQuestSelection;
import noppes.npcs.client.gui.util.*;
@@ -76,7 +77,7 @@ public class GuiNpcConversation extends GuiNPCInterface2 implements ITextfieldLi
setSubGui(new SubGuiNpcConversationLine(line.text, line.sound));
}
if(button.id == 51){
this.setSubGui(questSelection = new GuiNPCQuestSelection(this, job.quest));
NoppesUtil.openGUI(player, new GuiNPCQuestSelection(npc, this, job.quest));
}
if(button.id == 52){
job.quest = -1;
@@ -44,7 +44,8 @@ public class SubGuiNpcConversationLine extends SubGuiInterface implements ITextf
protected void actionPerformed(GuiButton guibutton){
int id = guibutton.id;
if(id == 1){
setSubGui(gui = new GuiNpcSoundSelection(parent, sound));
gui = new GuiNpcSoundSelection(parent, sound);
NoppesUtil.openGUI(player, gui);
}
if(id == 2){
sound = "";