Search in sources :

Example 11 with IQuestLine

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

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

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

the class GuiQuestLines method initPanel.

@Override
public void initPanel() {
    super.initPanel();
    if (selectedLineId >= 0) {
        selectedLine = QuestLineDatabase.INSTANCE.getValue(selectedLineId);
        if (selectedLine == null) {
            selectedLineId = -1;
        }
    } else {
        selectedLine = null;
    }
    boolean canEdit = QuestingAPI.getAPI(ApiReference.SETTINGS).canUserEdit(mc.player);
    PEventBroadcaster.INSTANCE.register(this, PEventButton.class);
    CanvasTextured cvBackground = new CanvasTextured(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(0, 0, 0, 0), 0), PresetTexture.PANEL_MAIN.getTexture());
    this.addPanel(cvBackground);
    if (canEdit) {
        cvBackground.addPanel(new PanelButton(new GuiTransform(GuiAlign.BOTTOM_CENTER, -100, -16, 100, 16, 0), 0, I18n.format("gui.back")));
        cvBackground.addPanel(new PanelButton(new GuiTransform(GuiAlign.BOTTOM_CENTER, 0, -16, 100, 16, 0), 3, I18n.format("betterquesting.btn.edit")));
    } else {
        cvBackground.addPanel(new PanelButton(new GuiTransform(GuiAlign.BOTTOM_CENTER, -100, -16, 200, 16, 0), 0, I18n.format("gui.back")));
    }
    CanvasScrolling cvList = new CanvasScrolling(new GuiTransform(GuiAlign.LEFT_EDGE, new GuiPadding(16, 16, -158, 16), 0));
    cvBackground.addPanel(cvList);
    PanelVScrollBar pnQScroll = new PanelVScrollBar(new GuiTransform(GuiAlign.RIGHT_EDGE, new GuiPadding(0, 0, -8, 0), 0));
    cvList.setScrollDriverY(pnQScroll);
    cvBackground.addPanel(pnQScroll);
    pnQScroll.getTransform().setParent(cvList.getTransform());
    List<IQuestLine> lineList = QuestLineDatabase.INSTANCE.getAllValues();
    this.qlBtns = new PanelButtonStorage[lineList.size()];
    UUID playerID = QuestingAPI.getQuestingUUID(mc.player);
    for (int i = 0; i < lineList.size(); i++) {
        IQuestLine ql = lineList.get(i);
        PanelButtonStorage<IQuestLine> btnLine = new PanelButtonStorage<>(new GuiRectangle(0, i * 16, 142, 16, 0), 1, I18n.format(ql.getUnlocalisedName()), ql);
        boolean show = canEdit;
        if (!show) {
            for (int qID : ql.getAllKeys()) {
                IQuest q = QuestDatabase.INSTANCE.getValue(qID);
                if (q != null && CanvasQuestLine.isQuestShown(q, playerID)) {
                    show = true;
                    break;
                }
            }
        }
        if (!show || ql == selectedLine) {
            btnLine.setBtnState(false);
        }
        cvList.addPanel(btnLine);
        qlBtns[i] = btnLine;
    }
    pnQScroll.setEnabled(cvList.getScrollBounds().getHeight() > 0);
    CanvasTextured cvFrame = new CanvasTextured(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(174, 16, 16, 66), 0), PresetTexture.AUX_FRAME_0.getTexture());
    cvBackground.addPanel(cvFrame);
    cvQuest = new CanvasQuestLine(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(0, 0, 0, 0), 0), 2);
    cvFrame.addPanel(cvQuest);
    cvDesc = new CanvasScrolling(new GuiTransform(GuiAlign.BOTTOM_EDGE, new GuiPadding(174, -66, 24, 16), 0));
    cvBackground.addPanel(cvDesc);
    paDesc = new PanelTextBox(new GuiRectangle(0, 0, cvDesc.getTransform().getWidth(), 0, 0), "", true);
    paDesc.setColor(PresetColor.TEXT_MAIN.getColor());
    cvDesc.addPanel(paDesc);
    scDesc = new PanelVScrollBar(new GuiTransform(GuiAlign.BOTTOM_RIGHT, new GuiPadding(-24, -66, 16, 16), 0));
    cvDesc.setScrollDriverY(scDesc);
    cvBackground.addPanel(scDesc);
    if (selectedLine != null) {
        cvQuest.setQuestLine(selectedLine);
        cvQuest.setZoom(lastZoom);
        cvQuest.setScrollX(lastScrollX);
        cvQuest.setScrollY(lastScrollY);
        paDesc.setText(I18n.format(selectedLine.getUnlocalisedDescription()));
        scDesc.setEnabled(cvDesc.getScrollBounds().getHeight() > 0);
    }
    // === DECORATIVE LINES ===
    IGuiRect ls0 = new GuiTransform(GuiAlign.TOP_LEFT, 16, 16, 0, 0, 0);
    ls0.setParent(cvBackground.getTransform());
    IGuiRect le0 = new GuiTransform(GuiAlign.TOP_LEFT, 166, 16, 0, 0, 0);
    le0.setParent(cvBackground.getTransform());
    PanelLine paLine0 = new PanelLine(ls0, le0, PresetLine.GUI_DIVIDER.getLine(), 1, PresetColor.GUI_DIVIDER.getColor(), -1);
    cvBackground.addPanel(paLine0);
    IGuiRect ls1 = new GuiTransform(GuiAlign.BOTTOM_LEFT, 16, -16, 0, 0, 0);
    ls1.setParent(cvBackground.getTransform());
    IGuiRect le1 = new GuiTransform(GuiAlign.BOTTOM_LEFT, 166, -16, 0, 0, 0);
    le1.setParent(cvBackground.getTransform());
    PanelLine paLine1 = new PanelLine(ls1, le1, PresetLine.GUI_DIVIDER.getLine(), 1, PresetColor.GUI_DIVIDER.getColor(), 1);
    cvBackground.addPanel(paLine1);
    IGuiRect ls3 = new GuiTransform(GuiAlign.BOTTOM_LEFT, 174, -16, 0, 0, 0);
    ls3.setParent(cvBackground.getTransform());
    IGuiRect le3 = new GuiTransform(GuiAlign.BOTTOM_RIGHT, -16, -16, 0, 0, 0);
    le3.setParent(cvBackground.getTransform());
    PanelLine paLine3 = new PanelLine(ls3, le3, PresetLine.GUI_DIVIDER.getLine(), 1, PresetColor.GUI_DIVIDER.getColor(), 1);
    cvBackground.addPanel(paLine3);
}
Also used : PanelButton(betterquesting.api2.client.gui.controls.PanelButton) IPanelButton(betterquesting.api2.client.gui.controls.IPanelButton) IQuest(betterquesting.api.questing.IQuest) PanelVScrollBar(betterquesting.api2.client.gui.panels.bars.PanelVScrollBar) PanelLine(betterquesting.api2.client.gui.panels.content.PanelLine) PanelTextBox(betterquesting.api2.client.gui.panels.content.PanelTextBox) IQuestLine(betterquesting.api.questing.IQuestLine) CanvasTextured(betterquesting.api2.client.gui.panels.CanvasTextured) CanvasScrolling(betterquesting.api2.client.gui.panels.lists.CanvasScrolling) UUID(java.util.UUID) PanelButtonStorage(betterquesting.api2.client.gui.controls.PanelButtonStorage)

Example 14 with IQuestLine

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

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

the class ToolboxToolRemove method onMouseClick.

@Override
public void onMouseClick(int mx, int my, int click) {
    if (click != 0) {
        return;
    }
    IQuestLine line = gui.getQuestLine().getQuestLine();
    GuiButtonQuestInstance btn = gui.getQuestLine().getButtonAt(mx, my);
    if (line != null && btn != null) {
        int qID = QuestDatabase.INSTANCE.getKey(btn.getQuest());
        line.removeKey(qID);
        NBTTagCompound tags = new NBTTagCompound();
        tags.setInteger("action", EnumPacketAction.EDIT.ordinal());
        NBTTagCompound base = new NBTTagCompound();
        base.setTag("line", line.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
        tags.setTag("data", base);
        tags.setInteger("lineID", QuestLineDatabase.INSTANCE.getKey(line));
        PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.LINE_EDIT.GetLocation(), tags));
    }
}
Also used : GuiButtonQuestInstance(betterquesting.api.client.gui.controls.GuiButtonQuestInstance) IQuestLine(betterquesting.api.questing.IQuestLine) 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