Search in sources :

Example 1 with IQuestLineEntry

use of betterquesting.api.questing.IQuestLineEntry in project BetterQuesting by Funwayguy.

the class QuestLine method writeToNBT.

@Override
public NBTTagCompound writeToNBT(NBTTagCompound json, EnumSaveType saveType) {
    if (saveType != EnumSaveType.CONFIG) {
        return json;
    }
    json.setTag("properties", info.writeToNBT(new NBTTagCompound(), saveType));
    NBTTagList jArr = new NBTTagList();
    for (Entry<Integer, IQuestLineEntry> entry : questList.entrySet()) {
        NBTTagCompound qle = entry.getValue().writeToNBT(new NBTTagCompound(), saveType);
        qle.setInteger("id", entry.getKey());
        jArr.appendTag(qle);
    }
    json.setTag("quests", jArr);
    return json;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IQuestLineEntry(betterquesting.api.questing.IQuestLineEntry)

Example 2 with IQuestLineEntry

use of betterquesting.api.questing.IQuestLineEntry 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 IQuestLineEntry

use of betterquesting.api.questing.IQuestLineEntry in project BetterQuesting by Funwayguy.

the class ToolboxToolGrab method onMouseClick.

@Override
public void onMouseClick(int mx, int my, int click) {
    if (click == 1 && grabbed != null) {
        IQuestLineEntry qle = gui.getQuestLine().getQuestLine().getValue(grabID);
        if (qle != null) {
            // Reset position
            grabbed.x = qle.getPosX();
            grabbed.y = qle.getPosY();
        }
        grabbed = null;
        return;
    } else if (click != 0) {
        return;
    }
    if (grabbed == null) {
        grabbed = gui.getQuestLine().getButtonAt(mx, my);
        grabID = grabbed == null ? -1 : QuestDatabase.INSTANCE.getKey(grabbed.getQuest());
    } else {
        IQuestLine qLine = gui.getQuestLine().getQuestLine();
        int lID = QuestLineDatabase.INSTANCE.getKey(qLine);
        IQuestLineEntry qle = gui.getQuestLine().getQuestLine().getValue(grabID);
        if (qle != null) {
            qle.setPosition(grabbed.x, grabbed.y);
            // Sync Line
            NBTTagCompound tag2 = new NBTTagCompound();
            NBTTagCompound base2 = new NBTTagCompound();
            base2.setTag("line", qLine.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
            tag2.setTag("data", base2);
            tag2.setInteger("action", EnumPacketAction.EDIT.ordinal());
            tag2.setInteger("lineID", lID);
            PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.LINE_EDIT.GetLocation(), tag2));
        }
        grabbed = null;
        grabID = -1;
    }
}
Also used : IQuestLine(betterquesting.api.questing.IQuestLine) IQuestLineEntry(betterquesting.api.questing.IQuestLineEntry) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 4 with IQuestLineEntry

use of betterquesting.api.questing.IQuestLineEntry in project BetterQuesting by Funwayguy.

the class ToolboxToolScale method onMouseClick.

@Override
public void onMouseClick(int mx, int my, int click) {
    if (click == 1) {
        IQuestLineEntry qle = gui.getQuestLine().getQuestLine().getValue(grabID);
        if (qle != null) {
            // Reset size
            grabbed.width = qle.getSize();
            grabbed.height = qle.getSize();
        }
        grabbed = null;
        return;
    } else if (click != 0) {
        return;
    }
    if (grabbed == null) {
        grabbed = gui.getQuestLine().getButtonAt(mx, my);
        grabID = grabbed == null ? -1 : QuestDatabase.INSTANCE.getKey(grabbed.getQuest());
    } else {
        IQuestLine qLine = gui.getQuestLine().getQuestLine();
        int lID = QuestLineDatabase.INSTANCE.getKey(qLine);
        IQuestLineEntry qle = gui.getQuestLine().getQuestLine().getValue(grabID);
        if (qle != null) {
            qle.setSize(Math.max(grabbed.width, grabbed.height));
            // Sync Line
            NBTTagCompound tag2 = new NBTTagCompound();
            NBTTagCompound base2 = new NBTTagCompound();
            base2.setTag("line", qLine.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
            tag2.setTag("data", base2);
            tag2.setInteger("action", EnumPacketAction.EDIT.ordinal());
            tag2.setInteger("lineID", lID);
            PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.LINE_EDIT.GetLocation(), tag2));
        }
        grabbed = null;
        grabID = -1;
    }
}
Also used : IQuestLine(betterquesting.api.questing.IQuestLine) IQuestLineEntry(betterquesting.api.questing.IQuestLineEntry) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 5 with IQuestLineEntry

use of betterquesting.api.questing.IQuestLineEntry in project BetterQuesting by Funwayguy.

the class QuestLineButtonTree method RebuildTree.

public void RebuildTree() {
    buttonTree.clear();
    treeW = 0;
    treeH = 0;
    if (line == null) {
        return;
    }
    for (int id : line.getAllKeys()) {
        IQuest quest = QuestingAPI.getAPI(ApiReference.QUEST_DB).getValue(id);
        IQuestLineEntry entry = line.getValue(id);
        if (quest != null && entry != null) {
            buttonTree.add(new GuiButtonQuestInstance(0, entry.getPosX(), entry.getPosY(), entry.getSize(), entry.getSize(), quest));
        }
    }
    // Offset origin to 0,0 and establish bounds
    for (GuiButtonQuestInstance btn : buttonTree) {
        if (btn == null) {
            continue;
        }
        treeW = Math.max(btn.x + btn.width, treeW);
        treeH = Math.max(btn.y + btn.height, treeH);
        for (GuiButtonQuestInstance b2 : buttonTree) {
            if (b2 == null || btn == b2 || btn.getQuest() == null) {
                continue;
            }
            if (btn.getQuest().getPrerequisites().contains(b2.getQuest())) {
                btn.addParent(b2);
            }
        }
    }
}
Also used : GuiButtonQuestInstance(betterquesting.api.client.gui.controls.GuiButtonQuestInstance) IQuest(betterquesting.api.questing.IQuest) IQuestLineEntry(betterquesting.api.questing.IQuestLineEntry)

Aggregations

IQuestLineEntry (betterquesting.api.questing.IQuestLineEntry)10 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 QuestingPacket (betterquesting.api.network.QuestingPacket)3 IQuest (betterquesting.api.questing.IQuest)3 IQuestLine (betterquesting.api.questing.IQuestLine)3 QuestLineEntry (betterquesting.questing.QuestLineEntry)2 GuiButtonQuestInstance (betterquesting.api.client.gui.controls.GuiButtonQuestInstance)1 EnumQuestState (betterquesting.api.enums.EnumQuestState)1 IPropertyContainer (betterquesting.api.properties.IPropertyContainer)1 IQuestDatabase (betterquesting.api.questing.IQuestDatabase)1 IQuestLineDatabase (betterquesting.api.questing.IQuestLineDatabase)1 PanelButtonStorage (betterquesting.api2.client.gui.controls.PanelButtonStorage)1 GuiRectangle (betterquesting.api2.client.gui.misc.GuiRectangle)1 IGuiRect (betterquesting.api2.client.gui.misc.IGuiRect)1 PanelGeneric (betterquesting.api2.client.gui.panels.content.PanelGeneric)1 PanelLine (betterquesting.api2.client.gui.panels.content.PanelLine)1 IGuiColor (betterquesting.api2.client.gui.resources.colors.IGuiColor)1 IGuiLine (betterquesting.api2.client.gui.resources.lines.IGuiLine)1 GuiTextureColored (betterquesting.api2.client.gui.resources.textures.GuiTextureColored)1 IGuiTexture (betterquesting.api2.client.gui.resources.textures.IGuiTexture)1