Allow for custom reloading sounds
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
module Dodge.Item.Display where
|
||||
module Dodge.Item.Display
|
||||
where
|
||||
import Dodge.Module
|
||||
import Dodge.Data
|
||||
import Dodge.Inventory.ItemSpace
|
||||
@@ -11,6 +12,23 @@ import Data.Sequence
|
||||
itemString :: Item -> String
|
||||
itemString = head . itemDisplay
|
||||
|
||||
selectedItemDisplay :: Creature -> Item -> [String]
|
||||
selectedItemDisplay cr it = Prelude.take (itSlotsTaken it) $
|
||||
(midPadL 15 ' ' thename (' ' : thenumber) ++ theparam)
|
||||
: catMaybes [maybeWarmupStatus it]
|
||||
++ moduleStrings it ++ repeat "*"
|
||||
where
|
||||
thename = show . _iyBase $ _itType it
|
||||
thenumber = showSelectedConsumption cr (_itConsumption it)
|
||||
theparam = fromMaybe []
|
||||
. listToMaybe
|
||||
$ mapMaybe ($ it)
|
||||
[ maybeModeStatus
|
||||
-- , maybeWarmupStatus
|
||||
-- , maybeRateStatus
|
||||
]
|
||||
|
||||
|
||||
{- | Displays the item name, ammo if loaded, and any selected '_itCharMode'. -}
|
||||
-- TODO make work on remote launchers
|
||||
itemDisplay :: Item -> [String]
|
||||
@@ -28,17 +46,31 @@ itemDisplay it = Prelude.take (itSlotsTaken it) $
|
||||
-- , maybeWarmupStatus
|
||||
-- , maybeRateStatus
|
||||
]
|
||||
showSelectedConsumption :: Creature -> ItemConsumption -> String
|
||||
showSelectedConsumption cr ic = case ic of
|
||||
LoadableAmmo{} -> showReloadProgress cr ic
|
||||
ChargeableAmmo{} -> show $ _wpCharge ic
|
||||
ItemItselfConsumable{} -> show (_icAmount ic)
|
||||
NoConsumption -> ""
|
||||
|
||||
showReloadProgress :: Creature -> ItemConsumption -> String
|
||||
showReloadProgress cr ic = case cr ^?! crInvSel . iselAction of
|
||||
ReloadAction i la _ -> show i ++ showLoadActionType la
|
||||
_ -> case ic ^? laProgress . _Just . ix 0 of
|
||||
Nothing -> show $ _laLoaded ic
|
||||
Just la -> show (_actionTime la) ++ showLoadActionType la
|
||||
|
||||
showLoadProgress :: Int -> Maybe [LoadAction] -> String
|
||||
showLoadProgress x mlas = case mlas ^? _Just . ix 0 of
|
||||
Just la -> show (_actionTime la) ++ showLoadActionType la
|
||||
Nothing -> show x
|
||||
|
||||
showConsumption :: ItemConsumption -> String
|
||||
showConsumption ic = case ic of
|
||||
am@LoadableAmmo{} -> showLoading ic ++ show (_laLoaded am)
|
||||
LoadableAmmo{} -> showLoadProgress (_laLoaded ic) (_laProgress ic)
|
||||
am@ChargeableAmmo{} -> show $ _wpCharge am
|
||||
x@ItemItselfConsumable{} -> show (_icAmount x)
|
||||
NoConsumption -> ""
|
||||
showLoading :: ItemConsumption -> String
|
||||
showLoading ic = case ic ^? laProgress . _Just . ix 0 of
|
||||
Just la -> showLoadActionType la
|
||||
Nothing -> ""
|
||||
showLoadActionType :: LoadAction -> String
|
||||
showLoadActionType la = case la of
|
||||
Eject {} -> "E"
|
||||
|
||||
Reference in New Issue
Block a user