move tooltip sprite, right-click menu INTO camera

This commit is contained in:
2025-12-18 19:43:02 -06:00
parent 09ad2ae91c
commit 8cb65c2684

View File

@@ -1036,7 +1036,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 controlCamera.scroll.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 +1057,16 @@
(when tooltipSprite
(tooltipSprite.kill)
(tooltipSprite.destroy))
(set tooltipSprite (SpriteTools.textPlateV2 text textSize (/ textSize 2) (objectWith [width (min widthAllowed (- width (- control.x controlCamera.scroll.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)))
@@ -1117,10 +1122,18 @@
(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]