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

« back to all changes in this revision

Viewing changes to include/newmenu.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
 
! NewMenu.h -- 960131   Mike Phillips (mike@lawlib.wm.edu)
2
 
3
 
! for Inform 5.5, Library 5/12 (may work with earlier versions)
4
 
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).
14
 
!
15
 
! All rights released, use it how you will.  No warranty, of course.
16
 
!
17
 
! To make use of this, place the following lines:
18
 
! Replace LowKey_Menu;
19
 
! Replace DoMenu;
20
 
!
21
 
! before including Parser.h, and include NewMenu.h some time after that.
22
 
!
23
 
 
24
 
 
25
 
[ LowKey_Menu menu_choices EntryR ChoiceR lines main_title i j;
26
 
  menu_nesting++;
27
 
 .LKRD;
28
 
  menu_item=0;
29
 
  lines=indirect(EntryR);
30
 
  main_title=item_name;
31
 
 
32
 
  print "--- "; print_paddr main_title; print " ---^^";
33
 
  if (ZRegion(menu_choices)==3) print_paddr menu_choices;
34
 
  else indirect(menu_choices);
35
 
 
36
 
 .LKML;
37
 
  print "^Type a number from 1 to ", lines,
38
 
        ", 0 to redisplay or press ENTER.^> ";
39
 
 
40
 
   #IFV3; read buffer parse; #ENDIF;
41
 
   temp_global=0;
42
 
   #IFV5; read buffer parse DrawStatusLine; #ENDIF;
43
 
   i=parse-->1;
44
 
   if (i=='quit' or #n$q || parse->1==0)
45
 
   {   menu_nesting--; if (menu_nesting>0) rfalse;
46
 
       if (deadflag==0) <<Look>>;
47
 
       rfalse;
48
 
   }
49
 
   i=TryNumber(1);
50
 
   if (i==0) jump LKRD;
51
 
   if (i<1 || i>lines) jump LKML;
52
 
   menu_item=i;
53
 
   j=indirect(ChoiceR);
54
 
   if (j==2) jump LKRD;
55
 
   if (j==3) rfalse;
56
 
   jump LKML;
57
 
];
58
 
 
59
 
#IFV3;
60
 
[ DoMenu menu_choices EntryR ChoiceR;
61
 
  LowKey_Menu(menu_choices,EntryR,ChoiceR);
62
 
];
63
 
#ENDIF;
64
 
 
65
 
#IFV5;
66
 
Global DoM_cl;
67
 
[ DoMenu menu_choices EntryR ChoiceR
68
 
         lines main_title main_wid cl i j oldcl pkey;
69
 
  if (pretty_flag==0)
70
 
  {   LowKey_Menu(menu_choices,EntryR,ChoiceR);
71
 
      rfalse;
72
 
  }
73
 
  menu_nesting++;
74
 
  DoM_cl=7;
75
 
  cl=DoM_cl;
76
 
  .ReDisplay;
77
 
      menu_item=0;
78
 
      lines=indirect(EntryR);
79
 
      main_title=item_name; main_wid=item_width;
80
 
      oldcl=0;
81
 
      @erase_window $ffff;
82
 
      i=lines+7;
83
 
      @split_window i;
84
 
      i = 0->33;
85
 
      if (i==0) i=80;
86
 
      @set_window 1;
87
 
      @set_cursor 1 1;
88
 
      style reverse;
89
 
      spaces(i); j=i/2-main_wid;
90
 
      @set_cursor 1 j;
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;
98
 
      if (menu_nesting==1)
99
 
          print "  Q = resume game";
100
 
      else
101
 
          print "Q = previous menu";
102
 
      style roman;
103
 
      @set_cursor 5 2; font off;
104
 
 
105
 
      if (ZRegion(menu_choices)==3) print_paddr menu_choices;
106
 
      else indirect(menu_choices);
107
 
 
108
 
      .KeyLoop;
109
 
      if (cl~=oldcl)
110
 
      {   if (oldcl>0) { @set_cursor oldcl 4; print " "; }
111
 
          @set_cursor cl 4; print ">";
112
 
      }
113
 
      oldcl=cl;
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; }
120
 
      if (pkey==10 or 13)
121
 
      {   @set_window 0; font on;
122
 
          new_line; new_line; new_line;
123
 
 
124
 
          menu_item=cl-6;
125
 
          indirect(EntryR);
126
 
 
127
 
          @erase_window $ffff;
128
 
          @split_window 1;
129
 
          i = 0->33; if (i==0) { i=80; }
130
 
          @set_window 1; @set_cursor 1 1; style reverse; spaces(i);
131
 
          j=i/2-item_width;
132
 
          @set_cursor 1 j;
133
 
          print_paddr item_name;
134
 
          style roman; @set_window 0; new_line;
135
 
 
136
 
          i = indirect(ChoiceR);
137
 
          if (i==2) { cl=DoM_cl; jump ReDisplay; }
138
 
          if (i==3) jump QuitHelp;
139
 
 
140
 
          print "^[Please press SPACE.]^";
141
 
          @read_char 1 0 0 pkey; jump ReDisplay;
142
 
      }
143
 
      jump KeyLoop;
144
 
      .QuitHelp;
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>>;
150
 
];  
151
 
#ENDIF;