// show next squad pic void barracks_next_squad_pic() { // check if no squad images or no pilot selected if ((Num_pilot_squad_images == 0) || (Cur_pilot->callsign[0] == '\0')) { gamesnd_play_iface(SND_GENERAL_FAIL); return; } // reset squad pic number Pic_squad_number++; if (Pic_squad_number >= Num_pilot_squad_images){ Pic_squad_number = 0; } // copy squad pic filename into pilot struct if ((Pic_squad_number >= 0) && (Pic_squad_number < Num_pilot_squad_images)){ if (Game_mode & GM_MULTIPLAYER) { strcpy_s(Cur_pilot->m_squad_filename, Pilot_squad_image_names[Pic_squad_number]); } else { strcpy_s(Cur_pilot->s_squad_filename, Pilot_squad_image_names[Pic_squad_number]); } } // play scroll sound gamesnd_play_iface(SND_SCROLL); }
int credits_screen_button_pressed(int n) { switch (n) { case TECH_DATABASE_BUTTON: gamesnd_play_iface(SND_SWITCH_SCREENS); gameseq_post_event(GS_EVENT_TECH_MENU); return 1; case SIMULATOR_BUTTON: gamesnd_play_iface(SND_SWITCH_SCREENS); gameseq_post_event(GS_EVENT_SIMULATOR_ROOM); return 1; case CUTSCENES_BUTTON: gamesnd_play_iface(SND_SWITCH_SCREENS); gameseq_post_event(GS_EVENT_GOTO_VIEW_CUTSCENES_SCREEN); return 1; case EXIT_BUTTON: gamesnd_play_iface(SND_COMMIT_PRESSED); gameseq_post_event(GS_EVENT_MAIN_MENU); game_flush(); break; } return 0; }
// fire up the player info popup, select first available pilot if np == NULL void multi_pinfo_popup(net_player *np) { // if the popup is already running, don't do anything if(Multi_pinfo_popup_running){ return; } // set the player for informational purposes Assert(np != NULL); // play the popup appear sound gamesnd_play_iface(SND_POPUP_APPEAR); // initialize the popup multi_pinfo_popup_init(np); // mark the popup as running Multi_pinfo_popup_running = 1; // run the popup multi_pinfo_popup_do(); // close the popup multi_pinfo_popup_close(); // play the popup disappear sound gamesnd_play_iface(SND_POPUP_DISAPPEAR); }
void hud_page_scroll_list(int dir) { int max = hud_get_scroll_max_pos(); if (dir) { if (Scroll_offset) { hud_goto_pos(-Hud_mission_log_list_coords[gr_screen.res][3]); if (Scroll_offset < 0) Scroll_offset = 0; gamesnd_play_iface(SND_SCROLL); } else gamesnd_play_iface(SND_GENERAL_FAIL); } else { if (Scroll_offset < max) { hud_goto_pos(Hud_mission_log_list_coords[gr_screen.res][3]); if (Scroll_offset > max) Scroll_offset = max; gamesnd_play_iface(SND_SCROLL); } else gamesnd_play_iface(SND_GENERAL_FAIL); } }
// a button was pressed, deal with it void red_alert_button_pressed(int n) { switch (n) { case RA_CONTINUE: // warp the mouse cursor the the middle of the screen for those who control with a mouse mouse_set_pos( gr_screen.max_w/2, gr_screen.max_h/2 ); if(Game_mode & GM_MULTIPLAYER){ // process the initial orders now (moved from post_process_mission()in missionparse) mission_parse_fixup_players(); ai_post_process_mission(); } gameseq_post_event(GS_EVENT_ENTER_GAME); break; case RA_REPLAY_MISSION: if ( Game_mode & GM_CAMPAIGN_MODE ) { // TODO: make call to campaign code to set correct mission for loading // mission_campaign_play_previous_mission(Red_alert_precursor_mission); if ( !mission_campaign_previous_mission() ) { gamesnd_play_iface(SND_GENERAL_FAIL); break; } gameseq_post_event(GS_EVENT_START_GAME); } else { gamesnd_play_iface(SND_GENERAL_FAIL); } break; } }
void tech_scroll_list_down() { if (List_offset + Tech_list_coords[gr_screen.res][SHIP_H_COORD] / gr_get_font_height() < Current_list_size) { List_offset++; gamesnd_play_iface(SND_SCROLL); } else { gamesnd_play_iface(SND_GENERAL_FAIL); } }
// scroll up barracks stats list one line void barracks_scroll_stats_up() { if (Stats_scroll_offset > 0) { Stats_scroll_offset--; gamesnd_play_iface(SND_SCROLL); } else { gamesnd_play_iface(SND_GENERAL_FAIL); } }
void tech_scroll_info_up() { if (Text_offset) { Text_offset--; gamesnd_play_iface(SND_SCROLL); } else { gamesnd_play_iface(SND_GENERAL_FAIL); } }
// scroll down barracks stats list one line void barracks_scroll_stats_down() { int font_height = gr_get_font_height(); if (Stats_scroll_offset + Barracks_stats_coords[gr_screen.res][BARRACKS_H_COORD] / font_height < Num_stat_lines) { Stats_scroll_offset++; gamesnd_play_iface(SND_SCROLL); } else { gamesnd_play_iface(SND_GENERAL_FAIL); } }
void tech_scroll_list_up() { //int last; if (List_offset > 0) { List_offset--; gamesnd_play_iface(SND_SCROLL); } else { gamesnd_play_iface(SND_GENERAL_FAIL); } }
void cutscenes_screen_scroll_line_up() { if (Selected_line) { Selected_line--; gamesnd_play_iface(SND_SCROLL); } else gamesnd_play_iface(SND_GENERAL_FAIL); if (Selected_line < Scroll_offset) Scroll_offset = Selected_line; }
// scroll up barracks pilot list one line void barracks_scroll_callsign_up() { if (Selected_line > 0) { Selected_line--; gamesnd_play_iface(SND_SCROLL); } else { gamesnd_play_iface(SND_GENERAL_FAIL); } if ((Selected_line >= 0) && (Selected_line < List_scroll_offset)) { List_scroll_offset = Selected_line; } }
void fiction_viewer_scroll_up() { Top_fiction_viewer_text_line--; if (Top_fiction_viewer_text_line < 0) { Top_fiction_viewer_text_line = 0; gamesnd_play_iface(SND_GENERAL_FAIL); } else { gamesnd_play_iface(SND_SCROLL); } }
void tech_scroll_info_down() { int h; h = Tech_desc_coords[gr_screen.res][SHIP_H_COORD]; if (Text_offset + h / gr_get_font_height() < Text_size) { Text_offset++; gamesnd_play_iface(SND_SCROLL); } else { //-V523 gamesnd_play_iface(SND_GENERAL_FAIL); } }
void fiction_viewer_scroll_down() { Top_fiction_viewer_text_line++; if ((Num_brief_text_lines[0] - Top_fiction_viewer_text_line) < Fiction_viewer_text_max_lines) { Top_fiction_viewer_text_line--; gamesnd_play_iface(SND_GENERAL_FAIL); } else { gamesnd_play_iface(SND_SCROLL); } }
void hotkey_scroll_screen_up() { if (Scroll_offset) { Scroll_offset--; Assert(Selected_line > Scroll_offset); while (!hotkey_line_query_visible(Selected_line) || (Hotkey_lines[Selected_line].type == HOTKEY_LINE_HEADING)) Selected_line--; gamesnd_play_iface(SND_SCROLL); } else gamesnd_play_iface(SND_GENERAL_FAIL); }
void UI_DOT_SLIDER::process(int focus) { if (disabled_flag) return; // check focus and derived focus with one variable if (my_wnd->selected_gadget == this) focus = 1; // first check the dot area button.process(focus); if (button.button_down() || button.pressed() || mouse_captured()) { capture_mouse(); // while we are changing level, ignore all other buttons if ( has_end_buttons ) { pos = (ui_mouse.x - x + 17) / 19; } else { pos = (ui_mouse.x - x) / 19; } if (pos < 0){ pos = 0; } if ( pos > num_pos ){ pos = num_pos; } return; } if ( has_end_buttons ) { up_button.process(focus); if (up_button.pressed()) { if (pos < num_pos){ pos++; } else { gamesnd_play_iface(SND_GENERAL_FAIL); } } down_button.process(focus); if (down_button.pressed()) { if (pos){ pos--; } else { gamesnd_play_iface(SND_GENERAL_FAIL); } } } }
// scroll the list of players down void player_select_scroll_list_down() { // change the pilot selected index and play the appropriate sound if ( Player_select_pilot < Player_select_num_pilots - 1 ) { Player_select_pilot++; gamesnd_play_iface(SND_SCROLL); } else { gamesnd_play_iface(SND_GENERAL_FAIL); } if ( Player_select_pilot >= (Player_select_list_start + Max_lines) ) { Player_select_list_start++; } }
void hotkey_scroll_screen_down() { if (Hotkey_lines[Num_lines - 1].y + gr_get_font_height() > Hotkey_lines[Scroll_offset].y + Hotkey_list_coords[gr_screen.res][3]) { Scroll_offset++; while (!hotkey_line_query_visible(Selected_line) || (Hotkey_lines[Selected_line].type == HOTKEY_LINE_HEADING)) { Selected_line++; Assert(Selected_line < Num_lines); } gamesnd_play_iface(SND_SCROLL); } else gamesnd_play_iface(SND_GENERAL_FAIL); }
// scroll down barracks pilot list one line void barracks_scroll_callsign_down() { if (Selected_line < Num_pilots - 1) { Selected_line++; gamesnd_play_iface(SND_SCROLL); } else { gamesnd_play_iface(SND_GENERAL_FAIL); } // num_pilots_to_fill_height is the number of pilots that can fit in given height int num_pilots_to_fill_height = Barracks_list_coords[gr_screen.res][BARRACKS_H_COORD] / gr_get_font_height(); if (Selected_line >= List_scroll_offset + num_pilots_to_fill_height) { List_scroll_offset++; } }
void hotkey_scroll_line_up() { if (Selected_line > 1) { Selected_line--; while (Hotkey_lines[Selected_line].type == HOTKEY_LINE_HEADING) Selected_line--; if (Selected_line < Scroll_offset) Scroll_offset = Selected_line; gamesnd_play_iface(SND_SCROLL); } else gamesnd_play_iface(SND_GENERAL_FAIL); }
void hotkey_scroll_line_down() { if (Selected_line < Num_lines - 1) { Selected_line++; while (Hotkey_lines[Selected_line].type == HOTKEY_LINE_HEADING) Selected_line++; Assert(Selected_line > Scroll_offset); while (!hotkey_line_query_visible(Selected_line)) Scroll_offset++; gamesnd_play_iface(SND_SCROLL); } else gamesnd_play_iface(SND_GENERAL_FAIL); }
// maybe play a sound when key up/down is pressed to switch default choice void popup_play_default_change_sound(popup_info *pi) { if ( pi->nchoices > 1 ) { int i, mouse_over=0; UI_BUTTON *br, *b; // only play if mouse not currently highlighting a choice for ( i = 0; i < pi->nchoices; i++ ) { br = &Popup_button_regions[i]; b = &Popup_buttons[i]; if ( br->button_down() ) { mouse_over=1; break; } if ( br->button_hilighted() && !b->button_down() ) { mouse_over=1; break; } if ( b->button_hilighted() ) { mouse_over=1; } } if (!mouse_over) { gamesnd_play_iface(SND_USER_SELECT); } } }
// called when a popup goes away void popup_close(popup_info *pi, int screen_id) { int i; gamesnd_play_iface(SND_POPUP_DISAPPEAR); // play sound when popup disappears for (i=0; i<pi->nchoices; i++ ) { if ( pi->button_text[i] != NULL ) { vm_free(pi->button_text[i]); pi->button_text[i] = NULL; } } if(screen_id >= 0){ gr_free_screen(screen_id); } Popup_window.destroy(); anim_ignore_next_frametime(); // to avoid skips in animation since next frametime is saturated game_flush(); Popup_is_active = 0; Popup_running_state = 0; // 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_start_time(); }
// select previous entry in current list void tech_prev_entry() { //unload the current animation, we load another one for the new current entry techroom_unload_animation(); Cur_entry--; if (Cur_entry < 0) { Cur_entry = Current_list_size - 1; // scroll to end of list List_offset = Cur_entry - Tech_list_coords[gr_screen.res][SHIP_H_COORD] / gr_get_font_height() + 1; if (List_offset < 0) { // this happens when there are not enough items to scroll List_offset = 0; } Tech_slider.force_currentItem(Tech_slider.get_numberItems()); } else { // maybe adjust list position by 1 if (List_offset > Cur_entry) { tech_scroll_list_up(); Tech_slider.forceUp(); } } techroom_select_new_entry(); gamesnd_play_iface(SND_SCROLL); }
void cutscenes_screen_scroll_screen_down() { int h; h = Cutscene_list_coords[gr_screen.res][3] / gr_get_font_height(); if (Scroll_offset + h < (int)Cutscene_list.size()) { Scroll_offset++; if (Selected_line < Scroll_offset){ Selected_line = Scroll_offset; } gamesnd_play_iface(SND_SCROLL); } else { gamesnd_play_iface(SND_GENERAL_FAIL); } }
void cutscenes_screen_scroll_line_down() { int h; if (Selected_line < Num_files - 1) { Selected_line++; gamesnd_play_iface(SND_SCROLL); } else gamesnd_play_iface(SND_GENERAL_FAIL); h = Cutscene_list_coords[gr_screen.res][3] / gr_get_font_height(); if (Selected_line >= Scroll_offset + h){ Scroll_offset++; } }
// called when proceeding to the next help page void gameplay_help_goto_next_screen() { Current_help_page++; if (Current_help_page > Gp_last_screen) { Current_help_page = GP_FIRST_SCREEN; } gamesnd_play_iface(SND_SWITCH_SCREENS); }
void chatbox_toggle_size() { // if we're in "small" mode if(Chatbox_mode_flags & CHATBOX_FLAG_SMALL){ chatbox_force_big(); // play a sound gamesnd_play_iface(SND_IFACE_MOUSE_CLICK); } // if we're in "big" mode else if(Chatbox_mode_flags & CHATBOX_FLAG_BIG){ chatbox_force_small(); // play a sound gamesnd_play_iface(SND_IFACE_MOUSE_CLICK); } }
void cutscenes_screen_scroll_screen_up() { int h; if (Scroll_offset) { Scroll_offset--; Assert(Selected_line > Scroll_offset); h = Cutscene_list_coords[gr_screen.res][3] / gr_get_font_height(); while (Selected_line >= Scroll_offset + h){ Selected_line--; } gamesnd_play_iface(SND_SCROLL); } else { gamesnd_play_iface(SND_GENERAL_FAIL); } }