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

« back to all changes in this revision

Viewing changes to include/altmenu.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
 
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -*- Inform -*- !!!!
2
 
!       AltMenu                 An Inform 6 Library extension to create 
3
 
!                               object-oriented menus.  By L. Ross Raszewski
4
 
!                               (rraszews@skipjack.bluecrab.org)
5
 
!  Requires DoMenu.h and Center.h
6
 
! First of all, let me say that this is inspired heavily by Graham Nelson's
7
 
! own alternative menu system.  While the code is all my own, I'm not the 
8
 
! sort of person who would shamelessly copy someone else's idea without at 
9
 
! least mentioning them.
10
 
! Graham's implemenatation is really a lot more impressive code-wise.  Mine 
11
 
! is really just a shell for DoMenu.  However, my library uses the extended
12
 
! functions of the DoMenu Library I've written.
13
 
! Usage:
14
 
! To activate a menu, send the select(); message to the appropriate 
15
 
! Menu-Class object.  
16
 
! Menu objectname "Title of the Menu"
17
 
!     with description "If given, this text will be displayed above the menu
18
 
!                       choices",
19
 
!          number (number of lines in the description),
20
 
!          title_bar "If given, this will be displayed on the top line and the
21
 
!                       object name will appear on the second line.";
22
 
!  The children of a menu object are the options on the menu.  All children of 
23
 
! a menu MUST be of class Option, or of an option-ovide a select and doname property, but that's all Class
24
 
! Option does)
25
 
! Option -> "Title of the option"
26
 
!    with description [; string or rouine to be printed when Option is selected
27
 
!                        returns 1 to prompt a waitforkey, 2 to return instanly
28
 
!                        to the menu, or 3 to return and quit the menu];
29
 
! option.select(); is called when an option is selected, so you could change 
30
 
! that if you wanted.
31
 
!
32
 
!
33
 
!  This is part of a series actually, these are inter-dependant libraries.
34
 
!  For this to work, you have to include:
35
 
!  center.h   -> Centers a line of text (or a routine to print one) in 
36
 
!  the upper or lower window.
37
 
!  DoMenu       -> A modified DoMenu routine to allow long headers and 2-line
38
 
!                       title bars.
39
 
! For maximum enjoyment, add on (not required)
40
 
!  Hints.H (UPDATED)  -> A system for making object-oriented hints which appear
41
 
!                      formatted in the same way as Infocom's InvisiClues
42
 
!
43
 
 
44
 
 
45
 
Class Option
46
 
        with select [; return self.description();],
47
 
              doname [; print (name) self;];
48
 
 
49
 
 
50
 
Class Menu
51
 
        class Option,
52
 
        with select [; DoMenu(self.emblazon,self.titles,self.execute); 
53
 
                        return 2;],
54
 
             emblazon [ o; if (self provides description) self.description();
55
 
                                else new_line;
56
 
                         objectloop (o in self) {
57
 
                                spaces(5);
58
 
                                print (name) o;
59
 
                                new_line;
60
 
                                }
61
 
                         ],
62
 
             titles [ i o; if (menu_item==-1) {
63
 
                                if (self provides title_bar) 
64
 
                                        item_name=self.doname;
65
 
                                if (self provides number)
66
 
                                        return self.number();
67
 
                                else return 1;
68
 
                                }
69
 
                        if (menu_item==0) {
70
 
                                if (self provides title_bar)
71
 
                                        item_name=self.title_bar;
72
 
                                else item_name=self.doname;
73
 
                                return children(self);
74
 
                                }
75
 
                        o=child(self);
76
 
                        for (i=1:o~=nothing:i++)
77
 
                                {if (menu_item==i) item_name=o.doname;
78
 
                                 o=sibling(o);}
79
 
                        ],
80
 
             execute [ i o; 
81
 
                        o=child(self);
82
 
                        for (i=1:o~=nothing:i++)
83
 
                                {if (menu_item==i) return o.select();
84
 
                                 o=sibling(o);}
85
 
                        return 2;
86
 
                        ];