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"
61 #include "mainhallmenu.h"
63 // ----------------------------------------------------------------------------------------------------------------
68 const char *Pause_bmp_name[GR_NUM_RESOLUTIONS] = {
77 // pause bitmap display stuff
78 int Please_wait_coords[GR_NUM_RESOLUTIONS][4] = {
91 const char *Pause_multi_fname[GR_NUM_RESOLUTIONS] = {
95 const char *Pause_multi_mask[GR_NUM_RESOLUTIONS] = {
100 // pause window objects
102 UI_CHECKBOX Pause_single_step;
103 UI_CHECKBOX Pause_physics;
104 UI_CHECKBOX Pause_ai;
105 UI_CHECKBOX Pause_ai_render;
106 UI_CHECKBOX Pause_firing;
107 UI_CHECKBOX Pause_external_view_mode_check;
108 UI_BUTTON Pause_continue;
110 // if we're already paused
113 // background screen (for the chatbox)
114 int Pause_background_bitmap = -1;
116 // saved background screen
117 int Pause_saved_screen = -1;
119 // if we're in external vie wmode
120 int Pause_external_view_mode = 0;
123 extern int Player_attacking_enabled;
124 extern int Ai_render_debug_flag;
125 extern int Ai_firing_enabled;
126 extern int physics_paused;
127 extern int ai_paused;
128 extern int last_single_step;
129 extern int game_single_step;
131 // ----------------------------------------------------------------------------------------------------------------
135 // initialize the pause screen
136 void pause_init(int multi)
138 // if we're already paused. do nothing
143 // pause all beam weapon sounds
146 if(!(Game_mode & GM_STANDALONE_SERVER)){
147 Pause_saved_screen = gr_save_screen();
149 // pause all game music
150 audiostream_pause_all();
151 main_hall_stop_ambient();
153 //JAS: REMOVED CALL TO SET INTERFACE PALETTE TO GET RID OF SCREEN CLEAR WHEN PAUSING
154 //common_set_interface_palette(); // set the interface palette
155 Pause_win.create(0, 0, gr_screen.max_w, gr_screen.max_h, 0);
158 Pause_win.set_mask_bmap(Pause_multi_mask[gr_screen.res]);
159 Pause_background_bitmap = bm_load(Pause_multi_fname[gr_screen.res]);
161 multi_pause_init(&Pause_win);
163 Pause_background_bitmap = bm_load(Pause_bmp_name[gr_screen.res]);
166 multi_pause_init(NULL);
172 // pause do frame - will handle running multiplayer operations if necessary
173 void pause_do(int multi)
177 const char *pause_str = XSTR("Paused", 767);
181 if(Game_mode & GM_STANDALONE_SERVER){
184 // RENDER A GAME FRAME HERE AS THE BACKGROUND
185 gr_restore_screen(Pause_saved_screen);
186 if (Pause_background_bitmap >= 0) {
187 gr_set_bitmap(Pause_background_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
192 gr_bitmap(Please_wait_coords[gr_screen.res][0], Please_wait_coords[gr_screen.res][1]);
195 // draw "Paused" on it
196 gr_set_color_fast(&Color_normal);
198 gr_get_string_size(&str_w, &str_h, pause_str);
199 gr_string((gr_screen.max_w - str_w) / 2, (gr_screen.max_h - str_h) / 2, pause_str);
205 // the multi paused screen will do its own window processing
209 // otherwise process the ui window here
211 k = Pause_win.process() & ~KEY_DEBUGGED;
215 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
220 // draw the background window
223 // a very unique case where we shouldn't be doing the page flip because we're inside of popup code
227 // this should only be happening in a very unique multiplayer case
228 SDL_assert(Game_mode & GM_MULTIPLAYER);
233 // close the pause screen
234 void pause_close(int multi)
236 // if we're not paused - do nothing
241 // unpause all beam weapon sounds
242 beam_unpause_sounds();
245 if(Game_mode & GM_STANDALONE_SERVER){
248 gr_free_screen(Pause_saved_screen);
250 if (Pause_background_bitmap){
251 bm_unload(Pause_background_bitmap);
260 // unpause all the music
261 audiostream_unpause_all();
268 void pause_debug_init()
270 Pause_win.create( 100,100,400,300, WIN_DIALOG );
272 Pause_physics.create( &Pause_win, NOX("Physics Pause <P>"), 200, 150, physics_paused );
273 Pause_ai.create( &Pause_win, NOX("AI Pause <A>"), 200, 175, ai_paused );
275 Pause_ai_render.create( &Pause_win, NOX("AI Render Stuff <R>"), 200, 200, Ai_render_debug_flag);
277 Pause_firing.create( &Pause_win, NOX("AI firing <F>"), 200, 225, Ai_firing_enabled);
278 Pause_external_view_mode_check.create( &Pause_win, NOX("External View <E>"), 200, 250, Pause_external_view_mode);
279 Pause_single_step.create( &Pause_win, NOX("Single Step <S>"), 200, 290, game_single_step );
280 Pause_continue.create( &Pause_win, NOX("Leave Pause"), 200, 350, 200, 40 );
282 Pause_single_step.set_hotkey( SDLK_s );
283 Pause_physics.set_hotkey( SDLK_p );
284 Pause_ai.set_hotkey( SDLK_a );
285 Pause_ai_render.set_hotkey( SDLK_r );
286 Pause_firing.set_hotkey( SDLK_f );
287 Pause_external_view_mode_check.set_hotkey( SDLK_e );
288 Pause_continue.set_hotkey( SDLK_ESCAPE );
290 Pause_continue.set_focus();
293 // debug pause do frame
294 void pause_debug_do()
298 key = Pause_win.process();
299 if ( Pause_single_step.changed()) {
300 game_single_step = Pause_single_step.checked();
303 if ( Pause_physics.changed()) {
304 physics_paused = Pause_physics.checked();
307 if ( Pause_ai.changed()) {
308 ai_paused = Pause_ai.checked();
310 obj_init_all_ships_physics();
314 if ( Pause_ai_render.changed()) {
315 Ai_render_debug_flag = Pause_ai_render.checked();
318 if ( Pause_firing.changed()) {
319 Ai_firing_enabled = Pause_firing.checked();
322 if ( Pause_external_view_mode_check.changed()) {
323 Pause_external_view_mode = Pause_external_view_mode_check.checked();
324 if (Pause_external_view_mode){
325 HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "External view of player ship.", 182));
327 HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "View from inside player ship.", 183));
331 if ( Pause_continue.pressed() || (key == SDLK_PAUSE) ) { // Changed, MK, 11/9/97, only Pause break pause.
332 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
342 void pause_debug_close()
344 last_single_step = 0; // Make so single step waits a frame before stepping