Cleanup
This commit is contained in:
@@ -22,32 +22,23 @@ import NewInt
|
||||
import Padding
|
||||
import Picture.Base
|
||||
|
||||
--invSelectionItem :: Int -> World -> ComposedItem -> SelectionItem ()
|
||||
invSelectionItem :: World -> Int -> LocationLDT ItemLink ComposedItem -> SelectionItem ()
|
||||
invSelectionItem w indent loc =
|
||||
SelectionItem
|
||||
-- { _siPictures = pics & ix 0 %~ (++ anyequippos ++ anyhotkey)
|
||||
{ _siPictures = pics -- & ix 0 %~ (++ anyequippos ++ anyhotkey)
|
||||
{ _siPictures = itemDisplay w cr ci
|
||||
, _siHeight = itInvHeight $ ci ^. _1
|
||||
, _siWidth = 15
|
||||
, _siIsSelectable = True
|
||||
, _siColor = col
|
||||
, _siColor = itemInvColor ci
|
||||
, _siOffX = indent
|
||||
, _siPayload = ()
|
||||
}
|
||||
where
|
||||
ci = loc ^. locLDT . ldtValue
|
||||
lw = w ^. cWorld . lWorld
|
||||
cr = lw ^?! creatures . ix 0
|
||||
itid = ci ^. _1 . itID . unNInt
|
||||
anyhotkey = maybe [] ((' ' :) . hotkeyToString) (lw ^? imHotkeys . unNIntMap . ix itid)
|
||||
anyequippos = maybe
|
||||
[]
|
||||
(rightPad 8 ' ' . (' ' :) . eqPosText)
|
||||
(ci ^? _1 . itLocation . ilEquipSite . _Just)
|
||||
col = itemInvColor ci
|
||||
pics = itemDisplay w cr ci
|
||||
cr = w ^?! cWorld . lWorld . creatures . ix 0
|
||||
|
||||
-- note the convoluted display of the hotkey/equipment, this was done to avoid a
|
||||
-- space leak
|
||||
itemDisplay :: World -> Creature -> ComposedItem -> [String]
|
||||
itemDisplay w cr ci = f
|
||||
(basicItemDisplay itm)
|
||||
@@ -60,67 +51,18 @@ itemDisplay w cr ci = f
|
||||
f xs _ = xs
|
||||
g (x:xs) (y:_) = (rightPad 15 ' ' x ++ y) : xs
|
||||
g xs _ = xs
|
||||
anyextra = maybe [] ((:[])) (anyhotkey <> anyequippos)
|
||||
anyextra = maybe [] (:[]) (anyhotkey <> anyequippos)
|
||||
anyhotkey = fmap hotkeyToString
|
||||
(w ^? cWorld . lWorld . imHotkeys . unNIntMap . ix itid)
|
||||
-- anyhotkey = maybe [] ((:[]) . hotkeyToString)
|
||||
-- (w ^? cWorld . lWorld . imHotkeys . unNIntMap . ix itid)
|
||||
anyequippos = fmap
|
||||
(rightPad 8 ' ' . (' ' :) . eqPosText)
|
||||
(ci ^? _1 . itLocation . ilEquipSite . _Just)
|
||||
-- anyequippos = maybe
|
||||
-- []
|
||||
-- (rightPad 8 ' ' . (' ' :) . eqPosText)
|
||||
-- (ci ^? _1 . itLocation . ilEquipSite . _Just)
|
||||
|
||||
--itemDisplay :: World -> Creature -> ComposedItem -> [String]
|
||||
--itemDisplay w cr ci =
|
||||
-- zipWithDefaults
|
||||
-- id
|
||||
-- (leftPad 15 ' ')
|
||||
-- itemDisplayPad
|
||||
-- (basicItemDisplay itm)
|
||||
-- (itemNumberDisplay w cr ci)
|
||||
-- where
|
||||
-- itm = ci ^. _1
|
||||
|
||||
zipWithDefaults :: (a -> c) -> (b -> c) -> (a -> b -> c) -> [a] -> [b] -> [c]
|
||||
zipWithDefaults f g h = go
|
||||
where
|
||||
go [] bs = map g bs
|
||||
go as [] = map f as
|
||||
go (a : as) (b : bs) = h a b : go as bs
|
||||
|
||||
itemDisplayPad :: [Char] -> String -> [Char]
|
||||
itemDisplayPad ls rs
|
||||
| rs == "" = ls
|
||||
| otherwise = midPadL 15 ' ' ls (' ' : rs)
|
||||
|
||||
-- this can change, but probably won't when (say) dropped and then picked up
|
||||
-- again
|
||||
-- that is to say, it should not change based on functional positioning
|
||||
--itemNumberDisplay :: World -> Creature -> ComposedItem -> String
|
||||
--itemNumberDisplay w cr ci
|
||||
-- | Just x <- ci ^? _1 . itUse . uInt = show x
|
||||
-- | Just x <- ci ^? _1 . itUse . useToggle = show x
|
||||
-- | ITEMSCAN <- ci ^. _1 . itType
|
||||
-- , Just ExamineInventory <- w ^? hud . hudElement . subInventory
|
||||
-- = "ACTIVE"
|
||||
-- | EQUIP WRIST_ECG <- ci ^. _1 . itType =
|
||||
-- displayPulse $ cr ^?! crType . avatarPulse . pulseProgress
|
||||
-- | HELD ALTERIFLE <- ci ^. _1 . itType =
|
||||
-- case ci ^? _1 . itUse . heldAim . aimMuzzles . ix 0 . mzAmmoSlot of
|
||||
-- Just 0 -> "/"
|
||||
-- _ -> "\\"
|
||||
-- | isJust $ ci ^? _1 . itTargeting . itTgPos . _Just =
|
||||
-- "!TARG!"
|
||||
-- | Just x <- ci ^? _1 . itConsumables . magLoadStatus . iaLoaded = shortShow x
|
||||
-- | UseAttach (APInt i) <- ci ^. _1 . itUse = show i
|
||||
-- | UseAttach (APProjectiles x) <- ci ^. _1 . itUse = show x
|
||||
-- | UseScope OpticScope{_opticZoom = x} <- ci ^. _1 . itUse = shortShow x
|
||||
-- | Just t <- ci ^? _1 . itType . ibtIntroScanType = introScanDisplay cr t
|
||||
-- | otherwise = mempty
|
||||
|
||||
itemNumberDisplay :: World -> Creature -> ComposedItem -> [String]
|
||||
itemNumberDisplay w cr ci
|
||||
| Just x <- ci ^? _1 . itUse . uInt = [show x]
|
||||
@@ -134,8 +76,7 @@ itemNumberDisplay w cr ci
|
||||
case ci ^? _1 . itUse . heldAim . aimMuzzles . ix 0 . mzAmmoSlot of
|
||||
Just 0 -> ["/"]
|
||||
_ -> ["\\"]
|
||||
| isJust $ ci ^? _1 . itTargeting . itTgPos . _Just =
|
||||
["!TARG!"]
|
||||
| isJust $ ci ^? _1 . itTargeting . itTgPos . _Just = ["!TARG!"]
|
||||
| Just x <- ci ^? _1 . itConsumables . magLoadStatus . iaLoaded = [shortShow x]
|
||||
| UseAttach (APInt i) <- ci ^. _1 . itUse = [show i]
|
||||
| UseAttach (APProjectiles x) <- ci ^. _1 . itUse = [show x]
|
||||
|
||||
Reference in New Issue
Block a user