mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-26 17:23:07 +00:00
More work on the party GUI, which can now properly start a party. Created a party controller.
This commit is contained in:
1 parent
0ecc94bdb0
commit
2ef38dfdf4
6 files changed
+263
-23
No files matched your search
@@ -7,6 +7,7 @@ import noppes.npcs.client.gui.OverlayQuestTracking;
|
||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||
import noppes.npcs.client.renderer.ImageData;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import noppes.npcs.controllers.data.Party;
|
||||
import noppes.npcs.controllers.data.SkinOverlay;
|
||||
import noppes.npcs.util.CacheHashMap;
|
||||
|
||||
@@ -22,6 +23,8 @@ public class ClientCacheHandler {
|
||||
public static HashMap<UUID, HashMap<Integer, SkinOverlay>> skinOverlays = new HashMap<>();
|
||||
public static HashMap<UUID, AnimationData> playerAnimations = new HashMap<>();
|
||||
|
||||
public static Party party;
|
||||
|
||||
public static ImageData getImageData(String directory) {
|
||||
synchronized (imageDataCache) {
|
||||
if (!imageDataCache.containsKey(directory)) {
|
||||
@@ -47,5 +50,6 @@ public class ClientCacheHandler {
|
||||
ClientCacheHandler.customOverlays.clear();
|
||||
ClientCacheHandler.skinOverlays.clear();
|
||||
ClientCacheHandler.playerAnimations.clear();
|
||||
party = null;
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,19 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.client.CustomNpcResourceListener;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.data.Party;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tconstruct.client.tabs.InventoryTabQuests;
|
||||
import tconstruct.client.tabs.TabRegistry;
|
||||
|
||||
public class GuiParty extends GuiNPCInterface implements ITopButtonListener,ICustomScrollListener, IGuiData {
|
||||
import java.util.UUID;
|
||||
|
||||
public class GuiParty extends GuiNPCInterface implements ITextfieldListener, ITopButtonListener,ICustomScrollListener, IGuiData {
|
||||
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
|
||||
private final EntityPlayer player;
|
||||
|
||||
@@ -28,10 +34,12 @@ public class GuiParty extends GuiNPCInterface implements ITopButtonListener,ICus
|
||||
ySize = 180;
|
||||
drawDefaultBackground = false;
|
||||
|
||||
//TODO: Send initial data packet
|
||||
Client.sendData(EnumPacketServer.GetPartyData);
|
||||
}
|
||||
|
||||
public void initGui(){
|
||||
Party party = ClientCacheHandler.party;
|
||||
|
||||
super.initGui();
|
||||
guiTop +=10;
|
||||
|
||||
@@ -48,10 +56,93 @@ public class GuiParty extends GuiNPCInterface implements ITopButtonListener,ICus
|
||||
partyButton.active = true;
|
||||
partyButton.renderStack = new ItemStack(CustomItems.bag);
|
||||
addButton(partyButton);
|
||||
|
||||
if (receivedData) {
|
||||
if (party == null) {
|
||||
//
|
||||
//create party button
|
||||
//
|
||||
GuiNpcButton createPartyButton = new GuiNpcButton(200, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 20, "Create Party");
|
||||
createPartyButton.width = 100;
|
||||
this.addButton(createPartyButton);
|
||||
|
||||
this.addLabel(new GuiNpcLabel(201, "You're not in a party!", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 30));
|
||||
this.addLabel(new GuiNpcLabel(202, "Either wait for an invite", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 20));
|
||||
this.addLabel(new GuiNpcLabel(203, "or create one.", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 10));
|
||||
|
||||
//party invites list
|
||||
//
|
||||
GuiCustomScroll inviteScroll = new GuiCustomScroll(this, 210, false);
|
||||
inviteScroll.setSize(150, 160);
|
||||
inviteScroll.guiLeft = guiLeft + 5;
|
||||
inviteScroll.guiTop = guiTop + 5;
|
||||
this.addScroll(inviteScroll);
|
||||
|
||||
GuiNpcButton acceptButton = new GuiNpcButton(215, guiLeft + 15, guiTop + ySize - 12, "Accept");
|
||||
acceptButton.width = 60;
|
||||
this.addButton(acceptButton);
|
||||
|
||||
GuiNpcButton ignoreButton = new GuiNpcButton(220, guiLeft + 80, guiTop + ySize - 12, "Ignore");
|
||||
ignoreButton.width = 60;
|
||||
this.addButton(ignoreButton);
|
||||
} else {
|
||||
//
|
||||
//party player list
|
||||
//
|
||||
GuiCustomScroll playerScroll = new GuiCustomScroll(this, 300, false);
|
||||
playerScroll.setSize(150, 160);
|
||||
playerScroll.guiLeft = guiLeft + 5;
|
||||
playerScroll.guiTop = guiTop + 5;
|
||||
this.addScroll(playerScroll);
|
||||
|
||||
//set leader button
|
||||
//
|
||||
GuiNpcButton leaderButton = new GuiNpcButton(305, guiLeft + 5, guiTop + ySize - 12, "Make Leader");
|
||||
leaderButton.width = 70;
|
||||
this.addButton(leaderButton);
|
||||
|
||||
//kick player button
|
||||
//
|
||||
GuiNpcButton kickButton = new GuiNpcButton(315, guiLeft + 85, guiTop + ySize - 12, "Kick");
|
||||
kickButton.width = 70;
|
||||
this.addButton(kickButton);
|
||||
|
||||
//toggle friendly fire
|
||||
//
|
||||
GuiNpcButton friendlyFireButton = new GuiNpcButton(320, guiLeft + xSize/2 + 95, guiTop + ySize/2, new String[] {"On", "Off"}, 0); //party.friendlyFire() ? 0 : 1
|
||||
friendlyFireButton.width = 40;
|
||||
this.addButton(friendlyFireButton);
|
||||
|
||||
GuiNpcLabel friendlyFireLabel = new GuiNpcLabel(321, "Friendly Fire:", guiLeft + xSize/2 + 20, guiTop + ySize/2 + 5);
|
||||
this.addLabel(friendlyFireLabel);
|
||||
|
||||
//send invite button (opens subgui)
|
||||
//
|
||||
GuiNpcTextField playerTextField = new GuiNpcTextField(325, this, guiLeft + xSize/2 + 20, guiTop + ySize/2 + 40,100, 20, "");
|
||||
this.addTextField(playerTextField);
|
||||
|
||||
GuiNpcButton inviteButton = new GuiNpcButton(330, guiLeft + xSize/2 + 125, guiTop + ySize/2 + 40, "Invite");
|
||||
inviteButton.width = 50;
|
||||
this.addButton(inviteButton);
|
||||
|
||||
//disband party
|
||||
//
|
||||
GuiNpcButton disbandButton = new GuiNpcButton(335, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 70, "Disband Party");
|
||||
disbandButton.width = 100;
|
||||
this.addButton(disbandButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton){
|
||||
switch (guibutton.id) {
|
||||
case 200:
|
||||
Client.sendData(EnumPacketServer.CreateParty);
|
||||
receivedData = false;
|
||||
break;
|
||||
}
|
||||
|
||||
initGui();
|
||||
|
||||
if (guibutton.id == 100) {
|
||||
@@ -77,17 +168,19 @@ public class GuiParty extends GuiNPCInterface implements ITopButtonListener,ICus
|
||||
periods += ".";
|
||||
}
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("gui.loading") + periods,guiLeft + xSize/2,guiTop + 80, CustomNpcResourceListener.DefaultTextColor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char c, int i)
|
||||
{
|
||||
if (i == 1 || i == mc.gameSettings.keyBindInventory.getKeyCode()) // inventory key
|
||||
{
|
||||
mc.displayGuiScreen(null);
|
||||
mc.setIngameFocus();
|
||||
super.keyTyped(c, i);
|
||||
if (!GuiNpcTextField.isFieldActive()) {
|
||||
if (i == 1 || i == mc.gameSettings.keyBindInventory.getKeyCode()) // inventory key
|
||||
{
|
||||
mc.displayGuiScreen(null);
|
||||
mc.setIngameFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +193,17 @@ public class GuiParty extends GuiNPCInterface implements ITopButtonListener,ICus
|
||||
@Override
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
this.receivedData = true;
|
||||
|
||||
if (compound.hasKey("PartyUUID")) {
|
||||
Party party = ClientCacheHandler.party;
|
||||
UUID uuid = UUID.fromString(compound.getString("PartyUUID"));
|
||||
if (party == null || !party.getPartyUUID().equals(uuid)) {
|
||||
ClientCacheHandler.party = new Party(uuid);
|
||||
party = ClientCacheHandler.party;
|
||||
}
|
||||
party.readFromNBT(compound);
|
||||
}
|
||||
|
||||
initGui();
|
||||
}
|
||||
|
||||
@@ -118,4 +222,9 @@ public class GuiParty extends GuiNPCInterface implements ITopButtonListener,ICus
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user