From 8cb65c268453ec6e505b7f419c8d19c8a5abe383 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Thu, 18 Dec 2025 19:43:02 -0600 Subject: [PATCH] move tooltip sprite, right-click menu INTO camera --- src/kiss_flixel/SimpleWindow.kiss | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/kiss_flixel/SimpleWindow.kiss b/src/kiss_flixel/SimpleWindow.kiss index e752ca6..6b284ce 100644 --- a/src/kiss_flixel/SimpleWindow.kiss +++ b/src/kiss_flixel/SimpleWindow.kiss @@ -1036,7 +1036,8 @@ (method :Void showTooltipText [:FlxSprite control :String text :Map 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]