Change behaviour when clicking on filter

This commit is contained in:
2024-11-26 11:59:26 +00:00
parent 145ab77859
commit a4d95c5bd5
6 changed files with 35 additions and 11 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ data MouseContext
} }
| OverInvDragSelect { _mcoSecSelStart :: (Int,Int), _mcoSelEnd :: Maybe Int } | OverInvDragSelect { _mcoSecSelStart :: (Int,Int), _mcoSelEnd :: Maybe Int }
| OverInvSelect { _mcoInvSelect :: (Int,Int)} | OverInvSelect { _mcoInvSelect :: (Int,Int)}
| OverInvFilt { _mcoInvFilt :: (Int,Int)} | OverCombFiltInv { _mcoInvFilt :: (Int,Int)}
| OverCombSelect { _mcoCombSelect :: (Int,Int)} | OverCombSelect { _mcoCombSelect :: (Int,Int)}
| OverCombCombine { _mcoCombCombine :: (Int,Int)} | OverCombCombine { _mcoCombCombine :: (Int,Int)}
| OverCombFilter | OverCombFilter
+1 -1
View File
@@ -160,7 +160,7 @@ updateDisplaySections w cfig =
makehead str i = (i,IM.singleton 0 $ SelectionInfo [str] 1 False white 0) makehead str i = (i,IM.singleton 0 $ SelectionInfo [str] 1 False white 0)
statushead = (-4,IM.singleton 0 $ SelectionInfo ["STATUS"] 1 False white 0) statushead = (-4,IM.singleton 0 $ SelectionInfo ["STATUS"] 1 False white 0)
statusdisplay = (-3,IM.singleton 0 $ SelectionInfo ["HEALTH: "++show (_crHP cr)] 1 False white 0) statusdisplay = (-3,IM.singleton 0 $ SelectionInfo ["HEALTH: "++show (_crHP cr)] 1 False white 0)
invhead = if null sfinv then makehead "INVENTORY" (-2) else filtinv invhead = if null sfinv then makehead "INVENTORY" (-1) else filtinv
youitems = IM.singleton 0 $ SelectionItem [thetext] 1 True invDimColor 2 () youitems = IM.singleton 0 $ SelectionItem [thetext] 1 True invDimColor 2 ()
thetext = displayFreeSlots (crNumFreeSlots cr) thetext = displayFreeSlots (crNumFreeSlots cr)
closeitms = closeitms =
+2 -1
View File
@@ -362,7 +362,8 @@ drawTerminalDisplay tid cfig w = fromMaybe mempty $ do
return $ return $
invHead cfig (_tmTitle tm ++ ":T" ++ show tid) invHead cfig (_tmTitle tm ++ ":T" ++ show tid)
<> drawSelectionList secondColumnParams cfig (thesellist tm) <> drawSelectionList secondColumnParams cfig (thesellist tm)
<> color (withAlpha 0.5 green) (drawSelectionListBackground secondColumnParams cfig tsize) <> color (withAlpha 0.5 green) -- consider integrating termScreenColor somehow
(drawSelectionListBackground secondColumnParams cfig tsize)
<> color (dark $ _tmExternalColor tm) (drawTitleBackground cfig) <> color (dark $ _tmExternalColor tm) (drawTitleBackground cfig)
where where
toselitm (str, col) = SelectionItem [str] 1 True col 0 () toselitm (str, col) = SelectionItem [str] 1 True col 0 ()
+8 -4
View File
@@ -95,16 +95,19 @@ mouseCursorType u = case u ^. uvWorld . input . mouseContext of
OverInvDrag 3 _ _ _ -> drawEmptySet 5 OverInvDrag 3 _ _ _ -> drawEmptySet 5
OverInvDrag {} -> drawEmptySet 5 OverInvDrag {} -> drawEmptySet 5
OverInvDragSelect {} -> drawDragSelect 5 OverInvDragSelect {} -> drawDragSelect 5
OverInvSelect (-1,_) | selsec == Just (-1) -> drawJumpDown 5
OverInvSelect (2,_) | selsec == Just 2-> drawJumpDown 5
OverInvSelect {} -> drawSelect 5 OverInvSelect {} -> drawSelect 5
OverInvFilt {} -> drawCombFilter 5 OverCombFiltInv {} -> drawCombFilter 5
OverCombSelect {} -> drawSelect 5 OverCombSelect {} -> drawSelect 5
OverCombFilter {} -> drawCombFilterJump 5 OverCombFilter {} -> drawJumpDown 5
OverCombCombine {} -> drawGapPlus 5 OverCombCombine {} -> drawGapPlus 5
OverCombEscape -> rotate (pi/4) $ drawPlus 5 OverCombEscape -> rotate (pi/4) $ drawPlus 5
OverTerminalReturn {} -> drawReturn 5 OverTerminalReturn {} -> drawReturn 5
OverTerminalEscape -> rotate (pi/4) $ drawPlus 5 OverTerminalEscape -> rotate (pi/4) $ drawPlus 5
where where
w = u ^. uvWorld w = u ^. uvWorld
selsec = u ^? uvWorld . hud . hudElement . diSelection . _Just . _1
a = fromMaybe 0 $ do a = fromMaybe 0 $ do
cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos
return . toClosestMultiple (pi / 32) $ return . toClosestMultiple (pi / 32) $
@@ -156,8 +159,9 @@ drawMenuCursor z = fold
y = x + z y = x + z
ny = - y ny = - y
nx = - x nx = - x
drawCombFilterJump :: Float -> Picture
drawCombFilterJump x = rotate (0.25*pi) drawJumpDown :: Float -> Picture
drawJumpDown x = rotate (0.25*pi)
$ fold [line [V2 0 0, V2 x 0], line [V2 0 0, V2 0 x]] $ fold [line [V2 0 0, V2 x 0], line [V2 0 0, V2 0 x]]
drawDragSelect :: Float -> Picture drawDragSelect :: Float -> Picture
+1 -1
View File
@@ -338,7 +338,7 @@ updateMouseContextGame cfig u = case u ^. uvWorld . input . mouseContext of
case w ^? hud . hudElement . subInventory . ciSelection of case w ^? hud . hudElement . subInventory . ciSelection of
Just _ -> do Just _ -> do
guard (i == 0) guard (i == 0)
return $ OverInvFilt selpos return $ OverCombFiltInv selpos
_ -> do _ -> do
guard $ ButtonRight `M.notMember` (w ^. input . mouseButtons) guard $ ButtonRight `M.notMember` (w ^. input . mouseButtons)
guard =<< sss ^? ix i . ssItems . ix j . siIsSelectable guard =<< sss ^? ix i . ssItems . ix j . siIsSelectable
+22 -3
View File
@@ -40,7 +40,7 @@ updateUseInputInGame u = updateFunctionKeys $ case u ^. uvWorld . hud . hudEleme
DisplayCarte -> over uvWorld updatePressedButtonsCarte u DisplayCarte -> over uvWorld updatePressedButtonsCarte u
DisplayInventory{_subInventory = si, _diSelection = disel} -> case si of DisplayInventory{_subInventory = si, _diSelection = disel} -> case si of
DisplayTerminal tmid -> updateKeysInTerminal tmid u DisplayTerminal tmid -> updateKeysInTerminal tmid u
CombineInventory{_ciSections = sss, _ciSelection = msel@(Just ((-1),_,_))} -> CombineInventory{_ciSections = sss, _ciSelection = msel@(Just (-1,_,_))} ->
u u
& uvWorld . hud . hudElement . subInventory & uvWorld . hud . hudElement . subInventory
%~ docombineregexinput sss msel %~ docombineregexinput sss msel
@@ -171,6 +171,12 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
return $ return $
w & input . mouseContext w & input . mouseContext
.~ OverInvDragSelect ysel Nothing .~ OverInvDragSelect ysel Nothing
OverInvSelect (-1,_) | selsec == Just (-1) -> w
& hud . hudElement . diSelection %~ endRegex (-1) w
& hud . hudElement . diInvFilter .~ Nothing
OverInvSelect (2,_) | selsec == Just 2 -> w
& hud . hudElement . diSelection %~ endRegex 2 w
& hud . hudElement . diCloseFilter .~ Nothing
OverInvSelect x | ScancodeLShift `M.member` (w ^. input . pressedKeys ) OverInvSelect x | ScancodeLShift `M.member` (w ^. input . pressedKeys )
-> fromMaybe w $ do -> fromMaybe w $ do
guard (isGroupSelectableSection $ fst x) guard (isGroupSelectableSection $ fst x)
@@ -195,7 +201,7 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
w w
& worldEventFlags . at InventoryChange ?~ () & worldEventFlags . at InventoryChange ?~ ()
& hud . hudElement . subInventory .~ NoSubInventory & hud . hudElement . subInventory .~ NoSubInventory
OverInvFilt (i, j) -> fromMaybe w $ do OverCombFiltInv (i, j) -> fromMaybe w $ do
guard $ i == 0 guard $ i == 0
str <- str <-
fmap (take 5) $ fmap (take 5) $
@@ -213,6 +219,18 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
ldp = invDisplayParams w ldp = invDisplayParams w
mpos = w ^. input . mousePos mpos = w ^. input . mousePos
f (x,y) = (x,y,mempty) f (x,y) = (x,y,mempty)
selsec = w ^? hud . hudElement . diSelection . _Just . _1
endRegex :: Int -> World
-> Maybe (Int,Int,IS.IntSet)
-> Maybe (Int,Int,IS.IntSet)
endRegex i w = fromMaybe id $ do
sss <- w ^? hud . hudElement . diSections
let j = fromMaybe 0 $ do
itms <- sss ^? ix i . ssItems
(k,_) <- IM.lookupMin itms
return k
return $ ssSetCursor (ssLookupDown i j) sss
startDrag :: (Int, Int) -> Configuration -> World -> World startDrag :: (Int, Int) -> Configuration -> World -> World
startDrag (a, b) cfig w = setcontext startDrag (a, b) cfig w = setcontext
@@ -394,7 +412,8 @@ doRegexInput inp i sss msel filts
) )
where where
endregex a b = endregex a b =
( sss & ix i . ssItems .~ mempty --( sss & ix i . ssItems .~ mempty
( sss -- & ix i . ssItems .~ mempty
, msel & ssSetCursor (ssLookupDown a b) sss , msel & ssSetCursor (ssLookupDown a b) sss
, Nothing , Nothing
) )