Remove SelectionIntMap

This commit is contained in:
2023-02-19 09:59:09 +00:00
parent 8ec1dc0830
commit a88755bd75
8 changed files with 6 additions and 118 deletions
-9
View File
@@ -52,14 +52,6 @@ data SelectionSection a = SelectionSection
, _ssDescriptor :: String
}
data SelectionIntMap a = SelectionIntMap
{ _smItems :: [SelectionItem a]
, _smSelPos :: Maybe Int
, _smRegex :: Maybe String
, _smShownItems :: IntMap (SelectionItem a)
}
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
data SelectionWidth = FixedSelectionWidth Int
| VariableSelectionWidth (Int -> Int)
| UseMaxSelectionItemWidth
@@ -94,7 +86,6 @@ data SelectionItem a = SelectionItem
makeLenses ''ListDisplayParams
makeLenses ''SelectionList
makeLenses ''SelectionItem
makeLenses ''SelectionIntMap
makeLenses ''SelectionSection
makeLenses ''SelectionSections
makeLenses ''SectionCursor
-1
View File
@@ -6,7 +6,6 @@ module Dodge.Render.HUD (
) where
import Dodge.Inventory
import SelectionIntMap
import Dodge.Data.Combine
import Dodge.Default.SelectionList
import Dodge.Creature.Info
-35
View File
@@ -2,7 +2,6 @@ module Dodge.Render.List where
--import Picture.Text
import Dodge.Inventory
import SelectionIntMap
import qualified Data.IntMap.Strict as IM
--import Data.Foldable
import Dodge.SelectionList
@@ -29,29 +28,12 @@ drawSelectionList ldps cfig sl =
(makeSelectionListPictures sl)
<> drawSelectionCursor ldps cfig sl
drawSelectionMap :: ListDisplayParams -> Configuration -> SelectionIntMap a -> Picture
drawSelectionMap ldps cfig sl =
listPicturesAtScaleOff
(_ldpVerticalGap ldps)
(_ldpScale ldps)
(_ldpPosX ldps)
(_ldpPosY ldps)
cfig
0 --(_slOffset sl)
(makeSelectionMapPictures sl)
<> drawSelectionMapCursor ldps cfig sl
makeSelectionListPictures :: SelectionList a -> [Picture]
makeSelectionListPictures sl = concatMap f $ getShownItems sl
where
f si = map (color (_siColor si) . text) $ _siPictures si
--f si = map (textGrad (_siColor si) (withAlpha 0 (_siColor si))) $ _siPictures si
makeSelectionMapPictures :: SelectionIntMap a -> [Picture]
makeSelectionMapPictures sl = foldMap f $ _smShownItems sl
where
f si = map (color (_siColor si) . text) $ _siPictures si
drawCursorAt :: ListDisplayParams -> Configuration -> Maybe Int -> [SelectionItem a] -> Picture
drawCursorAt ldps cfig mi lis = fromMaybe mempty $ do
i <- mi
@@ -67,23 +49,6 @@ drawCursorAt ldps cfig mi lis = fromMaybe mempty $ do
FixedSelectionWidth x -> x
_ -> 1
drawCursorAt' :: ListDisplayParams -> Configuration -> Int -> IM.IntMap (SelectionItem a) -> Picture
drawCursorAt' ldps cfig i lis = fromMaybe mempty $ do
selit <- lis IM.!? i
f <- case _ldpCursorType ldps of
BorderCursor cps -> Just $ listCursorChooseBorderScale (_ldpVerticalGap ldps) (_ldpScale ldps) cps
NoCursor -> Nothing
let j = getIthPos i lis
col = _siColor selit
return $ f (_ldpPosX ldps + (9 * fromIntegral (_siOffX selit))) (_ldpPosY ldps) cfig j 0 col wdth (_siHeight selit)
where
wdth = case _ldpWidth ldps of
FixedSelectionWidth x -> x
_ -> 1
drawSelectionMapCursor :: ListDisplayParams -> Configuration -> SelectionIntMap a -> Picture
drawSelectionMapCursor ldps cfig sl = drawCursorAt ldps cfig (sl ^. smSelPos) (IM.elems $ _smShownItems sl)
drawSelectionCursor :: ListDisplayParams -> Configuration -> SelectionList a -> Picture
drawSelectionCursor ldps cfig sl = drawCursorAt ldps cfig (f $ sl ^. slSelPos) (getShownItems sl)
where
+3
View File
@@ -119,3 +119,6 @@ ssLookupGE' i sss = do
case IM.lookupMin (ss ^. ssItems) of
Just (j', si) -> return (i', j', si)
Nothing -> ssLookupGT' i' sss
getIthPos :: Int -> IM.IntMap (SelectionItem a) -> Int
getIthPos i sm = sum . fmap _siHeight . fst $ IM.split i sm
-6
View File
@@ -151,12 +151,6 @@ updateUseInput u = case u ^? uvScreenLayers . _head of
_ | inCloseRegex (u ^. uvWorld) -> doRegexInput 2 closeRegex closeRegex u
_ -> M.foldlWithKey' updateKeyInGame u pkeys
where
inregex sm = fromMaybe False $ do
i <- sm ^? smSelPos . _Just
si <- sm ^? smShownItems . ix i
case si of
SelectionRegex {} -> return True
_ -> return False
pkeys = u ^. uvWorld . input . pressedKeys
optionScreenUpdate ::
-1
View File
@@ -3,7 +3,6 @@ module Dodge.Update.Scroll (
) where
import Dodge.SelectionSections
import SelectionIntMap
import qualified Data.Map.Strict as M
import Data.Maybe
import Dodge.Base
+3 -5
View File
@@ -6,19 +6,17 @@ module Dodge.Update.UsingInput (
import Control.Lens
import qualified Data.Map.Strict as M
import Dodge.Base.You
import Dodge.Combine
--import Dodge.Combine
import Dodge.Creature.Impulse.UseItem
import Dodge.Data.Combine
import Dodge.Data.SelectionList
import Dodge.Data.World
import Dodge.InputFocus
import Dodge.Inventory
import Dodge.Inventory.Add
--import Dodge.Inventory
--import Dodge.Inventory.Add
import Dodge.Terminal.LeftButton
import Geometry
import ListHelp
import SDL
import SelectionIntMap
updateUsingInput :: World -> World
updateUsingInput w = case w ^. hud . hudElement of