Allow for swapping inventory items

This commit is contained in:
2023-02-23 14:12:08 +00:00
parent 6fff71cdcc
commit 683acf8a05
9 changed files with 161 additions and 104 deletions
+25 -15
View File
@@ -1,6 +1,6 @@
module Dodge.Update.Input.InGame
( updateUseInputInGame
) where
module Dodge.Update.Input.InGame (
updateUseInputInGame,
) where
import qualified Data.IntMap.Strict as IM
import Data.List (sort)
@@ -39,10 +39,13 @@ updateUseInputInGame h u = case h of
| lbinitialpress ->
u & uvWorld . cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const True
CombineInventory{_ciSections = sss}
| inSubInvRegex (u ^. uvWorld) -> u & uvWorld . hud . hudElement . subInventory . ciSections %~ doRegexInput u (-1)
& uvWorld . worldEventFlags . at CombineInventoryChange ?~ ()
| lbinitialpress -> (uvWorld . worldEventFlags . at InventoryChange ?~ ()) . maybeExitCombine $ over uvWorld (tryCombine sss) u
| inSubInvRegex (u ^. uvWorld) ->
u & uvWorld . hud . hudElement . subInventory . ciSections %~ doRegexInput u (-1)
& uvWorld . worldEventFlags . at CombineInventoryChange ?~ ()
| lbinitialpress ->
(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
@@ -154,11 +157,16 @@ doRegexInput u i sss
updateBackspaceRegex :: World -> World
updateBackspaceRegex w = case di ^? subInventory of
Just NoSubInventory | secfocus (-1) 0 -> w & hud . hudElement . diSections %~ trybackspace (-1)
& worldEventFlags . at InventoryChange ?~ ()
Just NoSubInventory | secfocus 2 3 -> w & hud . hudElement . diSections %~ trybackspace 2
& worldEventFlags . at InventoryChange ?~ ()
Just CombineInventory{} -> w & hud . hudElement . subInventory . ciSections %~ trybackspace (-1)
Just NoSubInventory
| secfocus (-1) 0 ->
w & hud . hudElement . diSections %~ trybackspace (-1)
& worldEventFlags . at InventoryChange ?~ ()
Just NoSubInventory
| secfocus 2 3 ->
w & hud . hudElement . diSections %~ trybackspace 2
& worldEventFlags . at InventoryChange ?~ ()
Just CombineInventory{} ->
w & hud . hudElement . subInventory . ciSections %~ trybackspace (-1)
& worldEventFlags . at InventoryChange ?~ ()
_ -> w
where
@@ -208,10 +216,12 @@ spaceAction :: World -> World
spaceAction w = case w ^. hud . hudElement of
DisplayCarte -> w & hud . carteCenter .~ theLoc
DisplayInventory{_subInventory = NoSubInventory} -> case selectedCloseObject w of
Just (Left flit) -> pickUpItem 0 flit w
& worldEventFlags . at InventoryChange ?~ ()
Just (Right but) -> doButtonEvent (_btEvent but) but w
& worldEventFlags . at InventoryChange ?~ ()
Just (Left flit) ->
pickUpItem 0 flit w
& worldEventFlags . at InventoryChange ?~ ()
Just (Right but) ->
doButtonEvent (_btEvent but) but w
& worldEventFlags . at InventoryChange ?~ ()
_ -> w
DisplayInventory{_subInventory = DisplayTerminal{}} ->
w & hud . hudElement . subInventory .~ NoSubInventory
+1 -1
View File
@@ -31,7 +31,7 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
(Nothing, _) -> closeObjScrollDir y w
(Just f, _) -> doHeldScroll f y (you w) w
| lbDown -> w & cWorld . camPos . camZoom +~ y
| invKeyDown -> changeSwapInvSel yi w
| invKeyDown -> changeSwapSel yi w
| otherwise -> stopSoundFrom (CrReloadSound 0) $ scrollAugInvSel yi w
DisplayInventory {_subInventory = ExamineInventory mi}
| invKeyDown && rbDown -> w & moveTweakSel yi