Cleanup, delete hotkeys when deleting item from inventory
This commit is contained in:
+32
-31
@@ -14,23 +14,19 @@ import Dodge.Base
|
||||
import Dodge.Creature.Test
|
||||
import Dodge.Data.Config
|
||||
import Dodge.Data.World
|
||||
--import Dodge.Equipment
|
||||
--import Dodge.InputFocus
|
||||
import Dodge.SmoothScroll
|
||||
import Dodge.Viewpoints
|
||||
import Dodge.WASD
|
||||
import Dodge.Zoning.Wall
|
||||
import Geometry
|
||||
--import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
import SDL (MouseButton (..))
|
||||
--import qualified SDL
|
||||
|
||||
{- Update the screen camera rotation and position, including any in rold scope/remote camera modifiers;
|
||||
update where your avatar's view is from. -}
|
||||
updateCamera :: Configuration -> World -> World
|
||||
updateCamera cfig w = case w ^. wCam . camControl of
|
||||
CamInGame {} -> updateInGameCamera cfig w
|
||||
CamInGame{} -> updateInGameCamera cfig w
|
||||
CamFloat -> updateFloatingCamera cfig w
|
||||
|
||||
updateFloatingCamera :: Configuration -> World -> World
|
||||
@@ -62,15 +58,19 @@ translateFloatingCamera theinput cam = fromMaybe cam $ do
|
||||
return $ cam & camRot -~ angleBetween (theinput ^. mousePos) a
|
||||
|
||||
translateFloatingCameraKeys :: Input -> Camera -> Camera
|
||||
translateFloatingCameraKeys theinput = (camCenter -~ thetran) . (camViewFrom -~ thetran)
|
||||
translateFloatingCameraKeys theinput cam =
|
||||
cam
|
||||
& camCenter -~ thetran
|
||||
& camViewFrom -~ thetran
|
||||
where
|
||||
thetran = 10 *.* wasdDir theinput
|
||||
thetran = rotateV (cam ^. camRot) $ negate 10 *.* wasdDir theinput
|
||||
|
||||
zoomFloatingCamera :: Input -> Camera -> Camera
|
||||
zoomFloatingCamera theinput
|
||||
| ButtonRight `M.member` (theinput ^. mouseButtons) =
|
||||
camZoom *~ ((39/40) ^^ negate (getSmoothScrollValue theinput))
|
||||
camZoom *~ ((39 / 40) ^^ negate (getSmoothScrollValue theinput))
|
||||
| otherwise = id
|
||||
|
||||
-- the 39/40 is taken from zoomSpeed
|
||||
|
||||
updateInGameCamera :: Configuration -> World -> World
|
||||
@@ -78,14 +78,13 @@ updateInGameCamera cfig w =
|
||||
w
|
||||
& updateBounds cfig
|
||||
& wCam %~ moveZoomCamera cfig (w ^. input) (you w) w
|
||||
-- & updateScopeZoom
|
||||
& rotateCamera cfig
|
||||
& over wCam (setViewDistance cfig) -- I think this should be updated after the zoom?
|
||||
|
||||
moveZoomCamera :: Configuration -> Input -> Creature -> World -> Camera -> Camera
|
||||
moveZoomCamera cfig theinput cr w campos =
|
||||
campos
|
||||
& camCenter .~ fromMaybe (_crPos cr +.+ offset ) mremotepos
|
||||
& camCenter .~ fromMaybe (_crPos cr +.+ offset) mremotepos
|
||||
& camViewFrom .~ fromMaybe (_crPos cr) mremotepos
|
||||
& camZoom .~ newzoom
|
||||
& camDefaultZoom .~ newDefaultZoom
|
||||
@@ -101,9 +100,10 @@ moveZoomCamera cfig theinput cr w campos =
|
||||
guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
|
||||
i <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
fmap docamrot (cr ^? crInv . ix i . itUse . uScope . opticPos)
|
||||
noscopeoffset = docamrot $
|
||||
noscopeoffset =
|
||||
docamrot $
|
||||
((newzoom - newDefaultZoom) / (newDefaultZoom * newzoom)) *.* _mousePos theinput
|
||||
newzoom = fromMaybe (newDefaultZoom * newItemZoom) $ do
|
||||
newzoom = fromMaybe (newDefaultZoom * newItemZoom) $ do
|
||||
i <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
cr ^? crInv . ix i . itUse . uScope . opticZoom
|
||||
idealDefaultZoom = clipZoom wallZoom
|
||||
@@ -135,6 +135,21 @@ moveZoomCamera cfig theinput cr w campos =
|
||||
viewDistanceFromItems :: Creature -> Float
|
||||
viewDistanceFromItems _ = 1
|
||||
|
||||
rotateCamera :: Configuration -> World -> World
|
||||
rotateCamera cfig w
|
||||
| Just ltime <- pkeys ^? ix SDL.ButtonLeft
|
||||
, Just rtime <- pkeys ^? ix SDL.ButtonRight
|
||||
, ltime > rtime =
|
||||
w & wCam . camRot -~ rotation
|
||||
| otherwise = ifConfigWallRotate cfig (w ^. input . mouseButtons) w
|
||||
where
|
||||
pkeys = w ^. input . mouseButtons
|
||||
rotation =
|
||||
maybe
|
||||
0
|
||||
(angleBetween $ w ^. input . mousePos)
|
||||
(w ^. input . heldPos . at SDL.ButtonRight)
|
||||
|
||||
ifConfigWallRotate :: Configuration -> M.Map MouseButton Int -> World -> World
|
||||
ifConfigWallRotate cfig mbs
|
||||
| _gameplay_rotate_to_wall cfig && not (SDL.ButtonRight `M.member` mbs) =
|
||||
@@ -163,21 +178,6 @@ doWallRotate wl w = rotateUsing $ (argV . uncurry (-.-) $ _wlLine wl) - (w ^. wC
|
||||
b = a * (4 / pi)
|
||||
b' = fromIntegral (round b :: Int)
|
||||
|
||||
rotateCamera :: Configuration -> World -> World
|
||||
rotateCamera cfig w
|
||||
| Just ltime <- pkeys ^? ix SDL.ButtonLeft
|
||||
, Just rtime <- pkeys ^? ix SDL.ButtonRight
|
||||
, ltime > rtime = w & wCam . camRot -~ rotation
|
||||
| otherwise = ifConfigWallRotate cfig (w ^. input . mouseButtons) w
|
||||
where
|
||||
pkeys = w ^. input . mouseButtons
|
||||
rotation =
|
||||
maybe
|
||||
0
|
||||
(angleBetween $ w ^. input . mousePos)
|
||||
(w ^. input . heldPos . at SDL.ButtonRight)
|
||||
|
||||
|
||||
zoomFromItem :: ItZoom -> Float
|
||||
zoomFromItem ItZoom{_izMax = zMax, _izMin = zMin, _izFac = zFac} =
|
||||
min zMax $ max zMin zFac
|
||||
@@ -214,10 +214,11 @@ findBoundDists cfig w
|
||||
-- though I'm not sure how often it should be updated
|
||||
updateBounds :: Configuration -> World -> World
|
||||
updateBounds cfig w = case (w ^. cWorld . cClock) `mod` 5 of
|
||||
0 -> w
|
||||
& wCam . camBoundDist .~ bdists
|
||||
& wCam . camBoundBox
|
||||
.~ map ((+.+ w ^. wCam . camCenter) . rotateV (w ^. wCam . camRot)) (rectNSWE n s w' e)
|
||||
0 ->
|
||||
w
|
||||
& wCam . camBoundDist .~ bdists
|
||||
& wCam . camBoundBox
|
||||
.~ map ((+.+ w ^. wCam . camCenter) . rotateV (w ^. wCam . camRot)) (rectNSWE n s w' e)
|
||||
_ -> w
|
||||
where
|
||||
bdists@(n, s, e, w') = findBoundDists cfig w
|
||||
|
||||
Reference in New Issue
Block a user