home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / main / newmenu.h < prev    next >
Text File  |  1998-06-08  |  10KB  |  232 lines

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