Full Screen Directory Mode for Cloner Tab Handling

This commit is contained in:
Kam committed 2026-02-04 12:34:26 -05:00
1 parent 65e29e42dd
commit a325c5c618
16 files changed
+826 -621

No files matched your search

@@ -1,7 +1,11 @@
package noppes.npcs.client.gui.util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.List;
@@ -11,9 +15,11 @@ public class GuiCustomScrollIcons extends GuiCustomScroll {
public static final int ICON_TAB = 1;
public static final int ICON_FOLDER = 2;
private static final int ICON_WIDTH = 14;
private static final int FOLDER_COLOR = 0xFFDDAA00;
private static final int TAB_COLOR = 0xFF6688AA;
private static final ResourceLocation TAB_TEXTURE = new ResourceLocation("customnpcs", "textures/gui/cloner/tab.png");
private static final ResourceLocation FOLDER_TEXTURE = new ResourceLocation("customnpcs", "textures/gui/cloner/folder.png");
private static final int ICON_RENDER_SIZE = 10;
private static final int ICON_PADDING = 14;
private List<Integer> iconTypes = new ArrayList<>();
@@ -28,6 +34,7 @@ public class GuiCustomScrollIcons extends GuiCustomScroll {
@Override
protected void drawItems() {
Minecraft mc = Minecraft.getMinecraft();
for (int i = 0; i < list.size(); i++) {
int j = 4;
int k = (14 * i + 4) - scrollY;
@@ -37,20 +44,24 @@ public class GuiCustomScrollIcons extends GuiCustomScroll {
int iconType = (i < iconTypes.size()) ? iconTypes.get(i) : ICON_NONE;
int textX = j;
if (iconType != ICON_NONE) {
textX = j + ICON_WIDTH;
textX = j + ICON_PADDING;
}
// Draw icon
if (iconType == ICON_FOLDER) {
drawRect(j, k - 1, j + 10, k + 7, FOLDER_COLOR);
} else if (iconType == ICON_TAB) {
drawRect(j, k - 1, j + 10, k + 7, TAB_COLOR);
// Draw icon texture
if (iconType == ICON_FOLDER || iconType == ICON_TAB) {
ResourceLocation tex = (iconType == ICON_FOLDER) ? FOLDER_TEXTURE : TAB_TEXTURE;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(tex);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
drawFullTexture(j, k - 1, ICON_RENDER_SIZE, ICON_RENDER_SIZE);
GL11.glDisable(GL11.GL_BLEND);
}
// Draw text
String displayString = StatCollector.translateToLocal(list.get(i));
String text = "";
float maxWidth = (xSize + xOffset - 8 - (iconType != ICON_NONE ? ICON_WIDTH : 0)) * 0.8f;
float maxWidth = (xSize + xOffset - 8 - (iconType != ICON_NONE ? ICON_PADDING : 0)) * 0.8f;
if (fontRendererObj.getStringWidth(displayString) > maxWidth) {
for (int h = 0; h < displayString.length(); h++) {
char c = displayString.charAt(h);
@@ -64,18 +75,34 @@ public class GuiCustomScrollIcons extends GuiCustomScroll {
text = displayString;
}
int itemColor = this.colors.getOrDefault(list.get(i), 0xffffff);
if ((multipleSelection && selectedList.contains(list.get(i))) || (!multipleSelection && selected == i)) {
drawVerticalLine(j - 2, k - 4, k + 10, 0xffffffff);
drawVerticalLine(j + xSize - 18 + xOffset, k - 4, k + 10, 0xffffffff);
drawHorizontalLine(j - 2, j + xSize - 18 + xOffset, k - 3, 0xffffffff);
drawHorizontalLine(j - 2, j + xSize - 18 + xOffset, k + 10, 0xffffffff);
fontRendererObj.drawString(text, textX, k, 0xffffff);
fontRendererObj.drawString(text, textX, k, itemColor);
} else if (i == hover) {
fontRendererObj.drawString(text, textX, k, 0x00ff00);
} else {
fontRendererObj.drawString(text, textX, k, 0xffffff);
fontRendererObj.drawString(text, textX, k, itemColor);
}
}
}
}
/**
* Draw a full texture (UV 0,0 to 1,1) scaled to the given width/height.
* Works with any texture size (not just 256x256).
*/
private void drawFullTexture(int x, int y, int w, int h) {
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(x, y + h, 0, 0, 1);
tessellator.addVertexWithUV(x + w, y + h, 0, 1, 1);
tessellator.addVertexWithUV(x + w, y, 0, 1, 0);
tessellator.addVertexWithUV(x, y, 0, 0, 0);
tessellator.draw();
}
}