Improve jump to hotkey
This commit is contained in:
@@ -40,7 +40,8 @@ yourControl _ w
|
||||
handleHotkeys :: World -> World
|
||||
handleHotkeys w
|
||||
| ispressed SDL.ScancodeLShift || ispressed SDL.ScancodeRShift
|
||||
, Just hk <- listToMaybe . mapMaybe scancodeToHotkey . M.keys $ w ^. input . pressedKeys
|
||||
, Just hk <-
|
||||
listToMaybe . mapMaybe scancodeToHotkey . M.keys $ w ^. input . pressedKeys
|
||||
, Just invid <- lw ^? creatures . ix 0 . crManipulation . manObject . imSelectedItem
|
||||
, Just itid <- lw ^? creatures . ix 0 . crInv . ix invid . itID =
|
||||
w & cWorld . lWorld %~ assignHotkey itid hk
|
||||
@@ -50,7 +51,7 @@ handleHotkeys w
|
||||
w ^. input . pressedKeys
|
||||
, Just itid <- lw ^? hotkeys . ix hk . unNInt
|
||||
, Just invid <- lw ^? itemLocations . ix itid . ilInvID =
|
||||
w & augInvDirectSelect (0, invid, mempty)
|
||||
w & invSetSelectionPos 0 invid
|
||||
| otherwise =
|
||||
M.foldl'
|
||||
useHotkey
|
||||
|
||||
+15
-3
@@ -4,7 +4,8 @@ module Dodge.Inventory (
|
||||
destroyInvItem,
|
||||
updateCloseObjects,
|
||||
changeSwapSel,
|
||||
augInvDirectSelect,
|
||||
invSetSelection,
|
||||
invSetSelectionPos,
|
||||
scrollAugInvSel,
|
||||
crNumFreeSlots,
|
||||
setInvPosFromSS,
|
||||
@@ -176,14 +177,25 @@ changeSwapWith f w = case w ^? hud . hudElement . diSelection . _Just of
|
||||
Just (5, i, _) -> w & changeSwapOther ispCloseButton 5 f i
|
||||
_ -> w
|
||||
|
||||
augInvDirectSelect :: (Int, Int, IS.IntSet) -> World -> World
|
||||
augInvDirectSelect sel w =
|
||||
invSetSelection :: (Int, Int, IS.IntSet) -> World -> World
|
||||
invSetSelection sel w =
|
||||
w
|
||||
& hud . hudElement . diSelection ?~ sel
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
& setInvPosFromSS
|
||||
& cWorld . lWorld %~ crUpdateItemLocations 0
|
||||
|
||||
invSetSelectionPos :: Int -> Int -> World -> World
|
||||
invSetSelectionPos i j w =
|
||||
w
|
||||
& hud . hudElement . diSelection %~ f
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
& setInvPosFromSS
|
||||
& cWorld . lWorld %~ crUpdateItemLocations 0
|
||||
where
|
||||
f Nothing = Just (i,j,mempty)
|
||||
f (Just (_,_,s)) = Just (i,j,s)
|
||||
|
||||
scrollAugInvSel :: Int -> World -> World
|
||||
scrollAugInvSel yi w
|
||||
| yi == 0 = w
|
||||
|
||||
@@ -175,7 +175,7 @@ updateMouseReleaseInGame w = case w ^. input . mouseContext of
|
||||
& hud . hudElement . diSelection . _Just . _3 %~ const mempty
|
||||
OverInvDragSelect ssel (Just esel) ->
|
||||
w & input . mouseContext .~ MouseInGame
|
||||
& augInvDirectSelect (f (fst ssel, esel) (h ssel esel))
|
||||
& invSetSelection (f (fst ssel, esel) (h ssel esel))
|
||||
_ -> w
|
||||
where
|
||||
getuniques x y = IS.union x y IS.\\ IS.intersection x y
|
||||
@@ -278,7 +278,7 @@ startDrag :: (Int, Int) -> Configuration -> World -> World
|
||||
startDrag (a, b) cfig w = setcontext
|
||||
$ case w ^? hud . hudElement . diSelection . _Just of
|
||||
Just (i,_,xs) | i == a && b `IS.member` xs -> w
|
||||
_ -> augInvDirectSelect (a, b, IS.singleton b) w
|
||||
_ -> invSetSelection (a, b, IS.singleton b) w
|
||||
where
|
||||
setcontext = input . mouseContext .~ OverInvDrag a (Just (a, b)) above bneath
|
||||
above = inverseSelSecYint (yint - 1) =<< w ^? hud . hudElement . diSections
|
||||
|
||||
Reference in New Issue
Block a user