Continue mouse refactor, add explicit release event/timer
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
module Dodge.Update.Input.InGame (
|
||||
updateUseInputInGame,
|
||||
updateMouseClickInGame,
|
||||
updateMouseInGame,
|
||||
) where
|
||||
|
||||
import Dodge.ListDisplayParams
|
||||
import Control.Applicative
|
||||
import Control.Monad
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
@@ -87,18 +88,27 @@ updateUseInputInGame u = updateFunctionKeys $ case u ^. uvWorld . hud . hudEleme
|
||||
& ciSelection .~ msel'
|
||||
& ciFilter .~ filts'
|
||||
|
||||
updateMouseClickInGame :: World -> World
|
||||
updateMouseClickInGame w = case w ^? input . mouseButtons . ix ButtonLeft of
|
||||
Just 0 -> updateMouseClickInGame' w
|
||||
Just _ -> w
|
||||
updateMouseInGame :: Configuration -> World -> World
|
||||
updateMouseInGame cfig w = case w ^? input . mouseButtons . ix ButtonLeft of
|
||||
Just 0 -> updateMouseClickInGame cfig w
|
||||
Just _ -> updateMouseHeldInGame w
|
||||
Nothing -> w
|
||||
|
||||
updateMouseClickInGame' :: World -> World
|
||||
updateMouseClickInGame' w = case w ^. input . mouseContext of
|
||||
OverInvSelect (i,j) -> w
|
||||
updateMouseHeldInGame :: World -> World
|
||||
updateMouseHeldInGame w = w
|
||||
|
||||
updateMouseClickInGame :: Configuration -> World -> World
|
||||
updateMouseClickInGame cfig w = case w ^. input . mouseContext of
|
||||
MouseInGame -> fromMaybe w $ do
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
ysel <- inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
|
||||
return $
|
||||
w & input . mouseContext
|
||||
.~ OverInvDragSelect ysel Nothing
|
||||
OverInvSelect x -> startDrag x w
|
||||
OverTerminalReturn tmid -> terminalReturnEffect tmid w
|
||||
OverTerminalEscape -> w
|
||||
& hud . hudElement . subInventory .~ NoSubInventory MouseInvNothing
|
||||
& hud . hudElement . subInventory .~ NoSubInventory --MouseInvNothing
|
||||
OverCombSelect x ->
|
||||
w & hud . hudElement . subInventory . ciSelection ?~ x
|
||||
& worldEventFlags . at CombineInventoryChange ?~ ()
|
||||
@@ -112,7 +122,7 @@ updateMouseClickInGame' w = case w ^. input . mouseContext of
|
||||
OverCombEscape ->
|
||||
w
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
& hud . hudElement . subInventory .~ NoSubInventory MouseInvNothing
|
||||
& hud . hudElement . subInventory .~ NoSubInventory --MouseInvNothing
|
||||
OverInvFilt (i, j) -> fromMaybe w $ do
|
||||
guard $ i == 0
|
||||
str <-
|
||||
@@ -127,6 +137,20 @@ updateMouseClickInGame' w = case w ^. input . mouseContext of
|
||||
& hud . hudElement . subInventory . ciFilter .~ Nothing
|
||||
_ -> w & hud . hudElement . subInventory . ciFilter ?~ ("<" ++ str)
|
||||
_ -> w
|
||||
where
|
||||
ldp = invDisplayParams w
|
||||
mpos = w ^. input . mousePos
|
||||
|
||||
startDrag :: (Int, Int) -> World -> World
|
||||
startDrag (a, b) w = fromMaybe (augInvDirectSelect (a, b) $ setmichosen 0 w) $ do
|
||||
(i, j) <- w ^? hud . hudElement . diSelection . _Just
|
||||
x <- w ^? hud . hudElement . diSelectionExtra
|
||||
guard $ i == a && b >= j && b <= j + x
|
||||
return $ setmichosen x w
|
||||
where
|
||||
setmichosen x =
|
||||
(input . mouseContext .~ OverInvDrag)
|
||||
. (hud . hudElement . diSelectionExtra .~ x)
|
||||
|
||||
updateFunctionKeys :: Universe -> Universe
|
||||
updateFunctionKeys u =
|
||||
@@ -321,11 +345,11 @@ spaceAction w = case w ^. hud . hudElement of
|
||||
_ -> w
|
||||
DisplayInventory{_subInventory = DisplayTerminal{}} ->
|
||||
w & hud . hudElement . subInventory
|
||||
.~ NoSubInventory MouseInvNothing
|
||||
.~ NoSubInventory --MouseInvNothing
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
_ ->
|
||||
w & hud . hudElement . subInventory
|
||||
.~ NoSubInventory MouseInvNothing
|
||||
.~ NoSubInventory --MouseInvNothing
|
||||
where
|
||||
theLoc =
|
||||
doWorldPos
|
||||
@@ -337,7 +361,7 @@ toggleMap u = case u ^. uvWorld . hud . hudElement of
|
||||
DisplayCarte ->
|
||||
u & uvWorld . hud . hudElement
|
||||
.~ DisplayInventory
|
||||
{ _subInventory = NoSubInventory MouseInvNothing
|
||||
{ _subInventory = NoSubInventory --MouseInvNothing
|
||||
, _diSections = defaultInvSections
|
||||
, _diSelection = Nothing
|
||||
, _diSelectionExtra = 0
|
||||
@@ -351,7 +375,7 @@ toggleTweakInv :: World -> World
|
||||
toggleTweakInv w = case w ^? hud . hudElement . subInventory of
|
||||
Just ExamineInventory{} ->
|
||||
w
|
||||
& thepointer .~ NoSubInventory MouseInvNothing
|
||||
& thepointer .~ NoSubInventory --MouseInvNothing
|
||||
_ -> w & thepointer .~ ExamineInventory -- mi
|
||||
where
|
||||
thepointer = hud . hudElement . subInventory
|
||||
@@ -375,4 +399,4 @@ maybeExitCombine w
|
||||
| ButtonRight `M.member` (w ^. input . mouseButtons) = w
|
||||
| otherwise =
|
||||
w & hud . hudElement . subInventory
|
||||
.~ NoSubInventory MouseInvNothing
|
||||
.~ NoSubInventory --MouseInvNothing
|
||||
|
||||
Reference in New Issue
Block a user