Partially successful change of terminals to external entities

This commit is contained in:
2022-06-06 12:49:14 +01:00
parent 597336499c
commit eb38874102
12 changed files with 141 additions and 167 deletions
+24 -24
View File
@@ -94,8 +94,8 @@ handlePressedMouseButton :: MouseButton -> Universe -> Maybe Universe
handlePressedMouseButton but w = case (_hudElement (_hud $ _uvWorld w), but) of
(DisplayCarte,_) -> Just $ w & uvWorld . clickMousePos .~ _mousePos (_uvWorld w)
(_,ButtonMiddle) -> Just $ w & uvWorld . clickMousePos .~ _mousePos (_uvWorld w)
( DisplayInventory (DisplayTerminal _ _) , ButtonLeft)
-> Just $ over uvWorld doTerminalEffect w
( DisplayInventory (DisplayTerminal tmid _) , ButtonLeft)
-> Just $ over uvWorld (doTerminalEffect (w ^?! uvWorld . terminals . ix tmid)) w
( DisplayInventory (CombineInventory mi) , ButtonLeft)
-> Just $ fromMaybe (w & uvWorld . hud . hudElement .~ DisplayInventory NoSubInventory)
$ do -- ugly
@@ -144,30 +144,30 @@ wheelEvent y w = case _hudElement $ _hud w of
| otherwise -> w & moveTweakSel yi
DisplayInventory (CombineInventory _) -> w
& hud . hudElement . subInventory . combineInvSel . _Just %~ ((`mod` numcombs) . subtract yi)
DisplayInventory DisplayTerminal{}
| rbDown -> w
& hud . hudElement . subInventory . termParams %~ updatetermsubsel
| otherwise -> w
& hud . hudElement . subInventory . termParams %~ updatetermsel
-- DisplayInventory (DisplayTerminal tmid True)
-- | rbDown -> w
-- & terminals . ix tmid %~ updatetermsubsel
-- | otherwise -> w
-- & terminals . ix tmid %~ updatetermsel
_ -> w
where
updatetermsel tp = case _termSel tp of
Nothing -> tp & termSel ?~ (0,0)
& termInput . _Just %~ replacewith tp 0
Just (i,_) -> let newi = ((`mod` length (_termScrollCommands tp)) . subtract yi) i
in tp & termSel . _Just .~ (newi,0)
& termInput . _Just %~ replacewith tp newi
updatetermsubsel tp = case _termSel tp of
Nothing -> tp
Just (i,j) -> let newj = (j - yi) `mod` (1 + length (_tcArguments (_termScrollCommands tp !! i) w))
in tp & termSel . _Just .~ (i,newj)
& termInput . _Just %~ replacewith' tp i newj w
replacewith tp newi _ = T.pack (_tcString (_termScrollCommands tp !! newi))
replacewith' tp i j w' _ = T.pack $ _tcString tc ++ " " ++ arg-- ++ ((_tcArguments tp) w !! j)
where
arg :: String
arg = ("": _tcArguments tc w' )!! j
tc = _termScrollCommands tp !! i
-- updatetermsel tp = case _tmSel tp of
-- Nothing -> tp & tmSel ?~ (0,0)
-- & tmInput . _Just %~ replacewith tp 0
-- Just (i,_) -> let newi = ((`mod` length (_tmScrollCommands tp)) . subtract yi) i
-- in tp & tmSel . _Just .~ (newi,0)
-- & tmInput . _Just %~ replacewith tp newi
-- updatetermsubsel tp = case _tmSel tp of
-- Nothing -> tp
-- Just (i,j) -> let newj = (j - yi) `mod` (1 + length (_tcArguments (_tmScrollCommands tp !! i) tp w))
-- in tp & tmSel . _Just .~ (i,newj)
-- & tmInput . _Just %~ replacewith' tp i newj w
-- replacewith tp newi _ = T.pack (_tcString (_tmScrollCommands tp !! newi))
-- replacewith' tp i j w' _ = T.pack $ _tcString tc ++ " " ++ arg-- ++ ((_tcArguments tp) w !! j)
-- where
-- arg :: String
-- arg = ("": _tcArguments tc w' )!! j
-- tc = _tmScrollCommands tp !! i
numcombs = length $ combineItemListYou w
yi = round $ signum y
numLocs = (fst . IM.findMax $ _seenLocations w) + 1