// run the popup in a tight loop (no states) void multi_pinfo_popup_do() { int k; // if there was an error in initialization, return immediately if (Multi_pinfo_popup_error) { return; } // tight loop while (!Multi_pinfo_popup_done) { multi_pinfo_maybe_reload_pic(&Mp_pilot); multi_pinfo_maybe_reload_pic(&Mp_squad); // process the window k = Multi_pinfo_window.process(); switch (k) { case KEY_ESC : Multi_pinfo_popup_done = 1; break; } // check button presses multi_pinfo_popup_check_buttons(); // set frametime and run background stuff game_set_frametime(-1); game_do_state_common(gameseq_get_state()); // draw the background bitmap and the ui window over it Assert(Multi_pinfo_screen_save != -1); gr_reset_clip(); gr_restore_screen(Multi_pinfo_screen_save); // grey the screen gr_set_shader(&Grey_shader); gr_shade(0, 0, gr_screen.clip_width, gr_screen.clip_height, false); // draw the background bitmap gr_set_bitmap(Multi_pinfo_bitmap); gr_bitmap(0, 0); // blit the selected pilot image multi_pinfo_blit_pilot_image(); // blit the squadron logo multi_pinfo_blit_squadron_logo(); // blit the player statistics multi_pinfo_blit_player_stats(); // draw the ui window and flip Multi_pinfo_window.draw(); gr_flip(); } }
int popup_do_with_condition(popup_info *pi, int flags, int(*condition)()) { int screen_id, choice = -1, done = 0; int test; screen_id = gr_save_screen(); if ( popup_init(pi, flags) == -1 ) return -1; int old_max_w_unscaled = gr_screen.max_w_unscaled; int old_max_h_unscaled = gr_screen.max_h_unscaled; int old_max_w_unscaled_zoomed = gr_screen.max_w_unscaled_zoomed; int old_max_h_unscaled_zoomed = gr_screen.max_h_unscaled_zoomed; gr_reset_screen_scale(); while(!done) { int k; os_poll(); game_set_frametime(-1); game_do_state_common(gameseq_get_state()); // do stuff common to all states gr_restore_screen(screen_id); // draw one frame first Popup_window.draw(); popup_force_draw_buttons(pi); popup_draw_msg_text(pi, flags); popup_draw_button_text(pi, flags); gr_flip(); // test the condition function or process for the window if ((test = condition()) > 0) { done = 1; choice = test; } else { k = Popup_window.process(); // poll for input, handle mouse choice = popup_process_keys(pi, k, flags); if ( choice != POPUP_NOCHANGE ) { done=1; } if ( !done ) { choice = popup_check_buttons(pi); if ( choice != POPUP_NOCHANGE ) { done=1; } } } } gr_set_screen_scale(old_max_w_unscaled, old_max_h_unscaled, old_max_w_unscaled_zoomed, old_max_h_unscaled_zoomed); popup_close(pi,screen_id); return choice; }
// exit: -1 => error // 0..nchoices-1 => choice int popup_do(popup_info *pi, int flags) { int screen_id, choice = -1, done = 0; if ( popup_init(pi, flags) == -1 ){ return -1; } screen_id = gr_save_screen(); int old_max_w_unscaled = gr_screen.max_w_unscaled; int old_max_h_unscaled = gr_screen.max_h_unscaled; int old_max_w_unscaled_zoomed = gr_screen.max_w_unscaled_zoomed; int old_max_h_unscaled_zoomed = gr_screen.max_h_unscaled_zoomed; gr_reset_screen_scale(); while(!done) { int k; os_poll(); // if we were killed by a call to popup_kill_any_active(), kill the popup if(Popup_should_die){ choice = -1; break; } // if we're flagged as should be running the state underneath, then do so if(flags & PF_RUN_STATE){ game_do_state(gameseq_get_state()); } // otherwise just run the common functions (for networking,etc) else { game_set_frametime(-1); game_do_state_common(gameseq_get_state(),flags & PF_NO_NETWORKING); // do stuff common to all states } k = Popup_window.process(); // poll for input, handle mouse choice = popup_process_keys(pi, k, flags); if ( choice != POPUP_NOCHANGE ) { done=1; } if ( !done ) { choice = popup_check_buttons(pi); if ( choice != POPUP_NOCHANGE ) { done=1; } } // don't draw anything if(!(flags & PF_RUN_STATE)){ gr_restore_screen(screen_id); } // if this is an input popup, store the input text if(flags & PF_INPUT){ Popup_input.get_text(pi->input_text); } Popup_window.draw(); popup_force_draw_buttons(pi); popup_draw_msg_text(pi, flags); popup_draw_button_text(pi, flags); gr_flip(); } gr_set_screen_scale(old_max_w_unscaled, old_max_h_unscaled, old_max_w_unscaled_zoomed, old_max_h_unscaled_zoomed); popup_close(pi,screen_id); return choice; }
// pause do frame - will handle running multiplayer operations if necessary void pause_do() { int k; const char *pause_str = XSTR("Paused", 767); int str_w, str_h; // next two are for view resetting static int previous_Viewer_mode = -1; static int previous_hud_state = -1; Assert( !(Game_mode & GM_MULTIPLAYER) ); // RENDER A GAME FRAME HERE AS THE BACKGROUND (if normal pause) if(Pause_type == PAUSE_TYPE_NORMAL) { // Fall back to viewer just incase saved screen is invalid if(Pause_saved_screen == -1){ Pause_type = PAUSE_TYPE_VIEWER; } else if(Pause_type == PAUSE_TYPE_NORMAL) { gr_restore_screen(Pause_saved_screen); } } if(Pause_type == PAUSE_TYPE_NORMAL){ if (Pause_background_bitmap >= 0) { gr_set_bitmap(Pause_background_bitmap); // draw the bitmap gr_bitmap(Please_wait_coords[gr_screen.res][0], Please_wait_coords[gr_screen.res][1], GR_RESIZE_MENU); // draw "Paused" on it gr_set_color_fast(&Color_normal); gr_set_font(FONT2); gr_get_string_size(&str_w, &str_h, pause_str); gr_string((gr_screen.max_w_unscaled - str_w) / 2, (gr_screen.max_h_unscaled - str_h) / 2, pause_str, GR_RESIZE_MENU); gr_set_font(FONT1); } } if (Pause_type == PAUSE_TYPE_VIEWER) { if (previous_Viewer_mode < 0) previous_Viewer_mode = Viewer_mode; if (previous_hud_state < 0) previous_hud_state = hud_disabled(); } // process the ui window here k = Pause_win.process() & ~KEY_DEBUGGED; switch (k) { case KEY_TAB: hud_toggle_draw(); break; // view from outside of the ship case KEY_ENTER: if (Pause_type == PAUSE_TYPE_VIEWER) { button_function_demo_valid(VIEW_EXTERNAL); } break; // view from target case KEY_PADDIVIDE: if (Pause_type == PAUSE_TYPE_VIEWER) { button_function_demo_valid(VIEW_OTHER_SHIP); } break; // change target case KEY_PADMULTIPLY: if (Pause_type == PAUSE_TYPE_VIEWER) { button_function(TARGET_NEXT); } break; case KEY_ESC: case KEY_ALTED + KEY_PAUSE: case KEY_PAUSE: // reset previous view if we happened to be playing around with it during pause if (Pause_type == PAUSE_TYPE_VIEWER) { if (previous_Viewer_mode >= 0) { Viewer_mode = previous_Viewer_mode; } // NOTE remember that hud state is reversed here (0 == on, 1 == off) if ( (previous_hud_state >= 0) && (hud_disabled() != previous_hud_state) ) { hud_set_draw( !previous_hud_state ); } } gameseq_post_event(GS_EVENT_PREVIOUS_STATE); break; } // end switch // draw the background window Pause_win.draw(); // a very unique case where we shouldn't be doing the page flip because we're inside of popup code if(!popup_active()){ if(Pause_type == PAUSE_TYPE_NORMAL) { gr_flip(); } } else { // this should only be happening in a very unique multiplayer case Int3(); } }
void multi_pause_do() { int k; // make sure we don't enter this state unless we're in the mission itself Netgame.game_state = NETGAME_STATE_PAUSED; // server of the game should periodically be sending pause packets for good measure if (Net_player->flags & NETINFO_FLAG_AM_MASTER) { } if (!(Game_mode & GM_STANDALONE_SERVER)) { // restore saved screen data if any if (Multi_paused_screen_id >= 0) { gr_restore_screen(Multi_paused_screen_id); } // set the background image if (Multi_paused_background >= 0) { gr_set_bitmap(Multi_paused_background); gr_bitmap(0, 0, GR_RESIZE_MENU); } // if we're inside of popup code right now, don't process the window if(!popup_active()){ // process chatbox and window stuff k = chatbox_process(); k = Multi_paused_window.process(k); switch (k) { case KEY_ESC: case KEY_PAUSE: multi_pause_request(0); break; } } // check for any button presses multi_pause_check_buttons(); // render the callsign of the guy who paused multi_pause_render_callsign(); // render the chatbox chatbox_render(); // draw tooltips // Multi_paused_window.draw_tooltip(); Multi_paused_window.draw(); // display the voice status indicator multi_common_voice_display_status(); // don't flip screen if we are in the popup code right now if (!popup_active()) { gr_flip(); } } // standalone pretty much does nothing here else { os_sleep(1); } }