mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-25 05:14:28 +00:00
Icons for Global Menu
This commit is contained in:
1 parent
dfb4c511cc
commit
48e3ae5271
8 files changed
+348
-77
No files matched your search
+2
-1
@@ -1,9 +1,10 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import noppes.npcs.client.gui.util.GuiDiagram;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.controllers.MagicController;
|
||||
import noppes.npcs.controllers.data.Magic;
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
|
||||
import noppes.npcs.client.gui.GuiMagicMap;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface2;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
|
||||
@@ -1,83 +1,233 @@
|
||||
package noppes.npcs.client.gui.mainmenu;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import noppes.npcs.NoppesStringUtils;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.global.GuiNpcManagePlayerData;
|
||||
import noppes.npcs.client.gui.global.GuiNpcNaturalSpawns;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface2;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.GuiNpcSquareButton;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class GuiNPCGlobalMainMenu extends GuiNPCInterface2{
|
||||
public GuiNPCGlobalMainMenu(EntityNPCInterface npc){
|
||||
super(npc,5);
|
||||
import static noppes.npcs.client.gui.player.inventory.GuiCNPCInventory.specialIcons;
|
||||
|
||||
public class GuiNPCGlobalMainMenu extends GuiNPCInterface2 {
|
||||
|
||||
// Store all composite buttons keyed by their IDs.
|
||||
private Map<Integer, GuiNpcSquareButton> buttonMap = new HashMap<>();
|
||||
|
||||
private GuiNpcSquareButton bankButton;
|
||||
private GuiNpcSquareButton factionButton;
|
||||
private GuiNpcSquareButton dialogButton;
|
||||
private GuiNpcSquareButton questButton;
|
||||
private GuiNpcSquareButton transportButton;
|
||||
private GuiNpcSquareButton playerdataButton;
|
||||
private GuiNpcSquareButton recipeButton;
|
||||
private GuiNpcSquareButton spawnButton;
|
||||
private GuiNpcSquareButton linkedButton;
|
||||
private GuiNpcSquareButton animationButton;
|
||||
private GuiNpcSquareButton tagButton;
|
||||
|
||||
public GuiNPCGlobalMainMenu(EntityNPCInterface npc) {
|
||||
super(npc, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new composite button.
|
||||
*/
|
||||
public void registerButton(GuiNpcSquareButton button) {
|
||||
buttonMap.put(button.id, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
int y = guiTop + 10;
|
||||
this.addButton(new GuiNpcButton(2, guiLeft + 5, y, "global.banks"));
|
||||
this.addButton(new GuiNpcButton(3, guiLeft + 5, y += 22, "menu.factions"));
|
||||
this.addButton(new GuiNpcButton(4, guiLeft + 5, y += 22, "dialog.dialogs"));
|
||||
this.addButton(new GuiNpcButton(11, guiLeft + 5, y += 22, "quest.quests"));
|
||||
this.addButton(new GuiNpcButton(12, guiLeft + 5, y += 22, "global.transport"));
|
||||
this.addButton(new GuiNpcButton(13, guiLeft + 5, y += 22, "global.playerdata"));
|
||||
this.addButton(new GuiNpcButton(14, guiLeft + 5, y += 22, "global.recipes"));
|
||||
this.addButton(new GuiNpcButton(15, guiLeft + 5, y += 22, NoppesStringUtils.translate("global.naturalspawn")));
|
||||
this.addButton(new GuiNpcButton(16, guiLeft + 5, y += 22, "global.linked"));
|
||||
y = guiTop + 10;
|
||||
this.addButton(new GuiNpcButton(18, guiLeft + 210, y, "menu.animations"));
|
||||
this.addButton(new GuiNpcButton(17, guiLeft + 210, y += 22, "menu.tags"));
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
// Create and register composite buttons.
|
||||
registerButton(bankButton = new GuiNpcSquareButton(2, 0, 0, 20, "global.banks", 0xFF333333));
|
||||
bankButton.setIconPos(24, 24, 72, 32).setIconTexture(specialIcons);
|
||||
|
||||
registerButton(factionButton = new GuiNpcSquareButton(3, 0, 0, 20, "menu.factions", 0xFF333333));
|
||||
factionButton.setIconPos(24, 24, 0, 32).setIconTexture(specialIcons);
|
||||
|
||||
registerButton(dialogButton = new GuiNpcSquareButton(4, 0, 0, 20, "dialog.dialogs", 0xFF333333));
|
||||
dialogButton.setIconPos(24, 24, 24, 32).setIconTexture(specialIcons);
|
||||
|
||||
registerButton(questButton = new GuiNpcSquareButton(11, 0, 0, 20, "quest.quests", 0xFF333333));
|
||||
questButton.setIconPos(24, 24, 0, 56).setIconTexture(specialIcons);
|
||||
|
||||
registerButton(transportButton = new GuiNpcSquareButton(12, 0, 0, 20, "global.transport", 0xFF333333));
|
||||
transportButton.setIconPos(24, 24, 96, 32).setIconTexture(specialIcons);
|
||||
|
||||
registerButton(playerdataButton = new GuiNpcSquareButton(13, 0, 0, 20, "global.playerdata", 0xFF333333));
|
||||
playerdataButton.setIconPos(24, 24, 216, 32).setIconTexture(specialIcons);
|
||||
|
||||
registerButton(recipeButton = new GuiNpcSquareButton(14, 0, 0, 20, "global.recipes", 0xFF333333));
|
||||
recipeButton.setIconPos(24, 24, 48, 32).setIconTexture(specialIcons);
|
||||
|
||||
registerButton(spawnButton = new GuiNpcSquareButton(15, 0, 0, 20, NoppesStringUtils.translate("global.naturalspawn"), 0xFF333333));
|
||||
spawnButton.setIconPos(24, 24, 144, 32).setIconTexture(specialIcons);
|
||||
|
||||
registerButton(linkedButton = new GuiNpcSquareButton(16, 0, 0, 20, "global.linked", 0xFF333333));
|
||||
linkedButton.setIconPos(24, 24, 168, 32).setIconTexture(specialIcons);
|
||||
|
||||
registerButton(animationButton = new GuiNpcSquareButton(18, 0, 0, 20, "menu.animations", 0xFF333333));
|
||||
animationButton.setIconPos(24, 24, 120, 32).setIconTexture(specialIcons);
|
||||
|
||||
registerButton(tagButton = new GuiNpcSquareButton(17, 0, 0, 20, "menu.tags", 0xFF333333));
|
||||
tagButton.setIconPos(24, 24, 192, 32).setIconTexture(specialIcons);
|
||||
|
||||
// Layout composite buttons optimally.
|
||||
layoutButtons();
|
||||
// Add all composite buttons to the GUI.
|
||||
for (GuiNpcButton btn : buttonMap.values()) {
|
||||
this.addButton(btn);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the optimal layout by iterating over candidate row counts from 1 to total.
|
||||
* For each candidate:
|
||||
* - cols = ceil(total / r)
|
||||
* - candidateHoriz = (availWidth - (cols+1)*padding) / cols
|
||||
* - candidateVert = (availHeight - (r+1)*padding) / r
|
||||
* - candidate = min(candidateHoriz, candidateVert)
|
||||
* - usedWidth = cols * candidate + (cols+1)*padding
|
||||
* - usedHeight = r * candidate + (r+1)*padding
|
||||
* - horizontalWaste = availWidth - usedWidth
|
||||
* - verticalWaste = availHeight - usedHeight
|
||||
* Then define a score = candidate - (horizontalWaste + verticalWaste) * wasteWeight,
|
||||
* where wasteWeight is a constant (try 0.1 or 0.2). We choose the candidate with the highest score.
|
||||
*
|
||||
* @param total Total number of buttons.
|
||||
* @param padding Padding in pixels.
|
||||
* @return An array with {optimalRows, candidateSize}.
|
||||
*/
|
||||
private int[] computeOptimalLayout(int total, int padding) {
|
||||
int availWidth = xSize - 2 * padding;
|
||||
int availHeight = ySize - 2 * padding;
|
||||
int bestRows = 1;
|
||||
int bestCandidate = 0;
|
||||
double bestScore = -Double.MAX_VALUE;
|
||||
double wasteWeight = 0.2; // adjust as needed
|
||||
|
||||
for (int r = 1; r <= total; r++) {
|
||||
int cols = (int) Math.ceil(total / (double) r);
|
||||
int candidateHoriz = (availWidth - (cols + 1) * padding) / cols;
|
||||
int candidateVert = (availHeight - (r + 1) * padding) / r;
|
||||
int candidate = Math.min(candidateHoriz, candidateVert);
|
||||
if (candidate <= 0)
|
||||
continue;
|
||||
int usedWidth = cols * candidate + (cols + 1) * padding;
|
||||
int usedHeight = r * candidate + (r + 1) * padding;
|
||||
int horizontalWaste = availWidth - usedWidth;
|
||||
int verticalWaste = availHeight - usedHeight;
|
||||
double score = candidate - wasteWeight * (horizontalWaste + verticalWaste);
|
||||
if (score > bestScore) {
|
||||
bestScore = score;
|
||||
bestCandidate = candidate;
|
||||
bestRows = r;
|
||||
}
|
||||
}
|
||||
if (bestCandidate <= 0) {
|
||||
bestCandidate = availHeight - 2 * padding;
|
||||
bestRows = 1;
|
||||
}
|
||||
return new int[]{bestRows, bestCandidate};
|
||||
}
|
||||
|
||||
|
||||
private void layoutButtons() {
|
||||
List<GuiNpcSquareButton> buttons = new ArrayList<>(buttonMap.values());
|
||||
Collections.sort(buttons, new Comparator<GuiNpcSquareButton>() {
|
||||
@Override
|
||||
public int compare(GuiNpcSquareButton b1, GuiNpcSquareButton b2) {
|
||||
return Integer.compare(b1.id, b2.id);
|
||||
}
|
||||
});
|
||||
int total = buttons.size();
|
||||
if (total == 0)
|
||||
return;
|
||||
int padding = 5;
|
||||
int[] optimal = computeOptimalLayout(total, padding);
|
||||
int rows = optimal[0];
|
||||
int buttonSize = optimal[1]; // composite button size (square)
|
||||
|
||||
// Distribute buttons evenly among the rows.
|
||||
int base = total / rows;
|
||||
int extra = total % rows;
|
||||
int[] rowCounts = new int[rows];
|
||||
for (int i = 0; i < rows; i++) {
|
||||
rowCounts[i] = base + (i < extra ? 1 : 0);
|
||||
}
|
||||
int totalHeight = rows * buttonSize + (rows + 1) * padding;
|
||||
int startY = guiTop + (ySize - totalHeight) / 2;
|
||||
int index = 0;
|
||||
for (int row = 0; row < rows; row++) {
|
||||
int count = rowCounts[row];
|
||||
int rowWidth = count * buttonSize + (count + 1) * padding;
|
||||
int rowStartX = guiLeft + (xSize - rowWidth) / 2;
|
||||
int yPos = startY + padding + row * (buttonSize + padding);
|
||||
for (int col = 0; col < count; col++) {
|
||||
if (index >= total)
|
||||
break;
|
||||
GuiNpcSquareButton btn = buttons.get(index);
|
||||
btn.updatePositionAndSize(rowStartX + padding + col * (buttonSize + padding), yPos, buttonSize);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
int id = guibutton.id;
|
||||
if (id == 11) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageQuests);
|
||||
}
|
||||
if (id == 2) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageBanks);
|
||||
}
|
||||
if (id == 3) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageFactions);
|
||||
}
|
||||
if (id == 17) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageTags);
|
||||
}
|
||||
if (id == 18) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageAnimations);
|
||||
}
|
||||
if (id == 4) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageDialogs);
|
||||
}
|
||||
if (id == 12) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageTransport);
|
||||
}
|
||||
if (id == 13) {
|
||||
NoppesUtil.openGUI(player, new GuiNpcManagePlayerData(npc));
|
||||
}
|
||||
if (id == 14) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageRecipes, 4, 0, 0);
|
||||
}
|
||||
if (id == 15) {
|
||||
NoppesUtil.openGUI(player, new GuiNpcNaturalSpawns(npc));
|
||||
}
|
||||
if (id == 16) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageLinked);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
int id = guibutton.id;
|
||||
if (id == 11) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageQuests);
|
||||
}
|
||||
if (id == 2) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageBanks);
|
||||
}
|
||||
if (id == 3) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageFactions);
|
||||
}
|
||||
if (id == 17) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageTags);
|
||||
}
|
||||
if (id == 18) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageAnimations);
|
||||
}
|
||||
if (id == 4) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageDialogs);
|
||||
}
|
||||
if (id == 12) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageTransport);
|
||||
}
|
||||
if (id == 13) {
|
||||
NoppesUtil.openGUI(player, new GuiNpcManagePlayerData(npc));
|
||||
}
|
||||
if (id == 14) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageRecipes, 4, 0, 0);
|
||||
}
|
||||
if (id == 15) {
|
||||
NoppesUtil.openGUI(player, new GuiNpcNaturalSpawns(npc));
|
||||
}
|
||||
if (id == 16) {
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.ManageLinked);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void save() {
|
||||
}
|
||||
|
||||
|
||||
public void save() {
|
||||
// No saving logic needed.
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
package noppes.npcs.client.gui.util;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.*;
|
||||
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
@@ -13,7 +13,6 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.CustomNpcResourceListener;
|
||||
import noppes.npcs.client.TextBlockClient;
|
||||
import noppes.npcs.client.gui.global.GuiDiagram;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
@@ -24,9 +24,12 @@ public class GuiNpcButton extends GuiButton {
|
||||
boolean hasSubGUI = false;
|
||||
|
||||
// Fields for icon texture and its dimensions.
|
||||
private ResourceLocation iconTexture = null;
|
||||
private int iconWidth = 16;
|
||||
private int iconHeight = 16;
|
||||
protected ResourceLocation iconTexture = null;
|
||||
protected int iconWidth = 16;
|
||||
protected int iconHeight = 16;
|
||||
|
||||
protected int iconPosX = 0;
|
||||
protected int iconPosY = 0;
|
||||
|
||||
public GuiNpcButton(int i, int j, int k, String s) {
|
||||
super(i, j, k, StatCollector.translateToLocal(s));
|
||||
@@ -97,16 +100,17 @@ public class GuiNpcButton extends GuiButton {
|
||||
* Sets the icon texture for this button.
|
||||
* The texture should be 16x16 by default, unless you adjust the icon dimensions.
|
||||
*/
|
||||
public void setIconTexture(ResourceLocation texture) {
|
||||
public GuiNpcButton setIconTexture(ResourceLocation texture) {
|
||||
this.iconTexture = texture;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the icon dimensions.
|
||||
*/
|
||||
public void setIconSize(int width, int height) {
|
||||
public GuiNpcButton setIconPos(int width, int height, int x, int y) {
|
||||
this.iconWidth = width;
|
||||
this.iconHeight = height;
|
||||
this.iconPosX = x;
|
||||
this.iconPosY = y;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,7 +143,7 @@ public class GuiNpcButton extends GuiButton {
|
||||
int iconX = this.xPosition + (this.width - iconWidth) / 2;
|
||||
int iconY = this.yPosition + (this.height - iconHeight) / 2;
|
||||
// Draw the texture; we assume texture coordinates start at (0,0) with the desired size.
|
||||
this.drawTexturedModalRect(iconX, iconY, 0, 0, iconWidth, iconHeight);
|
||||
this.drawTexturedModalRect(iconX, iconY, iconPosX, iconPosY, iconWidth, iconHeight);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package noppes.npcs.client.gui.util;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import static noppes.npcs.client.gui.player.inventory.GuiCNPCInventory.specialIcons;
|
||||
|
||||
public class GuiNpcSquareButton extends GuiNpcButton {
|
||||
|
||||
// Fixed height for the text button portion.
|
||||
public static final int TEXT_BUTTON_HEIGHT = 20;
|
||||
// Overall square side length (set via layout).
|
||||
public int size;
|
||||
// The icon area height is the overall size minus TEXT_BUTTON_HEIGHT.
|
||||
public int iconAreaHeight;
|
||||
// Background color (ARGB) for the icon area.
|
||||
protected int backgroundColor;
|
||||
// The child text button.
|
||||
public GuiNpcButton textButton;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param id Button id.
|
||||
* @param x Initial x (placeholder; layout will override).
|
||||
* @param y Initial y (placeholder; layout will override).
|
||||
* @param size Overall square side (placeholder; layout will override).
|
||||
* @param label Button text.
|
||||
* @param backgroundColor ARGB color for the icon area.
|
||||
*/
|
||||
public GuiNpcSquareButton(int id, int x, int y, int size, String label, int backgroundColor) {
|
||||
// The composite button’s width and height are both "size".
|
||||
super(id, x, y, size, size, label);
|
||||
this.size = size;
|
||||
this.iconAreaHeight = size - TEXT_BUTTON_HEIGHT;
|
||||
this.backgroundColor = backgroundColor;
|
||||
// Create the child text button.
|
||||
this.textButton = new GuiNpcButton(id, x, y + iconAreaHeight, size, TEXT_BUTTON_HEIGHT, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the composite button’s position and overall size.
|
||||
*/
|
||||
public void updatePositionAndSize(int x, int y, int newSize) {
|
||||
this.xPosition = x;
|
||||
this.yPosition = y;
|
||||
this.size = newSize;
|
||||
this.width = newSize;
|
||||
this.height = newSize;
|
||||
this.iconAreaHeight = newSize - TEXT_BUTTON_HEIGHT;
|
||||
this.textButton.xPosition = x;
|
||||
this.textButton.yPosition = y + this.iconAreaHeight;
|
||||
this.textButton.width = newSize;
|
||||
this.textButton.height = TEXT_BUTTON_HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (!this.visible)
|
||||
return;
|
||||
|
||||
// --- Draw the icon area background ---
|
||||
Gui.drawRect(xPosition, yPosition, xPosition + size, yPosition + iconAreaHeight, backgroundColor);
|
||||
|
||||
// --- Draw the icon ---
|
||||
if (iconTexture != null) {
|
||||
this.zLevel = 100.0F;
|
||||
mc.getTextureManager().bindTexture(iconTexture);
|
||||
GL11.glPushMatrix();
|
||||
// Disable lighting so the icon is drawn at full brightness.
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
// Set color to white
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
// Compute center of icon area.
|
||||
float centerX = xPosition + size / 2.0F;
|
||||
float centerY = yPosition + iconAreaHeight / 2.0F;
|
||||
GL11.glTranslatef(centerX, centerY, 0F);
|
||||
|
||||
float scale = (float) iconAreaHeight / iconHeight;
|
||||
GL11.glScalef(scale, scale, 1F);
|
||||
|
||||
GL11.glTranslatef(-8F, -8F, 0F);
|
||||
// Draw the icon (using stored UV coordinates)
|
||||
this.drawTexturedModalRect(0, 0, iconPosX, iconPosY, iconWidth, iconHeight);
|
||||
GL11.glPopMatrix();
|
||||
this.zLevel = 0f;
|
||||
}
|
||||
|
||||
// --- Draw the child text button ---
|
||||
textButton.drawButton(mc, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (!this.visible)
|
||||
return false;
|
||||
|
||||
// If click is in the text button area:
|
||||
if (mouseX >= xPosition && mouseX < xPosition + size &&
|
||||
mouseY >= yPosition + iconAreaHeight && mouseY < yPosition + size) {
|
||||
return textButton.mousePressed(mc, mouseX, mouseY);
|
||||
}
|
||||
// Or if click is in the icon area, we also treat it as a click.
|
||||
if (mouseX >= xPosition && mouseX < xPosition + size &&
|
||||
mouseY >= yPosition && mouseY < yPosition + iconAreaHeight) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
textButton.mouseReleased(mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user