Refactor triplet to Selection datatype

This commit is contained in:
2025-08-26 18:13:27 +01:00
parent 9034c409e1
commit b87c3380b8
16 changed files with 127 additions and 135 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ tryPutItemInInv cid itid w = do
& updateselectionextra invid
where
updateselectionextra i
| cid == 0 = hud . diSelection . _Just . _3 %~ IS.map (f i)
| cid == 0 = hud . diSelection . _Just . slSet %~ IS.map (f i)
| otherwise = id
f j i | i >= _unNInt j = i + 1
| otherwise = i
+1 -1
View File
@@ -97,7 +97,7 @@ setInvPosFromSS w = w
& cWorld . lWorld . creatures . ix 0 . crManipulation . manObject .~ thesel
where
thesel = fromMaybe SelNothing $ do
(i, j, _) <- w ^? hud . diSelection . _Just
Sel i j _ <- w ^? hud . diSelection . _Just
case i of
(-1) -> Just SortInventory
0 -> do
+4 -4
View File
@@ -27,8 +27,8 @@ swapInvItems f i w = fromMaybe w $ do
ss <- w ^? hud . diSections . ix 0 . ssItems
k <- f i ss
let updateselection = case w ^? hud . diSelection . _Just of
Just (0, j,_) | j == k -> hud . diSelection . _Just . _2 .~ i
Just (0, j,_) | j == i -> hud . diSelection . _Just . _2 .~ k
Just (Sel 0 j _) | j == k -> hud . diSelection . _Just . slInt .~ i
Just (Sel 0 j _) | j == i -> hud . diSelection . _Just . slInt .~ k
_ -> id
return $
w
@@ -55,11 +55,11 @@ swapInvItems f i w = fromMaybe w $ do
swapAnyExtraSelection :: Int -> Int -> World -> World
swapAnyExtraSelection i k w = fromMaybe w $ do
is <- w ^? hud . diSelection . _Just . _3
is <- w ^? hud . diSelection . _Just . slSet
let f = if i `IS.member` is then IS.insert k else id
g = if k `IS.member` is then IS.insert i else id
return $
w & hud . diSelection . _Just . _3
w & hud . diSelection . _Just . slSet
%~ (f . g . IS.delete i . IS.delete k)
checkConnection :: SoundOrigin -> SoundID -> Int -> Int -> World -> World