|
|
|
|
@@ -26,6 +26,8 @@
|
|
|
|
|
(prop :FlxSprite selectionMarker)
|
|
|
|
|
(var &mut :FlxSprite defaultSelectionMarker)
|
|
|
|
|
|
|
|
|
|
(prop &mut firstFrame true)
|
|
|
|
|
|
|
|
|
|
(prop &mut :Int _selectedIndex -1)
|
|
|
|
|
(prop :Int selectedIndex (property get set))
|
|
|
|
|
(method get_selectedIndex [] _selectedIndex)
|
|
|
|
|
@@ -46,13 +48,15 @@
|
|
|
|
|
(Std.isOfType controlToSelect KissInputText)))
|
|
|
|
|
|
|
|
|
|
(when controlToDeselect
|
|
|
|
|
(set controlToDeselect.color (dictGet _colors controlToDeselect))
|
|
|
|
|
(whenLet [c (dictGet _colors controlToDeselect)]
|
|
|
|
|
(set controlToDeselect.color c))
|
|
|
|
|
(whenLet [onDeselectLast (dictGet _onDeselectEvents controlToDeselect)]
|
|
|
|
|
(onDeselectLast controlToDeselect)))
|
|
|
|
|
|
|
|
|
|
(set _selectedIndex value)
|
|
|
|
|
(when (= -1 value) (return value))
|
|
|
|
|
(set controlToSelect.color (getHighlighted (dictGet _colors controlToSelect)))
|
|
|
|
|
(whenLet [c (dictGet _colors controlToSelect)]
|
|
|
|
|
(set controlToSelect.color (getHighlighted c)))
|
|
|
|
|
|
|
|
|
|
// HANDLE WHEN A CONTROL IS SELECTED:
|
|
|
|
|
{
|
|
|
|
|
@@ -181,7 +185,8 @@
|
|
|
|
|
:String _enterKey
|
|
|
|
|
:ShortcutAction _onClose
|
|
|
|
|
:FlxSprite _selectionMarker
|
|
|
|
|
:String _screenReaderAudioFolder]
|
|
|
|
|
:String _screenReaderAudioFolder
|
|
|
|
|
:FlxColor _uiTextColor]
|
|
|
|
|
|
|
|
|
|
[:String title (or _title "")
|
|
|
|
|
&mut :Float nextControlX 0
|
|
|
|
|
@@ -189,6 +194,7 @@
|
|
|
|
|
&mut :Int controlsPerColumn 0
|
|
|
|
|
:FlxColor titleColor (or _textColor FlxColor.WHITE)
|
|
|
|
|
&mut :FlxColor textColor (or _textColor FlxColor.WHITE)
|
|
|
|
|
:FlxColor uiTextColor (or _uiTextColor FlxColor.WHITE)
|
|
|
|
|
:FlxColor bgColor (or _bgColor FlxColor.BLACK)
|
|
|
|
|
:Bool xButton ?_xButton
|
|
|
|
|
:String xKey (or _xKey defaultXKey)
|
|
|
|
|
@@ -287,7 +293,7 @@
|
|
|
|
|
(set ftext.font fontPath))
|
|
|
|
|
(set ftext.cameras [controlCamera])
|
|
|
|
|
(-= ftext.x ftext.width)
|
|
|
|
|
(set ftext.color textColor)
|
|
|
|
|
(set ftext.color uiTextColor)
|
|
|
|
|
(dictSet _colors ftext ftext.color)
|
|
|
|
|
(dictSet _actions ftext ->:Void _ (closeAction))
|
|
|
|
|
(set xText ftext)
|
|
|
|
|
@@ -325,7 +331,7 @@
|
|
|
|
|
(set beforeHorizX nextControlX))
|
|
|
|
|
(set horiz !horiz))
|
|
|
|
|
|
|
|
|
|
(method addControl [:FlxSprite control &opt :Bool ignoreLayout]
|
|
|
|
|
(method addControl [:FlxSprite control &opt :Bool ignoreLayout :Action onClick :Action onSelect :Action onDeselect :String tooltipText :Map<String,Action> altActions]
|
|
|
|
|
(when ?ignoreLayout
|
|
|
|
|
(nonLayoutControls.push control))
|
|
|
|
|
|
|
|
|
|
@@ -352,13 +358,29 @@
|
|
|
|
|
(when selectionMarker
|
|
|
|
|
(+= newControlWidth selectionMarker.width textSize))
|
|
|
|
|
(setNth columnWidths -1 (max newControlWidth (last columnWidths)))
|
|
|
|
|
(when hasScrollArrows
|
|
|
|
|
(refreshColumnTexts))
|
|
|
|
|
(when (and columnControls (= 0 (% columnControls.length controlsPerColumn)))
|
|
|
|
|
(set nextControlY 0)
|
|
|
|
|
(when title (+= nextControlY control.height))
|
|
|
|
|
(+= nextControlX (last columnWidths))
|
|
|
|
|
(columnWidths.push 0)
|
|
|
|
|
(when (> (apply + columnWidths) width)
|
|
|
|
|
(makeScrollArrows))))))
|
|
|
|
|
(defAndCall method nextColumn
|
|
|
|
|
(set nextControlY 0)
|
|
|
|
|
(when title (+= nextControlY titleText.height))
|
|
|
|
|
(+= nextControlX (last columnWidths))
|
|
|
|
|
(columnWidths.push 0)
|
|
|
|
|
(when (> (apply + columnWidths) width)
|
|
|
|
|
(makeScrollArrows)))))))
|
|
|
|
|
(when onSelect
|
|
|
|
|
(dictSet _onSelectEvents control onSelect))
|
|
|
|
|
(when onDeselect
|
|
|
|
|
(dictSet _onDeselectEvents control onDeselect))
|
|
|
|
|
(when onClick
|
|
|
|
|
(dictSet _actions control onClick)
|
|
|
|
|
|
|
|
|
|
(when (and selectFirstInteractiveControl (= -1 _selectedIndex))
|
|
|
|
|
(set selectedIndex (.indexOf (getColumnControls) control))))
|
|
|
|
|
(when altActions
|
|
|
|
|
(dictSet _altActions control altActions))
|
|
|
|
|
(when tooltipText
|
|
|
|
|
(dictSet _tooltips control tooltipText))
|
|
|
|
|
control)
|
|
|
|
|
|
|
|
|
|
(prop &mut :Bool _useScrolling false)
|
|
|
|
|
@@ -521,7 +543,7 @@
|
|
|
|
|
(set ftext.font fontPath))
|
|
|
|
|
(set ftext.cameras [controlCamera])
|
|
|
|
|
(-= ftext.y ftext.height)
|
|
|
|
|
(set ftext.color textColor)
|
|
|
|
|
(set ftext.color uiTextColor)
|
|
|
|
|
(dictSet _colors ftext ftext.color)
|
|
|
|
|
(dictSet _actions ftext ->:Void _ (scrollLeft))
|
|
|
|
|
(set leftText ftext))
|
|
|
|
|
@@ -533,7 +555,7 @@
|
|
|
|
|
(set ftext.cameras [controlCamera])
|
|
|
|
|
(-= ftext.x ftext.width)
|
|
|
|
|
(-= ftext.y ftext.height)
|
|
|
|
|
(set ftext.color textColor)
|
|
|
|
|
(set ftext.color uiTextColor)
|
|
|
|
|
(dictSet _colors ftext ftext.color)
|
|
|
|
|
(controls.add ftext)
|
|
|
|
|
(dictSet _actions ftext ->:Void _ (scrollRight))
|
|
|
|
|
@@ -548,6 +570,7 @@
|
|
|
|
|
|
|
|
|
|
(method refreshColumnTexts []
|
|
|
|
|
(doFor i (range columnWidths.length)
|
|
|
|
|
(when (= 0 (nth columnWidths i)) (continue))
|
|
|
|
|
(unless (> columnTexts.length i)
|
|
|
|
|
(let [ftext (new FlxText (fHalf width) height 0 (columnTextStr i) textSize)]
|
|
|
|
|
(when fontPath
|
|
|
|
|
@@ -555,7 +578,7 @@
|
|
|
|
|
(set ftext.cameras [controlCamera])
|
|
|
|
|
(-= ftext.x (fHalf ftext.width))
|
|
|
|
|
(-= ftext.y ftext.height)
|
|
|
|
|
(set ftext.color textColor)
|
|
|
|
|
(set ftext.color uiTextColor)
|
|
|
|
|
(dictSet _colors ftext ftext.color)
|
|
|
|
|
(dictSet _actions ftext
|
|
|
|
|
->:Void _
|
|
|
|
|
@@ -594,23 +617,12 @@
|
|
|
|
|
(when fontPath
|
|
|
|
|
(set t.font fontPath))
|
|
|
|
|
t))]
|
|
|
|
|
(when onClick
|
|
|
|
|
(unless noShortcut
|
|
|
|
|
(keyHandler.registerItem text ->:Void (onClick ftext))))
|
|
|
|
|
(set ftext.color (or color textColor))
|
|
|
|
|
(dictSet _colors ftext ftext.color)
|
|
|
|
|
(addControl ftext ?overridePosition)
|
|
|
|
|
(when onSelect
|
|
|
|
|
(dictSet _onSelectEvents ftext onSelect))
|
|
|
|
|
(when onDeselect
|
|
|
|
|
(dictSet _onDeselectEvents ftext onDeselect))
|
|
|
|
|
(when onClick
|
|
|
|
|
(dictSet _actions ftext onClick)
|
|
|
|
|
(unless noShortcut
|
|
|
|
|
(keyHandler.registerItem text ->:Void (onClick ftext)))
|
|
|
|
|
(when (and selectFirstInteractiveControl (= -1 _selectedIndex))
|
|
|
|
|
(set selectedIndex (.indexOf (getColumnControls) ftext))))
|
|
|
|
|
(when altActions
|
|
|
|
|
(dictSet _altActions ftext altActions))
|
|
|
|
|
(when tooltipText
|
|
|
|
|
(dictSet _tooltips ftext tooltipText))
|
|
|
|
|
(addControl ftext ?overridePosition onClick onSelect onDeselect tooltipText altActions)
|
|
|
|
|
ftext))
|
|
|
|
|
(redefineWithObjectArgs makeText &public makeTextV2 [text])
|
|
|
|
|
|
|
|
|
|
@@ -714,6 +726,11 @@
|
|
|
|
|
(xHandler.cancel)
|
|
|
|
|
(set _shown false)))
|
|
|
|
|
|
|
|
|
|
(method :Void hideOrHideMenu []
|
|
|
|
|
(if (rightClickMenu?.isShown)
|
|
|
|
|
(rightClickMenu.hide)
|
|
|
|
|
(hide)))
|
|
|
|
|
|
|
|
|
|
(function getHighlighted [:FlxColor color &opt :Float amount]
|
|
|
|
|
(unless amount (set amount 0.2))
|
|
|
|
|
(cond ((> color.lightness amount)
|
|
|
|
|
@@ -724,7 +741,7 @@
|
|
|
|
|
(prop &mut :Bool mouseMode false)
|
|
|
|
|
|
|
|
|
|
(prop &mut otherIsSelected false)
|
|
|
|
|
(method &override update [:Float elapsed]
|
|
|
|
|
(method &override :Void update [:Float elapsed]
|
|
|
|
|
(super.update elapsed)
|
|
|
|
|
(set justPressedUIButton false)
|
|
|
|
|
(set otherIsSelected false)
|
|
|
|
|
@@ -754,8 +771,12 @@
|
|
|
|
|
(set mouseMode false))
|
|
|
|
|
|
|
|
|
|
// Handle mouse input
|
|
|
|
|
// Click outside of right-click menu
|
|
|
|
|
(when (and isRightClickMenu !firstFrame (or FlxG.mouse.justPressed FlxG.mouse.justPressedRight) !(.containsPoint (getScreenBounds) (FlxG.mouse.getScreenPosition)))
|
|
|
|
|
(hide))
|
|
|
|
|
(when mouseMode
|
|
|
|
|
(let [mousePos (FlxG.mouse.getScreenPosition controlCamera)]
|
|
|
|
|
|
|
|
|
|
// Click and hover on clickable text entries
|
|
|
|
|
(controls.forEach ->text
|
|
|
|
|
(let [onClick (dictGet _actions text)
|
|
|
|
|
@@ -776,10 +797,12 @@
|
|
|
|
|
(hideTooltipText)))
|
|
|
|
|
|
|
|
|
|
(set otherIsSelected true)
|
|
|
|
|
(set text.color (getHighlighted (dictGet _colors text)))
|
|
|
|
|
(whenLet [c (dictGet _colors text)]
|
|
|
|
|
(set text.color (getHighlighted c)))
|
|
|
|
|
(set selectedIndex (columnControls.indexOf text))
|
|
|
|
|
}
|
|
|
|
|
(set text.color (dictGet _colors text)))))))
|
|
|
|
|
(whenLet [c (dictGet _colors text)]
|
|
|
|
|
(set text.color c)))))))
|
|
|
|
|
// Click on text boxes to focus them
|
|
|
|
|
(inputTexts.forEach ->:Void text
|
|
|
|
|
(when FlxG.mouse.justPressed
|
|
|
|
|
@@ -799,7 +822,8 @@
|
|
|
|
|
(hideTooltipText)
|
|
|
|
|
// Click anywhere else to take focus away from text boxes
|
|
|
|
|
(when FlxG.mouse.justPressed
|
|
|
|
|
(inputTexts.forEach ->text (set text.hasFocus false))))))))
|
|
|
|
|
(inputTexts.forEach ->text (set text.hasFocus false))))))
|
|
|
|
|
(set firstFrame false)))
|
|
|
|
|
|
|
|
|
|
(function &private :SimpleWindow notify [:String message
|
|
|
|
|
:Void->Void onDismiss
|
|
|
|
|
@@ -1036,7 +1060,8 @@
|
|
|
|
|
(method :Void showTooltipText [:FlxSprite control :String text :Map<String,Action> altActions]
|
|
|
|
|
(let [numAltActions (count altActions)
|
|
|
|
|
mousePos (FlxG.mouse.getWorldPosition controlCamera tempPoint)
|
|
|
|
|
widthAllowed (- width mousePos.x)]
|
|
|
|
|
widthAllowed (- width (- mousePos.x controlCamera.scroll.x))
|
|
|
|
|
heightAllowed (- height (- mousePos.y controlCamera.scroll.y))]
|
|
|
|
|
|
|
|
|
|
// With alt actions, append the number of them to the tooltip
|
|
|
|
|
(when (< 0 numAltActions)
|
|
|
|
|
@@ -1056,12 +1081,16 @@
|
|
|
|
|
(when tooltipSprite
|
|
|
|
|
(tooltipSprite.kill)
|
|
|
|
|
(tooltipSprite.destroy))
|
|
|
|
|
(set tooltipSprite (SpriteTools.textPlateV2 text textSize (/ textSize 2) (objectWith [width (min widthAllowed (- width control.x))] textColor bgColor null fontPath)))
|
|
|
|
|
(set tooltipSprite.x mousePos.x)
|
|
|
|
|
(set tooltipSprite.y mousePos.y)
|
|
|
|
|
(set tooltipSprite (SpriteTools.textPlateV2 text textSize (/ textSize 2) (objectWith [width (- width (- control.x controlCamera.scroll.x))] textColor bgColor null fontPath)))
|
|
|
|
|
(set tooltipSprite.x mousePos.x)
|
|
|
|
|
(set tooltipSprite.y mousePos.y)
|
|
|
|
|
(flixel.util.FlxSpriteUtil.drawRect tooltipSprite 0 0 tooltipSprite.width tooltipSprite.height FlxColor.TRANSPARENT (object color textColor))
|
|
|
|
|
(set lastTooltipText text)
|
|
|
|
|
})
|
|
|
|
|
(when (< widthAllowed tooltipSprite.width)
|
|
|
|
|
(-= tooltipSprite.x (- tooltipSprite.width widthAllowed)))
|
|
|
|
|
(when (< heightAllowed tooltipSprite.height)
|
|
|
|
|
(-= tooltipSprite.y (- tooltipSprite.height heightAllowed)))
|
|
|
|
|
(set tooltipSprite.cameras [controlCamera])
|
|
|
|
|
(FlxG.state.add tooltipSprite)))
|
|
|
|
|
|
|
|
|
|
@@ -1074,8 +1103,8 @@
|
|
|
|
|
(method :Void moveTo [:FlxPoint position]
|
|
|
|
|
(set x position.x)
|
|
|
|
|
(set y position.y)
|
|
|
|
|
(set controlCamera.x (+ camera.x position.x))
|
|
|
|
|
(set controlCamera.y (+ camera.y position.y)))
|
|
|
|
|
(set controlCamera.x (+ camera.x position.x (- camera.scroll.x)))
|
|
|
|
|
(set controlCamera.y (+ camera.y position.y (- camera.scroll.y))))
|
|
|
|
|
|
|
|
|
|
(method :Void resize [:Int width :Int height]
|
|
|
|
|
(makeGraphic
|
|
|
|
|
@@ -1091,6 +1120,7 @@
|
|
|
|
|
(-= xText.x xText.width)))
|
|
|
|
|
|
|
|
|
|
(prop &mut :SimpleWindow rightClickMenu)
|
|
|
|
|
(prop &mut isRightClickMenu false)
|
|
|
|
|
|
|
|
|
|
(method :Void showRightClickMenu [:FlxSprite control :Map<String,Action> altActions]
|
|
|
|
|
(hideTooltipText)
|
|
|
|
|
@@ -1114,13 +1144,23 @@
|
|
|
|
|
->choice
|
|
|
|
|
((dictGet altActions (dictGet keysWithoutNumberMap choice)) control)
|
|
|
|
|
(objectWith [choiceColor textColor xButton true] bgColor))]
|
|
|
|
|
(set choiceWindow.isRightClickMenu true)
|
|
|
|
|
(set choiceWindow.mouseMode mouseMode)
|
|
|
|
|
(set rightClickMenu choiceWindow)
|
|
|
|
|
// set up choiceWindow with position where it should be etc
|
|
|
|
|
(set choiceWindow.camera controlCamera)
|
|
|
|
|
(choiceWindow.moveTo mousePos)
|
|
|
|
|
(choiceWindow.resize
|
|
|
|
|
(+ (or choiceWindow.selectionMarker?.width 0) (* textSize 2) (or choiceWindow.xText?.width 0) (apply max (for control choiceWindow.controls control.width)))
|
|
|
|
|
(Std.int choiceWindow.nextControlY)))))
|
|
|
|
|
(let [widthNeeded (+ (or choiceWindow.selectionMarker?.width 0) (* textSize 2) (or choiceWindow.xText?.width 0) (apply max (for control choiceWindow.controls control.width)))
|
|
|
|
|
widthAvail (- width (- mousePos.x controlCamera.scroll.x))
|
|
|
|
|
heightNeeded (Std.int choiceWindow.nextControlY)
|
|
|
|
|
heightAvail (- height (- mousePos.y controlCamera.scroll.y))]
|
|
|
|
|
(when (< widthAvail widthNeeded)
|
|
|
|
|
(-= mousePos.x (- widthNeeded widthAvail)))
|
|
|
|
|
(when (< heightAvail heightNeeded)
|
|
|
|
|
(-= mousePos.y (- heightNeeded heightAvail)))
|
|
|
|
|
(choiceWindow.moveTo mousePos)
|
|
|
|
|
(choiceWindow.resize
|
|
|
|
|
widthNeeded
|
|
|
|
|
(Std.int choiceWindow.nextControlY))))))
|
|
|
|
|
|
|
|
|
|
(#when sys
|
|
|
|
|
(function filePicker [:String initialDir :ConstructorArgs args :String->Void resolve &opt :FileChoiceType choiceType]
|
|
|
|
|
|