Fix rb scrolling

This commit is contained in:
2022-12-31 22:29:12 +00:00
parent beac123dd2
commit 0dc9a09723
11 changed files with 44 additions and 37 deletions
+8 -2
View File
@@ -1,6 +1,9 @@
{-# LANGUAGE TupleSections #-} {-# LANGUAGE TupleSections #-}
module Dodge.Combine.Combinations where module Dodge.Combine.Combinations
( itemCombinations
, bulletWeapons
) where
import Dodge.Data.Item import Dodge.Data.Item
import Dodge.Item import Dodge.Item
@@ -8,7 +11,10 @@ import LensHelp
watchCombinations :: [([(ItAmount, ItemBaseType)], Item)] watchCombinations :: [([(ItAmount, ItemBaseType)], Item)]
watchCombinations = watchCombinations =
[ po [LEFT STOPWATCH, LEFT REWINDWATCH] scrollWatch] [ po [LEFT STOPWATCH, LEFT REWINDWATCH] scrollWatch
, po [CRAFT TIMEMODULE, CRAFT MICROCHIP, CRAFT HARDDRIVE] scrollWatch
, po [CRAFT TIMEMODULE, CRAFT MICROCHIP, CRAFT RAM] scrollWatch
]
where where
po xs it = (map o xs, it) po xs it = (map o xs, it)
o = (1,) o = (1,)
+3
View File
@@ -190,7 +190,10 @@ inventoryX c = case c of
'H' -> [shatterGun] 'H' -> [shatterGun]
'I' -> 'I' ->
[ makeTypeCraft TELEPORTMODULE [ makeTypeCraft TELEPORTMODULE
, makeTypeCraftNum 2 TIMEMODULE
, makeTypeCraftNum 2 MICROCHIP , makeTypeCraftNum 2 MICROCHIP
, makeTypeCraft HARDDRIVE
, makeTypeCraft RAM
] ]
'J' -> 'J' ->
[ lasGun [ lasGun
+7 -5
View File
@@ -30,7 +30,7 @@ useItem 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 $ tryReload cr it w $ foldl' (&) (useHeld eff) (useMod usemods) it cr hammerTest $ tryReload cr it (_input w) $ foldl' (&) (useHeld eff) (useMod usemods) it cr
--hammerTest $ tryReload cr it w $ foldl' (&) (useHeld eff) (reverse $ useMod usemods) it cr --hammerTest $ tryReload cr it w $ foldl' (&) (useHeld eff) (reverse $ useMod usemods) it cr
LeftUse{} -> doequipmentchange LeftUse{} -> doequipmentchange
EquipUse{} -> doequipmentchange EquipUse{} -> doequipmentchange
@@ -49,13 +49,15 @@ itemEffect cr it w = case it ^. itUse of
. activateEquipmentAt (_rbOptions w) cr . activateEquipmentAt (_rbOptions w) cr
) )
tryReload :: Creature -> Item -> World -> (World -> World) -> World -> World tryReload :: Creature -> Item -> Input -> (World -> World) -> World -> World
tryReload cr it w f tryReload cr it theinput f
| _crID cr == 0 && itNeedsLoading it && _mouseButtons (_input w) M.!? SDL.ButtonLeft == Just False = | cid == 0 && itNeedsLoading it && _mouseButtons theinput M.!? SDL.ButtonLeft == Just False =
crToggleReloading cr cWorld . lWorld . creatures . ix cid %~ crToggleReloading
| otherwise = | otherwise =
(runIdentity . pointerToItemLocation (_itLocation it) (return . (itUse . heldHammer .~ HammerDown))) (runIdentity . pointerToItemLocation (_itLocation it) (return . (itUse . heldHammer .~ HammerDown)))
. f . f
where
cid = _crID cr
itNeedsLoading :: Item -> Bool itNeedsLoading :: Item -> Bool
itNeedsLoading it = _laLoaded ic == 0 || not (_laPrimed ic) itNeedsLoading it = _laLoaded ic == 0 || not (_laPrimed ic)
+7 -7
View File
@@ -3,6 +3,7 @@ module Dodge.Creature.State (
doDamage, doDamage,
) where ) where
import Data.Maybe
import Dodge.Creature.Test import Dodge.Creature.Test
import Data.Foldable import Data.Foldable
import Dodge.Base import Dodge.Base
@@ -64,13 +65,12 @@ stateUpdate f =
] ]
heldAimEffects :: Creature -> World -> World heldAimEffects :: Creature -> World -> World
heldAimEffects cr heldAimEffects cr = fromMaybe id $ do
| crIsAiming cr = case cr ^? crInv . ix (cr ^. crInvSel . iselPos) of guard (crIsAiming cr)
Just itm -> case itm ^? itEffect . ieWhileAiming of ipos <- cr ^? crInvSel . iselPos
Just f -> doInvEffect f itm cr itm <- cr ^? crInv . ix ipos
_ -> id f <- itm ^? itEffect . ieWhileAiming
_ -> id return $ doInvEffect f itm cr
| otherwise = id
checkDeath :: Creature -> World -> World checkDeath :: Creature -> World -> World
checkDeath cr w checkDeath cr w
+4
View File
@@ -46,6 +46,8 @@ data CraftType
| PLATE | PLATE
| TRANSMITTER | TRANSMITTER
| MICROCHIP | MICROCHIP
| HARDDRIVE
| RAM
| AIUNIT | AIUNIT
| CAMERA | CAMERA
| MINIDISPLAY -- visual display unit | MINIDISPLAY -- visual display unit
@@ -102,7 +104,9 @@ data EquipItemType
| POWERLEGS | POWERLEGS
| SPEEDLEGS | SPEEDLEGS
| JUMPLEGS | JUMPLEGS
| JETPACK | JETPACK
| AUTODETECTOR Detector | AUTODETECTOR Detector
deriving (Eq,Ord,Show,Read) deriving (Eq,Ord,Show,Read)
--deriving (Eq, Ord, Show, Read) --Generic, Flat) --deriving (Eq, Ord, Show, Read) --Generic, Flat)
@@ -18,7 +18,9 @@ data LoadAction
| LoadPrime {_actionTime :: Int, _actionSound :: SoundID} | LoadPrime {_actionTime :: Int, _actionSound :: SoundID}
deriving (Eq, Ord, Show, Read) --Generic, Flat) deriving (Eq, Ord, Show, Read) --Generic, Flat)
data InvSel = InvSel {_iselPos :: Int, _iselAction :: InvSelAction} data InvSel
= InvSel {_iselPos :: Int, _iselAction :: InvSelAction}
| Brute
deriving (Eq, Ord, Show, Read) --Generic, Flat) deriving (Eq, Ord, Show, Read) --Generic, Flat)
data InvSelAction data InvSelAction
+3 -5
View File
@@ -25,6 +25,7 @@ module Dodge.Inventory (
invDimColor, invDimColor,
) where ) where
import Dodge.Reloading
import Color import Color
import Dodge.Inventory.Color import Dodge.Inventory.Color
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
@@ -52,11 +53,11 @@ rmInvItem ::
World -> World ->
World World
rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount of rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount of
Just x | x > 1 -> w & pointcid . crInv . ix invid . itUse . useAmount %~ subtract 1 Just x | x > 1 -> w & pointcid . crInv . ix invid . itUse . useAmount -~ 1
_ -> _ ->
w w
& pointcid . crInv %~ f & pointcid . crInv %~ f
& pointcid . crInvSel %~ stopCrInvSelAction & pointcid %~ crCancelReloading
& pointcid . crInvSel . iselPos %~ g & pointcid . crInvSel . iselPos %~ g
& pointcid . crLeftInvSel . lisMPos %~ g' & pointcid . crLeftInvSel . lisMPos %~ g'
& removeAnySlotEquipment & removeAnySlotEquipment
@@ -70,9 +71,6 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount
getcid = cWorld . lWorld . creatures . ix cid getcid = cWorld . lWorld . creatures . ix cid
pointcid = cWorld . lWorld . creatures . ix cid pointcid = cWorld . lWorld . creatures . ix cid
stopCrInvSelAction (InvSel i a)
| i == invid = InvSel i NoInvSelAction
| otherwise = InvSel i a
cr = w ^?! cWorld . lWorld . creatures . ix cid cr = w ^?! cWorld . lWorld . creatures . ix cid
itm = _crInv cr IM.! invid itm = _crInv cr IM.! invid
dounequipfunction = fromMaybe id $ do dounequipfunction = fromMaybe id $ do
+2 -2
View File
@@ -65,8 +65,8 @@ showAutoRechargeProgress lc = case lc of
ChargeableAmmo{} -> show (_wpCharge lc) ChargeableAmmo{} -> show (_wpCharge lc)
showReloadProgress :: Creature -> HeldConsumption -> String showReloadProgress :: Creature -> HeldConsumption -> String
showReloadProgress cr ic = case cr ^?! crInvSel . iselAction of showReloadProgress cr ic = case cr ^? crInvSel . iselAction of
ReloadAction i la _ -> show i ++ showLoadActionType la (_laLoaded ic) Just (ReloadAction i la _) -> show i ++ showLoadActionType la (_laLoaded ic)
_ -> case ic ^? laProgress . _Just . ix 0 of _ -> case ic ^? laProgress . _Just . ix 0 of
Nothing -> show $ _laLoaded ic Nothing -> show $ _laLoaded ic
Just la -> show (_actionTime la) ++ showLoadActionType la (_laLoaded ic) Just la -> show (_actionTime la) ++ showLoadActionType la (_laLoaded ic)
+5 -11
View File
@@ -1,13 +1,12 @@
module Dodge.Reloading ( module Dodge.Reloading (
crCancelReloading, crCancelReloading,
crToggleReloading, crToggleReloading,
crHoldReloading,
stepReloading, stepReloading,
tryStartLoading, tryStartLoading,
) where ) where
import Control.Lens import Control.Lens
import Dodge.Data.World import Dodge.Data.Creature
import Dodge.Hammer import Dodge.Hammer
crCancelReloading :: Creature -> Creature crCancelReloading :: Creature -> Creature
@@ -38,15 +37,10 @@ tryNextLoadAction cr = case cr ^? crInv . ix (crSel cr) . itUse . heldConsumptio
cr & crInvSel . iselAction . actionProgress .~ _actionTime la cr & crInvSel . iselAction . actionProgress .~ _actionTime la
& crInvSel . iselAction . reloadAction .~ la & crInvSel . iselAction . reloadAction .~ la
crToggleReloading :: Creature -> World -> World crToggleReloading :: Creature -> Creature
crToggleReloading cr w = case cr ^. crInvSel . iselAction of crToggleReloading cr = case cr ^? crInvSel . iselAction of
ReloadAction{} -> w & cWorld . lWorld . creatures . ix (_crID cr) . crInvSel . iselAction .~ NoInvSelAction Just ReloadAction{} -> cr & crInvSel . iselAction .~ NoInvSelAction
_ -> w & cWorld . lWorld . creatures . ix (_crID cr) %~ tryStartLoading _ -> cr & tryStartLoading
crHoldReloading :: Creature -> World -> World
crHoldReloading cr w =
w
& cWorld . lWorld . creatures . ix (_crID cr) . crInvSel . iselAction . actionHammer .~ HasHammer HammerDown
tryStartLoading :: Creature -> Creature tryStartLoading :: Creature -> Creature
tryStartLoading cr = case cr ^? crInv . ix (crSel cr) . itUse . heldConsumption of tryStartLoading cr = case cr ^? crInv . ix (crSel cr) . itUse . heldConsumption of
+1 -3
View File
@@ -75,13 +75,11 @@ updateKeyInGame uv sc InitialPress = case sc of
ScancodeP -> pauseGame uv ScancodeP -> pauseGame uv
ScancodeF -> over uvWorld youDropItem uv ScancodeF -> over uvWorld youDropItem uv
ScancodeM -> over uvWorld toggleMap uv ScancodeM -> over uvWorld toggleMap uv
ScancodeR -> over uvWorld (crToggleReloading (you w)) uv ScancodeR -> over (uvWorld . cWorld . lWorld . creatures . ix 0) crToggleReloading uv
ScancodeT -> over uvWorld testEvent uv ScancodeT -> over uvWorld testEvent uv
ScancodeX -> uv & uvWorld %~ toggleTweakInv ScancodeX -> uv & uvWorld %~ toggleTweakInv
ScancodeC -> over uvWorld toggleCombineInv uv ScancodeC -> over uvWorld toggleCombineInv uv
_ -> uv _ -> uv
where
w = _uvWorld uv
updateKeyInGame uv _ _ = uv updateKeyInGame uv _ _ = uv
pauseGame :: Universe -> Universe pauseGame :: Universe -> Universe
+1 -1
View File
@@ -94,7 +94,7 @@ terminalWheelEvent yi tmid w
scrollRBOption :: Int -> World -> World scrollRBOption :: Int -> World -> World
scrollRBOption y w scrollRBOption y w
| y < 0 = w & rbOptions . opSel %~ (min (length (_opEquip (_rbOptions w)) -1) . (+ y)) | y < 0 = w & rbOptions . opSel %~ (min (length (_opEquip (_rbOptions w)) -1) . subtract y)
| y > 0 = w & rbOptions . opSel %~ (max 0 . subtract y) | y > 0 = w & rbOptions . opSel %~ (max 0 . subtract y)
| otherwise = w | otherwise = w