diff --git a/src/Dodge/Data/Input.hs b/src/Dodge/Data/Input.hs index 50d24eb0f..a15128634 100644 --- a/src/Dodge/Data/Input.hs +++ b/src/Dodge/Data/Input.hs @@ -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 diff --git a/src/Dodge/DisplayInventory.hs b/src/Dodge/DisplayInventory.hs index 4e07bdb73..33ab36b87 100644 --- a/src/Dodge/DisplayInventory.hs +++ b/src/Dodge/DisplayInventory.hs @@ -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 = diff --git a/src/Dodge/Render/HUD.hs b/src/Dodge/Render/HUD.hs index 6eb1d1b57..3003b7567 100644 --- a/src/Dodge/Render/HUD.hs +++ b/src/Dodge/Render/HUD.hs @@ -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 () diff --git a/src/Dodge/Render/Picture.hs b/src/Dodge/Render/Picture.hs index 9a596065d..ac0b56b72 100644 --- a/src/Dodge/Render/Picture.hs +++ b/src/Dodge/Render/Picture.hs @@ -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 diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index fd9c392b0..d4f2cedc4 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -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 diff --git a/src/Dodge/Update/Input/InGame.hs b/src/Dodge/Update/Input/InGame.hs index 413c1b1e0..fd7c9e816 100644 --- a/src/Dodge/Update/Input/InGame.hs +++ b/src/Dodge/Update/Input/InGame.hs @@ -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 )