Better GUI handling for Ability Making System

This commit is contained in:
Kam committed 2026-02-02 21:51:21 -05:00
1 parent 38d305ab99
commit 2c6ec0ce34
31 files changed
+792 -464

No files matched your search

@@ -1,11 +1,9 @@
package noppes.npcs.client.gui.advanced;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.Condition;
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldBuilder;
import noppes.npcs.client.gui.builder.FieldDef;
import noppes.npcs.client.gui.builder.FieldType;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
@@ -55,7 +53,6 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
private int editingConditionIndex = -1;
private AbilityFieldBuilder builder;
private FieldDef activeSubGuiField = null;
// Scroll position preservation per tab
private float[] tabScrollY;
@@ -263,7 +260,6 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// ═══════════════════════════════════════════════════════════════════════════
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public void buttonEvent(GuiButton guibutton) {
int id = guibutton.id;
@@ -281,6 +277,22 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
if (id == -1000) { close(); return; }
// Condition buttons (50-80)
if (handleConditionButton(id)) return;
// Declarative field handling (effects list, booleans, enums, sub-guis, clear buttons)
if (builder.handleButtonEvent(id, guibutton)) {
// SUB_GUI needs special handling: open the sub-gui
FieldDef subGuiDef = builder.getActiveSubGuiField();
if (subGuiDef != null && subGuiDef.getSubGuiFactory() != null) {
setSubGui(subGuiDef.getSubGuiFactory().get());
} else {
initGui();
}
return;
}
}
private boolean handleConditionButton(int id) {
if (id >= 50 && id < 80) {
int condIndex = (id - 50) / 10;
int action = (id - 50) % 10;
@@ -295,109 +307,16 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
initGui();
}
}
return;
return true;
}
if (id == 80) {
if (conditions.size() < 3) {
editingConditionIndex = conditions.size();
setSubGui(new SubGuiConditionEdit(null));
}
return;
}
// Clear buttons (effects delete or SUB_GUI clear)
if (id >= CLEAR_ID_START) {
// Check effects list delete first
int[] meta = builder.getEffectWidgetMeta().get(id);
if (meta != null && meta[1] == 3) {
FieldDef def = builder.getClearFieldMap().get(id);
if (def != null && def.getType() == FieldType.EFFECTS_LIST) {
handleEffectButton(def, meta, guibutton);
return;
}
}
// SUB_GUI clear
FieldDef def = builder.getClearFieldMap().get(id);
if (def != null && def.hasClearAction()) {
def.getClearAction().run();
initGui();
}
return;
}
// Declarative field buttons
if (id >= DECLARATIVE_ID_START) {
FieldDef def = builder.getButtonFieldMap().get(id);
if (def == null) return;
// Effects list buttons (type, amp, add)
int[] meta = builder.getEffectWidgetMeta().get(id);
if (meta != null && def.getType() == FieldType.EFFECTS_LIST) {
handleEffectButton(def, meta, guibutton);
return;
}
switch (def.getType()) {
case BOOLEAN:
def.setValue(((GuiNpcButton) guibutton).getValue() == 1);
initGui();
break;
case ENUM: {
int idx = ((GuiNpcButton) guibutton).getValue();
Class<? extends Enum<?>> ec = def.getEnumClass();
if (ec != null) {
Enum<?>[] constants = ec.getEnumConstants();
if (idx >= 0 && idx < constants.length) def.setValue(constants[idx]);
}
initGui();
break;
}
case STRING_ENUM: {
int idx = ((GuiNpcButton) guibutton).getValue();
String[] values = def.getStringEnumValues();
if (values != null && idx >= 0 && idx < values.length) def.setStringEnumValue(values[idx]);
initGui();
break;
}
case SUB_GUI:
activeSubGuiField = def;
if (def.getSubGuiFactory() != null) setSubGui(def.getSubGuiFactory().get());
break;
}
}
}
@SuppressWarnings("unchecked")
private void handleEffectButton(FieldDef def, int[] meta, GuiButton btn) {
List<AbilityEffect> effects = (List<AbilityEffect>) def.getValue();
if (effects == null) return;
int effectIdx = meta[0];
int action = meta[1];
switch (action) {
case 0: // Type changed
if (effectIdx < effects.size()) {
effects.get(effectIdx).setType(AbilityEffect.EffectType.fromOrdinal(((GuiNpcButton) btn).getValue()));
}
break;
case 2: // Amp changed
if (effectIdx < effects.size()) {
effects.get(effectIdx).setAmplifier(((GuiNpcButton) btn).getValue());
}
break;
case 3: // Delete
if (effectIdx < effects.size()) {
effects.remove(effectIdx);
initGui();
}
break;
case 4: // Add
if (effects.size() < 5) {
effects.add(new AbilityEffect(AbilityEffect.EffectType.SLOWNESS, 60, 0));
initGui();
}
break;
return true;
}
return false;
}
// ═══════════════════════════════════════════════════════════════════════════
@@ -405,38 +324,9 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// ═══════════════════════════════════════════════════════════════════════════
@Override
@SuppressWarnings("unchecked")
public void unFocused(GuiNpcTextField textField) {
int id = textField.id;
if (id < DECLARATIVE_ID_START) return;
// Check effects list duration fields
int[] meta = builder.getEffectWidgetMeta().get(id);
if (meta != null && meta[1] == 1) {
FieldDef def = builder.getTextFieldMap().get(id);
if (def != null && def.getType() == FieldType.EFFECTS_LIST) {
List<AbilityEffect> effects = (List<AbilityEffect>) def.getValue();
if (effects != null && meta[0] < effects.size()) {
effects.get(meta[0]).setDurationTicks(textField.getInteger());
}
return;
}
}
FieldDef def = builder.getTextFieldMap().get(id);
if (def == null) return;
switch (def.getType()) {
case FLOAT:
try { def.setValue(Float.parseFloat(textField.getText())); } catch (NumberFormatException ignored) {}
break;
case INT:
try { def.setValue(Integer.parseInt(textField.getText())); } catch (NumberFormatException ignored) {}
break;
case STRING:
def.setValue(textField.getText());
break;
}
if (textField.id < DECLARATIVE_ID_START) return;
builder.handleTextFieldEvent(textField.id, textField);
}
// ═══════════════════════════════════════════════════════════════════════════
@@ -445,12 +335,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
@Override
public void subGuiClosed(SubGuiInterface subgui) {
if (activeSubGuiField != null) {
FieldDef def = activeSubGuiField;
activeSubGuiField = null;
if (def.getSubGuiResultHandler() != null) {
def.getSubGuiResultHandler().accept(subgui);
}
if (builder.handleSubGuiClosed(subgui)) {
initGui();
return;
}
@@ -1,11 +0,0 @@
package noppes.npcs.client.gui.builder;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public enum ColumnHint {
FULL,
LEFT,
RIGHT
}
@@ -24,12 +24,10 @@ public class FieldDef {
private final String label;
private final FieldType type;
private String tab = null;
private ColumnHint column = ColumnHint.FULL;
private Supplier<Object> getter;
private Consumer<Object> setter;
private BooleanSupplier visibleWhen = () -> true;
private BooleanSupplier enabledWhen = () -> true;
private String tooltip = null;
private String hoverText = null;
// Numeric range
@@ -51,6 +49,10 @@ public class FieldDef {
private Supplier<Integer> buttonTextColorSupplier;
private Runnable clearAction;
// Row pairing (ROW type only)
private FieldDef leftChild;
private FieldDef rightChild;
private FieldDef(String label, FieldType type) {
this.label = label;
this.type = type;
@@ -134,6 +136,17 @@ public class FieldDef {
return def;
}
/**
* Creates a two-column row pairing two fields side by side.
* If one child is hidden (via visibleWhen), the other renders full-width.
*/
public static FieldDef row(FieldDef left, FieldDef right) {
FieldDef def = new FieldDef("", FieldType.ROW);
def.leftChild = left;
def.rightChild = right;
return def;
}
// ═══════════════════════════════════════════════════════════════════
// CONVENIENCE FACTORIES (SUB_GUI wrappers)
// ═══════════════════════════════════════════════════════════════════
@@ -206,11 +219,6 @@ public class FieldDef {
return this;
}
public FieldDef column(ColumnHint column) {
this.column = column;
return this;
}
public FieldDef visibleWhen(BooleanSupplier condition) {
this.visibleWhen = condition;
return this;
@@ -221,11 +229,6 @@ public class FieldDef {
return this;
}
public FieldDef tooltip(String tooltip) {
this.tooltip = tooltip;
return this;
}
public FieldDef hover(String hoverText) {
this.hoverText = hoverText;
return this;
@@ -253,10 +256,8 @@ public class FieldDef {
public String getLabel() { return label; }
public FieldType getType() { return type; }
public String getTab() { return tab; }
public ColumnHint getColumn() { return column; }
public boolean isVisible() { return visibleWhen.getAsBoolean(); }
public boolean isEnabled() { return enabledWhen.getAsBoolean(); }
public String getTooltip() { return tooltip; }
public String getHoverText() { return hoverText; }
public float getMin() { return min; }
public float getMax() { return max; }
@@ -293,4 +294,7 @@ public class FieldDef {
return buttonTextColorSupplier != null ? buttonTextColorSupplier.get() : null;
}
public FieldDef getLeftChild() { return leftChild; }
public FieldDef getRightChild() { return rightChild; }
}
@@ -14,5 +14,6 @@ public enum FieldType {
STRING,
SECTION_HEADER,
LABEL,
EFFECTS_LIST
EFFECTS_LIST,
ROW
}
@@ -3,6 +3,7 @@ package noppes.npcs.client.gui.builder;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton;
@@ -10,6 +11,7 @@ import noppes.npcs.client.gui.util.GuiNpcButtonYesNo;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.GuiScrollWindow;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.HashMap;
import java.util.List;
@@ -19,8 +21,8 @@ import java.util.Map;
* General-purpose builder that converts a list of {@link FieldDef} into positioned
* GUI widgets inside a {@link GuiScrollWindow}.
* <p>
* Supports 1-column and 2-column layouts. Subclasses can override {@link #buildField}
* to handle custom field types.
* Uses {@link FieldDef#row(FieldDef, FieldDef)} for two-column layouts.
* Subclasses can override {@link #buildField} to handle custom field types.
*/
@SideOnly(Side.CLIENT)
public class GuiFieldBuilder {
@@ -36,9 +38,6 @@ public class GuiFieldBuilder {
protected int rowHeight = 24;
protected int labelPadding = 8;
// Column mode
protected int columnCount = 2;
// Dependencies
protected final GuiNPCInterface parent;
protected GuiScrollWindow sw;
@@ -71,7 +70,6 @@ public class GuiFieldBuilder {
// ═══════════════════════════════════════════════════════════════════
public GuiFieldBuilder scrollWindowId(int id) { this.scrollWindowId = id; return this; }
public GuiFieldBuilder columns(int count) { this.columnCount = Math.max(1, Math.min(2, count)); return this; }
public GuiFieldBuilder contentRight(int v) { this.contentRight = v; return this; }
public GuiFieldBuilder startIds(int widget, int clear, int label) {
this.widgetId = widget; this.clearId = clear; this.labelId = label; return this;
@@ -125,38 +123,37 @@ public class GuiFieldBuilder {
// Section header
if (def.getType() == FieldType.SECTION_HEADER) {
y += 3;
String sectionText = StatCollector.translateToLocal(def.getLabel());
if (def.getTooltip() != null && !def.getTooltip().isEmpty()) {
sectionText += " (" + StatCollector.translateToLocal(def.getTooltip()) + ")";
GuiNpcLabel sectionLabel = new GuiNpcLabel(labelId++, def.getLabel(), colLLabel, y + 2, 0xFFFF55);
if (def.getHoverText() != null && !def.getHoverText().isEmpty()) {
sectionLabel.setHoverText(def.getHoverText());
}
sw.addLabel(new GuiNpcLabel(labelId++, sectionText, colLLabel, y + 2, 0xFFFF55));
sw.addLabel(sectionLabel);
y += 15;
continue;
}
// Two-column pair: LEFT followed by RIGHT (only in 2-column mode)
if (columnCount == 2
&& def.getColumn() == ColumnHint.LEFT
&& i + 1 < fields.size()
&& fields.get(i + 1).getColumn() == ColumnHint.RIGHT
&& fields.get(i + 1).getType() != FieldType.SECTION_HEADER) {
renderFieldAt(def, colLLabel, colLField, colLWidth, y);
// ROW: explicit two-column pair
if (def.getType() == FieldType.ROW) {
FieldDef left = def.getLeftChild();
FieldDef right = def.getRightChild();
boolean leftVis = left != null && left.isVisible();
boolean rightVis = right != null && right.isVisible();
i++;
FieldDef rightDef = fields.get(i);
renderFieldAt(rightDef, colRLabel, colRField, colRWidth, y);
y += rowHeight;
} else {
// Full-width: compute fieldX from label pixel width
int fieldW = getFullFieldWidth(def);
String translated = StatCollector.translateToLocal(def.getLabel());
int labelW = fontRenderer.getStringWidth(translated);
int fieldX = colLLabel + labelW + labelPadding;
renderFieldAt(def, colLLabel, fieldX, fieldW, y);
y += rowHeight;
if (leftVis && rightVis) {
renderFieldAt(left, colLLabel, colLField, colLWidth, y);
renderFieldAt(right, colRLabel, colRField, colRWidth, y);
} else if (leftVis) {
renderFullWidth(left, y);
} else if (rightVis) {
renderFullWidth(right, y);
}
if (leftVis || rightVis) y += rowHeight;
continue;
}
// Full-width field
renderFullWidth(def, y);
y += rowHeight;
}
lastBuildY = y;
@@ -182,9 +179,12 @@ public class GuiFieldBuilder {
@SuppressWarnings({"unchecked", "rawtypes"})
protected void renderFieldAt(FieldDef def, int labelX, int fieldX, int fieldW, int y) {
sw.addLabel(new GuiNpcLabel(labelId++, def.getLabel(), labelX, y + 5, 0xFFFFFF));
String hover = def.getHoverText() != null ? def.getHoverText() : def.getTooltip();
GuiNpcLabel fieldLabel = new GuiNpcLabel(labelId++, def.getLabel(), labelX, y + 5, 0xFFFFFF);
String hover = def.getHoverText();
if (hover != null && !hover.isEmpty()) {
fieldLabel.setHoverText(hover);
}
sw.addLabel(fieldLabel);
switch (def.getType()) {
case FLOAT: {
@@ -307,6 +307,14 @@ public class GuiFieldBuilder {
}
}
private void renderFullWidth(FieldDef def, int y) {
int fieldW = getFullFieldWidth(def);
String translated = StatCollector.translateToLocal(def.getLabel());
int labelW = fontRenderer.getStringWidth(translated);
int fieldX = colLLabel + labelW + labelPadding;
renderFieldAt(def, colLLabel, fieldX, fieldW, y);
}
protected int getFullFieldWidth(FieldDef def) {
switch (def.getType()) {
case FLOAT:
@@ -321,6 +329,109 @@ public class GuiFieldBuilder {
}
}
// ═══════════════════════════════════════════════════════════════════
// EVENT HANDLING
// ═══════════════════════════════════════════════════════════════════
private FieldDef activeSubGuiField;
/**
* Handles button events for declarative fields.
* Call from parent GUI's buttonEvent(). Returns true if the event was handled.
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public boolean handleButtonEvent(int buttonId, GuiButton button) {
// Check clear buttons first
if (clearFieldMap.containsKey(buttonId)) {
FieldDef def = clearFieldMap.get(buttonId);
if (def != null && def.hasClearAction()) {
def.getClearAction().run();
return true;
}
}
// Check field buttons
FieldDef def = buttonFieldMap.get(buttonId);
if (def == null) return false;
switch (def.getType()) {
case BOOLEAN:
def.setValue(((GuiNpcButton) button).getValue() == 1);
return true;
case ENUM: {
int idx = ((GuiNpcButton) button).getValue();
Class<? extends Enum<?>> ec = def.getEnumClass();
if (ec != null) {
Enum<?>[] constants = ec.getEnumConstants();
if (idx >= 0 && idx < constants.length) def.setValue(constants[idx]);
}
return true;
}
case STRING_ENUM: {
int idx = ((GuiNpcButton) button).getValue();
String[] values = def.getStringEnumValues();
if (values != null && idx >= 0 && idx < values.length) def.setStringEnumValue(values[idx]);
return true;
}
case SUB_GUI:
activeSubGuiField = def;
return true;
default:
return false;
}
}
/**
* Handles text field unfocus events for declarative fields.
* Call from parent GUI's unFocused(). Returns true if the event was handled.
*/
public boolean handleTextFieldEvent(int textFieldId, GuiNpcTextField field) {
FieldDef def = textFieldMap.get(textFieldId);
if (def == null) return false;
switch (def.getType()) {
case FLOAT:
try { def.setValue(Float.parseFloat(field.getText())); } catch (NumberFormatException ignored) {}
return true;
case INT:
try { def.setValue(Integer.parseInt(field.getText())); } catch (NumberFormatException ignored) {}
return true;
case STRING:
def.setValue(field.getText());
return true;
default:
return false;
}
}
/**
* Handles sub-gui close events. Call from parent GUI's subGuiClosed().
* Returns true if the event was handled (activeSubGuiField was set).
*/
public boolean handleSubGuiClosed(SubGuiInterface subgui) {
if (activeSubGuiField != null) {
FieldDef def = activeSubGuiField;
activeSubGuiField = null;
if (def.getSubGuiResultHandler() != null) {
def.getSubGuiResultHandler().accept(subgui);
}
return true;
}
return false;
}
/**
* Returns the FieldDef for the currently active sub-gui, or null.
* After handleButtonEvent returns true for a SUB_GUI field, the parent
* should check this and call setSubGui(def.getSubGuiFactory().get()).
*/
public FieldDef getActiveSubGuiField() { return activeSubGuiField; }
/**
* Clears the active sub-gui field tracking.
*/
public void clearActiveSubGuiField() { activeSubGuiField = null; }
// ═══════════════════════════════════════════════════════════════════
// GETTERS
// ═══════════════════════════════════════════════════════════════════
@@ -1,18 +1,32 @@
package noppes.npcs.client.gui.util;
import kamkeel.npcs.util.TextSplitter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.CustomNpcResourceListener;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class GuiNpcLabel {
import java.util.Iterator;
import java.util.List;
public class GuiNpcLabel extends Gui {
public String label;
public int x, y, color;
public boolean enabled = true;
public int id;
public boolean drawShadow = false;
// Hover text support
public String hoverableText = "";
private boolean wasHovered = false;
private int hoverCount = 0;
public GuiNpcLabel(int id, Object label, int x, int y, int color) {
this.id = id;
this.label = StatCollector.translateToLocal(label.toString());
@@ -25,6 +39,10 @@ public class GuiNpcLabel {
this(id, label, x, y, CustomNpcResourceListener.DefaultTextColor);
}
public void setHoverText(String text) {
this.hoverableText = text;
}
public void drawLabel(GuiScreen gui, FontRenderer fontRenderer) {
if (enabled)
fontRenderer.drawString(label, x, y, color, drawShadow);
@@ -34,4 +52,119 @@ public class GuiNpcLabel {
int size = Minecraft.getMinecraft().fontRenderer.getStringWidth(label);
x += (width - size) / 2;
}
public boolean isMouseOver(int mouseX, int mouseY, FontRenderer fr) {
int width = fr.getStringWidth(label);
return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 10;
}
/**
* Draws hover tooltip if the mouse is over this label.
* @param localMouseX Mouse X in scroll-local coordinates (for hit testing)
* @param localMouseY Mouse Y in scroll-local coordinates (for hit testing)
* @param screenMouseX Mouse X in screen coordinates (for tooltip positioning)
* @param screenMouseY Mouse Y in screen coordinates (for tooltip positioning)
* @param hasSubGui Whether a sub-gui is open
* @param fr FontRenderer for measuring label width
*/
public void drawHover(int localMouseX, int localMouseY, int screenMouseX, int screenMouseY, boolean hasSubGui, FontRenderer fr) {
if (hasSubGui || hoverableText.isEmpty()) return;
boolean hovered = isMouseOver(localMouseX, localMouseY, fr);
if (!hovered) {
wasHovered = false;
hoverCount = 0;
return;
}
if (!wasHovered) {
wasHovered = true;
hoverCount = 0;
}
if (hoverCount < 65) hoverCount++;
if (hoverCount > 60) {
GL11.glPushMatrix();
Minecraft mc = Minecraft.getMinecraft();
String displayString = StatCollector.translateToLocal(hoverableText);
GL11.glColor4f(1, 1, 1, 1);
List<String> lines = TextSplitter.splitText(displayString, 30);
drawHoveringText(lines, screenMouseX, screenMouseY, mc);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
}
@SuppressWarnings("rawtypes")
protected void drawHoveringText(List textLines, int x, int y, Minecraft mc) {
if (mc.fontRenderer == null || textLines.isEmpty())
return;
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
int maxWidth = 0;
Iterator iterator = textLines.iterator();
while (iterator.hasNext()) {
String s = (String) iterator.next();
int lineWidth = mc.fontRenderer.getStringWidth(s);
if (lineWidth > maxWidth) {
maxWidth = lineWidth;
}
}
int j2 = x + 12;
int k2 = y - 12;
int maxHeight = 8;
if (textLines.size() > 1) {
maxHeight += 2 + (textLines.size() - 1) * 10;
}
ScaledResolution scaledRes = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int screenWidth = scaledRes.getScaledWidth();
int screenHeight = scaledRes.getScaledHeight();
if (j2 + maxWidth + 6 > screenWidth) {
j2 = x - maxWidth - 16;
}
if (j2 < 4) {
j2 = 4;
}
if (k2 + maxHeight + 6 > screenHeight) {
k2 = screenHeight - maxHeight - 6;
}
if (k2 < 4) {
k2 = 4;
}
this.zLevel = 300.0F;
int j1 = -267386864;
this.drawGradientRect(j2 - 3, k2 - 4, j2 + maxWidth + 3, k2 - 3, j1, j1);
this.drawGradientRect(j2 - 3, k2 + maxHeight + 3, j2 + maxWidth + 3, k2 + maxHeight + 4, j1, j1);
this.drawGradientRect(j2 - 3, k2 - 3, j2 + maxWidth + 3, k2 + maxHeight + 3, j1, j1);
this.drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + maxHeight + 3, j1, j1);
this.drawGradientRect(j2 + maxWidth + 3, k2 - 3, j2 + maxWidth + 4, k2 + maxHeight + 3, j1, j1);
int k1 = 1347420415;
int l1 = (k1 & 16711422) >> 1 | k1 & -16777216;
this.drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + maxHeight + 3 - 1, k1, l1);
this.drawGradientRect(j2 + maxWidth + 2, k2 - 3 + 1, j2 + maxWidth + 3, k2 + maxHeight + 3 - 1, k1, l1);
this.drawGradientRect(j2 - 3, k2 - 3, j2 + maxWidth + 3, k2 - 3 + 1, k1, k1);
this.drawGradientRect(j2 - 3, k2 + maxHeight + 2, j2 + maxWidth + 3, k2 + maxHeight + 3, l1, l1);
for (int i2 = 0; i2 < textLines.size(); ++i2) {
String s1 = (String) textLines.get(i2);
mc.fontRenderer.drawStringWithShadow(s1, j2, k2, -1);
if (i2 == 0) {
k2 += 2;
}
k2 += 10;
}
this.zLevel = 0.0F;
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
RenderHelper.enableStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
}
}
@@ -300,6 +300,14 @@ public class GuiScrollWindow extends GuiScreen implements ITextfieldListener, IC
button.drawHover(mouseX, mouseY, subGui);
}
}
// Label hover: convert screen mouse to scroll-local coords for hit testing
int localMouseX = mouseX - xPos;
int localMouseY = (int) (mouseY - yPos + scrollY);
for (GuiNpcLabel label : labels.values()) {
if (!label.hoverableText.isEmpty()) {
label.drawHover(localMouseX, localMouseY, mouseX, mouseY, subGui, fontRendererObj);
}
}
}
public void elementClicked() {