From 9f83c3835f820d27b98179e6525e7a42eb6393d6 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 10 Jan 2022 13:44:43 -0700 Subject: [PATCH] stagger label buttons in columns --- .../src/hollywoo_flixel/HollywooFlixelDSL.kiss | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/HollywooFlixelDSL.kiss b/projects/hollywoo-flixel/src/hollywoo_flixel/HollywooFlixelDSL.kiss index 5c6405dd..68925cdb 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/HollywooFlixelDSL.kiss +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/HollywooFlixelDSL.kiss @@ -54,12 +54,17 @@ (let [runners (labelRunners) buttons (new flixel.group.FlxGroup.FlxTypedGroup)] (localVar &mut buttonY 0) - (doFor label (sort (collect (runners.keys))) + (localVar buttonsPerColumn 25) + (doFor [num label] (enumerate (sort (collect (runners.keys)))) (let [runner (dictGet runners label) b (new flixel.ui.FlxButton 0 buttonY label ->{(FlxG.state.remove buttons)(runner)})] + (let [column (Std.int (/ num buttonsPerColumn))] + (set b.x (* b.width column))) (buttons.add b)) - (+= buttonY 20)) - (FlxG.state.add buttons))) + (+= buttonY 20) + (when (= (- buttonsPerColumn 1) (% num buttonsPerColumn)) + (set buttonY 0))) + (.add (cast (_currentScene) SceneFlxState) buttons))) (defMacro withProp [propKey name &body body] `(let [,name (dictGet props ,propKey)]