diff --git a/src/main/java/noppes/npcs/client/gui/hud/GuiHudEditor.java b/src/main/java/noppes/npcs/client/gui/hud/GuiHudEditor.java index d36727aad..5ffa2b50c 100644 --- a/src/main/java/noppes/npcs/client/gui/hud/GuiHudEditor.java +++ b/src/main/java/noppes/npcs/client/gui/hud/GuiHudEditor.java @@ -23,6 +23,7 @@ public class GuiHudEditor extends GuiScreen { private final int HANDLE_SIZE = 10; private final int RESET_POSITION_ID = 100; + private final int RESET_SIZE_ID = 104; // IDs for cycle buttons. private final int CYCLE_LEFT_ID = 101; @@ -90,9 +91,11 @@ public class GuiHudEditor extends GuiScreen { rowHeight += btn.height + spacingY; } } - // Always add the Reset Position button below the custom buttons. - GuiButton resetPos = new GuiButton(RESET_POSITION_ID, width / 2 - buttonWidth / 2, height - 70 - rowHeight, buttonWidth, 20, "Reset Position"); + // Always add the Reset Position and Reset Size buttons below the custom buttons. + GuiButton resetSize = new GuiButton(RESET_SIZE_ID, startXRight, height - 70 - rowHeight, buttonWidth, 20, "Reset Size"); + GuiButton resetPos = new GuiButton(RESET_POSITION_ID, startXLeft, height - 70 - rowHeight, buttonWidth, 20, "Reset Position"); buttonList.add(resetPos); + buttonList.add(resetSize); } // Now update (or add if missing) the cycle buttons at the very bottom. @@ -149,10 +152,11 @@ public class GuiHudEditor extends GuiScreen { int actualY = (int) (hud.posY / 100F * res.getScaledHeight()); int margin = 5; int barWidth = 6; // same as WIDTH_BAR_SIZE - int barX = actualX + (int) (hud.overlayWidth * effectiveScale) + margin; + int barX = actualX + (int) ((hud.overlayWidth + margin) * effectiveScale); int barY = actualY + (int) (((hud.overlayHeight - 20) / 2.0F) * effectiveScale); int barHeight = (int) (20 * effectiveScale); - if (mouseX >= barX && mouseX <= barX + barWidth && + int scaledBarWidth = Math.max(6, (int) (barWidth * effectiveScale)); + if (mouseX >= barX && mouseX <= barX + scaledBarWidth && mouseY >= barY && mouseY <= barY + barHeight) { resizingWidth = true; selectedComponent = hud; @@ -226,15 +230,22 @@ public class GuiHudEditor extends GuiScreen { } if (resizing) { int currentMouseX = Mouse.getX() * width / mc.displayWidth; - int deltaX = currentMouseX - initialMouseX; - selectedComponent.scale = initialScale + deltaX; + int currentMouseY = scaledHeight - (Mouse.getY() * scaledHeight / mc.displayHeight); + int actualX = (int) (selectedComponent.posX / 100F * scaledWidth); + int actualY = (int) (selectedComponent.posY / 100F * scaledHeight); + // Use diagonal distance ratio so the resize handle tracks the mouse + float initDist = (float) Math.sqrt((double)(initialMouseX - actualX) * (initialMouseX - actualX) + (double)(initialMouseY - actualY) * (initialMouseY - actualY)); + float currDist = (float) Math.sqrt((double)(currentMouseX - actualX) * (currentMouseX - actualX) + (double)(currentMouseY - actualY) * (currentMouseY - actualY)); + if (initDist > 1) { + selectedComponent.scale = (int) (initialScale * currDist / initDist); + } if (selectedComponent.scale < 50) selectedComponent.scale = 50; - if (selectedComponent.scale > 300) selectedComponent.scale = 300; + if (selectedComponent.scale > 500) selectedComponent.scale = 500; } if (resizingWidth && (selectedComponent instanceof CompassHudComponent)) { int currentMouseX = Mouse.getX() * width / mc.displayWidth; int delta = currentMouseX - initialWidthMouseX; - selectedComponent.overlayWidth = initialOverlayWidth + delta; + selectedComponent.overlayWidth = initialOverlayWidth + (int) (delta / effectiveScale); if (selectedComponent.overlayWidth < 50) selectedComponent.overlayWidth = 50; if (selectedComponent.overlayWidth > 500) selectedComponent.overlayWidth = 500; } @@ -267,6 +278,11 @@ public class GuiHudEditor extends GuiScreen { selectedComponent.posY = 100F * centerY / res.getScaledHeight(); updateCustomButtons(); } + } else if (button.id == RESET_SIZE_ID) { + if (selectedComponent != null) { + selectedComponent.scale = 100; + updateCustomButtons(); + } } else if (button.id == CYCLE_LEFT_ID) { cycleComponent(-1); } else if (button.id == CYCLE_RIGHT_ID) { diff --git a/src/main/java/noppes/npcs/config/ConfigClient.java b/src/main/java/noppes/npcs/config/ConfigClient.java index ea87eeaf9..fa4376334 100644 --- a/src/main/java/noppes/npcs/config/ConfigClient.java +++ b/src/main/java/noppes/npcs/config/ConfigClient.java @@ -87,10 +87,10 @@ public class ConfigClient { public static float QuestOverlayX = 0; public static Property QuestOverlayYProperty; - public static float QuestOverlayY = 31; + public static float QuestOverlayY = 14; public static Property QuestOverlayScaleProperty; - public static int QuestOverlayScale = 223; + public static int QuestOverlayScale = 246; public static Property QuestOverlayTextAlignProperty; public static int QuestOverlayTextAlign = 0; // 0: Left, 1: Center, 2: Right @@ -99,35 +99,35 @@ public class ConfigClient { public static boolean CompassEnabled = true; public static Property CompassOverlayXProperty; - public static float CompassOverlayX = 37; + public static float CompassOverlayX = 36; public static Property CompassOverlayYProperty; public static float CompassOverlayY = 0; public static Property CompassOverlayScaleProperty; - public static int CompassOverlayScale = 276; + public static int CompassOverlayScale = 344; public static Property CompassOverlayWidthProperty; - public static int CompassOverlayWidth = 200; + public static int CompassOverlayWidth = 158; // Ability Hotbar HUD public static Property AbilityHotbarEnabledProperty; public static boolean AbilityHotbarEnabled = true; public static Property AbilityHotbarXProperty; - public static float AbilityHotbarX = 3; + public static float AbilityHotbarX = 0; public static Property AbilityHotbarYProperty; - public static float AbilityHotbarY = 50; + public static float AbilityHotbarY = 43; public static Property AbilityHotbarScaleProperty; - public static int AbilityHotbarScale = 100; + public static int AbilityHotbarScale = 227; public static Property AbilityHotbarHorizontalProperty; public static boolean AbilityHotbarHorizontal = false; public static Property AbilityHotbarAltTextureProperty; - public static boolean AbilityHotbarAltTexture = false; + public static boolean AbilityHotbarAltTexture = true; // 1=Above(H)/Left(V), 2=Below(H)/Right(V) public static Property AbilityHotbarTextPositionProperty; @@ -179,11 +179,11 @@ public class ConfigClient { QuestOverlayXProperty = config.get(HUD, "Quest Hud X", 0.0, "X position of the quest overlay."); QuestOverlayX = (float) QuestOverlayXProperty.getDouble(0); - QuestOverlayYProperty = config.get(HUD, "Quest Hud Y", 31.0, "Y position of the quest overlay."); - QuestOverlayY = (float) QuestOverlayYProperty.getDouble(31); + QuestOverlayYProperty = config.get(HUD, "Quest Hud Y", 14.0, "Y position of the quest overlay."); + QuestOverlayY = (float) QuestOverlayYProperty.getDouble(14); - QuestOverlayScaleProperty = config.get(HUD, "Quest Hud Scale", 223, "Scale percentage of the quest overlay."); - QuestOverlayScale = QuestOverlayScaleProperty.getInt(223); + QuestOverlayScaleProperty = config.get(HUD, "Quest Hud Scale", 246, "Scale percentage of the quest overlay."); + QuestOverlayScale = QuestOverlayScaleProperty.getInt(246); QuestOverlayTextAlignProperty = config.get(HUD, "Quest Hud Text Alignment", 0, "Text alignment in quest overlay (0: Left, 1: Center, 2: Right)."); QuestOverlayTextAlign = QuestOverlayTextAlignProperty.getInt(0); @@ -200,7 +200,7 @@ public class ConfigClient { CompassOverlayXProperty = config.get( HUD, "Compass Hud X", - 37.0, + 36.0, "Horizontal position of compass overlay (0-100 percentage)" ); CompassOverlayX = (float) CompassOverlayXProperty.getDouble(); @@ -216,19 +216,19 @@ public class ConfigClient { CompassOverlayScaleProperty = config.get( HUD, "Compass Hud Scale", - 276, + 344, "Scale percentage of compass overlay", 50, - 300 + 500 ); CompassOverlayScale = CompassOverlayScaleProperty.getInt(); CompassOverlayWidthProperty = config.get( HUD, "Compass Hud Width", - 200, + 158, "Base width of compass bar in pixels", - 100, + 50, 1000 ); CompassOverlayWidth = CompassOverlayWidthProperty.getInt(); @@ -237,19 +237,19 @@ public class ConfigClient { AbilityHotbarEnabledProperty = config.get(HUD, "Ability Hotbar Enabled", true, "Enable Ability Hotbar HUD Component"); AbilityHotbarEnabled = AbilityHotbarEnabledProperty.getBoolean(); - AbilityHotbarXProperty = config.get(HUD, "Ability Hotbar X", 3.0, "Horizontal position (0-100 percentage)"); + AbilityHotbarXProperty = config.get(HUD, "Ability Hotbar X", 0.0, "Horizontal position (0-100 percentage)"); AbilityHotbarX = (float) AbilityHotbarXProperty.getDouble(); - AbilityHotbarYProperty = config.get(HUD, "Ability Hotbar Y", 50.0, "Vertical position (0-100 percentage)"); + AbilityHotbarYProperty = config.get(HUD, "Ability Hotbar Y", 43.0, "Vertical position (0-100 percentage)"); AbilityHotbarY = (float) AbilityHotbarYProperty.getDouble(); - AbilityHotbarScaleProperty = config.get(HUD, "Ability Hotbar Scale", 100, "Scale percentage", 50, 300); + AbilityHotbarScaleProperty = config.get(HUD, "Ability Hotbar Scale", 227, "Scale percentage", 50, 500); AbilityHotbarScale = AbilityHotbarScaleProperty.getInt(); AbilityHotbarHorizontalProperty = config.get(HUD, "Ability Hotbar Horizontal", false, "Display horizontally instead of vertically"); AbilityHotbarHorizontal = AbilityHotbarHorizontalProperty.getBoolean(); - AbilityHotbarAltTextureProperty = config.get(HUD, "Ability Hotbar Alt Texture", false, "Use rounded square instead of circle slots"); + AbilityHotbarAltTextureProperty = config.get(HUD, "Ability Hotbar Alt Texture", true, "Use rounded square instead of circle slots"); AbilityHotbarAltTexture = AbilityHotbarAltTextureProperty.getBoolean(); AbilityHotbarTextPositionProperty = config.get(HUD, "Ability Hotbar Text Position", 2, "Text label position (1=Above/Left, 2=Below/Right)");