From fba58b28fdbf41f48bf1d38bd8ba67ff7da9340b Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 29 Aug 2022 19:19:08 +0000 Subject: [PATCH] SimpleWindow.promptForChoice --- src/kiss_flixel/SimpleWindow.kiss | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/kiss_flixel/SimpleWindow.kiss b/src/kiss_flixel/SimpleWindow.kiss index b4e03ad..5b4e4c1 100644 --- a/src/kiss_flixel/SimpleWindow.kiss +++ b/src/kiss_flixel/SimpleWindow.kiss @@ -5,7 +5,7 @@ (prop &mut keyboardEnabled true) // TODO tooltip support with left-click and right-click action -// icons and explanations +// icons and explanations? (defNew [&opt :String _title :FlxColor bgColor @@ -129,4 +129,23 @@ } { (set text.color color) - }))))))) \ No newline at end of file + }))))))) + +(function :SimpleWindow promptForChoice <>[T] [:String prompt + :Array choices + :T->Void onChoice + &opt :FlxColor bgColor + :FlxColor titleColor + :FlxColor choiceColor + :Float percentWidth + :Float percentHeight] + (let [window (new SimpleWindow prompt bgColor titleColor percentWidth percentHeight) + choiceColor (or choiceColor titleColor FlxColor.WHITE)] + (doFor choice choices + (window.makeText (Std.string choice) choiceColor + ->:Void s { + (window.hide) + (onChoice choice) + })) + (window.show) + window)) \ No newline at end of file