Search in sources :

Example 6 with Point

use of de.johni0702.minecraft.gui.utils.lwjgl.Point in project jGui by ReplayMod.

the class AbstractGuiVerticalList method isOnBackground.

private boolean isOnBackground(ReadablePoint point) {
    int width = lastRenderSize.getWidth();
    int listPanelWidth = listPanel.calcMinSize().getWidth();
    return point.getX() < width / 2 - listPanelWidth / 2 || width / 2 + listPanelWidth / 2 + (drawSlider ? 6 : 0) < point.getX();
}
Also used : Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)

Example 7 with Point

use of de.johni0702.minecraft.gui.utils.lwjgl.Point in project jGui by ReplayMod.

the class AbstractGuiTextField method mouseClick.

@Override
public boolean mouseClick(ReadablePoint position, int button) {
    if (getContainer() != null) {
        getContainer().convertFor(this, (Point) (position = new Point(position)));
    }
    boolean hovering = isMouseHovering(position);
    if (hovering && isFocused() && button == 0) {
        updateCurrentOffset();
        int mouseX = position.getX() - BORDER;
        TextRenderer fontRenderer = MCVer.getFontRenderer();
        String text = this.text.substring(currentOffset);
        int textX = fontRenderer.trimToWidth(text, mouseX).length() + currentOffset;
        setCursorPosition(textX);
        return true;
    }
    setFocused(hovering);
    // Do not yet return true to allow focusables later in the event chain to be notified of the focus change
    return false;
}
Also used : Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) TextRenderer(net.minecraft.client.font.TextRenderer)

Example 8 with Point

use of de.johni0702.minecraft.gui.utils.lwjgl.Point in project jGui by ReplayMod.

the class AbstractGuiTexturedButton method draw.

@Override
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
    super.draw(renderer, size, renderInfo);
    renderer.bindTexture(texture);
    ReadablePoint texture = textureNormal;
    if (!isEnabled()) {
        texture = textureDisabled;
    } else if (isMouseHovering(new Point(renderInfo.mouseX, renderInfo.mouseY))) {
        texture = textureHover;
    }
    if (texture == null) {
        // Button is disabled but we have no texture for that
        // #if MC>=11700
        // $$ // TODO anything reasonable we can do here? do we even care?
        // #else
        color4f(0.5f, 0.5f, 0.5f, 1);
        // #endif
        texture = textureNormal;
    }
    enableBlend();
    blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1, 0);
    blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    renderer.drawTexturedRect(0, 0, texture.getX(), texture.getY(), size.getWidth(), size.getHeight(), textureSize.getWidth(), textureSize.getHeight(), textureTotalSize.getWidth(), textureTotalSize.getHeight());
}
Also used : Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) WritablePoint(de.johni0702.minecraft.gui.utils.lwjgl.WritablePoint) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)

Example 9 with Point

use of de.johni0702.minecraft.gui.utils.lwjgl.Point in project jGui by ReplayMod.

the class AbstractGuiButton method draw.

@Override
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
    super.draw(renderer, size, renderInfo);
    // #if MC<11700
    color4f(1, 1, 1, 1);
    // #endif
    byte texture = 1;
    int color = labelColor;
    if (!isEnabled()) {
        texture = 0;
        color = 0xa0a0a0;
    } else if (isMouseHovering(new Point(renderInfo.mouseX, renderInfo.mouseY))) {
        texture = 2;
        color = 0xffffa0;
    }
    enableBlend();
    blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1, 0);
    blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    int textureY = 46 + texture * 20;
    int halfWidth = size.getWidth() / 2;
    int secondHalfWidth = size.getWidth() - halfWidth;
    int halfHeight = size.getHeight() / 2;
    int secondHalfHeight = size.getHeight() - halfHeight;
    renderer.bindTexture(WIDGETS_TEXTURE);
    renderer.drawTexturedRect(0, 0, 0, textureY, halfWidth, halfHeight);
    renderer.drawTexturedRect(0, halfHeight, 0, textureY + 20 - secondHalfHeight, halfWidth, secondHalfHeight);
    renderer.drawTexturedRect(halfWidth, 0, 200 - secondHalfWidth, textureY, secondHalfWidth, halfHeight);
    renderer.drawTexturedRect(halfWidth, halfHeight, 200 - secondHalfWidth, textureY + 20 - secondHalfHeight, secondHalfWidth, secondHalfHeight);
    if (this.texture != null) {
        renderer.bindTexture(this.texture);
        if (spriteUV != null && textureSize != null) {
            ReadableDimension spriteSize = this.spriteSize != null ? this.spriteSize : getMinSize();
            renderer.drawTexturedRect(0, 0, spriteUV.getX(), spriteUV.getY(), size.getWidth(), size.getHeight(), spriteSize.getWidth(), spriteSize.getHeight(), textureSize.getWidth(), textureSize.getHeight());
        } else {
            renderer.drawTexturedRect(0, 0, 0, 0, size.getWidth(), size.getHeight());
        }
    }
    if (label != null) {
        renderer.drawCenteredString(halfWidth, (size.getHeight() - 8) / 2, color, label, true);
    }
}
Also used : ReadableDimension(de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension) Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)

Example 10 with Point

use of de.johni0702.minecraft.gui.utils.lwjgl.Point in project jGui by ReplayMod.

the class AbstractGuiHorizontalScrollbar method mouseRelease.

@Override
public boolean mouseRelease(ReadablePoint position, int button) {
    if (dragging) {
        Point pos = new Point(position);
        if (getContainer() != null) {
            getContainer().convertFor(this, pos);
        }
        updateValue(pos);
        dragging = false;
        startDragging = null;
        return true;
    } else {
        return false;
    }
}
Also used : Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)

Aggregations

Point (de.johni0702.minecraft.gui.utils.lwjgl.Point)25 ReadablePoint (de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)25 ReadableDimension (de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension)11 Dimension (de.johni0702.minecraft.gui.utils.lwjgl.Dimension)8 GuiElement (de.johni0702.minecraft.gui.element.GuiElement)6 OffsetGuiRenderer (de.johni0702.minecraft.gui.OffsetGuiRenderer)5 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 TextRenderer (net.minecraft.client.font.TextRenderer)4 Pair (org.apache.commons.lang3.tuple.Pair)4 CrashException (net.minecraft.util.crash.CrashException)2 CrashReport (net.minecraft.util.crash.CrashReport)2 CrashReportSection (net.minecraft.util.crash.CrashReportSection)2 RenderInfo (de.johni0702.minecraft.gui.RenderInfo)1 WritablePoint (de.johni0702.minecraft.gui.utils.lwjgl.WritablePoint)1 Window (net.minecraft.client.util.Window)1