1
! DOMENU A replacement for Inform's standard DoMenu
2
! built for Inform 6 by L. Ross Raszewski
3
! (rraszews@skipjack.bluecrab.org)
5
! Basically, this new menu does two very simple things. First, unlike
6
! with the traditional DoMenu, you can have any number of lines at the top
7
! for a description or whatnot. That is to say
8
! " Information is available on a variety of subjects^
9
! You can access this information by selecting one of the lines below^
10
! Press q to quit the menu^
15
! will now work correctly as a menu.
16
! "How?" you ask. Simple. In your EntryR() routine (That's the first one you
17
! name after the string), you add a line
18
! if (menu_item==-1) return x;
19
! where x is the number of lines of description (4 in the above example)
20
! The only change you'll have to make to existing menus if you don't want to
21
! change anthing is to remove 1 line at the top of the menu_choices.
22
! (incidentally, if you put in a ",1" after the third argument, the title bar
23
! will say "Q=quit game". Something for a game of mine I left in because I
24
! didn't want to take it out)
26
! Second, you can now have two lines of title at the top. Depending on
27
! your interpreter, (I believe Frotz and InfoTaskForce do this) the second
28
! line will appear in reverse-bold
29
! For this trick, set item_name to the second line when menu_item=-1
31
! if (menu_item==-1) { item_name="Second Line"; return 4;} in the example above
33
! One more thing, you no longer have to fiddle with item_width. DoMenu
34
! doesn't need it anymore. Merry Christmas.
37
! Replace LowKey_Menu();
39
! Some time before including this.
41
! Comments? e-mail me!
43
! This is part of a series actually, these are inter-dependant libraries.
44
! For this to work, you have to include:
45
! center.h -> Centers a line of text (or a routine to print one) in
46
! the upper or lower window.
48
! For maximum enjoyment, add on (not required)
49
! AltMenu.H -> An alternative to menus, object oriented menu system
50
! (inspired by Graham Nelson's attempt to do the same
51
! thing. Mine makes use of the nifty abilities of this
53
! Hints.H (UPDATED) -> A system for making object-oriented hints which appear
54
! formatted in the same way as Infocom's InvisiClues
57
[ LowKey_Menu menu_choices EntryR ChoiceR lines main_title i j;
61
lines=indirect(EntryR);
66
if (item_name ofclass string) print (string) item_name;
67
else indirect(item_name);
69
if (main_title ofclass string) print (string) main_title;
70
else indirect(main_title);
72
if (ZRegion(menu_choices)==3) print (string) menu_choices;
73
else indirect(menu_choices);
76
print "^Type a number from 1 to ", lines,
77
", 0 to redisplay or press ENTER.^> ";
79
#IFV3; read buffer parse; #ENDIF;
81
#IFV5; read buffer parse DrawStatusLine; #ENDIF;
83
if (i=='quit' or #n$q || parse->1==0)
84
{ menu_nesting--; if (menu_nesting>0) rfalse;
85
if (deadflag==0) <<Look>>;
90
if (i<1 || i>lines) jump LKML;
99
[ DoMenu menu_choices EntryR ChoiceR;
100
LowKey_Menu(menu_choices,EntryR,ChoiceR);
109
[ DoMenu menu_choices EntryR ChoiceR inflag
110
lines ban_lines main_title sub_title cl i j oldcl pkey;
112
{ LowKey_Menu(menu_choices,EntryR,ChoiceR);
116
lines=indirect(EntryR);
117
main_title=item_name;
120
ban_lines=indirect(EntryR);
121
ban_lines=ban_lines+5;
129
i=0->33; if (i==0) i=80;
134
CenterU(main_title,1);
135
@set_cursor 2 1; spaces (i);
137
CenterU(sub_title,2);
138
style roman; style reverse;
139
@set_cursor 2 2; print "N = next subject";
140
j=i-12; @set_cursor 2 j; print "P = previous";
141
@set_cursor 3 1; spaces(i);
142
@set_cursor 3 2; print "RETURN = read subject";
143
j=i-17; @set_cursor 3 j;
144
if (inflag==1) print " Q = quit game";
146
if (inflag==2) print " Q = quit menu";
149
print " Q = resume game";
151
print "Q = previous menu";
152
style roman; font off;
154
if (menu_choices ofclass String) print (string) menu_choices;
155
else indirect(menu_choices);
159
{ if (oldcl>0) { @set_cursor oldcl 4; print " ";}
160
@set_cursor cl 4; print ">";
163
@read_char 1 0 0 pkey;
164
if (pkey=='N' or 'n' or 130)
165
{ cl++; if (cl>=ban_lines+lines) cl=ban_lines; jump KeyLoop; }
166
if (pkey=='P' or 'p' or 129)
167
{ cl--; if (cl==ban_lines-1) cl=ban_lines+lines-1; jump KeyLoop; }
168
if ((pkey=='Q' or 'q' or 27)||(pkey==131)) { jump QuitHelp; }
169
if (pkey==10 or 13 or 132)
170
{ @set_window 0; font on;
171
new_line; new_line; new_line;
172
menu_item=cl-ban_lines+1;
177
i = 0->33; if (i==0) { i=80; }
178
@set_window 1; @set_cursor 1 1; style reverse; spaces(i);
179
CenterU(item_name,1);
180
style roman; @set_window 0; new_line;
182
i = indirect(ChoiceR);
183
! if (i==2 && Menuflag~=10000) jump ReDisplay;
184
if (i==2) jump ReDisplay;
185
if (i==3) jump QuitHelp;
187
print "^[Please press SPACE.]^";
188
@read_char 1 0 0 pkey; jump ReDisplay;
192
if (Menuflag==10000) Menuflag=0;
193
menu_nesting--; if (menu_nesting>0) rfalse;
194
font on; @set_cursor 1 1;
195
@erase_window $ffff; @set_window 0;
196
new_line; new_line; new_line;
197
if (deadflag==0 && inflag==0) <<Look>>;