Search in sources :

Example 1 with GuiQuest

use of betterquesting.client.gui2.GuiQuest in project BetterQuesting by Funwayguy.

the class GuiPrerequisiteEditor method actionPerformed.

@Override
public void actionPerformed(GuiButton button) {
    super.actionPerformed(button);
    if (button.id == 1) {
        createQuest();
    } else if (button.id > 1) {
        int column = button.id & 7;
        int id = (button.id >> 3) - 2;
        IQuest q = QuestDatabase.INSTANCE.getValue(id);
        if (id < 0 || q == null) {
            // Invalid quest ID
            return;
        } else if (// Edit quest
        column == 0 || column == 3) {
            mc.displayGuiScreen(new GuiQuest(this, id));
        } else if (// Remove quest
        column == 1) {
            quest.getPrerequisites().remove(q);
            SendChanges();
        } else if (// Delete quest
        column == 4) {
            NBTTagCompound tags = new NBTTagCompound();
            // Delete quest
            tags.setInteger("action", EnumPacketAction.REMOVE.ordinal());
            tags.setInteger("questID", id);
            PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.QUEST_EDIT.GetLocation(), tags));
        } else if (// Add quest
        column == 2) {
            quest.getPrerequisites().add(q);
            SendChanges();
        }
    }
}
Also used : GuiQuest(betterquesting.client.gui2.GuiQuest) IQuest(betterquesting.api.questing.IQuest) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 2 with GuiQuest

use of betterquesting.client.gui2.GuiQuest in project BetterQuesting by Funwayguy.

the class GuiQuestLineEditorB method actionPerformed.

@Override
public void actionPerformed(GuiButton button) {
    super.actionPerformed(button);
    if (button.id == 1) {
        createQuest();
    } else if (button.id > 1) {
        // Line listing (0 = quest, 1 = quest delete, 2 = registry)
        int column = button.id & 7;
        int id = (button.id >> 3) - 2;
        if (// Edit quest
        column == 0 || column == 3) {
            if (id >= 0) {
                IQuest q = QuestDatabase.INSTANCE.getValue(id);
                if (q != null) {
                    mc.displayGuiScreen(new GuiQuest(this, id));
                }
            }
        } else if (// Remove quest
        column == 1 && line != null) {
            line.removeKey(id);
            // RefreshColumns();
            SendChanges(EnumPacketAction.EDIT, lineID);
        } else if (// Delete quest
        column == 4 && id >= 0) {
            NBTTagCompound tags = new NBTTagCompound();
            // Delete quest
            tags.setInteger("action", EnumPacketAction.REMOVE.ordinal());
            tags.setInteger("questID", id);
            PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.QUEST_EDIT.GetLocation(), tags));
        } else if (// Add quest
        column == 2 && line != null && id >= 0) {
            IQuestLineEntry qe = new QuestLineEntry(0, 0);
            int x1 = 0;
            int y1 = 0;
            topLoop: while (true) {
                for (IQuestLineEntry qe2 : line.getAllValues()) {
                    int x2 = qe2.getPosX();
                    int y2 = qe2.getPosY();
                    int s2 = qe2.getSize();
                    if (x1 >= x2 && x1 < x2 + s2 && y1 >= y2 && y1 < y2 + s2) {
                        x1 += s2;
                        x2 += s2;
                        // We're in the way, move over and try again
                        continue topLoop;
                    }
                }
                break;
            }
            qe.setPosition(x1, y1);
            line.add(qe, id);
            RefreshColumns();
            SendChanges(EnumPacketAction.EDIT, lineID);
        }
    }
}
Also used : GuiQuest(betterquesting.client.gui2.GuiQuest) IQuest(betterquesting.api.questing.IQuest) IQuestLineEntry(betterquesting.api.questing.IQuestLineEntry) QuestLineEntry(betterquesting.questing.QuestLineEntry) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IQuestLineEntry(betterquesting.api.questing.IQuestLineEntry) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 3 with GuiQuest

use of betterquesting.client.gui2.GuiQuest in project BetterQuesting by Funwayguy.

the class ToolboxToolOpen method onMouseClick.

@Override
public void onMouseClick(int mx, int my, int click) {
    if (click != 0) {
        return;
    }
    GuiButtonQuestInstance btn = gui.getQuestLine().getButtonAt(mx, my);
    if (btn != null) {
        int qID = QuestDatabase.INSTANCE.getKey(btn.getQuest());
        Minecraft mc = Minecraft.getMinecraft();
        btn.playPressSound(mc.getSoundHandler());
        mc.displayGuiScreen(new GuiQuest(mc.currentScreen, qID));
    }
}
Also used : GuiButtonQuestInstance(betterquesting.api.client.gui.controls.GuiButtonQuestInstance) GuiQuest(betterquesting.client.gui2.GuiQuest) Minecraft(net.minecraft.client.Minecraft)

Aggregations

GuiQuest (betterquesting.client.gui2.GuiQuest)3 QuestingPacket (betterquesting.api.network.QuestingPacket)2 IQuest (betterquesting.api.questing.IQuest)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 GuiButtonQuestInstance (betterquesting.api.client.gui.controls.GuiButtonQuestInstance)1 IQuestLineEntry (betterquesting.api.questing.IQuestLineEntry)1 QuestLineEntry (betterquesting.questing.QuestLineEntry)1 Minecraft (net.minecraft.client.Minecraft)1