From ce86a523f5751e95bec303057c895c0fb095c6be Mon Sep 17 00:00:00 2001 From: MaybeMaru <97055307+MaybeMaru@users.noreply.github.com> Date: Mon, 4 Dec 2023 23:16:18 +0100 Subject: [PATCH] some polish before i start advanced selection --- source/funkin/graphics/FlxFunkText.hx | 2 +- source/funkin/objects/funkui/FunkButton.hx | 14 +++++++++++--- source/funkin/objects/funkui/FunkInputText.hx | 17 ++++++++++------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/source/funkin/graphics/FlxFunkText.hx b/source/funkin/graphics/FlxFunkText.hx index eba0a60b..ef49bb6e 100644 --- a/source/funkin/graphics/FlxFunkText.hx +++ b/source/funkin/graphics/FlxFunkText.hx @@ -58,7 +58,7 @@ class FlxFunkText extends FlxSprite { public var endSelection:Null = null; public var selected(get, never):Bool; function get_selected() { - return startSelection != null && endSelection != null; + return !(startSelection == null || endSelection == null); } inline public function setSelection(start:Int, end:Int) { diff --git a/source/funkin/objects/funkui/FunkButton.hx b/source/funkin/objects/funkui/FunkButton.hx index 6a0d1352..3076c61c 100644 --- a/source/funkin/objects/funkui/FunkButton.hx +++ b/source/funkin/objects/funkui/FunkButton.hx @@ -29,18 +29,26 @@ class FunkButton extends FourSideSprite implements IFunkUIObject { text.setPosition(X,Y); } + static final HIGHLIGHT_COLOR:Int = 0xFFC8C7C7; + static final PRESS_COLOR:Int = 0xFF808080; + + var targetColor:FlxColor = FlxColor.WHITE; + override function update(elapsed:Float) { super.update(elapsed); if (FlxG.mouse.overlaps(this)) { + targetColor = HIGHLIGHT_COLOR; if (FlxG.mouse.justPressed) { - text.color = color = FlxColor.GRAY; + text.color = color = PRESS_COLOR; onClick(); } + } else { + targetColor = FlxColor.WHITE; } - if (color != FlxColor.WHITE) { - text.color = color = FlxColor.interpolate(color, FlxColor.WHITE, elapsed * 10); + if (color != targetColor) { + text.color = color = FlxColor.interpolate(color, targetColor, elapsed * 10); } } diff --git a/source/funkin/objects/funkui/FunkInputText.hx b/source/funkin/objects/funkui/FunkInputText.hx index a44d9452..0c2fe4e8 100644 --- a/source/funkin/objects/funkui/FunkInputText.hx +++ b/source/funkin/objects/funkui/FunkInputText.hx @@ -24,6 +24,7 @@ class FunkInputText extends FourSideSprite implements IFunkUIObject { _addBar = false; _tmr = 0.0; __text.text = text; + __text.deselect(); } targetColor = selected ? FlxColor.WHITE : HIGHLIGHT_COLOR; return selected = value; @@ -122,8 +123,7 @@ class FunkInputText extends FourSideSprite implements IFunkUIObject { var shiftPress:Bool; var ctrlPress:Bool; - var clipBoard:String = ""; - var didCut:Bool = false; + static var clipBoard:String = ""; function ctrlKeys(key:FlxKey) { switch(key) { @@ -131,18 +131,17 @@ class FunkInputText extends FourSideSprite implements IFunkUIObject { __text.setSelection(0, text.length); case C: // Copy copySelection(); - didCut = false; case V: // Paste pasteSelection(); - if (didCut) clipBoard = ""; - didCut = false; case X: // Cut copySelection(); removeSelection(); - didCut = true; default: return false; } + + _addBar = true; + _tmr = 0.75; return true; } @@ -179,6 +178,10 @@ class FunkInputText extends FourSideSprite implements IFunkUIObject { } switch (key) { + case ESCAPE: + selected = false; + return; + case SHIFT | CONTROL | TAB: // these aint do nothin case CAPSLOCK: capsLock = !capsLock; case BACKSPACE: @@ -193,10 +196,10 @@ class FunkInputText extends FourSideSprite implements IFunkUIObject { updateCurLine(); case LEFT | RIGHT: + __text.deselect(); if (!ctrlPress) { // Normal scrolling wordPos += (key == LEFT ? -1 : 1); wordPos = cast FlxMath.bound(wordPos, 0, text.length); - __text.deselect(); updateCurLine(); } else { // CONTROL jump scrolling