Change behaviour when clicking on filter
This commit is contained in:
@@ -29,7 +29,7 @@ data MouseContext
|
||||
}
|
||||
| OverInvDragSelect { _mcoSecSelStart :: (Int,Int), _mcoSelEnd :: Maybe Int }
|
||||
| OverInvSelect { _mcoInvSelect :: (Int,Int)}
|
||||
| OverInvFilt { _mcoInvFilt :: (Int,Int)}
|
||||
| OverCombFiltInv { _mcoInvFilt :: (Int,Int)}
|
||||
| OverCombSelect { _mcoCombSelect :: (Int,Int)}
|
||||
| OverCombCombine { _mcoCombCombine :: (Int,Int)}
|
||||
| OverCombFilter
|
||||
|
||||
@@ -160,7 +160,7 @@ updateDisplaySections w cfig =
|
||||
makehead str i = (i,IM.singleton 0 $ SelectionInfo [str] 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)
|
||||
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 ()
|
||||
thetext = displayFreeSlots (crNumFreeSlots cr)
|
||||
closeitms =
|
||||
|
||||
@@ -362,7 +362,8 @@ drawTerminalDisplay tid cfig w = fromMaybe mempty $ do
|
||||
return $
|
||||
invHead cfig (_tmTitle tm ++ ":T" ++ show tid)
|
||||
<> 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)
|
||||
where
|
||||
toselitm (str, col) = SelectionItem [str] 1 True col 0 ()
|
||||
|
||||
@@ -95,16 +95,19 @@ mouseCursorType u = case u ^. uvWorld . input . mouseContext of
|
||||
OverInvDrag 3 _ _ _ -> drawEmptySet 5
|
||||
OverInvDrag {} -> drawEmptySet 5
|
||||
OverInvDragSelect {} -> drawDragSelect 5
|
||||
OverInvSelect (-1,_) | selsec == Just (-1) -> drawJumpDown 5
|
||||
OverInvSelect (2,_) | selsec == Just 2-> drawJumpDown 5
|
||||
OverInvSelect {} -> drawSelect 5
|
||||
OverInvFilt {} -> drawCombFilter 5
|
||||
OverCombFiltInv {} -> drawCombFilter 5
|
||||
OverCombSelect {} -> drawSelect 5
|
||||
OverCombFilter {} -> drawCombFilterJump 5
|
||||
OverCombFilter {} -> drawJumpDown 5
|
||||
OverCombCombine {} -> drawGapPlus 5
|
||||
OverCombEscape -> rotate (pi/4) $ drawPlus 5
|
||||
OverTerminalReturn {} -> drawReturn 5
|
||||
OverTerminalEscape -> rotate (pi/4) $ drawPlus 5
|
||||
where
|
||||
w = u ^. uvWorld
|
||||
selsec = u ^? uvWorld . hud . hudElement . diSelection . _Just . _1
|
||||
a = fromMaybe 0 $ do
|
||||
cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos
|
||||
return . toClosestMultiple (pi / 32) $
|
||||
@@ -156,8 +159,9 @@ drawMenuCursor z = fold
|
||||
y = x + z
|
||||
ny = - y
|
||||
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]]
|
||||
|
||||
drawDragSelect :: Float -> Picture
|
||||
|
||||
+1
-1
@@ -338,7 +338,7 @@ updateMouseContextGame cfig u = case u ^. uvWorld . input . mouseContext of
|
||||
case w ^? hud . hudElement . subInventory . ciSelection of
|
||||
Just _ -> do
|
||||
guard (i == 0)
|
||||
return $ OverInvFilt selpos
|
||||
return $ OverCombFiltInv selpos
|
||||
_ -> do
|
||||
guard $ ButtonRight `M.notMember` (w ^. input . mouseButtons)
|
||||
guard =<< sss ^? ix i . ssItems . ix j . siIsSelectable
|
||||
|
||||
@@ -40,7 +40,7 @@ updateUseInputInGame u = updateFunctionKeys $ case u ^. uvWorld . hud . hudEleme
|
||||
DisplayCarte -> over uvWorld updatePressedButtonsCarte u
|
||||
DisplayInventory{_subInventory = si, _diSelection = disel} -> case si of
|
||||
DisplayTerminal tmid -> updateKeysInTerminal tmid u
|
||||
CombineInventory{_ciSections = sss, _ciSelection = msel@(Just ((-1),_,_))} ->
|
||||
CombineInventory{_ciSections = sss, _ciSelection = msel@(Just (-1,_,_))} ->
|
||||
u
|
||||
& uvWorld . hud . hudElement . subInventory
|
||||
%~ docombineregexinput sss msel
|
||||
@@ -171,6 +171,12 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
|
||||
return $
|
||||
w & input . mouseContext
|
||||
.~ 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 )
|
||||
-> fromMaybe w $ do
|
||||
guard (isGroupSelectableSection $ fst x)
|
||||
@@ -195,7 +201,7 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
|
||||
w
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
& hud . hudElement . subInventory .~ NoSubInventory
|
||||
OverInvFilt (i, j) -> fromMaybe w $ do
|
||||
OverCombFiltInv (i, j) -> fromMaybe w $ do
|
||||
guard $ i == 0
|
||||
str <-
|
||||
fmap (take 5) $
|
||||
@@ -213,6 +219,18 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
|
||||
ldp = invDisplayParams w
|
||||
mpos = w ^. input . mousePos
|
||||
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 (a, b) cfig w = setcontext
|
||||
@@ -394,7 +412,8 @@ doRegexInput inp i sss msel filts
|
||||
)
|
||||
where
|
||||
endregex a b =
|
||||
( sss & ix i . ssItems .~ mempty
|
||||
--( sss & ix i . ssItems .~ mempty
|
||||
( sss -- & ix i . ssItems .~ mempty
|
||||
, msel & ssSetCursor (ssLookupDown a b) sss
|
||||
, Nothing
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user