diff --git a/src/main/java/cloudburst/rejects/gui/themes/rounded/MeteorRoundedGuiTheme.java b/src/main/java/cloudburst/rejects/gui/themes/rounded/MeteorRoundedGuiTheme.java index 65507d4..527a2e9 100644 --- a/src/main/java/cloudburst/rejects/gui/themes/rounded/MeteorRoundedGuiTheme.java +++ b/src/main/java/cloudburst/rejects/gui/themes/rounded/MeteorRoundedGuiTheme.java @@ -100,6 +100,7 @@ public class MeteorRoundedGuiTheme extends GuiTheme { public final Setting textColor = color(sgTextColors, "text", "Color of text.", new SettingColor(255, 255, 255)); public final Setting textSecondaryColor = color(sgTextColors, "text-secondary-text", "Color of secondary text.", new SettingColor(150, 150, 150)); + public final Setting textHighlightColor = color(sgTextColors, "text-highlight", "Color of text highlighting.", new SettingColor(45, 125, 245, 100)); public final Setting titleTextColor = color(sgTextColors, "title-text", "Color of title text.", new SettingColor(255, 255, 255)); public final Setting loggedInColor = color(sgTextColors, "logged-in-text", "Color of logged in account name.", new SettingColor(45, 225, 45)); diff --git a/src/main/java/cloudburst/rejects/gui/themes/rounded/widgets/input/WMeteorTextBox.java b/src/main/java/cloudburst/rejects/gui/themes/rounded/widgets/input/WMeteorTextBox.java index 65cfe26..e8277c0 100644 --- a/src/main/java/cloudburst/rejects/gui/themes/rounded/widgets/input/WMeteorTextBox.java +++ b/src/main/java/cloudburst/rejects/gui/themes/rounded/widgets/input/WMeteorTextBox.java @@ -39,28 +39,37 @@ public class WMeteorTextBox extends WTextBox implements MeteorWidget { } renderBackground(renderer, this, false, false); - renderTextAndCursor(renderer, delta); - } - - private void renderTextAndCursor(GuiRenderer renderer, double delta) { + MeteorRoundedGuiTheme theme = theme(); double pad = pad(); - double overflowWidth = getOverflowWidthForRender(); + renderer.scissorStart(x + pad, y + pad, width - pad * 2, height - pad * 2); + + // Text content if (!text.isEmpty()) { - renderer.scissorStart(x + pad, y + pad, width - pad * 2, height - pad * 2); renderer.text(text, x + pad - overflowWidth, y + pad, theme.textColor.get(), false); - renderer.scissorEnd(); } + // Text highlighting + if (focused && (cursor != selectionStart || cursor != selectionEnd)) { + double selStart = x + pad + getTextWidth(selectionStart) - overflowWidth; + double selEnd = x + pad + getTextWidth(selectionEnd) - overflowWidth; + + renderer.quad(selStart, y + pad, selEnd - selStart, theme.textHeight(), theme.textHighlightColor.get()); + } + + // Cursor animProgress += delta * 10 * (focused && cursorVisible ? 1 : -1); animProgress = Utils.clamp(animProgress, 0, 1); if ((focused && cursorVisible) || animProgress > 0) { renderer.setAlpha(animProgress); - renderer.quad(x + pad + getCursorTextWidth() - overflowWidth, y + pad, theme.scale(1), theme.textHeight(), theme.textColor.get()); + renderer.quad(x + pad + getTextWidth(cursor) - overflowWidth, y + pad, theme.scale(1), theme.textHeight(), theme.textColor.get()); renderer.setAlpha(1); } + + renderer.scissorEnd(); } + }