Work on selecting

This commit is contained in:
2026-05-13 16:07:44 +01:00
parent 2d731ae1ba
commit 44ecaf409e
6 changed files with 110 additions and 278 deletions
+19 -134
View File
@@ -211,70 +211,7 @@ updateMouseReleaseInGame cfig w = case w ^. input . mouseContext of
& hud . diSections . ix 0 . ssSet .~ mempty
& hud . diSections . ix 3 . ssSet .~ mempty
& doDragSelect cfig ssel
-- OverInvDragSelect (Just ssel) mesel
-- | ScancodeLShift `M.member` (w ^. input . pressedKeys) ->
-- w
-- & input
-- . mouseContext
-- .~ MouseInGame
-- & ( fromMaybe id $ do
-- j <- w ^? hud . diSelection . _Just . slSec
-- return $
-- hud
-- . diSections
-- . ix j
-- . ssSet
-- %~ getuniques
-- ( maybe
-- mempty
-- mempty
-- -- (h ssel)
-- (guard (ssel ^? _1 == w ^? hud . diSelection . _Just . slSec) >> mesel ^? _Just)
-- )
-- )
-- & hud
-- . diSections
-- . ix (fst ssel)
-- . ssSet
-- %~ getuniques
-- ( maybe
-- mempty
-- (h ssel)
-- (guard (ssel ^? _1 == w ^? hud . diSelection . _Just . slSec) >> mesel ^? _Just)
-- )
-- OverInvDragSelect (Just ssel) (Just esel) ->
-- w
-- & input
-- . mouseContext
-- .~ MouseInGame
-- -- & invSetSelection (f (fst ssel, esel) (h ssel esel))
-- & hud
-- . diSections
-- . ix (fst ssel)
-- . ssSet
-- .~ h ssel esel
-- & invSetSelection (f (fst ssel, esel))
-- OverInvDragSelect{} ->
-- w
-- & input
-- . mouseContext
-- .~ MouseInGame
-- -- & hud . diSelection . _Just . slSet %~ const mempty
-- & hud
-- . diSections
-- . each
-- . ssSet
-- %~ const mempty
_ -> w
where
f (x, y) = Sel x y
-- need to set this in OverInvDragSelect (twice)?
h (k, i) j = fold $ do
sss <- w ^? hud . diSections . ix k . ssItems
let (_, xss) = IM.split (min i j - 1) sss
(yss, _) = IM.split (max i j + 1) xss
return . IM.keysSet $ yss
doDragSelect :: Config -> XInfinity (Int,Int) -> World -> World
doDragSelect cfig x w = fromMaybe w $ do
@@ -291,45 +228,20 @@ doDragSelect cfig x w = fromMaybe w $ do
symmetricDifference :: IS.IntSet -> IS.IntSet -> IS.IntSet
symmetricDifference x y = (x `IS.union` y) IS.\\ (x `IS.intersection` y)
isGroupSelectableSection :: Int -> Bool
isGroupSelectableSection = \case
0 -> True
3 -> True
_ -> False
updateMouseClickInGame :: Config -> World -> World
updateMouseClickInGame cfig w = case w ^. input . mouseContext of
MouseInGame -> w & input . mouseContext .~ OverInvDragSelect
(inverseSelSecYint
(posSelSecYint cfig invDP (w ^. input . mousePos . _y))
(w ^. hud . diSections))
-- fromMaybe (w & input . mouseContext .~ OverInvDragSelect Nothing Nothing) $ do
-- let sss = w ^. hud . diSections
-- ysel <-
-- inverseSelSecYint
-- (posSelSecYint cfig invDP (w ^. input . mousePos . _y))
-- sss
-- ^? nonInf
-- guard (isGroupSelectableSection $ fst ysel)
-- return $ w & input . mouseContext .~ OverInvDragSelect (Just ysel) Nothing
OverInvSelect (-1, _)
| selsec == Just (-1) ->
w
& hud
. diSelection
%~ endRegex (-1) w
& hud
. diInvFilter
.~ Nothing
| selsec == Just (-1) -> w
& hud . diSelection %~ endRegex (-1) w
& hud . diInvFilter .~ Nothing
OverInvSelect (2, _)
| selsec == Just 2 ->
w
& hud
. diSelection
%~ endRegex 2 w
& hud
. diCloseFilter
.~ Nothing
| selsec == Just 2 -> w
& hud . diSelection %~ endRegex 2 w
& hud . diCloseFilter .~ Nothing
OverInvSelect (5, j) -> fromMaybe w $ do
k <- w ^? hud . closeButtons . ix j
but <- w ^? cWorld . lWorld . buttons . ix k
@@ -337,52 +249,25 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
OverInvSelect x
| ScancodeLShift `M.member` (w ^. input . pressedKeys)
-> w & input . mouseContext .~ OverInvDragSelect (NonInf x)
-- && isGroupSelectableSection (fst x) ->
-- w & input . mouseContext .~ OverInvDragSelect (Just x) (Just $ snd x)
OverInvSelect x -> startDrag x w
OverTerminal tmid TerminalTextInput{} -> terminalReturnEffect tmid w
OverTerminal tmid TerminalPressTo{} -> continueTerminal tmid w
OutsideTerminal -> w & hud . subInventory .~ NoSubInventory
OverCombSelect x ->
w
& hud
. subInventory
. ciSelection
?~ f x
& worldEventFlags
. at CombineInventoryChange
?~ ()
OverCombFilter ->
w
& hud
. subInventory
. ciFilter
.~ Nothing
& worldEventFlags
. at CombineInventoryChange
?~ ()
& hud
. subInventory
. ciSelection
%~ endCombineRegex w
OverCombCombine x ->
w
OverCombSelect x -> w
& hud . subInventory . ciSelection ?~ f x
& worldEventFlags . at CombineInventoryChange ?~ ()
OverCombFilter -> w
& hud . subInventory . ciFilter .~ Nothing
& worldEventFlags . at CombineInventoryChange ?~ ()
& hud . subInventory . ciSelection %~ endCombineRegex w
OverCombCombine x -> w
& tryCombine x
& worldEventFlags
. at CombineInventoryChange
?~ ()
& worldEventFlags
. at InventoryChange
?~ ()
& worldEventFlags . at CombineInventoryChange ?~ ()
& worldEventFlags . at InventoryChange ?~ ()
& maybeExitCombine
OverCombEscape ->
w
& worldEventFlags
. at InventoryChange
?~ ()
& hud
. subInventory
.~ NoSubInventory
OverCombEscape -> w
& worldEventFlags . at InventoryChange ?~ ()
& hud . subInventory .~ NoSubInventory
OverCombFiltInv (0, j) -> fromMaybe w $ do
str <-
fmap (take 5) $