Remove _ilIsSelected, _ilIsRoot

This commit is contained in:
2026-05-16 12:45:14 +01:00
parent ef70c85b79
commit ec969c924a
4 changed files with 31 additions and 25 deletions
+4 -7
View File
@@ -29,8 +29,8 @@ data ItemLocation
= InInv = InInv
{ _ilCrID :: Int { _ilCrID :: Int
, _ilInvID :: NewInt InvInt , _ilInvID :: NewInt InvInt
, _ilIsRoot :: Bool -- of any item -- , _ilIsRoot :: Bool -- of any item
, _ilIsSelected :: Bool -- , _ilIsSelected :: Bool
--- , _ilIsAttached :: Bool -- to selected item. question: downwards and upwards? --- , _ilIsAttached :: Bool -- to selected item. question: downwards and upwards?
, _ilEquipSite :: Maybe EquipSite , _ilEquipSite :: Maybe EquipSite
} }
@@ -40,12 +40,9 @@ data ItemLocation
deriving (Eq, Show, Ord, Read) --Generic, Flat) deriving (Eq, Show, Ord, Read) --Generic, Flat)
instance ShortShow ItemLocation where instance ShortShow ItemLocation where
shortShow (InInv cid invid rootb selb esite) = shortShow (InInv cid invid esite) =
"InInv:cid" <> shortShow cid <> "invid" <> shortShow (_unNInt invid) "InInv:cid" <> shortShow cid <> "invid" <> shortShow (_unNInt invid)
<> "root" <> "esite"
<> shortShow rootb
<> "sel"
<> shortShow selb
<> shortShow (fmap (SString . show) esite) <> shortShow (fmap (SString . show) esite)
shortShow x = show x shortShow x = show x
+2 -2
View File
@@ -29,8 +29,8 @@ tryPutItemInInv mcipos itid w = do
let itloc = InInv let itloc = InInv
{ _ilCrID = 0 { _ilCrID = 0
, _ilInvID = invid , _ilInvID = invid
, _ilIsRoot = False -- , _ilIsRoot = False
, _ilIsSelected = False -- , _ilIsSelected = False
-- , _ilIsAttached = False -- , _ilIsAttached = False
, _ilEquipSite = Nothing , _ilEquipSite = Nothing
} }
+12 -11
View File
@@ -37,15 +37,16 @@ crUpdateItemLocations lw = fromMaybe lw $ do
return $ crSetRoots $ IM.foldlWithKey' (crUpdateInvidLocations mo) lw $ _unNIntMap crinv return $ crSetRoots $ IM.foldlWithKey' (crUpdateInvidLocations mo) lw $ _unNIntMap crinv
crSetRoots :: World -> World crSetRoots :: World -> World
crSetRoots w = fromMaybe w $ do crSetRoots w = fromMaybe w Nothing
inv <- w ^? cWorld . lWorld . creatures . ix 0 . crInv -- $ do
let cinv = invIMDT $ fmap (\i -> w ^?! cWorld . lWorld . items . ix i) inv -- inv <- w ^? cWorld . lWorld . creatures . ix 0 . crInv
return $ foldl' f (foldl' g w inv) cinv -- let cinv = invIMDT $ fmap (\i -> w ^?! cWorld . lWorld . items . ix i) inv
where -- return $ foldl' f (foldl' g w inv) cinv
g w' i = w' & cWorld . lWorld . items . ix i . itLocation . ilIsRoot .~ False -- where
f :: World -> DTree OItem -> World -- g w' i = w' & cWorld . lWorld . items . ix i . itLocation . ilIsRoot .~ False
f w' x = -- f :: World -> DTree OItem -> World
w' & cWorld . lWorld . items . ix (x ^. dtValue . _1 . itID . unNInt) . itLocation . ilIsRoot .~ True -- f w' x =
-- w' & cWorld . lWorld . items . ix (x ^. dtValue . _1 . itID . unNInt) . itLocation . ilIsRoot .~ True
crUpdateInvidLocations :: ManipulatedObject -> World -> Int -> Item -> World crUpdateInvidLocations :: ManipulatedObject -> World -> Int -> Item -> World
crUpdateInvidLocations mo w invid itm = crUpdateInvidLocations mo w invid itm =
@@ -58,8 +59,8 @@ crUpdateInvidLocations mo w invid itm =
InInv InInv
{ _ilCrID = 0 { _ilCrID = 0
, _ilInvID = NInt invid , _ilInvID = NInt invid
, _ilIsRoot = Just (NInt invid) == mo ^? hiRootSelectedItem -- , _ilIsRoot = Just (NInt invid) == mo ^? hiRootSelectedItem
, _ilIsSelected = Just (Sel 0 invid) == w ^? hud . diSelection . _Just -- , _ilIsSelected = Just (Sel 0 invid) == w ^? hud . diSelection . _Just
-- , _ilIsAttached = invid `IS.member` (mo ^. hiAttachedItems) -- , _ilIsAttached = invid `IS.member` (mo ^. hiAttachedItems)
, _ilEquipSite = w ^? cWorld . lWorld . items . ix itid . itLocation . ilEquipSite . _Just , _ilEquipSite = w ^? cWorld . lWorld . items . ix itid . itLocation . ilEquipSite . _Just
} }
+13 -5
View File
@@ -36,9 +36,14 @@ rootNotrootEff ::
Creature -> Creature ->
World -> World ->
World World
rootNotrootEff f g it rootNotrootEff f g it cr w
| it ^? itLocation . ilIsRoot == Just True = f it | isroot = f it cr w
| otherwise = g it | otherwise = g it cr w
where
isroot = fromMaybe False $ do
i <- it ^? itLocation . ilInvID
j <- w ^? hud . manObject . hiRootSelectedItem
return $ i == j
rootAndAttNotEff :: rootAndAttNotEff ::
(Item -> Creature -> World -> World) -> (Item -> Creature -> World -> World) ->
@@ -48,8 +53,7 @@ rootAndAttNotEff ::
World -> World ->
World World
rootAndAttNotEff f g it cr w rootAndAttNotEff f g it cr w
| it ^? itLocation . ilIsRoot == Just True | isroot && isattached
&& isattached
= f it cr w = f it cr w
| otherwise = g it cr w | otherwise = g it cr w
where where
@@ -57,6 +61,10 @@ rootAndAttNotEff f g it cr w
i <- it ^? itLocation . ilInvID . unNInt i <- it ^? itLocation . ilInvID . unNInt
is <- w ^? hud . manObject . hiAttachedItems is <- w ^? hud . manObject . hiAttachedItems
return $ i `IS.member` is return $ i `IS.member` is
isroot = fromMaybe False $ do
i <- it ^? itLocation . ilInvID
j <- w ^? hud . manObject . hiRootSelectedItem
return $ i == j
createShieldWall :: Item -> Creature -> World -> World createShieldWall :: Item -> Creature -> World -> World
createShieldWall it cr w = case it ^? itParams . flatShieldWlMIX . _Just of createShieldWall it cr w = case it ^? itParams . flatShieldWlMIX . _Just of