2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/MenuUI/TrainingMenu.cpp $
15 * C module that contains functions to drive the Training user interface
18 * Revision 1.3 2004/09/20 01:31:44 theoddone33
21 * Revision 1.2 2002/06/09 04:41:22 relnev
22 * added copyright header
24 * Revision 1.1.1.1 2002/05/03 03:28:09 root
28 * 6 7/16/99 1:49p Dave
29 * 8 bit aabitmaps. yay.
31 * 5 1/30/99 5:08p Dave
32 * More new hi-res stuff.Support for nice D3D textures.
34 * 4 12/18/98 1:13a Dave
35 * Rough 1024x768 support for Direct3D. Proper detection and usage through
38 * 3 11/30/98 1:07p Dave
39 * 16 bit conversion, first run.
41 * 2 10/07/98 10:53a Dave
44 * 1 10/07/98 10:49a Dave
46 * 22 2/23/98 6:55p Lawrance
47 * Rip out obsolete code.
49 * 21 2/22/98 4:17p John
50 * More string externalization classification... 190 left to go!
52 * 20 12/06/97 1:11a Lawrance
53 * make a general interface for help overlays
55 * 19 12/05/97 2:39p Lawrance
56 * added some different sounds to main hall, add support for looping
59 * 18 11/19/97 8:36p Dave
60 * Removed references to MainMenu.h
62 * 17 9/03/97 4:32p John
63 * changed bmpman to only accept ani and pcx's. made passing .pcx or .ani
64 * to bm_load functions not needed. Made bmpman keep track of palettes
65 * for bitmaps not mapped into game palettes.
67 * 16 8/31/97 6:38p Lawrance
68 * pass in frametime to do_frame loop
70 * 15 6/12/97 2:50a Lawrance
71 * bm_unlock() now passed bitmap number, not pointer
73 * 14 5/12/97 12:27p John
74 * Restructured Graphics Library to add support for multiple renderers.
76 * 13 2/25/97 11:11a Lawrance
77 * adding more functionality needed for ship selection screen
79 * 12 12/10/96 4:18p Lawrance
80 * added snazzy_menu_close() call and integrated with existing menus
82 * 11 11/29/96 11:47a Lawrance
83 * removed out-dated comments
85 * 10 11/21/96 7:14p Lawrance
86 * converted menu code to use a file (menu.tbl) to get the data for the
89 * 9 11/20/96 12:33p Lawrance
90 * fixed problem when index for adding regions was not being initalized to
91 * 0 in the menu init() function
93 * 8 11/19/96 5:20p Lawrance
94 * fixed state problem that came up as a result of menu code re-work
96 * 7 11/15/96 12:09p John
97 * Added new UI code. Made mouse not return Enter when you click it.
98 * Changed the doSnazzyUI function and names to be snazzy_menu_xxx.
100 * 6 11/13/96 5:08p Lawrance
101 * fixed up close functions to only free stuff if it was actually
104 * 5 11/13/96 4:02p Lawrance
105 * complete over-haul of the menu system and the states associated with
108 * 4 11/13/96 8:32a Lawrance
109 * streamlined menu code
111 * 3 11/08/96 4:57p Lawrance
112 * integrated playing previous mission code with latest goal code
114 * 2 11/05/96 1:54p Lawrance
116 * 1 11/05/96 1:11p Lawrance
117 * files for different game menus
123 #include "gamesequence.h"
124 #include "trainingmenu.h"
126 #include "snazzyui.h"
127 #include "managepilot.h"
128 #include "missionload.h"
131 #include "mainhallmenu.h"
133 // global to this file
134 static int trainingMenuBitmap;
135 static int trainingMenuMask;
136 static bitmap* trainingMenuMaskPtr;
137 static ubyte* mask_data;
138 static int Training_mask_w, Training_mask_h;
139 static MENU_REGION region[TRAINING_MENU_MAX_CHOICES];
140 static int num_training;
142 static int training_menu_inited=0;
144 void training_menu_init()
146 char background_img_filename[MAX_FILENAME_LEN];
147 char background_mask_filename[MAX_FILENAME_LEN];
151 read_menu_tbl(NOX("TRAINING MENU"), background_img_filename, SDL_arraysize(background_img_filename),
152 background_mask_filename, SDL_arraysize(background_mask_filename), region, &num_training);
154 // load in the background bitmap (filenames are hard-coded temporarily)
155 trainingMenuBitmap = bm_load(background_img_filename);
156 if (trainingMenuBitmap < 0) {
157 Error(LOCATION,"Could not load in %s!",background_img_filename);
160 trainingMenuMask = bm_load(background_mask_filename);
161 Training_mask_w = -1;
162 Training_mask_h = -1;
164 if (trainingMenuMask < 0) {
165 Error(LOCATION,"Could not load in %s!",background_mask_filename);
168 // get a pointer to bitmap by using bm_lock()
169 trainingMenuMaskPtr = bm_lock(trainingMenuMask, 8, BMP_AABITMAP);
170 mask_data = (ubyte*)trainingMenuMaskPtr->data;
171 bm_get_info(trainingMenuMask, &Training_mask_w, &Training_mask_h);
175 void training_menu_close()
177 if (training_menu_inited) {
178 // done with the bitmap, so unlock it
179 bm_unlock(trainingMenuMask);
181 // unload the bitmaps
182 bm_unload(trainingMenuBitmap);
183 bm_unload(trainingMenuMask);
185 training_menu_inited = 0;
190 void training_menu_do_frame(float frametime)
192 int training_menu_choice;
194 if (!training_menu_inited) {
195 training_menu_init();
196 training_menu_inited=1;
201 GR_MAYBE_CLEAR_RES(trainingMenuBitmap);
202 // set the background
203 if(trainingMenuBitmap != -1){
204 gr_set_bitmap(trainingMenuBitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
208 int snazzy_action = -1;
209 training_menu_choice = snazzy_menu_do(mask_data, Training_mask_w, Training_mask_h, num_training, region, &snazzy_action);
210 if ( snazzy_action != SNAZZY_CLICKED ){
211 training_menu_choice = -1;
214 switch (training_menu_choice) {
216 case TRAINING_MENU_TRAINING_MISSIONS_MASK:
218 case TRAINING_MENU_REPLAY_MISSIONS_MASK:
219 // TODO: load the mission and start the briefing
221 case TRAINING_MENU_RETURN_MASK:
223 gameseq_post_event(GS_EVENT_MAIN_MENU);
229 Error(LOCATION, "Unknown option %d in training menu screen", training_menu_choice );