Commit before messing with main inventory display
This commit is contained in:
@@ -3,14 +3,13 @@ module Dodge.Update.UsingInput (
|
||||
updateUsingInput,
|
||||
) where
|
||||
|
||||
import Dodge.Combine
|
||||
import SelectionIntMap
|
||||
import Dodge.Data.Combine
|
||||
import Dodge.Data.SelectionList
|
||||
import Control.Lens
|
||||
import qualified Data.Map.Strict as M
|
||||
import Dodge.Base.You
|
||||
import Dodge.Combine
|
||||
import Dodge.Creature.Impulse.UseItem
|
||||
import Dodge.Data.Combine
|
||||
import Dodge.Data.SelectionList
|
||||
import Dodge.Data.World
|
||||
import Dodge.InputFocus
|
||||
import Dodge.Inventory
|
||||
@@ -19,10 +18,11 @@ import Dodge.Terminal.LeftButton
|
||||
import Geometry
|
||||
import ListHelp
|
||||
import SDL
|
||||
import SelectionIntMap
|
||||
|
||||
updateUsingInput :: World -> World
|
||||
updateUsingInput w = case w ^. hud . hudElement of
|
||||
DisplayInventory subinv ->
|
||||
DisplayInventory {_subInventory = subinv} ->
|
||||
pressedMBEffects subinv (_mouseButtons (_input w)) w
|
||||
DisplayCarte ->
|
||||
updatePressedButtonsCarte (_mouseButtons (_input w)) w
|
||||
@@ -30,9 +30,9 @@ updateUsingInput w = case w ^. hud . hudElement of
|
||||
pressedMBEffects :: SubInventory -> M.Map MouseButton Bool -> World -> World
|
||||
pressedMBEffects subinv pkeys w = case subinv of
|
||||
NoSubInventory -> pressedMBEffectsNoInventory pkeys w
|
||||
CombineInventory SelectionIntMap {_smSelPos = mi, _smRegexInput = False}
|
||||
CombineInventory SelectionIntMap{_smSelPos = mi, _smRegexInput = False}
|
||||
| lbinitialpress -> maybeexitcombine (maybe id doCombine mi w)
|
||||
CombineInventory SelectionIntMap {_smRegexInput = True}
|
||||
CombineInventory SelectionIntMap{_smRegexInput = True}
|
||||
| lbinitialpress -> w & hud . hudElement . subInventory . subInvMap . smRegexInput .~ False
|
||||
DisplayTerminal tmid
|
||||
| lbinitialpress && inTermFocus w ->
|
||||
@@ -43,9 +43,9 @@ pressedMBEffects subinv pkeys w = case subinv of
|
||||
where
|
||||
lbinitialpress = pkeys ^? ix ButtonLeft == Just False
|
||||
maybeexitcombine w'
|
||||
| ButtonRight `M.member` _mouseButtons (_input w)
|
||||
= (hud . hudElement . subInventory . subInvMap %~ setShownIntMap)
|
||||
$ (hud . hudElement . subInventory . subInvMap . smItems .~ combineList w') w'
|
||||
| ButtonRight `M.member` _mouseButtons (_input w) =
|
||||
(hud . hudElement . subInventory . subInvMap %~ setShownIntMap) $
|
||||
(hud . hudElement . subInventory . subInvMap . smItems .~ combineList w') w'
|
||||
| otherwise = w' & hud . hudElement . subInventory .~ NoSubInventory
|
||||
|
||||
pressedMBEffectsNoInventory :: M.Map MouseButton Bool -> World -> World
|
||||
@@ -58,7 +58,7 @@ pressedMBEffectsNoInventory pkeys w
|
||||
| otherwise = w
|
||||
where
|
||||
inTopInv = case w ^. hud . hudElement of
|
||||
DisplayInventory NoSubInventory -> True
|
||||
DisplayInventory {_subInventory = NoSubInventory} -> True
|
||||
_ -> False
|
||||
isDown but = but `M.member` pkeys
|
||||
rotation = angleBetween (_mousePos (_input w)) (_clickMousePos (_input w))
|
||||
@@ -68,13 +68,7 @@ pressedMBEffectsNoInventory pkeys w
|
||||
doCombine :: Int -> World -> World
|
||||
doCombine i w = case w ^? hud . hudElement . subInventory . subInvMap . smShownItems . ix i . siPayload of
|
||||
Nothing -> w
|
||||
Just (CombinableItem is it _) ->
|
||||
selectinv --enterCombineInv
|
||||
. createPutItem it
|
||||
$ foldr (rmInvItem 0) w (sort is)
|
||||
where
|
||||
selectinv (Just i', w') = w' & cWorld . lWorld . creatures . ix 0 . crInvSel .~ InvSel i' NoInvSelAction
|
||||
selectinv (Nothing, w') = w'
|
||||
Just (CombinableItem is it _) -> createAndSelectItem it $ foldr (rmInvItem 0) w (sort is)
|
||||
|
||||
updatePressedButtonsCarte :: M.Map MouseButton Bool -> World -> World
|
||||
updatePressedButtonsCarte pkeys w
|
||||
@@ -92,4 +86,5 @@ updatePressedButtonsCarte pkeys w
|
||||
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))
|
||||
trans = rotateV (w ^. hud . carteRot)
|
||||
$ 1 / (w ^. hud . carteZoom) *.* (_mousePos (_input w) -.- _clickMousePos (_input w))
|
||||
|
||||
Reference in New Issue
Block a user