Slightly tweak number displays

This commit is contained in:
2025-01-08 00:21:17 +00:00
parent 5fa5bdf21e
commit 47aa8655b1
3 changed files with 62 additions and 53 deletions
+7 -14
View File
@@ -40,9 +40,9 @@ invSelectionItem w indent loc =
-- 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
itemDisplay w cr ci = -- f
(basicItemDisplay itm)
(itemNumberDisplay w cr ci)
-- (itemNumberDisplay w cr ci)
`g` anyextra
where
itm = ci ^. _1
@@ -53,7 +53,7 @@ itemDisplay w cr ci = f
--g (x:xs) (y:_) = (rightPad 15 ' ' x ++ y) : xs
g (x:xs) (y:_) = (x ++ y) : xs
g xs _ = xs
anyextra = maybeToList (anyscroll <> anyhotkey <> anyequippos)
anyextra = maybeToList (anyscroll <> anyexternal <> anyhotkey <> anyequippos)
anyhotkey = fmap hotkeyToString
(w ^? cWorld . lWorld . imHotkeys . unNIntMap . ix itid)
anyequippos = do
@@ -61,21 +61,14 @@ itemDisplay w cr ci = f
epText <$> ci ^? _1 . itLocation . ilEquipSite
anyscroll = fmap absurround $ itemScrollDisplay =<< (ci ^? _1)
absurround str = " <" ++ str ++ ">"
anyexternal = fae <$> itemExternalValue itm w cr
-- will probably want to remote the !
fae (Left i) = " !"++shortShow i
fae (Right s) = " !" ++ s
epText :: Maybe EquipSite -> [Char]
epText (Just ep) = ' ' : rightPad 8 ' ' ('@' : eqPosText ep)
epText Nothing = " @NOT.EQP"
--epText Nothing = " ¬EQUIPED"
itemIntegralValue :: Item -> Maybe (Either Int String)
itemIntegralValue itm
| Just x <- itm ^? itUse . uInt = Just (Left x)
| Just x <- itm ^? itUse . useToggle = Just (Right $ show x)
| isJust $ itm ^? itTargeting . itTgPos . _Just = Just $ Right "!TARGETING"
| Just x <- itm ^? itConsumables . magLoadStatus . iaLoaded = Just $ Left x
| UseAttach (APInt i) <- itm ^. itUse = Just $ Left i
| UseAttach (APProjectiles x) <- itm ^. itUse = Just . Right $ show x
| otherwise = mempty
introScanValue :: Creature -> IntroScanType -> Either Int String
introScanValue cr = \case
+17 -1
View File
@@ -6,6 +6,7 @@ module Dodge.Item.Display (
basicItemDisplay,
) where
import ShortShow
import Data.Maybe
import Dodge.Data.World
import Dodge.Item.InvSize
@@ -19,9 +20,24 @@ import LensHelp
basicItemDisplay :: Item -> [String]
basicItemDisplay itm =
Prelude.take (itInvHeight itm) $
itemBaseName (itm ^. itType) :
(itemBaseName (itm ^. itType) ++ anyinternalvalue) :
catMaybes [maybeWarmupStatus itm]
++ repeat "*"
where
anyinternalvalue = maybe "" f $ itemInternalValue itm
f (Left i) = ' ':shortShow i
f (Right s) = ' ':s
itemInternalValue :: Item -> Maybe (Either Int String)
itemInternalValue itm
| Just x <- itm ^? itUse . uInt = Just (Left x)
| Just x <- itm ^? itUse . useToggle = Just (Right $ show x)
| isJust $ itm ^? itTargeting . itTgPos . _Just = Just $ Right "!TARGETING"
| Just x <- itm ^? itConsumables . magLoadStatus . iaLoaded = Just $ Left x
| UseAttach (APInt i) <- itm ^. itUse = Just $ Left i
| UseAttach (APProjectiles x) <- itm ^. itUse = Just . Right $ show x
| otherwise = mempty
maybeWarmupStatus :: Item -> Maybe String
maybeWarmupStatus it = case it ^? itUse . heldDelay . warmMax of