Commit before messing with main inventory display
This commit is contained in:
@@ -5,6 +5,7 @@ module Dodge.Update.Input (
|
||||
doSubInvRegexInput,
|
||||
) where
|
||||
|
||||
import Dodge.DisplayInventory
|
||||
import SelectionIntMap
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Char
|
||||
@@ -91,7 +92,7 @@ updateKeyInGame uv sc InitialPress = case sc of
|
||||
ScancodeSpace -> over uvWorld spaceAction uv
|
||||
ScancodeP -> pauseGame uv
|
||||
ScancodeF -> over uvWorld youDropItem uv
|
||||
ScancodeM -> over uvWorld toggleMap uv
|
||||
ScancodeM -> toggleMap uv
|
||||
ScancodeR -> over (uvWorld . cWorld . lWorld . creatures . ix 0) crToggleReloading uv
|
||||
ScancodeT -> over uvWorld testEvent uv
|
||||
ScancodeX -> uv & uvWorld %~ toggleTweakInv
|
||||
@@ -119,24 +120,28 @@ pauseGame u = u & uvScreenLayers .~ [pauseMenu u]
|
||||
spaceAction :: World -> World
|
||||
spaceAction w = case w ^?! hud . hudElement of
|
||||
DisplayCarte -> w & hud . carteCenter .~ theLoc
|
||||
DisplayInventory NoSubInventory -> case selectedCloseObject w of
|
||||
DisplayInventory {_subInventory = NoSubInventory} -> case selectedCloseObject w of
|
||||
Just (_, Left flit) -> pickUpItem 0 flit w
|
||||
Just (_, Right but) -> doButtonEvent (_btEvent but) but w
|
||||
_ -> w
|
||||
DisplayInventory DisplayTerminal{} -> w & hud . hudElement . subInventory .~ NoSubInventory
|
||||
DisplayInventory {_subInventory = DisplayTerminal{}}
|
||||
-> w & hud . hudElement . subInventory .~ NoSubInventory
|
||||
_ -> w & hud . hudElement . subInventory .~ NoSubInventory
|
||||
where
|
||||
--theLoc = doWorldPos (fst (_seenLocations (_cWorld w) IM.! _selLocation (_cWorld w))) w
|
||||
theLoc = doWorldPos (w ^?! cWorld . lWorld . seenLocations . ix (w ^. cWorld . lWorld . selLocation) . _1) w
|
||||
|
||||
toggleMap :: World -> World
|
||||
toggleMap w = case w ^?! hud . hudElement of
|
||||
DisplayCarte -> w & hud . hudElement .~ DisplayInventory NoSubInventory
|
||||
_ -> w & hud . hudElement .~ DisplayCarte
|
||||
toggleMap :: Universe -> Universe
|
||||
toggleMap u = case u ^?! uvWorld . hud . hudElement of
|
||||
DisplayCarte -> u & uvWorld . hud . hudElement .~ DisplayInventory {_subInventory = NoSubInventory, _diSections = makeDisplayInventory w cfig}
|
||||
_ -> u & uvWorld . hud . hudElement .~ DisplayCarte
|
||||
where
|
||||
w = u ^. uvWorld
|
||||
cfig = u ^. uvConfig
|
||||
|
||||
toggleTweakInv :: World -> World
|
||||
toggleTweakInv w = case w ^. hud . hudElement of
|
||||
DisplayInventory ExamineInventory{} -> w & thepointer .~ NoSubInventory
|
||||
toggleTweakInv w = case w ^? hud . hudElement . subInventory of
|
||||
Just ExamineInventory{} -> w & thepointer .~ NoSubInventory
|
||||
_ -> w & thepointer .~ ExamineInventory mi
|
||||
where
|
||||
thepointer = hud . hudElement . subInventory
|
||||
|
||||
@@ -22,7 +22,7 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
|
||||
DisplayCarte
|
||||
| rbDown -> w & hud . carteZoom %~ min 0.75 . max 0.05 . ((1 + y * 0.1) *)
|
||||
| otherwise -> w & cWorld . lWorld . selLocation %~ (`mod` numLocs) . (+ yi)
|
||||
DisplayInventory NoSubInventory
|
||||
DisplayInventory {_subInventory = NoSubInventory}
|
||||
-- functions that modify the inventory should be centralised so that
|
||||
-- this lock can be sensibly applied, perhaps
|
||||
| w ^?! cWorld . lWorld . creatures . ix 0 . crInvLock -> w
|
||||
@@ -33,13 +33,14 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
|
||||
| lbDown -> w & cWorld . camPos . camZoom +~ y
|
||||
| invKeyDown -> changeSwapInvSel yi w
|
||||
| otherwise -> stopSoundFrom (CrReloadSound 0) $ changeAugInvSel yi w
|
||||
DisplayInventory (ExamineInventory mi)
|
||||
DisplayInventory {_subInventory = ExamineInventory mi}
|
||||
| invKeyDown && rbDown -> w & moveTweakSel yi
|
||||
| invKeyDown -> stopSoundFrom (CrReloadSound 0) $ changeInvSel yi w
|
||||
| rbDown -> w & changeTweakParam mi yi
|
||||
| otherwise -> w & moveTweakSel yi
|
||||
DisplayInventory (CombineInventory SelectionIntMap {_smRegexInput = False}) -> w & moveCombineSel yi
|
||||
DisplayInventory (DisplayTerminal tmid) -> terminalWheelEvent yi tmid w
|
||||
DisplayInventory {_subInventory = CombineInventory SelectionIntMap {_smRegexInput = False}}
|
||||
-> w & moveCombineSel yi
|
||||
DisplayInventory {_subInventory = DisplayTerminal tmid} -> terminalWheelEvent yi tmid w
|
||||
_ -> w
|
||||
where
|
||||
y = fromIntegral yi
|
||||
|
||||
@@ -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