Cleanup, display more information for floor items
This commit is contained in:
@@ -29,9 +29,6 @@ data ItemLocation
|
||||
= InInv
|
||||
{ _ilCrID :: Int
|
||||
, _ilInvID :: NewInt InvInt
|
||||
-- , _ilIsRoot :: Bool -- of any item
|
||||
-- , _ilIsSelected :: Bool
|
||||
--- , _ilIsAttached :: Bool -- to selected item. question: downwards and upwards?
|
||||
, _ilEquipSite :: Maybe EquipSite
|
||||
}
|
||||
| OnTurret {_ilTuID :: Int}
|
||||
|
||||
@@ -4,12 +4,9 @@ module Dodge.Inventory.Location (
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
import Data.Foldable
|
||||
import qualified Data.IntSet as IS
|
||||
import Data.Maybe
|
||||
import Dodge.Base.You
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.Data.DoubleTree
|
||||
import Dodge.Data.Item.Use.Consumption.LoadAction
|
||||
import Dodge.Data.World
|
||||
import Dodge.Item.AimStance
|
||||
@@ -28,28 +25,14 @@ tryGetRootAttachedFromInvID (NInt invid) im = do
|
||||
t <- imroots ^? ix theroot . _2
|
||||
return (theroot, foldMap (IS.singleton . (^?! itLocation . ilInvID . unNInt)) t)
|
||||
|
||||
-- the following assumes that the crManipulation is correct
|
||||
crUpdateItemLocations :: World -> World
|
||||
crUpdateItemLocations lw = fromMaybe lw $ do
|
||||
mo <- lw ^? hud . manObject
|
||||
cinv <- lw ^? cWorld . lWorld . creatures . ix 0 . crInv
|
||||
let crinv = fmap (\k -> lw ^?! cWorld . lWorld . items . ix k) cinv
|
||||
return $ crSetRoots $ IM.foldlWithKey' (crUpdateInvidLocations mo) lw $ _unNIntMap crinv
|
||||
return $ IM.foldlWithKey' crUpdateInvidLocations lw $ _unNIntMap crinv
|
||||
|
||||
crSetRoots :: World -> World
|
||||
crSetRoots w = fromMaybe w Nothing
|
||||
-- $ do
|
||||
-- inv <- w ^? cWorld . lWorld . creatures . ix 0 . crInv
|
||||
-- let cinv = invIMDT $ fmap (\i -> w ^?! cWorld . lWorld . items . ix i) inv
|
||||
-- return $ foldl' f (foldl' g w inv) cinv
|
||||
-- where
|
||||
-- g w' i = w' & cWorld . lWorld . items . ix i . itLocation . ilIsRoot .~ False
|
||||
-- f :: World -> DTree OItem -> World
|
||||
-- f w' x =
|
||||
-- w' & cWorld . lWorld . items . ix (x ^. dtValue . _1 . itID . unNInt) . itLocation . ilIsRoot .~ True
|
||||
|
||||
crUpdateInvidLocations :: ManipulatedObject -> World -> Int -> Item -> World
|
||||
crUpdateInvidLocations mo w invid itm =
|
||||
crUpdateInvidLocations :: World -> Int -> Item -> World
|
||||
crUpdateInvidLocations w invid itm =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix 0 . crInv . ix (NInt invid) .~ itid
|
||||
& cWorld . lWorld . items . ix itid .~ (itm & itLocation .~ newloc)
|
||||
@@ -59,9 +42,6 @@ crUpdateInvidLocations mo w invid itm =
|
||||
InInv
|
||||
{ _ilCrID = 0
|
||||
, _ilInvID = NInt invid
|
||||
-- , _ilIsRoot = Just (NInt invid) == mo ^? hiRootSelectedItem
|
||||
-- , _ilIsSelected = Just (Sel 0 invid) == w ^? hud . diSelection . _Just
|
||||
-- , _ilIsAttached = invid `IS.member` (mo ^. hiAttachedItems)
|
||||
, _ilEquipSite = w ^? cWorld . lWorld . items . ix itid . itLocation . ilEquipSite . _Just
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@ import Picture.Base
|
||||
invSelectionItem :: World -> Int -> LocationDT OItem -> SelectionItem ()
|
||||
invSelectionItem w indent loc =
|
||||
SelItem
|
||||
{ _siPictures = itemDisplay w cr ci
|
||||
{ _siPictures = itemDisplay w (Just cr) $ ci ^. _1
|
||||
, _siHeight = itInvHeight $ ci ^. _1
|
||||
, _siWidth = maximum (15 : (length <$> itemDisplay w cr ci))
|
||||
, _siWidth = maximum (15 : (length <$> itemDisplay w (Just cr) (ci^._1)))
|
||||
, _siIsSelectable = True
|
||||
, _siColor = itemInvColor ci
|
||||
, _siOffX = indent
|
||||
@@ -51,10 +51,9 @@ invSelectionItem w indent loc =
|
||||
|
||||
-- note the convoluted display of the hotkey/equipment, this was done to avoid a
|
||||
-- space leak
|
||||
itemDisplay :: World -> Creature -> CItem -> [String]
|
||||
itemDisplay w cr ci = basicItemDisplay itm `g` anyextra
|
||||
itemDisplay :: World -> Maybe Creature -> Item -> [String]
|
||||
itemDisplay w mcr itm = basicItemDisplay itm `g` anyextra
|
||||
where
|
||||
itm = ci ^. _1
|
||||
NInt itid = itm ^. itID
|
||||
g (x:xs) (Just y) = (x <> y) : xs
|
||||
g xs _ = xs
|
||||
@@ -62,11 +61,11 @@ itemDisplay w cr ci = basicItemDisplay itm `g` anyextra
|
||||
anyhotkey = fmap hotkeyToString
|
||||
(w ^? cWorld . lWorld . imHotkeys . unNIntMap . ix itid)
|
||||
anyequippos = do
|
||||
_ <- ci ^? _1 . itType . ibtEquip
|
||||
epText <$> ci ^? _1 . itLocation . ilEquipSite
|
||||
anyscroll = fmap absurround $ itemScrollDisplay =<< (ci ^? _1)
|
||||
_ <- itm ^? itType . ibtEquip
|
||||
epText <$> itm ^? itLocation . ilEquipSite
|
||||
anyscroll = fmap absurround $ itemScrollDisplay =<< Just itm
|
||||
absurround str = " <" ++ str ++ ">"
|
||||
anyexternal = fae <$> itemExternalValue itm w cr
|
||||
anyexternal = fae <$> (itemExternalValue itm w =<< mcr)
|
||||
-- will probably want to remote the !
|
||||
fae (Left i) = " !"++shortShow i
|
||||
fae (Right s) = " !" ++ s
|
||||
@@ -221,7 +220,8 @@ hotkeyToChar = \case
|
||||
closeItemToSelectionItem :: World -> Int -> Maybe (SelectionItem ())
|
||||
closeItemToSelectionItem w i = do
|
||||
e <- w ^? cWorld . lWorld . items . ix i
|
||||
let (pics, col) = closeItemToTextPictures e
|
||||
let pics = itemDisplay w Nothing e
|
||||
col = itemInvColor (baseCI e)
|
||||
return
|
||||
SelItem
|
||||
{ _siPictures = pics
|
||||
@@ -260,6 +260,3 @@ btText bt = case _btEvent bt of
|
||||
ButtonSwitch {} -> "SWITCH"
|
||||
ButtonDumbSwitch {} -> "SWITCH" -- do we want to show switch status?
|
||||
ButtonAccessTerminal i -> "TERMINAL " ++ show i
|
||||
|
||||
closeItemToTextPictures :: Item -> ([String], Color)
|
||||
closeItemToTextPictures it = (basicItemDisplay it, itemInvColor $ baseCI it)
|
||||
|
||||
@@ -600,24 +600,12 @@ getCloseObj w = getSelectedCloseObj w <|> topcitem <|> topcbut
|
||||
tryCombine :: (Int, Int) -> World -> World
|
||||
tryCombine (i, j) w = fromMaybe w $ do
|
||||
CombItem is it <-
|
||||
w
|
||||
^? hud
|
||||
. subInventory
|
||||
. ciSections
|
||||
. ix i
|
||||
. ssItems
|
||||
. ix j
|
||||
. siPayload
|
||||
. _Just
|
||||
w ^? hud . subInventory . ciSections . ix i . ssItems . ix j . siPayload . _Just
|
||||
p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos . _xy
|
||||
return $
|
||||
createItemYou it (foldr (destroyInvItem 0 . NInt) w (sort is))
|
||||
& soundStart InventorySound p wrench1S Nothing
|
||||
& hud
|
||||
. diSections
|
||||
. ix 1
|
||||
. ssSet
|
||||
.~ mempty
|
||||
& hud . diSections . ix 1 . ssSet .~ mempty
|
||||
|
||||
-- & hud . diSelection . _Just . slSet .~ mempty
|
||||
|
||||
|
||||
Reference in New Issue
Block a user