mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 18:57:32 +00:00
Fix some Toggle Logic
This commit is contained in:
1 parent
34b3d9365a
commit
0eeeec5d22
3 files changed
+25
-9
No files matched your search
@@ -56,6 +56,9 @@ public final class AbilityTogglePacket extends AbstractPacket {
|
||||
|
||||
int newState = playerData.abilityData.toggleAbility(key);
|
||||
|
||||
// Sync toggle states to client (toggle may have side effects like mutual exclusivity)
|
||||
playerData.abilityData.syncToClient();
|
||||
|
||||
String displayName = ability.getDisplayName();
|
||||
if (newState > 0) {
|
||||
String stateLabel = ability.getToggleStateLabel(newState);
|
||||
|
||||
@@ -111,6 +111,17 @@ public class AbilityHotbarSlotRenderer extends Gui {
|
||||
drawCircle(radius, fillR, fillG, fillB, alpha * 0.8f, true);
|
||||
}
|
||||
|
||||
// Toggle active indicator: subtle green outline
|
||||
int toggleState = getToggleState();
|
||||
if (toggleState > 0) {
|
||||
float glowAlpha = 0.45f * slotAlpha;
|
||||
if (altTexture) {
|
||||
drawRoundedRect(-radius, -radius, radius, radius, 0.2f, 0.85f, 0.3f, glowAlpha, true);
|
||||
} else {
|
||||
drawCircle(radius, 0.2f, 0.85f, 0.3f, glowAlpha, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Ability icon
|
||||
if (icon != null) {
|
||||
GL11.glPushMatrix();
|
||||
@@ -119,7 +130,7 @@ public class AbilityHotbarSlotRenderer extends Gui {
|
||||
if (iconNaturalSize <= 0) iconNaturalSize = 16f;
|
||||
float iconScale = targetSize / iconNaturalSize;
|
||||
GL11.glScalef(iconScale, iconScale, 1);
|
||||
icon.draw(getToggleState(), slotAlpha);
|
||||
icon.draw(toggleState, slotAlpha);
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -399,6 +399,14 @@ public class GuiAbilities extends GuiCNPCInventory implements ISubGuiListener {
|
||||
boolean isDragSource = isDragging && dragSourceSlot == -1 && draggedKey != null
|
||||
&& draggedKey.equals(filteredKeys.get(absIndex));
|
||||
|
||||
// Compute toggle state early so border can reflect it
|
||||
int cellToggleState = 0;
|
||||
Ability cellAbility = filteredAbilities.get(absIndex);
|
||||
PlayerData cellPlayerData = ClientCacheHandler.playerData;
|
||||
if (cellAbility != null && cellAbility.isToggleable() && cellPlayerData != null && cellPlayerData.abilityData != null) {
|
||||
cellToggleState = cellPlayerData.abilityData.getToggleState(filteredKeys.get(absIndex));
|
||||
}
|
||||
|
||||
// Cell background
|
||||
int bgColor;
|
||||
if (isDragSource) bgColor = 0x40333333;
|
||||
@@ -409,7 +417,8 @@ public class GuiAbilities extends GuiCNPCInventory implements ISubGuiListener {
|
||||
|
||||
// Cell border
|
||||
int borderColor;
|
||||
if (isSelected) borderColor = 0xAA9999DD;
|
||||
if (cellToggleState > 0) borderColor = 0x7733DD55;
|
||||
else if (isSelected) borderColor = 0xAA9999DD;
|
||||
else if (isHovered) borderColor = 0xAA8888CC;
|
||||
else borderColor = 0x40404060;
|
||||
drawHorizontalLine(cellX, cellX + gridCellSize - 2, cellY, borderColor);
|
||||
@@ -430,13 +439,6 @@ public class GuiAbilities extends GuiCNPCInventory implements ISubGuiListener {
|
||||
int iconCenterX = cellX + (gridCellSize - 1) / 2;
|
||||
int iconCenterY = cellY + (gridCellSize - 1) / 2;
|
||||
|
||||
int cellToggleState = 0;
|
||||
Ability cellAbility = filteredAbilities.get(absIndex);
|
||||
PlayerData cellPlayerData = ClientCacheHandler.playerData;
|
||||
if (cellAbility != null && cellAbility.isToggleable() && cellPlayerData != null && cellPlayerData.abilityData != null) {
|
||||
cellToggleState = cellPlayerData.abilityData.getToggleState(filteredKeys.get(absIndex));
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(iconCenterX, iconCenterY, 0);
|
||||
GL11.glScalef(iconScale, iconScale, 1);
|
||||
|
||||
Reference in new issue
Block a user