1 /* $Id: newmenu.h,v 1.4 2003-10-10 09:36:35 btb Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
20 * Revision 1.3 1995/10/17 13:15:19 allender
21 * new call to nm_listbox for close_box
23 * Revision 1.2 1995/09/13 08:48:50 allender
24 * new prototype for newmenu -- have close box
26 * Revision 1.1 1995/05/16 16:00:32 allender
29 * Revision 2.0 1995/02/27 11:32:28 john
30 * New version 2.0, which has no anonymous unions, builds with
31 * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
33 * Revision 1.24 1995/02/11 16:20:05 john
34 * Added code to make the default mission be the one last played.
36 * Revision 1.23 1995/01/31 10:21:41 john
37 * Added code to specify width, height.
39 * Revision 1.22 1995/01/28 17:09:21 john
40 * *** empty log message ***
42 * Revision 1.21 1995/01/23 18:38:43 john
43 * Added listbox function.
45 * Revision 1.20 1994/11/26 15:29:55 matt
46 * Allow escape out of change pilot menu
48 * Revision 1.19 1994/11/26 14:17:05 matt
49 * Player can now only enter valid chars for his name
51 * Revision 1.18 1994/11/18 16:17:13 mike
52 * prototype Max_linear_depth_objects.
54 * Revision 1.17 1994/11/08 14:51:17 john
55 * Added nm_messagebox1, (like the original, only you can pass a function).
57 * Revision 1.16 1994/11/05 14:31:45 john
58 * Added a new menu function for the background.
60 * Revision 1.15 1994/11/05 14:05:46 john
61 * Fixed fade transitions between all screens by making gr_palette_fade_in and out keep
62 * track of whether the palette is faded in or not. Then, wherever the code needs to fade out,
63 * it just calls gr_palette_fade_out and it will fade out if it isn't already. The same with fade_in.
64 * This eliminates the need for all the flags like Menu_fade_out, game_fade_in palette, etc.
66 * Revision 1.14 1994/11/03 19:37:35 john
67 * Added scrolling file list box
69 * Revision 1.13 1994/10/13 11:34:03 john
70 * Made Thrustmaster FCS Hat work. Put a background behind the
71 * keyboard configure. Took out turn_sensitivity. Changed sound/config
72 * menu to new menu. Made F6 be calibrate joystick.
74 * Revision 1.12 1994/10/11 17:08:32 john
75 * Added sliders for volume controls.
77 * Revision 1.11 1994/10/04 10:26:23 matt
78 * Changed fade in to happen every time a global var is set
80 * Revision 1.10 1994/10/03 14:43:56 john
81 * Added newmenu_do1, which allows you to pass the starting
82 * item to the menu system
84 * Revision 1.9 1994/09/30 11:51:33 john
85 * Added Matt's NM_TYPE_INPUT_MENU
87 * Revision 1.8 1994/08/30 20:38:28 john
88 * Passed citem in newmenu sub.
90 * Revision 1.7 1994/08/12 03:11:00 john
91 * Made network be default off; Moved network options into
92 * main menu. Made starting net game check that mines are the
95 * Revision 1.6 1994/08/11 13:47:05 john
96 * Made newmenu have subtitles, passed key through to
97 * the newmenu subfunctions.
99 * Revision 1.5 1994/07/27 16:12:24 john
100 * Changed newmenu system to have a callback function.
103 * Revision 1.4 1994/07/24 17:41:38 john
104 * *** empty log message ***
106 * Revision 1.3 1994/07/24 17:33:01 john
107 * Added percent item. Also neatend up a bit.
109 * Revision 1.2 1994/07/22 17:48:12 john
110 * Added new menuing system.
112 * Revision 1.1 1994/07/22 13:55:51 john
122 #define NM_TYPE_MENU 0 // A menu item... when enter is hit on this, newmenu_do returns this item number
123 #define NM_TYPE_INPUT 1 // An input box... fills the text field in, and you need to fill in text_len field.
124 #define NM_TYPE_CHECK 2 // A check box. Set and get its status by looking at flags field (1=on, 0=off)
125 #define NM_TYPE_RADIO 3 // Same as check box, but only 1 in a group can be set at a time. Set group fields.
126 #define NM_TYPE_TEXT 4 // A line of text that does nothing.
127 #define NM_TYPE_NUMBER 5 // A numeric entry counter. Changes value from min_value to max_value;
128 #define NM_TYPE_INPUT_MENU 6 // A inputbox that you hit Enter to edit, when done, hit enter and menu leaves.
129 #define NM_TYPE_SLIDER 7 // A slider from min_value to max_value. Draws with text_len chars.
131 #define NM_MAX_TEXT_LEN 50
133 typedef struct newmenu_item {
134 int type; // What kind of item this is, see NM_TYPE_????? defines
135 int value; // For checkboxes and radio buttons, this is 1 if marked initially, else 0
136 int min_value, max_value; // For sliders and number bars.
137 int group; // What group this belongs to for radio buttons.
138 int text_len; // The maximum length of characters that can be entered by this inputboxes
139 char *text; // The text associated with this item.
140 // The rest of these are used internally by by the menu system, so don't set 'em!!
145 char saved_text[NM_MAX_TEXT_LEN+1];
148 // Pass an array of newmenu_items and it processes the menu. It will
149 // return a -1 if Esc is pressed, otherwise, it returns the index of
150 // the item that was current when Enter was was selected.
151 // The subfunction function gets called constantly, so you can dynamically
152 // change the text of an item. Just pass NULL if you don't want this.
153 // Title draws big, Subtitle draw medium sized. You can pass NULL for
154 // either/both of these if you don't want them.
155 extern int newmenu_do(char * title, char * subtitle, int nitems, newmenu_item *item, void (*subfunction)(int nitems, newmenu_item *items, int *last_key, int citem));
157 // Same as above, only you can pass through what item is initially selected.
158 extern int newmenu_do1(char *title, char *subtitle, int nitems, newmenu_item *item, void (*subfunction)(int nitems, newmenu_item *items, int *last_key, int citem), int citem);
160 // Same as above, only you can pass through what background bitmap to use.
161 extern int newmenu_do2(char *title, char *subtitle, int nitems, newmenu_item *item, void (*subfunction)(int nitems, newmenu_item *items, int *last_key, int citem), int citem, char *filename);
163 // Same as above, only you can pass through the width & height
164 extern int newmenu_do3(char *title, char *subtitle, int nitems, newmenu_item *item, void (*subfunction)(int nitems, newmenu_item *items, int *last_key, int citem), int citem, char *filename, int width, int height);
174 strcpy( xtext, "John" );
176 mm[0].type=NM_TYPE_MENU; mm[0].text="Play game";
177 mm[1].type=NM_TYPE_INPUT; mm[1].text=xtext; mm[1].text_len=20;
178 mm[2].type=NM_TYPE_CHECK; mm[2].value=0; mm[2].text="check box";
179 mm[3].type=NM_TYPE_TEXT; mm[3].text="-pickone-";
180 mm[4].type=NM_TYPE_RADIO; mm[4].value=1; mm[4].group=0; mm[4].text="Radio #1";
181 mm[5].type=NM_TYPE_RADIO; mm[5].value=1; mm[5].group=0; mm[5].text="Radio #2";
182 mm[6].type=NM_TYPE_RADIO; mm[6].value=1; mm[6].group=0; mm[6].text="Radio #3";
183 mm[7].type=NM_TYPE_PERCENT; mm[7].value=50; mm[7].text="Volume";
185 mmn = newmenu_do("Descent", "Sample Menu", 8, mm, NULL );
186 mprintf( 0, "Menu returned: %d\n", mmn );
191 // This function pops up a messagebox and returns which choice was selected...
193 // nm_messagebox( "Title", "Subtitle", 2, "Ok", "Cancel", "There are %d objects", nobjects );
194 // Returns 0 through nchoices-1.
195 int nm_messagebox(char *title, int nchoices, ...);
196 // Same as above, but you can pass a function
197 int nm_messagebox1(char *title, void (*subfunction)(int nitems, newmenu_item *items, int *last_key, int citem), int nchoices, ...);
199 void nm_draw_background(int x1, int y1, int x2, int y2);
200 void nm_restore_background(int x, int y, int w, int h);
202 // Returns 0 if no file selected, else filename is filled with selected file.
203 int newmenu_get_filename(char *title, char *filespec, char *filename, int allow_abort_flag);
206 extern int Max_linear_depth_objects;
208 extern char *Newmenu_allowed_chars;
210 // Example listbox callback function...
211 // int lb_callback( int * citem, int *nitems, char * items[], int *keypress )
215 // if ( *keypress = KEY_CTRLED+KEY_D ) {
216 // if ( *nitems > 1 ) {
217 // unlink( items[*citem] ); // Delete the file
218 // for (i=*citem; i<*nitems-1; i++ ) {
219 // items[i] = items[i+1];
221 // *nitems = *nitems - 1;
222 // free( items[*nitems] );
223 // items[*nitems] = NULL;
224 // return 1; // redraw;
231 extern int newmenu_listbox(char *title, int nitems, char *items[], int allow_abort_flag, int (*listbox_callback)(int *citem, int *nitems, char *items[], int *keypress));
232 extern int newmenu_listbox1(char *title, int nitems, char *items[], int allow_abort_flag, int default_item, int (*listbox_callback)(int *citem, int *nitems, char *items[], int *keypress));
234 extern int newmenu_filelist(char *title, char *filespace, char *filename);
236 //added on 10/14/98 by Victor Rachels to attempt a fixedwidth font messagebox
237 int nm_messagebox_fixedfont(char *title, int nchoices, ...);
238 //end this section addition
240 //should be called whenever the palette changes
241 extern void nm_remap_background(void);
243 #endif /* _NEWMENU_H */