Search in sources :

Example 6 with IQuestLine

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

the class GuiQuestLines method onButtonPress.

private void onButtonPress(PEventButton event) {
    Minecraft mc = Minecraft.getMinecraft();
    IPanelButton btn = event.getButton();
    if (// Exit
    btn.getButtonID() == 0) {
        mc.displayGuiScreen(this.parent);
    } else if (// Quest Line Select
    btn.getButtonID() == 1 && btn instanceof PanelButtonStorage) {
        for (PanelButtonStorage b : qlBtns) {
            if (b.getStoredValue() == selectedLine) {
                b.setBtnState(true);
                break;
            }
        }
        @SuppressWarnings("unchecked") IQuestLine ql = ((PanelButtonStorage<IQuestLine>) btn).getStoredValue();
        selectedLine = ql;
        selectedLineId = QuestLineDatabase.INSTANCE.getKey(ql);
        cvQuest.setQuestLine(ql);
        paDesc.setText(I18n.format(ql.getUnlocalisedDescription()));
        cvDesc.refreshScrollBounds();
        scDesc.setEnabled(cvDesc.getScrollBounds().getHeight() > 0);
        btn.setBtnState(false);
    } else if (// Quest Instance Select
    btn.getButtonID() == 2 && btn instanceof PanelButtonStorage) {
        @SuppressWarnings("unchecked") IQuest quest = ((PanelButtonStorage<IQuest>) btn).getStoredValue();
        GuiHome.bookmark = new GuiQuest(this, QuestDatabase.INSTANCE.getKey(quest));
        this.lastScrollX = cvQuest.getScrollX();
        this.lastScrollY = cvQuest.getScrollY();
        this.lastZoom = cvQuest.getZoom();
        mc.displayGuiScreen(GuiHome.bookmark);
    } else if (btn.getButtonID() == 3) {
        mc.displayGuiScreen(new GuiQuestLineEditorA(this));
    }
}
Also used : IQuest(betterquesting.api.questing.IQuest) IQuestLine(betterquesting.api.questing.IQuestLine) IPanelButton(betterquesting.api2.client.gui.controls.IPanelButton) PanelButtonStorage(betterquesting.api2.client.gui.controls.PanelButtonStorage) Minecraft(net.minecraft.client.Minecraft) GuiQuestLineEditorA(betterquesting.client.gui.editors.GuiQuestLineEditorA)

Example 7 with IQuestLine

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

the class ImportedQuestLines method createNew.

@Override
public IQuestLine createNew() {
    QuestLine ql = new QuestLine();
    ql.setParentDatabase(this);
    return ql;
}
Also used : QuestLine(betterquesting.questing.QuestLine) IQuestLine(betterquesting.api.questing.IQuestLine)

Example 8 with IQuestLine

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

the class ImportedQuestLines method writeToNBT.

@Override
public NBTTagList writeToNBT(NBTTagList json, EnumSaveType saveType) {
    if (saveType != EnumSaveType.CONFIG) {
        return json;
    }
    for (Entry<Integer, IQuestLine> entry : questLines.entrySet()) {
        if (entry.getValue() == null) {
            continue;
        }
        int id = entry.getKey();
        NBTTagCompound jObj = entry.getValue().writeToNBT(new NBTTagCompound(), saveType);
        jObj.setInteger("lineID", id);
        jObj.setInteger("order", getOrderIndex(id));
        json.appendTag(jObj);
    }
    return json;
}
Also used : IQuestLine(betterquesting.api.questing.IQuestLine) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 9 with IQuestLine

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

the class GuiQuestLineEditorA method SendChanges.

public void SendChanges(EnumPacketAction action, int lineID, int order) {
    IQuestLine questLine = QuestLineDatabase.INSTANCE.getValue(lineID);
    if (action == null) {
        return;
    }
    NBTTagCompound tags = new NBTTagCompound();
    if (action == EnumPacketAction.EDIT && questLine != null) {
        NBTTagCompound base = new NBTTagCompound();
        base.setTag("line", questLine.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
        tags.setTag("data", base);
    }
    tags.setInteger("lineID", questLine == null ? -1 : QuestLineDatabase.INSTANCE.getKey(questLine));
    tags.setInteger("order", order);
    tags.setInteger("action", action.ordinal());
    PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.LINE_EDIT.GetLocation(), tags));
}
Also used : IQuestLine(betterquesting.api.questing.IQuestLine) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 10 with IQuestLine

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

Aggregations

IQuestLine (betterquesting.api.questing.IQuestLine)20 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)11 QuestingPacket (betterquesting.api.network.QuestingPacket)6 IQuest (betterquesting.api.questing.IQuest)4 QuestLine (betterquesting.questing.QuestLine)4 GuiButtonQuestInstance (betterquesting.api.client.gui.controls.GuiButtonQuestInstance)3 IQuestLineEntry (betterquesting.api.questing.IQuestLineEntry)3 ArrayList (java.util.ArrayList)3 IPanelButton (betterquesting.api2.client.gui.controls.IPanelButton)2 PanelButtonStorage (betterquesting.api2.client.gui.controls.PanelButtonStorage)2 QuestInstance (betterquesting.questing.QuestInstance)2 QuestLineEntry (betterquesting.questing.QuestLineEntry)2 TextComponentString (net.minecraft.util.text.TextComponentString)2 GuiButtonThemed (betterquesting.api.client.gui.controls.GuiButtonThemed)1 EnumPacketAction (betterquesting.api.enums.EnumPacketAction)1 DatabaseEvent (betterquesting.api.events.DatabaseEvent)1 IQuestDatabase (betterquesting.api.questing.IQuestDatabase)1 IQuestLineDatabase (betterquesting.api.questing.IQuestLineDatabase)1 PanelButton (betterquesting.api2.client.gui.controls.PanelButton)1 CanvasTextured (betterquesting.api2.client.gui.panels.CanvasTextured)1