Tweak display, scrolling of item values

This commit is contained in:
2025-01-07 21:10:29 +00:00
parent b3cf10bd26
commit 5fa5bdf21e
18 changed files with 367 additions and 384 deletions
+74 -40
View File
@@ -47,24 +47,61 @@ itemDisplay w cr ci = f
where
itm = ci ^. _1
NInt itid = itm ^. itID
f (x:xs) (y:_) = itemDisplayPad x y : xs
--f (x:xs) (y:_) = itemDisplayPad x y : xs
f (x:xs) (y:_) = (x ++ ' ': y) : xs
f xs _ = xs
g (x:xs) (y:_) = (rightPad 15 ' ' x ++ y) : xs
--g (x:xs) (y:_) = (rightPad 15 ' ' x ++ y) : xs
g (x:xs) (y:_) = (x ++ y) : xs
g xs _ = xs
anyextra = maybeToList (anyhotkey <> anyequippos <> anyscroll)
anyextra = maybeToList (anyscroll <> anyhotkey <> anyequippos)
anyhotkey = fmap hotkeyToString
(w ^? cWorld . lWorld . imHotkeys . unNIntMap . ix itid)
anyequippos = fmap
(rightPad 8 ' ' . (' ' :) . eqPosText)
(ci ^? _1 . itLocation . ilEquipSite . _Just)
anyscroll = fmap absurround $ itemScrollDisplay =<< (ci ^? _1 . itScroll)
absurround str = '<' : str ++ ">"
anyequippos = do
_ <- ci ^? _1 . itUse . uequipEffect
epText <$> ci ^? _1 . itLocation . ilEquipSite
anyscroll = fmap absurround $ itemScrollDisplay =<< (ci ^? _1)
absurround str = " <" ++ str ++ ">"
itemScrollDisplay :: ItemScroll -> Maybe String
itemScrollDisplay = \case
NoItemScroll -> Nothing
ItemScrollInt i -> Just $ show i
ItemScrollIntRange _ i -> Just $ show i
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
HEALTH -> Left $ cr ^. crHP
MAXHEALTH -> Left $ cr ^. crMaxHP
itemExternalValue :: Item -> World -> Creature -> Maybe (Either Int String)
itemExternalValue itm w cr
| EQUIP WRIST_ECG <- itm ^. itType = Just . Right .
displayPulse $ cr ^?! crType . avatarPulse . pulseProgress
| Just t <- itm ^? itType . ibtIntroScanType = Just $ introScanValue cr t
| ITEMSCAN <- itm ^. itType
, Just ExamineInventory <- w ^? hud . hudElement . subInventory
= Just (Right "ON")
| otherwise = mempty
itemScrollDisplay :: Item -> Maybe String
itemScrollDisplay itm
| HELD ALTERIFLE <- itm ^. itType = Just $
case itm ^? itUse . heldAim . aimMuzzles . ix 0 . mzAmmoSlot of
Just 0 -> "L"
_ -> "R"
| UseScope OpticScope{_opticZoom = x} <- itm ^. itUse = Just $ shortShow x
| ItemScrollInt i <- itm ^. itScroll = Just $ show i
| ItemScrollIntRange _ i <- itm ^. itScroll = Just $ show i
| otherwise = Nothing
itemDisplayPad :: [Char] -> String -> [Char]
itemDisplayPad ls rs
@@ -76,19 +113,13 @@ 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"]
, 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 i <- ci ^? _1 . itUse . uaParams . apInt = [show i]
| Just x <- ci ^? _1 . itUse . uaParams . apProjectiles = [show x]
| Just t <- ci ^? _1 . itType . ibtIntroScanType = [introScanDisplay cr t]
| otherwise = mempty
@@ -104,24 +135,27 @@ displayPulse x = take 5 $ drop y "----^-----"
y = min 5 $ x `div` 3
hotkeyToString :: Hotkey -> String
hotkeyToString x = case x of
HotkeyQ -> "[Q]"
HotkeyE -> "[E]"
HotkeyR -> "[R]"
HotkeyZ -> "[Z]"
HotkeyX -> "[X]"
HotkeyC -> "[C]"
HotkeyV -> "[V]"
Hotkey1 -> "[1]"
Hotkey2 -> "[2]"
Hotkey3 -> "[3]"
Hotkey4 -> "[4]"
Hotkey5 -> "[5]"
Hotkey6 -> "[6]"
Hotkey7 -> "[7]"
Hotkey8 -> "[8]"
Hotkey9 -> "[9]"
Hotkey0 -> "[0]"
hotkeyToString x = " [" ++ hotkeyToChar x : "]"
hotkeyToChar :: Hotkey -> Char
hotkeyToChar = \case
HotkeyQ -> 'Q'
HotkeyE -> 'E'
HotkeyR -> 'R'
HotkeyZ -> 'Z'
HotkeyX -> 'X'
HotkeyC -> 'C'
HotkeyV -> 'V'
Hotkey1 -> '1'
Hotkey2 -> '2'
Hotkey3 -> '3'
Hotkey4 -> '4'
Hotkey5 -> '5'
Hotkey6 -> '6'
Hotkey7 -> '7'
Hotkey8 -> '8'
Hotkey9 -> '9'
Hotkey0 -> '0'
closeItemToSelectionItem :: World -> NewInt FloorInt -> Maybe (SelectionItem ())
closeItemToSelectionItem w (NInt i) = do