Implement simple indenting in selection menu

This commit is contained in:
2024-09-12 18:14:52 +01:00
parent 4dedba8d30
commit e69abf1715
8 changed files with 226 additions and 217 deletions
+21 -2
View File
@@ -1,5 +1,6 @@
module Dodge.Inventory.SelectionList (
invSelectionItem,
invSelectionItem',
closeObjectToSelectionItem,
) where
@@ -13,8 +14,8 @@ import Dodge.Item.InventoryColor
import LensHelp
import Picture.Base
invSelectionItem :: Creature -> Int -> Item -> SelectionItem ()
invSelectionItem cr i it =
invSelectionItem' :: Creature -> Int -> Item -> SelectionItem ()
invSelectionItem' cr i it =
SelectionItem
{ _siPictures = pics & ix 0 %~ (++ anyequippos ++ anyhotkey)
, _siHeight = itSlotsTaken it
@@ -31,6 +32,24 @@ invSelectionItem cr i it =
UndroppableIdentified -> itemDisplay cr it
_ -> itemDisplay cr it
invSelectionItem :: Creature -> Int -> (Item,Int,a) -> SelectionItem ()
invSelectionItem cr i (it,indent,_) =
SelectionItem
{ _siPictures = pics & ix 0 %~ (++ anyequippos ++ anyhotkey)
, _siHeight = itSlotsTaken it
, _siIsSelectable = True
, _siColor = col
, _siOffX = indent
, _siPayload = ()
}
where
anyhotkey = maybe [] ((' ':) .hotkeyToString) (cr ^? crInvHotkeys . ix i)
anyequippos = maybe [] (rightPad 8 ' ' . (' ':) . eqPosText) (cr ^? crInvEquipped . ix i)
col = itemInvColor it
pics = case _itCurseStatus it of
UndroppableIdentified -> itemDisplay cr it
_ -> itemDisplay cr it
hotkeyToString :: Hotkey -> String
hotkeyToString x = case x of
HotkeyQ -> "[Q]"