promptForColor give more controls

This commit is contained in:
2024-07-13 10:30:43 -06:00
parent d5008a7634
commit 9eae5590e5
2 changed files with 33 additions and 12 deletions

View File

@@ -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))

View File

@@ -806,9 +806,10 @@
(redefineWithObjectArgs promptForString promptForStringV2 [prompt onChoice])
(function :SimpleWindow promptForColor <>[T] [:String prompt
:Array<FlxColor> choices
:FlxColor->Void onChoice
&opt :FlxColor bgColor
&opt :Array<FlxColor> 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)