Remove explicit scancode from menu items
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user