Work on inventory management
This commit is contained in:
@@ -5,6 +5,7 @@ module Dodge.Update.Camera (
|
||||
updateCamera,
|
||||
) where
|
||||
|
||||
import Dodge.InputFocus
|
||||
import Bound
|
||||
import Dodge.Viewpoints
|
||||
import Control.Monad
|
||||
@@ -44,7 +45,7 @@ moveZoomCamera cfig theinput cr campos =
|
||||
where
|
||||
cpos = _crPos cr
|
||||
mitm = do
|
||||
i <- cr ^? crInvSel . isel . ispItem
|
||||
i <- cr ^? crManipulation . isel . ispItem
|
||||
cr ^? crInv . ix i
|
||||
newvf = cpos +.+ fromMaybe (V2 0 0) vfoffset
|
||||
vfoffset = do
|
||||
@@ -86,7 +87,7 @@ moveZoomCamera cfig theinput cr campos =
|
||||
|
||||
updateScopeZoom :: World -> World
|
||||
updateScopeZoom w = fromMaybe w $ do
|
||||
i <- w ^? cWorld . lWorld . creatures . ix 0 . crInvSel . isel . ispItem
|
||||
i <- w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . isel . ispItem
|
||||
return $ updateScopeZoom' i w
|
||||
|
||||
updateScopeZoom' :: Int -> World -> World
|
||||
@@ -178,7 +179,7 @@ rotateCameraBy x w =
|
||||
w
|
||||
& camPos . camRot +~ x
|
||||
& fromMaybe id (do
|
||||
i <- w ^? lWorld . creatures . ix 0 . crInvSel . isel . ispItem
|
||||
i <- w ^? lWorld . creatures . ix 0 . crManipulation . isel . ispItem
|
||||
return $ lWorld . creatures . ix 0 . crInv . ix i
|
||||
. itScope
|
||||
. scopePos
|
||||
@@ -187,17 +188,12 @@ rotateCameraBy x w =
|
||||
|
||||
rotateCamera :: Configuration -> World -> World
|
||||
rotateCamera cfig w
|
||||
| keyl && keyr = w
|
||||
| keyl = over cWorld (rotateCameraBy 0.025) w
|
||||
| keyr = over cWorld (rotateCameraBy (-0.025)) w
|
||||
| keydown SDL.ScancodeQ && keydown SDL.ScancodeE = w
|
||||
| keydown SDL.ScancodeQ = over cWorld (rotateCameraBy 0.025) w
|
||||
| keydown SDL.ScancodeE = over cWorld (rotateCameraBy (-0.025)) w
|
||||
| otherwise = ifConfigWallRotate cfig w
|
||||
where
|
||||
keyl = SDL.ScancodeQ `M.member` _pressedKeys (_input w) && notAtTerminal w
|
||||
keyr = SDL.ScancodeE `M.member` _pressedKeys (_input w) && notAtTerminal w
|
||||
|
||||
-- TODO check where/how this is used
|
||||
notAtTerminal :: World -> Bool
|
||||
notAtTerminal w = isNothing $ w ^? hud . hudElement . subInventory . termID
|
||||
keydown scode = scode `M.member` _pressedKeys (_input w) && not (inputFocus w)
|
||||
|
||||
--zoomCamBy :: Float -> World -> World
|
||||
--zoomCamBy x w = w {_cameraZoom = max (_cameraZoom w + x) 0.01}
|
||||
|
||||
@@ -79,7 +79,9 @@ doInvRegexInput :: Universe -> Universe
|
||||
doInvRegexInput u
|
||||
| backspacetonothing
|
||||
= u & uvWorld . hud . hudElement . diSections %~ overSection
|
||||
( ssRegex .~ EmptyRegex )
|
||||
( ( ssRegex .~ EmptyRegex )
|
||||
. ( ssItems . at (-1) .~ Nothing)
|
||||
)
|
||||
-- . initialSelPos )
|
||||
-- & uvWorld . hud . hudElement . diSections %~ setShownIntMap
|
||||
| endkeys || endmouse = u
|
||||
@@ -122,7 +124,13 @@ updateKeysInTerminal tmid u =
|
||||
| otherwise = id
|
||||
|
||||
updateKeyInGame :: Universe -> Scancode -> PressType -> Universe
|
||||
updateKeyInGame uv sc InitialPress = case sc of
|
||||
updateKeyInGame uv sc pt = case pt of
|
||||
InitialPress -> updateInitialPressInGame uv sc
|
||||
LongPress -> updateLongPressInGame uv sc
|
||||
_ -> uv
|
||||
|
||||
updateInitialPressInGame :: Universe -> Scancode -> Universe
|
||||
updateInitialPressInGame uv sc = case sc of
|
||||
ScancodeF5 -> doQuicksave uv
|
||||
ScancodeF9 -> loadSaveSlot QuicksaveSlot uv
|
||||
ScancodeEscape -> pauseGame uv
|
||||
@@ -137,20 +145,19 @@ updateKeyInGame uv sc InitialPress = case sc of
|
||||
-- the following should be put in a more sensible place
|
||||
ScancodeSlash -> uv & uvWorld . hud . hudElement %~ updateEnterRegex
|
||||
ScancodeBackspace -> uv & uvWorld . hud . hudElement %~ updateBackspaceRegex
|
||||
|
||||
-- in fact the whole logic should probably be rethought, oh well
|
||||
_ -> uv
|
||||
updateKeyInGame uv sc LongPress = case sc of
|
||||
|
||||
updateLongPressInGame :: Universe -> Scancode -> Universe
|
||||
updateLongPressInGame uv sc = case sc of
|
||||
ScancodeF -> over uvWorld youDropItem uv
|
||||
ScancodeSpace -> over uvWorld spaceAction uv
|
||||
_ -> uv
|
||||
updateKeyInGame uv _ _ = uv
|
||||
|
||||
updateBackspaceRegex :: HUDElement -> HUDElement
|
||||
updateBackspaceRegex di = case di ^? subInventory of
|
||||
Just NoSubInventory -> di & diSections %~ overSection
|
||||
( (ssRegex %~ backssregex)
|
||||
. (ssCursor .~ Just (SectionCursor (-1) 0 1 white))
|
||||
. (ssCursor ?~ SectionCursor (-1) 0 1 white)
|
||||
)
|
||||
Just CombineInventory {} -> di
|
||||
& subInventory . subInvMap . smRegex %~ enternonzeroregex
|
||||
@@ -165,7 +172,9 @@ updateBackspaceRegex di = case di ^? subInventory of
|
||||
|
||||
updateEnterRegex :: HUDElement -> HUDElement
|
||||
updateEnterRegex di = case di ^? subInventory of
|
||||
Just NoSubInventory -> di & diSections %~ overSection (ssRegex %~ enterssregex)
|
||||
Just NoSubInventory -> di & diSections %~ overSection
|
||||
( (ssRegex %~ enterssregex)
|
||||
)
|
||||
Just CombineInventory {} -> di
|
||||
& subInventory . subInvMap . smRegex %~ enterregex
|
||||
& subInventory . subInvMap . smSelPos ?~ 0
|
||||
|
||||
@@ -104,7 +104,7 @@ moveTweakSel i w = case yourItem w ^? _Just . itTweaks . tweakParams of
|
||||
|
||||
changeTweakParam :: Maybe Int -> Int -> World -> World
|
||||
changeTweakParam mi i w = fromMaybe w $ do
|
||||
curpos <- you w ^? crInvSel . isel . ispItem
|
||||
curpos <- you w ^? crManipulation . isel . ispItem
|
||||
paramid <- mi
|
||||
params <- yourItem w ^? _Just . itTweaks . tweakParams . ix paramid
|
||||
let x = (_tweakVal params + i) `mod` _tweakMax params
|
||||
|
||||
Reference in New Issue
Block a user