mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-13 06:37:34 +00:00
Move Confirmation
This commit is contained in:
1 parent
07ebe90437
commit
248b56ec1f
5 files changed
+80
-7
No files matched your search
@@ -847,9 +847,11 @@ public class GuiAbilityDirectory extends GuiDirectoryCategorized
|
||||
GL11.glTranslatef(0.0F, entity.yOffset, 1F);
|
||||
RenderManager.instance.playerViewY = 180F;
|
||||
|
||||
ClientEventHandler.renderingEntityInGUI = true;
|
||||
try {
|
||||
RenderManager.instance.renderEntityWithPosYaw(entity, 0.0, 0.0, 0.0, 0.0F, 1.0F);
|
||||
} catch (Exception ignored) {}
|
||||
ClientEventHandler.renderingEntityInGUI = false;
|
||||
|
||||
entity.prevRenderYawOffset = entity.renderYawOffset = f2;
|
||||
entity.prevRotationYaw = entity.rotationYaw = f3;
|
||||
|
||||
@@ -35,6 +35,7 @@ import noppes.npcs.controllers.data.AnimationData;
|
||||
import noppes.npcs.controllers.data.Category;
|
||||
import noppes.npcs.controllers.data.Frame;
|
||||
import noppes.npcs.controllers.data.FramePart;
|
||||
import noppes.npcs.client.ClientEventHandler;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -478,10 +479,12 @@ public class GuiAnimationDirectory extends GuiDirectoryCategorized {
|
||||
GL11.glTranslatef(0.0F, entity.yOffset, 1F);
|
||||
RenderManager.instance.playerViewY = 180F;
|
||||
|
||||
ClientEventHandler.renderingEntityInGUI = true;
|
||||
try {
|
||||
RenderManager.instance.renderEntityWithPosYaw(entity, 0.0, 0.0, 0.0, 0.0F, 1.0F);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
ClientEventHandler.renderingEntityInGUI = false;
|
||||
|
||||
entity.prevRenderYawOffset = entity.renderYawOffset = f2;
|
||||
entity.prevRotationYaw = entity.rotationYaw = f3;
|
||||
@@ -493,6 +496,8 @@ public class GuiAnimationDirectory 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();
|
||||
}
|
||||
|
||||
@@ -63,6 +63,10 @@ public abstract class GuiDirectoryCategorized extends GuiDirectory
|
||||
// ========== New Item Category ==========
|
||||
protected int pendingNewItemCatId = -1;
|
||||
|
||||
// ========== Pending Move Destination ==========
|
||||
private int pendingMoveDestCatId = -1;
|
||||
private String pendingMoveDestName = "";
|
||||
|
||||
// ========== Category Data Loaded ==========
|
||||
private boolean itemDataLoaded = false;
|
||||
|
||||
@@ -231,16 +235,16 @@ 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)
|
||||
// Phase 1: categories locked (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
|
||||
// Phase 2: color nav items orange (selectable) or red (current/source category)
|
||||
if (movePhase == 2) {
|
||||
catScroll.setSelectable(true);
|
||||
for (String name : navNames) {
|
||||
catScroll.colors.put(name, name.equals(prevCatName) ? 0xFF5555 : 0xFFAA00);
|
||||
}
|
||||
}
|
||||
|
||||
addScroll(catScroll);
|
||||
@@ -606,12 +610,14 @@ public abstract class GuiDirectoryCategorized extends GuiDirectory
|
||||
String selected = catScroll.getSelected();
|
||||
if (selected == null) return;
|
||||
|
||||
// Move phase 2: destination selected
|
||||
// Move phase 2: destination selected — show confirmation
|
||||
if (movePhase == 2) {
|
||||
if (!selected.equals(prevCatName)) {
|
||||
Integer destCatId = catData.get(selected);
|
||||
if (destCatId != null) {
|
||||
executeMoveItems(destCatId);
|
||||
pendingMoveDestCatId = destCatId;
|
||||
pendingMoveDestName = selected;
|
||||
setSubGui(new SubGuiCategoryMoveConfirm(moveSelection.size(), selected));
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -772,6 +778,16 @@ public abstract class GuiDirectoryCategorized extends GuiDirectory
|
||||
}
|
||||
}
|
||||
}
|
||||
if (subgui instanceof SubGuiCategoryMoveConfirm) {
|
||||
SubGuiCategoryMoveConfirm confirm = (SubGuiCategoryMoveConfirm) subgui;
|
||||
if (confirm.confirmed && !moveSelection.isEmpty() && pendingMoveDestCatId >= 0) {
|
||||
executeMoveItems(pendingMoveDestCatId);
|
||||
} else {
|
||||
// Cancelled — stay in phase 2
|
||||
}
|
||||
pendingMoveDestCatId = -1;
|
||||
pendingMoveDestName = "";
|
||||
}
|
||||
onSubGuiClosed(subgui);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package noppes.npcs.client.gui.util;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class SubGuiCategoryMoveConfirm extends SubGuiInterface {
|
||||
public boolean confirmed = false;
|
||||
|
||||
private final int count;
|
||||
public final String destCategoryName;
|
||||
|
||||
public SubGuiCategoryMoveConfirm(int count, String destCategoryName) {
|
||||
this.count = count;
|
||||
this.destCategoryName = destCategoryName;
|
||||
xSize = 220;
|
||||
ySize = 90;
|
||||
closeOnEsc = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
String line1 = String.format(StatCollector.translateToLocal("gui.move.confirmLine"), count);
|
||||
addLabel(new GuiNpcLabel(0, line1, guiLeft + 10, guiTop + 10, 0xFFFFFF));
|
||||
|
||||
String dest = StatCollector.translateToLocal("gui.category") + ": \"" + destCategoryName + "\"";
|
||||
addLabel(new GuiNpcLabel(1, " " + dest, guiLeft + 10, guiTop + 25, 0xFFFFFF));
|
||||
|
||||
addButton(new GuiNpcButton(0, guiLeft + 10, guiTop + 55, 95, 20, "gui.yes"));
|
||||
addButton(new GuiNpcButton(1, guiLeft + 115, guiTop + 55, 95, 20, "gui.cancel"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
if (guibutton.id == 0) {
|
||||
confirmed = true;
|
||||
close();
|
||||
}
|
||||
if (guibutton.id == 1) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user