||:: set up the menus :: run the test |:: set up the menus| :: define menu title-screen :: start -> switch-menu :: options -> switch-menu :: quit -> quit-game :: end menu :: define menu start :: easy -> easy-difficulty :: medium -> medium-difficulty :: hard -> hard-difficulty :: back -> exit-menu :: end menu :: define menu options :: video -> switch-menu :: audio -> switch-menu :: controls -> switch-menu :: back -> exit-menu :: end menu |:: run the test| :: enter menu title-screen :: select start :: I should be on menu start :: select back :: I should be on menu title-screen :: select options :: I should be on menu options :: select back :: I should be on menu title-screen :: the test passed! yay! |# A testing framework, whatever that is. #| |:: I should be on menu $menu :menu: $menu?| |:: I should be on menu $menu :menu: $other?| :: error :message: we wanted to be in $menu but we're in $other |:: I should be on menu $menu| :: error :message: we wanted to be in $menu but we're not in any menu |# Some default actions that switch the menu and navigate to a parent menu. #| |:: fire switch-menu for $menu| :: enter menu $menu |:: fire exit-menu for $option| :: exit menu |# The menu definition language. #| |:: define menu $menu| :menu: $menu |:: $option -> $action :menu: $menu?| :menus: $menu $option $action |:: end menu :menu: $menu| |:: end menu| :: error :message: you need to start a menu to end one |# The rest of this is menu mechanics. #| |:: enter menu $menu| :: load menu options for $menu :menu: $menu :options: |:: exit menu| :: unload menu options |:: select $option :options: $option $action?| :: reset options :: fire $action for $option |:: select $option? :options: $other $action| :seen options: $other $action |:: select $option| :: error :message: $option is not available |:: load menu options for $menu? :menus: $menu $option $action| :options: $option $action |:: load menu options for $menu? :menus: $other $option $action| :seen menus: $other $option $action |:: load menu options for $menu| :: reset menus |:: unload menu options? :menu: $menu? :options: $option $action| :menus: $menu $option $action |:: unload menu options :menu: $menu :options:| |:: unload menu options| :: error :message: we're not in a menu |:: reset menus? :seen menus: $menu $option $action| :menus: $menu $option $action |:: reset menus| |:: reset options? :seen options: $option $action| :options: $option $action |:: reset options|