Search in sources :

Example 1 with IGuiPanel

use of betterquesting.api2.client.gui.panels.IGuiPanel in project BetterQuesting by Funwayguy.

the class GuiScreenCanvas method onMouseRelease.

@Override
public boolean onMouseRelease(int mx, int my, int click) {
    boolean used = false;
    ListIterator<IGuiPanel> pnIter = guiPanels.listIterator(guiPanels.size());
    while (pnIter.hasPrevious()) {
        IGuiPanel entry = pnIter.previous();
        if (entry.isEnabled() && entry.onMouseRelease(mx, my, click)) {
            used = true;
            break;
        }
    }
    return used;
}
Also used : IGuiPanel(betterquesting.api2.client.gui.panels.IGuiPanel)

Example 2 with IGuiPanel

use of betterquesting.api2.client.gui.panels.IGuiPanel in project BetterQuesting by Funwayguy.

the class GuiScreenCanvas method onMouseScroll.

// @Override
public boolean onMouseScroll(int mx, int my, int scroll) {
    boolean used = false;
    ListIterator<IGuiPanel> pnIter = guiPanels.listIterator(guiPanels.size());
    while (pnIter.hasPrevious()) {
        IGuiPanel entry = pnIter.previous();
        if (entry.isEnabled() && entry.onMouseScroll(mx, my, scroll)) {
            used = true;
            break;
        }
    }
    return used;
}
Also used : IGuiPanel(betterquesting.api2.client.gui.panels.IGuiPanel)

Example 3 with IGuiPanel

use of betterquesting.api2.client.gui.panels.IGuiPanel in project BetterQuesting by Funwayguy.

the class GuiScreenCanvas method onKeyTyped.

@Override
public boolean onKeyTyped(char c, int keycode) {
    boolean used = false;
    ListIterator<IGuiPanel> pnIter = guiPanels.listIterator(guiPanels.size());
    while (pnIter.hasPrevious()) {
        IGuiPanel entry = pnIter.previous();
        if (entry.isEnabled() && entry.onKeyTyped(c, keycode)) {
            used = true;
            break;
        }
    }
    Minecraft mc = Minecraft.getMinecraft();
    if (!used && (BQ_Keybindings.openQuests.isPressed() || mc.gameSettings.keyBindInventory.isPressed())) {
        mc.displayGuiScreen(this.parent);
    }
    return used;
}
Also used : IGuiPanel(betterquesting.api2.client.gui.panels.IGuiPanel) Minecraft(net.minecraft.client.Minecraft)

Example 4 with IGuiPanel

use of betterquesting.api2.client.gui.panels.IGuiPanel in project BetterQuesting by Funwayguy.

the class CanvasScrolling method drawPanel.

@Override
public void drawPanel(int mx, int my, float partialTick) {
    float zs = zoomScale.readValue();
    if (isDragging) {
        int dx = (int) ((dragMX - mx) / zs);
        int dy = (int) ((dragMY - my) / zs);
        if (scrollBounds.getWidth() > 0) {
            float dsx = dx / (float) scrollBounds.getWidth() + dragSX;
            scrollX.writeValue(dsx);
            if (!hasDragged && Math.abs(dragSX - scrollX.readValue()) > 0.05F) {
                hasDragged = true;
            }
        }
        if (scrollBounds.getHeight() > 0) {
            float dsy = dy / (float) scrollBounds.getHeight() + dragSY;
            scrollY.writeValue(dsy);
            if (!hasDragged && Math.abs(dragSY - scrollY.readValue()) > 0.05F) {
                hasDragged = true;
            }
        }
    } else if (hasDragged) {
        hasDragged = false;
    }
    if (lsx != getScrollX() || lsy != getScrollY()) {
        this.updatePanelScroll();
    }
    GlStateManager.pushMatrix();
    Minecraft mc = Minecraft.getMinecraft();
    RenderUtils.startScissor(mc, new GuiRectangle(transform));
    int tx = transform.getX();
    int ty = transform.getY();
    GlStateManager.translate(tx - lsx * zs, ty - lsy * zs, 0F);
    GlStateManager.scale(zs, zs, 1F);
    int smx = (int) ((mx - tx) / zs) + lsx;
    int smy = (int) ((my - ty) / zs) + lsy;
    for (IGuiPanel panel : guiPanels) {
        if (panel.isEnabled()) {
            panel.drawPanel(smx, smy, partialTick);
        }
    }
    RenderUtils.endScissor(mc);
    GlStateManager.popMatrix();
}
Also used : IGuiPanel(betterquesting.api2.client.gui.panels.IGuiPanel) GuiRectangle(betterquesting.api2.client.gui.misc.GuiRectangle) Minecraft(net.minecraft.client.Minecraft)

Example 5 with IGuiPanel

use of betterquesting.api2.client.gui.panels.IGuiPanel in project BetterQuesting by Funwayguy.

the class CanvasScrolling method refreshScrollBounds.

public void refreshScrollBounds() {
    boolean first = true;
    int left = 0;
    int right = 0;
    int top = 0;
    int bottom = 0;
    List<IGuiPanel> tmp = new ArrayList<IGuiPanel>(guiPanels);
    float zs = zoomScale.readValue();
    for (IGuiPanel panel : tmp) {
        if (first) {
            left = panel.getTransform().getX();
            top = panel.getTransform().getY();
            right = panel.getTransform().getX() + panel.getTransform().getWidth();
            bottom = panel.getTransform().getY() + panel.getTransform().getHeight();
            first = false;
        } else {
            left = Math.min(left, panel.getTransform().getX());
            top = Math.min(top, panel.getTransform().getY());
            right = Math.max(right, panel.getTransform().getX() + panel.getTransform().getWidth());
            bottom = Math.max(bottom, panel.getTransform().getY() + panel.getTransform().getHeight());
        }
    }
    left -= margin;
    right += margin;
    top -= margin;
    bottom += margin;
    right -= (int) Math.ceil(this.getTransform().getWidth() / zs);
    bottom -= (int) Math.ceil(this.getTransform().getHeight() / zs);
    if (extendedScroll) {
        scrollBounds.x = Math.min(left, right);
        scrollBounds.y = Math.min(top, bottom);
        scrollBounds.w = Math.max(left, right) - scrollBounds.x;
        scrollBounds.h = Math.max(top, bottom) - scrollBounds.y;
    } else {
        scrollBounds.x = left;
        scrollBounds.y = right;
        scrollBounds.w = Math.max(0, right - left);
        scrollBounds.h = Math.max(0, bottom - top);
    }
    updatePanelScroll();
}
Also used : IGuiPanel(betterquesting.api2.client.gui.panels.IGuiPanel) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Aggregations

IGuiPanel (betterquesting.api2.client.gui.panels.IGuiPanel)11 Minecraft (net.minecraft.client.Minecraft)2 GuiRectangle (betterquesting.api2.client.gui.misc.GuiRectangle)1 ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1