Search in sources :

Example 1 with QuestLineEntry

use of betterquesting.questing.QuestLineEntry 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 2 with QuestLineEntry

use of betterquesting.questing.QuestLineEntry in project BetterQuesting by Funwayguy.

the class ToolboxToolCopy method onMouseClick.

@Override
public void onMouseClick(int mx, int my, int click) {
    if (click == 1 && btnQuest != null) {
        btnQuest = null;
    } else if (click != 0) {
        return;
    }
    int snap = ToolboxGuiMain.getSnapValue();
    int modX = ((mx % snap) + snap) % snap;
    int modY = ((my % snap) + snap) % snap;
    mx -= modX;
    my -= modY;
    if (btnQuest == null) {
        GuiButtonQuestInstance tmpBtn = gui.getQuestLine().getButtonAt(mx, my);
        if (tmpBtn != null) {
            // Unregistered but setup
            QuestInstance tmpQ = new QuestInstance();
            tmpQ.readFromNBT(tmpBtn.getQuest().writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG), EnumSaveType.CONFIG);
            btnQuest = new GuiButtonQuestInstance(0, mx, my, tmpBtn.width, tmpBtn.height, tmpQ);
        }
    } else {
        // Pre-sync
        IQuest quest = btnQuest.getQuest();
        IQuestLine qLine = gui.getQuestLine().getQuestLine();
        int qID = QuestDatabase.INSTANCE.nextKey();
        int lID = QuestLineDatabase.INSTANCE.getKey(qLine);
        QuestLineEntry qe = new QuestLineEntry(mx, my, Math.max(btnQuest.width, btnQuest.height));
        qLine.add(qe, qID);
        btnQuest = null;
        // Sync Quest
        NBTTagCompound tag1 = new NBTTagCompound();
        NBTTagCompound base1 = new NBTTagCompound();
        base1.setTag("config", quest.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
        tag1.setTag("data", base1);
        tag1.setInteger("action", EnumPacketAction.ADD.ordinal());
        tag1.setInteger("questID", qID);
        PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.QUEST_EDIT.GetLocation(), tag1));
        // 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));
    }
}
Also used : GuiButtonQuestInstance(betterquesting.api.client.gui.controls.GuiButtonQuestInstance) IQuest(betterquesting.api.questing.IQuest) GuiButtonQuestInstance(betterquesting.api.client.gui.controls.GuiButtonQuestInstance) QuestInstance(betterquesting.questing.QuestInstance) IQuestLine(betterquesting.api.questing.IQuestLine) QuestLineEntry(betterquesting.questing.QuestLineEntry) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 3 with QuestLineEntry

use of betterquesting.questing.QuestLineEntry in project BetterQuesting by Funwayguy.

the class ToolboxToolNew method onMouseClick.

@Override
public void onMouseClick(int mx, int my, int click) {
    if (click != 0) {
        return;
    }
    int snap = ToolboxGuiMain.getSnapValue();
    int modX = ((mx % snap) + snap) % snap;
    int modY = ((my % snap) + snap) % snap;
    mx -= modX;
    my -= modY;
    // Pre-sync
    IQuestLine qLine = gui.getQuestLine().getQuestLine();
    IQuest quest = new QuestInstance();
    int qID = QuestDatabase.INSTANCE.nextKey();
    int lID = QuestLineDatabase.INSTANCE.getKey(qLine);
    QuestLineEntry qe = new QuestLineEntry(mx, my, 24);
    qLine.add(qe, qID);
    // Sync Quest
    NBTTagCompound tag1 = new NBTTagCompound();
    NBTTagCompound base1 = new NBTTagCompound();
    base1.setTag("config", quest.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
    tag1.setTag("data", base1);
    tag1.setInteger("action", EnumPacketAction.ADD.ordinal());
    tag1.setInteger("questID", qID);
    PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.QUEST_EDIT.GetLocation(), tag1));
    // 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));
}
Also used : IQuest(betterquesting.api.questing.IQuest) IQuestLine(betterquesting.api.questing.IQuestLine) GuiButtonQuestInstance(betterquesting.api.client.gui.controls.GuiButtonQuestInstance) QuestInstance(betterquesting.questing.QuestInstance) QuestLineEntry(betterquesting.questing.QuestLineEntry) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 4 with QuestLineEntry

use of betterquesting.questing.QuestLineEntry in project BetterQuesting by Funwayguy.

the class LegacyLoader_v0 method readLine.

public void readLine(IQuestLine qLine, JsonObject json) {
    IPropertyContainer props = qLine.getProperties();
    props.setProperty(NativeProps.NAME, JsonHelper.GetString(json, "name", "New Quest Line"));
    props.setProperty(NativeProps.DESC, JsonHelper.GetString(json, "description", "No Description"));
    for (JsonElement je : JsonHelper.GetArray(json, "quests")) {
        if (je == null || !je.isJsonObject()) {
            continue;
        }
        JsonObject json2 = je.getAsJsonObject();
        IQuestLineEntry entry = new QuestLineEntry(JsonHelper.GetNumber(json2, "x", 0).intValue(), JsonHelper.GetNumber(json2, "y", 0).intValue(), 24);
        int qID = JsonHelper.GetNumber(json2, "id", -1).intValue();
        if (qID >= 0) {
            qLine.add(entry, qID);
        }
    }
}
Also used : IPropertyContainer(betterquesting.api.properties.IPropertyContainer) JsonElement(com.google.gson.JsonElement) IQuestLineEntry(betterquesting.api.questing.IQuestLineEntry) QuestLineEntry(betterquesting.questing.QuestLineEntry) IQuestLineEntry(betterquesting.api.questing.IQuestLineEntry) JsonObject(com.google.gson.JsonObject)

Aggregations

QuestLineEntry (betterquesting.questing.QuestLineEntry)4 QuestingPacket (betterquesting.api.network.QuestingPacket)3 IQuest (betterquesting.api.questing.IQuest)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 GuiButtonQuestInstance (betterquesting.api.client.gui.controls.GuiButtonQuestInstance)2 IQuestLine (betterquesting.api.questing.IQuestLine)2 IQuestLineEntry (betterquesting.api.questing.IQuestLineEntry)2 QuestInstance (betterquesting.questing.QuestInstance)2 IPropertyContainer (betterquesting.api.properties.IPropertyContainer)1 GuiQuest (betterquesting.client.gui2.GuiQuest)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1