2018-09-13 12:03:28 -04:00
|
|
|
package noppes.npcs.client.gui;
|
|
|
|
|
|
2025-02-02 16:07:16 -05:00
|
|
|
import kamkeel.npcs.network.PacketClient;
|
|
|
|
|
import kamkeel.npcs.network.packets.request.MailOpenSetupPacket;
|
2018-09-13 12:03:28 -04:00
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
|
import net.minecraft.client.gui.GuiScreen;
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
import noppes.npcs.client.gui.player.GuiMailmanWrite;
|
2024-03-13 18:40:40 -04:00
|
|
|
import noppes.npcs.client.gui.select.GuiQuestSelection;
|
2023-01-12 21:33:06 -05:00
|
|
|
import noppes.npcs.client.gui.util.*;
|
2018-09-13 12:03:28 -04:00
|
|
|
import noppes.npcs.containers.ContainerMail;
|
2022-05-24 01:07:50 -05:00
|
|
|
import noppes.npcs.controllers.data.PlayerMail;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2025-03-13 17:14:45 -04:00
|
|
|
public class SubGuiMailmanSendSetup extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener {
|
2024-03-13 18:40:40 -04:00
|
|
|
|
2025-03-13 17:14:45 -04:00
|
|
|
private PlayerMail mail;
|
2024-03-13 18:40:40 -04:00
|
|
|
|
2025-03-13 17:14:45 -04:00
|
|
|
public SubGuiMailmanSendSetup(PlayerMail mail, GuiScreen parent) {
|
|
|
|
|
this.parent = parent;
|
2018-09-13 12:03:28 -04:00
|
|
|
xSize = 256;
|
|
|
|
|
setBackground("menubg.png");
|
2025-03-13 17:14:45 -04:00
|
|
|
this.mail = mail;
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2025-03-13 17:14:45 -04:00
|
|
|
@Override
|
|
|
|
|
public void initGui() {
|
|
|
|
|
super.initGui();
|
|
|
|
|
addLabel(new GuiNpcLabel(1, "mailbox.subject", guiLeft + 4, guiTop + 19));
|
|
|
|
|
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 60, guiTop + 14, 180, 20, mail.subject));
|
|
|
|
|
addLabel(new GuiNpcLabel(0, "mailbox.sender", guiLeft + 4, guiTop + 41));
|
|
|
|
|
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 60, guiTop + 36, 180, 20, mail.sender));
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2025-03-13 17:14:45 -04:00
|
|
|
addButton(new GuiNpcButton(2, guiLeft + 29, guiTop + 100, "mailbox.write"));
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2025-03-13 17:14:45 -04:00
|
|
|
addLabel(new GuiNpcLabel(3, "quest.quest", guiLeft + 13, guiTop + 135));
|
|
|
|
|
String title = mail.questTitle;
|
|
|
|
|
if (title.isEmpty())
|
|
|
|
|
title = "gui.select";
|
|
|
|
|
addButton(new GuiNpcButton(3, guiLeft + 70, guiTop + 130, 100, 20, title));
|
|
|
|
|
addButton(new GuiNpcButton(4, guiLeft + 171, guiTop + 130, 20, 20, "X"));
|
2024-03-13 18:40:40 -04:00
|
|
|
|
2025-03-13 17:14:45 -04:00
|
|
|
addButton(new GuiNpcButton(0, guiLeft + 26, guiTop + 190, 100, 20, "gui.done"));
|
|
|
|
|
addButton(new GuiNpcButton(1, guiLeft + 130, guiTop + 190, 100, 20, "gui.cancel"));
|
2024-03-13 18:40:40 -04:00
|
|
|
|
2025-03-13 17:14:45 -04:00
|
|
|
if (player.openContainer instanceof ContainerMail) {
|
|
|
|
|
ContainerMail container = (ContainerMail) player.openContainer;
|
|
|
|
|
mail.items = container.mail.items;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2025-03-13 17:14:45 -04:00
|
|
|
public void buttonEvent(GuiButton guibutton) {
|
|
|
|
|
int id = guibutton.id;
|
|
|
|
|
if (id == 0) {
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
if (id == 1) {
|
|
|
|
|
mail.questId = -1;
|
|
|
|
|
mail.questTitle = "";
|
|
|
|
|
mail.message = new NBTTagCompound();
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
if (id == 2) {
|
|
|
|
|
GuiMailmanWrite.parent = getParent();
|
|
|
|
|
GuiMailmanWrite.mail = mail;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2025-02-02 16:07:16 -05:00
|
|
|
PacketClient.sendClient(new MailOpenSetupPacket(mail.writeNBT()));
|
2025-03-13 17:14:45 -04:00
|
|
|
}
|
|
|
|
|
if (id == 3) {
|
2024-03-13 18:40:40 -04:00
|
|
|
setSubGui(new GuiQuestSelection(mail.questId));
|
2025-03-13 17:14:45 -04:00
|
|
|
}
|
|
|
|
|
if (id == 4) {
|
|
|
|
|
mail.questId = -1;
|
|
|
|
|
mail.questTitle = "";
|
|
|
|
|
initGui();
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2025-03-13 17:14:45 -04:00
|
|
|
@Override
|
|
|
|
|
public void selected(int ob, String name) {
|
2024-03-13 18:40:40 -04:00
|
|
|
mail.questId = ob;
|
|
|
|
|
mail.questTitle = name;
|
2025-03-13 17:14:45 -04:00
|
|
|
initGui();
|
|
|
|
|
}
|
2024-03-13 18:40:40 -04:00
|
|
|
|
2025-03-13 17:14:45 -04:00
|
|
|
@Override
|
|
|
|
|
public void save() {
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2025-03-13 17:14:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void unFocused(GuiNpcTextField textField) {
|
|
|
|
|
if (textField.id == 0)
|
|
|
|
|
mail.sender = textField.getText();
|
|
|
|
|
if (textField.id == 1)
|
|
|
|
|
mail.subject = textField.getText();
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|