Fix bug on dropping item when reloading
This commit is contained in:
+15
-27
@@ -1,4 +1,8 @@
|
||||
module Dodge.Item.Display
|
||||
( itemDisplay
|
||||
, selectedItemDisplay
|
||||
, itemString
|
||||
)
|
||||
where
|
||||
import Dodge.Module
|
||||
import Dodge.Data
|
||||
@@ -12,40 +16,27 @@ 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]
|
||||
itemDisplayWithNumber :: String -> Item -> [String]
|
||||
itemDisplayWithNumber numberstr it = Prelude.take (itSlotsTaken it) $
|
||||
(midPadL 15 ' ' thename (' ' : numberstr) ++ theparam)
|
||||
: catMaybes [maybeWarmupStatus it,maybeRateStatus it]
|
||||
++ moduleStrings it ++ repeat "*"
|
||||
where
|
||||
thename = show . _iyBase $ _itType it
|
||||
thenumber = showSelectedConsumption cr (_itConsumption it)
|
||||
theparam = fromMaybe []
|
||||
. listToMaybe
|
||||
$ mapMaybe ($ it)
|
||||
[ maybeModeStatus
|
||||
-- , maybeWarmupStatus
|
||||
-- , maybeRateStatus
|
||||
]
|
||||
|
||||
selectedItemDisplay :: Creature -> Item -> [String]
|
||||
selectedItemDisplay cr it = itemDisplayWithNumber (showSelectedConsumption cr (_itConsumption it)) it
|
||||
|
||||
{- | Displays the item name, ammo if loaded, and any selected '_itCharMode'. -}
|
||||
-- TODO make work on remote launchers
|
||||
itemDisplay :: Item -> [String]
|
||||
itemDisplay it = Prelude.take (itSlotsTaken it) $
|
||||
(midPadL 15 ' ' thename (' ' : thenumber) ++ theparam)
|
||||
: catMaybes [maybeWarmupStatus it]
|
||||
++ moduleStrings it ++ repeat "*"
|
||||
where
|
||||
thename = show . _iyBase $ _itType it
|
||||
thenumber = showConsumption (_itConsumption it)
|
||||
theparam = fromMaybe []
|
||||
. listToMaybe
|
||||
$ mapMaybe ($ it)
|
||||
[ maybeModeStatus
|
||||
-- , maybeWarmupStatus
|
||||
-- , maybeRateStatus
|
||||
]
|
||||
itemDisplay it = itemDisplayWithNumber (showConsumption (_itConsumption it)) it
|
||||
|
||||
showSelectedConsumption :: Creature -> ItemConsumption -> String
|
||||
showSelectedConsumption cr ic = case ic of
|
||||
LoadableAmmo{} -> showReloadProgress cr ic
|
||||
@@ -68,9 +59,10 @@ showLoadProgress x mlas = case mlas ^? _Just . ix 0 of
|
||||
showConsumption :: ItemConsumption -> String
|
||||
showConsumption ic = case ic of
|
||||
LoadableAmmo{} -> showLoadProgress (_laLoaded ic) (_laProgress ic)
|
||||
am@ChargeableAmmo{} -> show $ _wpCharge am
|
||||
x@ItemItselfConsumable{} -> show (_icAmount x)
|
||||
ChargeableAmmo{} -> show $ _wpCharge ic
|
||||
ItemItselfConsumable{} -> show (_icAmount ic)
|
||||
NoConsumption -> ""
|
||||
|
||||
showLoadActionType :: LoadAction -> Int -> String
|
||||
showLoadActionType la x = case la of
|
||||
LoadEject {} -> "E"
|
||||
@@ -78,10 +70,6 @@ showLoadActionType la x = case la of
|
||||
LoadAdd {} -> "A" ++ show x
|
||||
LoadPrime {} -> "P"
|
||||
|
||||
-- & itInvDisplay .~ \it -> head (basicItemDisplay it) :
|
||||
-- ["*FIRERATE:" ++ fromMaybe "" (maybeRateStatus it)
|
||||
-- ]
|
||||
|
||||
maybeWarmupStatus :: Item -> Maybe String
|
||||
maybeWarmupStatus it = case it ^? itUse . useDelay . warmMax of
|
||||
Nothing -> Nothing
|
||||
|
||||
Reference in New Issue
Block a user