Cleanup and fix selection section cursor position bug
This commit is contained in:
@@ -34,23 +34,19 @@ useItemRightClick cr' w = fromMaybe (f w) $ do
|
|||||||
itemEffect :: Creature -> Item -> World -> World
|
itemEffect :: Creature -> Item -> World -> World
|
||||||
itemEffect cr it w = case it ^. itUse of
|
itemEffect cr it w = case it ^. itUse of
|
||||||
HeldUse{_heldUse = eff, _heldMods = usemods} ->
|
HeldUse{_heldUse = eff, _heldMods = usemods} ->
|
||||||
hammerTest $ foldl' (&) (useHeld eff) (useMod usemods) it cr
|
foldl' (&) (useHeld eff) (useMod usemods) it cr w
|
||||||
LeftUse{} -> doequipmentchange
|
LeftUse{} -> doequipmentchange
|
||||||
EquipUse{} -> doequipmentchange
|
EquipUse{} -> doequipmentchange
|
||||||
-- ConsumeUse will cause problems if the item is not selected
|
-- ConsumeUse will cause problems if the item is not selected
|
||||||
(ConsumeUse eff _) -> setuhamdown $ hammerTest $ useC eff it cr . rmInvItem (_crID cr) itRef
|
(ConsumeUse eff _) -> useC eff it cr $ rmInvItem (_crID cr) itRef w
|
||||||
CraftUse{} -> setuhamdown w
|
CraftUse{} -> w
|
||||||
where
|
where
|
||||||
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
hammerTest f = case _crHammerPosition cr of
|
hammerTest f = case _crHammerPosition cr of
|
||||||
HammerUp -> f w
|
HammerUp -> f w & setuhamdown
|
||||||
_ -> w & setuhamdown
|
_ -> w & setuhamdown
|
||||||
setuhamdown = cWorld . lWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
|
setuhamdown = cWorld . lWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
|
||||||
doequipmentchange =
|
doequipmentchange = hammerTest $ toggleEquipmentAt itRef cr
|
||||||
setuhamdown $
|
|
||||||
hammerTest
|
|
||||||
( toggleEquipmentAt itRef cr
|
|
||||||
)
|
|
||||||
|
|
||||||
toggleEquipmentAt :: Int -> Creature -> World -> World
|
toggleEquipmentAt :: Int -> Creature -> World -> World
|
||||||
toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ basicItemDisplay itm =
|
|||||||
itemBaseName itm :
|
itemBaseName itm :
|
||||||
catMaybes [maybeWarmupStatus itm, maybeRateStatus itm]
|
catMaybes [maybeWarmupStatus itm, maybeRateStatus itm]
|
||||||
++ moduleStrings itm
|
++ moduleStrings itm
|
||||||
++ repeat "\\"
|
++ repeat "*"
|
||||||
|
|
||||||
itemString :: Item -> String
|
itemString :: Item -> String
|
||||||
itemString = head . basicItemDisplay
|
itemString = head . basicItemDisplay
|
||||||
@@ -78,7 +78,7 @@ showAutoRechargeProgress lc = case lc of
|
|||||||
|
|
||||||
itemNumberDisplay :: Creature -> Item -> [String]
|
itemNumberDisplay :: Creature -> Item -> [String]
|
||||||
itemNumberDisplay cr itm = case iu of
|
itemNumberDisplay cr itm = case iu of
|
||||||
HeldUse{} -> [showReloadProgress' cr itm]
|
HeldUse{} -> [showReloadProgress cr itm]
|
||||||
LeftUse{} -> [showAutoRechargeProgress (_leftConsumption iu)]
|
LeftUse{} -> [showAutoRechargeProgress (_leftConsumption iu)]
|
||||||
EquipUse{} -> showEquipmentNumber cr itm
|
EquipUse{} -> showEquipmentNumber cr itm
|
||||||
_ -> [show $ iu ^?! useAmount . getItAmount]
|
_ -> [show $ iu ^?! useAmount . getItAmount]
|
||||||
@@ -106,17 +106,14 @@ showAmmoSource cr itm = fromMaybe ["FAIL"] $ do
|
|||||||
guard (at' == atype && as == AboveSource)
|
guard (at' == atype && as == AboveSource)
|
||||||
return ["vvvv",x] ) <|> Just [x]
|
return ["vvvv",x] ) <|> Just [x]
|
||||||
|
|
||||||
showReloadProgress' :: Creature -> Item -> String
|
showReloadProgress :: Creature -> Item -> String
|
||||||
showReloadProgress' cr itm = case ic ^? laSource of
|
showReloadProgress cr itm = case ic ^? laSource of
|
||||||
Just (InternalSource ia) -> case ia ^? iaProgress . _Just . ix 0 of
|
Just (InternalSource ia) -> case ia ^? iaProgress . _Just . ix 0 of
|
||||||
Nothing -> fromMaybe "" $ do
|
Nothing -> maybe "" show $ ic ^? laSource . _InternalSource . iaLoaded
|
||||||
x <- ic ^? laSource . _InternalSource . iaLoaded
|
Just la -> showLoadActionType la (_laSource ic)
|
||||||
return $ show x
|
|
||||||
Just la -> show (_actionTime la) ++ showLoadActionType la (_laSource ic)
|
|
||||||
Just AboveSource -> fromMaybe "||||" $ do
|
Just AboveSource -> fromMaybe "||||" $ do
|
||||||
i <- fmap (subtract 1) $ itm ^? itLocation . ipInvID
|
i <- fmap (subtract 1) $ itm ^? itLocation . ipInvID
|
||||||
_ <- cr ^? crInv . ix i . itUse . equipEffect . eeUse . euseAmmoAmount
|
_ <- cr ^? crInv . ix i . itUse . equipEffect . eeUse . euseAmmoAmount
|
||||||
--return $ showIntKMG' x
|
|
||||||
return ""
|
return ""
|
||||||
_ -> ""
|
_ -> ""
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -374,6 +374,7 @@ volleyGunShape i =
|
|||||||
[0 .. i -1]
|
[0 .. i -1]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
-- to get this rotating should probably add extra state to the minigun
|
||||||
miniGunXPictItem :: Int -> Item -> SPic
|
miniGunXPictItem :: Int -> Item -> SPic
|
||||||
miniGunXPictItem i it = miniGunXPict i spin
|
miniGunXPictItem i it = miniGunXPict i spin
|
||||||
where
|
where
|
||||||
|
|||||||
+17
-15
@@ -5,11 +5,9 @@ module Dodge.Reloading (
|
|||||||
tryStartLoading,
|
tryStartLoading,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Dodge.Data.Item.Use.Consumption.LoadAction
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Dodge.Data.Creature
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
--import qualified IntMapHelp as IM
|
import Dodge.Data.Creature
|
||||||
|
|
||||||
crCancelReloading :: Creature -> Creature
|
crCancelReloading :: Creature -> Creature
|
||||||
crCancelReloading cr =
|
crCancelReloading cr =
|
||||||
@@ -19,7 +17,9 @@ crCancelReloading cr =
|
|||||||
where
|
where
|
||||||
updateProgress = fromMaybe id $ do
|
updateProgress = fromMaybe id $ do
|
||||||
InInventory (SelItem i _) <- cr ^? crManipulation . manObject
|
InInventory (SelItem i _) <- cr ^? crManipulation . manObject
|
||||||
return $ crInv . ix i . itUse . heldConsumption . laSource . _InternalSource . iaProgress %~ const Nothing
|
return $
|
||||||
|
crInv . ix i . itUse . heldConsumption . laSource . _InternalSource . iaProgress
|
||||||
|
%~ const Nothing
|
||||||
|
|
||||||
stepReloading :: Creature -> Creature
|
stepReloading :: Creature -> Creature
|
||||||
stepReloading cr = case cr ^? crManipulation . manObject . inInventory of
|
stepReloading cr = case cr ^? crManipulation . manObject . inInventory of
|
||||||
@@ -50,28 +50,30 @@ crUpdateLoadSource cr = case cr ^? crManipulation . manObject . inInventory . is
|
|||||||
tryStartLoading :: Creature -> Creature
|
tryStartLoading :: Creature -> Creature
|
||||||
tryStartLoading cr = fromMaybe cr $ do
|
tryStartLoading cr = fromMaybe cr $ do
|
||||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
as <- cr ^? crInv . ix i . itUse . heldConsumption . laSource
|
ia <- cr ^? crInv . ix i . itUse . heldConsumption . laSource . _InternalSource
|
||||||
case as of
|
return $ startLoading ia cr
|
||||||
InternalSource ia -> return $ startLoading ia cr
|
|
||||||
AboveSource -> return cr
|
-- case as of
|
||||||
|
-- InternalSource ia -> return $ startLoading ia cr
|
||||||
|
-- AboveSource -> return cr
|
||||||
|
|
||||||
startLoading :: InternalAmmo -> Creature -> Creature
|
startLoading :: InternalAmmo -> Creature -> Creature
|
||||||
startLoading ic cr = case ic ^? iaProgress . _Just . ix 0 of
|
startLoading ic cr = case ic ^? iaProgress . _Just . ix 0 of
|
||||||
Just la -> cr & startLoadingStep la
|
Just la -> cr & startLoadingStep la
|
||||||
Nothing -> case ic ^? iaCycle of
|
Nothing -> case ic ^. iaCycle of
|
||||||
Nothing -> cr
|
[] -> error "item has empty load cycle"
|
||||||
Just [] -> error "item has empty load cycle"
|
_ | _iaLoaded ic >= _iaMax ic -> cr
|
||||||
Just _ | _iaLoaded ic >= _iaMax ic -> cr
|
(la : las) -> fromMaybe (error "item loading error") $ do
|
||||||
Just (la : las) -> fromMaybe (error "item loading error") $ do
|
|
||||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
return $ cr & startLoadingStep la
|
return $
|
||||||
|
cr & startLoadingStep la
|
||||||
& crInv . ix i . itUse . heldConsumption . laSource . _InternalSource . iaProgress ?~ (la : las)
|
& crInv . ix i . itUse . heldConsumption . laSource . _InternalSource . iaProgress ?~ (la : las)
|
||||||
|
|
||||||
startLoadingStep :: LoadAction -> Creature -> Creature
|
startLoadingStep :: LoadAction -> Creature -> Creature
|
||||||
startLoadingStep la cr = cr & crManipulation . manObject . inInventory . iselAction .~ ReloadAction (_actionTime la) la
|
startLoadingStep la cr = cr & crManipulation . manObject . inInventory . iselAction .~ ReloadAction (_actionTime la) la
|
||||||
|
|
||||||
rotateActionProgress :: InternalAmmo -> InternalAmmo
|
rotateActionProgress :: InternalAmmo -> InternalAmmo
|
||||||
rotateActionProgress ic = case ic ^? iaProgress . _Just of
|
rotateActionProgress ic = case ic ^. iaProgress of
|
||||||
Just (_ : la : las) -> ic & iaProgress . _Just .~ (la : las)
|
Just (_ : la : las) -> ic & iaProgress . _Just .~ (la : las)
|
||||||
_ | _iaLoaded ic < _iaMax ic -> ic & iaProgress ?~ _iaCycle ic
|
_ | _iaLoaded ic < _iaMax ic -> ic & iaProgress ?~ _iaCycle ic
|
||||||
_ -> ic & iaProgress .~ Nothing
|
_ -> ic & iaProgress .~ Nothing
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ module Dodge.Render.List (
|
|||||||
listCursorChooseBorderScale,
|
listCursorChooseBorderScale,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Dodge.SelectionSections
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Dodge.Base.Window
|
import Dodge.Base.Window
|
||||||
import Dodge.Data.CardinalPoint
|
import Dodge.Data.CardinalPoint
|
||||||
@@ -85,7 +86,8 @@ stackPicturesAtOff i = mconcat . zipWith (drawListElement 10 1 0) [i, i -1 ..]
|
|||||||
selSecDrawCursor :: Int -> ListDisplayParams -> SelectionSections a -> Picture
|
selSecDrawCursor :: Int -> ListDisplayParams -> SelectionSections a -> Picture
|
||||||
selSecDrawCursor xsize ldp sss = fromMaybe mempty $ do
|
selSecDrawCursor xsize ldp sss = fromMaybe mempty $ do
|
||||||
(i, j) <- sss ^? sssExtra . sssSelPos . _Just
|
(i, j) <- sss ^? sssExtra . sssSelPos . _Just
|
||||||
yint <- sss ^? sssSections . ix i . ssCursor . _Just . scurPos
|
--yint <- sss ^? sssSections . ix i . ssCursor . _Just . scurPos
|
||||||
|
yint <- selSecYint i j sss
|
||||||
xint <- sss ^? sssSections . ix i . ssIndent
|
xint <- sss ^? sssSections . ix i . ssIndent
|
||||||
si <- sss ^? sssSections . ix i . ssItems . ix j
|
si <- sss ^? sssSections . ix i . ssItems . ix j
|
||||||
return $
|
return $
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ selSecYint i j sss = do
|
|||||||
return . (secpos +)
|
return . (secpos +)
|
||||||
. subtract (ss ^. ssOffset)
|
. subtract (ss ^. ssOffset)
|
||||||
. sum
|
. sum
|
||||||
. fmap (length . _siPictures)
|
. fmap (_siHeight)
|
||||||
. fst
|
. fst
|
||||||
$ IM.split j (ss ^. ssItems)
|
$ IM.split j (ss ^. ssItems)
|
||||||
where
|
where
|
||||||
|
|||||||
Reference in New Issue
Block a user