2014-04-29 10:54:20 +10:00
|
|
|
package codechicken.nei;
|
|
|
|
|
|
2023-09-25 00:34:42 +02:00
|
|
|
import codechicken.nei.api.LayoutStyle;
|
|
|
|
|
import codechicken.nei.drawable.DrawableBuilder;
|
|
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
import static codechicken.lib.gui.GuiDraw.drawStringC;
|
2019-12-24 13:37:41 -08:00
|
|
|
import static codechicken.nei.LayoutManager.bookmarkPanel;
|
2021-03-20 22:38:46 -07:00
|
|
|
import static codechicken.nei.LayoutManager.bookmarksButton;
|
2019-12-24 13:37:41 -08:00
|
|
|
import static codechicken.nei.LayoutManager.delete;
|
|
|
|
|
import static codechicken.nei.LayoutManager.dropDown;
|
|
|
|
|
import static codechicken.nei.LayoutManager.gamemode;
|
|
|
|
|
import static codechicken.nei.LayoutManager.heal;
|
|
|
|
|
import static codechicken.nei.LayoutManager.itemPanel;
|
2021-05-22 18:31:40 +01:00
|
|
|
import static codechicken.nei.LayoutManager.itemPresenceOverlays;
|
2019-12-24 13:37:41 -08:00
|
|
|
import static codechicken.nei.LayoutManager.magnet;
|
|
|
|
|
import static codechicken.nei.LayoutManager.options;
|
2022-06-24 12:32:13 +01:00
|
|
|
import static codechicken.nei.LayoutManager.presetsPanel;
|
2019-12-24 13:37:41 -08:00
|
|
|
import static codechicken.nei.LayoutManager.rain;
|
|
|
|
|
import static codechicken.nei.LayoutManager.searchField;
|
|
|
|
|
import static codechicken.nei.LayoutManager.timeButtons;
|
|
|
|
|
import static codechicken.nei.NEIClientConfig.canPerformAction;
|
|
|
|
|
import static codechicken.nei.NEIClientConfig.disabledActions;
|
|
|
|
|
import static codechicken.nei.NEIClientConfig.getMagnetMode;
|
|
|
|
|
import static codechicken.nei.NEIClientConfig.isEnabled;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
public class LayoutStyleMinecraft extends LayoutStyle {
|
2023-01-28 17:55:51 -08:00
|
|
|
|
2019-12-24 13:37:41 -08:00
|
|
|
public int buttonCount;
|
|
|
|
|
public int leftSize;
|
|
|
|
|
public int numButtons;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getName() {
|
|
|
|
|
return "minecraft";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void init() {
|
|
|
|
|
delete.icon = new Image(144, 12, 12, 12);
|
2019-12-24 13:37:41 -08:00
|
|
|
rain.icon = new Image(120, 12, 12, 12);
|
2014-04-29 10:54:20 +10:00
|
|
|
gamemode.icons[0] = new Image(132, 12, 12, 12);
|
|
|
|
|
gamemode.icons[1] = new Image(156, 12, 12, 12);
|
|
|
|
|
gamemode.icons[2] = new Image(168, 12, 12, 12);
|
|
|
|
|
magnet.icon = new Image(180, 24, 12, 12);
|
|
|
|
|
timeButtons[0].icon = new Image(132, 24, 12, 12);
|
|
|
|
|
timeButtons[1].icon = new Image(120, 24, 12, 12);
|
|
|
|
|
timeButtons[2].icon = new Image(144, 24, 12, 12);
|
|
|
|
|
timeButtons[3].icon = new Image(156, 24, 12, 12);
|
|
|
|
|
heal.icon = new Image(168, 24, 12, 12);
|
2021-05-22 18:31:40 +01:00
|
|
|
itemPresenceOverlays[0] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 0, 40, 8, 8).build();
|
|
|
|
|
itemPresenceOverlays[1] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 8, 40, 8, 8).build();
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void reset() {
|
2019-12-24 13:37:41 -08:00
|
|
|
buttonCount = 0;
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2019-12-24 13:37:41 -08:00
|
|
|
public void layout(GuiContainer gui, VisiblityData visiblity) {
|
|
|
|
|
reset();
|
|
|
|
|
|
|
|
|
|
leftSize = ItemPanels.bookmarkPanel.getWidth(gui);
|
2020-01-21 20:20:23 -08:00
|
|
|
numButtons = Math.max(leftSize / 18, 1);
|
2019-12-24 13:37:41 -08:00
|
|
|
|
|
|
|
|
delete.state = 0x4;
|
2022-06-24 12:32:13 +01:00
|
|
|
if (NEIController.getDeleteMode()) delete.state |= 1;
|
|
|
|
|
else if (!visiblity.enableDeleteMode) delete.state |= 2;
|
2019-12-24 13:37:41 -08:00
|
|
|
|
|
|
|
|
rain.state = 0x4;
|
2022-06-24 12:32:13 +01:00
|
|
|
if (disabledActions.contains("rain")) rain.state |= 2;
|
|
|
|
|
else if (NEIClientUtils.isRaining()) rain.state |= 1;
|
2019-12-24 13:37:41 -08:00
|
|
|
|
|
|
|
|
gamemode.state = 0x4;
|
|
|
|
|
if (NEIClientUtils.getGamemode() != 0) {
|
|
|
|
|
gamemode.state |= 0x1;
|
|
|
|
|
gamemode.index = NEIClientUtils.getGamemode() - 1;
|
2014-04-29 10:54:20 +10:00
|
|
|
} else {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (NEIClientUtils.isValidGamemode("creative")) gamemode.index = 0;
|
|
|
|
|
else if (NEIClientUtils.isValidGamemode("creative+")) gamemode.index = 1;
|
|
|
|
|
else if (NEIClientUtils.isValidGamemode("adventure")) gamemode.index = 2;
|
2019-12-24 13:37:41 -08:00
|
|
|
}
|
2021-03-20 22:38:46 -07:00
|
|
|
bookmarksButton.index = NEIClientConfig.isBookmarkPanelHidden() ? 0 : 1;
|
2021-03-15 22:31:36 -07:00
|
|
|
options.index = NEIClientConfig.getCheatMode();
|
2019-12-24 13:37:41 -08:00
|
|
|
|
|
|
|
|
magnet.state = 0x4 | (getMagnetMode() ? 1 : 0);
|
|
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
if (canPerformAction("delete")) layoutButton(delete);
|
|
|
|
|
if (canPerformAction("rain")) layoutButton(rain);
|
|
|
|
|
if (NEIClientUtils.isValidGamemode("creative") || NEIClientUtils.isValidGamemode("creative+")
|
|
|
|
|
|| NEIClientUtils.isValidGamemode("adventure"))
|
|
|
|
|
layoutButton(gamemode);
|
|
|
|
|
if (canPerformAction("magnet")) layoutButton(magnet);
|
2019-12-24 13:37:41 -08:00
|
|
|
if (canPerformAction("time")) {
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
|
timeButtons[i].state = disabledActions.contains(NEIActions.timeZones[i]) ? 2 : 0;
|
|
|
|
|
layoutButton(timeButtons[i]);
|
|
|
|
|
}
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
2022-06-24 12:32:13 +01:00
|
|
|
if (canPerformAction("heal")) layoutButton(heal);
|
2019-12-24 13:37:41 -08:00
|
|
|
|
|
|
|
|
itemPanel.resize(gui);
|
|
|
|
|
bookmarkPanel.resize(gui);
|
|
|
|
|
|
|
|
|
|
options.x = isEnabled() ? 0 : 6;
|
|
|
|
|
options.y = isEnabled() ? gui.height - 22 : gui.height - 28;
|
2021-03-15 22:31:36 -07:00
|
|
|
options.w = 22;
|
2019-12-24 13:37:41 -08:00
|
|
|
options.h = 22;
|
2021-03-20 22:38:46 -07:00
|
|
|
|
|
|
|
|
bookmarksButton.x = 24 + (isEnabled() ? 0 : 6);
|
|
|
|
|
bookmarksButton.y = isEnabled() ? gui.height - 22 : gui.height - 28;
|
|
|
|
|
bookmarksButton.w = 22;
|
|
|
|
|
bookmarksButton.h = 22;
|
2019-12-24 13:37:41 -08:00
|
|
|
|
2022-05-06 22:41:45 +03:00
|
|
|
dropDown.h = 18;
|
|
|
|
|
dropDown.w = 150;
|
|
|
|
|
dropDown.y = 0;
|
|
|
|
|
dropDown.x = (gui.width - gui.xSize) / 2 + gui.xSize - dropDown.w;
|
2019-12-24 13:37:41 -08:00
|
|
|
|
2022-05-06 22:41:45 +03:00
|
|
|
presetsPanel.h = 16;
|
|
|
|
|
presetsPanel.w = 150;
|
|
|
|
|
presetsPanel.y = 2;
|
|
|
|
|
presetsPanel.x = (gui.width - gui.xSize) / 2 + gui.xSize - presetsPanel.w;
|
2022-06-24 12:32:13 +01:00
|
|
|
|
2019-12-24 13:37:41 -08:00
|
|
|
searchField.h = 20;
|
2023-04-01 16:16:18 -05:00
|
|
|
if (NEIClientConfig.isSearchWidgetCentered()) {
|
|
|
|
|
searchField.w = 150;
|
|
|
|
|
searchField.x = (gui.width - searchField.w) / 2;
|
|
|
|
|
} else {
|
|
|
|
|
searchField.w = (int) (itemPanel.w * (NEIClientConfig.showItemQuantityWidget() ? 0.7 : 1));
|
|
|
|
|
searchField.x = itemPanel.x;
|
|
|
|
|
}
|
2022-05-06 22:41:45 +03:00
|
|
|
searchField.y = gui.height - searchField.h - 2;
|
2019-12-24 13:37:41 -08:00
|
|
|
|
|
|
|
|
if (!visiblity.showItemSection) {
|
|
|
|
|
searchField.setFocus(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void layoutButton(Button button) {
|
2022-05-06 22:41:45 +03:00
|
|
|
button.x = 2 + (buttonCount % numButtons) * 19;
|
|
|
|
|
button.y = 2 + (buttonCount / numButtons) * 18;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2014-06-29 20:31:37 +10:00
|
|
|
button.h = 17;
|
|
|
|
|
button.w = button.contentWidth() + 6;
|
2019-12-24 13:37:41 -08:00
|
|
|
|
|
|
|
|
buttonCount++;
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void drawButton(Button b, int mousex, int mousey) {
|
|
|
|
|
GL11.glDisable(GL11.GL_LIGHTING);
|
|
|
|
|
GL11.glColor4f(1, 1, 1, 1);
|
|
|
|
|
|
|
|
|
|
int tex;
|
2022-06-24 12:32:13 +01:00
|
|
|
if ((b.state & 0x3) == 2) tex = 0;
|
|
|
|
|
else if ((b.state & 0x4) == 0 && b.contains(mousex, mousey) || // not a state button and mouseover
|
|
|
|
|
(b.state & 0x3) == 1) // state active
|
|
|
|
|
tex = 2;
|
|
|
|
|
else tex = 1;
|
2014-06-29 20:31:37 +10:00
|
|
|
LayoutManager.drawButtonBackground(b.x, b.y, b.w, b.h, true, tex);
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
Image icon = b.getRenderIcon();
|
|
|
|
|
if (icon == null) {
|
2021-03-15 22:31:36 -07:00
|
|
|
int colour = tex == 2 ? 0xffffa0 : tex == 0 ? 0x601010 : 0xe0e0e0;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2014-06-29 20:31:37 +10:00
|
|
|
drawStringC(b.getRenderLabel(), b.x + b.w / 2, b.y + (b.h - 8) / 2, colour);
|
2014-04-29 10:54:20 +10:00
|
|
|
} else {
|
|
|
|
|
GL11.glColor4f(1, 1, 1, 1);
|
|
|
|
|
|
2021-03-15 22:31:36 -07:00
|
|
|
final int iconX = b.x + (b.w - icon.width) / 2;
|
|
|
|
|
final int iconY = b.y + (b.h - icon.height) / 2;
|
2021-03-23 23:34:05 -07:00
|
|
|
|
2021-03-15 22:31:36 -07:00
|
|
|
LayoutManager.drawIcon(iconX, iconY, icon);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2014-06-29 20:31:37 +10:00
|
|
|
public void drawSubsetTag(String text, int x, int y, int w, int h, int state, boolean mouseover) {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (state == 1) GL11.glColor4f(0.65F, 0.65F, 0.65F, 1.0F);
|
|
|
|
|
else GL11.glColor4f(1, 1, 1, 1);
|
2014-06-29 20:31:37 +10:00
|
|
|
LayoutManager.drawButtonBackground(x, y, w, h, false, state == 0 ? 0 : 1);
|
2022-06-24 12:32:13 +01:00
|
|
|
if (text != null) drawStringC(text, x, y, w, h, state == 2 ? 0xFFE0E0E0 : 0xFFA0A0A0);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
}
|