FS2_Open
Open source remastering of the Freespace 2 engine
mainhalltemp.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
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 the
6  * source.
7  *
8 */
9 
10 
11 
12 #include "freespace2/freespace.h"
14 #include "gamesnd/gamesnd.h"
15 #include "io/key.h"
16 #include "menuui/mainhallmenu.h"
17 #include "menuui/mainhalltemp.h"
19 #include "mission/missionload.h"
20 #include "playerman/player.h"
21 #include "ui/ui.h"
22 
23 
24 // ------------------------------------------------------------------------------------------------------------------------
25 // TEMP MAIN HALL DEFINES/VARS
26 //
27 
28 #define MHT_NUM_BUTTONS 6
29 
31  "mht_background", // GR_640
32  "2_mht_background" // GR_1024
33 };
34 
36  "mht_mask", // GR_640
37  "2_mht_mask" // GR_1024
38 };
39 
40 // button defs
41 #define MHT_READY_ROOM 0
42 #define MHT_CAMPAIGN_ROOM 1
43 #define MHT_OPTIONS 2
44 #define MHT_TECH_ROOM 3
45 #define MHT_BARRACKS 4
46 #define MHT_EXIT 5
47 
48 UI_WINDOW Mht_window; // the window object for the join screen
49 int Mht_bitmap; // the background bitmap
50 
52  { // GR_640
53  ui_button_info( "MHT_00", 15, 194, -1, -1, 2 ), // ready room
54  ui_button_info( "MHT_01", 15, 222, -1, -1, 5 ), // campaigns
55  ui_button_info( "MHT_02", 14, 251, -1, -1, 4 ), // options
56  ui_button_info( "MHT_03", 14, 280, -1, -1, 3 ), // tech room
57  ui_button_info( "MHT_04", 14, 309, -1, -1, 1 ), // barracks
58  ui_button_info( "MHT_05", 16, 339, -1, -1, 0 ), // exit
59  },
60  { // GR_1024
61  ui_button_info( "2_MHT_00", 25, 312, -1, -1, 2 ), // ready room
62  ui_button_info( "2_MHT_01", 25, 357, -1, -1, 5 ), // campaigns
63  ui_button_info( "2_MHT_02", 24, 403, -1, -1, 4 ), // options
64  ui_button_info( "2_MHT_03", 24, 450, -1, -1, 3 ), // tech room
65  ui_button_info( "2_MHT_04", 25, 497, -1, -1, 1 ), // barracks
66  ui_button_info( "2_MHT_05", 27, 544, -1, -1, 0 ), // exit
67  }
68 };
69 
70 
71 // ------------------------------------------------------------------------------------------------------------------------
72 // TEMP MAIN HALL FUNCTIONS
73 //
74 
75 void mht_check_buttons();
76 void mht_button_pressed(int n);
77 void mht_exit_game();
78 
79 void mht_init()
80 {
81  int idx;
82 
83  // create the interface window
86 
87  // load the background bitmap
89  if(Mht_bitmap < 0){
90  // we failed to load the bitmap - this is very bad
91  Int3();
92  }
93 
94  // create the interface buttons
95  for(idx=0; idx<MHT_NUM_BUTTONS; idx++){
96  // create the object
97  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);
98 
99  // set the sound to play when highlighted
101 
102  // set the ani for the button
103  Mht_buttons[gr_screen.res][idx].button.set_bmaps(Mht_buttons[gr_screen.res][idx].filename);
104 
105  // set the hotspot
106  Mht_buttons[gr_screen.res][idx].button.link_hotspot(Mht_buttons[gr_screen.res][idx].hotspot);
107  }
108 
109  // remove any multiplayer flags from the game mode
111 
112  // initialize the music
114 
115  // set the game_mode based on the type of player
116  Assert( Player != NULL );
119  } else {
121  }
122 }
123 
124 void mht_do()
125 {
126  int k = Mht_window.process();
127 
128  // need to ensure ambient is playing, since it may be stopped by a playing movie
130 
131  // process any keypresses
132  switch(k){
133  case KEY_ESC :
134  mht_exit_game();
135  break;
136 
137  case KEY_B:
139  break;
140 
141  case KEY_G:
143  break;
144  }
145 
146  if (Num_recent_missions > 0) {
148  } else {
151  }
152 
155  break;
156 
157  case KEY_L:
159  break;
160 
161  case KEY_F2:
163  break;
164 
165  case KEY_M:
168  }
169  break;
170  }
171 
172  // process button presses
174 
175  // draw the background, etc
176  gr_reset_clip();
178  if(Mht_bitmap != -1){
181  }
182  Mht_window.draw();
183 
184  // flip the buffer
185  gr_flip();
186 }
187 
188 void mht_close()
189 {
190  // unload any bitmaps
191  if(!bm_unload(Mht_bitmap)){
192  nprintf(("General","WARNING : could not unload background bitmap %s\n", Mht_bitmap_fname[gr_screen.res]));
193  }
194 
195  // destroy the UI_WINDOW
196  Mht_window.destroy();
197 }
198 
200 {
201  int idx;
202  for(idx=0; idx<MHT_NUM_BUTTONS; idx++){
203  // we only really need to check for one button pressed at a time, so we can break after
204  // finding one.
205  if(Mht_buttons[gr_screen.res][idx].button.pressed()){
206  mht_button_pressed(idx);
207  break;
208  }
209  }
210 }
211 
213 {
214  switch(n){
215  case MHT_READY_ROOM:
218  } else {
220 
222  }
223  break;
224 
225  case MHT_CAMPAIGN_ROOM:
228  break;
229 
230  case MHT_OPTIONS:
233  break;
234 
235  case MHT_TECH_ROOM:
238  break;
239 
240  case MHT_BARRACKS:
243  break;
244 
245  case MHT_EXIT:
246  mht_exit_game();
248  break;
249  }
250 }
251 
253 {
254  // stop music first
255  main_hall_stop_music(true);
258 }
void set_highlight_action(void(*_user_function)(void))
Definition: button.cpp:375
int flags
Definition: player.h:104
int Game_mode
Definition: systemvars.cpp:24
void gr_flip()
Definition: 2d.cpp:2113
int x
Definition: ui.h:658
char Recent_missions[MAX_RECENT_MISSIONS][MAX_FILENAME_LEN]
Definition: missionload.cpp:34
char Game_current_mission_filename[MAX_FILENAME_LEN]
Definition: fredstubs.cpp:26
#define GR_RESIZE_MENU
Definition: 2d.h:684
int y
Definition: ui.h:658
char * Mht_bitmap_mask_fname[GR_NUM_RESOLUTIONS]
Assert(pm!=NULL)
#define GR_NUM_RESOLUTIONS
Definition: 2d.h:651
int res
Definition: 2d.h:370
int max_h_unscaled
Definition: 2d.h:361
void main_hall_start_ambient()
UI_WINDOW Mht_window
#define GR_MAYBE_CLEAR_RES(bmap)
Definition: 2d.h:639
int Mht_bitmap
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
Definition: 2d.cpp:2105
#define MHT_NUM_BUTTONS
int max_w_unscaled
Definition: 2d.h:361
#define Int3()
Definition: pstypes.h:292
int Num_recent_missions
Definition: missionload.cpp:35
char * name
void mht_exit_game()
#define MHT_TECH_ROOM
void destroy()
Definition: window.cpp:189
#define gr_reset_clip
Definition: 2d.h:745
void set_mask_bmap(char *fname)
Definition: window.cpp:75
int set_bmaps(char *ani_filename, int nframes=3, int start_frame=1)
Definition: gadget.cpp:71
void mht_button_pressed(int n)
#define nprintf(args)
Definition: pstypes.h:239
#define GM_MULTIPLAYER
Definition: systemvars.h:18
void mht_close()
int hotspot
Definition: ui.h:659
char * Mht_bitmap_fname[GR_NUM_RESOLUTIONS]
int pressed()
Definition: button.cpp:325
void main_hall_do_multi_ready()
#define MHT_EXIT
void main_hall_stop_ambient()
#define MHT_CAMPAIGN_ROOM
#define MHT_OPTIONS
UI_BUTTON button
Definition: ui.h:660
ui_button_info Mht_buttons[GR_NUM_RESOLUTIONS][MHT_NUM_BUTTONS]
int idx
Definition: multiui.cpp:761
GLclampd n
Definition: Glext.h:7286
int mission_load_up_campaign(player *pl)
user_click (mouse selects a control)
Definition: gamesnd.h:305
int current_mission
int bm_load(const char *real_filename)
Loads a bitmap so we can draw with it later.
Definition: bmpman.cpp:1119
#define KEY_B
Definition: key.h:83
void link_hotspot(int num)
Definition: gadget.cpp:50
campaign Campaign
void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h, int do_repeat=0, int ignore_focus=0)
Definition: button.cpp:26
#define KEY_ESC
Definition: key.h:124
void mht_do()
void create(int _x, int _y, int _w, int _h, int _flags, int _f_id=-1)
Definition: window.cpp:140
player * Player
#define MHT_READY_ROOM
Definition: ui.h:584
screen gr_screen
Definition: 2d.cpp:46
#define KEY_F2
Definition: key.h:144
void common_play_highlight_sound()
Definition: gamesnd.cpp:1151
void main_hall_start_music()
void mht_init()
void mht_check_buttons()
char * filename
Definition: ui.h:657
void gr_bitmap(int _x, int _y, int resize_mode)
Definition: 2d.cpp:1303
#define KEY_G
Definition: key.h:88
#define PLAYER_FLAGS_IS_MULTI
Definition: player.h:42
int bm_unload(int handle, int clear_render_targets, bool nodebug)
Unloads a bitmap's data, but not the bitmap info.
Definition: bmpman.cpp:2890
#define GM_NORMAL
Definition: systemvars.h:19
#define KEY_M
Definition: key.h:94
void gamesnd_play_iface(int n)
Definition: gamesnd.cpp:260
void draw()
Definition: window.cpp:220
struct ui_button_info ui_button_info
#define MHT_BARRACKS
void main_hall_stop_music(bool fade)
int process(int key_in=-1, int process_mouse=1)
Definition: window.cpp:401
void gameseq_post_event(int event)
cmission missions[MAX_CAMPAIGN_MISSIONS]
#define KEY_L
Definition: key.h:93
#define strcpy_s(...)
Definition: safe_strings.h:67