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
|
||||
|
||||
@@ -8,6 +8,7 @@ import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
import Dodge.Base.You
|
||||
import Dodge.Button.Event
|
||||
import Dodge.Camera
|
||||
import Dodge.Creature.Action
|
||||
import Dodge.Data.Combine
|
||||
import Dodge.Data.Universe
|
||||
@@ -46,9 +47,6 @@ updateUseInputInGame h u = case h of
|
||||
(uvWorld . worldEventFlags . at InventoryChange ?~ ()) . maybeExitCombine $
|
||||
over uvWorld (tryCombine sss) u
|
||||
& uvWorld . worldEventFlags . at CombineInventoryChange ?~ ()
|
||||
-- _ -> case regexFocus w of
|
||||
-- Nothing -> M.foldlWithKey' updateKeyInGame u pkeys
|
||||
-- Just (filtpoint,selpoint,i) -> u & uvWorld . p %~ doRegexInput
|
||||
_
|
||||
| inInvRegex (u ^. uvWorld) ->
|
||||
u & uvWorld . hud . hudElement . diSections %~ doRegexInput u (-1)
|
||||
@@ -108,6 +106,8 @@ updateKeyInGame uv sc pt = case pt of
|
||||
|
||||
updateInitialPressInGame :: Universe -> Scancode -> Universe
|
||||
updateInitialPressInGame uv sc = case sc of
|
||||
ScancodeF2 -> pauseAndFloatCam uv
|
||||
ScancodeF3 -> pauseAndPanCam uv
|
||||
ScancodeF5 -> doQuicksave uv
|
||||
ScancodeF9 -> doQuickload uv
|
||||
ScancodeEscape -> pauseGame uv
|
||||
|
||||
@@ -3,6 +3,7 @@ module Dodge.Update.Input.Text (
|
||||
doTextInputOver',
|
||||
) where
|
||||
|
||||
import Data.Either
|
||||
import Data.Char
|
||||
import Dodge.Data.Universe
|
||||
import LensHelp
|
||||
@@ -13,7 +14,7 @@ doTextInputOver p u = doTextInputOver' u p u
|
||||
|
||||
doTextInputOver' :: Universe -> ASetter' a String -> a -> a
|
||||
doTextInputOver' u p x =
|
||||
x & p %~ (++ map toUpper str)
|
||||
x & p %~ (++ map toUpper (rights str))
|
||||
& checkBackspace
|
||||
where
|
||||
str = u ^. uvWorld . input . textInput
|
||||
|
||||
@@ -30,7 +30,7 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
|
||||
(_, EquipOptions{}) -> w & rbOptions %~ scrollRBOption yi
|
||||
(Nothing, _) -> closeObjScrollDir y w
|
||||
(Just f, _) -> doHeldScroll f y (you w) w
|
||||
| lbDown -> w & cWorld . cwCamPos . camZoom +~ y
|
||||
| lbDown -> w & cWorld . cwCam . camZoom +~ y
|
||||
| invKeyDown -> changeSwapSel yi w
|
||||
| otherwise -> stopSoundFrom (CrReloadSound 0) $ scrollAugInvSel yi w
|
||||
DisplayInventory {_subInventory = ExamineInventory mi}
|
||||
|
||||
Reference in New Issue
Block a user