diff --git a/src/Dodge/Creature/Action.hs b/src/Dodge/Creature/Action.hs index e8b280e82..2d89db913 100644 --- a/src/Dodge/Creature/Action.hs +++ b/src/Dodge/Creature/Action.hs @@ -188,8 +188,8 @@ dropItem cr invid w' = itid <- cr ^? crInv . ix (NInt invid) w' ^? cWorld . lWorld . items . ix itid maybeshiftseldown w = fromMaybe w $ do - 3 <- w ^? hud . diSelection . _Just . _1 - return $ w & hud . diSelection . _Just . _2 +~ 1 + 3 <- w ^? hud . diSelection . _Just . slSec + return $ w & hud . diSelection . _Just . slInt +~ 1 -- | Get your creature to drop the item under the cursor. youDropItem :: World -> World diff --git a/src/Dodge/Data/HUD.hs b/src/Dodge/Data/HUD.hs index f6b53e326..8907956a0 100644 --- a/src/Dodge/Data/HUD.hs +++ b/src/Dodge/Data/HUD.hs @@ -6,7 +6,6 @@ module Dodge.Data.HUD where import Control.Lens -import Data.IntSet (IntSet) import qualified Data.IntSet as IS import Dodge.Data.Combine import Dodge.Data.Item.Location @@ -24,7 +23,7 @@ data SubInventory } | CombineInventory { _ciSections :: IMSS CombinableItem - , _ciSelection :: Maybe (Int, Int, IS.IntSet) + , _ciSelection :: Maybe Selection , _ciFilter :: Maybe String } | DisplayTerminal {_termID :: Int} @@ -32,7 +31,7 @@ data SubInventory data HUD = HUD { _subInventory :: SubInventory , _diSections :: IMSS () - , _diSelection :: Maybe (Int, Int, IntSet) + , _diSelection :: Maybe Selection , _diInvFilter :: Maybe String , _diCloseFilter :: Maybe String , _carteCenter :: Point2 @@ -42,9 +41,8 @@ data HUD = HUD , _closeButtons :: [Int] } -data Selection - = Sel {_slSec :: Int, _slInt :: Int, _slSet :: IS.IntSet} - | NoSel +data Selection = Sel {_slSec :: Int, _slInt :: Int, _slSet :: IS.IntSet} makeLenses ''HUD +makeLenses ''Selection makeLenses ''SubInventory diff --git a/src/Dodge/Default/World.hs b/src/Dodge/Default/World.hs index e04ac2d81..2370da86f 100644 --- a/src/Dodge/Default/World.hs +++ b/src/Dodge/Default/World.hs @@ -161,7 +161,7 @@ defaultHUD = HUD { _subInventory = NoSubInventory , _diSections = mempty - , _diSelection = Just (1, 0, mempty) + , _diSelection = Just (Sel 1 0 mempty) , _diInvFilter = mempty , _diCloseFilter = mempty , _carteCenter = V2 0 0 diff --git a/src/Dodge/DisplayInventory.hs b/src/Dodge/DisplayInventory.hs index c9e8f2718..1f6f3bd7c 100644 --- a/src/Dodge/DisplayInventory.hs +++ b/src/Dodge/DisplayInventory.hs @@ -9,6 +9,7 @@ module Dodge.DisplayInventory ( toggleCombineInv, ) where +import Dodge.Data.HUD import Dodge.Inventory.CheckSlots import NewInt import Control.Applicative @@ -16,7 +17,6 @@ import Control.Lens import Control.Monad import Data.IntMap.Merge.Strict import qualified Data.IntMap.Strict as IM -import Data.IntSet (IntSet) import Data.Maybe import Data.Monoid import Dodge.Base.You @@ -55,7 +55,7 @@ updateCombineSections w cfig = (getAvailableListLines secondColumnParams cfig) (IM.fromDistinctAscList [(-1, sfclose),(0, sclose')]) where - filtcurs = w ^? hud . subInventory . ciSelection . _Just . _1 == Just (-1) + filtcurs = w ^? hud . subInventory . ciSelection . _Just . slSec == Just (-1) (sfclose, sclose) = filterSectionsPair filtcurs @@ -97,14 +97,14 @@ checkInventorySelectionExists w | isJust $ w ^? hud . diSections . ix i . ssItems . ix j = w | otherwise = scrollAugNextInSection w where - (i, j, _) = fromMaybe (1, -1, mempty) $ w ^? hud . diSelection . _Just + Sel i j _ = fromMaybe (Sel 1 (-1) mempty) $ w ^? hud . diSelection . _Just checkCombineSelectionExists :: SubInventory -> SubInventory checkCombineSelectionExists si | Just sss <- si ^? ciSections - , Just (i, j, _) <- si ^? ciSelection . _Just <|> Just (0, 0, mempty) + , Sel i j _ <- fromMaybe (Sel 0 0 mempty) $ si ^? ciSelection . _Just , isNothing $ si ^? ciSections . ix i . ssItems . ix j = - si & ciSelection ?~ (0, -1, mempty) + si & ciSelection ?~ Sel 0 (-1) mempty & ciSelection %~ scrollSelectionSections (-1) sss | otherwise = si @@ -136,11 +136,11 @@ updateDisplaySections w cfig = ) where mselpos = w ^? hud . diSelection . _Just - invfiltcurs = mselpos ^? _Just . _1 == Just (-1) + invfiltcurs = mselpos ^? _Just . slSec == Just (-1) (sfinv, sinv) = filterSectionsPair invfiltcurs plainRegex invitems "INVENTORY" $ w ^? hud . diInvFilter . _Just - closefiltcurs = mselpos ^? _Just . _1 == Just 2 + closefiltcurs = mselpos ^? _Just . slSec == Just 2 (sfclose, sclose) = filterSectionsPair closefiltcurs plainRegex closeitms "NEARBY ITEMS" $ w ^? hud . diCloseFilter . _Just @@ -241,7 +241,7 @@ doSectionSize extraavailable mintaken is sss done = fromMaybe done $ do updateSectionsPositioning :: (Int -> Int) -> -- for determining each sections indent - Maybe (Int, Int, IntSet) -> + Maybe Selection -> Int -> IM.IntMap (IM.IntMap (SelectionItem a)) -> IM.IntMap (SelectionSection a) -> @@ -251,13 +251,13 @@ updateSectionsPositioning h mselpos allavailablelines lsss sss = where offsets = fmap _ssOffset sss m k = do - (k', i, _) <- mselpos + Sel k' i _ <- mselpos guard $ k == k' return i ls = lsss -- defaults non-existing offsets to 0 g = merge (mapMissing (const ($ 0))) dropMissing (zipWithMatched (const ($))) - lk = mselpos ^.. _Just . _1 + lk = mselpos ^.. _Just . slSec ssizes = sectionsSizes allavailablelines lk $ sectionsDesiredLines ls updateSection :: @@ -324,7 +324,7 @@ enterCombineInv cfig w = w & hud . subInventory .~ CombineInventory { _ciSections = updateCombineSections w cfig mempty - , _ciSelection = Just (0,0,mempty) + , _ciSelection = Just (Sel 0 0 mempty) , _ciFilter = Nothing } & hud . diInvFilter .~ Nothing diff --git a/src/Dodge/InputFocus.hs b/src/Dodge/InputFocus.hs index bf4ba9a90..46cf0e4af 100644 --- a/src/Dodge/InputFocus.hs +++ b/src/Dodge/InputFocus.hs @@ -16,11 +16,11 @@ textInputFocus :: World -> Maybe ((String -> f String) -> World -> f World) textInputFocus w = case w ^? hud . subInventory of - Just NoSubInventory{} -> case he ^? diSelection . _Just . _1 of + Just NoSubInventory{} -> case he ^? diSelection . _Just . slSec of Just (-1) -> Just $ hud . diInvFilter . _Just Just 2 -> Just $ hud . diCloseFilter . _Just _ -> Nothing - Just CombineInventory{} -> case he ^? subInventory . ciSelection . _Just . _1 of + Just CombineInventory{} -> case he ^? subInventory . ciSelection . _Just . slSec of Just (-1) -> Just $ hud . subInventory . ciFilter . _Just _ -> Nothing Just DisplayTerminal{_termID = tmid} -> do diff --git a/src/Dodge/Inventory.hs b/src/Dodge/Inventory.hs index 79b8fd774..c89d92a4d 100644 --- a/src/Dodge/Inventory.hs +++ b/src/Dodge/Inventory.hs @@ -17,7 +17,6 @@ module Dodge.Inventory ( ) where import Data.Function -import qualified Data.IntSet as IS import Data.Maybe import Dodge.Base import Dodge.Data.SelectionList @@ -87,7 +86,7 @@ rmInvItem cid invid w = where pointcid = cWorld . lWorld . creatures . ix cid updateselectionextra - | cid == 0 = hud . diSelection . _Just . _3 %~ const mempty + | cid == 0 = hud . diSelection . _Just . slSet %~ const mempty | otherwise = id updateselection | cid == 0 && cr ^? crManipulation . manObject . imSelectedItem == Just invid = @@ -166,7 +165,7 @@ changeSwapOther manlens n f i w = fromMaybe w $ do & cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . manlens %~ doswap & hud . closeItems %~ swapIndices i k - & hud . diSelection . _Just . _2 %~ doswap + & hud . diSelection . _Just . slInt %~ doswap & worldEventFlags . at InventoryChange ?~ () swapItemWith :: @@ -182,7 +181,7 @@ swapItemWith f (j, i) = case j of changeSwapWith :: (Int -> IM.IntMap (SelectionItem ()) -> Maybe Int) -> World -> World changeSwapWith f w - | Just (j,i,_) <- w ^. hud . diSelection = swapItemWith f (j,i) w + | Just (Sel j i _) <- w ^. hud . diSelection = swapItemWith f (j,i) w | otherwise = w --changeSwapWith :: (Int -> IM.IntMap (SelectionItem ()) -> Maybe Int) -> World -> World @@ -192,7 +191,7 @@ changeSwapWith f w -- Just (5, i, _) -> w & changeSwapOther ispCloseButton 5 f i -- _ -> w -invSetSelection :: (Int, Int, IS.IntSet) -> World -> World +invSetSelection :: Selection -> World -> World invSetSelection sel w = w & hud . diSelection ?~ sel @@ -208,8 +207,8 @@ invSetSelectionPos i j w = & setInvPosFromSS & cWorld . lWorld %~ crUpdateItemLocations 0 where - f Nothing = Just (i, j, mempty) - f (Just (_, _, s)) = Just (i, j, s) + f Nothing = Just (Sel i j mempty) + f (Just (Sel _ _ s)) = Just (Sel i j s) scrollAugInvSel :: Int -> World -> World scrollAugInvSel yi w diff --git a/src/Dodge/Inventory/Add.hs b/src/Dodge/Inventory/Add.hs index 31fc589ed..f33898c38 100644 --- a/src/Dodge/Inventory/Add.hs +++ b/src/Dodge/Inventory/Add.hs @@ -43,7 +43,7 @@ tryPutItemInInv cid itid w = do & updateselectionextra invid where updateselectionextra i - | cid == 0 = hud . diSelection . _Just . _3 %~ IS.map (f i) + | cid == 0 = hud . diSelection . _Just . slSet %~ IS.map (f i) | otherwise = id f j i | i >= _unNInt j = i + 1 | otherwise = i diff --git a/src/Dodge/Inventory/Location.hs b/src/Dodge/Inventory/Location.hs index 800a00fc1..f7de821ba 100644 --- a/src/Dodge/Inventory/Location.hs +++ b/src/Dodge/Inventory/Location.hs @@ -97,7 +97,7 @@ setInvPosFromSS w = w & cWorld . lWorld . creatures . ix 0 . crManipulation . manObject .~ thesel where thesel = fromMaybe SelNothing $ do - (i, j, _) <- w ^? hud . diSelection . _Just + Sel i j _ <- w ^? hud . diSelection . _Just case i of (-1) -> Just SortInventory 0 -> do diff --git a/src/Dodge/Inventory/Swap.hs b/src/Dodge/Inventory/Swap.hs index 78ae6a4a3..23c9b040c 100644 --- a/src/Dodge/Inventory/Swap.hs +++ b/src/Dodge/Inventory/Swap.hs @@ -27,8 +27,8 @@ swapInvItems f i w = fromMaybe w $ do ss <- w ^? hud . diSections . ix 0 . ssItems k <- f i ss let updateselection = case w ^? hud . diSelection . _Just of - Just (0, j,_) | j == k -> hud . diSelection . _Just . _2 .~ i - Just (0, j,_) | j == i -> hud . diSelection . _Just . _2 .~ k + Just (Sel 0 j _) | j == k -> hud . diSelection . _Just . slInt .~ i + Just (Sel 0 j _) | j == i -> hud . diSelection . _Just . slInt .~ k _ -> id return $ w @@ -55,11 +55,11 @@ swapInvItems f i w = fromMaybe w $ do swapAnyExtraSelection :: Int -> Int -> World -> World swapAnyExtraSelection i k w = fromMaybe w $ do - is <- w ^? hud . diSelection . _Just . _3 + is <- w ^? hud . diSelection . _Just . slSet let f = if i `IS.member` is then IS.insert k else id g = if k `IS.member` is then IS.insert i else id return $ - w & hud . diSelection . _Just . _3 + w & hud . diSelection . _Just . slSet %~ (f . g . IS.delete i . IS.delete k) checkConnection :: SoundOrigin -> SoundID -> Int -> Int -> World -> World diff --git a/src/Dodge/Render/HUD.hs b/src/Dodge/Render/HUD.hs index f3f1eca83..cb8aec527 100644 --- a/src/Dodge/Render/HUD.hs +++ b/src/Dodge/Render/HUD.hs @@ -60,7 +60,7 @@ drawInventory sss w cfig = <> itemconnections <> drawMouseOver cfig w where - f = fmap (\(x, y, _) -> (x, y)) + f = fmap (\(Sel x y _) -> (x, y)) curs = invCursorParams w itemconnections = fromMaybe mempty $ do inv' <- w ^? cWorld . lWorld . creatures . ix 0 . crInv @@ -131,14 +131,14 @@ drawMouseOver cfig w = drawDragSelected :: Configuration -> World -> Maybe Picture drawDragSelected cfig w = do - ys <- w ^? hud . diSelection . _Just . _3 + ys <- w ^? hud . diSelection . _Just . slSet guard $ not (IS.null ys) && ( case w ^? hud . subInventory of Just NoSubInventory -> True _ -> False ) - (i, _, _) <- w ^? hud . diSelection . _Just + Sel i _ _ <- w ^? hud . diSelection . _Just sss <- w ^? hud . diSections let f x = (selSecDrawCursorAt invDP BackdropCursor sss (i, x) <>) return . translateScreenPos cfig (invDP ^. ldpPos) @@ -188,7 +188,7 @@ drawCombineInventory cfig sss w = where curs = BoundaryCursor [North, South, West] msel = - fmap (\(x, y, _) -> (x, y)) $ + fmap (\(Sel x y _) -> (x, y)) $ w ^? hud . subInventory . ciSelection . _Just drawExamineInventory :: Configuration -> World -> Picture @@ -254,7 +254,7 @@ drawRBOptions cfig w = fold $ do i <- w ^? rbOptions . opSel let ae = getEquipmentAllocation invid w sss <- w ^? hud . diSections - (i', j, _) <- w ^? hud . diSelection . _Just + Sel i' j _ <- w ^? hud . diSelection . _Just curpos <- selSecYint i' j sss let ytext = drawListElement 0 1 0 curpos . text midstr = equipAllocString ae diff --git a/src/Dodge/Render/Picture.hs b/src/Dodge/Render/Picture.hs index 3f931830a..d9848dcc8 100644 --- a/src/Dodge/Render/Picture.hs +++ b/src/Dodge/Render/Picture.hs @@ -115,7 +115,7 @@ mouseCursorType u = case u ^. uvWorld . input . mouseContext of MouseGameRotate -> rotate a (drawVerticalDoubleArrow 5) where w = u ^. uvWorld - selsec = u ^? uvWorld . hud . diSelection . _Just . _1 + selsec = u ^? uvWorld . hud . diSelection . _Just . slSec a = fromMaybe 0 $ do cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos return . toClosestMultiple (pi / 32) $ diff --git a/src/Dodge/SelectedClose.hs b/src/Dodge/SelectedClose.hs index f95579607..10fbee8a1 100644 --- a/src/Dodge/SelectedClose.hs +++ b/src/Dodge/SelectedClose.hs @@ -13,7 +13,7 @@ interactWithCloseObj e w = worldEventFlags . at InventoryChange ?~ () $ case e o getSelectedCloseObj :: World -> Maybe (Either (NewInt ItmInt) Button) getSelectedCloseObj w = do - (i, j, _) <- w ^? hud . diSelection . _Just + Sel i j _ <- w ^? hud . diSelection . _Just case i of 3 -> Left <$> w ^? hud . closeItems . ix j 5 -> do diff --git a/src/Dodge/SelectionSections.hs b/src/Dodge/SelectionSections.hs index d6ddc9975..4f3396789 100644 --- a/src/Dodge/SelectionSections.hs +++ b/src/Dodge/SelectionSections.hs @@ -10,6 +10,7 @@ module Dodge.SelectionSections ( inverseSelNumPos, ) where +import Dodge.Data.HUD import Dodge.Data.CardinalPoint import qualified Data.IntSet as IS import Control.Applicative @@ -24,64 +25,52 @@ import Dodge.Data.SelectionList import Dodge.ScreenPos import Geometry.Data -scrollSelectionSections :: - Int -> - IMSS a -> - Maybe (Int, Int,IS.IntSet) -> - Maybe (Int, Int,IS.IntSet) +scrollSelectionSections :: Int -> IMSS a -> Maybe Selection -> Maybe Selection scrollSelectionSections yi sss msel | yi == 0 = msel | yi > 0 = foldl' (&) msel $ replicate yi (ssScrollUsing ssLookupUp sss) | otherwise = foldl' (&) msel $ replicate (negate yi) (ssScrollUsing ssLookupDown sss) -nextInSectionSS :: - IM.IntMap (SelectionSection a) -> - Maybe (Int, Int, IS.IntSet) -> - Maybe (Int, Int, IS.IntSet) +nextInSectionSS :: IMSS a -> Maybe Selection -> Maybe Selection nextInSectionSS = ssScrollUsing ssLookupNextMax ---setFirstPosSelectionSections :: SelectionSections a -> SelectionSections a ---setFirstPosSelectionSections sss = fromMaybe sss $ do --- (i, j, _) <- ssLookupMin sss --- return $ sss & sssExtra . sssSelPos ?~ (i, j) - ssScrollUsing :: - (Int -> Int -> IM.IntMap (SelectionSection a) -> Maybe (Int, Int, SelectionItem a)) -> - IM.IntMap (SelectionSection a) -> - Maybe (Int, Int, IS.IntSet) -> - Maybe (Int, Int, IS.IntSet) + (Int -> Int -> IMSS a -> Maybe (Int, Int, SelectionItem a)) -> + IMSS a -> + Maybe Selection -> + Maybe Selection ssScrollUsing g = ssScrollMinOnFail g . fmap (ssItems %~ IM.filter _siIsSelectable) ssScrollMinOnFail :: - (Int -> Int -> IM.IntMap (SelectionSection a) -> Maybe (Int, Int, SelectionItem a)) -> - IM.IntMap (SelectionSection a) -> - Maybe (Int, Int, IS.IntSet) -> - Maybe (Int, Int, IS.IntSet) -ssScrollMinOnFail f sss msel = fmap (\(i, j, _) -> (i, j, q i j)) $ l <|> ssLookupMin sss + (Int -> Int -> IMSS a -> Maybe (Int, Int, SelectionItem a)) -> + IMSS a -> + Maybe Selection -> + Maybe Selection +ssScrollMinOnFail f sss msel = fmap (\(i, j, _) -> Sel i j (q i j)) $ l <|> ssLookupMin sss where q i j = fromMaybe mempty $ do - (k,_,xs) <- msel ^? _Just + Sel k _ xs <- msel ^? _Just guard $ j `IS.member` xs && i == k return xs l = do - (i, j, _) <- msel + Sel i j _ <- msel f i j sss ssSetCursor :: (IM.IntMap (SelectionSection a) -> Maybe (Int, Int, SelectionItem a)) -> IM.IntMap (SelectionSection a) -> - Maybe (Int, Int, IS.IntSet) -> - Maybe (Int, Int, IS.IntSet) + Maybe Selection -> + Maybe Selection ssSetCursor f sss msel = fromMaybe msel $ do (i, j, _) <- f sss let newxs = fromMaybe mempty $ do - (k,_,xs) <- msel + Sel k _ xs <- msel guard $ k == i && j `IS.member` xs return xs - return $ Just (i, j,newxs) + return $ Just (Sel i j newxs) ssLookupMax :: IM.IntMap (SelectionSection a) -> Maybe (Int, Int, SelectionItem a) ssLookupMax sss = do diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index 63147654d..17f943e27 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -378,7 +378,7 @@ updateMouseContextGame cfig u = case u ^. uvWorld . input . mouseContext of return $ OverInvSelect selpos overcomb = do sss <- w ^? hud . subInventory . ciSections - (xl, xr, _) <- w ^? hud . subInventory . ciSelection . _Just + Sel xl xr _ <- w ^? hud . subInventory . ciSelection . _Just let msel = (xl, xr) let mpossel = inverseSelNumPos cfig secondColumnParams sss (w ^. input . mousePos) return $ case mpossel of diff --git a/src/Dodge/Update/Input/InGame.hs b/src/Dodge/Update/Input/InGame.hs index 6412db947..c6fbc69a1 100644 --- a/src/Dodge/Update/Input/InGame.hs +++ b/src/Dodge/Update/Input/InGame.hs @@ -46,18 +46,18 @@ updateUseInputInGame :: Universe -> Universe updateUseInputInGame u = updateFunctionKeys $ case u ^. uvWorld . hud of HUD{_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 (Sel (-1) _ _))} -> u & tohud . subInventory %~ docombineregexinput sss msel & uvWorld . worldEventFlags . at CombineInventoryChange ?~ () _ - | disel ^? _Just . _1 == Just (-1) -> + | disel ^? _Just . slSec == Just (-1) -> u & tohud %~ dodisplayregexinput diInvFilter diInvFilter (-1) & uvWorld . worldEventFlags . at InventoryChange ?~ () & uvWorld %~ setInvPosFromSS _ - | disel ^? _Just . _1 == Just 2 -> + | disel ^? _Just . slSec == Just 2 -> u & tohud %~ dodisplayregexinput diCloseFilter diCloseFilter 2 & uvWorld . worldEventFlags . at InventoryChange ?~ () @@ -128,7 +128,7 @@ doDrag cfig n k mmouseover w = fromMaybe w $ do guard (n /= 0) ss <- w ^? hud . diSections . ix k . ssItems x <- mmouseover - is <- w ^? hud . diSelection . _Just . _3 + is <- w ^? hud . diSelection . _Just . slSet return $ if concurrentIS is then shiftInvItems cfig n k x is ss w @@ -138,7 +138,7 @@ tryDropSelected :: Maybe (Int, Int) -> World -> Maybe World tryDropSelected mpos w = do guard $ maybe True (\(i, _) -> i == 3) mpos cr <- w ^? cWorld . lWorld . creatures . ix 0 - (0, _, xs) <- w ^? hud . diSelection . _Just + Sel 0 _ xs <- w ^? hud . diSelection . _Just return . foldl' (flip $ dropItem cr) w . IS.toDescList $ xs tryPickupSelected :: Int -> Maybe (Int, Int) -> World -> Maybe World @@ -146,7 +146,7 @@ tryPickupSelected k mpos w = do guard $ k == 3 guard $ maybe True (\(i, _) -> i == 0 || i == 1) mpos cr <- w ^? cWorld . lWorld . creatures . ix 0 - xs <- w ^? hud . diSelection . _Just . _3 + xs <- w ^? hud . diSelection . _Just . slSet let nfreeslots = crNumFreeSlots (w ^. cWorld . lWorld . items) cr itmstopickup = mapMaybe g $ IS.toList xs slotsneeded = alaf Sum foldMap itInvHeight itmstopickup @@ -158,7 +158,7 @@ tryPickupSelected k mpos w = do where newdisel j xs = hud . diSelection - ?~ (0, j, IS.fromDistinctAscList [j .. j + IS.size xs -1]) + ?~ Sel 0 j (IS.fromDistinctAscList [j .. j + IS.size xs -1]) g i = do NInt j <- w ^? hud . closeItems . ix i w ^? cWorld . lWorld . items . ix j @@ -171,23 +171,23 @@ updateMouseReleaseInGame w = case w ^. input . mouseContext of OverInvDragSelect (Just ssel) mesel | ScancodeLShift `M.member` (w ^. input . pressedKeys) -> w & input . mouseContext .~ MouseInGame - & hud . diSelection . _Just . _3 + & hud . diSelection . _Just . slSet %~ getuniques ( maybe mempty (h ssel) - (guard (ssel ^? _1 == w ^? hud . diSelection . _Just . _1) >> mesel ^? _Just) + (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)) OverInvDragSelect{} -> w & input . mouseContext .~ MouseInGame - & hud . diSelection . _Just . _3 %~ const mempty + & hud . diSelection . _Just . slSet %~ const mempty _ -> w where getuniques x y = IS.union x y IS.\\ IS.intersection x y - f (x, y) z = (x, y, z) + f (x, y) z = Sel x y z h (k, i) j = fold $ do sss <- w ^? hud . diSections . ix k . ssItems let (_, xss) = IM.split (min i j -1) sss @@ -259,16 +259,16 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of _ -> w & hud . subInventory . ciFilter ?~ ("#" ++ str) _ -> w where - f (x, y) = (x, y, mempty) - selsec = w ^? hud . diSelection . _Just . _1 + f (x, y) = Sel x y mempty + selsec = w ^? hud . diSelection . _Just . slSec -endRegex :: Int -> World -> Maybe (Int, Int, IS.IntSet) -> Maybe (Int, Int, IS.IntSet) +endRegex :: Int -> World -> Maybe Selection -> Maybe Selection endRegex i w = ssSetCursor (ssLookupDown i j) sss where sss = w ^. hud . diSections j = maybe 0 fst $ IM.lookupMin =<< sss ^? ix i . ssItems -endCombineRegex :: World -> Maybe (Int, Int, IS.IntSet) -> Maybe (Int, Int, IS.IntSet) +endCombineRegex :: World -> Maybe Selection -> Maybe Selection endCombineRegex w = ssSetCursor (ssLookupDown 0 j) sss where sss = w ^. hud . subInventory . ciSections @@ -279,8 +279,8 @@ endCombineRegex w = ssSetCursor (ssLookupDown 0 j) sss startDrag :: (Int, Int) -> World -> World startDrag (a, b) w = setcontext $ case w ^? hud . diSelection . _Just of - Just (i, _, xs) | i == a && b `IS.member` xs -> w - _ -> invSetSelection (a, b, IS.singleton b) w + Just (Sel i _ xs) | i == a && b `IS.member` xs -> w + _ -> invSetSelection (Sel a b (IS.singleton b)) w where setcontext = input . mouseContext .~ OverInvDrag a (Just (a, b)) @@ -336,10 +336,10 @@ shiftInvItems cfig n k x xs ss w = setSelWhileDragging . fromMaybe w $ do setSelWhileDragging :: World -> World setSelWhileDragging w = fromMaybe w $ do - (i, _, xs) <- w ^? hud . diSelection . _Just + Sel i _ xs <- w ^? hud . diSelection . _Just (k, j) <- w ^? input . mouseContext . mcoMaybeSelect . _Just guard $ i == k && j `IS.member` xs - return $ w & hud . diSelection . _Just . _2 .~ j + return $ w & hud . diSelection . _Just . slInt .~ j shiftInvItemsUp :: Int -> IS.IntSet -> World -> World shiftInvItemsUp j is w = IS.foldl' f w is @@ -446,9 +446,9 @@ doRegexInput :: Input -> Int -> IMSS a -> - Maybe (Int, Int, IS.IntSet) -> + Maybe Selection -> Maybe String -> - (IMSS a, Maybe (Int, Int, IS.IntSet), Maybe String) + (IMSS a, Maybe Selection, Maybe String) doRegexInput inp i sss msel filts | backspacetonothing || escapekey = endregex i 0 | endkeys = endregex (i + 1) (j -1) @@ -489,14 +489,14 @@ updateBackspaceRegex w = case di ^? subInventory of _ -> w where secfocus a b = fromMaybe False $ do - i <- di ^? diSelection . _Just . _1 + i <- di ^? diSelection . _Just . slSec return $ i == a || i == b trybackspace x filtget filtset selset he = fromMaybe he $ do str <- he ^? filtget . _Just return $ case str of (_ : _) -> he & filtset . _Just %~ init - & selset ?~ (x, 0, mempty) + & selset ?~ Sel x 0 mempty [] -> he & filtset .~ Nothing di = w ^. hud @@ -504,19 +504,19 @@ updateEnterRegex :: World -> World updateEnterRegex w = case w ^? hud . subInventory of Just NoSubInventory{} | secfocus [-1, 0, 1] -> - w & hud . diSelection ?~ (-1, 0, mempty) + w & hud . diSelection ?~ Sel (-1) 0 mempty & hud . diInvFilter %~ enterregex Just NoSubInventory{} | secfocus [2, 3] -> - w & hud . diSelection ?~ (2, 0, mempty) + w & hud . diSelection ?~ Sel 2 0 mempty & hud . diCloseFilter %~ enterregex Just CombineInventory{} -> w & hud . subInventory . ciFilter %~ enterregex - & hud . subInventory . ciSelection ?~ (-1, 0, mempty) + & hud . subInventory . ciSelection ?~ Sel (-1) 0 mempty _ -> w where secfocus xs = fromMaybe False $ do - i <- w ^? hud . diSelection . _Just . _1 + i <- w ^? hud . diSelection . _Just . slSec return $ i `elem` xs enterregex = (<|> Just "") @@ -547,7 +547,7 @@ tryCombine (i, j) w = fromMaybe w $ do return $ (createItemYou it (foldr (destroyInvItem 0 . NInt) w (sort is))) & soundStart InventorySound p wrench1S Nothing - & hud . diSelection . _Just . _3 .~ mempty + & hud . diSelection . _Just . slSet .~ mempty maybeExitCombine :: World -> World maybeExitCombine w diff --git a/tags b/tags index 598d3619e..2e13e63db 100644 --- a/tags +++ b/tags @@ -239,7 +239,7 @@ CombClust src/Dodge/Combine/Graph.hs 19;" t CombEdge src/Dodge/Combine/Graph.hs 32;" t CombNode src/Dodge/Combine/Graph.hs 25;" t CombinableItem src/Dodge/Data/Combine.hs 5;" t -CombineInventory src/Dodge/Data/HUD.hs 26;" C +CombineInventory src/Dodge/Data/HUD.hs 25;" C CombineInventoryChange src/Dodge/Data/World.hs 32;" C ComsSS src/Dodge/Data/Scenario.hs 98;" C ConcurrentEffect src/Loop/Data.hs 6;" t @@ -343,7 +343,7 @@ DestroyItem src/Dodge/Data/Scenario.hs 7;" C Detector src/Dodge/Data/Item/Combine.hs 183;" t Dirt src/Dodge/Data/Material.hs 11;" C DisasterType src/Dodge/Data/Scenario.hs 24;" t -DisplayTerminal src/Dodge/Data/HUD.hs 31;" C +DisplayTerminal src/Dodge/Data/HUD.hs 30;" C Distortion src/Dodge/Data/Distortion.hs 12;" t DivineRetribution src/Dodge/Data/Scenario.hs 35;" C DoActionIf src/Dodge/Data/ActionPlan.hs 116;" C @@ -416,7 +416,7 @@ EquipmentPlatformSF src/Dodge/Data/ComposedItem.hs 17;" C Escape src/Dodge/Data/Scenario.hs 10;" C EscapeMenuOption src/Dodge/Data/Universe.hs 76;" t Essential src/Shape/Data.hs 34;" C -ExamineInventory src/Dodge/Data/HUD.hs 20;" C +ExamineInventory src/Dodge/Data/HUD.hs 19;" C Explore src/Dodge/Data/Scenario.hs 4;" C Explosion src/Dodge/Data/SoundOrigin.hs 38;" C ExplosionPayload src/Dodge/Data/Payload.hs 11;" C @@ -443,7 +443,7 @@ FetchItem src/Dodge/Data/Scenario.hs 11;" C FireSpark src/Dodge/Data/Spark.hs 22;" C Fixated src/Dodge/Data/Creature/Perception.hs 62;" C FixedCoordLayer src/Picture/Data.hs 28;" C -FixedSelectionWidth src/Dodge/Data/SelectionList.hs 40;" C +FixedSelectionWidth src/Dodge/Data/SelectionList.hs 39;" C FlIt src/Dodge/Data/FloorItem.hs 15;" C Flame src/Dodge/Data/Flame.hs 13;" t FlameBeamCombine src/Dodge/Data/Beam.hs 39;" C @@ -535,7 +535,7 @@ HEATSENSOR src/Dodge/Data/Item/Combine.hs 83;" C HELD src/Dodge/Data/Item/Combine.hs 17;" C HOMINGMODULE src/Dodge/Data/Item/Combine.hs 102;" C HOSE src/Dodge/Data/Item/Combine.hs 55;" C -HUD src/Dodge/Data/HUD.hs 33;" t +HUD src/Dodge/Data/HUD.hs 32;" t HalfRes src/Dodge/Data/Config.hs 97;" C HammerTrigger src/Dodge/Data/TriggerType.hs 10;" C HardQuit src/Dodge/Data/Universe.hs 70;" C @@ -753,7 +753,7 @@ MakeTempLight src/Dodge/Data/WorldEffect.hs 34;" C ManipulatedObject src/Dodge/Data/Item/Use/Consumption/LoadAction.hs 22;" t Manipulation src/Dodge/Data/Item/Use/Consumption/LoadAction.hs 16;" t Manipulator src/Dodge/Data/Item/Use/Consumption/LoadAction.hs 17;" C -MapperInventory src/Dodge/Data/HUD.hs 21;" C +MapperInventory src/Dodge/Data/HUD.hs 20;" C MapperSF src/Dodge/Data/ComposedItem.hs 39;" C Material src/Dodge/Data/Material.hs 11;" t MaterialSound src/Dodge/Data/SoundOrigin.hs 35;" C @@ -866,9 +866,10 @@ NoResurrection src/Dodge/Data/Corpse.hs 14;" C NoRightButtonOptions src/Dodge/Data/RightButtonOptions.hs 16;" C NoRoomClipBoundaries src/Dodge/Data/Config.hs 107;" C NoSF src/Dodge/Data/ComposedItem.hs 29;" C +NoSel src/Dodge/Data/HUD.hs 47;" C NoShadowFidelity src/Shape/Data.hs 25;" C NoShadows src/Dodge/Data/Config.hs 103;" C -NoSubInventory src/Dodge/Data/HUD.hs 19;" C +NoSubInventory src/Dodge/Data/HUD.hs 18;" C NoTrigger src/Dodge/Data/TriggerType.hs 11;" C NoWorldEffect src/Dodge/Data/WorldEffect.hs 23;" C Noclip src/Dodge/Data/Config.hs 70;" C @@ -1197,13 +1198,15 @@ SecretCabal src/Dodge/Data/Scenario.hs 44;" C SectionCursor src/Dodge/Data/SelectionList.hs 23;" t SeeAbove src/Dodge/Data/Wall.hs 42;" C SeeThrough src/Dodge/Data/Wall.hs 41;" C +Sel src/Dodge/Data/HUD.hs 46;" C SelCloseButton src/Dodge/Data/Item/Use/Consumption/LoadAction.hs 33;" C SelCloseItem src/Dodge/Data/Item/Use/Consumption/LoadAction.hs 31;" C -SelItem src/Dodge/Data/SelectionList.hs 44;" C +SelItem src/Dodge/Data/SelectionList.hs 42;" C SelNothing src/Dodge/Data/Item/Use/Consumption/LoadAction.hs 29;" C Select_creature src/Dodge/Data/Config.hs 94;" C SelectedItem src/Dodge/Data/Item/Use/Consumption/LoadAction.hs 24;" C -SelectionItem src/Dodge/Data/SelectionList.hs 43;" t +Selection src/Dodge/Data/HUD.hs 45;" t +SelectionItem src/Dodge/Data/SelectionList.hs 41;" t SelectionSection src/Dodge/Data/SelectionList.hs 29;" t SelectionWidth src/Dodge/Data/SelectionList.hs 39;" t SelfTree src/Dodge/Data/MetaTree.hs 18;" t @@ -1293,7 +1296,7 @@ Stone src/Dodge/Data/Material.hs 11;" C StorageSS src/Dodge/Data/Scenario.hs 94;" C Strategy src/Dodge/Data/ActionPlan.hs 176;" t StrategyActions src/Dodge/Data/ActionPlan.hs 188;" C -SubInventory src/Dodge/Data/HUD.hs 18;" t +SubInventory src/Dodge/Data/HUD.hs 17;" t Superfluous src/Shape/Data.hs 38;" C Surface src/Shape/Data.hs 41;" t Survive src/Dodge/Data/Scenario.hs 5;" C @@ -1432,7 +1435,7 @@ UseHeld src/Dodge/Data/Item/Use.hs 31;" C UseInt src/Dodge/Data/Item/Use.hs 33;" C UseInvItem src/Dodge/Data/WorldEffect.hs 35;" C UseItem src/Dodge/Data/ActionPlan.hs 37;" C -UseItemWidth src/Dodge/Data/SelectionList.hs 41;" C +UseItemWidth src/Dodge/Data/SelectionList.hs 39;" C UseMapper src/Dodge/Data/Item/Use.hs 39;" C UseMvTargetPos src/Dodge/Data/ActionPlan.hs 163;" C UseNothing src/Dodge/Data/Item/Use.hs 34;" C @@ -1635,9 +1638,9 @@ _camViewFrom src/Dodge/Data/Camera.hs 29;" f _camZoom src/Dodge/Data/Camera.hs 26;" f _canID src/Dodge/Data/LWorld.hs 170;" f _carriage src/Dodge/Data/Creature/Stance.hs 14;" f -_carteCenter src/Dodge/Data/HUD.hs 39;" f -_carteRot src/Dodge/Data/HUD.hs 41;" f -_carteZoom src/Dodge/Data/HUD.hs 40;" f +_carteCenter src/Dodge/Data/HUD.hs 38;" f +_carteRot src/Dodge/Data/HUD.hs 40;" f +_carteZoom src/Dodge/Data/HUD.hs 39;" f _cdtCloseLeft src/Dodge/Data/DoubleTree.hs 88;" f _cdtCloseLeft src/Dodge/Data/DoubleTree.hs 96;" f _cdtCloseRight src/Dodge/Data/DoubleTree.hs 90;" f @@ -1653,11 +1656,11 @@ _ceString src/Dodge/Data/Universe.hs 67;" f _chasmShader src/Data/Preload/Render.hs 46;" f _chasmVBO src/Data/Preload/Render.hs 45;" f _chasms src/Dodge/Data/CWorld.hs 30;" f -_ciFilter src/Dodge/Data/HUD.hs 29;" f +_ciFilter src/Dodge/Data/HUD.hs 28;" f _ciInvIDs src/Dodge/Data/Combine.hs 6;" f _ciItem src/Dodge/Data/Combine.hs 7;" f -_ciSections src/Dodge/Data/HUD.hs 27;" f -_ciSelection src/Dodge/Data/HUD.hs 28;" f +_ciSections src/Dodge/Data/HUD.hs 26;" f +_ciSelection src/Dodge/Data/HUD.hs 27;" f _cigType src/Dodge/Data/Camera.hs 19;" f _clPos src/Dodge/Data/Cloud.hs 15;" f _clTimer src/Dodge/Data/Cloud.hs 17;" f @@ -1678,8 +1681,8 @@ _cldtUp src/Dodge/Data/DoubleTree.hs 45;" f _cldtUp src/Dodge/Data/DoubleTree.hs 53;" f _clickPos src/Dodge/Data/Input.hs 42;" f _clickWorldPos src/Dodge/Data/Input.hs 44;" f -_closeButtons src/Dodge/Data/HUD.hs 43;" f -_closeItems src/Dodge/Data/HUD.hs 42;" f +_closeButtons src/Dodge/Data/HUD.hs 42;" f +_closeItems src/Dodge/Data/HUD.hs 41;" f _cloudEBO src/Data/Preload/Render.hs 51;" f _cloudShader src/Data/Preload/Render.hs 50;" f _cloudVBO src/Data/Preload/Render.hs 49;" f @@ -1764,10 +1767,10 @@ _debugV3 src/Dodge/Data/Universe.hs 59;" f _debug_booleans src/Dodge/Data/Config.hs 57;" f _debug_view_clip_bounds src/Dodge/Data/Config.hs 56;" f _delayedEvents src/Dodge/Data/LWorld.hs 137;" f -_diCloseFilter src/Dodge/Data/HUD.hs 38;" f -_diInvFilter src/Dodge/Data/HUD.hs 37;" f -_diSections src/Dodge/Data/HUD.hs 35;" f -_diSelection src/Dodge/Data/HUD.hs 36;" f +_diCloseFilter src/Dodge/Data/HUD.hs 37;" f +_diInvFilter src/Dodge/Data/HUD.hs 36;" f +_diSections src/Dodge/Data/HUD.hs 34;" f +_diSelection src/Dodge/Data/HUD.hs 35;" f _dimAttachPos src/Dodge/Data/Item/Misc.hs 16;" f _dimCenter src/Dodge/Data/Item/Misc.hs 15;" f _dimRad src/Dodge/Data/Item/Misc.hs 14;" f @@ -2016,9 +2019,9 @@ _magBelowID src/Dodge/Data/Muzzle.hs 22;" f _magnets src/Dodge/Data/LWorld.hs 130;" f _mainAction src/Dodge/Data/ActionPlan.hs 171;" f _manObject src/Dodge/Data/Item/Use/Consumption/LoadAction.hs 17;" f -_mapInvItmID src/Dodge/Data/HUD.hs 24;" f -_mapInvOffset src/Dodge/Data/HUD.hs 22;" f -_mapInvZoom src/Dodge/Data/HUD.hs 23;" f +_mapInvItmID src/Dodge/Data/HUD.hs 23;" f +_mapInvOffset src/Dodge/Data/HUD.hs 21;" f +_mapInvZoom src/Dodge/Data/HUD.hs 22;" f _matUBO src/Data/Preload/Render.hs 39;" f _mbAttach src/Dodge/Data/MetaTree.hs 16;" f _mbTree src/Dodge/Data/MetaTree.hs 16;" f @@ -2331,13 +2334,13 @@ _shapeHalfSize src/Shape/Data.hs 18;" f _shapeShader src/Data/Preload/Render.hs 25;" f _shellPayload src/Dodge/Data/Item/Combine.hs 103;" f _shockwaves src/Dodge/Data/LWorld.hs 118;" f -_siColor src/Dodge/Data/SelectionList.hs 49;" f -_siHeight src/Dodge/Data/SelectionList.hs 46;" f -_siIsSelectable src/Dodge/Data/SelectionList.hs 48;" f -_siOffX src/Dodge/Data/SelectionList.hs 50;" f -_siPayload src/Dodge/Data/SelectionList.hs 51;" f -_siPictures src/Dodge/Data/SelectionList.hs 45;" f -_siWidth src/Dodge/Data/SelectionList.hs 47;" f +_siColor src/Dodge/Data/SelectionList.hs 47;" f +_siHeight src/Dodge/Data/SelectionList.hs 44;" f +_siIsSelectable src/Dodge/Data/SelectionList.hs 46;" f +_siOffX src/Dodge/Data/SelectionList.hs 48;" f +_siPayload src/Dodge/Data/SelectionList.hs 49;" f +_siPictures src/Dodge/Data/SelectionList.hs 43;" f +_siWidth src/Dodge/Data/SelectionList.hs 45;" f _sideEffect src/Loop/Data.hs 13;" f _sideImpulses src/Dodge/Data/ActionPlan.hs 170;" f _silhouetteEBO src/Data/Preload/Render.hs 27;" f @@ -2348,6 +2351,9 @@ _skVel src/Dodge/Data/Spark.hs 15;" f _skinHead src/Dodge/Data/Creature/Misc.hs 78;" f _skinLower src/Dodge/Data/Creature/Misc.hs 80;" f _skinUpper src/Dodge/Data/Creature/Misc.hs 79;" f +_slInt src/Dodge/Data/HUD.hs 46;" f +_slSec src/Dodge/Data/HUD.hs 46;" f +_slSet src/Dodge/Data/HUD.hs 46;" f _smoothScrollAmount src/Dodge/Data/Input.hs 41;" f _soundAngDist src/Sound/Data.hs 49;" f _soundChannel src/Sound/Data.hs 48;" f @@ -2375,7 +2381,7 @@ _stuckCrID src/Dodge/Data/Projectile.hs 50;" f _stuckCrOffset src/Dodge/Data/Projectile.hs 50;" f _stuckCrRot src/Dodge/Data/Projectile.hs 50;" f _stuckWlID src/Dodge/Data/Projectile.hs 51;" f -_subInventory src/Dodge/Data/HUD.hs 34;" f +_subInventory src/Dodge/Data/HUD.hs 33;" f _swColor src/Dodge/Data/Shockwave.hs 18;" f _swDam src/Dodge/Data/Shockwave.hs 23;" f _swDirection src/Dodge/Data/Shockwave.hs 19;" f @@ -2396,7 +2402,7 @@ _tbPos src/Dodge/Data/TractorBeam.hs 14;" f _tbStartPos src/Dodge/Data/TractorBeam.hs 15;" f _tbTime src/Dodge/Data/TractorBeam.hs 17;" f _tbVel src/Dodge/Data/TractorBeam.hs 16;" f -_termID src/Dodge/Data/HUD.hs 31;" f +_termID src/Dodge/Data/HUD.hs 30;" f _terminals src/Dodge/Data/LWorld.hs 128;" f _teslaArcs src/Dodge/Data/LWorld.hs 116;" f _testFloat src/Dodge/Data/World.hs 43;" f