Fix terminal mouse over positioning

This commit is contained in:
2025-12-24 20:10:03 +00:00
parent 3cdab08184
commit de6bbe7697
5 changed files with 132 additions and 120 deletions
+4 -1
View File
@@ -1,8 +1,8 @@
module Dodge.ListDisplayParams (
invDP,
-- secDP,
invCursorParams,
secondColumnLDP,
terminalLDP,
subInvX,
menuLDP,
) where
@@ -42,6 +42,9 @@ invCursorParams w = BoundaryCursor $ case w ^? hud . subInventory of
secondColumnLDP :: LDParams
secondColumnLDP = defaultLDP & ldpPos . spPixelOff .~ V2 subInvX (-20)
terminalLDP :: LDParams
terminalLDP = secondColumnLDP & ldpBorder ?~ (49, 16)
subInvX :: Float
subInvX = 10 * fromIntegral topInvW + 170
+1 -1
View File
@@ -364,7 +364,7 @@ drawTerminalDisplay w cfig tid = fold $ do
TerminalTextInput s -> (++ [(getPromptTM ++ s ++ [cFilledRect], white)])
TerminalPressTo s -> (++ [(s, white)])
return $
drawSelectionList (secondColumnLDP & ldpBorder ?~ (49, 16)) cfig f
drawSelectionList terminalLDP cfig f
<> drawTerminalCursorLink w cfig tm
where
-- <> tm ^. tmButtonID
+11
View File
@@ -15,6 +15,7 @@ module Dodge.Render.List (
drawTitleBackground, -- should be renamed, made sensible
drawCursorAt,
drawLabelledList,
ldpRect,
) where
import Data.Maybe
@@ -47,6 +48,16 @@ drawSelectionList ldps cfig sl =
(-5)
(10 * sf * fromIntegral x)
ldpRect :: Config -> LDParams -> Maybe (Point2, Point2) -- (NW, SE)
ldpRect cfig ldp = do
(x,y) <- ldp ^? ldpBorder . _Just
return $ ( V2 (-5) 5
, V2 (10 * sf * fromIntegral x) (negate $ (20 * sf + ygap) * fromIntegral y + 5)
) & each +~ screenPosAbs cfig (ldp ^. ldpPos)
where
sf = ldp ^. ldpScale
ygap = ldp ^. ldpVerticalGap
drawTitleBackground :: Config -> Picture
drawTitleBackground cfig =
translateScreenPos cfig (fromTopLeft (V2 (subInvX - 5) 75))
+10 -12
View File
@@ -3,6 +3,7 @@
module Dodge.Update (updateUniverse) where
import Dodge.Render.List
import Data.Foldable
import qualified Data.Set as S
import Color
@@ -399,19 +400,16 @@ getMenuMouseContext screen u = case screen ^. scOptions of
return $ if t then MouseMenuClick yi else NoMouseContext
isOverTerminalScreen :: Config -> Point2 -> Bool
isOverTerminalScreen cfig (V2 x y) =
x <= xmax
&& x >= xmin - 5
&& y <= ymax + 5
&& y >= ymin
isOverTerminalScreen cfig (V2 x y) = fromMaybe False $ do
(V2 xmin ymax, V2 xmax ymin) <- ldpRect cfig terminalLDP
return $ x <= xmax && x >= xmin && y <= ymax && y >= ymin
where
--ldp = secondColumnLDP
ldp = invDP
V2 xmin ymax = screenPosAbs cfig (ldp ^. ldpPos)
tsize = fromIntegral $ getMaxLinesTM + 1
s = 5 + tsize * (20 * ldp ^. ldpScale + ldp ^. ldpVerticalGap)
ymin = ymax - s
xmax = xmin + 555 -- HACK drawSelectionListBackground
-- ldp = terminalLDP
-- V2 xmin ymax = screenPosAbs cfig (ldp ^. ldpPos)
-- tsize = fromIntegral $ getMaxLinesTM + 1
-- s = 5 + tsize * (20 * ldp ^. ldpScale + ldp ^. ldpVerticalGap)
-- ymin = ymax - s
-- xmax = xmin + 555 -- HACK drawSelectionListBackground
updateWheelEvents :: World -> World
updateWheelEvents w = case w ^. input . scrollAmount of