Raw
Playground
||:: 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|
| 1 | ||:: set up the menus |
| 2 | :: run the test |
| 3 | |
| 4 | |:: set up the menus| |
| 5 | :: define menu title-screen |
| 6 | :: start -> switch-menu |
| 7 | :: options -> switch-menu |
| 8 | :: quit -> quit-game |
| 9 | :: end menu |
| 10 | :: define menu start |
| 11 | :: easy -> easy-difficulty |
| 12 | :: medium -> medium-difficulty |
| 13 | :: hard -> hard-difficulty |
| 14 | :: back -> exit-menu |
| 15 | :: end menu |
| 16 | :: define menu options |
| 17 | :: video -> switch-menu |
| 18 | :: audio -> switch-menu |
| 19 | :: controls -> switch-menu |
| 20 | :: back -> exit-menu |
| 21 | :: end menu |
| 22 | |
| 23 | |:: run the test| |
| 24 | :: enter menu title-screen |
| 25 | :: select start |
| 26 | :: I should be on menu start |
| 27 | :: select back |
| 28 | :: I should be on menu title-screen |
| 29 | :: select options |
| 30 | :: I should be on menu options |
| 31 | :: select back |
| 32 | :: I should be on menu title-screen |
| 33 | :: the test passed! yay! |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |# A testing framework, whatever that is. #| |
| 39 | |:: I should be on menu $menu :menu: $menu?| |
| 40 | |:: I should be on menu $menu :menu: $other?| |
| 41 | :: error :message: we wanted to be in $menu but we're in $other |
| 42 | |:: I should be on menu $menu| |
| 43 | :: error :message: we wanted to be in $menu but we're not in any menu |
| 44 | |
| 45 | |
| 46 | |# Some default actions that switch the menu and navigate to a parent menu. #| |
| 47 | |:: fire switch-menu for $menu| |
| 48 | :: enter menu $menu |
| 49 | |:: fire exit-menu for $option| |
| 50 | :: exit menu |
| 51 | |
| 52 | |# The menu definition language. #| |
| 53 | |:: define menu $menu| :menu: $menu |
| 54 | |:: $option -> $action :menu: $menu?| |
| 55 | :menus: $menu $option $action |
| 56 | |:: end menu :menu: $menu| |
| 57 | |:: end menu| |
| 58 | :: error :message: you need to start a menu to end one |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |# The rest of this is menu mechanics. #| |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |:: enter menu $menu| |
| 69 | :: load menu options for $menu |
| 70 | :menu: $menu |
| 71 | :options: |
| 72 | |
| 73 | |:: exit menu| |
| 74 | :: unload menu options |
| 75 | |
| 76 | |:: select $option :options: $option $action?| |
| 77 | :: reset options |
| 78 | :: fire $action for $option |
| 79 | |:: select $option? :options: $other $action| |
| 80 | :seen options: $other $action |
| 81 | |:: select $option| |
| 82 | :: error :message: $option is not available |
| 83 | |
| 84 | |:: load menu options for $menu? :menus: $menu $option $action| |
| 85 | :options: $option $action |
| 86 | |:: load menu options for $menu? :menus: $other $option $action| |
| 87 | :seen menus: $other $option $action |
| 88 | |:: load menu options for $menu| |
| 89 | :: reset menus |
| 90 | |
| 91 | |:: unload menu options? :menu: $menu? :options: $option $action| |
| 92 | :menus: $menu $option $action |
| 93 | |:: unload menu options :menu: $menu :options:| |
| 94 | |:: unload menu options| |
| 95 | :: error :message: we're not in a menu |
| 96 | |
| 97 | |:: reset menus? :seen menus: $menu $option $action| |
| 98 | :menus: $menu $option $action |
| 99 | |:: reset menus| |
| 100 | |
| 101 | |:: reset options? :seen options: $option $action| |
| 102 | :options: $option $action |
| 103 | |:: reset options| |