Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Commit

Permalink
some polish before i start advanced selection
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Dec 4, 2023
1 parent 1958811 commit ce86a52
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion source/funkin/graphics/FlxFunkText.hx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class FlxFunkText extends FlxSprite {
public var endSelection:Null<Int> = 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) {
Expand Down
14 changes: 11 additions & 3 deletions source/funkin/objects/funkui/FunkButton.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
17 changes: 10 additions & 7 deletions source/funkin/objects/funkui/FunkInputText.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -122,27 +123,25 @@ 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) {
case A: // Get all
__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;
}

Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit ce86a52

Please sign in to comment.