Allow use of items while examine subinventory shows
Still not sure what to do with right click scrolling, item swapping
This commit is contained in:
@@ -23,8 +23,9 @@ import qualified SDL
|
||||
yourControl :: Creature -> World -> World
|
||||
yourControl _ w
|
||||
| inTextInputFocus w = w
|
||||
| Just x <- w ^? hud . hudElement . subInventory
|
||||
, f x = w
|
||||
| Just x <- w ^? hud . hudElement . subInventory
|
||||
, f x =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix 0
|
||||
%~ (wasdWithAiming w . setCrPosture pkeys)
|
||||
& tryClickUse pkeys
|
||||
@@ -69,6 +70,11 @@ hotkeyToScancode :: Hotkey -> SDL.Scancode
|
||||
hotkeyToScancode x = case x of
|
||||
HotkeyQ -> SDL.ScancodeQ
|
||||
HotkeyE -> SDL.ScancodeE
|
||||
HotkeyR -> SDL.ScancodeE
|
||||
HotkeyZ -> SDL.ScancodeZ
|
||||
HotkeyX -> SDL.ScancodeX
|
||||
HotkeyC -> SDL.ScancodeC
|
||||
HotkeyV -> SDL.ScancodeV
|
||||
Hotkey1 -> SDL.Scancode1
|
||||
Hotkey2 -> SDL.Scancode2
|
||||
Hotkey3 -> SDL.Scancode3
|
||||
@@ -84,6 +90,11 @@ scancodeToHotkey :: SDL.Scancode -> Maybe Hotkey
|
||||
scancodeToHotkey x = case x of
|
||||
SDL.ScancodeQ -> Just HotkeyQ
|
||||
SDL.ScancodeE -> Just HotkeyE
|
||||
SDL.ScancodeR -> Just HotkeyR
|
||||
SDL.ScancodeZ -> Just HotkeyZ
|
||||
SDL.ScancodeX -> Just HotkeyX
|
||||
SDL.ScancodeC -> Just HotkeyC
|
||||
SDL.ScancodeV -> Just HotkeyV
|
||||
SDL.Scancode1 -> Just Hotkey1
|
||||
SDL.Scancode2 -> Just Hotkey2
|
||||
SDL.Scancode3 -> Just Hotkey3
|
||||
@@ -166,16 +177,14 @@ tryClickUse :: M.Map SDL.MouseButton Int -> World -> World
|
||||
tryClickUse pkeys w = fromMaybe w $ do
|
||||
ltime <- pkeys ^? ix SDL.ButtonLeft
|
||||
rtime <- pkeys ^? ix SDL.ButtonRight
|
||||
guard $ ltime <= rtime && inTopInv
|
||||
invid <- w
|
||||
^? cWorld . lWorld . creatures . ix 0
|
||||
. crManipulation
|
||||
. manObject
|
||||
. imSelectedItem
|
||||
guard $ ltime <= rtime
|
||||
invid <-
|
||||
w
|
||||
^? cWorld . lWorld . creatures . ix 0
|
||||
. crManipulation
|
||||
. manObject
|
||||
. imSelectedItem
|
||||
useItem invid (f ltime) w
|
||||
where
|
||||
f 0 = InitialPress
|
||||
f _ = ShortPress
|
||||
inTopInv = case w ^. hud . hudElement of
|
||||
DisplayInventory{_subInventory = NoSubInventory{}} -> True
|
||||
_ -> False
|
||||
|
||||
Reference in New Issue
Block a user