Search in sources :

Example 1 with GuiButtonQuestInstance

use of betterquesting.api.client.gui.controls.GuiButtonQuestInstance in project BetterQuesting by Funwayguy.

the class GuiQuestLinesEmbedded method drawBackground.

@Override
public void drawBackground(int mx, int my, float partialTick) {
    mouseDrag(mx, my);
    Minecraft mc = Minecraft.getMinecraft();
    double scaleX = sizeX / 128D;
    double scaleY = sizeY / 128D;
    float zs = zoom / 100F;
    int rmx = getRelativeX(mx);
    int rmy = getRelativeY(my);
    mc.renderEngine.bindTexture(currentTheme().getGuiTexture());
    GlStateManager.color(1F, 1F, 1F, 1F);
    GlStateManager.pushMatrix();
    GlStateManager.scale(scaleX, scaleY, 1F);
    GlStateManager.translate(posX / scaleX, posY / scaleY, 0);
    drawTexturedModalRect(0, 0, 0, 128, 128, 128);
    GlStateManager.popMatrix();
    IQuest qTooltip = null;
    if (qLine != null) {
        GlStateManager.pushMatrix();
        RenderUtils.startScissor(mc, new GuiRectangle(posX, posY, sizeX, sizeY));
        GlStateManager.translate(posX + (scrollX) * zs, posY + (scrollY) * zs, 0);
        GlStateManager.scale(zs, zs, 1F);
        if (bgImg != null) {
            GlStateManager.pushMatrix();
            GlStateManager.scale(bgSize / 256F, bgSize / 256F, 1F);
            mc.renderEngine.bindTexture(bgImg);
            this.drawTexturedModalRect(0, 0, 0, 0, 256, 256);
            GlStateManager.popMatrix();
        }
        for (int i = 0; i < qBtns.size(); i++) {
            GuiButtonQuestInstance btnQuest = qBtns.get(i);
            btnQuest.drawButton(mc, rmx, rmy, partialTick);
            if (btnQuest.visible && isWithin(rmx, rmy, btnQuest.x, btnQuest.y, btnQuest.width, btnQuest.height) && isWithin(mx, my, posX, posY, sizeX, sizeY)) {
                qTooltip = btnQuest.getQuest();
            }
        }
        RenderUtils.endScissor(mc);
        GlStateManager.popMatrix();
    }
    if (curTool != null) {
        GlStateManager.pushMatrix();
        RenderUtils.startScissor(mc, new GuiRectangle(posX, posY, sizeX, sizeY));
        GlStateManager.translate(posX + (scrollX) * zs, posY + (scrollY) * zs, 0);
        GlStateManager.scale(zs, zs, 1F);
        curTool.drawTool(rmx, rmy, partialTick);
        RenderUtils.endScissor(mc);
        GlStateManager.popMatrix();
    }
    if (qTooltip != null && (curTool == null || curTool.allowTooltips())) {
        curTooltip = qTooltip.getTooltip(mc.player);
    } else {
        curTooltip = null;
    }
}
Also used : GuiButtonQuestInstance(betterquesting.api.client.gui.controls.GuiButtonQuestInstance) IQuest(betterquesting.api.questing.IQuest) GuiRectangle(betterquesting.api2.client.gui.misc.GuiRectangle) Minecraft(net.minecraft.client.Minecraft)

Example 2 with GuiButtonQuestInstance

use of betterquesting.api.client.gui.controls.GuiButtonQuestInstance 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 GuiButtonQuestInstance

use of betterquesting.api.client.gui.controls.GuiButtonQuestInstance in project BetterQuesting by Funwayguy.

the class ToolboxToolNew method initTool.

@Override
public void initTool(IGuiQuestLine gui) {
    this.gui = gui;
    nQuest = new GuiButtonQuestInstance(0, 0, 0, 24, 24, new QuestInstance());
}
Also used : GuiButtonQuestInstance(betterquesting.api.client.gui.controls.GuiButtonQuestInstance) GuiButtonQuestInstance(betterquesting.api.client.gui.controls.GuiButtonQuestInstance) QuestInstance(betterquesting.questing.QuestInstance)

Example 4 with GuiButtonQuestInstance

use of betterquesting.api.client.gui.controls.GuiButtonQuestInstance 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)

Example 5 with GuiButtonQuestInstance

use of betterquesting.api.client.gui.controls.GuiButtonQuestInstance in project BetterQuesting by Funwayguy.

the class QuestLineButtonTree method getButtonAt.

public GuiButtonQuestInstance getButtonAt(int x, int y) {
    if (line == null) {
        return null;
    }
    int id = line.getQuestAt(x, y);
    IQuest quest = QuestingAPI.getAPI(ApiReference.QUEST_DB).getValue(id);
    if (quest == null) {
        return null;
    }
    for (GuiButtonQuestInstance btn : buttonTree) {
        if (btn.getQuest() == quest) {
            return btn;
        }
    }
    return null;
}
Also used : GuiButtonQuestInstance(betterquesting.api.client.gui.controls.GuiButtonQuestInstance) IQuest(betterquesting.api.questing.IQuest)

Aggregations

GuiButtonQuestInstance (betterquesting.api.client.gui.controls.GuiButtonQuestInstance)11 QuestingPacket (betterquesting.api.network.QuestingPacket)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 IQuest (betterquesting.api.questing.IQuest)4 Minecraft (net.minecraft.client.Minecraft)3 IQuestLine (betterquesting.api.questing.IQuestLine)2 QuestInstance (betterquesting.questing.QuestInstance)2 IQuestLineEntry (betterquesting.api.questing.IQuestLineEntry)1 GuiRectangle (betterquesting.api2.client.gui.misc.GuiRectangle)1 GuiQuest (betterquesting.client.gui2.GuiQuest)1 GuiToolIconProxy (betterquesting.client.toolbox.GuiToolIconProxy)1 QuestLineEntry (betterquesting.questing.QuestLineEntry)1