From 9eae5590e5d4127eb65a006282c275a22eb04a41 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sat, 13 Jul 2024 10:30:43 -0600 Subject: [PATCH] promptForColor give more controls --- shader-test/source/MirroredOrnamentState.kiss | 8 ++-- src/kiss_flixel/SimpleWindow.kiss | 37 +++++++++++++++---- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/shader-test/source/MirroredOrnamentState.kiss b/shader-test/source/MirroredOrnamentState.kiss index b3931d7..a5a090b 100644 --- a/shader-test/source/MirroredOrnamentState.kiss +++ b/shader-test/source/MirroredOrnamentState.kiss @@ -26,19 +26,19 @@ (method &override :Void update [:Float elapsed] (super.update elapsed) (when FlxG.keys.justPressed.A - (SimpleWindow.promptForColor "Choose color A" (collect FlxColor.colorLookup) + (SimpleWindow.promptForColor "Choose color A" ->color (set shader.color_aFlxColor color))) (when FlxG.keys.justPressed.B - (SimpleWindow.promptForColor "Choose color B" (collect FlxColor.colorLookup) + (SimpleWindow.promptForColor "Choose color B" ->color (set shader.color_bFlxColor color))) (when FlxG.keys.justPressed.C - (SimpleWindow.promptForColor "Choose color C" (collect FlxColor.colorLookup) + (SimpleWindow.promptForColor "Choose color C" ->color (set shader.color_cFlxColor color))) (when FlxG.keys.justPressed.D - (SimpleWindow.promptForColor "Choose color D" (collect FlxColor.colorLookup) + (SimpleWindow.promptForColor "Choose color D" ->color (set shader.color_dFlxColor color))) (+= FlxG.camera.zoom 0.01)) \ No newline at end of file diff --git a/src/kiss_flixel/SimpleWindow.kiss b/src/kiss_flixel/SimpleWindow.kiss index d8018e1..5812508 100644 --- a/src/kiss_flixel/SimpleWindow.kiss +++ b/src/kiss_flixel/SimpleWindow.kiss @@ -806,9 +806,10 @@ (redefineWithObjectArgs promptForString promptForStringV2 [prompt onChoice]) (function :SimpleWindow promptForColor <>[T] [:String prompt - :Array choices :FlxColor->Void onChoice - &opt :FlxColor bgColor + &opt :Array choices + :FlxColor currentColor + :FlxColor bgColor :FlxColor titleColor :Float percentWidth :Float percentHeight @@ -826,19 +827,39 @@ (let [window (new SimpleWindow (unless wrapPrompt prompt) bgColor titleColor percentWidth percentHeight xButton xKey leftKey rightKey upKey downKey enterKey onClose defaultSelectionMarker screenReaderAudioFolder)] (when wrapPrompt (window.makeWrappedText prompt titleColor true)) - (doFor choice choices - (window.makeTextV2 - " " + (unless choices (set choices (collect FlxColor.colorLookup))) + (unless currentColor (set currentColor (first choices))) + (localFunction recursiveCall [:FlxColor newCurrentColor] + (window.hide) + (promptForColor prompt onChoice choices newCurrentColor bgColor titleColor percentWidth percentHeight xButton xKey leftKey rightKey upKey downKey enterKey onClose noShortcuts wrapPrompt screenReaderAudioFolder)) + (window.makeTextV2 + " " (object - bgColor choice + bgColor currentColor onClick ->:Void s { (window.hide) - (onChoice choice) + (onChoice currentColor) } + noShortcut noShortcuts)) + (var COLOR_STEP 0.1) + (window.makeTextV2 "Lighter" (object onClick ->:Void s (recursiveCall (currentColor.getLightened COLOR_STEP)))) + (window.makeTextV2 "Darker" (object onClick ->:Void s (recursiveCall (currentColor.getDarkened COLOR_STEP)))) + (window.makeTextV2 "Red++" (object onClick ->:Void s (recursiveCall {(+= currentColor.redFloat COLOR_STEP) currentColor}))) + (window.makeTextV2 "Red--" (object onClick ->:Void s (recursiveCall {(-= currentColor.redFloat COLOR_STEP) currentColor}))) + (window.makeTextV2 "Green++" (object onClick ->:Void s (recursiveCall {(+= currentColor.greenFloat COLOR_STEP) currentColor}))) + (window.makeTextV2 "Green--" (object onClick ->:Void s (recursiveCall {(-= currentColor.greenFloat COLOR_STEP) currentColor}))) + (window.makeTextV2 "Blue++" (object onClick ->:Void s (recursiveCall {(+= currentColor.blueFloat COLOR_STEP) currentColor}))) + (window.makeTextV2 "Blue--" (object onClick ->:Void s (recursiveCall {(-= currentColor.blueFloat COLOR_STEP) currentColor}))) + (doFor choice choices + (window.makeTextV2 + " " + (object + bgColor choice + onClick ->:Void s (recursiveCall choice) noShortcut noShortcuts))) (window.show) window)) -(redefineWithObjectArgs promptForColor promptForColorV2 [prompt choices onChoice]) +(redefineWithObjectArgs promptForColor promptForColorV2 [prompt onChoice]) (method scrollLeft [] (when (> cameraColumn 0)