Clickable SimpleWindow pages. Close #139.
This commit is contained in:
@@ -107,8 +107,12 @@
|
|||||||
(+= nextControlY control.height)
|
(+= nextControlY control.height)
|
||||||
// TODO controls that aren't the same height as text will be able to vertically overflow
|
// TODO controls that aren't the same height as text will be able to vertically overflow
|
||||||
(let [columnControls (controls.members.slice (if title 1 0))]
|
(let [columnControls (controls.members.slice (if title 1 0))]
|
||||||
(doFor c [xText columnText leftText rightText]
|
// Don't count special controls as part of any column:
|
||||||
|
(doFor c [xText leftText rightText]
|
||||||
(when c (columnControls.remove c)))
|
(when c (columnControls.remove c)))
|
||||||
|
(doFor c columnTexts
|
||||||
|
(when c (columnControls.remove c)))
|
||||||
|
|
||||||
(setNth columnWidths -1 (max (+ control.width textSize) (last columnWidths)))
|
(setNth columnWidths -1 (max (+ control.width textSize) (last columnWidths)))
|
||||||
(when (and columnControls (= 0 (% columnControls.length controlsPerColumn)))
|
(when (and columnControls (= 0 (% columnControls.length controlsPerColumn)))
|
||||||
(set nextControlY 0)
|
(set nextControlY 0)
|
||||||
@@ -122,11 +126,11 @@
|
|||||||
(prop &mut :FlxText titleText)
|
(prop &mut :FlxText titleText)
|
||||||
(prop &mut :FlxText leftText)
|
(prop &mut :FlxText leftText)
|
||||||
(prop &mut :FlxText rightText)
|
(prop &mut :FlxText rightText)
|
||||||
(prop &mut :FlxText columnText)
|
(prop &mut :Array<FlxText> columnTexts [])
|
||||||
(prop &mut :FlxText xText)
|
(prop &mut :FlxText xText)
|
||||||
|
|
||||||
(method columnTextStr []
|
(method columnTextStr [:Int column]
|
||||||
"$(* cameraColumn ".")*$(* (- columnWidths.length 1 cameraColumn) ".")")
|
(if (= cameraColumn column) ">${column}<" "$column"))
|
||||||
|
|
||||||
(method makeScrollArrows []
|
(method makeScrollArrows []
|
||||||
(unless hasScrollArrows
|
(unless hasScrollArrows
|
||||||
@@ -147,17 +151,35 @@
|
|||||||
(controls.add ftext)
|
(controls.add ftext)
|
||||||
(dictSet _actions ftext ->:Void _ (scrollRight))
|
(dictSet _actions ftext ->:Void _ (scrollRight))
|
||||||
(set rightText ftext))
|
(set rightText ftext))
|
||||||
(let [ftext (new FlxText (fHalf width) height 0 (columnTextStr) textSize)]
|
(refreshColumnTexts)
|
||||||
(set ftext.cameras [controlCamera])
|
|
||||||
(-= ftext.x (fHalf ftext.width))
|
|
||||||
(-= ftext.y ftext.height)
|
|
||||||
(set ftext.color textColor)
|
|
||||||
(dictSet _colors ftext ftext.color)
|
|
||||||
(controls.add ftext)
|
|
||||||
(set columnText ftext))
|
|
||||||
(set hasScrollArrows true))
|
(set hasScrollArrows true))
|
||||||
// A column could be added while the same window is shown.
|
// A column could be added while the same window is shown.
|
||||||
(set columnText.text (columnTextStr)))
|
(refreshColumnTexts))
|
||||||
|
|
||||||
|
(method refreshColumnTexts []
|
||||||
|
(doFor i (range columnWidths.length)
|
||||||
|
(unless (> columnTexts.length i)
|
||||||
|
(let [ftext (new FlxText (fHalf width) height 0 (columnTextStr i) textSize)]
|
||||||
|
// TODO make clickable action
|
||||||
|
(set ftext.cameras [controlCamera])
|
||||||
|
(-= ftext.x (fHalf ftext.width))
|
||||||
|
(-= ftext.y ftext.height)
|
||||||
|
(set ftext.color textColor)
|
||||||
|
(dictSet _colors ftext ftext.color)
|
||||||
|
(dictSet _actions ftext
|
||||||
|
->:Void _
|
||||||
|
(until (= cameraColumn i)
|
||||||
|
(if (< cameraColumn i)
|
||||||
|
(scrollRight)
|
||||||
|
(scrollLeft))))
|
||||||
|
(controls.add ftext)
|
||||||
|
(columnTexts.push ftext)))
|
||||||
|
(let [ftext (nth columnTexts i)]
|
||||||
|
(set ftext.text (columnTextStr i))
|
||||||
|
(set ftext.x (+ (fHalf width) controlCamera.scroll.x))
|
||||||
|
(-= ftext.x (* (- (fHalf columnWidths.length) i) textSize 3))
|
||||||
|
(when (= cameraColumn i) (-= ftext.x .width (new FlxText 0 0 0 ">" textSize))))))
|
||||||
|
|
||||||
(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))
|
||||||
@@ -185,6 +207,7 @@
|
|||||||
|
|
||||||
(method clearControls []
|
(method clearControls []
|
||||||
(set columnWidths [0.0])
|
(set columnWidths [0.0])
|
||||||
|
(set columnTexts [])
|
||||||
(set hasScrollArrows false)
|
(set hasScrollArrows false)
|
||||||
(_actions.clear)
|
(_actions.clear)
|
||||||
(controls.clear)
|
(controls.clear)
|
||||||
@@ -302,10 +325,11 @@
|
|||||||
(-= titleText.x scrollAmount))
|
(-= titleText.x scrollAmount))
|
||||||
(-= leftText.x scrollAmount)
|
(-= leftText.x scrollAmount)
|
||||||
(-= rightText.x scrollAmount)
|
(-= rightText.x scrollAmount)
|
||||||
(-= columnText.x scrollAmount)
|
(doFor columnText columnTexts
|
||||||
|
(-= columnText.x scrollAmount))
|
||||||
(when xText
|
(when xText
|
||||||
(-= xText.x scrollAmount)))
|
(-= xText.x scrollAmount)))
|
||||||
(set columnText.text (columnTextStr))))
|
(refreshColumnTexts)))
|
||||||
|
|
||||||
(method scrollRight []
|
(method scrollRight []
|
||||||
(when (< cameraColumn (- columnWidths.length 1 ))
|
(when (< cameraColumn (- columnWidths.length 1 ))
|
||||||
@@ -315,14 +339,15 @@
|
|||||||
(+= titleText.x scrollAmount))
|
(+= titleText.x scrollAmount))
|
||||||
(+= leftText.x scrollAmount)
|
(+= leftText.x scrollAmount)
|
||||||
(+= rightText.x scrollAmount)
|
(+= rightText.x scrollAmount)
|
||||||
(+= columnText.x scrollAmount)
|
(doFor columnText columnTexts
|
||||||
|
(+= columnText.x scrollAmount))
|
||||||
(when xText
|
(when xText
|
||||||
(+= xText.x scrollAmount)))
|
(+= xText.x scrollAmount)))
|
||||||
(+= cameraColumn 1)
|
(+= cameraColumn 1)
|
||||||
(when (< (apply + (columnWidths.slice cameraColumn)) width)
|
(when (< (apply + (columnWidths.slice cameraColumn)) width)
|
||||||
(controls.remove rightText))
|
(controls.remove rightText))
|
||||||
(controls.add leftText)
|
(controls.add leftText)
|
||||||
(set columnText.text (columnTextStr))))
|
(refreshColumnTexts)))
|
||||||
|
|
||||||
// Irreversibly disable the window's buttons (for when you're going to hide it in the next frame)
|
// Irreversibly disable the window's buttons (for when you're going to hide it in the next frame)
|
||||||
(method clearActions []
|
(method clearActions []
|
||||||
|
Reference in New Issue
Block a user