Start to generalise text input to "terminal signal" input
This commit is contained in:
+21
-15
@@ -26,15 +26,21 @@ 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 =
|
||||
updateCamera cfig w = case w ^. cWorld . cwCam . camControl of
|
||||
CamInGame -> updateInGameCamera cfig w
|
||||
CamFloat -> w
|
||||
CamPan -> w
|
||||
|
||||
updateInGameCamera :: Configuration -> World -> World
|
||||
updateInGameCamera cfig w =
|
||||
w
|
||||
& updateBounds cfig
|
||||
& over (cWorld . cwCamPos) (setViewDistance cfig)
|
||||
& cWorld . cwCamPos %~ moveZoomCamera cfig (w ^. input) (you w)
|
||||
& over (cWorld . cwCam) (setViewDistance cfig)
|
||||
& cWorld . cwCam %~ moveZoomCamera cfig (w ^. input) (you w)
|
||||
& updateScopeZoom
|
||||
& rotateCamera cfig
|
||||
|
||||
moveZoomCamera :: Configuration -> Input -> Creature -> CamPos -> CamPos
|
||||
moveZoomCamera :: Configuration -> Input -> Creature -> Camera -> Camera
|
||||
moveZoomCamera cfig theinput cr campos =
|
||||
campos
|
||||
& camCenter .~ newcen
|
||||
@@ -98,7 +104,7 @@ updateScopeZoom' i w
|
||||
wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix i . itScope
|
||||
resetscope (ZoomScope _ _ _ defz bl) = ZoomScope (V2 0 0) 0 defz defz bl
|
||||
resetscope otherAtt = otherAtt
|
||||
mp = rotateV (w ^. cWorld . cwCamPos . camRot) $ _mousePos (_input w)
|
||||
mp = rotateV (w ^. cWorld . cwCam . camRot) $ _mousePos (_input w)
|
||||
|
||||
doScopeZoom :: Point2 -> Scope -> Scope
|
||||
doScopeZoom mp sc = case sc ^? scopeZoomChange of
|
||||
@@ -163,11 +169,11 @@ rotateToOverlappingWall w =
|
||||
p = _crPos (you w)
|
||||
|
||||
doWallRotate :: Wall -> World -> World
|
||||
doWallRotate wl w = rotateUsing $ (argV . uncurry (-.-) $ _wlLine wl) - (w ^. cWorld . cwCamPos . camRot)
|
||||
doWallRotate wl w = rotateUsing $ (argV . uncurry (-.-) $ _wlLine wl) - (w ^. cWorld . cwCam . camRot)
|
||||
where
|
||||
rotateUsing a
|
||||
| b - b' > 0.01 = w & cWorld . cwCamPos . camRot +~ 0.01
|
||||
| b - b' < negate 0.01 = w & cWorld . cwCamPos . camRot -~ 0.01
|
||||
| b - b' > 0.01 = w & cWorld . cwCam . camRot +~ 0.01
|
||||
| b - b' < negate 0.01 = w & cWorld . cwCam . camRot -~ 0.01
|
||||
| otherwise = w
|
||||
where
|
||||
--b = a * (2 / pi)
|
||||
@@ -177,7 +183,7 @@ doWallRotate wl w = rotateUsing $ (argV . uncurry (-.-) $ _wlLine wl) - (w ^. cW
|
||||
rotateCameraBy :: Float -> CWorld -> CWorld
|
||||
rotateCameraBy x w =
|
||||
w
|
||||
& cwCamPos . camRot +~ x
|
||||
& cwCam . camRot +~ x
|
||||
& rotateanyscope
|
||||
where
|
||||
rotateanyscope = fromMaybe id $ do
|
||||
@@ -208,7 +214,7 @@ clipZoom ::
|
||||
Float
|
||||
clipZoom = min 20 . max 0.2
|
||||
|
||||
setViewDistance :: Configuration -> CamPos -> CamPos
|
||||
setViewDistance :: Configuration -> Camera -> Camera
|
||||
setViewDistance cfig w =
|
||||
w & camViewDistance
|
||||
.~ sqrt (halfWidth cfig ** 2 + halfHeight cfig ** 2) / (w ^. camZoom)
|
||||
@@ -218,7 +224,7 @@ farWallDistDirection p w =
|
||||
boundPoints $
|
||||
map f $ getViewpoints p (_cWorld w)
|
||||
where
|
||||
f q = (rotateV (negate (w ^. cWorld . cwCamPos . camRot)) . (-.- p)) (foldl' findPoint q (wls q))
|
||||
f q = (rotateV (negate (w ^. cWorld . cwCam . camRot)) . (-.- p)) (foldl' findPoint q (wls q))
|
||||
wls q = filter wlIsOpaque $ wlsNearSeg p q w
|
||||
findPoint q = fromMaybe q . uncurry (intersectSegSeg p q) . _wlLine
|
||||
|
||||
@@ -226,7 +232,7 @@ findBoundDists :: Configuration -> World -> (Float, Float, Float, Float)
|
||||
findBoundDists cfig w
|
||||
| debugOn Bound_box_screen cfig = (hh, - hh, hw, - hw)
|
||||
-- | otherwise = fromMaybe (0, 0, 0, 0) $ farWallDistDirection (w ^. cWorld . camPos . camCenter) w
|
||||
| otherwise = fromMaybe (0, 0, 0, 0) $ farWallDistDirection (w ^. cWorld . cwCamPos . camViewFrom) w
|
||||
| otherwise = fromMaybe (0, 0, 0, 0) $ farWallDistDirection (w ^. cWorld . cwCam . camViewFrom) w
|
||||
where
|
||||
hw = halfWidth cfig
|
||||
hh = halfHeight cfig
|
||||
@@ -234,8 +240,8 @@ findBoundDists cfig w
|
||||
updateBounds :: Configuration -> World -> World
|
||||
updateBounds cfig w =
|
||||
w
|
||||
& cWorld . cwCamPos . camBoundDist .~ bdists
|
||||
& cWorld . cwCamPos . camBoundBox
|
||||
.~ map ((+.+ w ^. cWorld . cwCamPos . camCenter) . rotateV (w ^. cWorld . cwCamPos . camRot)) (rectNSWE n s w' e)
|
||||
& cWorld . cwCam . camBoundDist .~ bdists
|
||||
& cWorld . cwCam . camBoundBox
|
||||
.~ map ((+.+ w ^. cWorld . cwCam . camCenter) . rotateV (w ^. cWorld . cwCam . camRot)) (rectNSWE n s w' e)
|
||||
where
|
||||
bdists@(n, s, e, w') = findBoundDists cfig w
|
||||
|
||||
Reference in New Issue
Block a user