2 * $Logfile: /Freespace2/code/MenuUI/TrainingMenu.cpp $
7 * C module that contains functions to drive the Training user interface
10 * Revision 1.1 2002/05/03 03:28:09 root
14 * 6 7/16/99 1:49p Dave
15 * 8 bit aabitmaps. yay.
17 * 5 1/30/99 5:08p Dave
18 * More new hi-res stuff.Support for nice D3D textures.
20 * 4 12/18/98 1:13a Dave
21 * Rough 1024x768 support for Direct3D. Proper detection and usage through
24 * 3 11/30/98 1:07p Dave
25 * 16 bit conversion, first run.
27 * 2 10/07/98 10:53a Dave
30 * 1 10/07/98 10:49a Dave
32 * 22 2/23/98 6:55p Lawrance
33 * Rip out obsolete code.
35 * 21 2/22/98 4:17p John
36 * More string externalization classification... 190 left to go!
38 * 20 12/06/97 1:11a Lawrance
39 * make a general interface for help overlays
41 * 19 12/05/97 2:39p Lawrance
42 * added some different sounds to main hall, add support for looping
45 * 18 11/19/97 8:36p Dave
46 * Removed references to MainMenu.h
48 * 17 9/03/97 4:32p John
49 * changed bmpman to only accept ani and pcx's. made passing .pcx or .ani
50 * to bm_load functions not needed. Made bmpman keep track of palettes
51 * for bitmaps not mapped into game palettes.
53 * 16 8/31/97 6:38p Lawrance
54 * pass in frametime to do_frame loop
56 * 15 6/12/97 2:50a Lawrance
57 * bm_unlock() now passed bitmap number, not pointer
59 * 14 5/12/97 12:27p John
60 * Restructured Graphics Library to add support for multiple renderers.
62 * 13 2/25/97 11:11a Lawrance
63 * adding more functionality needed for ship selection screen
65 * 12 12/10/96 4:18p Lawrance
66 * added snazzy_menu_close() call and integrated with existing menus
68 * 11 11/29/96 11:47a Lawrance
69 * removed out-dated comments
71 * 10 11/21/96 7:14p Lawrance
72 * converted menu code to use a file (menu.tbl) to get the data for the
75 * 9 11/20/96 12:33p Lawrance
76 * fixed problem when index for adding regions was not being initalized to
77 * 0 in the menu init() function
79 * 8 11/19/96 5:20p Lawrance
80 * fixed state problem that came up as a result of menu code re-work
82 * 7 11/15/96 12:09p John
83 * Added new UI code. Made mouse not return Enter when you click it.
84 * Changed the doSnazzyUI function and names to be snazzy_menu_xxx.
86 * 6 11/13/96 5:08p Lawrance
87 * fixed up close functions to only free stuff if it was actually
90 * 5 11/13/96 4:02p Lawrance
91 * complete over-haul of the menu system and the states associated with
94 * 4 11/13/96 8:32a Lawrance
95 * streamlined menu code
97 * 3 11/08/96 4:57p Lawrance
98 * integrated playing previous mission code with latest goal code
100 * 2 11/05/96 1:54p Lawrance
102 * 1 11/05/96 1:11p Lawrance
103 * files for different game menus
109 #include "gamesequence.h"
110 #include "trainingmenu.h"
112 #include "snazzyui.h"
113 #include "managepilot.h"
114 #include "missionload.h"
117 #include "mainhallmenu.h"
119 // global to this file
120 static int trainingMenuBitmap;
121 static int trainingMenuMask;
122 static bitmap* trainingMenuMaskPtr;
123 static ubyte* mask_data;
124 static int Training_mask_w, Training_mask_h;
125 static MENU_REGION region[TRAINING_MENU_MAX_CHOICES];
126 static int num_training;
128 static int training_menu_inited=0;
130 void training_menu_init()
132 char background_img_filename[MAX_FILENAME_LEN];
133 char background_mask_filename[MAX_FILENAME_LEN];
137 read_menu_tbl(NOX("TRAINING MENU"), background_img_filename, background_mask_filename, region, &num_training);
139 // load in the background bitmap (filenames are hard-coded temporarily)
140 trainingMenuBitmap = bm_load(background_img_filename);
141 if (trainingMenuBitmap < 0) {
142 Error(LOCATION,"Could not load in %s!",background_img_filename);
145 trainingMenuMask = bm_load(background_mask_filename);
146 Training_mask_w = -1;
147 Training_mask_h = -1;
149 if (trainingMenuMask < 0) {
150 Error(LOCATION,"Could not load in %s!",background_mask_filename);
153 // get a pointer to bitmap by using bm_lock()
154 trainingMenuMaskPtr = bm_lock(trainingMenuMask, 8, BMP_AABITMAP);
155 mask_data = (ubyte*)trainingMenuMaskPtr->data;
156 bm_get_info(trainingMenuMask, &Training_mask_w, &Training_mask_h);
160 void training_menu_close()
162 if (training_menu_inited) {
163 // done with the bitmap, so unlock it
164 bm_unlock(trainingMenuMask);
166 // unload the bitmaps
167 bm_unload(trainingMenuBitmap);
168 bm_unload(trainingMenuMask);
170 training_menu_inited = 0;
175 void training_menu_do_frame(float frametime)
177 int training_menu_choice;
179 if (!training_menu_inited) {
180 training_menu_init();
181 training_menu_inited=1;
186 GR_MAYBE_CLEAR_RES(trainingMenuBitmap);
187 // set the background
188 if(trainingMenuBitmap != -1){
189 gr_set_bitmap(trainingMenuBitmap);
193 int snazzy_action = -1;
194 training_menu_choice = snazzy_menu_do(mask_data, Training_mask_w, Training_mask_h, num_training, region, &snazzy_action);
195 if ( snazzy_action != SNAZZY_CLICKED ){
196 training_menu_choice = -1;
199 switch (training_menu_choice) {
201 case TRAINING_MENU_TRAINING_MISSIONS_MASK:
203 case TRAINING_MENU_REPLAY_MISSIONS_MASK:
204 // TODO: load the mission and start the briefing
206 case TRAINING_MENU_RETURN_MASK:
208 gameseq_post_event(GS_EVENT_MAIN_MENU);
214 Error(LOCATION, "Unknown option %d in training menu screen", training_menu_choice );