~ubuntu-branches/ubuntu/vivid/inform/vivid

« back to all changes in this revision

Viewing changes to include/domenu.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Christoph Nordholz
  • Date: 2008-05-26 22:09:44 UTC
  • mfrom: (2.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080526220944-ba7phz0d1k4vo7wx
Tags: 6.31.1+dfsg-1
* Remove a considerable number of files from the package
  due to unacceptable licensing terms.
* Repair library symlinks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
!    DOMENU             A replacement for Inform's standard DoMenu
2
 
!                       built for Inform 6 by L. Ross Raszewski
3
 
!                       (rraszews@skipjack.bluecrab.org)
4
 
!       REQUIRES CENTER.H
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^
11
 
!   ^     Prologue
12
 
!   ^     Beginning
13
 
!   ^     Middle
14
 
!   ^     End"
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)
25
 
!
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
30
 
!
31
 
! if (menu_item==-1) { item_name="Second Line"; return 4;} in the example above
32
 
!
33
 
! One more thing, you no longer have to fiddle with item_width.  DoMenu 
34
 
! doesn't need it anymore.  Merry Christmas.
35
 
!
36
 
! Replace DoMenu(); 
37
 
! Replace LowKey_Menu();
38
 
!
39
 
! Some time before including this.
40
 
!
41
 
! Comments?  e-mail me!
42
 
!
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.
47
 
!
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
52
 
!                        library)
53
 
!  Hints.H (UPDATED)  -> A system for making object-oriented hints which appear
54
 
!                      formatted in the same way as Infocom's InvisiClues
55
 
!
56
 
 
57
 
[ LowKey_Menu menu_choices EntryR ChoiceR lines main_title i j;
58
 
  menu_nesting++;
59
 
 .LKRD;
60
 
  menu_item=0;
61
 
  lines=indirect(EntryR);
62
 
  main_title=item_name;
63
 
  item_name=" ";
64
 
  menu_item=-1;
65
 
  indirect(EntryR);
66
 
  if (item_name ofclass string) print (string) item_name;
67
 
  else indirect(item_name);
68
 
  print "^--- "; 
69
 
  if (main_title ofclass string) print (string) main_title;
70
 
  else indirect(main_title);
71
 
  print " ---^^^";
72
 
  if (ZRegion(menu_choices)==3) print (string) menu_choices;
73
 
  else indirect(menu_choices);
74
 
 
75
 
 .LKML;
76
 
  print "^Type a number from 1 to ", lines,
77
 
        ", 0 to redisplay or press ENTER.^> ";
78
 
 
79
 
   #IFV3; read buffer parse; #ENDIF;
80
 
   temp_global=0;
81
 
   #IFV5; read buffer parse DrawStatusLine; #ENDIF;
82
 
   i=parse-->1;
83
 
   if (i=='quit' or #n$q || parse->1==0)
84
 
   {   menu_nesting--; if (menu_nesting>0) rfalse;
85
 
       if (deadflag==0) <<Look>>;
86
 
       rfalse;
87
 
   }
88
 
   i=TryNumber(1);
89
 
   if (i==0) jump LKRD;
90
 
   if (i<1 || i>lines) jump LKML;
91
 
   menu_item=i;
92
 
   j=indirect(ChoiceR);
93
 
   if (j==2) jump LKRD;
94
 
   if (j==3) rfalse;
95
 
   jump LKML;
96
 
];
97
 
 
98
 
#IFV3;
99
 
[ DoMenu menu_choices EntryR ChoiceR;
100
 
  LowKey_Menu(menu_choices,EntryR,ChoiceR);
101
 
];
102
 
#ENDIF;
103
 
 
104
 
 
105
 
#IFNDEF MenuFlag;
106
 
Global MenuFlag;
107
 
#ENDIF;
108
 
 
109
 
[ DoMenu menu_choices EntryR ChoiceR inflag 
110
 
         lines ban_lines main_title sub_title cl i j oldcl pkey;
111
 
        if (pretty_flag==0) 
112
 
         { LowKey_Menu(menu_choices,EntryR,ChoiceR);
113
 
           rfalse;}
114
 
         menu_nesting++;
115
 
         menu_item=0;
116
 
         lines=indirect(EntryR);
117
 
         main_title=item_name;
118
 
         item_name=" ";
119
 
         menu_item=-1;
120
 
         ban_lines=indirect(EntryR);
121
 
         ban_lines=ban_lines+5;
122
 
         sub_title=item_name;
123
 
         cl=ban_lines;
124
 
         .ReDisplay;
125
 
                oldcl=0;
126
 
                @erase_window -1;
127
 
                i=ban_lines+lines;
128
 
                @split_window i;
129
 
                i=0->33; if (i==0) i=80;
130
 
                @set_window 1;
131
 
                @set_cursor 1 1;
132
 
                style reverse;
133
 
                spaces(i);
134
 
                CenterU(main_title,1);
135
 
                @set_cursor 2 1; spaces (i);
136
 
                style bold;
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";
145
 
                else
146
 
                if (inflag==2) print "    Q = quit menu";
147
 
                else
148
 
                if (menu_nesting==1)
149
 
                        print "  Q = resume game";
150
 
                else
151
 
                        print "Q = previous menu";
152
 
                style roman; font off;
153
 
                @set_cursor 5 2;
154
 
                if (menu_choices ofclass String) print (string) menu_choices;
155
 
                else indirect(menu_choices);
156
 
 
157
 
       .KeyLoop;
158
 
                if (cl~=oldcl)
159
 
                 {  if (oldcl>0) { @set_cursor oldcl 4; print " ";}
160
 
                    @set_cursor cl 4; print ">";
161
 
                 }
162
 
                oldcl=cl;
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;
173
 
          indirect(EntryR);
174
 
 
175
 
          @erase_window $ffff;
176
 
          @split_window 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;
181
 
 
182
 
          i = indirect(ChoiceR);
183
 
       !   if (i==2 && Menuflag~=10000) jump ReDisplay;
184
 
          if (i==2) jump ReDisplay;
185
 
          if (i==3) jump QuitHelp;
186
 
 
187
 
          print "^[Please press SPACE.]^";
188
 
          @read_char 1 0 0 pkey; jump ReDisplay;
189
 
      }
190
 
      jump KeyLoop;
191
 
      .QuitHelp;
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>>;
198
 
];  
199