Tweak scrolling, particularly zooming
This commit is contained in:
@@ -15,11 +15,6 @@ data HeldScroll
|
|||||||
| HeldScrollZoom
|
| HeldScrollZoom
|
||||||
| HeldScrollCharMode
|
| HeldScrollCharMode
|
||||||
{_hsCharMode :: Seq.Seq Char}
|
{_hsCharMode :: Seq.Seq Char}
|
||||||
| HeldScrollInt
|
|
||||||
{ _hsInt :: Int
|
|
||||||
, _hsMaxInt :: Int
|
|
||||||
}
|
|
||||||
| HeldScrollTime
|
|
||||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||||
|
|
||||||
makeLenses ''HeldScroll
|
makeLenses ''HeldScroll
|
||||||
|
|||||||
+1
-11
@@ -14,21 +14,11 @@ 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 zoomLongGun
|
HeldScrollZoom -> overYourItem (const . zoomLongGun)
|
||||||
HeldScrollCharMode{} -> overYourItem $ \x _ -> itUse . heldScroll . hsCharMode %~ cycleSignum x
|
HeldScrollCharMode{} -> overYourItem $ \x _ -> itUse . heldScroll . hsCharMode %~ cycleSignum x
|
||||||
HeldScrollTime -> doScrollTime
|
|
||||||
HeldScrollInt{} -> undefined
|
|
||||||
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
|
||||||
|
|
||||||
doScrollTime :: Float -> Creature -> World -> World
|
|
||||||
doScrollTime _ _ w = w
|
|
||||||
-- | x > 0 = case _futureWorlds $ _cwTime w of
|
|
||||||
-- (w':ws) -> w -- & cWorld .~ w'
|
|
||||||
-- -- & cwTime . futureWorlds %~ tail
|
|
||||||
-- -- & cwTime . rewindWorlds .:~ _cWorld w
|
|
||||||
-- _ -> w
|
|
||||||
-- | otherwise = w
|
|
||||||
cycleSignum :: Float -> Seq a -> Seq a
|
cycleSignum :: Float -> Seq a -> Seq a
|
||||||
cycleSignum x
|
cycleSignum x
|
||||||
| x > 0 = cycleL
|
| x > 0 = cycleL
|
||||||
|
|||||||
@@ -108,7 +108,6 @@ maybeWarmupStatus it = case it ^? itUse . heldDelay . warmMax of
|
|||||||
maybeModeStatus :: Item -> Maybe String
|
maybeModeStatus :: Item -> Maybe String
|
||||||
maybeModeStatus it = case it ^? itUse . heldScroll of
|
maybeModeStatus it = case it ^? itUse . heldScroll of
|
||||||
Just HeldScrollCharMode{_hsCharMode = (c :<| _)} -> Just [' ', c]
|
Just HeldScrollCharMode{_hsCharMode = (c :<| _)} -> Just [' ', c]
|
||||||
Just HeldScrollInt{_hsInt = i} -> Just $ show i
|
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
maybeRateStatus :: Item -> Maybe String
|
maybeRateStatus :: Item -> Maybe String
|
||||||
|
|||||||
@@ -1,11 +1,19 @@
|
|||||||
module Dodge.Item.Weapon.ZoomScope where
|
module Dodge.Item.Weapon.ZoomScope where
|
||||||
|
|
||||||
import Dodge.Data.Creature
|
import Dodge.Data.Item
|
||||||
import LensHelp
|
import LensHelp
|
||||||
-- should be possible without the creature
|
-- should be possible without the creature
|
||||||
|
|
||||||
zoomLongGun :: Float -> Creature -> Item -> Item
|
zoomLongGun :: Float -> Item -> Item
|
||||||
zoomLongGun x _
|
zoomLongGun x
|
||||||
| x > 0 = itScope . scopeZoomChange %~ (max 15 . (+ 4))
|
| x > 0 = itScope . scopeZoomChange %~ (max 0 . (+ xi))
|
||||||
| x < 0 = itScope . scopeZoomChange %~ (min (-15) . subtract 4)
|
| x < 0 = itScope . scopeZoomChange %~ (min 0 . (+ xi))
|
||||||
| otherwise = id
|
| otherwise = id
|
||||||
|
where
|
||||||
|
xi | x > 2 = 20
|
||||||
|
| x > 1 = 4
|
||||||
|
| x > 0 = 1
|
||||||
|
| x < -2 = - 20
|
||||||
|
| x < -1 = - 4
|
||||||
|
| x < -0 = - 1
|
||||||
|
| otherwise = 0
|
||||||
|
|||||||
+12
-1
@@ -1,5 +1,6 @@
|
|||||||
module Dodge.TestString where
|
module Dodge.TestString where
|
||||||
|
|
||||||
|
import Dodge.Base.You
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Dodge.Data.Universe
|
import Dodge.Data.Universe
|
||||||
--import Data.Maybe
|
--import Data.Maybe
|
||||||
@@ -8,8 +9,18 @@ import Dodge.Data.Universe
|
|||||||
--import qualified IntMapHelp as IM
|
--import qualified IntMapHelp as IM
|
||||||
testStringInit :: Universe -> [String]
|
testStringInit :: Universe -> [String]
|
||||||
testStringInit u =
|
testStringInit u =
|
||||||
[ showTimeFlow $ u ^. uvWorld . cWorld . timeFlow
|
[ show $ u ^. uvWorld . input . scrollAmount
|
||||||
|
, maybe mempty show mit
|
||||||
|
, maybe mempty (show . f) mit
|
||||||
|
, maybe mempty show mit'
|
||||||
|
, maybe mempty show mit''
|
||||||
]
|
]
|
||||||
|
where
|
||||||
|
f x = 1/ (x *2) ** (40/39)
|
||||||
|
ycr = you (u ^. uvWorld)
|
||||||
|
mit = ycr ^? crInv . ix (crSel ycr) . itScope . scopeZoom
|
||||||
|
mit' = ycr ^? crInv . ix (crSel ycr) . itScope . scopePos
|
||||||
|
mit'' = ycr ^? crInv . ix (crSel ycr) . itScope . scopeZoomChange
|
||||||
|
|
||||||
showTimeFlow :: TimeFlowStatus -> String
|
showTimeFlow :: TimeFlowStatus -> String
|
||||||
showTimeFlow tfs = case tfs of
|
showTimeFlow tfs = case tfs of
|
||||||
|
|||||||
+5
-1
@@ -330,8 +330,12 @@ menuWheelStep i u = fromMaybe u $ do
|
|||||||
then Just newu
|
then Just newu
|
||||||
else Just $ menuWheelStep i newu
|
else Just $ menuWheelStep i newu
|
||||||
|
|
||||||
|
--updateWheelEvents :: World -> World
|
||||||
|
--updateWheelEvents w = foldr ($) w (replicate (abs y) (updateWheelEvent (signum y)))
|
||||||
|
-- where
|
||||||
|
-- y = w ^. input . scrollAmount
|
||||||
updateWheelEvents :: World -> World
|
updateWheelEvents :: World -> World
|
||||||
updateWheelEvents w = foldr ($) w (replicate (abs y) (updateWheelEvent (signum y)))
|
updateWheelEvents w = updateWheelEvent y w
|
||||||
where
|
where
|
||||||
y = w ^. input . scrollAmount
|
y = w ^. input . scrollAmount
|
||||||
|
|
||||||
|
|||||||
+11
-13
@@ -84,16 +84,12 @@ moveZoomCamera cfig theinput cr campos =
|
|||||||
|
|
||||||
updateScopeZoom :: World -> World
|
updateScopeZoom :: World -> World
|
||||||
updateScopeZoom w
|
updateScopeZoom w
|
||||||
| SDL.ButtonRight `M.member` _mouseButtons (_input w) = over wppointer (doScopeZoom mp) w
|
| SDL.ButtonRight `M.member` _mouseButtons (_input w) = w & wppointer %~ doScopeZoom mp
|
||||||
| otherwise =
|
| otherwise = w & wppointer %~ resetscope
|
||||||
w
|
|
||||||
& cWorld . lWorld . creatures . ix 0 . crInv . ix (crSel (w ^?! cWorld . lWorld . creatures . ix 0))
|
|
||||||
. itScope
|
|
||||||
%~ updateScope
|
|
||||||
where
|
where
|
||||||
wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix (crSel (w ^?! cWorld . lWorld . creatures . ix 0)) . itScope
|
wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix (crSel (w ^?! cWorld . lWorld . creatures . ix 0)) . itScope
|
||||||
updateScope (ZoomScope _ _ _ defz bl) = ZoomScope (V2 0 0) 0 defz defz bl
|
resetscope (ZoomScope _ _ _ defz bl) = ZoomScope (V2 0 0) 0 defz defz bl
|
||||||
updateScope otherAtt = otherAtt
|
resetscope otherAtt = otherAtt
|
||||||
mp = rotateV (w ^. cWorld . camPos . camRot) $ _mousePos (_input w)
|
mp = rotateV (w ^. cWorld . camPos . camRot) $ _mousePos (_input w)
|
||||||
|
|
||||||
doScopeZoom :: Point2 -> Scope -> Scope
|
doScopeZoom :: Point2 -> Scope -> Scope
|
||||||
@@ -117,23 +113,25 @@ zoomInLongGun mousep sc
|
|||||||
sc
|
sc
|
||||||
& scopePos .+.+~ (1 - zoomSpeed) / newzoom *.* mousep
|
& scopePos .+.+~ (1 - zoomSpeed) / newzoom *.* mousep
|
||||||
& scopeZoom %~ (/ zoomSpeed)
|
& scopeZoom %~ (/ zoomSpeed)
|
||||||
& decreaseScopeZoomChange
|
& scopeZoomChange -~ 1
|
||||||
| otherwise = sc & scopeZoomChange .~ 0
|
| otherwise = sc & scopeZoomChange .~ 0
|
||||||
where
|
where
|
||||||
decreaseScopeZoomChange = scopeZoomChange -~ 1
|
|
||||||
Just currentZoom = sc ^? scopeZoom
|
Just currentZoom = sc ^? scopeZoom
|
||||||
newzoom = (sc ^?! scopeZoom) / zoomSpeed
|
newzoom = (sc ^?! scopeZoom) / zoomSpeed
|
||||||
|
|
||||||
zoomOutLongGun :: Scope -> Scope
|
zoomOutLongGun :: Scope -> Scope
|
||||||
zoomOutLongGun sc
|
zoomOutLongGun sc
|
||||||
| currentZoom > 0.5 =
|
| currentzoom > 0.5 =
|
||||||
sc
|
sc
|
||||||
-- & scopePos .+.+~ ((1*zoomSpeed-1)) / currentZoom *.* mousep
|
& scopePos %~ (\p -> p +.+ (zoomSpeed-1) / currentzoom *.* p)
|
||||||
|
-- & scopePos .*.*~ 1 - ((newzoom * 2) ** zoomSpeed)
|
||||||
& scopeZoom *~ zoomSpeed
|
& scopeZoom *~ zoomSpeed
|
||||||
& scopeZoomChange +~ 1
|
& scopeZoomChange +~ 1
|
||||||
| otherwise = sc & scopeZoomChange .~ 0
|
| otherwise = sc & scopeZoomChange .~ 0
|
||||||
|
& scopePos .~ V2 0 0
|
||||||
where
|
where
|
||||||
Just currentZoom = sc ^? scopeZoom
|
Just currentzoom = sc ^? scopeZoom
|
||||||
|
--newzoom = (sc ^?! scopeZoom) / zoomSpeed
|
||||||
|
|
||||||
ifConfigWallRotate :: Configuration -> World -> World
|
ifConfigWallRotate :: Configuration -> World -> World
|
||||||
ifConfigWallRotate cfig w
|
ifConfigWallRotate cfig w
|
||||||
|
|||||||
Reference in New Issue
Block a user