refactored game entry control flow

This commit is contained in:
Jonathan Lamothe
2019-11-23 01:13:17 -05:00
parent f1f7077c8c
commit 8795cb46a9
5 changed files with 60 additions and 97 deletions

View File

@@ -23,6 +23,7 @@ module Mtlstats.Menu (
-- * Menu Functions
menuController,
menuControllerWith,
menuStateController,
drawMenu,
menuHandler,
-- * Menus
@@ -76,6 +77,21 @@ menuControllerWith header menu = Controller
return True
}
-- | Generate and create a controller for a menu based on the current
-- 'ProgState'
menuStateController
:: (ProgState -> Menu ())
-- ^ The function to generate the menu
-> Controller
-- ^ The resulting controller
menuStateController menuFunc = Controller
{ drawController = drawMenu . menuFunc
, handleController = \e -> do
menu <- gets menuFunc
menuHandler menu e
return True
}
-- | The draw function for a 'Menu'
drawMenu :: Menu a -> C.Update C.CursorMode
drawMenu m = do