Tweak scrolling, move onto reloading

This commit is contained in:
2023-01-07 23:50:54 +00:00
parent d4122b2d6f
commit f8d9b54586
7 changed files with 27 additions and 35 deletions
@@ -8,7 +8,6 @@ module Dodge.Data.Item.Use.Consumption.LoadAction where
import Control.Lens import Control.Lens
import Data.Aeson import Data.Aeson
import Data.Aeson.TH import Data.Aeson.TH
import Dodge.Data.Hammer
import Sound.Data import Sound.Data
data LoadAction data LoadAction
@@ -25,7 +24,7 @@ data InvSel
data InvSelAction data InvSelAction
= NoInvSelAction = NoInvSelAction
| ReloadAction {_actionProgress :: Int, _reloadAction :: LoadAction, _actionHammer :: HammerType} | ReloadAction {_actionProgress :: Int, _reloadAction :: LoadAction}
deriving (Eq, Ord, Show, Read) --Generic, Flat) deriving (Eq, Ord, Show, Read) --Generic, Flat)
data LeftInvSel = LeftInvSel data LeftInvSel = LeftInvSel
+1 -1
View File
@@ -14,7 +14,7 @@ import Dodge.Item.Weapon.ZoomScope
doHeldScroll :: HeldScroll -> Float -> Creature -> World -> World doHeldScroll :: HeldScroll -> Float -> Creature -> World -> World
doHeldScroll hs = case hs of doHeldScroll hs = case hs of
HeldScrollDoNothing -> const . const id HeldScrollDoNothing -> const . const id
HeldScrollZoom -> overYourItem (const . zoomLongGun) HeldScrollZoom -> overYourItem (const . setZoomScopeChange)
HeldScrollCharMode{} -> overYourItem $ \x _ -> itUse . heldScroll . hsCharMode %~ cycleSignum x HeldScrollCharMode{} -> overYourItem $ \x _ -> itUse . heldScroll . hsCharMode %~ cycleSignum x
where where
overYourItem f x cr w = w & cWorld . lWorld . creatures . ix 0 . crInv . ix (crSel $ you w) %~ f x cr overYourItem f x cr w = w & cWorld . lWorld . creatures . ix 0 . crInv . ix (crSel $ you w) %~ f x cr
+1 -1
View File
@@ -66,7 +66,7 @@ showAutoRechargeProgress lc = case lc of
showReloadProgress :: Creature -> HeldConsumption -> String showReloadProgress :: Creature -> HeldConsumption -> String
showReloadProgress cr ic = case cr ^? crInvSel . iselAction of showReloadProgress cr ic = case cr ^? crInvSel . iselAction of
Just (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)
+4 -4
View File
@@ -4,16 +4,16 @@ import Dodge.Data.Item
import LensHelp import LensHelp
-- should be possible without the creature -- should be possible without the creature
zoomLongGun :: Float -> Item -> Item setZoomScopeChange :: Float -> Item -> Item
zoomLongGun x setZoomScopeChange x
| x > 0 = itScope . scopeZoomChange %~ (max 0 . (+ xi)) | x > 0 = itScope . scopeZoomChange %~ (max 0 . (+ xi))
| x < 0 = itScope . scopeZoomChange %~ (min 0 . (+ xi)) | x < 0 = itScope . scopeZoomChange %~ (min 0 . (+ xi))
| otherwise = id | otherwise = id
where where
xi | x > 2 = 20 xi | x > 2 = 20
| x > 1 = 4 | x > 1 = 10
| x > 0 = 1 | x > 0 = 1
| x < -2 = - 20 | x < -2 = - 20
| x < -1 = - 4 | x < -1 = - 10
| x < -0 = - 1 | x < -0 = - 1
| otherwise = 0 | otherwise = 0
+3 -6
View File
@@ -7,7 +7,6 @@ module Dodge.Reloading (
import Control.Lens import Control.Lens
import Dodge.Data.Creature import Dodge.Data.Creature
import Dodge.Hammer
crCancelReloading :: Creature -> Creature crCancelReloading :: Creature -> Creature
crCancelReloading cr = crCancelReloading cr =
@@ -17,14 +16,12 @@ crCancelReloading cr =
stepReloading :: Creature -> Creature stepReloading :: Creature -> Creature
stepReloading cr = case cr ^?! crInvSel . iselAction of stepReloading cr = case cr ^?! crInvSel . iselAction of
ReloadAction _ _ (HasHammer HammerUp) -> cr & crInvSel . iselAction .~ NoInvSelAction -- ReloadAction _ _ (HasHammer HammerUp) -> cr & crInvSel . iselAction .~ NoInvSelAction
ReloadAction x la _ ReloadAction x la
| x > 0 -> | x > 0 ->
cr & crInvSel . iselAction . actionProgress -~ 1 cr & crInvSel . iselAction . actionProgress -~ 1
& crInvSel . iselAction . actionHammer . hammerPosition %~ moveHammerUp
| otherwise -> | otherwise ->
cr cr
& crInvSel . iselAction . actionHammer . hammerPosition %~ moveHammerUp
& crInv . ix (crSel cr) . itUse . heldConsumption %~ doLoadAction la & crInv . ix (crSel cr) . itUse . heldConsumption %~ doLoadAction la
& crInv . ix (crSel cr) . itUse . heldConsumption %~ rotateActionProgress & crInv . ix (crSel cr) . itUse . heldConsumption %~ rotateActionProgress
& tryNextLoadAction & tryNextLoadAction
@@ -59,7 +56,7 @@ startLoading ic cr = case ic ^? laProgress . _Just . ix 0 of
& crInv . ix (crSel cr) . itUse . heldConsumption . laProgress ?~ (la : las) & crInv . ix (crSel cr) . itUse . heldConsumption . laProgress ?~ (la : las)
startLoadingStep :: LoadAction -> Creature -> Creature startLoadingStep :: LoadAction -> Creature -> Creature
startLoadingStep la cr = cr & crInvSel . iselAction .~ ReloadAction (_actionTime la) la NoHammer startLoadingStep la cr = cr & crInvSel . iselAction .~ ReloadAction (_actionTime la) la
rotateActionProgress :: HeldConsumption -> HeldConsumption rotateActionProgress :: HeldConsumption -> HeldConsumption
rotateActionProgress ic = case ic ^? laProgress . _Just of rotateActionProgress ic = case ic ^? laProgress . _Just of
+5 -12
View File
@@ -335,9 +335,7 @@ menuWheelStep i u = fromMaybe u $ do
-- where -- where
-- y = w ^. input . scrollAmount -- y = w ^. input . scrollAmount
updateWheelEvents :: World -> World updateWheelEvents :: World -> World
updateWheelEvents w = updateWheelEvent y w updateWheelEvents w = updateWheelEvent (w ^. input . scrollAmount) w
where
y = w ^. input . scrollAmount
advanceScrollAmount :: Universe -> Universe advanceScrollAmount :: Universe -> Universe
advanceScrollAmount u = advanceScrollAmount u =
@@ -351,18 +349,13 @@ updatePastWorlds w = w & pastWorlds %~ (forceFoldable . take 100 . ((w ^. lWorld
--updatePastWorlds w = w & pastWorlds .~ [] --updatePastWorlds w = w & pastWorlds .~ []
moveHammersUp :: Universe -> Universe moveHammersUp :: Universe -> Universe
--moveHammersUp = uvWorld . hammers .~ M.empty
moveHammersUp = uvWorld . input . hammers %~ M.map moveHammerUp moveHammersUp = uvWorld . input . hammers %~ M.map moveHammerUp
--moveHammersUp = uvWorld . hammers . each %~ (moveHammerUp $!)
--moveHammersUp = uvWorld %~ ( (hammers . each %~ (moveHammerUp $!)) $!)
--moveHammersUp uv = uv { _uvWorld = w' }
-- where
-- w = _uvWorld uv
-- w' = w {_hammers = fmap moveHammerUp (_hammers w)}
doWorldEvents :: World -> World doWorldEvents :: World -> World
doWorldEvents w = foldl' (flip doWdWd) (w & cWorld . lWorld . worldEvents .~ []) (w ^. cWorld . lWorld . worldEvents) doWorldEvents w = foldl'
(flip doWdWd)
(w & cWorld . lWorld . worldEvents .~ [])
(w ^. cWorld . lWorld . worldEvents)
updateLasers :: World -> World updateLasers :: World -> World
updateLasers w = updateLasers w =
+12 -9
View File
@@ -95,12 +95,18 @@ updateScopeZoom w
doScopeZoom :: Point2 -> Scope -> Scope doScopeZoom :: Point2 -> Scope -> Scope
doScopeZoom mp sc = case sc ^? scopeZoomChange of doScopeZoom mp sc = case sc ^? scopeZoomChange of
Just x Just x
| x > 10 -> (zoomInLongGun mp . zoomInLongGun mp . zoomInLongGun mp) sc | x > 10 -> (zoomInLongGun mp . zoomInLongGun mp . zoomInLongGun mp) $ sc
| x > 5 -> (zoomInLongGun mp . zoomInLongGun mp) sc & scopeZoomChange -~ 2
| x > 0 -> (zoomInLongGun mp) sc | x > 5 -> (zoomInLongGun mp . zoomInLongGun mp) $ sc
| x < -10 -> (zoomOutLongGun . zoomOutLongGun . zoomOutLongGun) sc & scopeZoomChange -~ 1
| x < -5 -> (zoomOutLongGun . zoomOutLongGun) sc | x > 0 -> zoomInLongGun mp $ sc
| x < 0 -> zoomOutLongGun sc & scopeZoomChange -~ 1
| x < -10 -> (zoomOutLongGun . zoomOutLongGun . zoomOutLongGun) $ sc
& scopeZoomChange +~ 2
| x < -5 -> (zoomOutLongGun . zoomOutLongGun) $ sc
& scopeZoomChange +~ 1
| x < 0 -> zoomOutLongGun $ sc
& scopeZoomChange +~ 1
| otherwise -> sc | otherwise -> sc
_ -> sc _ -> sc
@@ -113,7 +119,6 @@ zoomInLongGun mousep sc
sc sc
& scopePos .+.+~ (1 - zoomSpeed) / newzoom *.* mousep & scopePos .+.+~ (1 - zoomSpeed) / newzoom *.* mousep
& scopeZoom %~ (/ zoomSpeed) & scopeZoom %~ (/ zoomSpeed)
& scopeZoomChange -~ 1
| otherwise = sc & scopeZoomChange .~ 0 | otherwise = sc & scopeZoomChange .~ 0
where where
Just currentZoom = sc ^? scopeZoom Just currentZoom = sc ^? scopeZoom
@@ -126,7 +131,6 @@ zoomOutLongGun sc
& scopePos %~ (\p -> p +.+ (zoomSpeed-1) / currentzoom *.* p) & scopePos %~ (\p -> p +.+ (zoomSpeed-1) / currentzoom *.* p)
-- & scopePos .*.*~ 1 - ((newzoom * 2) ** zoomSpeed) -- & scopePos .*.*~ 1 - ((newzoom * 2) ** zoomSpeed)
& scopeZoom *~ zoomSpeed & scopeZoom *~ zoomSpeed
& scopeZoomChange +~ 1
| otherwise = sc & scopeZoomChange .~ 0 | otherwise = sc & scopeZoomChange .~ 0
& scopePos .~ V2 0 0 & scopePos .~ V2 0 0
where where
@@ -204,7 +208,6 @@ setViewDistance cfig w =
w & camViewDistance w & camViewDistance
.~ sqrt (halfWidth cfig ** 2 + halfHeight cfig ** 2) / (w ^. camZoom) .~ sqrt (halfWidth cfig ** 2 + halfHeight cfig ** 2) / (w ^. camZoom)
farWallDistDirection :: Point2 -> World -> Maybe (Float, Float, Float, Float) farWallDistDirection :: Point2 -> World -> Maybe (Float, Float, Float, Float)
farWallDistDirection p w = farWallDistDirection p w =
boundPoints $ boundPoints $