Make hud non-saveable

This commit is contained in:
2022-12-29 01:10:09 +00:00
parent be41d51819
commit 7fc3b788b4
17 changed files with 57 additions and 59 deletions
+15 -14
View File
@@ -30,7 +30,8 @@ import Dodge.Inventory.Color
import qualified Data.Map.Strict as M
import Data.Maybe
import Dodge.Base
import Dodge.Data.Universe
import Dodge.Data.World
import Dodge.Data.Config
import Dodge.Euse
import Dodge.Inventory.CheckSlots
import Dodge.Inventory.CloseObject
@@ -107,7 +108,7 @@ trimapAugmentInv f x g w =
IM.insert n x $
IM.union
(f <$> yourInv w)
(IM.fromAscList $ zip [n + 1 ..] $ map g $ w ^. cWorld . lWorld . closeObjects)
(IM.fromAscList $ zip [n + 1 ..] $ map g $ w ^. hud . closeObjects)
where
n = length $ yourInv w
@@ -152,8 +153,8 @@ updateTerminal :: World -> World
updateTerminal = checkTermDist
checkTermDist :: World -> World
checkTermDist w = case w ^? cWorld . lWorld . hud . hudElement . subInventory . termID of
Just tmid -> fromMaybe (w & cWorld . lWorld . hud . hudElement . subInventory .~ NoSubInventory) $ do
checkTermDist w = case w ^? hud . hudElement . subInventory . termID of
Just tmid -> fromMaybe (w & hud . hudElement . subInventory .~ NoSubInventory) $ do
btid <- w ^? cWorld . lWorld . terminals . ix tmid . tmButtonID
btpos <- w ^? cWorld . lWorld . buttons . ix btid . btPos
if dist btpos (_crPos $ you w) < 40 then Just w else Nothing
@@ -163,7 +164,7 @@ checkTermDist w = case w ^? cWorld . lWorld . hud . hudElement . subInventory .
updateCloseObjects :: World -> World
updateCloseObjects w =
w
& cWorld . lWorld . closeObjects .~ unionBy closeObjEq oldCloseFiltered currentClose
& hud . closeObjects .~ unionBy closeObjEq oldCloseFiltered currentClose
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ updateinvsel
where
updateinvsel curinvsel
@@ -178,7 +179,7 @@ updateCloseObjects w =
. IM.elems
$ w ^. cWorld . lWorld . buttons
currentClose = filt $ map Left (IM.elems $ w ^. cWorld . lWorld . floorItems) ++ activeButtons
oldClose = filt $ mapMaybe updatebyid $ w ^. cWorld . lWorld . closeObjects
oldClose = filt $ mapMaybe updatebyid $ w ^. hud . closeObjects
oldCloseFiltered = intersectBy closeObjEq oldClose currentClose
updatebyid (Left flid) = fmap Left $ w ^? cWorld . lWorld . floorItems . ix (_flItID flid)
updatebyid (Right btid) = fmap Right $ w ^? cWorld . lWorld . buttons . ix (_btID btid)
@@ -304,8 +305,8 @@ equipSiteToPositions es = case es of
closeObjScrollDir :: Float -> World -> World
closeObjScrollDir x
| x > 0 = over (cWorld . lWorld . closeObjects) rotU
| x < 0 = over (cWorld . lWorld . closeObjects) rotD
| x > 0 = over (hud . closeObjects) rotU
| x < 0 = over (hud . closeObjects) rotD
| otherwise = id
changeInvSel :: Int -> World -> World
@@ -323,7 +324,7 @@ changeInvSel i w
-- arguably this should jump the invpos into the inventory proper
pointcrInvSel = cWorld . lWorld . creatures . ix 0 . crInvSel
n = length $ w ^?! cWorld . lWorld . creatures . ix 0 . crInv
numCO = length $ w ^. cWorld . lWorld . closeObjects
numCO = length $ w ^. hud . closeObjects
changeSwapInvSel :: Int -> World -> World
changeSwapInvSel k w
@@ -333,7 +334,7 @@ changeSwapInvSel k w
| yourInvSel w > n =
w
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos .~ ico'
& cWorld . lWorld . closeObjects %~ swapIndices (i - (n+1)) (ico' - (n+1))
& hud . closeObjects %~ swapIndices (i - (n+1)) (ico' - (n+1))
| otherwise = w
where
updatecreature =
@@ -355,7 +356,7 @@ changeSwapInvSel k w
i = crSel cr
ico' = ((i - (k + n + 1)) `mod` numCO) + n + 1
n = length $ _crInv cr
numCO = length $ w ^. cWorld . lWorld . closeObjects
numCO = length $ w ^. hud . closeObjects
changeAugInvSel :: Int -> World -> World
changeAugInvSel i w
@@ -365,10 +366,10 @@ changeAugInvSel i w
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ (`mod` n) . subtract i
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselAction .~ NoInvSelAction
where
n = length (yourInv w) + length (w ^. cWorld . lWorld . closeObjects) + 1
n = length (yourInv w) + length (w ^. hud . closeObjects) + 1
bestCloseObjectIndex :: World -> Maybe Int
bestCloseObjectIndex w = findIndex f $ w ^. cWorld . lWorld . closeObjects
bestCloseObjectIndex w = findIndex f $ w ^. hud . closeObjects
where
f (Right _) = True
f (Left flit) = itSlotsTaken (_flIt flit) <= _crInvCapacity ycr - crInvSize ycr
@@ -384,4 +385,4 @@ selectedCloseObject w
inv = _crInv cr
selectNthCloseObject :: World -> Int -> Maybe (Int, Either FloorItem Button)
selectNthCloseObject w n = (length (yourInv w) + n + 1,) <$> (_closeObjects (_lWorld (_cWorld w)) !? n)
selectNthCloseObject w n = (length (yourInv w) + n + 1,) <$> (_closeObjects (_hud w) !? n)