~ubuntu-branches/ubuntu/hoary/inform/hoary

« back to all changes in this revision

Viewing changes to include/manual.h

  • Committer: Bazaar Package Importer
  • Author(s): Mark Baker
  • Date: 2004-03-29 23:52:44 UTC
  • Revision ID: james.westby@ubuntu.com-20040329235244-fox1z1yv7d6vojoo
Tags: upstream-6.30
ImportĀ upstreamĀ versionĀ 6.30

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
!-----------------------------------------------------------------------------
 
2
!  Manual.H                     An Inform _6_ library (Backward compatable)
 
3
!                               to generate nicely-formatted browseable text
 
4
!                               for Z-Machine books and built-in manuals. 
 
5
!                               By L. Ross Raszewski
 
6
 
7
! Yes, that's right.  The library-writer who brought you 'TimeWait', 'Date',
 
8
! 'PluralF', 'Footnotes', and all of those other useless #include files has 
 
9
! finally perfected (I hope) his manual-writing library in a form that allows
 
10
! you, yes you, to create an "Inform book".
 
11
! (I'm not being pompous, I'm just glad to have gotten this working, I've 
 
12
! been working on it for a while, and it's never been easy to modify.)
 
13
!
 
14
! So, how does it work?
 
15
! Simple:  you provide a call to the routine WriteManual with the 
 
16
! following arguments:
 
17
!
 
18
! WriteManual(DoFunc,Title,Titlelength,PageNames,PageNameLength,
 
19
!             NumberOfPages,[StartPageNumber]);
 
20
!
 
21
! DoFunc:  A function which can be called with 1 argument, and which prints
 
22
!               a page of text based on that argument (probably with a switch 
 
23
!               directive
 
24
! Title:   The Title you want to appear on the first line of the header 
 
25
!          (a string)
 
26
! Titlelength: The number of characters in the title (used for centering)
 
27
! PageNames: An array containing the titles of the pages to appear on 
 
28
!            the second line of the header
 
29
! PageNameLength: An Array containing the lengths of the PageNames
 
30
! NumberOfPages: Just what it says
 
31
! StartPageNumber: For indexing (I'll write that later), you can call the 
 
32
!                  manual to any page.  By default, it will start on page 0
 
33
!                  which should be a title page.
 
34
!
 
35
! Toss something like this into your code:
 
36
! [ ManualSub;
 
37
!   WriteManual(DoPage,"Zork - Game Manual",18,pspage,pspn,3);
 
38
! ];
 
39
! Verb meta "manual" "instructions" *                     ->Manual;
 
40
!
 
41
! and "Manual" will bring up a manual.  Your DoPage(mpage); should run 
 
42
! something like:
 
43
!
 
44
! [ DoPage i;
 
45
!     switch(i){
 
46
!               0: @erase_window -1; box "Zork Manual";
 
47
!               1: "This is page 1";
 
48
!               2: "This is Page 2";
 
49
!               ...
 
50
!               };
 
51
! ];
 
52
! pspage --> "Title" "Page 1" "Page 2" "Hey, Page 3";
 
53
! pspn -> 5 6 6 11;
 
54
!
 
55
! Note that the banner will only appear on the title page if the user 
 
56
! holds down on the "p" key (It will sort of flicker as it is drawn by 
 
57
! ManualPage and erased by DoPage).
 
58
!
 
59
! Up and P work as page up, Down and N work as page down, Esc and Q work as 
 
60
! exit, and [Space] will advance from page 0.
 
61
!
 
62
! This also checks pretty_flag, and produces a lowkey_Menu, which simply 
 
63
! writes to the screen and asks for an N, P or Q.  Lowkey menus will not 
 
64
! start on page 0, but the player can pageup to them.
 
65
!
 
66
! If you have any trouble, or comments on this or any of my libraries,
 
67
! _please_ write me at rraszews@skipjack.bluecrab.org
 
68
! I'm always glad to hear from people using my libraries.
 
69
!
 
70
! Thanks to Graham Nelson for Inform, The Guys on R.A.I-F, and whoever 
 
71
! told me that Inform 6.05 would actually _work_ on my story files.
 
72
!
 
73
 
 
74
 
 
75
[ WriteManual doman title titlel pagen pagel npages startp pnum flag;
 
76
  if (pretty_flag==0) {LowKeyManual(doman,title,pagen,npages,startp); rtrue;};
 
77
   pnum=startp;
 
78
   do {
 
79
        switch(ManualPage(pnum,pagen-->pnum,pagel->pnum,title,titlel,doman))
 
80
                {0: pnum--;
 
81
                 1: pnum++;
 
82
                 2: flag=1;};
 
83
        if (pnum<0) pnum=0;
 
84
        if (pnum>npages) pnum=pnum--;}
 
85
   until (flag==1);
 
86
   print "^^Back to story...^^"; rtrue;
 
87
];
 
88
 
 
89
[ ManualPage mpage header l title titlel doman i j keypress;
 
90
i=0->33; if (i==0) i=80;
 
91
l=l/2;
 
92
style roman;
 
93
@split_window 3; @set_window 1; style reverse;
 
94
@set_cursor 1 1; spaces(i); @set_cursor 2 1; spaces(i); @set_cursor 3 1; spaces(i);
 
95
j=(i/2)-(titlel/2); @set_cursor 1 j;print (string) title;style bold;style reverse;
 
96
j=(i/2)-l;@set_cursor 2 j; print (string) header; style roman; style reverse;
 
97
@set_cursor 2 2; print "P = previous page";
 
98
j=i-13 ; @set_cursor 2 j; print "N = next page";
 
99
@set_cursor 3 2; print "Q = resume story";
 
100
@set_cursor 3 j; print "Page ", mpage;
 
101
@set_window 0; style roman; font on; indirect(doman,mpage); new_line;
 
102
do { @read_char 1 0 0 keypress;} until ((keypress==129 or 'P' or 'p' or 130 
 
103
                                        or 'N' or 'n' or 'q' or 'Q' or 27) 
 
104
                                        || (keypress==32 or 10 or 13 && mpage==0));
 
105
@erase_window -1;
 
106
if (keypress==129 or 'P' or 'p') return 0;
 
107
if (keypress==32 or 10 or 13 && mpage==0) return 1;
 
108
if (keypress==130 or 'N' or 'n') return 1;
 
109
if (keypress==27 or 'Q' or 'q') return 2;
 
110
];
 
111
 
 
112
[ LowKeyManual doman title pagen npages startp i j k;
 
113
        if (startp==0) startp=1;
 
114
        print "^^^"; print (string) title;
 
115
        j=startp;
 
116
        do        
 
117
        { print (string) pagen-->j; print "^";
 
118
        indirect(doman,j);
 
119
        print "^^[Press ~N~ for the next page, ~P~ for the previous, 
 
120
                 or ~Q~ to quit]^^";
 
121
        do {@read_char 1 0 0 i;} until (i=='N' or 'n' or 'P' or 'p' or 'Q' or 'q');
 
122
        if (i=='N' or 'n') j++;
 
123
        if (i=='P' or 'p') j--;
 
124
        if (i=='Q' or 'q') k=1;
 
125
        if (j<0) j==0;
 
126
        if (j>npages) j--;
 
127
        #IFV5;
 
128
        DrawStatusLine();
 
129
        #ENDIF;
 
130
        } until (k==1);
 
131
];