Remove explicit scancode from menu items

This commit is contained in:
2022-11-04 08:42:30 +00:00
parent 6e7cd14f49
commit c263012b61
11 changed files with 81 additions and 85 deletions
+5 -9
View File
@@ -3,7 +3,6 @@ module Dodge.Menu.Option
import Dodge.ScodeToChar
import Padding
import Picture.Base
import Color
import Dodge.Data.CardinalPoint
import Dodge.Data.SelectionList
import Dodge.Data.Universe
@@ -31,13 +30,14 @@ makeOptionsSelectionList mselpos u mos = SelectionList
, _slSelPos = mselpos
, _slCursorType = BorderCursor (Set.fromList [North,South,West])
, _slWidth = FixedSelectionWidth 15
, _slLength = length $ optionsToSelections u mos
}
optionsToSelections :: Universe -> [MenuOption] -> [SelectionItem]
optionsToSelections u ops = map colStrToSelItem colstrs
where
maxOptionLength = 3 + maximum (0 : map (optionValueOffset u) visibleops)
colstrs = map (menuOptionToString u maxOptionLength) visibleops
colstrs = zipWith (menuOptionToString u maxOptionLength) ['A'..] visibleops
visibleops = filter notInvisible ops
notInvisible InvisibleToggle{} = False
notInvisible _ = True
@@ -47,6 +47,7 @@ colStrToSelItem (col,str) = SelectionItem
{ _siPictures = [color col $ text str]
, _siHeight = 1
, _siIsSelectable = True
, _siWidth = length str
, _siColor = col
, _siOffX = 0
}
@@ -56,8 +57,8 @@ optionValueOffset u mo = case _moString mo u of
MODStringOption s _ -> length s
_ -> 0
menuOptionToString :: Universe -> Int -> MenuOption -> (Color, String)
menuOptionToString w padAmount mo = (thecol, theKeys ++ optionText)
menuOptionToString :: Universe -> Int -> Char -> MenuOption -> (Color, String)
menuOptionToString w padAmount char mo = (thecol, (char:":") ++ optionText)
where
thecol = case _moString mo w of
MODBlockedString{} -> greyN 0.5
@@ -65,8 +66,3 @@ menuOptionToString w padAmount mo = (thecol, theKeys ++ optionText)
optionText = case _moString mo w of
MODStringOption s t -> rightPad padAmount '.' s ++ t
x -> _modString x
theKeys = case mo of
Toggle{_moKey = k} -> stc k : ":"
Toggle2{_moKey1 = k1, _moKey2 = k2} -> stc k1 : '/' : stc k2 : ":"
_ -> undefined
stc = scodeToChar