Utoljára aktív 2 days ago

A small menu system with configurable actions.

june's Avatar june gist felülvizsgálása 2 days ago. Revízióhoz ugrás

1 file changed, 1 insertion, 1 deletion

menu.nv

@@ -30,7 +30,7 @@
30 30 :: I should be on menu options
31 31 :: select back
32 32 :: I should be on menu title-screen
33 - :: the test passed! yay!
33 + :: the test passed! yay!
34 34
35 35
36 36

june's Avatar june gist felülvizsgálása 2 days ago. Revízióhoz ugrás

1 file changed, 1 insertion, 1 deletion

menu.nv

@@ -30,7 +30,7 @@
30 30 :: I should be on menu options
31 31 :: select back
32 32 :: I should be on menu title-screen
33 - :: the test passed! yay!
33 + :: the test passed! yay!
34 34
35 35
36 36

june's Avatar june gist felülvizsgálása 2 days ago. Revízióhoz ugrás

1 file changed, 9 insertions, 2 deletions

menu.nv

@@ -30,11 +30,12 @@
30 30 :: I should be on menu options
31 31 :: select back
32 32 :: I should be on menu title-screen
33 + :: the test passed! yay!
33 34
34 35
35 36
36 37
37 - |# A "testing framework", whatever that is. #|
38 + |# A testing framework, whatever that is. #|
38 39 |:: I should be on menu $menu :menu: $menu?|
39 40 |:: I should be on menu $menu :menu: $other?|
40 41 :: error :message: we wanted to be in $menu but we're in $other
@@ -48,7 +49,7 @@
48 49 |:: fire exit-menu for $option|
49 50 :: exit menu
50 51
51 - |# The menu "definition language". #|
52 + |# The menu definition language. #|
52 53 |:: define menu $menu| :menu: $menu
53 54 |:: $option -> $action :menu: $menu?|
54 55 :menus: $menu $option $action
@@ -56,8 +57,14 @@
56 57 |:: end menu|
57 58 :: error :message: you need to start a menu to end one
58 59
60 +
61 +
62 +
59 63 |# The rest of this is menu mechanics. #|
60 64
65 +
66 +
67 +
61 68 |:: enter menu $menu|
62 69 :: load menu options for $menu
63 70 :menu: $menu

june's Avatar june gist felülvizsgálása 2 days ago. Revízióhoz ugrás

1 file changed, 96 insertions

menu.nv(fájl létrehozva)

@@ -0,0 +1,96 @@
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 +
34 +
35 +
36 +
37 + |# A "testing framework", whatever that is. #|
38 + |:: I should be on menu $menu :menu: $menu?|
39 + |:: I should be on menu $menu :menu: $other?|
40 + :: error :message: we wanted to be in $menu but we're in $other
41 + |:: I should be on menu $menu|
42 + :: error :message: we wanted to be in $menu but we're not in any menu
43 +
44 +
45 + |# Some default actions that switch the menu and navigate to a parent menu. #|
46 + |:: fire switch-menu for $menu|
47 + :: enter menu $menu
48 + |:: fire exit-menu for $option|
49 + :: exit menu
50 +
51 + |# The menu "definition language". #|
52 + |:: define menu $menu| :menu: $menu
53 + |:: $option -> $action :menu: $menu?|
54 + :menus: $menu $option $action
55 + |:: end menu :menu: $menu|
56 + |:: end menu|
57 + :: error :message: you need to start a menu to end one
58 +
59 + |# The rest of this is menu mechanics. #|
60 +
61 + |:: enter menu $menu|
62 + :: load menu options for $menu
63 + :menu: $menu
64 + :options:
65 +
66 + |:: exit menu|
67 + :: unload menu options
68 +
69 + |:: select $option :options: $option $action?|
70 + :: reset options
71 + :: fire $action for $option
72 + |:: select $option? :options: $other $action|
73 + :seen options: $other $action
74 + |:: select $option|
75 + :: error :message: $option is not available
76 +
77 + |:: load menu options for $menu? :menus: $menu $option $action|
78 + :options: $option $action
79 + |:: load menu options for $menu? :menus: $other $option $action|
80 + :seen menus: $other $option $action
81 + |:: load menu options for $menu|
82 + :: reset menus
83 +
84 + |:: unload menu options? :menu: $menu? :options: $option $action|
85 + :menus: $menu $option $action
86 + |:: unload menu options :menu: $menu :options:|
87 + |:: unload menu options|
88 + :: error :message: we're not in a menu
89 +
90 + |:: reset menus? :seen menus: $menu $option $action|
91 + :menus: $menu $option $action
92 + |:: reset menus|
93 +
94 + |:: reset options? :seen options: $option $action|
95 + :options: $option $action
96 + |:: reset options|
Újabb Régebbi