// render the chatbox for this frame void chatbox_render() { if (!Chatbox_created){ return; } // clear the multiplayer chat window // gr_set_clip(Chatbox_x1, Chatbox_y1, Chatbox_w, Chatbox_h, GR_RESIZE_MENU); // gr_clear(); // gr_reset_clip(); // draw the background bitmap if we're supposed to if ( (Chatbox_bitmap != -1) && (Chatbox_mode_flags & CHATBOX_FLAG_DRAW_BOX)) { gr_set_bitmap( Chatbox_bitmap ); gr_bitmap(Chatbox_x1, Chatbox_y1, GR_RESIZE_MENU); } // render the chat lines chatbox_render_chat_lines(); // render any UI window stuff Chat_window.draw(); }
// Called once when the red alert interface is exited void red_alert_close() { if (Red_alert_inited) { red_alert_voice_stop(); red_alert_voice_unload(); weapon_select_close_team(); if (Background_bitmap >= 0) { bm_release(Background_bitmap); } Ui_window.destroy(); // bm_unload(&Flash_anim); common_free_interface_palette(); // restore game palette game_flush(); } Red_alert_inited = 0; fsspeech_stop(); }
// debug pause init void pause_debug_init() { Pause_win.create( 100,100,400,300, WIN_DIALOG ); Pause_physics.create( &Pause_win, NOX("Physics Pause <P>"), 200, 150, physics_paused ); Pause_ai.create( &Pause_win, NOX("AI Pause <A>"), 200, 175, ai_paused ); #ifndef NDEBUG Pause_ai_render.create( &Pause_win, NOX("AI Render Stuff <R>"), 200, 200, Ai_render_debug_flag); #endif Pause_firing.create( &Pause_win, NOX("AI firing <F>"), 200, 225, Ai_firing_enabled); Pause_external_view_mode_check.create( &Pause_win, NOX("External View <E>"), 200, 250, Pause_external_view_mode); Pause_single_step.create( &Pause_win, NOX("Single Step <S>"), 200, 290, game_single_step ); Pause_continue.create( &Pause_win, NOX("Leave Pause"), 200, 350, 200, 40 ); Pause_single_step.set_hotkey( KEY_S ); Pause_physics.set_hotkey( KEY_P ); Pause_ai.set_hotkey( KEY_A ); Pause_ai_render.set_hotkey( KEY_R ); Pause_firing.set_hotkey( KEY_F ); Pause_external_view_mode_check.set_hotkey( KEY_E ); Pause_continue.set_hotkey( KEY_ESC ); Pause_continue.set_focus(); }
// ----------------------------------------------------------------------------- void barracks_close() { // destroy window Ui_window.destroy(); // release background bitmap if (Background_bitmap >= 0) { bm_release(Background_bitmap); } // release rank pip bitmaps bm_release(Rank_pips_bitmaps); // release pilot pic bitmaps for (int i=0; i<Num_pilot_images; i++) { if (Pilot_images[i] >= 0) { bm_release(Pilot_images[i]); } } // unload the overlay bitmap help_overlay_unload(BARRACKS_OVERLAY); if(Stat_labels != NULL) { delete[] Stat_labels; Stat_labels = NULL; } if(Stats != NULL) { delete[] Stats; Stats = NULL; } game_flush(); }
void player_select_do() { int k; // Goober5000 - display a popup warning about problems in the mod if ((Global_warning_count > 10 || Global_error_count > 0) && !Startup_warning_dialog_displayed) { char text[512]; sprintf(text, "Warning!\n\nThe currently active mod has generated %d warnings and/or errors during program startup. These could have been caused by anything from incorrectly formated table files to corrupt models. While FreeSpace Open will attempt to compensate for these issues, it cannot guarantee a trouble-free gameplay experience. Source Code Project staff cannot provide assistance or support for these problems, as they are caused by the mod's data files, not FreeSpace Open's source code.", Global_warning_count + Global_error_count); popup(PF_TITLE_BIG | PF_TITLE_RED | PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, text); Startup_warning_dialog_displayed = true; } // set the input box at the "virtual" line 0 to be active so the player can enter a callsign if (Player_select_input_mode) { Player_select_input_box.set_focus(); } // process any ui window stuff k = Player_select_window.process(); if (k) { extern void game_process_cheats(int k); game_process_cheats(k); } switch (k) { // switch between single and multiplayer modes case KEY_TAB: { if (Player_select_input_mode) { gamesnd_play_iface(SND_GENERAL_FAIL); break; } // play a little sound gamesnd_play_iface(SND_USER_SELECT); if (Player_select_mode == PLAYER_SELECT_MODE_MULTI) { player_select_set_bottom_text(XSTR( "Single-Player Mode", 376)); // reinitialize as single player mode player_select_init_player_stuff(PLAYER_SELECT_MODE_SINGLE); } else if (Player_select_mode == PLAYER_SELECT_MODE_SINGLE) { player_select_set_bottom_text(XSTR( "Multiplayer Mode", 377)); // reinitialize as multiplayer mode player_select_init_player_stuff(PLAYER_SELECT_MODE_MULTI); } break; } case KEY_ESC: { // we can hit ESC to get out of text input mode, and we don't want // to set this var in that case since it will crash on a NULL Player // ptr when going to the mainhall if ( !Player_select_input_mode ) { Player_select_no_save_pilot = 1; } break; } } // draw the player select pseudo-dialog over it GR_MAYBE_CLEAR_RES(Player_select_background_bitmap); gr_set_bitmap(Player_select_background_bitmap); gr_bitmap(0,0,GR_RESIZE_MENU); // press the accept button if (Player_select_autoaccept) { Player_select_buttons[gr_screen.res][ACCEPT_BUTTON].button.press_button(); } // draw any ui window stuf Player_select_window.draw(); // light up the correct mode button (single or multi) if (Player_select_mode == PLAYER_SELECT_MODE_SINGLE) { Player_select_buttons[gr_screen.res][SINGLE_BUTTON].button.draw_forced(2); } else { Player_select_buttons[gr_screen.res][MULTI_BUTTON].button.draw_forced(2); } // draw the pilot list text player_select_draw_list(); // draw copyright message on the bottom on the screen player_select_display_copyright(); if (!Player_select_input_mode) { player_select_process_noninput(k); } else { player_select_process_input(k); } // draw any pending messages on the bottom or middle of the screen player_select_display_all_text(); gr_flip(); }
void mht_do() { int k = Mht_window.process(); // need to ensure ambient is playing, since it may be stopped by a playing movie main_hall_start_ambient(); // process any keypresses switch(k){ case KEY_ESC : mht_exit_game(); break; case KEY_B: gameseq_post_event( GS_EVENT_BARRACKS_MENU ); break; case KEY_G: if(Player->flags & PLAYER_FLAGS_IS_MULTI){ break; } if (Num_recent_missions > 0) { strcpy_s( Game_current_mission_filename, Recent_missions[0] ); } else { mission_load_up_campaign(); strcpy_s( Game_current_mission_filename, Campaign.missions[0].name ); } Campaign.current_mission = -1; gameseq_post_event(GS_EVENT_START_GAME_QUICK); break; case KEY_L: gameseq_post_event( GS_EVENT_LOAD_MISSION_MENU ); break; case KEY_F2: gameseq_post_event(GS_EVENT_OPTIONS_MENU); break; case KEY_M: if (Player->flags & PLAYER_FLAGS_IS_MULTI){ main_hall_do_multi_ready(); } break; } // process button presses mht_check_buttons(); // draw the background, etc gr_reset_clip(); GR_MAYBE_CLEAR_RES(Mht_bitmap); if(Mht_bitmap != -1){ gr_set_bitmap(Mht_bitmap); gr_bitmap(0,0,GR_RESIZE_MENU); } Mht_window.draw(); // flip the buffer gr_flip(); }
// functions for selecting single/multiplayer pilots at the very beginning of FreeSpace void player_select_init() { int i; barracks_buttons *b; UI_WINDOW *w; // start a looping ambient sound main_hall_start_ambient(); Player_select_force_main_hall = ""; Player_select_screen_active = 1; // create the UI window Player_select_window.create(0, 0, gr_screen.max_w_unscaled, gr_screen.max_h_unscaled, 0); Player_select_window.set_mask_bmap(Player_select_background_mask_bitmap[gr_screen.res]); // initialize the control buttons for (i=0; i<NUM_PLAYER_SELECT_BUTTONS; i++) { b = &Player_select_buttons[gr_screen.res][i]; // create the button b->button.create(&Player_select_window, NULL, b->x, b->y, 60, 30, 1, 1); // set its highlight action b->button.set_highlight_action(common_play_highlight_sound); // set its animation bitmaps b->button.set_bmaps(b->filename); // link the mask hotspot b->button.link_hotspot(b->hotspot); } // add some text w = &Player_select_window; w->add_XSTR("Create", 1034, Player_select_buttons[gr_screen.res][CREATE_PILOT_BUTTON].xt, Player_select_buttons[gr_screen.res][CREATE_PILOT_BUTTON].yt, &Player_select_buttons[gr_screen.res][CREATE_PILOT_BUTTON].button, UI_XSTR_COLOR_GREEN); w->add_XSTR("Clone", 1040, Player_select_buttons[gr_screen.res][CLONE_BUTTON].xt, Player_select_buttons[gr_screen.res][CLONE_BUTTON].yt, &Player_select_buttons[gr_screen.res][CLONE_BUTTON].button, UI_XSTR_COLOR_GREEN); w->add_XSTR("Remove", 1038, Player_select_buttons[gr_screen.res][DELETE_BUTTON].xt, Player_select_buttons[gr_screen.res][DELETE_BUTTON].yt, &Player_select_buttons[gr_screen.res][DELETE_BUTTON].button, UI_XSTR_COLOR_GREEN); w->add_XSTR("Select", 1039, Player_select_buttons[gr_screen.res][ACCEPT_BUTTON].xt, Player_select_buttons[gr_screen.res][ACCEPT_BUTTON].yt, &Player_select_buttons[gr_screen.res][ACCEPT_BUTTON].button, UI_XSTR_COLOR_PINK); w->add_XSTR("Single", 1041, Player_select_buttons[gr_screen.res][SINGLE_BUTTON].xt, Player_select_buttons[gr_screen.res][SINGLE_BUTTON].yt, &Player_select_buttons[gr_screen.res][SINGLE_BUTTON].button, UI_XSTR_COLOR_GREEN); w->add_XSTR("Multi", 1042, Player_select_buttons[gr_screen.res][MULTI_BUTTON].xt, Player_select_buttons[gr_screen.res][MULTI_BUTTON].yt, &Player_select_buttons[gr_screen.res][MULTI_BUTTON].button, UI_XSTR_COLOR_GREEN); for(i=0; i<PLAYER_SELECT_NUM_TEXT; i++) { w->add_XSTR(&Player_select_text[gr_screen.res][i]); } // create the list button text select region Player_select_list_region.create(&Player_select_window, "", Choose_list_coords[gr_screen.res][0], Choose_list_coords[gr_screen.res][1], Choose_list_coords[gr_screen.res][2], Choose_list_coords[gr_screen.res][3], 0, 1); Player_select_list_region.hide(); // create the pilot callsign input box Player_select_input_box.create(&Player_select_window, Choose_list_coords[gr_screen.res][0], Choose_list_coords[gr_screen.res][1], Choose_list_coords[gr_screen.res][2] , CALLSIGN_LEN - 1, "", UI_INPUTBOX_FLAG_INVIS | UI_INPUTBOX_FLAG_KEYTHRU | UI_INPUTBOX_FLAG_LETTER_FIRST); Player_select_input_box.set_valid_chars(VALID_PILOT_CHARS); Player_select_input_box.hide(); Player_select_input_box.disable(); // not currently entering any text Player_select_input_mode = 0; // set up hotkeys for buttons so we draw the correct animation frame when a key is pressed Player_select_buttons[gr_screen.res][SCROLL_LIST_UP_BUTTON].button.set_hotkey(KEY_UP); Player_select_buttons[gr_screen.res][SCROLL_LIST_DOWN_BUTTON].button.set_hotkey(KEY_DOWN); Player_select_buttons[gr_screen.res][ACCEPT_BUTTON].button.set_hotkey(KEY_ENTER); Player_select_buttons[gr_screen.res][CREATE_PILOT_BUTTON].button.set_hotkey(KEY_C); // attempt to load in the background bitmap Player_select_background_bitmap = bm_load(Player_select_background_bitmap_name[gr_screen.res]); Assert(Player_select_background_bitmap >= 0); // load in the palette for the screen // Player_select_palette = bm_load(PLAYER_SELECT_PALETTE); // Player_select_palette_set = 0; // unset the very first pilot data Player_select_very_first_pilot = 0; Player_select_initial_count = -1; memset(Player_select_very_first_pilot_callsign, 0, CALLSIGN_LEN + 2); // if(Player_select_num_pilots == 0){ // Player_select_autoaccept = 1; // } // if we found a pilot if ( player_select_get_last_pilot_info() ) { if (Player_select_last_is_multi && !Networking_disabled) { player_select_init_player_stuff(PLAYER_SELECT_MODE_MULTI); } else { player_select_init_player_stuff(PLAYER_SELECT_MODE_SINGLE); } } else { // otherwise go to the single player mode by default player_select_init_player_stuff(PLAYER_SELECT_MODE_SINGLE); } if ( (Player_select_num_pilots == 1) && Player_select_input_mode ) { Player_select_autoaccept = 1; } }
// ----------------------------------------------------------------------------- void barracks_do_frame(float frametime) { int k = Ui_window.process(); if ( k > 0 ) { if ( help_overlay_active(Barracks_overlay_id) ) { help_overlay_set_state(Barracks_overlay_id,gr_screen.res,0); k = 0; } } // pilot that mouse is over int prospective_pilot = -1; int i; // Entering pilot callsign if (Barracks_callsign_enter_mode) { // set focus to inputbox Inputbox.set_focus(); switch (k) { case KEY_ESC: // cancel create pilot Num_pilots--; for (i=0; i<Num_pilots; i++) { strcpy(Pilots[i], Pilots[i + 1]); Pilot_ranks[i] = Pilot_ranks[i + 1]; } barracks_set_callsign_enter_mode(false); break; case KEY_ENTER: barracks_accept_new_pilot_callsign(); break; } } else { // not entering pilot callsign switch (k) { case KEY_ENTER: if (barracks_new_pilot_selected()) { gamesnd_play_iface(SND_GENERAL_FAIL); } else { gamesnd_play_iface(SND_USER_SELECT); } break; case KEY_ESC: // cancel if (!help_overlay_active(Barracks_overlay_id)) { if (Num_pilots && !barracks_pilot_accepted()) { gameseq_post_event(GS_EVENT_MAIN_MENU); } else { gamesnd_play_iface(SND_GENERAL_FAIL); } } else { // kill the overlay help_overlay_set_state(Barracks_overlay_id,gr_screen.res,0); } break; case KEY_TAB: // switch mode (simgle/multi) if ( Networking_disabled ) { game_feature_disabled_popup(); break; } if (Player_sel_mode == PLAYER_SELECT_MODE_SINGLE) { Cur_pilot->flags |= PLAYER_FLAGS_IS_MULTI; Pilot.save_player(Cur_pilot); barracks_init_player_stuff(PLAYER_SELECT_MODE_MULTI); } else { // make sure we don't carry over the multi flag Cur_pilot->flags &= ~PLAYER_FLAGS_IS_MULTI; Pilot.save_player(Cur_pilot); barracks_init_player_stuff(PLAYER_SELECT_MODE_SINGLE); } gamesnd_play_iface(SND_USER_SELECT); break; case KEY_F1: // show help overlay gamesnd_play_iface(SND_HELP_PRESSED); break; case KEY_F2: // goto options screen gamesnd_play_iface(SND_SWITCH_SCREENS); gameseq_post_event(GS_EVENT_OPTIONS_MENU); break; } // end switch // process buttons for (i=0; i<BARRACKS_NUM_BUTTONS; i++) { if (Buttons[gr_screen.res][i].button.pressed()) { barracks_button_pressed(i); } } // if mouse is over a pilot, find index into Pilots array if (List_region.is_mouse_on()) { int y; List_region.get_mouse_pos(NULL, &y); int pilot_index = List_scroll_offset + (y / gr_get_font_height()); if ((pilot_index >= 0) && (pilot_index < Num_pilots)) { prospective_pilot = pilot_index; } } // if mouse clicked in list region, find index into Pilots array if (List_region.pressed()) { if (prospective_pilot != -1) { Selected_line = prospective_pilot; gamesnd_play_iface(SND_USER_SELECT); } } } // check mouse over help if (mouse_down(MOUSE_LEFT_BUTTON)) { help_overlay_set_state(Barracks_overlay_id, gr_screen.res, 0); } // do pilot pic stuff if ((Pic_number >= 0) && (Pic_number < Num_pilot_images)) { if (Pilot_images[Pic_number] == BARRACKS_IMAGE_NOT_LOADED) { // haven't tried loading it yet Pilot_images[Pic_number] = bm_load(Pilot_image_names[Pic_number]); if (Pilot_images[Pic_number] >= 0) { int w, h; bm_get_info(Pilot_images[Pic_number], &w, &h, NULL); // check for invalid pilot pic file if ((w != PLAYER_PILOT_PIC_W) || (h != PLAYER_PILOT_PIC_H)) { bm_release(Pilot_images[Pic_number]); Pilot_images[Pic_number] = -1; } } } } else { Pic_number = -1; } // do squad pic stuff if ((Pic_squad_number >= 0) && (Pic_squad_number < Num_pilot_squad_images)) { if (Pilot_squad_images[Pic_squad_number] == BARRACKS_IMAGE_NOT_LOADED) { // haven't tried loading it yet Pilot_squad_images[Pic_squad_number] = bm_load_duplicate(Pilot_squad_image_names[Pic_squad_number]); if (Pilot_squad_images[Pic_squad_number] >= 0) { int w, h; bm_get_info(Pilot_squad_images[Pic_squad_number], &w, &h, NULL); // check for invalid pilot pic file if ((w != PLAYER_SQUAD_PIC_W) || (h != PLAYER_SQUAD_PIC_H)) { bm_release(Pilot_squad_images[Pic_squad_number]); Pilot_squad_images[Pic_squad_number] = -1; } } } } else { Pic_squad_number = -1; } // draw the background, etc gr_reset_clip(); GR_MAYBE_CLEAR_RES(Background_bitmap); if (Background_bitmap >= 0) { gr_set_bitmap(Background_bitmap); gr_bitmap(0, 0, GR_RESIZE_MENU); } // draw pilot image and clean up afterwards barracks_draw_pilot_pic(); barracks_draw_squad_pic(); // draw the window Ui_window.draw(); // light up the correct mode button (single or multi) if (Player_sel_mode == PLAYER_SELECT_MODE_SINGLE) { Buttons[gr_screen.res][B_PILOT_SINGLE_MODE_BUTTON].button.draw_forced(2); } else { Buttons[gr_screen.res][B_PILOT_MULTI_MODE_BUTTON].button.draw_forced(2); } // write out pilot call signs barracks_display_pilot_callsigns(prospective_pilot); // write out current pilot stats barracks_display_pilot_stats(); // blit help overlay if active help_overlay_maybe_blit(Barracks_overlay_id, gr_screen.res); // flip the page gr_flip(); }
// debug pause close void pause_debug_close() { last_single_step = 0; // Make so single step waits a frame before stepping Pause_win.destroy(); game_flush(); }
void techroom_do_frame(float frametime) { int i, k; // turn off controls when overlay is on if ( help_overlay_active(Techroom_overlay_id) ) { Buttons[gr_screen.res][HELP_BUTTON].button.reset_status(); Ui_window.set_ignore_gadgets(1); } // turn off controls in trackball mode if (Trackball_active) { Ui_window.set_ignore_gadgets(1); } else { Ui_window.set_ignore_gadgets(0); } k = Ui_window.process() & ~KEY_DEBUGGED; if ( (k > 0) || B1_JUST_RELEASED ) { if ( help_overlay_active(Techroom_overlay_id) ) { help_overlay_set_state(Techroom_overlay_id, gr_screen.res, 0); Ui_window.set_ignore_gadgets(0); k = 0; } } if ( !help_overlay_active(Techroom_overlay_id) ) { Ui_window.set_ignore_gadgets(0); } switch (k) { case KEY_SHIFTED | KEY_TAB: // activate previous tab i = Tab - 1; if (i < 0) { i = NUM_TABS - 1; } techroom_change_tab(i); break; case KEY_TAB: // activate next tab i = Tab + 1; if (i >= NUM_TABS) { i = 0; } techroom_change_tab(i); break; case KEY_CTRLED | KEY_DOWN: if ( !(Player->flags & PLAYER_FLAGS_IS_MULTI) ) { techroom_button_pressed(SIMULATOR_TAB); break; } // fall through case KEY_CTRLED | KEY_UP: techroom_button_pressed(CREDITS_TAB); break; case KEY_CTRLED | KEY_ENTER: case KEY_ESC: gameseq_post_event(GS_EVENT_MAIN_MENU); break; case KEY_CTRLED | KEY_SHIFTED | KEY_S: Techroom_show_all = 1; techroom_lists_reset(); techroom_change_tab(Tab); break; } // check ship model window for activity if (View_window.pressed()) { Trackball_active = 1; Trackball_mode = 1; } if (B1_RELEASED) { Trackball_active = 0; } // check all da buttons for (i=0; i<NUM_BUTTONS; i++) { if (Buttons[gr_screen.res][i].button.pressed()) { if (techroom_button_pressed(i)) { return; } } } // check for mouseovers/clicks on the selection list Select_tease_line = -1; for (i=0; i<LIST_BUTTONS_MAX; i++) { if (List_buttons[i].is_mouse_on()) { Select_tease_line = i + List_offset; } if (List_buttons[i].pressed()) { Cur_entry = i + List_offset; gamesnd_play_iface(SND_USER_SELECT); techroom_select_new_entry(); } } // clear & draw bg bitmap GR_MAYBE_CLEAR_RES(Tech_background_bitmap); if (Tech_background_bitmap >= 0) { gr_set_bitmap(Tech_background_bitmap); gr_bitmap(0, 0, GR_RESIZE_MENU); } // render switch (Tab) { case SHIPS_DATA_TAB: techroom_ships_render(frametime); break; case WEAPONS_DATA_TAB: case INTEL_DATA_TAB: techroom_anim_render(frametime); break; } Ui_window.draw(); for (i=TECH_DATABASE_TAB; i<=CREDITS_TAB; i++) { if (Buttons[gr_screen.res][i].button.button_down()) { break; } } if (i > CREDITS_TAB) { Buttons[gr_screen.res][TECH_DATABASE_TAB].button.draw_forced(2); } for (i=0; i<NUM_TABS; i++){ if (Buttons[gr_screen.res][i].button.button_down()){ break; } } if (i == NUM_TABS){ Buttons[gr_screen.res][Tab].button.draw_forced(2); } // blit help overlay if active help_overlay_maybe_blit(Techroom_overlay_id, gr_screen.res); gr_flip(); }
void credits_do_frame(float frametime) { GR_DEBUG_SCOPE("Credits do frame"); int i, k, next, percent, bm1, bm2; int bx1, by1, bw1, bh1; int bx2, by2, bw2, bh2; // Use this id to trigger the start of music playing on the credits screen if ( timestamp_elapsed(Credits_music_begin_timestamp) ) { Credits_music_begin_timestamp = 0; credits_start_music(); } k = Ui_window.process(); switch (k) { case KEY_ESC: gameseq_post_event(GS_EVENT_MAIN_MENU); key_flush(); break; case KEY_CTRLED | KEY_UP: case KEY_SHIFTED | KEY_TAB: if ( !(Player->flags & PLAYER_FLAGS_IS_MULTI) ) { credits_screen_button_pressed(CUTSCENES_BUTTON); break; } // else, react like tab key. case KEY_CTRLED | KEY_DOWN: case KEY_TAB: credits_screen_button_pressed(TECH_DATABASE_BUTTON); break; default: break; } // end switch for (i=0; i<NUM_BUTTONS; i++){ if (Buttons[i][gr_screen.res].button.pressed()){ if (credits_screen_button_pressed(i)){ return; } } } gr_reset_clip(); GR_MAYBE_CLEAR_RES(Background_bitmap); if (Background_bitmap >= 0) { gr_set_bitmap(Background_bitmap); gr_bitmap(0, 0, GR_RESIZE_MENU); } percent = (int) (100.0f - (Credits_artwork_display_time - Credits_counter) * 100.0f / Credits_artwork_fade_time); if (percent < 0){ percent = 0; } next = Credits_artwork_index + 1; if (next >= Credits_num_images){ next = 0; } if (Credits_bmps[Credits_artwork_index] < 0) { char buf[40]; if (gr_screen.res == GR_1024) { sprintf(buf, NOX("2_CrIm%.2d"), Credits_artwork_index); } else { sprintf(buf, NOX("CrIm%.2d"), Credits_artwork_index); } Credits_bmps[Credits_artwork_index] = bm_load(buf); } if (Credits_bmps[next] < 0) { char buf[40]; if (gr_screen.res == GR_1024) { sprintf(buf, NOX("2_CrIm%.2d"), next); } else { sprintf(buf, NOX("CrIm%.2d"), next); } Credits_bmps[next] = bm_load(buf); } bm1 = Credits_bmps[Credits_artwork_index]; bm2 = Credits_bmps[next]; if((bm1 != -1) && (bm2 != -1)){ GR_DEBUG_SCOPE("Render credits bitmap"); Assert(percent >= 0 && percent <= 100); // get width and height bm_get_info(bm1, &bw1, &bh1, NULL, NULL, NULL); bm_get_info(bm2, &bw2, &bh2, NULL, NULL, NULL); // determine where to draw the coords bx1 = Credits_image_coords[gr_screen.res][CREDITS_X_COORD] + ((Credits_image_coords[gr_screen.res][CREDITS_W_COORD] - bw1)/2); by1 = Credits_image_coords[gr_screen.res][CREDITS_Y_COORD] + ((Credits_image_coords[gr_screen.res][CREDITS_H_COORD] - bh1)/2); bx2 = Credits_image_coords[gr_screen.res][CREDITS_X_COORD] + ((Credits_image_coords[gr_screen.res][CREDITS_W_COORD] - bw2)/2); by2 = Credits_image_coords[gr_screen.res][CREDITS_Y_COORD] + ((Credits_image_coords[gr_screen.res][CREDITS_H_COORD] - bh2)/2); auto alpha = (float)percent / 100.0f; gr_set_bitmap(bm1, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 1.0f - alpha); gr_bitmap(bx1, by1, GR_RESIZE_MENU); gr_set_bitmap(bm2, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, alpha); gr_bitmap(bx2, by2, GR_RESIZE_MENU); } Ui_window.draw(); for (i=TECH_DATABASE_BUTTON; i<=CREDITS_BUTTON; i++){ if (Buttons[i][gr_screen.res].button.button_down()){ break; } } if (i > CREDITS_BUTTON){ Buttons[CREDITS_BUTTON][gr_screen.res].button.draw_forced(2); } gr_set_clip(Credits_text_coords[gr_screen.res][CREDITS_X_COORD], Credits_text_coords[gr_screen.res][CREDITS_Y_COORD], Credits_text_coords[gr_screen.res][CREDITS_W_COORD], Credits_text_coords[gr_screen.res][CREDITS_H_COORD], GR_RESIZE_MENU); font::set_font(font::FONT1); gr_set_color_fast(&Color_normal); int y_offset = 0; for (SCP_vector<SCP_string>::iterator iter = Credit_text_parts.begin(); iter != Credit_text_parts.end(); ++iter) { size_t currentPos = 0; size_t lineEnd; do { int height; int width; lineEnd = iter->find('\n', currentPos); auto length = lineEnd - currentPos; if (lineEnd == SCP_string::npos) { length = std::numeric_limits<size_t>::max(); } gr_get_string_size(&width, &height, iter->c_str() + currentPos, static_cast<int>(length)); // Check if the text part is actually visible if (Credit_position + y_offset + height > 0.0f) { float x = static_cast<float>((gr_screen.clip_width_unscaled - width) / 2); gr_string(x, Credit_position + y_offset, iter->c_str() + currentPos, GR_RESIZE_MENU, static_cast<int>(length)); } y_offset += height; currentPos = lineEnd + 1; } while (lineEnd < iter->length() && lineEnd != SCP_string::npos); } int temp_time; temp_time = timer_get_milliseconds(); Credits_frametime = temp_time - Credits_last_time; Credits_last_time = temp_time; timestamp_inc(i2f(Credits_frametime) / TIMESTAMP_FREQUENCY); float fl_frametime = i2fl(Credits_frametime) / 1000.f; if (keyd_pressed[KEY_LSHIFT]) { Credit_position -= fl_frametime * Credits_scroll_rate * 4.0f; } else { Credit_position -= fl_frametime * Credits_scroll_rate; } if (Credit_position < Credit_stop_pos){ Credit_position = Credit_start_pos; } Credits_counter += fl_frametime; while (Credits_counter >= Credits_artwork_display_time) { Credits_counter -= Credits_artwork_display_time; Credits_artwork_index = next; } gr_flip(); }
// init void fiction_viewer_init() { if (Fiction_viewer_inited) return; // no fiction viewer? if (!mission_has_fiction()) return; // music common_music_init(SCORE_FICTION_VIEWER); // see if we have a background bitmap, and if so, which one // currently, we prioritize the UI that comes latest in the array; // in the future we might specify this in the mission or in a tbl for (Fiction_viewer_ui = NUM_FVW_SETTINGS - 1; Fiction_viewer_ui >= 0; Fiction_viewer_ui--) { // load the first available background bitmap Fiction_viewer_bitmap = bm_load(Fiction_viewer_screen_filename[Fiction_viewer_ui][gr_screen.res]); if (Fiction_viewer_bitmap >= 0) break; } // no ui is valid? if (Fiction_viewer_ui < 0) { Warning(LOCATION, "No fiction viewer graphics -- cannot display fiction viewer!"); return; } // set up fiction viewer font use_fv_font(); // calculate text area lines from font Fiction_viewer_text_max_lines = Fiction_viewer_text_coordinates[Fiction_viewer_ui][gr_screen.res][3] / gr_get_font_height(); // window Fiction_viewer_window.create(0, 0, gr_screen.max_w_unscaled, gr_screen.max_h_unscaled, 0, Fiction_viewer_fontnum); Fiction_viewer_window.set_mask_bmap(Fiction_viewer_screen_mask[Fiction_viewer_ui][gr_screen.res]); // add the buttons for (int i = 0; i < NUM_FVW_BUTTONS; i++) { int repeat = (i == FVW_BUTTON_SCROLL_UP || i == FVW_BUTTON_SCROLL_DOWN); ui_button_info *b = &Fiction_viewer_buttons[Fiction_viewer_ui][gr_screen.res][i]; b->button.create(&Fiction_viewer_window, "", b->x, b->y, b->xt, b->yt, repeat, 1); b->button.set_highlight_action(common_play_highlight_sound); b->button.set_bmaps(b->filename); b->button.link_hotspot(b->hotspot); } // set up hotkeys for buttons Fiction_viewer_buttons[Fiction_viewer_ui][gr_screen.res][FVW_BUTTON_ACCEPT].button.set_hotkey(KEY_CTRLED | KEY_ENTER); Fiction_viewer_buttons[Fiction_viewer_ui][gr_screen.res][FVW_BUTTON_SCROLL_UP].button.set_hotkey(KEY_UP); Fiction_viewer_buttons[Fiction_viewer_ui][gr_screen.res][FVW_BUTTON_SCROLL_DOWN].button.set_hotkey(KEY_DOWN); // init brief text brief_color_text_init(Fiction_viewer_text, Fiction_viewer_text_coordinates[Fiction_viewer_ui][gr_screen.res][2], default_fiction_viewer_color, 0, 0); // if the story is going to overflow the screen, add a slider if (Num_brief_text_lines[0] > Fiction_viewer_text_max_lines) { Fiction_viewer_slider.create(&Fiction_viewer_window, Fiction_viewer_slider_coordinates[Fiction_viewer_ui][gr_screen.res][0], Fiction_viewer_slider_coordinates[Fiction_viewer_ui][gr_screen.res][1], Fiction_viewer_slider_coordinates[Fiction_viewer_ui][gr_screen.res][2], Fiction_viewer_slider_coordinates[Fiction_viewer_ui][gr_screen.res][3], Num_brief_text_lines[0] - Fiction_viewer_text_max_lines, Fiction_viewer_slider_filename[Fiction_viewer_ui][gr_screen.res], &fiction_viewer_scroll_up, &fiction_viewer_scroll_down, &fiction_viewer_scroll_capture); } if (Fiction_viewer_voice >= 0) { audiostream_play(Fiction_viewer_voice, Master_voice_volume, 0); } Fiction_viewer_inited = 1; }
// do void fiction_viewer_do_frame(float frametime) { int i, k, w, h; // make sure we exist if (!Fiction_viewer_inited) { fiction_viewer_exit(); return; } // process keys k = Fiction_viewer_window.process() & ~KEY_DEBUGGED; switch (k) { case KEY_ESC: common_music_close(); gameseq_post_event(GS_EVENT_MAIN_MENU); return; } // process button presses for (i = 0; i < NUM_FVW_BUTTONS; i++) if (Fiction_viewer_buttons[Fiction_viewer_ui][gr_screen.res][i].button.pressed()) fiction_viewer_button_pressed(i); common_music_do(); // clear GR_MAYBE_CLEAR_RES(Fiction_viewer_bitmap); if (Fiction_viewer_bitmap >= 0) { gr_set_bitmap(Fiction_viewer_bitmap); gr_bitmap(0, 0, GR_RESIZE_MENU); } // draw the window Fiction_viewer_window.draw(); // render the briefing text brief_render_text(Top_fiction_viewer_text_line, Fiction_viewer_text_coordinates[Fiction_viewer_ui][gr_screen.res][0], Fiction_viewer_text_coordinates[Fiction_viewer_ui][gr_screen.res][1], Fiction_viewer_text_coordinates[Fiction_viewer_ui][gr_screen.res][3], frametime); // maybe output the "more" indicator if ((Fiction_viewer_text_max_lines + Top_fiction_viewer_text_line) < Num_brief_text_lines[0]) { use_std_font(); // can be scrolled down int more_txt_x = Fiction_viewer_text_coordinates[Fiction_viewer_ui][gr_screen.res][0] + (Fiction_viewer_text_coordinates[Fiction_viewer_ui][gr_screen.res][2]/2) - 10; int more_txt_y = Fiction_viewer_text_coordinates[Fiction_viewer_ui][gr_screen.res][1] + Fiction_viewer_text_coordinates[Fiction_viewer_ui][gr_screen.res][3]; // located below text, centered gr_get_string_size(&w, &h, XSTR("more", 1469), strlen(XSTR("more", 1469))); gr_set_color_fast(&Color_black); gr_rect(more_txt_x-2, more_txt_y, w+3, h, GR_RESIZE_MENU); gr_set_color_fast(&Color_more_indicator); gr_string(more_txt_x, more_txt_y, XSTR("more", 1469), GR_RESIZE_MENU); // base location on the input x and y? use_fv_font(); } gr_flip(); }
// init the Popup window int popup_init(popup_info *pi, int flags) { int i; UI_BUTTON *b; popup_background *pbg; char *fname; if(pi->nchoices == 0){ pbg = &Popup_background[gr_screen.res][0]; } else { pbg = &Popup_background[gr_screen.res][pi->nchoices-1]; } // anytime in single player, and multiplayer, not in mission, go ahead and stop time if ( (Game_mode & GM_NORMAL) || ((Game_mode & GM_MULTIPLAYER) && !(Game_mode & GM_IN_MISSION)) ){ game_stop_time(); } // create base window Popup_window.create(pbg->coords[0], pbg->coords[1], Popup_text_coords[gr_screen.res][2]+100, Popup_text_coords[gr_screen.res][3]+50, 0); Popup_window.set_foreground_bmap(pbg->filename); // create buttons for (i=0; i<pi->nchoices; i++) { b = &Popup_buttons[i]; // accommodate single-choice positive icon being positioned differently if ( (pi->nchoices == 1) && (flags&PF_USE_AFFIRMATIVE_ICON) ) { b->create(&Popup_window, "", Button_coords[gr_screen.res][i+1][0], Button_coords[gr_screen.res][i+1][1], 30, 25, 0, 1); } else { b->create(&Popup_window, "", Button_coords[gr_screen.res][i][0], Button_coords[gr_screen.res][i][1], 30, 25, 0, 1); } fname = popup_get_button_filename(pi, i, flags); b->set_bmaps(fname, 3, 0); b->set_highlight_action(common_play_highlight_sound); if ( pi->keypress[i] >= 0 ) { b->set_hotkey(pi->keypress[i]); } // create invisible buttons to detect mouse presses... can't use mask since button region is dynamically sized int lx, w, h; gr_get_string_size(&w, &h, pi->button_text[i]); lx = Button_regions[gr_screen.res][i][0] - w; b = &Popup_button_regions[i]; // accommodate single-choice positive icon being positioned differently if ( (pi->nchoices == 1) && (flags&PF_USE_AFFIRMATIVE_ICON) ) { b->create(&Popup_window, "", lx, Button_regions[gr_screen.res][i+1][1], Button_regions[gr_screen.res][i+1][2]-lx, Button_regions[gr_screen.res][i+1][3]-Button_regions[gr_screen.res][i+1][1], 0, 1); } else { b->create(&Popup_window, "", lx, Button_regions[gr_screen.res][i][1], Button_regions[gr_screen.res][i][2]-lx, Button_regions[gr_screen.res][i][3]-Button_regions[gr_screen.res][i][1], 0, 1); } b->hide(); } // webcursor setup if (Web_cursor_bitmap >= 0) { if (flags & PF_WEB_CURSOR_1) { Popup_buttons[1].set_custom_cursor_bmap(Web_cursor_bitmap); } if (flags & PF_WEB_CURSOR_2) { Popup_buttons[2].set_custom_cursor_bmap(Web_cursor_bitmap); } } // if this is an input popup, create and center the popup if(flags & PF_INPUT){ Popup_input.create(&Popup_window, Popup_text_coords[gr_screen.res][0], pbg->coords[1] + Popup_input_y_offset[gr_screen.res], Popup_text_coords[gr_screen.res][2], pi->max_input_text_len, "", UI_INPUTBOX_FLAG_INVIS | UI_INPUTBOX_FLAG_ESC_CLR | UI_INPUTBOX_FLAG_ESC_FOC | UI_INPUTBOX_FLAG_KEYTHRU | UI_INPUTBOX_FLAG_TEXT_CEN); Popup_input.set_focus(); } Popup_default_choice=0; Popup_should_die = 0; if (flags & PF_RUN_STATE) { Popup_running_state = 1; } else { Popup_running_state = 0; } popup_split_lines(pi, flags); // create the popup slider (which we may not need to use Popup_slider.create(&Popup_window, Popup_slider_coords[gr_screen.res][0], Popup_slider_coords[gr_screen.res][1], Popup_slider_coords[gr_screen.res][2], Popup_slider_coords[gr_screen.res][3], pi->nlines > Popup_max_display[gr_screen.res] ? pi->nlines - Popup_max_display[gr_screen.res] : 0, Popup_slider_name[gr_screen.res], popup_slider_bogus, popup_slider_bogus, NULL); return 0; }
// 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; }
// do void loop_brief_do(float frametime) { int k; int idx; // process keys k = Loop_brief_window.process(); switch (k) { case KEY_ESC: int do_loop = 0; // this popup should be straight forward, and also not allow you to get out // of it without actually picking one of the two options do_loop = popup(PF_USE_NEGATIVE_ICON | PF_USE_AFFIRMATIVE_ICON | PF_IGNORE_ESC | PF_BODY_BIG, 2, XSTR("Decline", 1467), XSTR("Accept", 1035), XSTR("You must either Accept or Decline before returning to the Main Hall", 1618)); // if we accepted moving into loop then set it up for the next time the user plays if (do_loop == 1) { // select the loop mission Campaign.loop_enabled = 1; Campaign.loop_reentry = Campaign.next_mission; // save reentry pt, so we can break out of loop Campaign.next_mission = Campaign.loop_mission; } gameseq_post_event(GS_EVENT_MAIN_MENU); return; } // process button presses for (idx=0; idx<NUM_LOOP_BRIEF_BUTTONS; idx++){ if (Loop_buttons[gr_screen.res][idx].button.pressed()){ loop_brief_button_pressed(idx); } } common_music_do(); // clear GR_MAYBE_CLEAR_RES(Loop_brief_bitmap); if (Loop_brief_bitmap >= 0) { gr_set_bitmap(Loop_brief_bitmap); gr_bitmap(0, 0, GR_RESIZE_MENU); } // draw the window Loop_brief_window.draw(); // render the briefing text brief_render_text(0, Loop_brief_text_coords[gr_screen.res][0], Loop_brief_text_coords[gr_screen.res][1], Loop_brief_text_coords[gr_screen.res][3], flFrametime); if(Loop_anim.num_frames > 0) { int x; int y; bm_get_info((Loop_anim.streaming) ? Loop_anim.bitmap_id : Loop_anim.first_frame, &x, &y, NULL, NULL, NULL); x = Loop_brief_anim_center_coords[gr_screen.res][0] - x / 2; y = Loop_brief_anim_center_coords[gr_screen.res][1] - y / 2; generic_anim_render(&Loop_anim, frametime, x, y, true); } // render all anims anim_render_all(GS_STATE_LOOP_BRIEF, flFrametime); gr_flip(); }
// init void loop_brief_init() { int idx; ui_button_info *b; // load the background bitmap Loop_brief_bitmap = bm_load(Loop_brief_fname[gr_screen.res]); Assert(Loop_brief_bitmap != -1); // window Loop_brief_window.create(0, 0, gr_screen.max_w_unscaled, gr_screen.max_h_unscaled, 0); Loop_brief_window.set_mask_bmap(Loop_brief_mask[gr_screen.res]); // add the buttons for (idx=0; idx<NUM_LOOP_BRIEF_BUTTONS; idx++) { b = &Loop_buttons[gr_screen.res][idx]; b->button.create(&Loop_brief_window, "", b->x, b->y, 60, 30, 0, 1); b->button.set_highlight_action(common_play_highlight_sound); b->button.set_bmaps(b->filename); b->button.link_hotspot(b->hotspot); } // add text for(idx=0; idx<NUM_LOOP_TEXT; idx++){ Loop_brief_window.add_XSTR(&Loop_text[gr_screen.res][idx]); } const char* anim_name; // load animation if any if(Campaign.missions[Campaign.current_mission].mission_branch_brief_anim != NULL){ anim_name = Campaign.missions[Campaign.current_mission].mission_branch_brief_anim; } else { anim_name = "CB_default"; } int stream_result = generic_anim_init_and_stream(&Loop_anim, anim_name, bm_get_type(Loop_brief_bitmap), true); // we've failed to load any animation if (stream_result < 0) { // load an image and treat it like a 1 frame animation Loop_anim.first_frame = bm_load(anim_name); //if we fail here, the value is still -1 if(Loop_anim.first_frame != -1) { Loop_anim.num_frames = 1; } } // init brief text if(Campaign.missions[Campaign.current_mission].mission_branch_desc != NULL){ brief_color_text_init(Campaign.missions[Campaign.current_mission].mission_branch_desc, Loop_brief_text_coords[gr_screen.res][2], default_loop_briefing_color); } bool sound_played = false; // open sound if(Campaign.missions[Campaign.current_mission].mission_branch_brief_sound != NULL){ Loop_sound = audiostream_open(Campaign.missions[Campaign.current_mission].mission_branch_brief_sound, ASF_VOICE); if(Loop_sound != -1){ audiostream_play(Loop_sound, Master_voice_volume, 0); sound_played = true; } } if(sound_played == false) { fsspeech_play(FSSPEECH_FROM_BRIEFING, Campaign.missions[Campaign.current_mission].mission_branch_desc); } // music common_music_init(SCORE_BRIEFING); }
// initialize all popup details (graphics, etc) void multi_pinfo_popup_init(net_player *np) { int idx; // no errors to start with Multi_pinfo_popup_error = 0; // shouldn't be done Multi_pinfo_popup_done = 0; // store the background as it currently is Multi_pinfo_screen_save = gr_save_screen(); if(Multi_pinfo_screen_save == -1){ Multi_pinfo_popup_error = 1; return; } // create the interface window Multi_pinfo_window.create(0,0,gr_screen.max_w_unscaled,gr_screen.max_h_unscaled,0); Multi_pinfo_window.set_mask_bmap(Multi_pinfo_bitmap_mask[gr_screen.res]); // load the background bitmap Multi_pinfo_bitmap = bm_load(Multi_pinfo_bitmap_name[gr_screen.res]); if(Multi_pinfo_bitmap < 0){ Multi_pinfo_popup_error = 1; return; } // backup hardware textures setting and bash to max Multi_pinfo_hardware_texture_backup = Detail.hardware_textures; Detail.hardware_textures = MAX_DETAIL_LEVEL; // zero bitmap info Mp_pilot.bitmap = -1; strcpy_s(Mp_pilot.filename, ""); Mp_squad.bitmap = -1; strcpy_s(Mp_squad.filename, ""); // set the player status multi_pinfo_reset_player(np); // create the interface buttons for(idx=0;idx<MULTI_PINFO_NUM_BUTTONS;idx++){ // create the object Multi_pinfo_buttons[gr_screen.res][idx].button.create(&Multi_pinfo_window, "", Multi_pinfo_buttons[gr_screen.res][idx].x, Multi_pinfo_buttons[gr_screen.res][idx].y, 1, 1, 0, 1); // set the sound to play when highlighted Multi_pinfo_buttons[gr_screen.res][idx].button.set_highlight_action(common_play_highlight_sound); // set the ani for the button Multi_pinfo_buttons[gr_screen.res][idx].button.set_bmaps(Multi_pinfo_buttons[gr_screen.res][idx].filename); // set the hotspot Multi_pinfo_buttons[gr_screen.res][idx].button.link_hotspot(Multi_pinfo_buttons[gr_screen.res][idx].hotspot); } // add xstrs for(idx=0; idx<MULTI_PINFO_NUM_TEXT; idx++){ Multi_pinfo_window.add_XSTR(&Multi_pinfo_text[gr_screen.res][idx]); } // initialize strings Multi_pinfo_stats_labels[0] = vm_strdup(XSTR("Rank", 1007)); Multi_pinfo_stats_labels[1] = vm_strdup(XSTR("Missions Flown", 1008)); Multi_pinfo_stats_labels[2] = vm_strdup(XSTR("Flight Time", 1009)); Multi_pinfo_stats_labels[3] = vm_strdup(XSTR("Last Flown",1010)); Multi_pinfo_stats_labels[4] = vm_strdup(XSTR("Total Kills", 115)); Multi_pinfo_stats_labels[5] = vm_strdup(XSTR("Primary Shots Fired", 1012)); Multi_pinfo_stats_labels[6] = vm_strdup(XSTR("Primary Hit %", 1013)); Multi_pinfo_stats_labels[7] = vm_strdup(XSTR("Secondary Shots Fired", 1014)); Multi_pinfo_stats_labels[8] = vm_strdup(XSTR("Secondary Hit %", 1015)); }
void player_select_close() { // destroy the player select window Player_select_window.destroy(); // if we're in input mode - we should undo the pilot create reqeust if(Player_select_input_mode) { player_select_cancel_create(); } // if we are just exiting then don't try to save any pilot files - taylor if (Player_select_no_save_pilot) { Player = NULL; return; } // actually set up the Player struct here if ( (Player_select_pilot == -1) || (Player_select_num_pilots == 0) ) { nprintf(("General","WARNING! No pilot selected! We should be exiting the game now!\n")); return; } // unload all bitmaps if(Player_select_background_bitmap >= 0) { bm_release(Player_select_background_bitmap); Player_select_background_bitmap = -1; } // if(Player_select_palette >= 0){ // bm_release(Player_select_palette); //Player_select_palette = -1; // } // setup the player struct Player_num = 0; Player = &Players[0]; Player->flags |= PLAYER_FLAGS_STRUCTURE_IN_USE; // New pilot file makes no distinction between multi pilots and regular ones, so let's do this here. if (Player_select_mode == PLAYER_SELECT_MODE_MULTI) { Player->flags |= PLAYER_FLAGS_IS_MULTI; } // WMC - Set appropriate game mode if ( Player->flags & PLAYER_FLAGS_IS_MULTI ) { Game_mode = GM_MULTIPLAYER; } else { Game_mode = GM_NORMAL; } // now read in a the pilot data if ( !Pilot.load_player(Pilots[Player_select_pilot], Player) ) { Error(LOCATION,"Couldn't load pilot file, bailing"); Player = NULL; } else { // NOTE: this may fail if there is no current campaign, it's not fatal Pilot.load_savefile(Player->current_campaign); } if (Player_select_force_main_hall != "") { main_hall_init(Player_select_force_main_hall); } // free memory from all parsing so far, all tbls found during game_init() // and the current campaign which we loaded here stop_parse(); Player_select_screen_active = 0; }
void credits_init() { int i, w, h; credits_screen_buttons *b; char line[512] = ""; char *linep1, *linep2; int credits_spooled_music_index = event_music_get_spooled_music_index("Cinema"); if(credits_spooled_music_index != -1){ char *credits_wavfile_name = Spooled_music[credits_spooled_music_index].filename; if(credits_wavfile_name != NULL){ credits_load_music(credits_wavfile_name); } } // Use this id to trigger the start of music playing on the briefing screen Credits_music_begin_timestamp = timestamp(CREDITS_MUSIC_DELAY); Credits_frametime = 0; Credits_last_time = timer_get_milliseconds(); Credit_text = NULL; Credit_text_malloced = 0; // allocate enough space for credits text CFILE *fp = cfopen( NOX("credits.tbl"), "rb" ); if(fp != NULL){ int rval, size; size = cfilelength(fp); Credit_text = (char *) vm_malloc(size + 200 + strlen(fs2_open_credit_text) + strlen(unmodified_credits)); if (Credit_text == NULL) { return; } else { Credit_text_malloced = 1; } cfclose(fp); // open localization lcl_ext_open(); if ((rval = setjmp(parse_abort)) != 0) { mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", "credits.tbl", rval)); lcl_ext_close(); return; } read_file_text("credits.tbl"); reset_parse(); // keep reading everything in strcpy(Credit_text, fs2_open_credit_text); bool first_run = true; while(!check_for_string_raw("#end")){ stuff_string_line(line, sizeof(line)); // This is a bit odd but it means if a total conversion uses different credits the // Volition credit won't happen if(first_run == true) { if(strcmp(line, mod_check) == 0) { strcat(Credit_text, unmodified_credits); } first_run = false; } linep1 = line; do { linep2 = split_str_once(linep1, Credits_text_coords[gr_screen.res][2]); Assert( linep2 != linep1 ); strcat(Credit_text, linep1); strcat(Credit_text, "\n"); linep1 = linep2; } while (linep2 != NULL); } // close localization lcl_ext_close(); } else { Credit_text = NOX("No credits available.\n"); } int ch; for ( i = 0; Credit_text[i]; i++ ) { ch = Credit_text[i]; switch (ch) { case -4: ch = 129; break; case -28: ch = 132; break; case -10: ch = 148; break; case -23: ch = 130; break; case -30: ch = 131; break; case -25: ch = 135; break; case -21: ch = 137; break; case -24: ch = 138; break; case -17: ch = 139; break; case -18: ch = 140; break; case -60: ch = 142; break; case -55: ch = 144; break; case -12: ch = 147; break; case -14: ch = 149; break; case -5: ch = 150; break; case -7: ch = 151; break; case -42: ch = 153; break; case -36: ch = 154; break; case -31: ch = 160; break; case -19: ch = 161; break; case -13: ch = 162; break; case -6: ch = 163; break; case -32: ch = 133; break; case -22: ch = 136; break; case -20: ch = 141; break; } Credit_text[i] = (char)ch; } gr_get_string_size(&w, &h, Credit_text); Credit_start_pos = i2fl(Credits_text_coords[gr_screen.res][CREDITS_H_COORD]); Credit_stop_pos = -i2fl(h); Credit_position = Credit_start_pos; Ui_window.create(0, 0, gr_screen.max_w_unscaled, gr_screen.max_h_unscaled, 0); Ui_window.set_mask_bmap(Credits_bitmap_mask_fname[gr_screen.res]); common_set_interface_palette("InterfacePalette"); // set the interface palette for (i=0; i<NUM_BUTTONS; i++) { b = &Buttons[i][gr_screen.res]; b->button.create(&Ui_window, "", b->x, b->y, 60, 30, (i < 2), 1); // set up callback for when a mouse first goes over a button b->button.set_highlight_action(common_play_highlight_sound); b->button.set_bmaps(b->filename); b->button.link_hotspot(b->hotspot); } // add some text Ui_window.add_XSTR("Technical Database", 1055, Buttons[TECH_DATABASE_BUTTON][gr_screen.res].xt, Buttons[TECH_DATABASE_BUTTON][gr_screen.res].yt, &Buttons[TECH_DATABASE_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_GREEN); Ui_window.add_XSTR("Mission Simulator", 1056, Buttons[SIMULATOR_BUTTON][gr_screen.res].xt, Buttons[SIMULATOR_BUTTON][gr_screen.res].yt, &Buttons[SIMULATOR_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_GREEN); Ui_window.add_XSTR("Cutscenes", 1057, Buttons[CUTSCENES_BUTTON][gr_screen.res].xt, Buttons[CUTSCENES_BUTTON][gr_screen.res].yt, &Buttons[CUTSCENES_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_GREEN); Ui_window.add_XSTR("Credits", 1058, Buttons[CREDITS_BUTTON][gr_screen.res].xt, Buttons[CREDITS_BUTTON][gr_screen.res].yt, &Buttons[CREDITS_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_GREEN); Ui_window.add_XSTR("Exit", 1420, Buttons[EXIT_BUTTON][gr_screen.res].xt, Buttons[EXIT_BUTTON][gr_screen.res].yt, &Buttons[EXIT_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_PINK); if (Player->flags & PLAYER_FLAGS_IS_MULTI) { Buttons[SIMULATOR_BUTTON][gr_screen.res].button.disable(); Buttons[CUTSCENES_BUTTON][gr_screen.res].button.disable(); } Buttons[EXIT_BUTTON][gr_screen.res].button.set_hotkey(KEY_CTRLED | KEY_ENTER); Background_bitmap = bm_load(Credits_bitmap_fname[gr_screen.res]); Credits_artwork_index = rand() % NUM_IMAGES; for (i=0; i<NUM_IMAGES; i++){ Credits_bmps[i] = -1; } // CreditsWin01 = bm_load(NOX("CreditsWin01")); // CreditsWin02 = bm_load(NOX("CreditsWin02")); // CreditsWin03 = bm_load(NOX("CreditsWin03")); // CreditsWin04 = bm_load(NOX("CreditsWin04")); }
void techroom_init() { int i, idx; techroom_buttons *b; Ships_loaded = 0; Weapons_loaded = 0; Intel_loaded = 0; Techroom_show_all = 0; // set up UI stuff Ui_window.create(0, 0, gr_screen.max_w_unscaled, gr_screen.max_h_unscaled, 0); Ui_window.set_mask_bmap(Tech_mask_filename[gr_screen.res]); Tech_background_bitmap = bm_load(Tech_background_filename[gr_screen.res]); if (Tech_background_bitmap < 0) { // failed to load bitmap, not a good thing Error(LOCATION,"Couldn't load techroom background bitmap"); } for (i=0; i<NUM_BUTTONS; i++) { b = &Buttons[gr_screen.res][i]; b->button.create(&Ui_window, "", b->x, b->y, 60, 30, b->flags & REPEAT, 1); // set up callback for when a mouse first goes over a button if (b->filename) { b->button.set_bmaps(b->filename); b->button.set_highlight_action(common_play_highlight_sound); } else { b->button.hide(); } b->button.link_hotspot(b->hotspot); } // common tab button text Ui_window.add_XSTR("Technical Database", 1055, Buttons[gr_screen.res][TECH_DATABASE_TAB].xt, Buttons[gr_screen.res][TECH_DATABASE_TAB].yt, &Buttons[gr_screen.res][TECH_DATABASE_TAB].button, UI_XSTR_COLOR_GREEN); Ui_window.add_XSTR("Mission Simulator", 1056, Buttons[gr_screen.res][SIMULATOR_TAB].xt, Buttons[gr_screen.res][SIMULATOR_TAB].yt, &Buttons[gr_screen.res][SIMULATOR_TAB].button, UI_XSTR_COLOR_GREEN); Ui_window.add_XSTR("Cutscenes", 1057, Buttons[gr_screen.res][CUTSCENES_TAB].xt, Buttons[gr_screen.res][CUTSCENES_TAB].yt, &Buttons[gr_screen.res][CUTSCENES_TAB].button, UI_XSTR_COLOR_GREEN); Ui_window.add_XSTR("Credits", 1058, Buttons[gr_screen.res][CREDITS_TAB].xt, Buttons[gr_screen.res][CREDITS_TAB].yt, &Buttons[gr_screen.res][CREDITS_TAB].button, UI_XSTR_COLOR_GREEN); // common ship/weapon/intel text Ui_window.add_XSTR("Ships", 293, Buttons[gr_screen.res][SHIPS_DATA_TAB].xt, Buttons[gr_screen.res][SHIPS_DATA_TAB].yt, &Buttons[gr_screen.res][SHIPS_DATA_TAB].button, UI_XSTR_COLOR_GREEN); Ui_window.add_XSTR("Weapons", 1553, Buttons[gr_screen.res][WEAPONS_DATA_TAB].xt, Buttons[gr_screen.res][WEAPONS_DATA_TAB].yt, &Buttons[gr_screen.res][WEAPONS_DATA_TAB].button, UI_XSTR_COLOR_GREEN); Ui_window.add_XSTR("Intelligence", 1066, Buttons[gr_screen.res][INTEL_DATA_TAB].xt, Buttons[gr_screen.res][INTEL_DATA_TAB].yt, &Buttons[gr_screen.res][INTEL_DATA_TAB].button, UI_XSTR_COLOR_GREEN); // common help/options/commit text Ui_window.add_XSTR("Exit", 1418, Buttons[gr_screen.res][EXIT_BUTTON].xt, Buttons[gr_screen.res][EXIT_BUTTON].yt, &Buttons[gr_screen.res][EXIT_BUTTON].button, UI_XSTR_COLOR_PINK); if (Player->flags & PLAYER_FLAGS_IS_MULTI) { Buttons[gr_screen.res][SIMULATOR_TAB].button.disable(); Buttons[gr_screen.res][CUTSCENES_TAB].button.disable(); } // set some hotkeys Buttons[gr_screen.res][PREV_ENTRY_BUTTON].button.set_hotkey(KEY_LEFT); Buttons[gr_screen.res][NEXT_ENTRY_BUTTON].button.set_hotkey(KEY_RIGHT); Buttons[gr_screen.res][SCROLL_INFO_UP].button.set_hotkey(KEY_UP); Buttons[gr_screen.res][SCROLL_INFO_DOWN].button.set_hotkey(KEY_DOWN); for (i=0; i<LIST_BUTTONS_MAX; i++) { List_buttons[i].create(&Ui_window, "", 0, 0, 60, 30, 0, 1); List_buttons[i].hide(); List_buttons[i].disable(); } View_window.create(&Ui_window, "", Tech_ship_display_coords[gr_screen.res][SHIP_X_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_Y_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_W_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_H_COORD], 1, 1); View_window.hide(); Buttons[gr_screen.res][HELP_BUTTON].button.set_hotkey(KEY_F1); Buttons[gr_screen.res][EXIT_BUTTON].button.set_hotkey(KEY_CTRLED | KEY_ENTER); Buttons[gr_screen.res][SCROLL_LIST_UP].button.set_hotkey(KEY_PAGEUP); Buttons[gr_screen.res][SCROLL_LIST_DOWN].button.set_hotkey(KEY_PAGEDOWN); // init help overlay states Techroom_overlay_id = help_overlay_get_index(TECH_ROOM_OVERLAY); help_overlay_set_state(Techroom_overlay_id, gr_screen.res, 0); // setup slider Tech_slider.create(&Ui_window, Tech_slider_coords[gr_screen.res][SHIP_X_COORD], Tech_slider_coords[gr_screen.res][SHIP_Y_COORD], Tech_slider_coords[gr_screen.res][SHIP_W_COORD], Tech_slider_coords[gr_screen.res][SHIP_H_COORD], Ship_info.size(), Tech_slider_filename[gr_screen.res], &tech_scroll_list_up, &tech_scroll_list_down, &tech_ship_scroll_capture); // zero intel anim/bitmap stuff for(idx=0; idx<MAX_INTEL_ENTRIES; idx++){ Intel_list[idx].animation.num_frames = 0; Intel_list[idx].bitmap = -1; } mprintf(("Techroom successfully initialized, now changing tab...\n")); techroom_change_tab(Tab); }
void credits_do_frame(float frametime) { int i, k, next, percent, bm1, bm2; int bx1, by1, bw1, bh1; int bx2, by2, bw2, bh2; // Use this id to trigger the start of music playing on the credits screen if ( timestamp_elapsed(Credits_music_begin_timestamp) ) { Credits_music_begin_timestamp = 0; credits_start_music(); } k = Ui_window.process(); switch (k) { case KEY_ESC: gameseq_post_event(GS_EVENT_MAIN_MENU); key_flush(); break; case KEY_CTRLED | KEY_UP: case KEY_SHIFTED | KEY_TAB: if ( !(Player->flags & PLAYER_FLAGS_IS_MULTI) ) { credits_screen_button_pressed(CUTSCENES_BUTTON); break; } // else, react like tab key. case KEY_CTRLED | KEY_DOWN: case KEY_TAB: credits_screen_button_pressed(TECH_DATABASE_BUTTON); break; default: break; } // end switch for (i=0; i<NUM_BUTTONS; i++){ if (Buttons[i][gr_screen.res].button.pressed()){ if (credits_screen_button_pressed(i)){ return; } } } gr_reset_clip(); GR_MAYBE_CLEAR_RES(Background_bitmap); if (Background_bitmap >= 0) { gr_set_bitmap(Background_bitmap); gr_bitmap(0, 0); } percent = (int) (100.0f - (CREDITS_ARTWORK_DISPLAY_TIME - Credits_counter) * 100.0f / CREDITS_ARTWORK_FADE_TIME); if (percent < 0){ percent = 0; } next = Credits_artwork_index + 1; if (next >= NUM_IMAGES){ next = 0; } if (Credits_bmps[Credits_artwork_index] < 0) { char buf[40]; if (gr_screen.res == GR_1024) { sprintf(buf, NOX("2_CrIm%.2d"), Credits_artwork_index); } else { sprintf(buf, NOX("CrIm%.2d"), Credits_artwork_index); } Credits_bmps[Credits_artwork_index] = bm_load(buf); } if (Credits_bmps[next] < 0) { char buf[40]; if (gr_screen.res == GR_1024) { sprintf(buf, NOX("2_CrIm%.2d"), Credits_artwork_index); } else { sprintf(buf, NOX("CrIm%.2d"), next); } Credits_bmps[next] = bm_load(buf); } bm1 = Credits_bmps[Credits_artwork_index]; bm2 = Credits_bmps[next]; if((bm1 != -1) && (bm2 != -1)){ Assert(percent >= 0 && percent <= 100); // get width and height bm_get_info(bm1, &bw1, &bh1, NULL, NULL, NULL); bm_get_info(bm2, &bw2, &bh2, NULL, NULL, NULL); // determine where to draw the coords bx1 = Credits_image_coords[gr_screen.res][CREDITS_X_COORD] + ((Credits_image_coords[gr_screen.res][CREDITS_W_COORD] - bw1)/2); by1 = Credits_image_coords[gr_screen.res][CREDITS_Y_COORD] + ((Credits_image_coords[gr_screen.res][CREDITS_H_COORD] - bh1)/2); bx2 = Credits_image_coords[gr_screen.res][CREDITS_X_COORD] + ((Credits_image_coords[gr_screen.res][CREDITS_W_COORD] - bw2)/2); by2 = Credits_image_coords[gr_screen.res][CREDITS_Y_COORD] + ((Credits_image_coords[gr_screen.res][CREDITS_H_COORD] - bh2)/2); gr_cross_fade(bm1, bm2, bx1, by1, bx2, by2, (float)percent / 100.0f); } /* if (CreditsWin01 != -1) { gr_set_bitmap(CreditsWin01); gr_bitmap(233, 5); } if (CreditsWin02 != -1) { gr_set_bitmap(CreditsWin02); gr_bitmap(616, 8); } if (CreditsWin03 != -1) { gr_set_bitmap(CreditsWin03); gr_bitmap(233, 299); } if (CreditsWin04 != -1) { gr_set_bitmap(CreditsWin04); gr_bitmap(215, 8); } */ Ui_window.draw(); for (i=TECH_DATABASE_BUTTON; i<=CREDITS_BUTTON; i++){ if (Buttons[i][gr_screen.res].button.button_down()){ break; } } if (i > CREDITS_BUTTON){ Buttons[CREDITS_BUTTON][gr_screen.res].button.draw_forced(2); } gr_set_clip(Credits_text_coords[gr_screen.res][CREDITS_X_COORD], Credits_text_coords[gr_screen.res][CREDITS_Y_COORD], Credits_text_coords[gr_screen.res][CREDITS_W_COORD], Credits_text_coords[gr_screen.res][CREDITS_H_COORD]); gr_set_font(FONT1); gr_set_color_fast(&Color_normal); int sy; if ( Credit_position > 0 ) { sy = fl2i(Credit_position+0.5f); } else { sy = fl2i(Credit_position-0.5f); } gr_string(0x8000, sy, Credit_text); int temp_time; temp_time = timer_get_milliseconds(); Credits_frametime = temp_time - Credits_last_time; Credits_last_time = temp_time; timestamp_inc(Credits_frametime / 1000.0f); float fl_frametime = i2fl(Credits_frametime) / 1000.f; if (keyd_pressed[KEY_LSHIFT]) { Credit_position -= fl_frametime * CREDITS_SCROLL_RATE * 4.0f; } else { Credit_position -= fl_frametime * CREDITS_SCROLL_RATE; } if (Credit_position < Credit_stop_pos){ Credit_position = Credit_start_pos; } Credits_counter += fl_frametime; while (Credits_counter >= CREDITS_ARTWORK_DISPLAY_TIME) { Credits_counter -= CREDITS_ARTWORK_DISPLAY_TIME; Credits_artwork_index = next; } gr_flip(); }
void credits_init() { int i; credits_screen_buttons *b; // pre-initialize Credits_num_images = DEFAULT_NUM_IMAGES; Credits_artwork_index = -1; // this is moved up here so we can override it if desired strcpy_s(Credits_music_name, "Cinema"); // parse credits early so as to set up any overrides (for music and such) Credits_parsed = false; credits_parse(); // we could conceivably have specified a number of images but not an index, // so if that's the case, set the value here if (Credits_artwork_index < 0) { Credits_artwork_index = rand() % Credits_num_images; } int credits_spooled_music_index = event_music_get_spooled_music_index(Credits_music_name); if(credits_spooled_music_index != -1){ char *credits_wavfile_name = Spooled_music[credits_spooled_music_index].filename; if(credits_wavfile_name != NULL){ credits_load_music(credits_wavfile_name); } } // Use this id to trigger the start of music playing on the briefing screen Credits_music_begin_timestamp = timestamp(Credits_music_delay); Credits_frametime = 0; Credits_last_time = timer_get_milliseconds(); if (!Credits_parsed) { Credit_text_parts.push_back(SCP_string("No credits available.\n")); } else { switch (SCP_credits_position) { case START: Credit_text_parts.insert(Credit_text_parts.begin(), fs2_open_credit_text); break; case END: Credit_text_parts.push_back(fs2_open_credit_text); break; default: Error(LOCATION, "Unimplemented credits position %d. Get a coder!", (int) SCP_credits_position); break; } } int ch; SCP_vector<SCP_string>::iterator iter; for (iter = Credit_text_parts.begin(); iter != Credit_text_parts.end(); ++iter) { for (SCP_string::iterator ii = iter->begin(); ii != iter->end(); ++ii) { ch = *ii; switch (ch) { case -4: ch = 129; break; case -28: ch = 132; break; case -10: ch = 148; break; case -23: ch = 130; break; case -30: ch = 131; break; case -25: ch = 135; break; case -21: ch = 137; break; case -24: ch = 138; break; case -17: ch = 139; break; case -18: ch = 140; break; case -60: ch = 142; break; case -55: ch = 144; break; case -12: ch = 147; break; case -14: ch = 149; break; case -5: ch = 150; break; case -7: ch = 151; break; case -42: ch = 153; break; case -36: ch = 154; break; case -31: ch = 160; break; case -19: ch = 161; break; case -13: ch = 162; break; case -6: ch = 163; break; case -32: ch = 133; break; case -22: ch = 136; break; case -20: ch = 141; break; } *ii = (char) ch; } } int temp_h; int h = 0; for (iter = Credit_text_parts.begin(); iter != Credit_text_parts.end(); ++iter) { gr_get_string_size(NULL, &temp_h, iter->c_str(), (int)iter->length()); h = h + temp_h; } Credit_start_pos = i2fl(Credits_text_coords[gr_screen.res][CREDITS_H_COORD]); Credit_stop_pos = -i2fl(h); Credit_position = Credit_start_pos; Ui_window.create(0, 0, gr_screen.max_w_unscaled, gr_screen.max_h_unscaled, 0); Ui_window.set_mask_bmap(Credits_bitmap_mask_fname[gr_screen.res]); common_set_interface_palette("InterfacePalette"); // set the interface palette for (i=0; i<NUM_BUTTONS; i++) { b = &Buttons[i][gr_screen.res]; b->button.create(&Ui_window, "", b->x, b->y, 60, 30, (i < 2), 1); // set up callback for when a mouse first goes over a button b->button.set_highlight_action(common_play_highlight_sound); b->button.set_bmaps(b->filename); b->button.link_hotspot(b->hotspot); } // add some text Ui_window.add_XSTR("Technical Database", 1055, Buttons[TECH_DATABASE_BUTTON][gr_screen.res].xt, Buttons[TECH_DATABASE_BUTTON][gr_screen.res].yt, &Buttons[TECH_DATABASE_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_GREEN); Ui_window.add_XSTR("Mission Simulator", 1056, Buttons[SIMULATOR_BUTTON][gr_screen.res].xt, Buttons[SIMULATOR_BUTTON][gr_screen.res].yt, &Buttons[SIMULATOR_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_GREEN); Ui_window.add_XSTR("Cutscenes", 1057, Buttons[CUTSCENES_BUTTON][gr_screen.res].xt, Buttons[CUTSCENES_BUTTON][gr_screen.res].yt, &Buttons[CUTSCENES_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_GREEN); Ui_window.add_XSTR("Credits", 1058, Buttons[CREDITS_BUTTON][gr_screen.res].xt, Buttons[CREDITS_BUTTON][gr_screen.res].yt, &Buttons[CREDITS_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_GREEN); Ui_window.add_XSTR("Exit", 1420, Buttons[EXIT_BUTTON][gr_screen.res].xt, Buttons[EXIT_BUTTON][gr_screen.res].yt, &Buttons[EXIT_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_PINK); if (Player->flags & PLAYER_FLAGS_IS_MULTI) { Buttons[SIMULATOR_BUTTON][gr_screen.res].button.disable(); Buttons[CUTSCENES_BUTTON][gr_screen.res].button.disable(); } Buttons[EXIT_BUTTON][gr_screen.res].button.set_hotkey(KEY_CTRLED | KEY_ENTER); Background_bitmap = bm_load(Credits_bitmap_fname[gr_screen.res]); Credits_bmps.resize(Credits_num_images); for (i=0; i<Credits_num_images; i++) { Credits_bmps[i] = -1; } }
// 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 barracks_init() { //Set these to null, 'cause they aren't allocated yet. Stat_labels = NULL; Stats = NULL; UI_WINDOW *w = &Ui_window; // save current pilot file, so we don't possibly loose it. Pilot.save_player(); // create interface Ui_window.create(0, 0, gr_screen.max_w_unscaled, gr_screen.max_h_unscaled, 0); Ui_window.set_mask_bmap(Barracks_bitmap_mask_fname[gr_screen.res]); // load background bitmap Background_bitmap = bm_load(Barracks_bitmap_fname[gr_screen.res]); if(Background_bitmap < 0){ // we failed to load the bitmap - this is very bad Int3(); } // create buttons int i; for (i=0; i<BARRACKS_NUM_BUTTONS; i++) { // create the object Buttons[gr_screen.res][i].button.create(&Ui_window, "", Buttons[gr_screen.res][i].x, Buttons[gr_screen.res][i].y, 60, 30, Buttons[gr_screen.res][i].repeat, 1); // set the sound to play when highlighted Buttons[gr_screen.res][i].button.set_highlight_action(common_play_highlight_sound); // set the ani for the button Buttons[gr_screen.res][i].button.set_bmaps(Buttons[gr_screen.res][i].filename); // set the hotspot Buttons[gr_screen.res][i].button.link_hotspot(Buttons[gr_screen.res][i].hotspot); } // add all strings w->add_XSTR("Create", 1034, Buttons[gr_screen.res][0].text_x, Buttons[gr_screen.res][0].text_y, &Buttons[gr_screen.res][0].button, UI_XSTR_COLOR_GREEN); w->add_XSTR("Accept", 1035, Buttons[gr_screen.res][5].text_x, Buttons[gr_screen.res][5].text_y, &Buttons[gr_screen.res][5].button, UI_XSTR_COLOR_PINK); w->add_XSTR("Help", 928, Buttons[gr_screen.res][6].text_x, Buttons[gr_screen.res][6].text_y, &Buttons[gr_screen.res][6].button, UI_XSTR_COLOR_GREEN); w->add_XSTR("Options",1036, Buttons[gr_screen.res][7].text_x, Buttons[gr_screen.res][7].text_y, &Buttons[gr_screen.res][7].button, UI_XSTR_COLOR_GREEN); w->add_XSTR("Medals", 1037, Buttons[gr_screen.res][8].text_x, Buttons[gr_screen.res][8].text_y, &Buttons[gr_screen.res][8].button, UI_XSTR_COLOR_GREEN); w->add_XSTR("Remove", 1038, Buttons[gr_screen.res][11].text_x, Buttons[gr_screen.res][11].text_y, &Buttons[gr_screen.res][11].button, UI_XSTR_COLOR_GREEN); w->add_XSTR("Select", 1552, Buttons[gr_screen.res][12].text_x, Buttons[gr_screen.res][12].text_y, &Buttons[gr_screen.res][12].button, UI_XSTR_COLOR_GREEN); w->add_XSTR("Clone", 1040, Buttons[gr_screen.res][13].text_x, Buttons[gr_screen.res][13].text_y, &Buttons[gr_screen.res][13].button, UI_XSTR_COLOR_GREEN); w->add_XSTR("Single", 1041, Buttons[gr_screen.res][14].text_x, Buttons[gr_screen.res][14].text_y, &Buttons[gr_screen.res][14].button, UI_XSTR_COLOR_GREEN); w->add_XSTR("Multi", 1042, Buttons[gr_screen.res][15].text_x, Buttons[gr_screen.res][15].text_y, &Buttons[gr_screen.res][15].button, UI_XSTR_COLOR_GREEN); // w->add_XSTR("Convert",1043, Buttons[gr_screen.res][16].text_x, Buttons[gr_screen.res][16].text_y, &Buttons[gr_screen.res][16].button, UI_XSTR_COLOR_GREEN); for(i=0; i<BARRACKS_NUM_TEXT; i++) { w->add_XSTR(&Barracks_text[gr_screen.res][i]); } // button for selecting pilot List_region.create(&Ui_window, "", Barracks_list_coords[gr_screen.res][BARRACKS_X_COORD], Barracks_list_coords[gr_screen.res][BARRACKS_Y_COORD], Barracks_list_coords[gr_screen.res][BARRACKS_W_COORD], Barracks_list_coords[gr_screen.res][BARRACKS_H_COORD], 0, 1); List_region.hide(); // create input box (for new pilot) Inputbox.create(&Ui_window, Barracks_list_coords[gr_screen.res][BARRACKS_X_COORD], Barracks_list_coords[gr_screen.res][BARRACKS_Y_COORD], Barracks_list_coords[gr_screen.res][BARRACKS_W_COORD], CALLSIGN_LEN - 1, "", UI_INPUTBOX_FLAG_INVIS | UI_INPUTBOX_FLAG_KEYTHRU | UI_INPUTBOX_FLAG_LETTER_FIRST); Inputbox.set_valid_chars(VALID_PILOT_CHARS); Inputbox.disable(); Inputbox.hide(); // load in help overlay bitmap Barracks_overlay_id = help_overlay_get_index(BARRACKS_OVERLAY); help_overlay_set_state(Barracks_overlay_id,gr_screen.res,0); // other init stuff Barracks_callsign_enter_mode = 0; List_scroll_offset = Stats_scroll_offset = Pic_number = Pic_squad_number = Selected_line = 0; Cur_pilot = &Players[Player_num]; // disable squad logo selection buttons in single player if(!(Cur_pilot->flags & PLAYER_FLAGS_IS_MULTI)){ // squad logo picture buttons Buttons[gr_screen.res][B_SQUAD_PREV_BUTTON].button.hide(); Buttons[gr_screen.res][B_SQUAD_PREV_BUTTON].button.disable(); Buttons[gr_screen.res][B_SQUAD_NEXT_BUTTON].button.hide(); Buttons[gr_screen.res][B_SQUAD_NEXT_BUTTON].button.disable(); } else { // squad logo picture buttons Buttons[gr_screen.res][B_SQUAD_PREV_BUTTON].button.enable(); Buttons[gr_screen.res][B_SQUAD_PREV_BUTTON].button.unhide(); Buttons[gr_screen.res][B_SQUAD_NEXT_BUTTON].button.enable(); Buttons[gr_screen.res][B_SQUAD_NEXT_BUTTON].button.unhide(); } // set up hotkeys for buttons so we draw the correct animation frame when a key is pressed barracks_set_hotkeys(1); // load ramp pips Rank_pips_bitmaps = bm_load_animation("IconRankMini.ani", &Rank_pips_count); // load up the pilot pic list pilot_load_pic_list(); pilot_load_squad_pic_list(); // don't load pilot images yet for (i=0; i<MAX_PILOT_IMAGES; i++) { Pilot_images[i] = BARRACKS_IMAGE_NOT_LOADED; // while -1 is can't load Pilot_squad_images[i] = BARRACKS_IMAGE_NOT_LOADED; } // init stats barracks_init_stats(&Cur_pilot->stats); // base the mode we're in (single or multi) on the status of the currently selected pilot barracks_init_player_stuff((Game_mode & GM_MULTIPLAYER) == GM_MULTIPLAYER); }
// --------------------------------------------------------------------- // mission_hotkey_do_frame() // // Called once per frame to process user input for the Hotkey Assignment Screen // void mission_hotkey_do_frame(float frametime) { char buf[256]; int i, k, w, h, y, z, line, hotkeys; int font_height = gr_get_font_height(); int select_tease_line = -1; // line mouse is down on, but won't be selected until button released color circle_color; if ( help_overlay_active(Hotkey_overlay_id) ) { Buttons[gr_screen.res][HELP_BUTTON].button.reset_status(); Ui_window.set_ignore_gadgets(1); } k = Ui_window.process() & ~KEY_DEBUGGED; if ( (k > 0) || B1_JUST_RELEASED ) { if ( help_overlay_active(Hotkey_overlay_id) ) { help_overlay_set_state(Hotkey_overlay_id, gr_screen.res, 0); Ui_window.set_ignore_gadgets(0); k = 0; } } if ( !help_overlay_active(Hotkey_overlay_id) ) { Ui_window.set_ignore_gadgets(0); } switch (k) { case KEY_DOWN: // scroll list down hotkey_scroll_line_down(); break; case KEY_UP: // scroll list up hotkey_scroll_line_up(); break; case KEY_PAGEDOWN: // scroll list down hotkey_scroll_screen_down(); break; case KEY_PAGEUP: // scroll list up hotkey_scroll_screen_up(); break; case KEY_CTRLED | KEY_ENTER: save_hotkeys(); // fall through to next state -- allender changed this behavior since ESC should always cancel, no? case KEY_ESC: mission_hotkey_exit(); break; case KEY_TAB: case KEY_ENTER: case KEY_PADENTER: expand_wing(); break; case KEY_EQUAL: case KEY_PADPLUS: add_hotkey(Cur_hotkey); break; case KEY_MINUS: case KEY_PADMINUS: remove_hotkey(); break; case KEY_F2: gameseq_post_event(GS_EVENT_OPTIONS_MENU); break; case KEY_CTRLED | KEY_R: reset_hotkeys(); break; case KEY_CTRLED | KEY_C: clear_hotkeys(); break; } // end switch // ? for (i=0; i<MAX_KEYED_TARGETS; i++) { if (k == Key_sets[i]) Cur_hotkey = i; if (k == (Key_sets[i] | KEY_SHIFTED)) add_hotkey(i); } // handle pressed buttons for (i=0; i<NUM_BUTTONS; i++) { if (Buttons[gr_screen.res][i].button.pressed()) { hotkey_button_pressed(i); break; // only need to handle 1 button @ a time } } for (i=0; i<LIST_BUTTONS_MAX; i++) { // check for tease line if (List_buttons[i].button_down()) { select_tease_line = i + Scroll_offset; } // check for selected list item if (List_buttons[i].pressed()) { Selected_line = i + Scroll_offset; List_buttons[i].get_mouse_pos(&z, NULL); z += Hotkey_list_coords[gr_screen.res][0]; // adjust to full screen space if ((z >= Hotkey_wing_icon_x[gr_screen.res]) && (z < (Hotkey_wing_icon_x[gr_screen.res]) + Hotkey_function_field_width[gr_screen.res])) { expand_wing(); } } if (List_buttons[i].double_clicked()) { Selected_line = i + Scroll_offset; hotkeys = -1; switch (Hotkey_lines[Selected_line].type) { case HOTKEY_LINE_WING: hotkeys = get_wing_hotkeys(Hotkey_lines[Selected_line].index); break; case HOTKEY_LINE_SHIP: case HOTKEY_LINE_SUBSHIP: hotkeys = Hotkey_bits[Hotkey_lines[Selected_line].index]; break; } if (hotkeys != -1) { if (hotkeys & (1 << Cur_hotkey)) remove_hotkey(); else add_hotkey(Cur_hotkey); } } } GR_MAYBE_CLEAR_RES(Background_bitmap); if (Background_bitmap >= 0) { gr_set_bitmap(Background_bitmap); gr_bitmap(0, 0, GR_RESIZE_MENU); } else gr_clear(); Ui_window.draw(); gr_init_color(&circle_color, 160, 160, 0); // draw the big "F10" in the little box font::set_font(font::FONT2); gr_set_color_fast(&Color_text_normal); strcpy_s(buf, Scan_code_text[Key_sets[Cur_hotkey]]); gr_get_string_size(&w, &h, buf); gr_printf_menu(Hotkey_function_name_coords[gr_screen.res][0] + (Hotkey_function_name_coords[gr_screen.res][2] - w) / 2, Hotkey_function_name_coords[gr_screen.res][1], buf); font::set_font(font::FONT1); line = Scroll_offset; while (hotkey_line_query_visible(line)) { z = Hotkey_lines[line].index; y = Hotkey_list_coords[gr_screen.res][1] + Hotkey_lines[line].y - Hotkey_lines[Scroll_offset].y; hotkeys = 0; switch (Hotkey_lines[line].type) { case HOTKEY_LINE_HEADING: gr_set_color_fast(&Color_text_heading); gr_get_string_size(&w, &h, Hotkey_lines[line].label); i = y + h / 2 - 1; gr_line(Hotkey_list_coords[gr_screen.res][0], i, Hotkey_ship_x[gr_screen.res] - 2, i, GR_RESIZE_MENU); gr_line(Hotkey_ship_x[gr_screen.res] + w + 1, i, Hotkey_list_coords[gr_screen.res][0] + Hotkey_list_coords[gr_screen.res][2], i, GR_RESIZE_MENU); break; case HOTKEY_LINE_WING: gr_set_bitmap(Wing_bmp); bm_get_info(Wing_bmp, NULL, &h, NULL); i = y + font_height / 2 - h / 2 - 1; gr_bitmap(Hotkey_wing_icon_x[gr_screen.res], i, GR_RESIZE_MENU); // i = y + font_height / 2 - 1; // gr_set_color_fast(&circle_color); // gr_circle(ICON_LIST_X + 4, i, 5, GR_RESIZE_MENU); // gr_set_color_fast(&Color_bright); // gr_line(ICON_LIST_X, i, ICON_LIST_X + 2, i, GR_RESIZE_MENU); // gr_line(ICON_LIST_X + 4, i - 4, ICON_LIST_X + 4, i - 2, GR_RESIZE_MENU); // gr_line(ICON_LIST_X + 6, i, ICON_LIST_X + 8, i, GR_RESIZE_MENU); // gr_line(ICON_LIST_X + 4, i + 2, ICON_LIST_X + 4, i + 4, GR_RESIZE_MENU); hotkeys = get_wing_hotkeys(Hotkey_lines[line].index); break; case HOTKEY_LINE_SHIP: case HOTKEY_LINE_SUBSHIP: hotkeys = Hotkey_bits[Hotkey_lines[line].index]; break; default: Int3(); } if (Hotkey_lines[line].type != HOTKEY_LINE_HEADING) { Assert( (line - Scroll_offset) < LIST_BUTTONS_MAX ); List_buttons[line - Scroll_offset].update_dimensions(Hotkey_list_coords[gr_screen.res][0], y, Hotkey_list_coords[gr_screen.res][0] + Hotkey_list_coords[gr_screen.res][2] - Hotkey_list_coords[gr_screen.res][0], font_height); List_buttons[line - Scroll_offset].enable(); if (hotkeys & (1 << Cur_hotkey)) { gr_set_color_fast(&Color_text_active); } else { if (line == Selected_line) gr_set_color_fast(&Color_text_selected); else if (line == select_tease_line) gr_set_color_fast(&Color_text_subselected); else gr_set_color_fast(&Color_text_normal); } } else { Assert( (line - Scroll_offset) < LIST_BUTTONS_MAX ); List_buttons[line - Scroll_offset].disable(); } // print active hotkeys associated for this line if (hotkeys) { for (i=0; i<MAX_KEYED_TARGETS; i++) { if (hotkeys & (1 << i)) { gr_printf_menu(Hotkey_list_coords[gr_screen.res][0] + Hotkey_function_field_width[gr_screen.res]*i, y, Scan_code_text[Key_sets[i]]); } } /* *buf = 0; for (i=0; i<MAX_KEYED_TARGETS; i++) { if (hotkeys & (1 << i)) { strcat_s(buf, Scan_code_text[Key_sets[i]]); strcat_s(buf, ", "); } } Assert(strlen(buf) > 1); buf[strlen(buf) - 2] = 0; // lose the ", " on the end font::force_fit_string(buf, 255, GROUP_LIST_W); gr_printf_menu(GROUP_LIST_X, y, buf);*/ } // draw ship/wing name strcpy_s(buf, Hotkey_lines[line].label); end_string_at_first_hash_symbol(buf); if (Hotkey_lines[line].type == HOTKEY_LINE_SUBSHIP) { // indent font::force_fit_string(buf, 255, Hotkey_list_coords[gr_screen.res][0] + Hotkey_list_coords[gr_screen.res][2] - (Hotkey_ship_x[gr_screen.res]+20)); gr_printf_menu(Hotkey_ship_x[gr_screen.res]+20, y, buf); } else { font::force_fit_string(buf, 255, Hotkey_list_coords[gr_screen.res][0] + Hotkey_list_coords[gr_screen.res][2] - Hotkey_ship_x[gr_screen.res]); gr_printf_menu(Hotkey_ship_x[gr_screen.res], y, buf); } line++; } i = line - Scroll_offset; while (i < LIST_BUTTONS_MAX) List_buttons[i++].disable(); // blit help overlay if active help_overlay_maybe_blit(Hotkey_overlay_id, gr_screen.res); gr_flip(); }
// initialize all chatbox details with the given mode flags int chatbox_create(int mode_flags) { int idx; // don't do anything if the chatbox is already initialized if (Chatbox_created){ return -1; } // probably shouldn't be using the chatbox in single player mode Assert(Game_mode & GM_MULTIPLAYER); // setup all data to correspond to our mode flags chatbox_set_mode(mode_flags); // initialize all low-level details related to chatting chatbox_chat_init(); // attempt to load in the chatbox background bitmap if(Chatbox_mode_flags & CHATBOX_FLAG_DRAW_BOX){ Chatbox_big_bitmap = bm_load(Chatbox_big_bitmap_fname[gr_screen.res]); Chatbox_small_bitmap = bm_load(Chatbox_small_bitmap_fname[gr_screen.res]); Chatbox_mp_bitmap = bm_load(Chatbox_p_bitmap_fname[gr_screen.res]); if(Chatbox_mode_flags & CHATBOX_FLAG_SMALL){ Chatbox_bitmap = Chatbox_small_bitmap; } else if(Chatbox_mode_flags & CHATBOX_FLAG_BIG){ Chatbox_bitmap = Chatbox_big_bitmap; } else { Chatbox_bitmap = Chatbox_mp_bitmap; } if((Chatbox_bitmap == -1) || (Chatbox_small_bitmap == -1) || (Chatbox_big_bitmap == -1) || (Chatbox_mp_bitmap == -1)){ return -1; } } // attempt to create the ui window for the chatbox and assign the mask Chat_window.create( 0, 0, gr_screen.max_w_unscaled, gr_screen.max_h_unscaled, 0 ); Chat_window.set_mask_bmap(Chatbox_mask); // create the chat text enter input area Chat_inputbox.create( &Chat_window, Chatbox_inputbox_x, Chatbox_textenter_y, Chatbox_inputbox_w, CHATBOX_MAX_LEN, "", UI_INPUTBOX_FLAG_INVIS | UI_INPUTBOX_FLAG_ESC_CLR | UI_INPUTBOX_FLAG_KEYTHRU | UI_INPUTBOX_FLAG_EAT_USED, Chatbox_w, Color_netplayer[MY_NET_PLAYER_NUM]); Chat_inputbox.set_focus(); Chat_inputbox.set_invalid_chars(CHATBOX_INVALID_CHARS); // if we're supposed to supply and check for out own buttons if((Chatbox_mode_flags & CHATBOX_FLAG_BUTTONS) && (Chatbox_mode_flags & CHATBOX_FLAG_DRAW_BOX)){ for(idx=0; idx<CHATBOX_NUM_BUTTONS; idx++){ // create the button Chatbox_buttons[gr_screen.res][idx].button.create(&Chat_window, "", Chatbox_buttons[gr_screen.res][idx].x, Chatbox_buttons[gr_screen.res][idx].y, 60, 30, (idx == CHATBOX_TOGGLE_SIZE) ? 0 : 1); // set the highlight action Chatbox_buttons[gr_screen.res][idx].button.set_highlight_action(common_play_highlight_sound); // set the bitmap Chatbox_buttons[gr_screen.res][idx].button.set_bmaps(Chatbox_buttons[gr_screen.res][idx].filename); // set the hotspot Chatbox_buttons[gr_screen.res][idx].button.link_hotspot(Chatbox_buttons[gr_screen.res][idx].hotspot); } // now create the toggle size button with the appropriate button if(Chatbox_mode_flags & CHATBOX_FLAG_SMALL){ Chatbox_buttons[gr_screen.res][CHATBOX_TOGGLE_SIZE].button.set_bmaps(Chatbox_buttons[gr_screen.res][CHATBOX_TOGGLE_SIZE].filename); } else { Chatbox_buttons[gr_screen.res][CHATBOX_TOGGLE_SIZE].button.set_bmaps(Chatbox_buttons[gr_screen.res][CHATBOX_TOGGLE_SIZE+1].filename); } } // an invisible button that will set focus to input box when clicked on Chat_enter_text.create( &Chat_window, "", 0, 0, 60, 30, 0); Chat_enter_text.hide(); // button doesn't show up Chat_enter_text.link_hotspot(50); Chatbox_created = 1; return 0; }
// --------------------------------------------------------------------- // mission_hotkey_init() // // Initialize the hotkey assignment screen system. Called when GS_STATE_HOTKEY_SCREEN // is entered. // void mission_hotkey_init() { int i; hotkey_buttons *b; // pause all weapon sounds weapon_pause_sounds(); // pause all game music audiostream_pause_all(); reset_hotkeys(); common_set_interface_palette(); // set the interface palette Ui_window.create(0, 0, gr_screen.max_w_unscaled, gr_screen.max_h_unscaled, 0); Ui_window.set_mask_bmap(Hotkey_mask_fname[gr_screen.res]); for (i=0; i<NUM_BUTTONS; i++) { b = &Buttons[gr_screen.res][i]; b->button.create(&Ui_window, "", b->x, b->y, 60, 30, i < 2 ? 1 : 0, 1); // set up callback for when a mouse first goes over a button b->button.set_highlight_action(common_play_highlight_sound); b->button.set_bmaps(b->filename); b->button.link_hotspot(b->hotspot); } // add all xstr text for(i=0; i<HOTKEY_NUM_TEXT; i++) { Ui_window.add_XSTR(&Hotkey_text[gr_screen.res][i]); } for (i=0; i<LIST_BUTTONS_MAX; i++) { List_buttons[i].create(&Ui_window, "", 0, 0, 60, 30, (i < 2), 1); List_buttons[i].hide(); List_buttons[i].disable(); } // set up hotkeys for buttons so we draw the correct animation frame when a key is pressed Buttons[gr_screen.res][SCROLL_UP_BUTTON].button.set_hotkey(KEY_PAGEUP); Buttons[gr_screen.res][SCROLL_DOWN_BUTTON].button.set_hotkey(KEY_PAGEDOWN); // ensure help overlay is off Hotkey_overlay_id = help_overlay_get_index(HOTKEY_OVERLAY); help_overlay_set_state(Hotkey_overlay_id,gr_screen.res,0); // load in relevant bitmaps Background_bitmap = bm_load(Hotkey_background_fname[gr_screen.res]); if (Background_bitmap < 0) { // bitmap didnt load -- this is bad Int3(); } Wing_bmp = bm_load("WingDesignator"); if (Wing_bmp < 0) { // bitmap didnt load -- this is bad Int3(); } Scroll_offset = 0; Selected_line = 1; hotkey_build_listing(); }
void cutscenes_screen_do_frame() { int i, k, y, z; int font_height = gr_get_font_height(); int select_tease_line = -1; k = Ui_window.process(); switch (k) { case KEY_DOWN: // select next line cutscenes_screen_scroll_line_down(); break; case KEY_UP: // select previous line cutscenes_screen_scroll_line_up(); break; case KEY_TAB: case KEY_CTRLED | KEY_DOWN: cutscenes_screen_button_pressed(CREDITS_BUTTON); break; case KEY_SHIFTED | KEY_TAB: case KEY_CTRLED | KEY_UP: cutscenes_screen_button_pressed(SIMULATOR_BUTTON); break; case KEY_ENTER: cutscenes_screen_play(); break; case KEY_ESC: // cancel gameseq_post_event(GS_EVENT_MAIN_MENU); game_flush(); break; case KEY_F1: // show help overlay break; case KEY_F2: // goto options screen gameseq_post_event(GS_EVENT_OPTIONS_MENU); break; // the "show-all" hotkey case KEY_CTRLED | KEY_SHIFTED | KEY_S: { Cutscene_list.clear(); size_t size = Cutscenes.size(); for (size_t t = 0; t < size; t++) { Cutscene_list.push_back((int)t); } break; } } // end switch for (i=0; i<NUM_BUTTONS; i++){ if (Buttons[gr_screen.res][i].button.pressed()){ if (cutscenes_screen_button_pressed(i)){ return; } } } if (List_region.button_down()) { List_region.get_mouse_pos(NULL, &y); z = Scroll_offset + y / font_height; if ((z >= 0) && (z < (int)Cutscene_list.size())) select_tease_line = z; } if (List_region.pressed()) { List_region.get_mouse_pos(NULL, &y); z = Scroll_offset + y / font_height; if ((z >= 0) && (z < (int)Cutscene_list.size())) Selected_line = z; } GR_MAYBE_CLEAR_RES(Background_bitmap); if (Background_bitmap >= 0) { gr_set_bitmap(Background_bitmap); gr_bitmap(0, 0); } Ui_window.draw(); for (i=TECH_DATABASE_BUTTON; i<=CREDITS_BUTTON; i++){ if (Buttons[gr_screen.res][i].button.button_down()){ break; } } if (i > CREDITS_BUTTON){ Buttons[gr_screen.res][CUTSCENES_BUTTON].button.draw_forced(2); } y = 0; z = Scroll_offset; while (y + font_height <= Cutscene_list_coords[gr_screen.res][3]) { if (z >= (int)Cutscene_list.size()){ break; } if (z == Selected_line){ gr_set_color_fast(&Color_text_selected); } else if (z == select_tease_line) { gr_set_color_fast(&Color_text_subselected); } else { gr_set_color_fast(&Color_text_normal); } gr_printf(Cutscene_list_coords[gr_screen.res][0], Cutscene_list_coords[gr_screen.res][1] + y, Cutscenes[Cutscene_list[z]].name); y += font_height; z++; } if (Description_index != Selected_line) { char *src = NULL; Description_index = Selected_line; Text_size = 0; if ( Description_index < (int)Cutscene_list.size( ) && (int)Cutscene_list[ Description_index ] < (int)Cutscenes.size( ) ) { src = Cutscenes[Cutscene_list[Description_index]].description; if (src) { Text_size = split_str(src, Cutscene_desc_coords[gr_screen.res][2], Text_line_size, Text_lines, Cutscene_max_text_lines[gr_screen.res]); Assert(Text_size >= 0 && Text_size < Cutscene_max_text_lines[gr_screen.res]); } } } if (Description_index >= 0) { int len; char line[MAX_TEXT_LINE_LEN + 1]; gr_set_color_fast(&Color_text_normal); y = 0; z = Text_offset; while (y + font_height <= Cutscene_desc_coords[gr_screen.res][3]) { if (z >= Text_size || z >= MAX_TEXT_LINES-1) break; len = Text_line_size[z]; if (len > MAX_TEXT_LINE_LEN) len = MAX_TEXT_LINE_LEN; strncpy(line, Text_lines[z], len); line[len] = 0; gr_string(Cutscene_desc_coords[gr_screen.res][0], Cutscene_desc_coords[gr_screen.res][1] + y, line); y += font_height; z++; } } gr_flip(); }
void hud_scrollback_do_frame(float frametime) { int i, k, x, y; int font_height = gr_get_font_height(); k = Ui_window.process(); switch (k) { case KEY_RIGHT: case KEY_TAB: if (Scrollback_mode == SCROLLBACK_MODE_OBJECTIVES) { Scrollback_mode = SCROLLBACK_MODE_MSGS_LOG; Scroll_max = hud_query_scrollback_size(); hud_scroll_reset(); } else if (Scrollback_mode == SCROLLBACK_MODE_MSGS_LOG) { Scrollback_mode = SCROLLBACK_MODE_EVENT_LOG; Scroll_max = Num_log_lines * gr_get_font_height(); hud_scroll_reset(); } else { Scrollback_mode = SCROLLBACK_MODE_OBJECTIVES; Scroll_max = Num_obj_lines * gr_get_font_height(); Scroll_offset = 0; } break; case KEY_LEFT: case KEY_SHIFTED | KEY_TAB: if (Scrollback_mode == SCROLLBACK_MODE_OBJECTIVES) { Scrollback_mode = SCROLLBACK_MODE_EVENT_LOG; Scroll_max = Num_log_lines * gr_get_font_height(); hud_scroll_reset(); } else if (Scrollback_mode == SCROLLBACK_MODE_MSGS_LOG) { Scrollback_mode = SCROLLBACK_MODE_OBJECTIVES; Scroll_max = Num_obj_lines * gr_get_font_height(); Scroll_offset = 0; } else { Scrollback_mode = SCROLLBACK_MODE_MSGS_LOG; Scroll_max = hud_query_scrollback_size(); hud_scroll_reset(); } break; case KEY_PAGEUP: hud_page_scroll_list(1); break; case KEY_PAGEDOWN: hud_page_scroll_list(0); break; case KEY_ENTER: case KEY_CTRLED | KEY_ENTER: case KEY_ESC: hud_scrollback_exit(); break; case KEY_F1: // show help overlay break; case KEY_F2: // goto options screen gameseq_post_event(GS_EVENT_OPTIONS_MENU); break; } // end switch for (i=0; i<NUM_BUTTONS; i++) { if (Buttons[gr_screen.res][i].button.pressed()) { hud_scrollback_button_pressed(i); } } GR_MAYBE_CLEAR_RES(Background_bitmap); if (Background_bitmap >= 0) { gr_set_bitmap(Background_bitmap); gr_bitmap(0, 0, GR_RESIZE_MENU); } /* if ((Scrollback_mode == SCROLLBACK_MODE_OBJECTIVES) && (Status_bitmap >= 0)) { gr_set_bitmap(Status_bitmap); gr_bitmap(Hud_mission_log_status_coords[gr_screen.res][0], Hud_mission_log_status_coords[gr_screen.res][1], GR_RESIZE_MENU); } */ // draw the objectives key at the bottom of the ingame objectives screen if (Scrollback_mode == SCROLLBACK_MODE_OBJECTIVES) { ML_render_objectives_key(); } Ui_window.draw(); if (Scrollback_mode == SCROLLBACK_MODE_EVENT_LOG) { Buttons[gr_screen.res][SHOW_EVENTS_BUTTON].button.draw_forced(2); mission_log_scrollback(Scroll_offset, Hud_mission_log_list_coords[gr_screen.res][0], Hud_mission_log_list_coords[gr_screen.res][1], Hud_mission_log_list_coords[gr_screen.res][2], Hud_mission_log_list_coords[gr_screen.res][3]); } else if (Scrollback_mode == SCROLLBACK_MODE_OBJECTIVES) { Buttons[gr_screen.res][SHOW_OBJS_BUTTON].button.draw_forced(2); ML_objectives_do_frame(Scroll_offset); } else { line_node *node_ptr; Buttons[gr_screen.res][SHOW_MSGS_BUTTON].button.draw_forced(2); // y = ((LIST_H / font_height) - 1) * font_height; y = 0; if ( !EMPTY(&Msg_scrollback_used_list) && HUD_msg_inited ) { node_ptr = GET_FIRST(&Msg_scrollback_used_list); i = 0; while ( node_ptr != END_OF_LIST(&Msg_scrollback_used_list) ) { if ((node_ptr->source == HUD_SOURCE_HIDDEN) || (i++ < Scroll_offset)) { node_ptr = GET_NEXT(node_ptr); } else { int team = HUD_source_get_team(node_ptr->source); if (team >= 0) { gr_set_color_fast(iff_get_color_by_team(team, Player_ship->team, 0)); } else { switch (node_ptr->source) { case HUD_SOURCE_TRAINING: gr_set_color_fast(&Color_bright_blue); break; case HUD_SOURCE_TERRAN_CMD: gr_set_color_fast(&Color_bright_white); break; case HUD_SOURCE_IMPORTANT: case HUD_SOURCE_FAILED: case HUD_SOURCE_SATISFIED: gr_set_color_fast(&Color_bright_white); break; default: gr_set_color_fast(&Color_text_normal); break; } } if (node_ptr->time) gr_print_timestamp(Hud_mission_log_list_coords[gr_screen.res][0], Hud_mission_log_list_coords[gr_screen.res][1] + y, node_ptr->time, GR_RESIZE_MENU); x = Hud_mission_log_list2_coords[gr_screen.res][0] + node_ptr->x; gr_printf_menu(x, Hud_mission_log_list_coords[gr_screen.res][1] + y, "%s", node_ptr->text); if (node_ptr->underline_width) gr_line(x, Hud_mission_log_list_coords[gr_screen.res][1] + y + font_height - 1, x + node_ptr->underline_width, Hud_mission_log_list_coords[gr_screen.res][1] + y + font_height - 1, GR_RESIZE_MENU); if ((node_ptr->source == HUD_SOURCE_FAILED) || (node_ptr->source == HUD_SOURCE_SATISFIED)) { // draw goal icon if (node_ptr->source == HUD_SOURCE_FAILED) gr_set_color_fast(&Color_bright_red); else gr_set_color_fast(&Color_bright_green); i = Hud_mission_log_list_coords[gr_screen.res][1] + y + font_height / 2 - 1; gr_circle(Hud_mission_log_list2_coords[gr_screen.res][0] - 6, i, 5, GR_RESIZE_MENU); gr_set_color_fast(&Color_bright); gr_line(Hud_mission_log_list2_coords[gr_screen.res][0] - 10, i, Hud_mission_log_list2_coords[gr_screen.res][0] - 8, i, GR_RESIZE_MENU); gr_line(Hud_mission_log_list2_coords[gr_screen.res][0] - 6, i - 4, Hud_mission_log_list2_coords[gr_screen.res][0] - 6, i - 2, GR_RESIZE_MENU); gr_line(Hud_mission_log_list2_coords[gr_screen.res][0] - 4, i, Hud_mission_log_list2_coords[gr_screen.res][0] - 2, i, GR_RESIZE_MENU); gr_line(Hud_mission_log_list2_coords[gr_screen.res][0] - 6, i + 2, Hud_mission_log_list2_coords[gr_screen.res][0] - 6, i + 4, GR_RESIZE_MENU); } y += font_height + node_ptr->y; node_ptr = GET_NEXT(node_ptr); if (y + font_height > Hud_mission_log_list_coords[gr_screen.res][3]) break; } } } } gr_set_color_fast(&Color_text_heading); gr_print_timestamp(Hud_mission_log_time_coords[gr_screen.res][0], Hud_mission_log_time_coords[gr_screen.res][1] - font_height, Missiontime, GR_RESIZE_MENU); gr_string(Hud_mission_log_time2_coords[gr_screen.res][0], Hud_mission_log_time_coords[gr_screen.res][1] - font_height, XSTR( "Current time", 289), GR_RESIZE_MENU); gr_flip(); }