mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 20:52:36 +00:00
Merge remote-tracking branch 'origin/janino-scripts' into janino-scripts
This commit is contained in:
commit
1ac7c0e797
4 files changed
+58
-6
No files matched your search
@@ -261,6 +261,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)
|
||||
@@ -271,8 +276,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);
|
||||
|
||||
@@ -550,6 +555,8 @@ public class GuiScriptTextArea extends GuiNpcTextField {
|
||||
goToLineDialog.draw(xMouse, yMouse);
|
||||
|
||||
KEYS_OVERLAY.draw(xMouse, yMouse, wheelDelta);
|
||||
y -= searchHeight;
|
||||
height += searchHeight;
|
||||
}
|
||||
|
||||
private void scissorViewport() {
|
||||
|
||||
@@ -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) {
|
||||
@@ -480,7 +484,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;
|
||||
@@ -595,7 +602,12 @@ public class SearchReplaceBar {
|
||||
close();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (hoverSearchUnwind) {
|
||||
showReplace = !showReplace;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (showReplace) {
|
||||
int replaceRowY = y + barHeight + 2;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class KeyPreset {
|
||||
public class KeyPreset implements Comparable<KeyPreset> {
|
||||
/**
|
||||
* @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 otherSpecialCount - mySpecialCount;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -11,8 +11,11 @@ import java.util.List;
|
||||
|
||||
public class KeyPresetManager {
|
||||
public List<KeyPreset> keys = new ArrayList<>();
|
||||
public List<KeyPreset> keysSorted = new ArrayList<>();
|
||||
public String fileName;
|
||||
|
||||
private boolean wasSorted = false;
|
||||
|
||||
public KeyPresetManager(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
@@ -20,12 +23,22 @@ 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() {
|
||||
for (KeyPreset key : keys)
|
||||
if (!wasSorted) {
|
||||
keysSorted.sort(KeyPreset::compareTo);
|
||||
wasSorted = true;
|
||||
}
|
||||
|
||||
for (KeyPreset key : keysSorted) {
|
||||
key.tick();
|
||||
if (key.isDown && key.shouldConflict)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user