void player_select_process_noninput(int k) { int idx; // check for pressed buttons for (idx=0; idx<NUM_PLAYER_SELECT_BUTTONS; idx++) { if (Player_select_buttons[gr_screen.res][idx].button.pressed()) { player_select_button_pressed(idx); } } // check for keypresses switch (k) { // quit the game entirely case KEY_ESC: gameseq_post_event(GS_EVENT_QUIT_GAME); break; case KEY_ENTER | KEY_CTRLED: player_select_button_pressed(ACCEPT_BUTTON); break; // delete the currently highlighted pilot case KEY_DELETE: player_select_button_pressed(DELETE_BUTTON); break; } // check to see if the user has clicked on the "list region" button // and change the selected pilot appropriately if (Player_select_list_region.pressed()) { int click_y; // get the mouse position Player_select_list_region.get_mouse_pos(NULL, &click_y); // determine what index to select //idx = (click_y+5) / 10; idx = click_y / gr_get_font_height(); // if he selected a valid item if ( ((idx + Player_select_list_start) < Player_select_num_pilots) && (idx >= 0) ) { Player_select_pilot = idx + Player_select_list_start; } } // if the player has double clicked on a valid pilot, choose it and hit the accept button if (Player_select_list_region.double_clicked()) { if ((Player_select_pilot >= 0) && (Player_select_pilot < Player_select_num_pilots)) { player_select_button_pressed(ACCEPT_BUTTON); } } }
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 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(); }
void player_select_process_noninput(int k) { int idx; // check for pressed buttons for (idx=0; idx<NUM_PLAYER_SELECT_BUTTONS; idx++) { if (Player_select_buttons[gr_screen.res][idx].button.pressed()) { player_select_button_pressed(idx); } } // check for keypresses switch (k) { // quit the game entirely case KEY_ESC: gameseq_post_event(GS_EVENT_QUIT_GAME); break; case KEY_ENTER | KEY_CTRLED: player_select_button_pressed(ACCEPT_BUTTON); break; // delete the currently highlighted pilot case KEY_DELETE: if (Player_select_pilot >= 0) { int ret; if (Player_select_mode == PLAYER_SELECT_MODE_MULTI) { popup(PF_TITLE_BIG | PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, XSTR("Pilots can only be deleted from the single player menu!", 1611)); } else { // display a popup requesting confirmation ret = popup(PF_USE_AFFIRMATIVE_ICON | PF_USE_NEGATIVE_ICON,2,POPUP_NO,POPUP_YES,XSTR( "Are you sure you want to delete this pilot?", 383)); // delete the pilot if (ret == 1) { player_select_delete_pilot(); } } } break; } // check to see if the user has clicked on the "list region" button // and change the selected pilot appropriately if (Player_select_list_region.pressed()) { int click_y; // get the mouse position Player_select_list_region.get_mouse_pos(NULL, &click_y); // determine what index to select //idx = (click_y+5) / 10; idx = click_y / gr_get_font_height(); // if he selected a valid item if ( ((idx + Player_select_list_start) < Player_select_num_pilots) && (idx >= 0) ) { Player_select_pilot = idx + Player_select_list_start; } } // if the player has double clicked on a valid pilot, choose it and hit the accept button if (Player_select_list_region.double_clicked()) { if ((Player_select_pilot >= 0) && (Player_select_pilot < Player_select_num_pilots)) { player_select_button_pressed(ACCEPT_BUTTON); } } }
void pilot_manage_do(void) { int k = Ui_window.process(); int i; if ( k > 0 ) { // put back in when overlay stuff is fixed // if ( help_overlay_active(PILOT_MANAGE_OVERLAY) ) { // help_overlay_set_state(PILOT_MANAGE_OVERLAY,0); // k = 0; // } } switch (k) { case KEY_ESC: // cancel only if not trying to enter a pilot name if (!pilot_manage_callsign_enter_mode) gameseq_post_event(GS_EVENT_BARRACKS_MENU);//GS_EVENT_PREVIOUS_STATE break; } // end switch int prospective_pilot = -1; // Entering pilot callsign if (pilot_manage_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]; } pilot_manage_set_callsign_enter_mode(false); break; case KEY_ENTER: pilot_manage_accept_new_pilot_callsign(); break; } } // process buttons for (i=0; i<PM_NUM_BUTTONS; i++) { if (Buttons[gr_screen.res][i].button.pressed()) { pilot_manage_button_pressed(i); } } // pilot that mouse is over // 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); } } gr_reset_clip(); GR_MAYBE_CLEAR_RES(Background_bitmap); if (Background_bitmap >= 0) { gr_set_bitmap(Background_bitmap); gr_bitmap(0, 0); } Ui_window.draw(); //light up the correct mode button (single or multi) if (Player_sel_mode == PLAYER_SELECT_MODE_SINGLE) { Buttons[gr_screen.res][PM_SINGLE_MODE_BUTTON].button.draw_forced(2); } else { Buttons[gr_screen.res][PM_MULTI_MODE_BUTTON].button.draw_forced(2); } pilot_manage_display_pilot_callsigns(prospective_pilot); pilot_manage_force_button_frame(); pilot_manage_maybe_show_button_text(); // needs to be fixed help_overlay_maybe_blit(PILOT_MANAGE_OVERLAY); gr_flip(); }