Fix Some issues with Lang Setup, Button Widths, Moving System

This commit is contained in:
Kam committed 2026-03-09 22:15:22 -04:00
1 parent 676c0626d1
commit b0168c1d55
7 files changed
+141 -41

No files matched your search

@@ -269,7 +269,24 @@ public class GuiAbilityDirectory extends GuiDirectoryCategorized
@Override
protected void onCloneItem() {
// Abilities don't support cloning through this mechanism
if (currentIsBuiltIn) return;
if (isChainedMode() && selectedChain != null) {
ChainedAbility clone = new ChainedAbility();
clone.readNBT(selectedChain.writeNBT(false));
String cloneName = selectedChain.getName() + "_copy";
clone.setName(cloneName);
PacketClient.sendClient(new ChainedAbilitySavePacket(clone.writeNBT(false)));
if (selectedCatId >= 0) requestItemsInCategory(selectedCatId);
} else if (selectedAbility != null) {
Ability clone = AbilityController.Instance.fromNBT(selectedAbility.writeNBT(false));
if (clone != null) {
clone.setId(UUID.randomUUID().toString());
String cloneName = selectedAbility.getName() + "_copy";
clone.setName(cloneName);
PacketClient.sendClient(new CustomAbilitySavePacket(clone.writeNBT(false)));
if (selectedCatId >= 0 && isCustomMode()) requestItemsInCategory(selectedCatId);
}
}
}
@Override
@@ -672,10 +689,10 @@ public class GuiAbilityDirectory extends GuiDirectoryCategorized
if (!isPlaying || isPaused) {
String statusKey = isPaused ? "animation.paused" : "animation.stopped";
addLabel(new GuiNpcLabel(90, statusKey, btnX, playY + 5));
addLabel(new GuiNpcLabel(90, statusKey, btnX, playY + 5, 0xFFFFFF));
addButton(new GuiTexturedButton(91, "", btnX + 65, playY, 11, 20, animTexture, 18, 71));
} else {
addLabel(new GuiNpcLabel(90, "animation.playing", btnX, playY + 5));
addLabel(new GuiNpcLabel(90, "animation.playing", btnX, playY + 5, 0xFFFFFF));
addButton(new GuiTexturedButton(92, "", btnX + 65, playY, 14, 20, animTexture, 0, 71));
}
if (isActive) {
@@ -683,13 +700,19 @@ public class GuiAbilityDirectory extends GuiDirectoryCategorized
}
}
// Edit + Remove at bottom
int editY = contentY + contentH - btnH * 2 - gap;
GuiNpcButton editBtn = new GuiNpcButton(51, rightX, editY, rightPanelW, btnH, "gui.edit");
// Edit + Copy on one row, Remove below
int btnY = contentY + contentH - btnH * 2 - gap;
int halfW = (rightPanelW - gap) / 2;
GuiNpcButton editBtn = new GuiNpcButton(51, rightX, btnY, halfW, btnH, "gui.edit");
editBtn.enabled = hasSelectedItem() && movePhase == 0 && !currentIsBuiltIn;
addButton(editBtn);
int removeY = editY + btnH + gap;
GuiNpcButton cloneBtn = new GuiNpcButton(52, rightX + halfW + gap, btnY, halfW, btnH, "gui.copy");
cloneBtn.enabled = hasSelectedItem() && movePhase == 0 && !currentIsBuiltIn;
addButton(cloneBtn);
int removeY = btnY + btnH + gap;
GuiNpcButton removeBtn = new GuiNpcButton(53, rightX, removeY, rightPanelW, btnH, "gui.remove");
removeBtn.enabled = hasSelectedItem() && movePhase == 0 && !currentIsBuiltIn;
removeBtn.setTextColor(0xFF5555);
@@ -783,6 +806,8 @@ public class GuiAbilityDirectory extends GuiDirectoryCategorized
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
GL11.glDisable(GL11.GL_TEXTURE_2D);
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
GL11.glDisable(GL11.GL_COLOR_MATERIAL);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_SCISSOR_TEST);
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
@@ -836,6 +861,8 @@ public class GuiAbilityDirectory extends GuiDirectoryCategorized
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
GL11.glDisable(GL11.GL_TEXTURE_2D);
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
GL11.glDisable(GL11.GL_COLOR_MATERIAL);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
GL11.glPopMatrix();
}
@@ -959,32 +986,32 @@ public class GuiAbilityDirectory extends GuiDirectoryCategorized
if (isChainedMode() && selectedChain != null) {
fontRendererObj.drawString(selectedChain.getDisplayName(), x, y, 0xFFFFFF, true);
y += 14;
fontRendererObj.drawString("Entries: " + selectedChain.getEntries().size(), x, y, 0xB5B5B5, false);
fontRendererObj.drawString(StatCollector.translateToLocal("ability.entries") + ": " + selectedChain.getEntries().size(), x, y, 0xB5B5B5, false);
y += 12;
fontRendererObj.drawString("Cooldown: " + selectedChain.getCooldownTicks() + "t", x, y, 0xB5B5B5, false);
fontRendererObj.drawString(StatCollector.translateToLocal("ability.cooldown") + ": " + selectedChain.getCooldownTicks() + "t", x, y, 0xB5B5B5, false);
y += 12;
UserType ut = selectedChain.getAllowedBy();
fontRendererObj.drawString("Allowed: " + ut.name(), x, y, 0xB5B5B5, false);
fontRendererObj.drawString(StatCollector.translateToLocal("ability.allowed") + ": " + ut.name(), x, y, 0xB5B5B5, false);
} else if (selectedAbility != null) {
fontRendererObj.drawString(selectedAbility.getDisplayName(), x, y, 0xFFFFFF, true);
y += 14;
String typeId = selectedAbility.getTypeId();
String typeName = StatCollector.translateToLocal(typeId);
fontRendererObj.drawString("Type: " + typeName, x, y, 0xFFAE0D, false);
fontRendererObj.drawString(StatCollector.translateToLocal("gui.type") + ": " + typeName, x, y, 0xFFAE0D, false);
y += 12;
fontRendererObj.drawString("Cooldown: " + selectedAbility.getCooldownTicks() + "t", x, y, 0xB5B5B5, false);
fontRendererObj.drawString(StatCollector.translateToLocal("ability.cooldown") + ": " + selectedAbility.getCooldownTicks() + "t", x, y, 0xB5B5B5, false);
y += 12;
fontRendererObj.drawString("Windup: " + selectedAbility.getWindUpTicks() + "t", x, y, 0xB5B5B5, false);
fontRendererObj.drawString(StatCollector.translateToLocal("ability.windup") + ": " + selectedAbility.getWindUpTicks() + "t", x, y, 0xB5B5B5, false);
y += 12;
UserType ut = selectedAbility.getAllowedBy();
fontRendererObj.drawString("Allowed: " + ut.name(), x, y, 0xB5B5B5, false);
fontRendererObj.drawString(StatCollector.translateToLocal("ability.allowed") + ": " + ut.name(), x, y, 0xB5B5B5, false);
if (selectedAbility.hasDamage()) {
y += 12;
fontRendererObj.drawString("Damage: " + selectedAbility.getDisplayDamage(), x, y, 0xFF5555, false);
fontRendererObj.drawString(StatCollector.translateToLocal("ability.damage") + ": " + selectedAbility.getDisplayDamage(), x, y, 0xFF5555, false);
}
if (currentIsBuiltIn) {
y += 12;
fontRendererObj.drawString("(Built-in)", x, y, 0x55FF55, false);
fontRendererObj.drawString(StatCollector.translateToLocal("gui.builtin.tag"), x, y, 0x55FF55, false);
}
}
}
@@ -19,6 +19,7 @@ import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiDirectoryCategorized;
@@ -263,10 +264,13 @@ public class GuiAnimationDirectory extends GuiDirectoryCategorized {
@Override
protected void initRightPanel(int startY) {
// Calculate layout: playback row + edit/copy + remove rows
// Calculate layout: playback rows + edit/copy + remove rows
int bottomRows = 2; // edit+copy, remove
boolean hasPlayback = animation != null && !animation.frames.isEmpty() && hasSelectedItem();
if (hasPlayback) bottomRows++; // playback row
if (hasPlayback) {
bottomRows++; // playback controls row
if (playingAnimation) bottomRows++; // frame info row
}
int bottomH = bottomRows * (btnH + gap) + 14;
previewX = rightX;
@@ -283,15 +287,17 @@ public class GuiAnimationDirectory extends GuiDirectoryCategorized {
if (!playingAnimation || (data.animation != null && data.animation.paused)) {
String statusKey = (data.animation != null && data.animation.paused) ? "animation.paused" : "animation.stopped";
addLabel(new GuiNpcLabel(90, statusKey, btnX, playY + 5));
addLabel(new GuiNpcLabel(90, statusKey, btnX, playY + 5, 0xFFFFFF));
addButton(new GuiTexturedButton(91, "", btnX + 65, playY, 11, 20, animTexture, 18, 71));
} else {
addLabel(new GuiNpcLabel(90, "animation.playing", btnX, playY + 5));
addLabel(new GuiNpcLabel(94, "", btnX + 60, playY + 5));
addLabel(new GuiNpcLabel(90, "animation.playing", btnX, playY + 5, 0xFFFFFF));
addButton(new GuiTexturedButton(92, "", btnX + 65, playY, 14, 20, animTexture, 0, 71));
}
if (playingAnimation) {
addButton(new GuiTexturedButton(93, "", btnX + 85, playY, 14, 20, animTexture, 33, 71));
// Frame info on its own line below playback controls
int frameInfoY = playY + btnH + gap;
addLabel(new GuiNpcLabel(94, "", btnX, frameInfoY + 5, 0xFFFFFF));
}
}
@@ -498,15 +504,15 @@ public class GuiAnimationDirectory extends GuiDirectoryCategorized {
fontRendererObj.drawString(animation.name, x, y, 0xFFFFFF, true);
y += 14;
fontRendererObj.drawString("Frames: " + animation.frames.size(), x, y, 0xB5B5B5, false);
fontRendererObj.drawString(StatCollector.translateToLocal("animation.frames") + ": " + animation.frames.size(), x, y, 0xB5B5B5, false);
y += 12;
fontRendererObj.drawString("Speed: " + animation.speed, x, y, 0xB5B5B5, false);
fontRendererObj.drawString(StatCollector.translateToLocal("stats.speed") + ": " + animation.speed, x, y, 0xB5B5B5, false);
y += 12;
String loopStr = animation.loop == 0 ? "None" : animation.loop == 1 ? "Loop" : "Mirror";
fontRendererObj.drawString("Loop: " + loopStr, x, y, 0xB5B5B5, false);
String loopStr = animation.loop == 0 ? StatCollector.translateToLocal("gui.none") : animation.loop == 1 ? StatCollector.translateToLocal("animation.loop") : StatCollector.translateToLocal("animation.mirror");
fontRendererObj.drawString(StatCollector.translateToLocal("animation.loop") + ": " + loopStr, x, y, 0xB5B5B5, false);
if (currentIsBuiltIn) {
y += 12;
fontRendererObj.drawString("(Built-in)", x, y, 0x55FF55, false);
fontRendererObj.drawString(StatCollector.translateToLocal("gui.builtin.tag"), x, y, 0x55FF55, false);
}
}
@@ -15,7 +15,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.ClientCacheHandler;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.gui.SubGuiEffectGeneral;
import noppes.npcs.client.gui.util.GuiDirectoryCategorized;
import noppes.npcs.client.gui.util.SubGuiInterface;
@@ -180,7 +179,7 @@ public class GuiEffectDirectory extends GuiDirectoryCategorized {
if (effect == null || effect.id == -1) return;
String drawString = effect.getMenuName();
fontRendererObj.drawString(drawString, x, y, CustomNpcResourceListener.DefaultTextColor, true);
fontRendererObj.drawString(drawString, x, y, 0xFFFFFF, true);
y += 14;
fontRendererObj.drawString(StatCollector.translateToLocal("gui.name") + ": " + effect.name, x, y, 0xFFFFFF, false);
@@ -17,7 +17,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.ClientCacheHandler;
import noppes.npcs.client.CustomNpcResourceListener;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.gui.item.SubGuiLinkedItem;
import noppes.npcs.client.gui.util.GuiDirectoryCategorized;
@@ -215,7 +214,7 @@ public class GuiLinkedItemDirectory extends GuiDirectoryCategorized {
protected void drawItemDetails(int x, int y, int w) {
if (linkedItem == null || linkedItem.id < 0) return;
fontRendererObj.drawString(linkedItem.name, x, y, CustomNpcResourceListener.DefaultTextColor, true);
fontRendererObj.drawString(linkedItem.name, x, y, 0xFFFFFF, true);
y += 14;
int labelColor = 0xffae0d;
@@ -184,7 +184,7 @@ public abstract class GuiDirectoryCategorized extends GuiDirectory
x += topBtnW + 2;
// MOVE
String moveLabel = movePhase > 0 ? "Moving" : "Move";
String moveLabel = movePhase > 0 ? "gui.moving" : "gui.move";
GuiNpcButton moveBtn = new GuiNpcButton(54, x, topBtnY, topBtnW, btnH, moveLabel);
moveBtn.enabled = selectedCatId >= 0 && !leftCollapsed && hasCategories();
addButton(moveBtn);
@@ -192,8 +192,9 @@ public abstract class GuiDirectoryCategorized extends GuiDirectory
// Confirm (only during move phase 1)
if (movePhase == 1) {
GuiNpcButton confirmBtn = new GuiNpcButton(55, x, topBtnY, topBtnW, btnH, "Confirm");
GuiNpcButton confirmBtn = new GuiNpcButton(55, x, topBtnY, topBtnW, btnH, "gui.confirm");
confirmBtn.enabled = !moveSelection.isEmpty();
confirmBtn.setTextColor(0x55FFFF);
addButton(confirmBtn);
x += topBtnW + 2;
}
@@ -230,6 +231,13 @@ public abstract class GuiDirectoryCategorized extends GuiDirectory
catScroll.setSelected(prevCatName);
catScroll.scrollY = Math.max(0, Math.min(savedCatScrollY, catScroll.maxScrollY));
// Phase 1: categories are locked (RED labels, not clickable)
if (movePhase == 1) {
catScroll.setSelectable(false);
for (String name : navNames) {
catScroll.colors.put(name, 0xFF5555);
}
}
// Phase 2: ensure scroll is clickable for destination selection
if (movePhase == 2) {
catScroll.setSelectable(true);
@@ -391,19 +399,19 @@ public abstract class GuiDirectoryCategorized extends GuiDirectory
// Draw ID (skip if -1, e.g. abilities use names not IDs)
if (hasSelectedItem() && getSelectedItemId() >= 0) {
String idStr = "ID: " + getSelectedItemId();
int idY = contentY + contentH - btnH - 14;
String idStr = StatCollector.translateToLocal("gui.id") + ": " + getSelectedItemId();
int idY = contentY + contentH - btnH * 2 - gap - 12;
fontRendererObj.drawString(idStr, previewX + 4, idY, 0xFFFFFF, true);
}
}
// Move phase overlay text
if (movePhase == 1) {
String text = "Select Items to Move (max " + MAX_MOVE_ITEMS + ")";
String text = String.format(StatCollector.translateToLocal("gui.move.selectItems"), MAX_MOVE_ITEMS);
int textW = fontRendererObj.getStringWidth(text);
fontRendererObj.drawStringWithShadow(text, width / 2 - textW / 2, height - pad - 10, 0x55FF55);
} else if (movePhase == 2) {
String text = "Select Destination Category";
String text = StatCollector.translateToLocal("gui.move.selectCategory");
int textW = fontRendererObj.getStringWidth(text);
fontRendererObj.drawStringWithShadow(text, width / 2 - textW / 2, height - pad - 10, 0xFF5555);
}
@@ -592,6 +600,9 @@ public abstract class GuiDirectoryCategorized extends GuiDirectory
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
// Category scroll
if (guiCustomScroll.id == 2) {
// Block category clicks during move phase 1 (selecting items)
if (movePhase == 1) return;
String selected = catScroll.getSelected();
if (selected == null) return;
@@ -5,6 +5,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
@@ -166,8 +167,13 @@ public class GuiNpcButton extends GuiButton {
}
}
}
// First, draw the button normally using the superclass method.
super.drawButton(mc, mouseX, mouseY);
// Wide buttons (>396px) break the vanilla 200px button texture.
// Draw them with a three-patch approach instead.
if (this.width > 396) {
drawWideButton(mc, mouseX, mouseY);
} else {
super.drawButton(mc, mouseX, mouseY);
}
// Restore original display string
this.displayString = original;
// Then, if an icon texture is set, draw it.
@@ -175,17 +181,58 @@ public class GuiNpcButton extends GuiButton {
mc.getTextureManager().bindTexture(iconTexture);
GL11.glPushMatrix();
RenderHelper.enableGUIStandardItemLighting();
// Calculate the icon position so that it's centered in the button.
// (Assumes the button's (xPosition,yPosition) is its top left.)
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, iconPosX, iconPosY, iconWidth, iconHeight);
RenderHelper.disableStandardItemLighting();
GL11.glPopMatrix();
}
}
/**
* Draws a button wider than the vanilla 200px texture allows.
* Uses three-patch rendering: left cap, tiled center, right cap.
*/
private void drawWideButton(Minecraft mc, int mouseX, int mouseY) {
FontRenderer fontrenderer = mc.fontRenderer;
mc.getTextureManager().bindTexture(buttonTextures);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition
&& mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
int k = this.getHoverState(this.field_146123_n);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
int texY = 46 + k * 20;
int cap = 100;
// Left cap (first 100px of texture)
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, texY, cap, this.height);
// Right cap (last 100px of texture)
this.drawTexturedModalRect(this.xPosition + this.width - cap, this.yPosition, 200 - cap, texY, cap, this.height);
// Tile the center column to fill the gap
int gapStart = this.xPosition + cap;
int gapEnd = this.xPosition + this.width - cap;
for (int x = gapStart; x < gapEnd; x += 2) {
int drawW = Math.min(2, gapEnd - x);
this.drawTexturedModalRect(x, this.yPosition, 99, texY, drawW, this.height);
}
this.mouseDragged(mc, mouseX, mouseY);
int l = 14737632;
if (packedFGColour != 0) {
l = packedFGColour;
} else if (!this.enabled) {
l = 10526880;
} else if (this.field_146123_n) {
l = 16777120;
}
this.drawCenteredString(fontrenderer, this.displayString,
this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l);
}
public void drawHover(int i, int j, boolean hasSubGui) {
if (hasSubGui || !visible || hoverableText.isEmpty())
return;