Implemented proper functionality for the quest party options GUI.

This commit is contained in:
luisc committed 2024-02-13 17:30:01 -06:00
1 parent 71a272a08b
commit 680fc98d51
5 files changed
+91 -23

No files matched your search

@@ -5,16 +5,17 @@ import net.minecraft.util.StatCollector;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.constants.EnumPartyExchange;
import noppes.npcs.constants.EnumPartyRequirements;
import noppes.npcs.controllers.data.FactionOptions;
import noppes.npcs.controllers.data.PartyOptions;
import java.util.HashMap;
import java.util.Vector;
public class SubGuiNpcPartyOptions extends SubGuiInterface
public class SubGuiNpcPartyOptions extends SubGuiInterface implements ITextfieldListener
{
private final PartyOptions options;
private HashMap<String,Integer> data = new HashMap<>();
public SubGuiNpcPartyOptions(PartyOptions options)
{
@@ -29,16 +30,66 @@ public class SubGuiNpcPartyOptions extends SubGuiInterface
{
super.initGui();
//Allow party - T/F button
addButton(new GuiNpcButton(0, guiLeft + 90, guiTop + 10, 60, 20,
new String[]{"gui.no", "gui.yes"}, options.allowParty ? 1 : 0));
addLabel(new GuiNpcLabel(1, "party.allowParty", guiLeft + 10, guiTop + 17));
if (options.allowParty) {
//Party requirements - enum button
addButton(new GuiNpcButton(5, guiLeft + 110, guiTop + 35, 60, 20,
EnumPartyRequirements.values(), options.partyRequirements.ordinal()));
addLabel(new GuiNpcLabel(6, "party.partyRequirements", guiLeft + 10, guiTop + 42));
//Party rewards - enum button
addButton(new GuiNpcButton(10, guiLeft + 110, guiTop + 60, 60, 20,
EnumPartyExchange.values(), options.rewardControl.ordinal()));
addLabel(new GuiNpcLabel(11, "party.partyRewards", guiLeft + 10, guiTop + 67));
//Complete for - enum button
addButton(new GuiNpcButton(15, guiLeft + 110, guiTop + 85, 60, 20,
EnumPartyExchange.values(), options.completeFor.ordinal()));
addLabel(new GuiNpcLabel(16, "party.completeFor", guiLeft + 10, guiTop + 92));
//max party size - number field
GuiNpcTextField textField = new GuiNpcTextField(20, this, guiLeft + 110, guiTop + 110,
40, 20, String.valueOf(options.maxPartySize));
textField.integersOnly = true;
textField.setMinMaxDefault(1, Integer.MAX_VALUE, 4);
addTextField(textField);
addLabel(new GuiNpcLabel(20, "party.maxPartySize", guiLeft + 10, guiTop + 117));
}
addButton(new GuiNpcButton(66, guiLeft + 20, guiTop + 192, 90, 20, "gui.done"));
}
protected void actionPerformed(GuiButton guibutton)
{
int id = guibutton.id;
switch (id) {
case 0:
options.allowParty = !options.allowParty;
break;
case 5:
options.partyRequirements = EnumPartyRequirements.valueOf(guibutton.displayString);
break;
case 10:
options.rewardControl = EnumPartyExchange.valueOf(guibutton.displayString);
break;
case 15:
options.completeFor = EnumPartyExchange.valueOf(guibutton.displayString);
break;
case 66:
close();
break;
}
initGui();
}
if(id == 66)
{
close();
@Override
public void unFocused(GuiNpcTextField textfield) {
if (textfield.id == 20) {
options.maxPartySize = textfield.getInteger();
}
}
}
@@ -63,8 +63,8 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener,
addButton(new GuiNpcButton(6, guiLeft + 240, guiTop + 76, 60, 20, new String[]{"quest.item","quest.dialog","quest.kill","quest.location","quest.areakill"},quest.type.ordinal()));
addButton(new GuiNpcButton(7, guiLeft + 303, guiTop + 76,50, 20, "selectServer.edit"));
addLabel(new GuiNpcLabel(17, "party.options", guiLeft + 180, guiTop + 105));
addButton(new GuiNpcButton(18, guiLeft + 303, guiTop + 100, 50, 20, "selectServer.edit"));
addLabel(new GuiNpcLabel(17, "party.options", guiLeft + 180, guiTop + 135));
addButton(new GuiNpcButton(18, guiLeft + 303, guiTop + 130, 50, 20, "selectServer.edit"));
this.addButton(new GuiNpcButton(9, guiLeft + 7, guiTop + 102,90, 20, new String[]{"quest.npc","quest.instant"},quest.completion.ordinal()));
if(quest.completerNpc.isEmpty() && npc != null)
@@ -90,7 +90,7 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener,
if(!quest.mail.subject.isEmpty())
getButton(13).setDisplayText(quest.mail.subject);
}
public void buttonEvent(GuiButton guibutton)
{
GuiNpcButton button = (GuiNpcButton) guibutton;
@@ -4,12 +4,14 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.StatCollector;
import java.util.ArrayList;
public class GuiNpcButton extends GuiButton{
protected String[] display;
private int displayValue = 0;
public int id;
public GuiNpcButton(int i, int j, int k, String s) {
super(i, j, k, StatCollector.translateToLocal(s));
id = i;
@@ -29,28 +31,42 @@ public class GuiNpcButton extends GuiButton{
this.display = display;
this.displayValue = display.length == 0?0:val % display.length;
}
public GuiNpcButton(int i, int j, int k, int l, int m, Enum<?>[] displayEnums,
int val) {
this(i, j, k, l, m, displayEnums.length == 0 ? "" : displayEnums[val % displayEnums.length].toString());
ArrayList<String> strings = new ArrayList<>();
for (Enum<?> e : displayEnums) {
strings.add(e.toString());
}
this.display = strings.toArray(new String[0]);
this.displayValue = display.length == 0?0:val % display.length;
}
public void setDisplayText(String text){
this.displayString = StatCollector.translateToLocal(text);
}
public int getValue(){
return displayValue;
}
public void setEnabled(boolean bo){
this.enabled = bo;
}
public void setVisible(boolean b) {
this.visible = b;
}
}
public boolean getVisible() {
return visible;
}
public void setDisplay(int value){
this.displayValue = value;
this.setDisplayText(display[value]);
}
}
public void setTextColor(int color){
this.packedFGColour = color;
}
@@ -65,7 +81,7 @@ public class GuiNpcButton extends GuiButton{
}
return bo;
}
public int getWidth() {
return width;
}
@@ -1,23 +1,18 @@
package noppes.npcs.controllers.data;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentTranslation;
import noppes.npcs.api.handler.data.IPartyOptions;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.constants.EnumPartyExchange;
import noppes.npcs.constants.EnumPartyRequirements;
import noppes.npcs.controllers.FactionController;
import noppes.npcs.controllers.PlayerDataController;
public class PartyOptions implements IPartyOptions {
public boolean allowParty = false;
public EnumPartyRequirements partyRequirements = EnumPartyRequirements.Leader;
public EnumPartyExchange rewardControl = EnumPartyExchange.Leader;
public EnumPartyExchange completeFor = EnumPartyExchange.Leader;
public int maxPartySize = ConfigMain.DefaultMaxPartySize;
public void readFromNBT(NBTTagCompound compound)
{
// Party Management