Start to unify selection lists
This commit is contained in:
+46
-1
@@ -3,6 +3,7 @@ module Dodge.Render.HUD (
|
||||
hudDrawings,
|
||||
) where
|
||||
|
||||
import Dodge.Data.SelectionList
|
||||
import Control.Lens
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
@@ -47,8 +48,34 @@ drawInGameHUD uv =
|
||||
w = _uvWorld uv
|
||||
cfig = _uvConfig uv
|
||||
|
||||
defaultSelectionList :: SelectionList
|
||||
defaultSelectionList = SelectionList
|
||||
{ _slVerticalGap = 10
|
||||
, _slScale = 1
|
||||
, _slPosX = 0
|
||||
, _slPosY = 0
|
||||
, _slOffset = 0
|
||||
, _slItems = []
|
||||
, _slSelPos = Nothing
|
||||
, _slCursorType = NoCursor
|
||||
}
|
||||
|
||||
inventorySelectionList :: World -> [SelectionItem]
|
||||
inventorySelectionList w = map (invSelectionItem cr) (IM.toList inv)
|
||||
++ [SelectionItem displayFreeSlots 1 False]
|
||||
++ map (closeObjectToSelectionItem nfreeslots) (w ^. cWorld . lWorld . closeObjects)
|
||||
where
|
||||
cr = you w
|
||||
inv = _crInv cr
|
||||
nfreeslots = crNumFreeSlots cr
|
||||
displayFreeSlots = case nfreeslots of
|
||||
0 -> [color invDimColor . text $ " INVENTORY FULL"]
|
||||
1 -> [color invDimColor . text $ " +1 FREE SLOT"]
|
||||
x -> [color invDimColor . text $ " +" ++ show x ++ " FREE SLOTS"]
|
||||
|
||||
inventoryDisplay :: Configuration -> World -> Picture
|
||||
inventoryDisplay cfig w = listPicturesAt 0 0 cfig invlist
|
||||
inventoryDisplay cfig w = drawSelectionList cfig (defaultSelectionList & slItems .~ inventorySelectionList w)
|
||||
--inventoryDisplay cfig w = listPicturesAt 0 0 cfig invlist
|
||||
where
|
||||
cr = you w
|
||||
inv = _crInv cr
|
||||
@@ -308,6 +335,15 @@ invHead cfig s =
|
||||
invDimColor :: Color
|
||||
invDimColor = greyN 0.7
|
||||
|
||||
closeObjectToSelectionItem :: Int -> Either FloorItem Button -> SelectionItem
|
||||
closeObjectToSelectionItem n e = SelectionItem
|
||||
{ _siPictures = pics
|
||||
, _siHeight = length pics
|
||||
, _siIsSelectable = True
|
||||
}
|
||||
where
|
||||
pics = closeObjectToTextPictures n e
|
||||
|
||||
closeObjectToTextPictures :: Int -> Either FloorItem Button -> [Picture]
|
||||
closeObjectToTextPictures nfreeslots e = case e of
|
||||
Left flit -> let it = _flIt flit in map (applycolor it . textindent) $ itemDisplay it
|
||||
@@ -396,6 +432,15 @@ mapWall cfig thehud wl =
|
||||
mainListCursor :: Color -> Int -> Configuration -> Picture
|
||||
mainListCursor c = openCursorAt 120 c 5 0
|
||||
|
||||
invSelectionItem :: Creature -> (Int,Item) -> SelectionItem
|
||||
invSelectionItem cr x = SelectionItem
|
||||
{ _siPictures = pics
|
||||
, _siHeight = length pics
|
||||
, _siIsSelectable = True
|
||||
}
|
||||
where
|
||||
pics = itemText' cr x
|
||||
|
||||
itemText' :: Creature -> (Int, Item) -> [Picture]
|
||||
{-# INLINE itemText' #-}
|
||||
itemText' cr (i, it) = f $ case _itCurseStatus it of
|
||||
|
||||
Reference in New Issue
Block a user