From f8d9b54586e52050eba75e760f7a046abd548347 Mon Sep 17 00:00:00 2001 From: justin Date: Sat, 7 Jan 2023 23:50:54 +0000 Subject: [PATCH] Tweak scrolling, move onto reloading --- .../Data/Item/Use/Consumption/LoadAction.hs | 3 +-- src/Dodge/HeldScroll.hs | 2 +- src/Dodge/Item/Display.hs | 2 +- src/Dodge/Item/Weapon/ZoomScope.hs | 8 +++---- src/Dodge/Reloading.hs | 9 +++----- src/Dodge/Update.hs | 17 +++++---------- src/Dodge/Update/Camera.hs | 21 +++++++++++-------- 7 files changed, 27 insertions(+), 35 deletions(-) diff --git a/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs b/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs index be0b6e38d..b90a6b838 100644 --- a/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs +++ b/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs @@ -8,7 +8,6 @@ module Dodge.Data.Item.Use.Consumption.LoadAction where import Control.Lens import Data.Aeson import Data.Aeson.TH -import Dodge.Data.Hammer import Sound.Data data LoadAction @@ -25,7 +24,7 @@ data InvSel data InvSelAction = NoInvSelAction - | ReloadAction {_actionProgress :: Int, _reloadAction :: LoadAction, _actionHammer :: HammerType} + | ReloadAction {_actionProgress :: Int, _reloadAction :: LoadAction} deriving (Eq, Ord, Show, Read) --Generic, Flat) data LeftInvSel = LeftInvSel diff --git a/src/Dodge/HeldScroll.hs b/src/Dodge/HeldScroll.hs index 99e1fd3e6..293cf3bf0 100644 --- a/src/Dodge/HeldScroll.hs +++ b/src/Dodge/HeldScroll.hs @@ -14,7 +14,7 @@ import Dodge.Item.Weapon.ZoomScope doHeldScroll :: HeldScroll -> Float -> Creature -> World -> World doHeldScroll hs = case hs of HeldScrollDoNothing -> const . const id - HeldScrollZoom -> overYourItem (const . zoomLongGun) + HeldScrollZoom -> overYourItem (const . setZoomScopeChange) HeldScrollCharMode{} -> overYourItem $ \x _ -> itUse . heldScroll . hsCharMode %~ cycleSignum x where overYourItem f x cr w = w & cWorld . lWorld . creatures . ix 0 . crInv . ix (crSel $ you w) %~ f x cr diff --git a/src/Dodge/Item/Display.hs b/src/Dodge/Item/Display.hs index cdc7a334d..675b703cb 100644 --- a/src/Dodge/Item/Display.hs +++ b/src/Dodge/Item/Display.hs @@ -66,7 +66,7 @@ showAutoRechargeProgress lc = case lc of showReloadProgress :: Creature -> HeldConsumption -> String 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 Nothing -> show $ _laLoaded ic Just la -> show (_actionTime la) ++ showLoadActionType la (_laLoaded ic) diff --git a/src/Dodge/Item/Weapon/ZoomScope.hs b/src/Dodge/Item/Weapon/ZoomScope.hs index 9bf31cf54..ee37fee8e 100644 --- a/src/Dodge/Item/Weapon/ZoomScope.hs +++ b/src/Dodge/Item/Weapon/ZoomScope.hs @@ -4,16 +4,16 @@ import Dodge.Data.Item import LensHelp -- should be possible without the creature -zoomLongGun :: Float -> Item -> Item -zoomLongGun x +setZoomScopeChange :: Float -> Item -> Item +setZoomScopeChange x | x > 0 = itScope . scopeZoomChange %~ (max 0 . (+ xi)) | x < 0 = itScope . scopeZoomChange %~ (min 0 . (+ xi)) | otherwise = id where xi | x > 2 = 20 - | x > 1 = 4 + | x > 1 = 10 | x > 0 = 1 | x < -2 = - 20 - | x < -1 = - 4 + | x < -1 = - 10 | x < -0 = - 1 | otherwise = 0 diff --git a/src/Dodge/Reloading.hs b/src/Dodge/Reloading.hs index c0a8ff67f..f840a2e46 100644 --- a/src/Dodge/Reloading.hs +++ b/src/Dodge/Reloading.hs @@ -7,7 +7,6 @@ module Dodge.Reloading ( import Control.Lens import Dodge.Data.Creature -import Dodge.Hammer crCancelReloading :: Creature -> Creature crCancelReloading cr = @@ -17,14 +16,12 @@ crCancelReloading cr = stepReloading :: Creature -> Creature stepReloading cr = case cr ^?! crInvSel . iselAction of - ReloadAction _ _ (HasHammer HammerUp) -> cr & crInvSel . iselAction .~ NoInvSelAction - ReloadAction x la _ +-- ReloadAction _ _ (HasHammer HammerUp) -> cr & crInvSel . iselAction .~ NoInvSelAction + ReloadAction x la | x > 0 -> cr & crInvSel . iselAction . actionProgress -~ 1 - & crInvSel . iselAction . actionHammer . hammerPosition %~ moveHammerUp | otherwise -> cr - & crInvSel . iselAction . actionHammer . hammerPosition %~ moveHammerUp & crInv . ix (crSel cr) . itUse . heldConsumption %~ doLoadAction la & crInv . ix (crSel cr) . itUse . heldConsumption %~ rotateActionProgress & tryNextLoadAction @@ -59,7 +56,7 @@ startLoading ic cr = case ic ^? laProgress . _Just . ix 0 of & crInv . ix (crSel cr) . itUse . heldConsumption . laProgress ?~ (la : las) 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 ic = case ic ^? laProgress . _Just of diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index 1dcedf17c..3b40f748e 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -335,9 +335,7 @@ menuWheelStep i u = fromMaybe u $ do -- where -- y = w ^. input . scrollAmount updateWheelEvents :: World -> World -updateWheelEvents w = updateWheelEvent y w - where - y = w ^. input . scrollAmount +updateWheelEvents w = updateWheelEvent (w ^. input . scrollAmount) w advanceScrollAmount :: Universe -> Universe advanceScrollAmount u = @@ -351,18 +349,13 @@ updatePastWorlds w = w & pastWorlds %~ (forceFoldable . take 100 . ((w ^. lWorld --updatePastWorlds w = w & pastWorlds .~ [] moveHammersUp :: Universe -> Universe ---moveHammersUp = uvWorld . hammers .~ M.empty 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 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 w = diff --git a/src/Dodge/Update/Camera.hs b/src/Dodge/Update/Camera.hs index e8d0fbed1..0d4aa3a09 100644 --- a/src/Dodge/Update/Camera.hs +++ b/src/Dodge/Update/Camera.hs @@ -95,12 +95,18 @@ updateScopeZoom w doScopeZoom :: Point2 -> Scope -> Scope doScopeZoom mp sc = case sc ^? scopeZoomChange of Just x - | x > 10 -> (zoomInLongGun mp . zoomInLongGun mp . zoomInLongGun mp) sc - | x > 5 -> (zoomInLongGun mp . zoomInLongGun mp) sc - | x > 0 -> (zoomInLongGun mp) sc - | x < -10 -> (zoomOutLongGun . zoomOutLongGun . zoomOutLongGun) sc - | x < -5 -> (zoomOutLongGun . zoomOutLongGun) sc - | x < 0 -> zoomOutLongGun sc + | x > 10 -> (zoomInLongGun mp . zoomInLongGun mp . zoomInLongGun mp) $ sc + & scopeZoomChange -~ 2 + | x > 5 -> (zoomInLongGun mp . zoomInLongGun mp) $ sc + & scopeZoomChange -~ 1 + | x > 0 -> zoomInLongGun mp $ 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 _ -> sc @@ -113,7 +119,6 @@ zoomInLongGun mousep sc sc & scopePos .+.+~ (1 - zoomSpeed) / newzoom *.* mousep & scopeZoom %~ (/ zoomSpeed) - & scopeZoomChange -~ 1 | otherwise = sc & scopeZoomChange .~ 0 where Just currentZoom = sc ^? scopeZoom @@ -126,7 +131,6 @@ zoomOutLongGun sc & scopePos %~ (\p -> p +.+ (zoomSpeed-1) / currentzoom *.* p) -- & scopePos .*.*~ 1 - ((newzoom * 2) ** zoomSpeed) & scopeZoom *~ zoomSpeed - & scopeZoomChange +~ 1 | otherwise = sc & scopeZoomChange .~ 0 & scopePos .~ V2 0 0 where @@ -204,7 +208,6 @@ setViewDistance cfig w = w & camViewDistance .~ sqrt (halfWidth cfig ** 2 + halfHeight cfig ** 2) / (w ^. camZoom) - farWallDistDirection :: Point2 -> World -> Maybe (Float, Float, Float, Float) farWallDistDirection p w = boundPoints $