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.2 2002/06/09 04:41:22 relnev
19 * added copyright header
21 * Revision 1.1.1.1 2002/05/03 03:28:09 root
25 * 3 6/04/99 9:52a Dave
26 * Fixed some rendering problems.
28 * 2 6/03/99 10:15p Dave
29 * Put in temporary main hall screen.
35 #include "mainhallmenu.h"
36 #include "mainhalltemp.h"
42 #include "gamesequence.h"
43 #include "missionparse.h"
44 #include "missioncampaign.h"
46 #include "freespace.h"
48 // ------------------------------------------------------------------------------------------------------------------------
49 // TEMP MAIN HALL DEFINES/VARS
52 #define MHT_NUM_BUTTONS 6
54 char *Mht_bitmap_fname[GR_NUM_RESOLUTIONS] = {
55 "mht_background", // GR_640
56 "2_mht_background" // GR_1024
59 char *Mht_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = {
61 "2_mht_mask" // GR_1024
65 #define MHT_READY_ROOM 0
66 #define MHT_CAMPAIGN_ROOM 1
68 #define MHT_TECH_ROOM 3
69 #define MHT_BARRACKS 4
72 UI_WINDOW Mht_window; // the window object for the join screen
73 int Mht_bitmap; // the background bitmap
75 ui_button_info Mht_buttons[GR_NUM_RESOLUTIONS][MHT_NUM_BUTTONS] = {
77 ui_button_info( "MHT_00", 15, 194, -1, -1, 2 ), // ready room
78 ui_button_info( "MHT_01", 15, 222, -1, -1, 5 ), // campaigns
79 ui_button_info( "MHT_02", 14, 251, -1, -1, 4 ), // options
80 ui_button_info( "MHT_03", 14, 280, -1, -1, 3 ), // tech room
81 ui_button_info( "MHT_04", 14, 309, -1, -1, 1 ), // barracks
82 ui_button_info( "MHT_05", 16, 339, -1, -1, 0 ), // exit
85 ui_button_info( "2_MHT_00", 25, 312, -1, -1, 2 ), // ready room
86 ui_button_info( "2_MHT_01", 25, 357, -1, -1, 5 ), // campaigns
87 ui_button_info( "2_MHT_02", 24, 403, -1, -1, 4 ), // options
88 ui_button_info( "2_MHT_03", 24, 450, -1, -1, 3 ), // tech room
89 ui_button_info( "2_MHT_04", 25, 497, -1, -1, 1 ), // barracks
90 ui_button_info( "2_MHT_05", 27, 544, -1, -1, 0 ), // exit
95 // ------------------------------------------------------------------------------------------------------------------------
96 // TEMP MAIN HALL FUNCTIONS
99 void mht_check_buttons();
100 void mht_button_pressed(int n);
101 void mht_exit_game();
107 // create the interface window
108 Mht_window.create(0, 0, gr_screen.max_w,gr_screen.max_h, 0);
109 Mht_window.set_mask_bmap(Mht_bitmap_mask_fname[gr_screen.res]);
111 // load the background bitmap
112 Mht_bitmap = bm_load(Mht_bitmap_fname[gr_screen.res]);
114 // we failed to load the bitmap - this is very bad
118 // create the interface buttons
119 for(idx=0; idx<MHT_NUM_BUTTONS; idx++){
121 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);
123 // set the sound to play when highlighted
124 Mht_buttons[gr_screen.res][idx].button.set_highlight_action(common_play_highlight_sound);
126 // set the ani for the button
127 Mht_buttons[gr_screen.res][idx].button.set_bmaps(Mht_buttons[gr_screen.res][idx].filename);
130 Mht_buttons[gr_screen.res][idx].button.link_hotspot(Mht_buttons[gr_screen.res][idx].hotspot);
133 // remove any multiplayer flags from the game mode
134 Game_mode &= ~(GM_MULTIPLAYER);
136 // initialize the music
137 main_hall_start_music();
139 // set the game_mode based on the type of player
140 Assert( Player != NULL );
141 if ( Player->flags & PLAYER_FLAGS_IS_MULTI ){
142 Game_mode = GM_MULTIPLAYER;
144 Game_mode = GM_NORMAL;
150 int k = Mht_window.process();
152 // need to ensure ambient is playing, since it may be stopped by a playing movie
153 main_hall_start_ambient();
155 // process any keypresses
162 gameseq_post_event( GS_EVENT_BARRACKS_MENU );
166 if(Player->flags & PLAYER_FLAGS_IS_MULTI){
170 if (Num_recent_missions > 0) {
171 strncpy( Game_current_mission_filename, Recent_missions[0], MAX_FILENAME_LEN );
173 mission_load_up_campaign();
174 strncpy( Game_current_mission_filename, Campaign.missions[0].name, MAX_FILENAME_LEN );
177 Campaign.current_mission = -1;
178 gameseq_post_event(GS_EVENT_START_GAME_QUICK);
182 gameseq_post_event( GS_EVENT_LOAD_MISSION_MENU );
186 gameseq_post_event(GS_EVENT_OPTIONS_MENU);
190 if (Player->flags & PLAYER_FLAGS_IS_MULTI){
191 main_hall_do_multi_ready();
196 // process button presses
199 // draw the background, etc
201 GR_MAYBE_CLEAR_RES(Mht_bitmap);
202 if(Mht_bitmap != -1){
203 gr_set_bitmap(Mht_bitmap);
214 // unload any bitmaps
215 if(!bm_unload(Mht_bitmap)){
216 nprintf(("General","WARNING : could not unload background bitmap %s\n", Mht_bitmap_fname[gr_screen.res]));
219 // destroy the UI_WINDOW
220 Mht_window.destroy();
223 void mht_check_buttons()
226 for(idx=0; idx<MHT_NUM_BUTTONS; idx++){
227 // we only really need to check for one button pressed at a time, so we can break after
229 if(Mht_buttons[gr_screen.res][idx].button.pressed()){
230 mht_button_pressed(idx);
236 void mht_button_pressed(int n)
240 if (Player->flags & PLAYER_FLAGS_IS_MULTI){
241 main_hall_do_multi_ready();
243 gameseq_post_event(GS_EVENT_NEW_CAMPAIGN);
245 gamesnd_play_iface(SND_USER_SELECT);
249 case MHT_CAMPAIGN_ROOM:
250 gameseq_post_event(GS_EVENT_CAMPAIGN_ROOM);
251 gamesnd_play_iface(SND_USER_SELECT);
255 gameseq_post_event(GS_EVENT_OPTIONS_MENU);
256 gamesnd_play_iface(SND_USER_SELECT);
260 gameseq_post_event( GS_EVENT_TECH_MENU );
261 gamesnd_play_iface(SND_USER_SELECT);
265 gameseq_post_event( GS_EVENT_BARRACKS_MENU );
266 gamesnd_play_iface(SND_USER_SELECT);
271 gamesnd_play_iface(SND_USER_SELECT);
279 main_hall_stop_music();
280 main_hall_stop_ambient();
281 gameseq_post_event(GS_EVENT_QUIT_GAME);