Update changes in menu values

This commit is contained in:
2022-12-21 16:08:22 +00:00
parent 03c945d189
commit 91d65094c9
4 changed files with 14 additions and 11 deletions
+1 -3
View File
@@ -24,9 +24,7 @@ data SelectionList = SelectionList
}
data SelectionItemIndex = ListedSelectionItem Int
| DummySelectionItem
| ScrollUpSelectionItem
| ScrollDownSelectionItem
| ScrollSelectionItem
| SpecialSelectionItem
data SpecialSelectionItem = NoSpecialSelectionItem
+8
View File
@@ -21,6 +21,14 @@ slTitleOptionsEff title ops defstr eff u =
, _scSelectionList = makeOptionsSelectionList (Just 0) u ops
}
refreshOptionsSelectionList :: Universe -> Universe
refreshOptionsSelectionList u = u & uvScreenLayers . ix 0 %~ f
where
f sl = case sl of
OptionScreen {_scOptions = mops} -> sl & scSelectionList . slItems .~ optionsToSelections u mops
_ -> sl
--makeOptionsSelectionList :: Maybe Int -> Universe -> [MenuOption] -> Maybe String -> SelectionList
--makeOptionsSelectionList mselpos u mos defstr = SelectionList
makeOptionsSelectionList :: Maybe Int -> Universe -> [MenuOption] -> SelectionList
+2 -4
View File
@@ -7,11 +7,9 @@ import LensHelp
setShownSelectionItems :: SelectionList -> SelectionList
setShownSelectionItems sl = case sl ^? slSizeRestriction of
Just (SelectionSizeRestriction maxlines _ botit _)
| length allitems <= maxlines -> sl & slShownItems .~ allitems
-- | offset > length allitems + 3 - maxlines -> sl
| otherwise ->
| length allitems > maxlines ->
sl & slShownItems .~ take (maxlines - 2) (drop offset allitems) -- ++ repeat dummyitem))
++ [(botit,ScrollDownSelectionItem)]
++ [(botit,ScrollSelectionItem)]
_ -> sl & slShownItems .~ allitems
where
-- dummyitem = (SelectionItem [] 1 False 0 white 0, DummySelectionItem)
+3 -4
View File
@@ -7,6 +7,7 @@ Description : Simulation update
module Dodge.Update (updateUniverse) where
--import Dodge.Menu.Option
import Dodge.Menu.Option
import Dodge.SelectionList
import Dodge.Data.SelectionList
import Dodge.InputFocus
@@ -98,14 +99,12 @@ mouseClickOptionsList mos sl u = case u ^. uvWorld . input . mouseButtons . at B
i <- sl ^. slSelPos
si <- sl ^? slShownItems . ix i . _2
return $ maybe u ($ u) $ case si of
ListedSelectionItem j -> mos ^? ix j . moEff
ScrollUpSelectionItem -> Just $ uvScreenLayers . _head . scSelectionList . slOffset %~ (max 0 . subtract 5)
ScrollDownSelectionItem -> do
ListedSelectionItem j -> fmap (refreshOptionsSelectionList .) (mos ^? ix j . moEff)
ScrollSelectionItem -> do
maxlines <- sl ^? slSizeRestriction . maxSelectionLines
alllines <- sl ^? slLength
Just $ uvScreenLayers . _head . scSelectionList . slOffset %~
(\x -> if x + maxlines - 2 >= alllines then 0 else x + maxlines - 2)
DummySelectionItem -> Just id
SpecialSelectionItem -> Just id
_ -> u