SimpleWindow columns for (some) overflow
This commit is contained in:
@@ -130,8 +130,9 @@ class Prelude {
|
|||||||
|
|
||||||
static function _max(values:Array<Dynamic>):Dynamic {
|
static function _max(values:Array<Dynamic>):Dynamic {
|
||||||
var max = values[0];
|
var max = values[0];
|
||||||
for (value in values.slice(1))
|
for (value in values.slice(1)) {
|
||||||
max = Math.max(max, value);
|
max = Math.max(max, value);
|
||||||
|
}
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,9 @@
|
|||||||
:Float percentHeight]
|
:Float percentHeight]
|
||||||
|
|
||||||
[:String title (or _title "")
|
[:String title (or _title "")
|
||||||
|
&mut :Float nextControlX 0
|
||||||
&mut :Float nextControlY 0
|
&mut :Float nextControlY 0
|
||||||
|
&mut :Int controlsPerColumn 0
|
||||||
:FlxColor titleColor (or _textColor FlxColor.WHITE)
|
:FlxColor titleColor (or _textColor FlxColor.WHITE)
|
||||||
&mut :FlxColor textColor (or _textColor FlxColor.WHITE)
|
&mut :FlxColor textColor (or _textColor FlxColor.WHITE)
|
||||||
:FlxTypedGroup<FlxSprite> controls (new FlxTypedGroup)
|
:FlxTypedGroup<FlxSprite> controls (new FlxTypedGroup)
|
||||||
@@ -26,8 +28,13 @@
|
|||||||
(Std.int (* FlxG.height (or percentHeight 0.5)))
|
(Std.int (* FlxG.height (or percentHeight 0.5)))
|
||||||
(or bgColor FlxColor.BLACK))
|
(or bgColor FlxColor.BLACK))
|
||||||
(screenCenter)
|
(screenCenter)
|
||||||
|
(set nextControlX x)
|
||||||
(set nextControlY y)
|
(set nextControlY y)
|
||||||
|
|
||||||
|
(let [textHeight
|
||||||
|
.height (new FlxText 0 0 0 "a" textSize)]
|
||||||
|
(set controlsPerColumn (Math.floor (/ height textHeight))))
|
||||||
|
|
||||||
(when title
|
(when title
|
||||||
(makeText title null))
|
(makeText title null))
|
||||||
|
|
||||||
@@ -45,12 +52,18 @@
|
|||||||
(prop :Map<FlxSprite,Action> _actions (new Map))
|
(prop :Map<FlxSprite,Action> _actions (new Map))
|
||||||
(prop :Map<FlxSprite,FlxColor> _colors (new Map))
|
(prop :Map<FlxSprite,FlxColor> _colors (new Map))
|
||||||
(method makeText [:String text &opt :FlxColor color :Action onClick]
|
(method makeText [:String text &opt :FlxColor color :Action onClick]
|
||||||
(let [ftext (new FlxText x nextControlY 0 text textSize)]
|
(let [ftext (new FlxText nextControlX nextControlY 0 text textSize)]
|
||||||
(set ftext.color (or color textColor))
|
(set ftext.color (or color textColor))
|
||||||
(dictSet _colors ftext ftext.color)
|
(dictSet _colors ftext ftext.color)
|
||||||
(set ftext.cameras this.cameras)
|
(set ftext.cameras this.cameras)
|
||||||
(controls.add ftext)
|
(controls.add ftext)
|
||||||
(+= nextControlY ftext.height)
|
(+= nextControlY ftext.height)
|
||||||
|
(when (= 0 (% controls.length controlsPerColumn))
|
||||||
|
(set nextControlY y)
|
||||||
|
(when title (+= nextControlY ftext.height))
|
||||||
|
(+= nextControlX (apply max
|
||||||
|
(for control (last (groups controls.members controlsPerColumn))
|
||||||
|
control.width)) textSize))
|
||||||
(when onClick
|
(when onClick
|
||||||
(dictSet _actions ftext onClick)
|
(dictSet _actions ftext onClick)
|
||||||
// TODO right click?
|
// TODO right click?
|
||||||
|
Reference in New Issue
Block a user