Remove SelectionSections

This commit is contained in:
2024-10-25 22:19:04 +01:00
parent a20fc48eaa
commit d93c548d3c
15 changed files with 202 additions and 195 deletions
+21 -11
View File
@@ -56,7 +56,7 @@ drawHP cfig =
. show
. (^?! cWorld . lWorld . creatures . ix 0 . crHP)
drawInventory :: SelectionSections () -> World -> Configuration -> Picture
drawInventory :: IM.IntMap (SelectionSection ()) -> World -> Configuration -> Picture
drawInventory sss w cfig =
drawSelectionSections sss ldp cfig
<> drawSSCursor sss (w ^? hud . hudElement . diSelection . _Just) ldp curs cfig
@@ -123,7 +123,11 @@ drawSubInventory subinv cfig w = case subinv of
DisplayTerminal tid -> displayTerminal tid cfig (w ^. cWorld . lWorld)
CombineInventory{_ciSections = sss} -> drawCombineInventory cfig sss w
drawCombineInventory :: Configuration -> SelectionSections CombinableItem -> World -> Picture
drawCombineInventory ::
Configuration ->
IM.IntMap (SelectionSection CombinableItem) ->
World ->
Picture
drawCombineInventory cfig sss w =
invHead cfig "COMBINE"
<> drawSelectionSections sss secondColumnParams cfig
@@ -249,7 +253,7 @@ equipAllocString = \case
RemoveEquipment{} -> "TAKE OFF"
inventoryExtra ::
SelectionSections () ->
IM.IntMap (SelectionSection ()) ->
Configuration ->
World ->
IM.IntMap (Maybe (Int, Int), [Int], [Int]) ->
@@ -259,7 +263,13 @@ inventoryExtra sss cfig w =
. IM.foldMapWithKey (inventoryExtraH sss cfig w)
. fmap (\(_, a, b) -> a <> b)
inventoryExtraH :: SelectionSections () -> Configuration -> World -> Int -> [Int] -> Picture
inventoryExtraH ::
IM.IntMap (SelectionSection ()) ->
Configuration ->
World ->
Int ->
[Int] ->
Picture
inventoryExtraH sss cfig w i is = fromMaybe mempty $ do
p <- snum i
let ps = mapMaybe snum is
@@ -268,7 +278,7 @@ inventoryExtraH sss cfig w i is = fromMaybe mempty $ do
snum = selNumPos cfig (invDisplayParams w) sss 0
combineInventoryExtra ::
SelectionSections CombinableItem ->
IM.IntMap (SelectionSection CombinableItem) ->
Maybe (Int, Int) ->
Configuration ->
World ->
@@ -276,7 +286,7 @@ combineInventoryExtra ::
combineInventoryExtra sss msel cfig w = fromMaybe mempty $ do
(i, j) <- msel
cpos <- selSecYint i j sss
si <- sss ^? sssSections . ix i . ssItems . ix j
si <- sss ^? ix i . ssItems . ix j
let col = _siColor si
mconcat
[ do
@@ -403,7 +413,7 @@ invHead cfig =
selNumPos ::
Configuration ->
ListDisplayParams ->
SelectionSections a ->
IM.IntMap (SelectionSection a) ->
Int ->
Int ->
Maybe Point2
@@ -427,14 +437,14 @@ selNumPosCardinal ::
CardinalEightPoint ->
Configuration ->
ListDisplayParams ->
SelectionSections a ->
IM.IntMap (SelectionSection a) ->
Int ->
Int ->
Maybe Point2
selNumPosCardinal card cfig ldp sss i j = do
ipos <- selSecYint i j sss
size <- selSecSelSize i j sss
indent <- sss ^? sssSections . ix i . ssItems . ix j . siOffX
indent <- sss ^? ix i . ssItems . ix j . siOffX
let offset = cardEightVec card * V2 0 (fromIntegral size * 0.5 * 20 * s)
return $
screenPosAbs cfig (ldp ^. ldpPos)
@@ -446,5 +456,5 @@ selNumPosCardinal card cfig ldp sss i j = do
s = _ldpScale ldp
ygap = _ldpVerticalGap ldp
selSecSelCol :: Int -> Int -> SelectionSections a -> Maybe Color
selSecSelCol i j sss = sss ^? sssSections . ix i . ssItems . ix j . siColor
selSecSelCol :: Int -> Int -> IM.IntMap (SelectionSection a) -> Maybe Color
selSecSelCol i j sss = sss ^? ix i . ssItems . ix j . siColor
+5 -4
View File
@@ -14,6 +14,7 @@ module Dodge.Render.List (
selSecDrawCursorAt,
) where
import qualified Data.IntMap.Strict as IM
import Data.Maybe
import Dodge.Base.Window
import Dodge.Data.CardinalPoint
@@ -86,13 +87,13 @@ selSecDrawCursorAt ::
Int ->
ListDisplayParams ->
CursorDisplay ->
SelectionSections a ->
IM.IntMap (SelectionSection a) ->
(Int, Int) ->
Picture
selSecDrawCursorAt xsize ldp curs sss (i, j) = fromMaybe mempty $ do
yint <- selSecYint i j sss
xint <- sss ^? sssSections . ix i . ssIndent
si <- sss ^? sssSections . ix i . ssItems . ix j
xint <- sss ^? ix i . ssIndent
si <- sss ^? ix i . ssItems . ix j
return $
listCursorChooseBorderScale
(ldp ^. ldpVerticalGap)
@@ -108,7 +109,7 @@ selSecDrawCursor ::
Int ->
ListDisplayParams ->
CursorDisplay ->
SelectionSections a ->
IM.IntMap (SelectionSection a) ->
Maybe (Int, Int) ->
Picture
selSecDrawCursor xsize ldp curs = maybe mempty . selSecDrawCursorAt xsize ldp curs