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/MissionUI/MissionPause.cpp $
17 * Revision 1.5 2004/09/20 01:31:44 theoddone33
20 * Revision 1.4 2003/05/25 02:30:43 taylor
23 * Revision 1.3 2002/06/09 04:41:23 relnev
24 * added copyright header
26 * Revision 1.2 2002/05/07 03:16:46 theoddone33
27 * The Great Newline Fix
29 * Revision 1.1.1.1 2002/05/03 03:28:10 root
33 * 7 7/29/99 10:48p Dave
34 * Multiplayer pause screen.
36 * 6 6/29/99 7:39p Dave
37 * Lots of small bug fixes.
39 * 5 6/09/99 2:17p Dave
40 * Fixed up pleasewait bitmap rendering.
46 #include "missionpause.h"
48 #include "multi_pause.h"
54 #include "gamesequence.h"
55 #include "freespace.h"
59 #include "alphacolors.h"
62 // ----------------------------------------------------------------------------------------------------------------
67 const char *Pause_bmp_name[GR_NUM_RESOLUTIONS] = {
76 // pause bitmap display stuff
77 int Please_wait_coords[GR_NUM_RESOLUTIONS][4] = {
90 const char *Pause_multi_fname[GR_NUM_RESOLUTIONS] = {
94 const char *Pause_multi_mask[GR_NUM_RESOLUTIONS] = {
99 // pause window objects
101 UI_CHECKBOX Pause_single_step;
102 UI_CHECKBOX Pause_physics;
103 UI_CHECKBOX Pause_ai;
104 UI_CHECKBOX Pause_ai_render;
105 UI_CHECKBOX Pause_firing;
106 UI_CHECKBOX Pause_external_view_mode_check;
107 UI_BUTTON Pause_continue;
109 // if we're already paused
112 // background screen (for the chatbox)
113 int Pause_background_bitmap = -1;
115 // saved background screen
116 int Pause_saved_screen = -1;
118 // if we're in external vie wmode
119 int Pause_external_view_mode = 0;
122 extern int Player_attacking_enabled;
123 extern int Ai_render_debug_flag;
124 extern int Ai_firing_enabled;
125 extern int physics_paused;
126 extern int ai_paused;
127 extern int last_single_step;
128 extern int game_single_step;
130 // ----------------------------------------------------------------------------------------------------------------
134 // initialize the pause screen
135 void pause_init(int multi)
137 // if we're already paused. do nothing
142 // pause all beam weapon sounds
145 if(!(Game_mode & GM_STANDALONE_SERVER)){
146 Pause_saved_screen = gr_save_screen();
148 // pause all game music
149 audiostream_pause_all();
151 //JAS: REMOVED CALL TO SET INTERFACE PALETTE TO GET RID OF SCREEN CLEAR WHEN PAUSING
152 //common_set_interface_palette(); // set the interface palette
153 Pause_win.create(0, 0, gr_screen.max_w, gr_screen.max_h, 0);
156 Pause_win.set_mask_bmap(Pause_multi_mask[gr_screen.res]);
157 Pause_background_bitmap = bm_load(Pause_multi_fname[gr_screen.res]);
159 multi_pause_init(&Pause_win);
161 Pause_background_bitmap = bm_load(Pause_bmp_name[gr_screen.res]);
164 multi_pause_init(NULL);
170 // pause do frame - will handle running multiplayer operations if necessary
171 void pause_do(int multi)
175 const char *pause_str = XSTR("Paused", 767);
179 if(Game_mode & GM_STANDALONE_SERVER){
182 // RENDER A GAME FRAME HERE AS THE BACKGROUND
183 gr_restore_screen(Pause_saved_screen);
184 if (Pause_background_bitmap >= 0) {
185 gr_set_bitmap(Pause_background_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
190 gr_bitmap(Please_wait_coords[gr_screen.res][0], Please_wait_coords[gr_screen.res][1]);
193 // draw "Paused" on it
194 gr_set_color_fast(&Color_normal);
196 gr_get_string_size(&str_w, &str_h, pause_str);
197 gr_string((gr_screen.max_w - str_w) / 2, (gr_screen.max_h - str_h) / 2, pause_str);
203 // the multi paused screen will do its own window processing
207 // otherwise process the ui window here
209 k = Pause_win.process() & ~KEY_DEBUGGED;
213 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
218 // draw the background window
221 // a very unique case where we shouldn't be doing the page flip because we're inside of popup code
225 // this should only be happening in a very unique multiplayer case
226 SDL_assert(Game_mode & GM_MULTIPLAYER);
231 // close the pause screen
232 void pause_close(int multi)
234 // if we're not paused - do nothing
239 // unpause all beam weapon sounds
240 beam_unpause_sounds();
243 if(Game_mode & GM_STANDALONE_SERVER){
246 gr_free_screen(Pause_saved_screen);
248 if (Pause_background_bitmap){
249 bm_unload(Pause_background_bitmap);
258 // unpause all the music
259 audiostream_unpause_all();
266 void pause_debug_init()
268 Pause_win.create( 100,100,400,300, WIN_DIALOG );
270 Pause_physics.create( &Pause_win, NOX("Physics Pause <P>"), 200, 150, physics_paused );
271 Pause_ai.create( &Pause_win, NOX("AI Pause <A>"), 200, 175, ai_paused );
273 Pause_ai_render.create( &Pause_win, NOX("AI Render Stuff <R>"), 200, 200, Ai_render_debug_flag);
275 Pause_firing.create( &Pause_win, NOX("AI firing <F>"), 200, 225, Ai_firing_enabled);
276 Pause_external_view_mode_check.create( &Pause_win, NOX("External View <E>"), 200, 250, Pause_external_view_mode);
277 Pause_single_step.create( &Pause_win, NOX("Single Step <S>"), 200, 290, game_single_step );
278 Pause_continue.create( &Pause_win, NOX("Leave Pause"), 200, 350, 200, 40 );
280 Pause_single_step.set_hotkey( SDLK_s );
281 Pause_physics.set_hotkey( SDLK_p );
282 Pause_ai.set_hotkey( SDLK_a );
283 Pause_ai_render.set_hotkey( SDLK_r );
284 Pause_firing.set_hotkey( SDLK_f );
285 Pause_external_view_mode_check.set_hotkey( SDLK_e );
286 Pause_continue.set_hotkey( SDLK_ESCAPE );
288 Pause_continue.set_focus();
291 // debug pause do frame
292 void pause_debug_do()
296 key = Pause_win.process();
297 if ( Pause_single_step.changed()) {
298 game_single_step = Pause_single_step.checked();
301 if ( Pause_physics.changed()) {
302 physics_paused = Pause_physics.checked();
305 if ( Pause_ai.changed()) {
306 ai_paused = Pause_ai.checked();
308 obj_init_all_ships_physics();
312 if ( Pause_ai_render.changed()) {
313 Ai_render_debug_flag = Pause_ai_render.checked();
316 if ( Pause_firing.changed()) {
317 Ai_firing_enabled = Pause_firing.checked();
320 if ( Pause_external_view_mode_check.changed()) {
321 Pause_external_view_mode = Pause_external_view_mode_check.checked();
322 if (Pause_external_view_mode){
323 HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "External view of player ship.", 182));
325 HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "View from inside player ship.", 183));
329 if ( Pause_continue.pressed() || (key == SDLK_PAUSE) ) { // Changed, MK, 11/9/97, only Pause break pause.
330 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
340 void pause_debug_close()
342 last_single_step = 0; // Make so single step waits a frame before stepping