Allow to pick up item under cursor when in inventory
This commit is contained in:
@@ -1,15 +1,22 @@
|
|||||||
module Dodge.SelectedClose (getSelectedCloseObj, interactWithCloseObj) where
|
module Dodge.SelectedClose (getSelectedCloseObj, interactWithCloseObj) where
|
||||||
|
|
||||||
|
import Dodge.Inventory
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Dodge.Button.Event
|
import Dodge.Button.Event
|
||||||
import Dodge.Data.World
|
import Dodge.Data.World
|
||||||
import Dodge.Inventory.Add
|
import Dodge.Inventory.Add
|
||||||
import NewInt
|
import NewInt
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
import qualified Data.Map.Strict as M
|
||||||
|
import qualified SDL
|
||||||
|
|
||||||
-- assumes that, for picking up, you are selecting the item
|
-- assumes that, for picking up, you are selecting the item
|
||||||
interactWithCloseObj :: Either (NewInt ItmInt) Button -> World -> World
|
interactWithCloseObj :: Either (NewInt ItmInt) Button -> World -> World
|
||||||
interactWithCloseObj e w = worldEventFlags . at InventoryChange ?~ () $ case e of
|
interactWithCloseObj e w = worldEventFlags . at InventoryChange ?~ () $ case e of
|
||||||
|
(Left flit)
|
||||||
|
| SDL.ScancodeCapsLock `M.member` (w ^. input . pressedKeys)
|
||||||
|
, Just (Sel 0 j) <- w ^. hud . diSelection
|
||||||
|
-> scrollAugInvSel 1 $ pickUpItemAt j (i,_unNInt flit) w
|
||||||
(Left flit) -> pickUpItem i (_unNInt flit) w
|
(Left flit) -> pickUpItem i (_unNInt flit) w
|
||||||
(Right but) -> doButtonEvent (but ^. btEvent) but w
|
(Right but) -> doButtonEvent (but ^. btEvent) but w
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -536,6 +536,10 @@ pauseGame u = u & uvScreenLayers .~ [pauseMenu u] & pauseSound
|
|||||||
|
|
||||||
spaceAction :: World -> World
|
spaceAction :: World -> World
|
||||||
spaceAction w = case w ^. hud . subInventory of
|
spaceAction w = case w ^. hud . subInventory of
|
||||||
|
NoSubInventory
|
||||||
|
| ScancodeCapsLock `M.member` (w ^. input . pressedKeys)
|
||||||
|
, Just (Sel 0 j) <- w ^. hud . diSelection
|
||||||
|
-> maybe id interactWithCloseObj (getCloseObj w) w
|
||||||
NoSubInventory -> maybe id interactWithCloseObj (getCloseObj w) w
|
NoSubInventory -> maybe id interactWithCloseObj (getCloseObj w) w
|
||||||
_ -> w & hud . subInventory .~ NoSubInventory
|
_ -> w & hud . subInventory .~ NoSubInventory
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user