Continue shuffle
This commit is contained in:
@@ -2,6 +2,8 @@ module Dodge.Update.Input (
|
||||
updateUseInput,
|
||||
) where
|
||||
|
||||
import Dodge.Data.Combine
|
||||
import Geometry
|
||||
import Dodge.SelectionList
|
||||
import Dodge.Base.Window
|
||||
import Dodge.Menu.Option
|
||||
@@ -43,16 +45,28 @@ updateUseInputOnScreen sl = case sl of
|
||||
|
||||
updateUseInputInGame :: HUDElement -> Universe -> Universe
|
||||
updateUseInputInGame h u = case h of
|
||||
DisplayCarte -> u
|
||||
DisplayCarte -> over uvWorld updatePressedButtonsCarte u
|
||||
DisplayInventory si _ -> case si of
|
||||
DisplayTerminal tmid | inTermFocus (_uvWorld u) -> updateKeysInTerminal tmid u
|
||||
CombineInventory _ _ _
|
||||
DisplayTerminal tmid
|
||||
| lbinitialpress && inTermFocus w ->
|
||||
over uvWorld (doTerminalEffectLB (w ^?! cWorld . lWorld . terminals . ix tmid)) u
|
||||
| inTermFocus (_uvWorld u) -> updateKeysInTerminal tmid u
|
||||
| lbinitialpress ->
|
||||
u & uvWorld . cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const True
|
||||
CombineInventory _ _ sss
|
||||
| inSubInvRegex (u ^. uvWorld) -> doSubInvRegexInput u
|
||||
| lbinitialpress -> tryCombine sss u -- maybeexitcombine (maybe id doCombine mi w)
|
||||
_ | inInvRegex (u ^. uvWorld) -> doRegexInput (-1) invRegex invRegex u
|
||||
_ | inCloseRegex (u ^. uvWorld) -> doRegexInput 2 closeRegex closeRegex u
|
||||
_ -> M.foldlWithKey' updateKeyInGame u pkeys
|
||||
where
|
||||
w = u ^. uvWorld
|
||||
pkeys = u ^. uvWorld . input . pressedKeys
|
||||
pmb = u ^. uvWorld . input . mouseButtons
|
||||
lbinitialpress = pmb ^? ix ButtonLeft == Just False
|
||||
|
||||
tryCombine :: SelectionSections CombinableItem -> Universe -> Universe
|
||||
tryCombine sss w = w
|
||||
|
||||
doTextInputOver :: ASetter' Universe String -> Universe -> Universe
|
||||
doTextInputOver p u =
|
||||
@@ -374,3 +388,24 @@ setSelectionListRestriction :: Configuration -> ScreenLayer -> ScreenLayer
|
||||
setSelectionListRestriction cfig screen = fromMaybe screen $ do
|
||||
ldps <- screen ^? scListDisplayParams
|
||||
return $ screen & scAvailableLines %~ const (getAvailableListLines ldps cfig)
|
||||
|
||||
updatePressedButtonsCarte w = updatePressedButtonsCarte' (_mouseButtons (_input w)) w
|
||||
|
||||
updatePressedButtonsCarte' :: M.Map MouseButton Bool -> World -> World
|
||||
updatePressedButtonsCarte' pkeys w
|
||||
| isDown ButtonRight =
|
||||
w
|
||||
& input . clickMousePos .~ _mousePos (_input w)
|
||||
& hud . carteCenter %~ (-.- trans)
|
||||
| isDown ButtonLeft =
|
||||
w
|
||||
& input . clickMousePos .~ _mousePos (_input w)
|
||||
& hud . carteRot -~ rot
|
||||
& hud . carteZoom *~ czoom
|
||||
| otherwise = w
|
||||
where
|
||||
isDown but = but `M.member` pkeys
|
||||
rot = angleBetween (_mousePos (_input w)) (_clickMousePos (_input w))
|
||||
czoom = magV (_mousePos (_input w)) / magV (_clickMousePos (_input w))
|
||||
trans = rotateV (w ^. hud . carteRot)
|
||||
$ 1 / (w ^. hud . carteZoom) *.* (_mousePos (_input w) -.- _clickMousePos (_input w))
|
||||
|
||||
@@ -22,19 +22,11 @@ updateUsingInput :: World -> World
|
||||
updateUsingInput w = case w ^. hud . hudElement of
|
||||
DisplayInventory {_subInventory = subinv} ->
|
||||
pressedMBEffects subinv (_mouseButtons (_input w)) w
|
||||
DisplayCarte ->
|
||||
updatePressedButtonsCarte (_mouseButtons (_input w)) w
|
||||
DisplayCarte -> w
|
||||
|
||||
pressedMBEffects :: SubInventory -> M.Map MouseButton Bool -> World -> World
|
||||
pressedMBEffects subinv pkeys w = case subinv of
|
||||
NoSubInventory -> pressedMBEffectsNoInventory pkeys w
|
||||
CombineInventory _ _ sss
|
||||
| lbinitialpress -> tryCombine sss w -- maybeexitcombine (maybe id doCombine mi w)
|
||||
DisplayTerminal tmid
|
||||
| lbinitialpress && inTermFocus w ->
|
||||
doTerminalEffectLB (w ^?! cWorld . lWorld . terminals . ix tmid) w
|
||||
| lbinitialpress ->
|
||||
w & cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const True
|
||||
_ -> w
|
||||
where
|
||||
lbinitialpress = pkeys ^? ix ButtonLeft == Just False
|
||||
@@ -44,8 +36,6 @@ pressedMBEffects subinv pkeys w = case subinv of
|
||||
-- (hud . hudElement . subInventory . subInvMap . smItems .~ combineList w') w'
|
||||
-- | otherwise = w' & hud . hudElement . subInventory .~ NoSubInventory
|
||||
|
||||
tryCombine :: SelectionSections CombinableItem -> World -> World
|
||||
tryCombine sss w = w
|
||||
|
||||
pressedMBEffectsNoInventory :: M.Map MouseButton Bool -> World -> World
|
||||
pressedMBEffectsNoInventory pkeys w
|
||||
@@ -70,21 +60,3 @@ doCombine i w = undefined
|
||||
-- Nothing -> w
|
||||
-- Just (CombinableItem is it _) -> createAndSelectItem it $ foldr (rmInvItem 0) w (sort is)
|
||||
|
||||
updatePressedButtonsCarte :: M.Map MouseButton Bool -> World -> World
|
||||
updatePressedButtonsCarte pkeys w
|
||||
| isDown ButtonRight =
|
||||
w
|
||||
& input . clickMousePos .~ _mousePos (_input w)
|
||||
& hud . carteCenter %~ (-.- trans)
|
||||
| isDown ButtonLeft =
|
||||
w
|
||||
& input . clickMousePos .~ _mousePos (_input w)
|
||||
& hud . carteRot -~ rot
|
||||
& hud . carteZoom *~ czoom
|
||||
| otherwise = w
|
||||
where
|
||||
isDown but = but `M.member` pkeys
|
||||
rot = angleBetween (_mousePos (_input w)) (_clickMousePos (_input w))
|
||||
czoom = magV (_mousePos (_input w)) / magV (_clickMousePos (_input w))
|
||||
trans = rotateV (w ^. hud . carteRot)
|
||||
$ 1 / (w ^. hud . carteZoom) *.* (_mousePos (_input w) -.- _clickMousePos (_input w))
|
||||
|
||||
Reference in New Issue
Block a user