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