From aca9cec48c551c27faf875557de423f8b34d33af Mon Sep 17 00:00:00 2001 From: somehussar <148253652+somehussar@users.noreply.github.com> Date: Fri, 19 Dec 2025 22:38:43 +0100 Subject: [PATCH 1/6] Make it shift down the viewport if search is --- .../noppes/npcs/client/gui/util/GuiScriptTextArea.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java index c1e8e44f9..407be1454 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java @@ -262,6 +262,11 @@ public class GuiScriptTextArea extends GuiNpcTextField { } // Draw outer border around entire area drawRect(x - 1, y - 1, x + width + 1, y + height + 1, 0xffa0a0a0); + + int searchHeight = searchBar.getTotalHeight(); + y += searchHeight; + height -= searchHeight; + // Draw line number gutter background drawRect(x, y, x + LINE_NUMBER_GUTTER_WIDTH, y + height, 0xff000000); // Draw text viewport background (starts after gutter) @@ -551,6 +556,8 @@ public class GuiScriptTextArea extends GuiNpcTextField { goToLineDialog.draw(xMouse, yMouse); KEYS_OVERLAY.draw(xMouse, yMouse, wheelDelta); + y -= searchHeight; + height += searchHeight; } private void scissorViewport() { From 00eefb0887b19cb7eede1dd5bb8c0ccd0065672d Mon Sep 17 00:00:00 2001 From: somehussar <148253652+somehussar@users.noreply.github.com> Date: Fri, 19 Dec 2025 22:39:36 +0100 Subject: [PATCH 2/6] Cap scroll to amount of visible lines, currently was capped to amount of lines + 1 --- .../java/noppes/npcs/client/gui/util/GuiScriptTextArea.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java index 407be1454..2f31a86b7 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java @@ -277,8 +277,8 @@ public class GuiScriptTextArea extends GuiNpcTextField { // Enable scissor test to clip drawing to the TEXT viewport rectangle (excludes gutter) GL11.glEnable(GL11.GL_SCISSOR_TEST); scissorViewport(); - - container.visibleLines = height / container.lineHeight-1; + + container.visibleLines = (height / container.lineHeight); int maxScroll = Math.max(0, this.container.linesCount - container.visibleLines); From 3568fb8a868a07c5265bde66ab3605fc108e54f3 Mon Sep 17 00:00:00 2001 From: somehussar <148253652+somehussar@users.noreply.github.com> Date: Fri, 19 Dec 2025 23:08:37 +0100 Subject: [PATCH 3/6] Give priority of keybinds with special keys Stop searching if found match. --- .../noppes/npcs/client/key/KeyPreset.java | 22 ++++++++++++++++++- .../npcs/client/key/KeyPresetManager.java | 13 ++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/client/key/KeyPreset.java b/src/main/java/noppes/npcs/client/key/KeyPreset.java index cbc7cfb86..27ed9485b 100644 --- a/src/main/java/noppes/npcs/client/key/KeyPreset.java +++ b/src/main/java/noppes/npcs/client/key/KeyPreset.java @@ -8,7 +8,7 @@ import org.lwjgl.input.Mouse; import java.util.function.Consumer; -public class KeyPreset { +public class KeyPreset implements Comparable { /** * @field SINGLE_PRESS => on releasing before 5 ticks press time * @field PRESS_RELEASE => on pressing and releasing @@ -148,6 +148,26 @@ public class KeyPreset { return false; } + @Override + public int compareTo(KeyPreset o) { + int mySpecialCount = getSpecialKeyCount(this); + int otherSpecialCount = getSpecialKeyCount(o); + + return mySpecialCount - otherSpecialCount; + } + + private static int getSpecialKeyCount(KeyPreset preset) { + int res = 0; + if (preset.hasAlt()) + res += 1; + if (preset.hasCtrl()) + res += 1; + if (preset.hasShift()) + res += 1; + + return res; + } + public static class KeyState { public int keyCode = -1; diff --git a/src/main/java/noppes/npcs/client/key/KeyPresetManager.java b/src/main/java/noppes/npcs/client/key/KeyPresetManager.java index 61b74a610..355c07b54 100644 --- a/src/main/java/noppes/npcs/client/key/KeyPresetManager.java +++ b/src/main/java/noppes/npcs/client/key/KeyPresetManager.java @@ -13,6 +13,8 @@ public class KeyPresetManager { public List keys = new ArrayList<>(); public String fileName; + private boolean wasSorted = false; + public KeyPresetManager(String fileName) { this.fileName = fileName; } @@ -20,12 +22,21 @@ public class KeyPresetManager { public KeyPreset add(String name) { KeyPreset preset = new KeyPreset(name); keys.add(preset); + wasSorted = false; return preset; } public void tick() { - for (KeyPreset key : keys) + if (!wasSorted) { + keys.sort(KeyPreset::compareTo); + wasSorted = true; + } + + for (KeyPreset key : keys) { key.tick(); + if (key.isDown) + return; + } } From 0cbfe526cbc7a824d9429486d17502252a462583 Mon Sep 17 00:00:00 2001 From: somehussar <148253652+somehussar@users.noreply.github.com> Date: Fri, 19 Dec 2025 23:09:17 +0100 Subject: [PATCH 4/6] Add search / replace unwind button --- .../client/gui/util/script/SearchReplaceBar.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/util/script/SearchReplaceBar.java b/src/main/java/noppes/npcs/client/gui/util/script/SearchReplaceBar.java index f073ad1d7..ae01c430e 100644 --- a/src/main/java/noppes/npcs/client/gui/util/script/SearchReplaceBar.java +++ b/src/main/java/noppes/npcs/client/gui/util/script/SearchReplaceBar.java @@ -71,6 +71,7 @@ public class SearchReplaceBar { // ==================== HOVER STATE ==================== private boolean hoverClose = false; + private boolean hoverSearchUnwind = false; private boolean hoverMatchCase = false; private boolean hoverWholeWord = false; private boolean hoverPrev = false; @@ -323,6 +324,9 @@ public class SearchReplaceBar { int closeX = x + width - buttonSize - padding; drawCloseButton(closeX, rowY, hoverClose); + + int replaceUnwindButton = closeX - buttonSize - buttonSpacing; + drawActionButton(replaceUnwindButton, rowY, showReplace ? "▼" : "◀", hoverSearchUnwind, true); } private void drawReplaceRow(int mouseX, int mouseY) { @@ -477,7 +481,10 @@ public class SearchReplaceBar { int closeX = x + width - buttonSize - padding; hoverClose = isMouseOver(mouseX, mouseY, closeX, rowY, buttonSize, buttonSize); - + + int replaceUnwindButton = closeX - buttonSize - buttonSpacing; + hoverSearchUnwind = isMouseOver(mouseX, mouseY, replaceUnwindButton, rowY, buttonSize, buttonSize); + if (showReplace) { int replaceRowY = y + barHeight + 2; currentX = x + padding + textFieldWidth + buttonSpacing + 4; @@ -592,7 +599,12 @@ public class SearchReplaceBar { close(); return true; } - + + if (hoverSearchUnwind) { + showReplace = !showReplace; + return true; + } + if (showReplace) { int replaceRowY = y + barHeight + 2; From 2efdafe2546abc18d9fe1f31234d712fe01b5fd6 Mon Sep 17 00:00:00 2001 From: somehussar <148253652+somehussar@users.noreply.github.com> Date: Fri, 19 Dec 2025 23:15:48 +0100 Subject: [PATCH 5/6] Fix priority calculations. --- src/main/java/noppes/npcs/client/key/KeyPreset.java | 2 +- src/main/java/noppes/npcs/client/key/KeyPresetManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/client/key/KeyPreset.java b/src/main/java/noppes/npcs/client/key/KeyPreset.java index 27ed9485b..8c21d86c5 100644 --- a/src/main/java/noppes/npcs/client/key/KeyPreset.java +++ b/src/main/java/noppes/npcs/client/key/KeyPreset.java @@ -153,7 +153,7 @@ public class KeyPreset implements Comparable { int mySpecialCount = getSpecialKeyCount(this); int otherSpecialCount = getSpecialKeyCount(o); - return mySpecialCount - otherSpecialCount; + return otherSpecialCount - mySpecialCount; } private static int getSpecialKeyCount(KeyPreset preset) { diff --git a/src/main/java/noppes/npcs/client/key/KeyPresetManager.java b/src/main/java/noppes/npcs/client/key/KeyPresetManager.java index 355c07b54..96cf63731 100644 --- a/src/main/java/noppes/npcs/client/key/KeyPresetManager.java +++ b/src/main/java/noppes/npcs/client/key/KeyPresetManager.java @@ -34,7 +34,7 @@ public class KeyPresetManager { for (KeyPreset key : keys) { key.tick(); - if (key.isDown) + if (key.isDown && key.shouldConflict) return; } } From 780dc4ca76366d0e9f325f8523310d41115f44b7 Mon Sep 17 00:00:00 2001 From: somehussar <148253652+somehussar@users.noreply.github.com> Date: Fri, 19 Dec 2025 23:23:39 +0100 Subject: [PATCH 6/6] Stop sorting keys list, create sorted copy instead. Made it so the rendering for them would still work for visual grouping, but the ticking logic wouldn't suffer --- src/main/java/noppes/npcs/client/key/KeyPresetManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/client/key/KeyPresetManager.java b/src/main/java/noppes/npcs/client/key/KeyPresetManager.java index 96cf63731..8d25c43ac 100644 --- a/src/main/java/noppes/npcs/client/key/KeyPresetManager.java +++ b/src/main/java/noppes/npcs/client/key/KeyPresetManager.java @@ -11,6 +11,7 @@ import java.util.List; public class KeyPresetManager { public List keys = new ArrayList<>(); + public List keysSorted = new ArrayList<>(); public String fileName; private boolean wasSorted = false; @@ -22,17 +23,18 @@ public class KeyPresetManager { public KeyPreset add(String name) { KeyPreset preset = new KeyPreset(name); keys.add(preset); + keysSorted.add(preset); wasSorted = false; return preset; } public void tick() { if (!wasSorted) { - keys.sort(KeyPreset::compareTo); + keysSorted.sort(KeyPreset::compareTo); wasSorted = true; } - for (KeyPreset key : keys) { + for (KeyPreset key : keysSorted) { key.tick(); if (key.isDown && key.shouldConflict) return;