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/MainHallTemp.cpp $
15 * Header file for main-hall menu code
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 * 3 6/04/99 9:52a Dave
29 * Fixed some rendering problems.
31 * 2 6/03/99 10:15p Dave
32 * Put in temporary main hall screen.
38 #include "mainhallmenu.h"
39 #include "mainhalltemp.h"
45 #include "gamesequence.h"
46 #include "missionparse.h"
47 #include "missioncampaign.h"
49 #include "freespace.h"
51 // ------------------------------------------------------------------------------------------------------------------------
52 // TEMP MAIN HALL DEFINES/VARS
55 #define MHT_NUM_BUTTONS 6
57 const char *Mht_bitmap_fname[GR_NUM_RESOLUTIONS] = {
58 "mht_background", // GR_640
59 "2_mht_background" // GR_1024
62 const char *Mht_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = {
64 "2_mht_mask" // GR_1024
68 #define MHT_READY_ROOM 0
69 #define MHT_CAMPAIGN_ROOM 1
71 #define MHT_TECH_ROOM 3
72 #define MHT_BARRACKS 4
75 UI_WINDOW Mht_window; // the window object for the join screen
76 int Mht_bitmap; // the background bitmap
78 ui_button_info Mht_buttons[GR_NUM_RESOLUTIONS][MHT_NUM_BUTTONS] = {
80 ui_button_info( "MHT_00", 15, 194, -1, -1, 2 ), // ready room
81 ui_button_info( "MHT_01", 15, 222, -1, -1, 5 ), // campaigns
82 ui_button_info( "MHT_02", 14, 251, -1, -1, 4 ), // options
83 ui_button_info( "MHT_03", 14, 280, -1, -1, 3 ), // tech room
84 ui_button_info( "MHT_04", 14, 309, -1, -1, 1 ), // barracks
85 ui_button_info( "MHT_05", 16, 339, -1, -1, 0 ), // exit
88 ui_button_info( "2_MHT_00", 25, 312, -1, -1, 2 ), // ready room
89 ui_button_info( "2_MHT_01", 25, 357, -1, -1, 5 ), // campaigns
90 ui_button_info( "2_MHT_02", 24, 403, -1, -1, 4 ), // options
91 ui_button_info( "2_MHT_03", 24, 450, -1, -1, 3 ), // tech room
92 ui_button_info( "2_MHT_04", 25, 497, -1, -1, 1 ), // barracks
93 ui_button_info( "2_MHT_05", 27, 544, -1, -1, 0 ), // exit
98 // ------------------------------------------------------------------------------------------------------------------------
99 // TEMP MAIN HALL FUNCTIONS
102 void mht_check_buttons();
103 void mht_button_pressed(int n);
104 void mht_exit_game();
110 // create the interface window
111 Mht_window.create(0, 0, gr_screen.max_w,gr_screen.max_h, 0);
112 Mht_window.set_mask_bmap(Mht_bitmap_mask_fname[gr_screen.res]);
114 // load the background bitmap
115 Mht_bitmap = bm_load(Mht_bitmap_fname[gr_screen.res]);
117 // we failed to load the bitmap - this is very bad
121 // create the interface buttons
122 for(idx=0; idx<MHT_NUM_BUTTONS; idx++){
124 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);
126 // set the sound to play when highlighted
127 Mht_buttons[gr_screen.res][idx].button.set_highlight_action(common_play_highlight_sound);
129 // set the ani for the button
130 Mht_buttons[gr_screen.res][idx].button.set_bmaps(Mht_buttons[gr_screen.res][idx].filename);
133 Mht_buttons[gr_screen.res][idx].button.link_hotspot(Mht_buttons[gr_screen.res][idx].hotspot);
136 // remove any multiplayer flags from the game mode
137 Game_mode &= ~(GM_MULTIPLAYER);
139 // initialize the music
140 main_hall_start_music();
142 // set the game_mode based on the type of player
143 SDL_assert( Player != NULL );
144 if ( Player->flags & PLAYER_FLAGS_IS_MULTI ){
145 Game_mode = GM_MULTIPLAYER;
147 Game_mode = GM_NORMAL;
153 int k = Mht_window.process();
155 // need to ensure ambient is playing, since it may be stopped by a playing movie
156 main_hall_start_ambient();
158 // process any keypresses
165 gameseq_post_event( GS_EVENT_BARRACKS_MENU );
169 if(Player->flags & PLAYER_FLAGS_IS_MULTI){
173 if (Num_recent_missions > 0) {
174 SDL_strlcpy( Game_current_mission_filename, Recent_missions[0], SDL_arraysize(Game_current_mission_filename) );
176 mission_load_up_campaign();
177 SDL_strlcpy( Game_current_mission_filename, Campaign.missions[0].name, SDL_arraysize(Game_current_mission_filename) );
180 Campaign.current_mission = -1;
181 gameseq_post_event(GS_EVENT_START_GAME_QUICK);
185 gameseq_post_event( GS_EVENT_LOAD_MISSION_MENU );
189 gameseq_post_event(GS_EVENT_OPTIONS_MENU);
193 if (Player->flags & PLAYER_FLAGS_IS_MULTI){
194 main_hall_do_multi_ready();
199 // process button presses
202 // draw the background, etc
204 GR_MAYBE_CLEAR_RES(Mht_bitmap);
205 if(Mht_bitmap != -1){
206 gr_set_bitmap(Mht_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
217 // unload any bitmaps
218 if(!bm_unload(Mht_bitmap)){
219 nprintf(("General","WARNING : could not unload background bitmap %s\n", Mht_bitmap_fname[gr_screen.res]));
222 // destroy the UI_WINDOW
223 Mht_window.destroy();
226 void mht_check_buttons()
229 for(idx=0; idx<MHT_NUM_BUTTONS; idx++){
230 // we only really need to check for one button pressed at a time, so we can break after
232 if(Mht_buttons[gr_screen.res][idx].button.pressed()){
233 mht_button_pressed(idx);
239 void mht_button_pressed(int n)
243 if (Player->flags & PLAYER_FLAGS_IS_MULTI){
244 main_hall_do_multi_ready();
246 gameseq_post_event(GS_EVENT_NEW_CAMPAIGN);
248 gamesnd_play_iface(SND_USER_SELECT);
252 case MHT_CAMPAIGN_ROOM:
253 gameseq_post_event(GS_EVENT_CAMPAIGN_ROOM);
254 gamesnd_play_iface(SND_USER_SELECT);
258 gameseq_post_event(GS_EVENT_OPTIONS_MENU);
259 gamesnd_play_iface(SND_USER_SELECT);
263 gameseq_post_event( GS_EVENT_TECH_MENU );
264 gamesnd_play_iface(SND_USER_SELECT);
268 gameseq_post_event( GS_EVENT_BARRACKS_MENU );
269 gamesnd_play_iface(SND_USER_SELECT);
274 gamesnd_play_iface(SND_USER_SELECT);
282 main_hall_stop_music();
283 main_hall_stop_ambient();
284 gameseq_post_event(GS_EVENT_QUIT_GAME);