1
! NewMenu.h -- 960131 Mike Phillips (mike@lawlib.wm.edu)
3
! for Inform 5.5, Library 5/12 (may work with earlier versions)
5
! This implementation of LowKey_Menu fixes one bug (inability to
6
! redisplay the menu) and adds a feature to the 'fancy' V5 menu:
7
! the DoM_cl global variable may be used as part of forcing a
8
! redraw (a menu routine returning 2, for instance) to select what
9
! the current 'line' of the pointer should be -- the first line is
10
! 7, the second is 8, etc. In addition, a re-draw of the menu will
11
! call the information again, so that the menu size can change and the
12
! title can change (used by the author to allow multiple pages in
13
! the AdHints.h library module without having multiple depths of menus).
15
! All rights released, use it how you will. No warranty, of course.
17
! To make use of this, place the following lines:
18
! Replace LowKey_Menu;
21
! before including Parser.h, and include NewMenu.h some time after that.
25
[ LowKey_Menu menu_choices EntryR ChoiceR lines main_title i j;
29
lines=indirect(EntryR);
32
print "--- "; print_paddr main_title; print " ---^^";
33
if (ZRegion(menu_choices)==3) print_paddr menu_choices;
34
else indirect(menu_choices);
37
print "^Type a number from 1 to ", lines,
38
", 0 to redisplay or press ENTER.^> ";
40
#IFV3; read buffer parse; #ENDIF;
42
#IFV5; read buffer parse DrawStatusLine; #ENDIF;
44
if (i=='quit' or #n$q || parse->1==0)
45
{ menu_nesting--; if (menu_nesting>0) rfalse;
46
if (deadflag==0) <<Look>>;
51
if (i<1 || i>lines) jump LKML;
60
[ DoMenu menu_choices EntryR ChoiceR;
61
LowKey_Menu(menu_choices,EntryR,ChoiceR);
67
[ DoMenu menu_choices EntryR ChoiceR
68
lines main_title main_wid cl i j oldcl pkey;
70
{ LowKey_Menu(menu_choices,EntryR,ChoiceR);
78
lines=indirect(EntryR);
79
main_title=item_name; main_wid=item_width;
89
spaces(i); j=i/2-main_wid;
91
print_paddr main_title;
92
@set_cursor 2 1; spaces(i);
93
@set_cursor 2 2; print "N = next subject";
94
j=i-12; @set_cursor 2 j; print "P = previous";
95
@set_cursor 3 1; spaces(i);
96
@set_cursor 3 2; print "RETURN = read subject";
97
j=i-17; @set_cursor 3 j;
99
print " Q = resume game";
101
print "Q = previous menu";
103
@set_cursor 5 2; font off;
105
if (ZRegion(menu_choices)==3) print_paddr menu_choices;
106
else indirect(menu_choices);
110
{ if (oldcl>0) { @set_cursor oldcl 4; print " "; }
111
@set_cursor cl 4; print ">";
114
@read_char 1 0 0 pkey;
115
if (pkey=='N' or 'n' or 130)
116
{ cl++; if (cl==7+lines) cl=7; jump KeyLoop; }
117
if (pkey=='P' or 'p' or 129)
118
{ cl--; if (cl==6) cl=6+lines; jump KeyLoop; }
119
if (pkey=='Q' or 'q' or 27) { jump QuitHelp; }
121
{ @set_window 0; font on;
122
new_line; new_line; new_line;
129
i = 0->33; if (i==0) { i=80; }
130
@set_window 1; @set_cursor 1 1; style reverse; spaces(i);
133
print_paddr item_name;
134
style roman; @set_window 0; new_line;
136
i = indirect(ChoiceR);
137
if (i==2) { cl=DoM_cl; jump ReDisplay; }
138
if (i==3) jump QuitHelp;
140
print "^[Please press SPACE.]^";
141
@read_char 1 0 0 pkey; jump ReDisplay;
145
menu_nesting--; if (menu_nesting>0) rfalse;
146
font on; @set_cursor 1 1;
147
@erase_window $ffff; @set_window 0;
148
new_line; new_line; new_line;
149
if (deadflag==0) <<Look>>;