This commit is contained in:
2024-11-25 22:16:54 +00:00
parent a4998716e9
commit bf6e02bd98
3 changed files with 125 additions and 123 deletions
+32 -31
View File
@@ -304,40 +304,20 @@ checkTermDist w = fromMaybe w $ do
btid <- w ^? cWorld . lWorld . terminals . ix tmid . tmButtonID
btpos <- w ^? cWorld . lWorld . buttons . ix btid . btPos
guard $ dist btpos (_crPos $ you w) > 40
return $
w & hud . hudElement . subInventory
.~ NoSubInventory --MouseInvNothing
return $ w & hud . hudElement . subInventory .~ NoSubInventory
updateMouseContext :: Configuration -> Universe -> Universe
updateMouseContext cfig u = case u ^. uvWorld . input . mouseContext of
updateMouseContext cfig u = case u ^? uvScreenLayers . ix 0 of
Just screen -> u & uvWorld . input . mouseContext .~ getMenuMouseContext screen u
Nothing -> updateMouseContextGame cfig u
updateMouseContextGame :: Configuration -> Universe -> Universe
updateMouseContextGame cfig u = case u ^. uvWorld . input . mouseContext of
OverInvDrag i _ _ _ -> u & uvWorld . input . mouseContext .~ invdrag i
OverInvDragSelect{} -> u
_ ->
u & uvWorld . input . mouseContext
.~ fromMaybe
aimcontext
(overmenu <|> overinv <|> overcomb <|> overterm)
_ -> u & uvWorld . input . mouseContext
.~ fromMaybe aimcontext (overinv <|> overcomb <|> overterm)
where
overmenu = do
screen <- u ^? uvScreenLayers . ix 0
return $ case screen ^. scOptions of
[] -> NoMouseContext
_ -> fromMaybe MouseMenuCursor $ do
ldps <- screen ^? scListDisplayParams
let ymax = maybe 0 length $ screen ^? scSelectionList
yi <-
ldpVerticalSelection
(u ^. uvConfig)
ldps
(u ^. uvWorld . input . mousePos)
guard (yi >= 0 && yi < ymax)
return $
if isselectable yi
then MouseMenuClick yi
else NoMouseContext
isselectable yi =
fromMaybe False $
u ^? uvScreenLayers . _head . scSelectionList . ix yi . siIsSelectable
w = u ^. uvWorld
aimcontext
| ButtonRight `M.member` (w ^. input . mouseButtons) = MouseAiming
@@ -360,8 +340,8 @@ updateMouseContext cfig u = case u ^. uvWorld . input . mouseContext of
return $ OverInvSelect selpos
overcomb = do
sss <- w ^? hud . hudElement . subInventory . ciSections
(xl,xr,_) <- w ^? hud . hudElement . subInventory . ciSelection . _Just
let msel = (xl,xr)
(xl, xr, _) <- w ^? hud . hudElement . subInventory . ciSelection . _Just
let msel = (xl, xr)
let mpossel = inverseSelNumPos cfig secondColumnParams sss (w ^. input . mousePos)
return $ case mpossel of
Nothing -> OverCombEscape
@@ -379,6 +359,27 @@ updateMouseContext cfig u = case u ^. uvWorld . input . mouseContext of
return $ OverTerminalReturn tmid
else OverTerminalEscape
getMenuMouseContext :: ScreenLayer -> Universe -> MouseContext
getMenuMouseContext screen u = case screen ^. scOptions of
[] -> NoMouseContext
_ -> fromMaybe MouseMenuCursor $ do
ldps <- screen ^? scListDisplayParams
let ymax = maybe 0 length $ screen ^? scSelectionList
yi <-
ldpVerticalSelection
(u ^. uvConfig)
ldps
(u ^. uvWorld . input . mousePos)
guard (yi >= 0 && yi < ymax)
return $
if isselectable yi
then MouseMenuClick yi
else NoMouseContext
where
isselectable yi =
fromMaybe False $
u ^? uvScreenLayers . _head . scSelectionList . ix yi . siIsSelectable
isOverTerminalScreen :: Configuration -> Terminal -> Point2 -> Bool
isOverTerminalScreen cfig _ (V2 x y) =
x <= xmax
+6 -7
View File
@@ -210,17 +210,16 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
f (x,y) = (x,y,mempty)
startDrag :: (Int, Int) -> Configuration -> World -> World
startDrag (a, b) cfig w = setcontext . fromMaybe (augInvDirectSelect (a, b, IS.singleton b) w) $ do
(i, _, xs) <- w ^? hud . hudElement . diSelection . _Just
guard $ i == a && b `IS.member` xs
return w
startDrag (a, b) cfig w = setcontext
. fromMaybe (augInvDirectSelect (a, b, IS.singleton b) w) $ do
(i, _, xs) <- w ^? hud . hudElement . diSelection . _Just
guard $ i == a && b `IS.member` xs
return w
where
setcontext = (input . mouseContext .~ OverInvDrag a (Just (a, b)) above bneath)
above :: Maybe (Int,Int)
setcontext = input . mouseContext .~ OverInvDrag a (Just (a, b)) above bneath
above = do
sss <- w ^? hud . hudElement . diSections
inverseSelSecYint (yint - 1) sss
bneath :: Maybe (Int,Int)
bneath = do
sss <- w ^? hud . hudElement . diSections
inverseSelSecYint (yint + 1) sss