Fix position of continue option on pause menu

This commit is contained in:
2022-12-24 12:55:24 +00:00
parent 5fb455b9e9
commit 80d319b38e
4 changed files with 20 additions and 16 deletions
+8 -5
View File
@@ -22,8 +22,8 @@ optionListDisplayParams = ListDisplayParams
, _ldpCursorType = BorderCursor (Set.fromList [North,South,West])
}
initializeOptionMenu :: String -> [MenuOption] -> Maybe String -> (Universe -> Universe) -> Universe -> ScreenLayer
initializeOptionMenu title ops defstr eff u =
initializeOptionMenu' :: String -> [MenuOption] -> PositionedMenuOption -> Universe -> ScreenLayer
initializeOptionMenu' title ops pmo u =
OptionScreen
{ _scTitle = title
, _scOptions = ops
@@ -34,6 +34,9 @@ initializeOptionMenu title ops defstr eff u =
, _scAvailableLines = getAvailableListLines optionListDisplayParams (u ^. uvConfig)
, _scListDisplayParams = optionListDisplayParams
}
initializeOptionMenu :: String -> [MenuOption] -> Maybe String -> (Universe -> Universe) -> Universe -> ScreenLayer
initializeOptionMenu title ops defstr eff = initializeOptionMenu' title ops pmo
where
pmo = case defstr of
Nothing -> NoPositionedMenuOption
@@ -60,7 +63,7 @@ makeOptionsSelectionList maxlines mselpos u mos pmo = SelectionList
optionsToSelections :: Int -> Universe -> [MenuOption] -> PositionedMenuOption -> [SelectionItem (Universe -> Universe)]
optionsToSelections maxlines u allops pmo = sits
where
offset = u ^?! uvScreenLayers . _head . scOffset
offset = fromMaybe 0 $ u ^? uvScreenLayers . _head . scOffset
ops | maxlines >= length allops = allops
| otherwise = take (maxlines - 2) (drop offset allops ++ repeat dummyMenuOption) ++ [cycleOptionsOption]
maxOptionLength = 3 + maximum (0 : map (optionValueOffset u) ops)
@@ -70,8 +73,8 @@ optionsToSelections maxlines u allops pmo = sits
BottomMenuOption mo -> map (menuOptionToSelectionItem u maxOptionLength) (ops ++ [mo])
cycleOptionsOption = Toggle cycleOptions (const (MODString ("MORE OPTIONS " ++ show n ++ "/" ++ show m)))
l = length allops
m = div (max 1 (l - 1)) (maxlines - 2) + 1
n = div (offset + 1) (maxlines - 2) + 1
m = div (l - 1) (max 1 (maxlines - 2)) + 1
n = div (offset + 1) (max 1 (maxlines - 2)) + 1
dummyMenuOption :: MenuOption
dummyMenuOption = Toggle id (const $ MODBlockedString "")