mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-28 00:55:38 +00:00
Merge branch 'dev' into syntax-highlighter-unified
This commit is contained in:
commit
df6beb4f15
207 files changed
+10330
-2705
No files matched your search
@@ -2,8 +2,11 @@ package noppes.npcs.client.gui.util;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.AbilityController;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.AbilityPhase;
|
||||
import kamkeel.npcs.controllers.data.ability.ChainedAbility;
|
||||
import kamkeel.npcs.controllers.data.ability.ChainedAbilityEntry;
|
||||
import kamkeel.npcs.controllers.data.ability.PreviewEntityHandler;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -19,10 +22,10 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Client-side executor for previewing abilities in the GUI.
|
||||
*
|
||||
* <p>
|
||||
* Uses unified execution: calls the REAL ability methods (onWindUpTick, onExecute, onActiveTick)
|
||||
* with previewMode=true. Abilities skip damage/effects/sounds when isPreview() returns true.
|
||||
*
|
||||
* <p>
|
||||
* Lifecycle:
|
||||
* 1. WINDUP phase - real onWindUpTick() called, telegraph shown, entities may spawn
|
||||
* 2. ACTIVE phase - real onExecute() then onActiveTick() called, physics simulated
|
||||
@@ -36,8 +39,11 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
|
||||
private Ability previewAbility;
|
||||
private EntityNPCInterface previewNpc;
|
||||
|
||||
/** Executor's own phase tracking (separate from ability.getPhase()) */
|
||||
private enum ExecutorPhase { IDLE, WINDUP, ACTIVE, EXTENDED }
|
||||
/**
|
||||
* Executor's own phase tracking (separate from ability.getPhase())
|
||||
*/
|
||||
private enum ExecutorPhase {IDLE, WINDUP, ACTIVE, EXTENDED, CHAIN_DELAY}
|
||||
|
||||
private ExecutorPhase executorPhase = ExecutorPhase.IDLE;
|
||||
|
||||
private int currentTick = 0;
|
||||
@@ -59,6 +65,14 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
|
||||
private TelegraphInstance previewTelegraph;
|
||||
private List<Entity> previewEntities = new ArrayList<>();
|
||||
|
||||
// ==================== CHAIN PREVIEW ====================
|
||||
private ChainedAbility previewChain;
|
||||
private List<Ability> chainAbilities;
|
||||
private List<Integer> chainDelays;
|
||||
private int chainIndex = -1;
|
||||
private int chainDelayRemaining = 0;
|
||||
private boolean chainWindUpAll = true;
|
||||
|
||||
// ==================== CALLBACKS ====================
|
||||
private GuiAbilityInterface parentGui;
|
||||
|
||||
@@ -70,28 +84,21 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Start previewing an ability using unified execution.
|
||||
* Start previewing a single ability using unified execution.
|
||||
* Sets previewMode=true on the ability, then calls its real methods.
|
||||
*/
|
||||
public void startPreview(Ability ability, EntityNPCInterface npc) {
|
||||
stop();
|
||||
|
||||
this.previewAbility = ability;
|
||||
this.previewNpc = npc;
|
||||
this.currentTick = 0;
|
||||
this.playing = true;
|
||||
this.paused = false;
|
||||
this.maxPreviewDuration = ability.getMaxPreviewDuration();
|
||||
|
||||
// Save NPC start position for restoring later
|
||||
this.npcStartX = npc.posX;
|
||||
this.npcStartY = npc.posY;
|
||||
this.npcStartZ = npc.posZ;
|
||||
|
||||
// Enable preview mode on the ability
|
||||
ability.setPreviewMode(true);
|
||||
ability.setPreviewEntityHandler(this);
|
||||
|
||||
// Create invisible fake target NPC for targeting
|
||||
createFakeTarget(npc);
|
||||
|
||||
@@ -100,10 +107,86 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
|
||||
parentGui.startTrackingMovement();
|
||||
}
|
||||
|
||||
beginAbilityPreview(ability);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start previewing a chained ability — plays all entries in sequence with delays.
|
||||
* Each entry is resolved and deep-copied to avoid modifying originals.
|
||||
*/
|
||||
public void startChainPreview(ChainedAbility chain, EntityNPCInterface npc) {
|
||||
stop();
|
||||
|
||||
this.previewNpc = npc;
|
||||
this.playing = true;
|
||||
this.paused = false;
|
||||
this.previewChain = chain;
|
||||
this.chainWindUpAll = chain.isWindUpAll();
|
||||
|
||||
// Save NPC start position for restoring later
|
||||
this.npcStartX = npc.posX;
|
||||
this.npcStartY = npc.posY;
|
||||
this.npcStartZ = npc.posZ;
|
||||
|
||||
// Resolve all entries to deep-copied abilities
|
||||
chainAbilities = new ArrayList<>();
|
||||
chainDelays = new ArrayList<>();
|
||||
for (ChainedAbilityEntry entry : chain.getEntries()) {
|
||||
Ability resolved = entry.resolve();
|
||||
if (resolved != null && AbilityController.Instance != null) {
|
||||
Ability copy = AbilityController.Instance.fromNBT(resolved.writeNBT());
|
||||
if (copy != null) {
|
||||
chainAbilities.add(copy);
|
||||
chainDelays.add(entry.getDelayTicks());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (chainAbilities.isEmpty()) {
|
||||
playing = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Create invisible fake target NPC for targeting
|
||||
createFakeTarget(npc);
|
||||
|
||||
// Start tracking NPC movement
|
||||
if (parentGui != null) {
|
||||
parentGui.startTrackingMovement();
|
||||
}
|
||||
|
||||
chainIndex = 0;
|
||||
beginAbilityPreview(chainAbilities.get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin previewing a single ability (shared by single and chain preview).
|
||||
* Cleans up the previous ability if any (for chain advancement).
|
||||
*/
|
||||
private void beginAbilityPreview(Ability ability) {
|
||||
// Clean up previous ability if any (for chain advancement)
|
||||
if (previewAbility != null) {
|
||||
previewAbility.cleanup();
|
||||
previewAbility.setPreviewMode(false);
|
||||
previewAbility.setPreviewEntityHandler(null);
|
||||
previewAbility.reset();
|
||||
}
|
||||
|
||||
this.previewAbility = ability;
|
||||
this.currentTick = 0;
|
||||
this.maxPreviewDuration = ability.getMaxPreviewDuration();
|
||||
|
||||
// Enable preview mode on the ability
|
||||
ability.setPreviewMode(true);
|
||||
ability.setPreviewEntityHandler(this);
|
||||
|
||||
// Use the ability's real start() method with the fake target
|
||||
ability.start(fakeTarget);
|
||||
|
||||
if (ability.getWindUpTicks() <= 0) {
|
||||
// Skip windup for non-first chain entries when windUpAll is false
|
||||
boolean skipWindup = previewChain != null && !chainWindUpAll && chainIndex > 0;
|
||||
|
||||
if (ability.getWindUpTicks() <= 0 || skipWindup) {
|
||||
// No windup — go straight to active
|
||||
this.executorPhase = ExecutorPhase.ACTIVE;
|
||||
transitionToActive();
|
||||
@@ -112,12 +195,12 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
|
||||
this.executorPhase = ExecutorPhase.WINDUP;
|
||||
|
||||
// Create telegraph for preview
|
||||
previewTelegraph = ability.createTelegraph(npc, fakeTarget);
|
||||
previewTelegraph = ability.createTelegraph(previewNpc, fakeTarget);
|
||||
|
||||
// Start windup animation
|
||||
Animation windUpAnim = ability.getWindUpAnimation();
|
||||
if (windUpAnim != null) {
|
||||
AnimationData data = npc.display.animationData;
|
||||
AnimationData data = previewNpc.display.animationData;
|
||||
data.setEnabled(true);
|
||||
data.setAnimation(windUpAnim);
|
||||
data.animation.paused = false;
|
||||
@@ -213,6 +296,13 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
|
||||
executorPhase = ExecutorPhase.IDLE;
|
||||
currentTick = 0;
|
||||
|
||||
// Clear chain state
|
||||
previewChain = null;
|
||||
chainAbilities = null;
|
||||
chainDelays = null;
|
||||
chainIndex = -1;
|
||||
chainDelayRemaining = 0;
|
||||
|
||||
previewTelegraph = null;
|
||||
|
||||
if (parentGui != null) {
|
||||
@@ -283,6 +373,9 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
|
||||
case EXTENDED:
|
||||
tickExtended();
|
||||
break;
|
||||
case CHAIN_DELAY:
|
||||
tickChainDelay();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -306,13 +399,21 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
|
||||
|
||||
// Check if the ability signaled completion (phase went to IDLE)
|
||||
if (previewAbility.getPhase() == AbilityPhase.IDLE) {
|
||||
transitionToExtended();
|
||||
if (hasNextChainEntry()) {
|
||||
transitionToChainDelay();
|
||||
} else {
|
||||
transitionToExtended();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Safety timeout
|
||||
if (currentTick >= maxPreviewDuration) {
|
||||
transitionToExtended();
|
||||
if (hasNextChainEntry()) {
|
||||
transitionToChainDelay();
|
||||
} else {
|
||||
transitionToExtended();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,6 +424,44 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== CHAIN ADVANCEMENT ====================
|
||||
|
||||
private boolean hasNextChainEntry() {
|
||||
return previewChain != null && chainAbilities != null && chainIndex < chainAbilities.size() - 1;
|
||||
}
|
||||
|
||||
private void transitionToChainDelay() {
|
||||
executorPhase = ExecutorPhase.CHAIN_DELAY;
|
||||
currentTick = 0;
|
||||
|
||||
// Use the NEXT entry's delay
|
||||
int nextIndex = chainIndex + 1;
|
||||
chainDelayRemaining = (nextIndex < chainDelays.size()) ? chainDelays.get(nextIndex) : 0;
|
||||
|
||||
// Clear current animation
|
||||
if (previewNpc != null) {
|
||||
AnimationData data = previewNpc.display.animationData;
|
||||
data.setAnimation(new Animation());
|
||||
}
|
||||
}
|
||||
|
||||
private void tickChainDelay() {
|
||||
if (chainDelayRemaining > 0) {
|
||||
chainDelayRemaining--;
|
||||
return;
|
||||
}
|
||||
advanceChainEntry();
|
||||
}
|
||||
|
||||
private void advanceChainEntry() {
|
||||
chainIndex++;
|
||||
if (chainIndex >= chainAbilities.size()) {
|
||||
transitionToExtended();
|
||||
return;
|
||||
}
|
||||
beginAbilityPreview(chainAbilities.get(chainIndex));
|
||||
}
|
||||
|
||||
private void transitionToActive() {
|
||||
executorPhase = ExecutorPhase.ACTIVE;
|
||||
currentTick = 0;
|
||||
@@ -424,33 +563,73 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
|
||||
|
||||
// ==================== GETTERS ====================
|
||||
|
||||
public boolean isPlaying() { return playing; }
|
||||
public boolean isPaused() { return paused; }
|
||||
public boolean isActive() { return playing || paused; }
|
||||
public boolean isPlaying() {
|
||||
return playing;
|
||||
}
|
||||
|
||||
public boolean isPaused() {
|
||||
return paused;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return playing || paused;
|
||||
}
|
||||
|
||||
public boolean isChainPreview() {
|
||||
return previewChain != null;
|
||||
}
|
||||
|
||||
public AbilityPhase getPhase() {
|
||||
switch (executorPhase) {
|
||||
case WINDUP: return AbilityPhase.WINDUP;
|
||||
case ACTIVE: return AbilityPhase.ACTIVE;
|
||||
default: return AbilityPhase.IDLE;
|
||||
case WINDUP:
|
||||
return AbilityPhase.WINDUP;
|
||||
case ACTIVE:
|
||||
return AbilityPhase.ACTIVE;
|
||||
default:
|
||||
return AbilityPhase.IDLE;
|
||||
}
|
||||
}
|
||||
public int getCurrentTick() { return currentTick; }
|
||||
public TelegraphInstance getTelegraph() { return previewTelegraph; }
|
||||
public List<Entity> getPreviewEntities() { return previewEntities; }
|
||||
public Ability getPreviewAbility() { return previewAbility; }
|
||||
public EntityNPCInterface getPreviewNpc() { return previewNpc; }
|
||||
|
||||
public int getCurrentTick() {
|
||||
return currentTick;
|
||||
}
|
||||
|
||||
public TelegraphInstance getTelegraph() {
|
||||
return previewTelegraph;
|
||||
}
|
||||
|
||||
public List<Entity> getPreviewEntities() {
|
||||
return previewEntities;
|
||||
}
|
||||
|
||||
public Ability getPreviewAbility() {
|
||||
return previewAbility;
|
||||
}
|
||||
|
||||
public EntityNPCInterface getPreviewNpc() {
|
||||
return previewNpc;
|
||||
}
|
||||
|
||||
public String getStatusString() {
|
||||
if (!playing && !paused) {
|
||||
return "Stopped";
|
||||
} else if (paused) {
|
||||
return "Paused";
|
||||
}
|
||||
|
||||
String chainPrefix = "";
|
||||
if (previewChain != null && chainAbilities != null) {
|
||||
chainPrefix = "Chain " + (chainIndex + 1) + "/" + chainAbilities.size() + " - ";
|
||||
}
|
||||
|
||||
if (paused) {
|
||||
return chainPrefix + "Paused";
|
||||
} else if (executorPhase == ExecutorPhase.WINDUP) {
|
||||
return "Windup: " + currentTick + "/" + (previewAbility != null ? previewAbility.getWindUpTicks() : 0);
|
||||
return chainPrefix + "Windup: " + currentTick + "/" + (previewAbility != null ? previewAbility.getWindUpTicks() : 0);
|
||||
} else if (executorPhase == ExecutorPhase.ACTIVE) {
|
||||
return "Active: " + currentTick + "/" + maxPreviewDuration;
|
||||
return chainPrefix + "Active: " + currentTick + "/" + maxPreviewDuration;
|
||||
} else if (executorPhase == ExecutorPhase.EXTENDED) {
|
||||
return "Extended: " + currentTick + "/" + EXTENDED_DURATION;
|
||||
return chainPrefix + "Extended: " + currentTick + "/" + EXTENDED_DURATION;
|
||||
} else if (executorPhase == ExecutorPhase.CHAIN_DELAY) {
|
||||
return chainPrefix + "Delay: " + chainDelayRemaining;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Base GUI class for ability preview with fixed camera.
|
||||
*
|
||||
* <p>
|
||||
* Key concepts:
|
||||
* - NPC positioned on left side of preview area
|
||||
* - NPC faces a fixed direction (NPC_FACING_YAW)
|
||||
@@ -33,15 +33,23 @@ import java.util.List;
|
||||
public class GuiAbilityInterface extends GuiNPCInterface2 {
|
||||
|
||||
// ==================== FIXED CAMERA SETTINGS ====================
|
||||
/** Fixed camera zoom level (higher = more zoomed in) */
|
||||
/**
|
||||
* Fixed camera zoom level (higher = more zoomed in)
|
||||
*/
|
||||
protected static float CAMERA_ZOOM = 45.0f;
|
||||
/** NPC facing direction - affects anchor points and visual facing */
|
||||
/**
|
||||
* NPC facing direction - affects anchor points and visual facing
|
||||
*/
|
||||
protected static float NPC_FACING_YAW = 160.0f;
|
||||
/** Camera pitch (slight downward angle) */
|
||||
/**
|
||||
* Camera pitch (slight downward angle)
|
||||
*/
|
||||
protected static float CAMERA_PITCH = 10.0f;
|
||||
|
||||
// ==================== VIEWING ROTATION ====================
|
||||
/** Viewing direction rotation (rotates entire 3D space) */
|
||||
/**
|
||||
* Viewing direction rotation (rotates entire 3D space)
|
||||
*/
|
||||
protected static float viewRotation = 0.0f;
|
||||
|
||||
private GuiNpcButton btnLeft, btnRight;
|
||||
@@ -49,21 +57,33 @@ public class GuiAbilityInterface extends GuiNPCInterface2 {
|
||||
// ==================== NPC STATE ====================
|
||||
public EntityNPCInterface npc;
|
||||
|
||||
/** NPC starting position (saved when preview starts, used to track movement) */
|
||||
/**
|
||||
* NPC starting position (saved when preview starts, used to track movement)
|
||||
*/
|
||||
protected double npcStartX, npcStartY, npcStartZ;
|
||||
/** Whether we're tracking NPC movement */
|
||||
/**
|
||||
* Whether we're tracking NPC movement
|
||||
*/
|
||||
protected boolean trackingNpcMovement = false;
|
||||
|
||||
/** Entities to render in preview space */
|
||||
/**
|
||||
* Entities to render in preview space
|
||||
*/
|
||||
protected List<Entity> previewEntities = new ArrayList<>();
|
||||
|
||||
/** Current telegraph to render in preview */
|
||||
/**
|
||||
* Current telegraph to render in preview
|
||||
*/
|
||||
protected TelegraphInstance previewTelegraph;
|
||||
|
||||
// ==================== LAYOUT ====================
|
||||
/** Preview area bounds */
|
||||
/**
|
||||
* Preview area bounds
|
||||
*/
|
||||
protected int previewX, previewY, previewWidth, previewHeight;
|
||||
/** NPC render position on screen */
|
||||
/**
|
||||
* NPC render position on screen
|
||||
*/
|
||||
protected int npcScreenX, npcScreenY;
|
||||
|
||||
public int xOffset = 0;
|
||||
@@ -74,7 +94,7 @@ public class GuiAbilityInterface extends GuiNPCInterface2 {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param npc The NPC for preview rendering
|
||||
* @param npc The NPC for preview rendering
|
||||
* @param hasMenuNpc If false, the top menu tabs (Display, Stats, etc.) are hidden.
|
||||
* Use false when opened from the global menu without a real NPC.
|
||||
*/
|
||||
@@ -99,8 +119,8 @@ public class GuiAbilityInterface extends GuiNPCInterface2 {
|
||||
previewHeight = 180;
|
||||
|
||||
// NPC position: left side of preview, slightly below center
|
||||
npcScreenX = previewX + (int)(previewWidth * 0.33f) + xOffset;
|
||||
npcScreenY = previewY + (int)(previewHeight * 0.85f) + yOffset;
|
||||
npcScreenX = previewX + (int) (previewWidth * 0.33f) + xOffset;
|
||||
npcScreenY = previewY + (int) (previewHeight * 0.85f) + yOffset;
|
||||
|
||||
// Viewing rotation buttons (below preview area)
|
||||
int btnY = guiTop + 192;
|
||||
@@ -351,7 +371,7 @@ public class GuiAbilityInterface extends GuiNPCInterface2 {
|
||||
super.drawBackground();
|
||||
|
||||
drawGradientRect(previewX, previewY, previewX + previewWidth, previewY + previewHeight,
|
||||
0xc0101010, 0xd0101010);
|
||||
0xc0101010, 0xd0101010);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@@ -364,8 +384,9 @@ public class GuiAbilityInterface extends GuiNPCInterface2 {
|
||||
|
||||
@Override
|
||||
public void keyTyped(char par1, int par2) {
|
||||
boolean hadSubGui = hasSubGui();
|
||||
super.keyTyped(par1, par2);
|
||||
if (par2 == 1) {
|
||||
if (par2 == 1 && !hadSubGui) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,14 +64,14 @@ public class GuiAuctionNavButton extends GuiNpcButton {
|
||||
/**
|
||||
* Create a fully customizable button.
|
||||
*
|
||||
* @param id Button ID
|
||||
* @param x X position
|
||||
* @param y Y position
|
||||
* @param buttonSize Size of the button background texture (e.g., 18 for 18x18, 10 for 10x10)
|
||||
* @param iconSize Size of the icon texture (e.g., 16 for 16x16, 8 for 8x8)
|
||||
* @param tooltipKey Lang key for tooltip
|
||||
* @param iconTexture Icon texture to draw inside the button
|
||||
* @param textureNormal Background texture for normal state
|
||||
* @param id Button ID
|
||||
* @param x X position
|
||||
* @param y Y position
|
||||
* @param buttonSize Size of the button background texture (e.g., 18 for 18x18, 10 for 10x10)
|
||||
* @param iconSize Size of the icon texture (e.g., 16 for 16x16, 8 for 8x8)
|
||||
* @param tooltipKey Lang key for tooltip
|
||||
* @param iconTexture Icon texture to draw inside the button
|
||||
* @param textureNormal Background texture for normal state
|
||||
* @param texturePressed Background texture for pressed/hover state
|
||||
*/
|
||||
public GuiAuctionNavButton(int id, int x, int y, int buttonSize, int iconSize, String tooltipKey,
|
||||
|
||||
@@ -4,29 +4,29 @@ package noppes.npcs.client.gui.util;
|
||||
* Abstract base class for fullscreen directory-browsing GUIs.
|
||||
* Provides a configurable three-panel layout (left nav, center content, right actions)
|
||||
* with percentage-based sizing, panel backgrounds/borders, and an optional resizable divider.
|
||||
*
|
||||
* <p>
|
||||
* Subclasses override abstract hooks to populate each panel region.
|
||||
* Designed for reuse across Cloner, Quest Manager, Dialog Manager, etc.
|
||||
*/
|
||||
public abstract class GuiDirectory extends GuiNPCInterface implements ICustomScrollListener, ISubGuiListener {
|
||||
|
||||
// ===== LAYOUT CONFIG (subclasses may override in constructor) =====
|
||||
protected float leftPanelPercent = 0.20f;
|
||||
protected float leftPanelPercent = 0.20f;
|
||||
protected float rightPanelPercent = 0.10f;
|
||||
protected int minLeftPanelW = 80;
|
||||
protected int minLeftPanelW = 80;
|
||||
protected int minRightPanelW = 40;
|
||||
protected int minCenterW = 100;
|
||||
protected int minCenterW = 100;
|
||||
|
||||
// ===== LAYOUT CONSTANTS =====
|
||||
protected int pad = 10;
|
||||
protected int pad = 10;
|
||||
protected int topBarH = 24;
|
||||
protected int gap = 4;
|
||||
protected int btnH = 20;
|
||||
protected int gap = 4;
|
||||
protected int btnH = 20;
|
||||
|
||||
// ===== PANEL COLORS =====
|
||||
protected int panelBg = 0xC0101010;
|
||||
protected int panelBg = 0xC0101010;
|
||||
protected int panelBorder = 0xFF333333;
|
||||
protected int topBarBg = 0xC0181818;
|
||||
protected int topBarBg = 0xC0181818;
|
||||
|
||||
// ===== COMPUTED LAYOUT (populated by computeLayout) =====
|
||||
protected int originX, originY, usableW, usableH;
|
||||
@@ -35,10 +35,10 @@ public abstract class GuiDirectory extends GuiNPCInterface implements ICustomScr
|
||||
protected int rightX;
|
||||
|
||||
// ===== OPTIONAL RESIZABLE DIVIDER (between left and center) =====
|
||||
protected boolean enableDivider = false;
|
||||
protected int dividerWidth = 5;
|
||||
protected int dividerLineHeight = 20;
|
||||
protected int minDividerPanelW = 50;
|
||||
protected boolean enableDivider = false;
|
||||
protected int dividerWidth = 5;
|
||||
protected int dividerLineHeight = 20;
|
||||
protected int minDividerPanelW = 50;
|
||||
private int dividerOffset;
|
||||
private boolean isDragging = false;
|
||||
private int dragStartX;
|
||||
@@ -57,8 +57,8 @@ public abstract class GuiDirectory extends GuiNPCInterface implements ICustomScr
|
||||
usableW = width - 2 * pad;
|
||||
usableH = height - 2 * pad;
|
||||
|
||||
leftPanelW = Math.max(minLeftPanelW, (int)(usableW * leftPanelPercent));
|
||||
rightPanelW = Math.max(minRightPanelW, (int)(usableW * rightPanelPercent));
|
||||
leftPanelW = Math.max(minLeftPanelW, (int) (usableW * leftPanelPercent));
|
||||
rightPanelW = Math.max(minRightPanelW, (int) (usableW * rightPanelPercent));
|
||||
|
||||
if (rightPanelPercent <= 0) {
|
||||
rightPanelW = 0;
|
||||
@@ -73,7 +73,7 @@ public abstract class GuiDirectory extends GuiNPCInterface implements ICustomScr
|
||||
contentX = originX + leftPanelW + gap;
|
||||
contentY = originY + topBarH + gap;
|
||||
contentH = usableH - topBarH - gap;
|
||||
rightX = contentX + contentW + gap;
|
||||
rightX = contentX + contentW + gap;
|
||||
|
||||
if (enableDivider && dividerOffset == 0) {
|
||||
dividerOffset = leftPanelW;
|
||||
@@ -128,7 +128,9 @@ public abstract class GuiDirectory extends GuiNPCInterface implements ICustomScr
|
||||
drawRect(divX + 1, handleTop, divX + dividerWidth - 1, handleTop + dividerLineHeight, 0xFF707070);
|
||||
}
|
||||
|
||||
/** Override for extra drawing after super.drawScreen (e.g. status text) */
|
||||
/**
|
||||
* Override for extra drawing after super.drawScreen (e.g. status text)
|
||||
*/
|
||||
protected void drawOverlay(int mouseX, int mouseY, float partialTicks) {
|
||||
}
|
||||
|
||||
@@ -177,7 +179,9 @@ public abstract class GuiDirectory extends GuiNPCInterface implements ICustomScr
|
||||
super.mouseMovedOrUp(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
/** Called when divider is dragged. Override to update scroll sizes. */
|
||||
/**
|
||||
* Called when divider is dragged. Override to update scroll sizes.
|
||||
*/
|
||||
protected void onDividerMoved(int newOffset) {
|
||||
}
|
||||
|
||||
@@ -192,15 +196,23 @@ public abstract class GuiDirectory extends GuiNPCInterface implements ICustomScr
|
||||
|
||||
// ===== ABSTRACT HOOKS (subclass must implement) =====
|
||||
|
||||
/** Populate top bar buttons. topBtnY is the y-coordinate for the button row. */
|
||||
/**
|
||||
* Populate top bar buttons. topBtnY is the y-coordinate for the button row.
|
||||
*/
|
||||
protected abstract void initTopBar(int topBtnY);
|
||||
|
||||
/** Populate the left navigation panel (scrolls, search fields, buttons). */
|
||||
/**
|
||||
* Populate the left navigation panel (scrolls, search fields, buttons).
|
||||
*/
|
||||
protected abstract void initLeftPanel();
|
||||
|
||||
/** Populate the center content panel (main scroll list). */
|
||||
/**
|
||||
* Populate the center content panel (main scroll list).
|
||||
*/
|
||||
protected abstract void initCenterPanel();
|
||||
|
||||
/** Populate the right action panel. startY is the first button y-coordinate. */
|
||||
/**
|
||||
* Populate the right action panel. startY is the first button y-coordinate.
|
||||
*/
|
||||
protected abstract void initRightPanel(int startY);
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class GuiModelInterface2 extends GuiNPCInterface2 {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param npc The NPC for preview rendering
|
||||
* @param npc The NPC for preview rendering
|
||||
* @param hasMenuNpc If false, the top menu tabs (Display, Stats, etc.) are hidden.
|
||||
* Use false when opened from the global menu without a real NPC.
|
||||
*/
|
||||
@@ -151,8 +151,9 @@ public class GuiModelInterface2 extends GuiNPCInterface2 {
|
||||
|
||||
@Override
|
||||
public void keyTyped(char par1, int par2) {
|
||||
boolean hadSubGui = hasSubGui();
|
||||
super.keyTyped(par1, par2);
|
||||
if (par2 == 1) {
|
||||
if (par2 == 1 && !hadSubGui) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,12 +60,13 @@ public class GuiNpcLabel extends Gui {
|
||||
|
||||
/**
|
||||
* Draws hover tooltip if the mouse is over this label.
|
||||
* @param localMouseX Mouse X in scroll-local coordinates (for hit testing)
|
||||
* @param localMouseY Mouse Y in scroll-local coordinates (for hit testing)
|
||||
*
|
||||
* @param localMouseX Mouse X in scroll-local coordinates (for hit testing)
|
||||
* @param localMouseY Mouse Y in scroll-local coordinates (for hit testing)
|
||||
* @param screenMouseX Mouse X in screen coordinates (for tooltip positioning)
|
||||
* @param screenMouseY Mouse Y in screen coordinates (for tooltip positioning)
|
||||
* @param hasSubGui Whether a sub-gui is open
|
||||
* @param fr FontRenderer for measuring label width
|
||||
* @param hasSubGui Whether a sub-gui is open
|
||||
* @param fr FontRenderer for measuring label width
|
||||
*/
|
||||
public void drawHover(int localMouseX, int localMouseY, int screenMouseX, int screenMouseY, boolean hasSubGui, FontRenderer fr) {
|
||||
if (hasSubGui || hoverableText.isEmpty()) return;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package noppes.npcs.client.gui.util;
|
||||
|
||||
import kamkeel.npcs.util.TextSplitter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import kamkeel.npcs.util.TextSplitter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class GuiNpcTextField extends GuiTextField {
|
||||
public boolean enabled = true;
|
||||
@@ -224,7 +224,7 @@ public class GuiNpcTextField extends GuiTextField {
|
||||
|
||||
public boolean isMouseOver(int mouseX, int mouseY) {
|
||||
return mouseX >= xPosition && mouseX < xPosition + width &&
|
||||
mouseY >= yPosition && mouseY < yPosition + height;
|
||||
mouseY >= yPosition && mouseY < yPosition + height;
|
||||
}
|
||||
|
||||
public void drawHover(int mouseX, int mouseY, boolean hasSubGui) {
|
||||
@@ -334,14 +334,14 @@ public class GuiNpcTextField extends GuiTextField {
|
||||
}
|
||||
|
||||
protected void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor, int zLevel) {
|
||||
float f = (float)(startColor >> 24 & 255) / 255.0F;
|
||||
float f1 = (float)(startColor >> 16 & 255) / 255.0F;
|
||||
float f2 = (float)(startColor >> 8 & 255) / 255.0F;
|
||||
float f3 = (float)(startColor & 255) / 255.0F;
|
||||
float f4 = (float)(endColor >> 24 & 255) / 255.0F;
|
||||
float f5 = (float)(endColor >> 16 & 255) / 255.0F;
|
||||
float f6 = (float)(endColor >> 8 & 255) / 255.0F;
|
||||
float f7 = (float)(endColor & 255) / 255.0F;
|
||||
float f = (float) (startColor >> 24 & 255) / 255.0F;
|
||||
float f1 = (float) (startColor >> 16 & 255) / 255.0F;
|
||||
float f2 = (float) (startColor >> 8 & 255) / 255.0F;
|
||||
float f3 = (float) (startColor & 255) / 255.0F;
|
||||
float f4 = (float) (endColor >> 24 & 255) / 255.0F;
|
||||
float f5 = (float) (endColor >> 16 & 255) / 255.0F;
|
||||
float f6 = (float) (endColor >> 8 & 255) / 255.0F;
|
||||
float f7 = (float) (endColor & 255) / 255.0F;
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
@@ -350,11 +350,11 @@ public class GuiNpcTextField extends GuiTextField {
|
||||
net.minecraft.client.renderer.Tessellator tessellator = net.minecraft.client.renderer.Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(f1, f2, f3, f);
|
||||
tessellator.addVertex((double)right, (double)top, (double)zLevel);
|
||||
tessellator.addVertex((double)left, (double)top, (double)zLevel);
|
||||
tessellator.addVertex((double) right, (double) top, (double) zLevel);
|
||||
tessellator.addVertex((double) left, (double) top, (double) zLevel);
|
||||
tessellator.setColorRGBA_F(f5, f6, f7, f4);
|
||||
tessellator.addVertex((double)left, (double)bottom, (double)zLevel);
|
||||
tessellator.addVertex((double)right, (double)bottom, (double)zLevel);
|
||||
tessellator.addVertex((double) left, (double) bottom, (double) zLevel);
|
||||
tessellator.addVertex((double) right, (double) bottom, (double) zLevel);
|
||||
tessellator.draw();
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package noppes.npcs.client.gui.util;
|
||||
|
||||
import kamkeel.npcs.controllers.data.ability.ChainedAbility;
|
||||
|
||||
/**
|
||||
* Callback for when a chained ability is saved from the config SubGui.
|
||||
*/
|
||||
public interface IChainedAbilityConfigCallback {
|
||||
void onChainedAbilitySaved(ChainedAbility chain);
|
||||
}
|
||||
@@ -8,6 +8,8 @@ import java.util.UUID;
|
||||
|
||||
public interface IClonerGui {
|
||||
int getShowingClones();
|
||||
|
||||
HashMap<UUID, Tag> getTags();
|
||||
|
||||
TagMap getTagMap();
|
||||
}
|
||||
Reference in new issue
Block a user