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();
}
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;
}
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());
}
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);
}
}
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;
}
}
Aggregations