Prevent selection of unselectable items when scrolling

This commit is contained in:
2023-02-20 11:19:25 +00:00
parent ab69de73c7
commit 2e46123a92
6 changed files with 58 additions and 81 deletions
+9 -6
View File
@@ -6,7 +6,7 @@ module Dodge.Combine (
) where
import Dodge.Data.Universe
import Regex
--import Regex
import Dodge.DisplayInventory
import Dodge.Render.HUD
import Dodge.SelectionList
@@ -53,7 +53,6 @@ combineItemListYouX = map (first $ concatMap g) . lookupItems . yourInv
combineList :: World -> [SelectionItem CombinableItem]
combineList w = case combineList' w of
-- [] -> [SelectionInfo ["No possible combinations"] 1 False 0 white 0]
[] -> [SelectionInfo ["No possible combinations"] 1 False white 0]
xs -> xs
@@ -140,22 +139,26 @@ toggleCombineInv uv = case uv ^? uvWorld . hud . hudElement . subInventory of
enterCombineInv :: Configuration -> World -> World
enterCombineInv cfig w = w & hud . hudElement . subInventory .~ CombineInventory
cm
cm'
Nothing
sss
--(updateCombineSelections w cfig sss)
where
cm = IM.fromAscList $ zip [0..] $ combineList w
cm' = IM.fromAscList $ zip [0..] $ combineList' w
cm | null cm' = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0
| otherwise = cm'
sss = SelectionSections
{ _sssSections = IM.singleton 0 combsection
, _sssSelPos = Just (0,0)
, _sssSelPos = selpos
}
selpos | null cm' = Nothing
| otherwise = Just (0,0)
availablelines = getAvailableListLines secondColumnParams cfig
combsection = updateSection cm (Just 0) availablelines combinationssection'
combinationssection' = SelectionSection
{ _ssItems = cm
, _ssCursor = do
(i,si) <- IM.lookupMin cm
(_,si) <- IM.lookupMin cm
return $ SectionCursor 0 (length (_siPictures si)) (_siColor si)
, _ssMinSize = 5
, _ssOffset = 0