Push more data out of selection list into menu screen
This commit is contained in:
@@ -19,7 +19,6 @@ data SelectionList = SelectionList
|
|||||||
, _slWidth :: SelectionWidth
|
, _slWidth :: SelectionWidth
|
||||||
, _slLength :: Int
|
, _slLength :: Int
|
||||||
, _slSizeRestriction :: SelectionSizeRestriction
|
, _slSizeRestriction :: SelectionSizeRestriction
|
||||||
-- , _slSpecialItem :: SpecialSelectionItem
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data SelectionItemIndex = ListedSelectionItem Int
|
data SelectionItemIndex = ListedSelectionItem Int
|
||||||
@@ -31,10 +30,7 @@ data SpecialSelectionItem = NoSpecialSelectionItem
|
|||||||
|
|
||||||
data SelectionSizeRestriction = NoSelectionSizeRestriction
|
data SelectionSizeRestriction = NoSelectionSizeRestriction
|
||||||
| SelectionSizeRestriction
|
| SelectionSizeRestriction
|
||||||
{ _maxSelectionLines :: Int
|
{ _overflowItemBottom :: SelectionItem
|
||||||
, _overflowItemTop :: SelectionItem
|
|
||||||
, _overflowItemBottom :: SelectionItem
|
|
||||||
, _ssrType :: SSRType
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newtype SSRType = SSRFromScreenBottom {_ssrFromScreenBottom :: Float}
|
newtype SSRType = SSRFromScreenBottom {_ssrFromScreenBottom :: Float}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ data ScreenLayer
|
|||||||
, _scMaybeOption :: Maybe MenuOption
|
, _scMaybeOption :: Maybe MenuOption
|
||||||
, _scOptionFlag :: OptionScreenFlag
|
, _scOptionFlag :: OptionScreenFlag
|
||||||
, _scSelectionList :: SelectionList
|
, _scSelectionList :: SelectionList
|
||||||
|
, _scAvailableLines :: Int
|
||||||
}
|
}
|
||||||
| ColumnsScreen
|
| ColumnsScreen
|
||||||
{ _scTitle :: String
|
{ _scTitle :: String
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ module Dodge.Menu.Option
|
|||||||
where
|
where
|
||||||
--import Dodge.ScodeToChar
|
--import Dodge.ScodeToChar
|
||||||
--import Data.Maybe
|
--import Data.Maybe
|
||||||
import Dodge.WindowLayout
|
--import Dodge.WindowLayout
|
||||||
import Padding
|
import Padding
|
||||||
import Picture.Base
|
import Picture.Base
|
||||||
import Dodge.Data.CardinalPoint
|
import Dodge.Data.CardinalPoint
|
||||||
@@ -20,6 +20,7 @@ slTitleOptionsEff title ops defstr eff u =
|
|||||||
, _scMaybeOption = fmap (Toggle eff . const . MODString) defstr
|
, _scMaybeOption = fmap (Toggle eff . const . MODString) defstr
|
||||||
, _scOptionFlag = NormalOptions
|
, _scOptionFlag = NormalOptions
|
||||||
, _scSelectionList = makeOptionsSelectionList (Just 0) u ops
|
, _scSelectionList = makeOptionsSelectionList (Just 0) u ops
|
||||||
|
, _scAvailableLines = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshOptionsSelectionList :: Universe -> Universe
|
refreshOptionsSelectionList :: Universe -> Universe
|
||||||
@@ -29,9 +30,6 @@ refreshOptionsSelectionList u = u & uvScreenLayers . ix 0 %~ f
|
|||||||
OptionScreen {_scOptions = mops} -> sl & scSelectionList . slItems .~ optionsToSelections u mops
|
OptionScreen {_scOptions = mops} -> sl & scSelectionList . slItems .~ optionsToSelections u mops
|
||||||
_ -> sl
|
_ -> sl
|
||||||
|
|
||||||
|
|
||||||
--makeOptionsSelectionList :: Maybe Int -> Universe -> [MenuOption] -> Maybe String -> SelectionList
|
|
||||||
--makeOptionsSelectionList mselpos u mos defstr = SelectionList
|
|
||||||
makeOptionsSelectionList :: Maybe Int -> Universe -> [MenuOption] -> SelectionList
|
makeOptionsSelectionList :: Maybe Int -> Universe -> [MenuOption] -> SelectionList
|
||||||
makeOptionsSelectionList mselpos u mos = SelectionList
|
makeOptionsSelectionList mselpos u mos = SelectionList
|
||||||
{ _slPosX = 50
|
{ _slPosX = 50
|
||||||
@@ -44,8 +42,7 @@ makeOptionsSelectionList mselpos u mos = SelectionList
|
|||||||
, _slCursorType = BorderCursor (Set.fromList [North,South,West])
|
, _slCursorType = BorderCursor (Set.fromList [North,South,West])
|
||||||
, _slWidth = FixedSelectionWidth 15
|
, _slWidth = FixedSelectionWidth 15
|
||||||
, _slLength = length $ optionsToSelections u mos
|
, _slLength = length $ optionsToSelections u mos
|
||||||
, _slSizeRestriction = SelectionSizeRestriction (availableMenuLines cfig) overflowit overflowit
|
, _slSizeRestriction = SelectionSizeRestriction overflowit
|
||||||
(SSRFromScreenBottom 5)
|
|
||||||
-- , _slSpecialItem = fromMaybe NoSpecialSelectionItem $ do
|
-- , _slSpecialItem = fromMaybe NoSpecialSelectionItem $ do
|
||||||
-- str <- defstr
|
-- str <- defstr
|
||||||
-- return $ BottomSelectionItem SelectionItem
|
-- return $ BottomSelectionItem SelectionItem
|
||||||
@@ -58,7 +55,6 @@ makeOptionsSelectionList mselpos u mos = SelectionList
|
|||||||
-- }
|
-- }
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
cfig = u ^. uvConfig
|
|
||||||
overflowit = SelectionItem
|
overflowit = SelectionItem
|
||||||
{ _siPictures = [text "MORE OPTIONS"]
|
{ _siPictures = [text "MORE OPTIONS"]
|
||||||
, _siHeight = 1
|
, _siHeight = 1
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
module Dodge.SelectionList where
|
module Dodge.SelectionList where
|
||||||
|
|
||||||
--import Color
|
--import Color
|
||||||
|
--import Dodge.WindowLayout
|
||||||
import Dodge.Data.Universe
|
import Dodge.Data.Universe
|
||||||
import LensHelp
|
import LensHelp
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
|
||||||
setShownSelectionItems :: ScreenLayer -> ScreenLayer
|
setShownSelectionItems :: Configuration -> ScreenLayer -> ScreenLayer
|
||||||
setShownSelectionItems sl = fromMaybe sl $ do
|
setShownSelectionItems cfig sl = fromMaybe sl $ do
|
||||||
offset <- sl ^? scOffset
|
offset <- sl ^? scOffset
|
||||||
return $ sl & scSelectionList %~ setShownSelectionItems' offset
|
maxlines <- sl ^? scAvailableLines
|
||||||
|
return $ sl & scSelectionList %~ setShownSelectionItems' maxlines offset
|
||||||
|
|
||||||
setShownSelectionItems' :: Int -> SelectionList -> SelectionList
|
setShownSelectionItems' :: Int -> Int -> SelectionList -> SelectionList
|
||||||
setShownSelectionItems' offset sl = case sl ^? slSizeRestriction of
|
setShownSelectionItems' maxlines offset sl = case sl ^? slSizeRestriction of
|
||||||
Just (SelectionSizeRestriction maxlines _ botit _)
|
Just (SelectionSizeRestriction botit)
|
||||||
| length allitems > maxlines ->
|
| length allitems > maxlines ->
|
||||||
sl & slShownItems .~ take (maxlines - 2) (drop offset allitems) -- ++ repeat dummyitem))
|
sl & slShownItems .~ take (maxlines - 2) (drop offset allitems) -- ++ repeat dummyitem))
|
||||||
++ [(botit,ScrollSelectionItem)]
|
++ [(botit,ScrollSelectionItem)]
|
||||||
|
|||||||
+20
-14
@@ -6,7 +6,6 @@ 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
|
||||||
@@ -93,15 +92,17 @@ gotoTerminal w = case _uvScreenLayers w of
|
|||||||
(InputScreen{} : _) -> w
|
(InputScreen{} : _) -> w
|
||||||
_ -> w & uvScreenLayers .:~ InputScreen T.empty "Enter command"
|
_ -> w & uvScreenLayers .:~ InputScreen T.empty "Enter command"
|
||||||
|
|
||||||
mouseClickOptionsList :: [MenuOption] -> SelectionList -> Universe -> Universe
|
mouseClickOptionsList :: [MenuOption] -> ScreenLayer -> Universe -> Universe
|
||||||
mouseClickOptionsList mos sl u = case u ^. uvWorld . input . mouseButtons . at ButtonLeft of
|
mouseClickOptionsList mos screen u = fromMaybe u $ do
|
||||||
|
sl <- screen ^? scSelectionList
|
||||||
|
Just $ case u ^. uvWorld . input . mouseButtons . at ButtonLeft of
|
||||||
Just False -> fromMaybe u $ do
|
Just False -> fromMaybe u $ do
|
||||||
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 -> fmap (refreshOptionsSelectionList .) (mos ^? ix j . moEff)
|
ListedSelectionItem j -> fmap (refreshOptionsSelectionList .) (mos ^? ix j . moEff)
|
||||||
ScrollSelectionItem -> do
|
ScrollSelectionItem -> do
|
||||||
maxlines <- sl ^? slSizeRestriction . maxSelectionLines
|
maxlines <- screen ^? scAvailableLines
|
||||||
alllines <- sl ^? slLength
|
alllines <- sl ^? slLength
|
||||||
Just $ uvScreenLayers . _head . scOffset %~
|
Just $ uvScreenLayers . _head . scOffset %~
|
||||||
(\x -> if x + maxlines - 2 >= alllines then 0 else x + maxlines - 2)
|
(\x -> if x + maxlines - 2 >= alllines then 0 else x + maxlines - 2)
|
||||||
@@ -125,20 +126,25 @@ mouseOverSelectionList sl u
|
|||||||
hh = halfHeight cfig
|
hh = halfHeight cfig
|
||||||
hw = halfWidth cfig
|
hw = halfWidth cfig
|
||||||
|
|
||||||
setSelectionListRestriction :: Configuration -> SelectionList -> SelectionList
|
setSelectionListRestriction' :: Configuration -> ScreenLayer -> ScreenLayer
|
||||||
setSelectionListRestriction cfig sl = sl & slSizeRestriction . maxSelectionLines %~ const nlines
|
setSelectionListRestriction' cfig screen = fromMaybe screen $ do
|
||||||
|
sl <- screen ^? scSelectionList
|
||||||
|
return $ screen & scAvailableLines %~ const (setSelectionListRestriction cfig sl)
|
||||||
|
|
||||||
|
setSelectionListRestriction :: Configuration -> SelectionList -> Int
|
||||||
|
setSelectionListRestriction cfig sl = nlines
|
||||||
where
|
where
|
||||||
nlines = floor ((dToBot - vgap) / itmHeight)
|
nlines = floor ((dToBot - vgap) / itmHeight)
|
||||||
vgap = sl ^. slVerticalGap
|
vgap = sl ^. slVerticalGap
|
||||||
itmHeight = 10 * sl ^. slScale + vgap
|
itmHeight = 10 * sl ^. slScale + vgap
|
||||||
dToBot = cfig ^. windowY - (sl ^. slPosY + dFromScreenBot)
|
dToBot = cfig ^. windowY - (sl ^. slPosY + dFromScreenBot)
|
||||||
dFromScreenBot = fromMaybe 0 $ sl ^? slSizeRestriction . ssrType . ssrFromScreenBottom
|
dFromScreenBot = 5 -- fromMaybe 0 $ sl ^? slSizeRestriction . ssrType . ssrFromScreenBottom
|
||||||
|
|
||||||
updateUseInput :: Universe -> Universe
|
updateUseInput :: Universe -> Universe
|
||||||
updateUseInput u = case u ^? uvScreenLayers . _head of
|
updateUseInput u = case u ^? uvScreenLayers . _head of
|
||||||
Just (InputScreen thetext _) -> doInputScreenInput thetext u
|
Just (InputScreen thetext _) -> doInputScreenInput thetext u
|
||||||
Just OptionScreen{_scOptions = mos, _scMaybeOption = mop, _scOptionFlag = flag, _scSelectionList = sellist}
|
Just screen@OptionScreen{_scOptions = mos, _scMaybeOption = mop, _scOptionFlag = flag, _scSelectionList = sellist}
|
||||||
-> optionScreenUpdate mos mop flag sellist u
|
-> optionScreenUpdate screen mos mop flag sellist u
|
||||||
-- Just ColumnsScreen{} -> u & uvScreenLayers %~ tail
|
-- Just ColumnsScreen{} -> u & uvScreenLayers %~ tail
|
||||||
_ -> case u ^? uvWorld . cWorld . lWorld . hud . hudElement . subInventory of
|
_ -> case u ^? uvWorld . cWorld . lWorld . hud . hudElement . subInventory of
|
||||||
Just (DisplayTerminal tmid) | inTermFocus (_uvWorld u) -> updateKeysInTerminal tmid u
|
Just (DisplayTerminal tmid) | inTermFocus (_uvWorld u) -> updateKeysInTerminal tmid u
|
||||||
@@ -146,16 +152,16 @@ updateUseInput u = case u ^? uvScreenLayers . _head of
|
|||||||
where
|
where
|
||||||
pkeys = u ^. uvWorld . input . pressedKeys
|
pkeys = u ^. uvWorld . input . pressedKeys
|
||||||
|
|
||||||
optionScreenUpdate :: [MenuOption] -> Maybe MenuOption -> OptionScreenFlag
|
optionScreenUpdate :: ScreenLayer -> [MenuOption] -> Maybe MenuOption -> OptionScreenFlag
|
||||||
-> SelectionList
|
-> SelectionList
|
||||||
-> Universe -> Universe
|
-> Universe -> Universe
|
||||||
optionScreenUpdate mos mop _ sl u =
|
optionScreenUpdate screen mos mop _ sl u =
|
||||||
optionScreenDefEff mop
|
optionScreenDefEff mop
|
||||||
. mouseClickOptionsList mos sl
|
. mouseClickOptionsList mos screen
|
||||||
. mouseOverSelectionList sl
|
. mouseOverSelectionList sl
|
||||||
. menuWheelEvents
|
. menuWheelEvents
|
||||||
. over (uvScreenLayers . _head . scSelectionList) (setSelectionListRestriction cfig)
|
. over (uvScreenLayers . _head) (setSelectionListRestriction' cfig)
|
||||||
$ over (uvScreenLayers . _head) setShownSelectionItems
|
$ over (uvScreenLayers . _head) (setShownSelectionItems cfig)
|
||||||
u
|
u
|
||||||
where
|
where
|
||||||
cfig = u ^. uvConfig
|
cfig = u ^. uvConfig
|
||||||
|
|||||||
Reference in New Issue
Block a user