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