2 * $Logfile: /Freespace2/code/MenuUI/MainHallTemp.cpp $
7 * Header file for main-hall menu code
10 * Revision 1.1 2002/05/03 03:28:09 root
14 * 3 6/04/99 9:52a Dave
15 * Fixed some rendering problems.
17 * 2 6/03/99 10:15p Dave
18 * Put in temporary main hall screen.
24 #include "mainhallmenu.h"
25 #include "mainhalltemp.h"
31 #include "gamesequence.h"
32 #include "missionparse.h"
33 #include "missioncampaign.h"
35 #include "freespace.h"
37 // ------------------------------------------------------------------------------------------------------------------------
38 // TEMP MAIN HALL DEFINES/VARS
41 #define MHT_NUM_BUTTONS 6
43 char *Mht_bitmap_fname[GR_NUM_RESOLUTIONS] = {
44 "mht_background", // GR_640
45 "2_mht_background" // GR_1024
48 char *Mht_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = {
50 "2_mht_mask" // GR_1024
54 #define MHT_READY_ROOM 0
55 #define MHT_CAMPAIGN_ROOM 1
57 #define MHT_TECH_ROOM 3
58 #define MHT_BARRACKS 4
61 UI_WINDOW Mht_window; // the window object for the join screen
62 int Mht_bitmap; // the background bitmap
64 ui_button_info Mht_buttons[GR_NUM_RESOLUTIONS][MHT_NUM_BUTTONS] = {
66 ui_button_info( "MHT_00", 15, 194, -1, -1, 2 ), // ready room
67 ui_button_info( "MHT_01", 15, 222, -1, -1, 5 ), // campaigns
68 ui_button_info( "MHT_02", 14, 251, -1, -1, 4 ), // options
69 ui_button_info( "MHT_03", 14, 280, -1, -1, 3 ), // tech room
70 ui_button_info( "MHT_04", 14, 309, -1, -1, 1 ), // barracks
71 ui_button_info( "MHT_05", 16, 339, -1, -1, 0 ), // exit
74 ui_button_info( "2_MHT_00", 25, 312, -1, -1, 2 ), // ready room
75 ui_button_info( "2_MHT_01", 25, 357, -1, -1, 5 ), // campaigns
76 ui_button_info( "2_MHT_02", 24, 403, -1, -1, 4 ), // options
77 ui_button_info( "2_MHT_03", 24, 450, -1, -1, 3 ), // tech room
78 ui_button_info( "2_MHT_04", 25, 497, -1, -1, 1 ), // barracks
79 ui_button_info( "2_MHT_05", 27, 544, -1, -1, 0 ), // exit
84 // ------------------------------------------------------------------------------------------------------------------------
85 // TEMP MAIN HALL FUNCTIONS
88 void mht_check_buttons();
89 void mht_button_pressed(int n);
96 // create the interface window
97 Mht_window.create(0, 0, gr_screen.max_w,gr_screen.max_h, 0);
98 Mht_window.set_mask_bmap(Mht_bitmap_mask_fname[gr_screen.res]);
100 // load the background bitmap
101 Mht_bitmap = bm_load(Mht_bitmap_fname[gr_screen.res]);
103 // we failed to load the bitmap - this is very bad
107 // create the interface buttons
108 for(idx=0; idx<MHT_NUM_BUTTONS; idx++){
110 Mht_buttons[gr_screen.res][idx].button.create(&Mht_window, "", Mht_buttons[gr_screen.res][idx].x, Mht_buttons[gr_screen.res][idx].y, 1, 1, 0, 1);
112 // set the sound to play when highlighted
113 Mht_buttons[gr_screen.res][idx].button.set_highlight_action(common_play_highlight_sound);
115 // set the ani for the button
116 Mht_buttons[gr_screen.res][idx].button.set_bmaps(Mht_buttons[gr_screen.res][idx].filename);
119 Mht_buttons[gr_screen.res][idx].button.link_hotspot(Mht_buttons[gr_screen.res][idx].hotspot);
122 // remove any multiplayer flags from the game mode
123 Game_mode &= ~(GM_MULTIPLAYER);
125 // initialize the music
126 main_hall_start_music();
128 // set the game_mode based on the type of player
129 Assert( Player != NULL );
130 if ( Player->flags & PLAYER_FLAGS_IS_MULTI ){
131 Game_mode = GM_MULTIPLAYER;
133 Game_mode = GM_NORMAL;
139 int k = Mht_window.process();
141 // need to ensure ambient is playing, since it may be stopped by a playing movie
142 main_hall_start_ambient();
144 // process any keypresses
151 gameseq_post_event( GS_EVENT_BARRACKS_MENU );
155 if(Player->flags & PLAYER_FLAGS_IS_MULTI){
159 if (Num_recent_missions > 0) {
160 strncpy( Game_current_mission_filename, Recent_missions[0], MAX_FILENAME_LEN );
162 mission_load_up_campaign();
163 strncpy( Game_current_mission_filename, Campaign.missions[0].name, MAX_FILENAME_LEN );
166 Campaign.current_mission = -1;
167 gameseq_post_event(GS_EVENT_START_GAME_QUICK);
171 gameseq_post_event( GS_EVENT_LOAD_MISSION_MENU );
175 gameseq_post_event(GS_EVENT_OPTIONS_MENU);
179 if (Player->flags & PLAYER_FLAGS_IS_MULTI){
180 main_hall_do_multi_ready();
185 // process button presses
188 // draw the background, etc
190 GR_MAYBE_CLEAR_RES(Mht_bitmap);
191 if(Mht_bitmap != -1){
192 gr_set_bitmap(Mht_bitmap);
203 // unload any bitmaps
204 if(!bm_unload(Mht_bitmap)){
205 nprintf(("General","WARNING : could not unload background bitmap %s\n", Mht_bitmap_fname[gr_screen.res]));
208 // destroy the UI_WINDOW
209 Mht_window.destroy();
212 void mht_check_buttons()
215 for(idx=0; idx<MHT_NUM_BUTTONS; idx++){
216 // we only really need to check for one button pressed at a time, so we can break after
218 if(Mht_buttons[gr_screen.res][idx].button.pressed()){
219 mht_button_pressed(idx);
225 void mht_button_pressed(int n)
229 if (Player->flags & PLAYER_FLAGS_IS_MULTI){
230 main_hall_do_multi_ready();
232 gameseq_post_event(GS_EVENT_NEW_CAMPAIGN);
234 gamesnd_play_iface(SND_USER_SELECT);
238 case MHT_CAMPAIGN_ROOM:
239 gameseq_post_event(GS_EVENT_CAMPAIGN_ROOM);
240 gamesnd_play_iface(SND_USER_SELECT);
244 gameseq_post_event(GS_EVENT_OPTIONS_MENU);
245 gamesnd_play_iface(SND_USER_SELECT);
249 gameseq_post_event( GS_EVENT_TECH_MENU );
250 gamesnd_play_iface(SND_USER_SELECT);
254 gameseq_post_event( GS_EVENT_BARRACKS_MENU );
255 gamesnd_play_iface(SND_USER_SELECT);
260 gamesnd_play_iface(SND_USER_SELECT);
268 main_hall_stop_music();
269 main_hall_stop_ambient();
270 gameseq_post_event(GS_EVENT_QUIT_GAME);