Make displayed terminal text screen dragable

This commit is contained in:
2026-04-05 23:45:38 +01:00
parent 017e92470e
commit ed28af8d11
11 changed files with 300 additions and 262 deletions
+12 -9
View File
@@ -3,6 +3,7 @@
module Dodge.Update (updateUniverse) where
import Dodge.Data.ScreenPos
import Bound
import Color
import Control.Applicative
@@ -412,6 +413,7 @@ updateMouseContextGame cfig u = \case
x@OverInvDragSelect{} -> x
MouseGameRotate x
| ButtonRight `M.member` (w ^. input . mouseButtons) -> MouseGameRotate x
OverTerminalBar p | ButtonLeft `M.member` (w ^. input . mouseButtons) -> OverTerminalBar p
_ -> fromMaybe aimcontext (overterm <|> overinv <|> overcomb)
where
w = u ^. uvWorld
@@ -443,10 +445,16 @@ updateMouseContextGame cfig u = \case
overterm = do
tmid <- w ^? hud . subInventory . termID
tm <- w ^? cWorld . lWorld . terminals . ix tmid
return $
if isOverTerminalScreen cfig mpos
then OverTerminal tmid (tm ^. tmStatus)
else OutsideTerminal
xy <- ldpRect cfig (w ^. tmLDP)
return $ tmScreenMousePos w xy mpos tmid (tm ^. tmStatus)
tmScreenMousePos :: World -> (Point2,Point2) -> Point2 -> Int -> TerminalStatus -> MouseContext
tmScreenMousePos w (V2 xmin ymax, V2 xmax ymin) (V2 x y) tmid ts
| xtest && y <= ymax && y >= ymin = OverTerminal tmid ts
| xtest && y <= ymax + 20 && y >= ymax = OverTerminalBar (w ^. tmLDP . ldpPos . spPixelOff - V2 x y)
| otherwise = OutsideTerminal
where
xtest = x <= xmax && x >= xmin
getDebugMouseOver :: Universe -> MouseContext
getDebugMouseOver u = fromMaybe MouseInGame $ do
@@ -468,11 +476,6 @@ getMenuMouseContext screen u = case screen ^. scOptions of
t <- screen ^? scSelectionList . ix yi . siIsSelectable
return $ if t then MouseMenuClick yi else NoMouseContext
isOverTerminalScreen :: Config -> Point2 -> Bool
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
updateWheelEvents :: World -> World
updateWheelEvents w = case w ^. input . scrollAmount of
0 -> w