Allow for swapping inventory items
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user