Unify key press and mouse button press timings
Both now use Ints for presses. Still no release timer for keyboard events.
This commit is contained in:
@@ -15,13 +15,13 @@ import Dodge.Item.Grammar
|
||||
import Dodge.Item.Location
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
useItem :: Int -> PressType -> World -> Maybe World
|
||||
useItem :: Int -> Int -> World -> Maybe World
|
||||
useItem invid pt w = fmap (worldEventFlags . at InventoryChange ?~ ()) $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
itmloc <- invIndents (_crInv cr) ^? ix invid . _2
|
||||
useItemLoc cr itmloc pt w
|
||||
|
||||
useItemLoc :: Creature -> LocationDT OItem -> PressType -> World -> Maybe World
|
||||
useItemLoc :: Creature -> LocationDT OItem -> Int -> World -> Maybe World
|
||||
useItemLoc cr loc pt w
|
||||
| aimuse
|
||||
, fromMaybe False $ loc ^? locDT . dtValue . _1 . itLocation . ilIsAttached
|
||||
@@ -30,19 +30,19 @@ useItemLoc cr loc pt w
|
||||
| GadgetPlatformSF <- sf =
|
||||
return $ gadgetEffect pt loc cr w
|
||||
| RemoteDetonatorSF <- sf
|
||||
, pt == InitialPress =
|
||||
, pt == 0 =
|
||||
return $ activateDetonator ldt w
|
||||
| ITEMSCAN <- itm ^. itType
|
||||
, pt == InitialPress =
|
||||
, pt == 0 =
|
||||
return $ toggleExamineInv w
|
||||
| MAPPER <- itm ^. itType
|
||||
, pt == InitialPress =
|
||||
, pt == 0 =
|
||||
return $ toggleMapperInv itm w
|
||||
| Just b <- itm ^? itUse . useToggle
|
||||
, pt == InitialPress =
|
||||
, pt == 0 =
|
||||
return $ w & pointerToItem itm . itUse . useToggle .~ not b
|
||||
| isJust $ itm ^? itType . ibtEquip
|
||||
, pt == InitialPress
|
||||
, pt == 0
|
||||
, Just invid' <- itm ^? itLocation . ilInvID =
|
||||
return $ toggleEquipmentAt invid' cr w
|
||||
| otherwise = (\loc' -> useItemLoc cr loc' pt w) =<< locUp' loc
|
||||
|
||||
@@ -228,7 +228,7 @@ tryUseParent :: LocationDT OItem -> World -> World
|
||||
tryUseParent loc w = fromMaybe w $ do
|
||||
t <- locUp' loc
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
return $ gadgetEffect InitialPress t cr w
|
||||
return $ gadgetEffect 0 t cr w
|
||||
|
||||
tryDrawToCapacitor :: LocationDT OItem -> World -> World
|
||||
tryDrawToCapacitor loc w = fromMaybe w $ do
|
||||
|
||||
@@ -67,7 +67,7 @@ handleHotkeys w
|
||||
thehotkeys = M.mapKeys hotkeyToScancode $ w ^. cWorld . lWorld . hotkeys
|
||||
lw = w ^. cWorld . lWorld
|
||||
|
||||
useHotkey :: World -> (NewInt ItmInt, PressType) -> World
|
||||
useHotkey :: World -> (NewInt ItmInt, Int) -> World
|
||||
useHotkey w (NInt itid, pt) = fromMaybe w $ do
|
||||
invid <- w ^? cWorld . lWorld . itemLocations . ix itid . ilInvID
|
||||
useItem invid pt w
|
||||
@@ -228,8 +228,5 @@ tryClickUse pkeys w = fromMaybe w $ do
|
||||
. crManipulation
|
||||
. manObject
|
||||
. imSelectedItem of
|
||||
Just invid -> useItem invid (f ltime) w
|
||||
Just invid -> useItem invid ltime w
|
||||
Nothing -> interactWithCloseObj <$> getSelectedCloseObj w ?? w
|
||||
where
|
||||
f 0 = InitialPress
|
||||
f _ = ShortPress
|
||||
|
||||
Reference in New Issue
Block a user