SimpleWindow.notify

This commit is contained in:
2023-08-13 19:33:47 -06:00
parent 3efb28078e
commit 315dfcf40f

View File

@@ -629,41 +629,40 @@
(when FlxG.mouse.justPressed (when FlxG.mouse.justPressed
(inputTexts.forEach ->text (set text.hasFocus false)))))))) (inputTexts.forEach ->text (set text.hasFocus false))))))))
(function :SimpleWindow promptForChoice <>[T] [:String prompt (function :SimpleWindow notify [:String message
:Array<T> choices :Void->Void onDismiss
:T->Void onChoice &opt :FlxColor bgColor
&opt :FlxColor bgColor :FlxColor titleColor
:FlxColor titleColor :FlxColor choiceColor
:FlxColor choiceColor :Float percentWidth
:Float percentWidth :Float percentHeight
:Float percentHeight :Bool xButton
:Bool xButton :String xKey
:String xKey :String enterKey]
:String leftKey (promptForChoice
:String rightKey message
:String upKey ["OK"]
:String downKey ->_ (onDismiss)
:String enterKey bgColor
:ShortcutAction onClose titleColor
:Bool noShortcuts] choiceColor
(let [window (new SimpleWindow prompt bgColor titleColor percentWidth percentHeight xButton xKey leftKey rightKey upKey downKey enterKey onClose) percentWidth
choiceColor (or choiceColor titleColor FlxColor.WHITE)] percentHeight
(doFor choice choices xButton
(window.makeText (Std.string choice) choiceColor xKey
(when (Std.string choice) null
->:Void s { null
(window.hide) null
(onChoice choice) null
}) enterKey
noShortcuts)) onDismiss))
(window.show)
window))
(function :SimpleWindow promptForString [:String prompt (function :SimpleWindow promptForChoice <>[T] [:String prompt
:String->Void onChoice :Array<T> choices
:T->Void onChoice
&opt :FlxColor bgColor &opt :FlxColor bgColor
:FlxColor titleColor :FlxColor titleColor
:FlxColor submitColor :FlxColor choiceColor
:Float percentWidth :Float percentWidth
:Float percentHeight :Float percentHeight
:Bool xButton :Bool xButton
@@ -673,12 +672,41 @@
:String upKey :String upKey
:String downKey :String downKey
:String enterKey :String enterKey
:ShortcutAction onClose] :ShortcutAction onClose
(let [window (new SimpleWindow prompt bgColor titleColor percentWidth percentHeight xButton xKey leftKey rightKey upKey downKey enterKey onClose) :Bool noShortcuts]
buttonColor (or submitColor FlxColor.WHITE) (let [window (new SimpleWindow prompt bgColor titleColor percentWidth percentHeight xButton xKey leftKey rightKey upKey downKey enterKey onClose)
inputText (new KissInputText 0 0 FlxG.width "" textSize true)] choiceColor (or choiceColor titleColor FlxColor.WHITE)]
(window.addControl inputText) (doFor choice choices
(window.makeText "{enter} Submit" buttonColor (window.makeText (Std.string choice) choiceColor
(when (Std.string choice)
->:Void s {
(window.hide)
(onChoice choice)
})
noShortcuts))
(window.show)
window))
(function :SimpleWindow promptForString [:String prompt
:String->Void onChoice
&opt :FlxColor bgColor
:FlxColor titleColor
:FlxColor submitColor
:Float percentWidth
:Float percentHeight
:Bool xButton
:String xKey
:String leftKey
:String rightKey
:String upKey
:String downKey
:String enterKey
:ShortcutAction onClose]
(let [window (new SimpleWindow prompt bgColor titleColor percentWidth percentHeight xButton xKey leftKey rightKey upKey downKey enterKey onClose)
buttonColor (or submitColor FlxColor.WHITE)
inputText (new KissInputText 0 0 FlxG.width "" textSize true)]
(window.addControl inputText)
(window.makeText "{enter} Submit" buttonColor
->:Void s { ->:Void s {
(window.hide) (window.hide)
(onChoice inputText.text) (onChoice inputText.text)