Search in sources :

Example 6 with ReadablePoint

use of de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint 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 ReadablePoint

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

the class AbstractGuiVerticalList method mouseDrag.

@Override
public boolean mouseDrag(ReadablePoint position, int button, long timeSinceLastCall) {
    position = convert(position);
    if (lastMousePos != null) {
        int dPixel = lastMousePos.getY() - position.getY();
        if (draggingSlider) {
            int contentHeight = listPanel.calcMinSize().getHeight();
            int renderHeight = lastRenderSize.getHeight();
            scrollY(dPixel * (contentHeight + renderHeight) / renderHeight);
        } else {
            scrollY(-dPixel);
        }
        lastMousePos = position;
    // Returning false on purpose, see #mouseClick
    }
    return false;
}
Also used : Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)

Example 8 with ReadablePoint

use of de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint 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 9 with ReadablePoint

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

the class AbstractGuiTexturedButton method setTexturePosV.

@Override
public T setTexturePosV(final ReadablePoint pos) {
    this.textureNormal = pos;
    this.textureHover = new ReadablePoint() {

        @Override
        public int getX() {
            return pos.getX();
        }

        @Override
        public int getY() {
            return pos.getY() + textureSize.getHeight();
        }

        @Override
        public void getLocation(WritablePoint dest) {
            dest.setLocation(getX(), getY());
        }
    };
    return getThis();
}
Also used : ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) WritablePoint(de.johni0702.minecraft.gui.utils.lwjgl.WritablePoint)

Example 10 with ReadablePoint

use of de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint 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)

Aggregations

ReadablePoint (de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)28 Point (de.johni0702.minecraft.gui.utils.lwjgl.Point)23 ReadableDimension (de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension)12 GuiElement (de.johni0702.minecraft.gui.element.GuiElement)8 Dimension (de.johni0702.minecraft.gui.utils.lwjgl.Dimension)8 Pair (org.apache.commons.lang3.tuple.Pair)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 CrashException (net.minecraft.util.crash.CrashException)4 CrashReport (net.minecraft.util.crash.CrashReport)4 CrashReportSection (net.minecraft.util.crash.CrashReportSection)4 WritablePoint (de.johni0702.minecraft.gui.utils.lwjgl.WritablePoint)3 AbstractComposedGuiElement (de.johni0702.minecraft.gui.element.AbstractComposedGuiElement)2 ComposedGuiElement (de.johni0702.minecraft.gui.element.ComposedGuiElement)2 Focusable (de.johni0702.minecraft.gui.function.Focusable)2 RenderInfo (de.johni0702.minecraft.gui.RenderInfo)1