// Figure out the y-coord to start drawing the popup text. The text // is centered vertically within the popup. int popup_calc_starting_y(popup_info *pi, int flags) { int sy, total_h=0; int num_lines = pi->nlines > Popup_max_display[gr_screen.res] ? Popup_max_display[gr_screen.res] : pi->nlines; if ( flags & (PF_TITLE | PF_TITLE_BIG) ) { if ( flags & PF_TITLE_BIG ) { gr_set_font(FONT2); } else { gr_set_font(FONT1); } total_h += gr_get_font_height(); } if ( flags & PF_BODY_BIG ) { gr_set_font(FONT2); } else { gr_set_font(FONT1); } total_h += num_lines * gr_get_font_height(); sy = fl2i((Popup_text_coords[gr_screen.res][1] + Popup_text_coords[gr_screen.res][3]/2.0f) - total_h/2.0f + 0.5f); // if this is an input style box, add in some y if(flags & PF_INPUT){ sy += Popup_input_text_y_offset[gr_screen.res]; } return sy; }
// draw copyright message on the bottom on the screen void player_select_display_copyright() { int sx, sy, w; char Copyright_msg1[256], Copyright_msg2[256]; // strcpy_s(Copyright_msg1, XSTR("Descent: FreeSpace - The Great War, Copyright c 1998, Volition, Inc.", -1)); gr_set_color_fast(&Color_white); // sprintf(Copyright_msg1, NOX("FreeSpace 2")); get_version_string(Copyright_msg1, sizeof(Copyright_msg1)); if (Unicode_text_mode) { // Use a Unicode character if we are in unicode mode instead of using special characters strcpy_s(Copyright_msg2, XSTR("Copyright \xC2\xA9 1999, Volition, Inc. All rights reserved.", 385)); } else { sprintf(Copyright_msg2, XSTR("Copyright %c 1999, Volition, Inc. All rights reserved.", 385), lcl_get_font_index(font::get_current_fontnum()) + 4); } gr_get_string_size(&w, NULL, Copyright_msg1); sx = fl2i((gr_screen.max_w_unscaled / 2) - w/2.0f + 0.5f); sy = (gr_screen.max_h_unscaled - 2) - 2*gr_get_font_height(); gr_string(sx, sy, Copyright_msg1, GR_RESIZE_MENU); gr_get_string_size(&w, NULL, Copyright_msg2); sx = fl2i((gr_screen.max_w_unscaled / 2) - w/2.0f + 0.5f); sy = (gr_screen.max_h_unscaled - 2) - gr_get_font_height(); gr_string(sx, sy, Copyright_msg2, GR_RESIZE_MENU); }
void hud_scrollback_button_pressed(int n) { switch (n) { case SCROLL_UP_BUTTON: hud_scroll_list(1); break; case SCROLL_DOWN_BUTTON: hud_scroll_list(0); break; case SHOW_MSGS_BUTTON: Scrollback_mode = SCROLLBACK_MODE_MSGS_LOG; Scroll_max = hud_query_scrollback_size(); hud_scroll_reset(); break; case SHOW_EVENTS_BUTTON: Scrollback_mode = SCROLLBACK_MODE_EVENT_LOG; Scroll_max = Num_log_lines * gr_get_font_height(); hud_scroll_reset(); break; case SHOW_OBJS_BUTTON: Scrollback_mode = SCROLLBACK_MODE_OBJECTIVES; Scroll_max = Num_obj_lines * gr_get_font_height(); Scroll_offset = 0; break; case ACCEPT_BUTTON: hud_scrollback_exit(); break; } }
// draw copyright message on the bottom on the screen void player_select_display_copyright() { int sx, sy, w; char Copyright_msg1[256], Copyright_msg2[256]; // strcpy_s(Copyright_msg1, XSTR("Descent: FreeSpace - The Great War, Copyright c 1998, Volition, Inc.", -1)); gr_set_color_fast(&Color_white); // sprintf(Copyright_msg1, NOX("FreeSpace 2")); get_version_string(Copyright_msg1, sizeof(Copyright_msg1)); if (Lcl_gr) { sprintf(Copyright_msg2, XSTR("Copyright %c 1999, Volition, Inc. All rights reserved.", 385), '\xA8'); } else { sprintf(Copyright_msg2, XSTR("Copyright %c 1999, Volition, Inc. All rights reserved.", 385), '\x83'); } gr_get_string_size(&w, NULL, Copyright_msg1); sx = fl2i((gr_screen.max_w_unscaled / 2) - w/2.0f + 0.5f); sy = (gr_screen.max_h_unscaled - 2) - 2*gr_get_font_height(); gr_string(sx, sy, Copyright_msg1, GR_RESIZE_MENU); gr_get_string_size(&w, NULL, Copyright_msg2); sx = fl2i((gr_screen.max_w_unscaled / 2) - w/2.0f + 0.5f); sy = (gr_screen.max_h_unscaled - 2) - gr_get_font_height(); gr_string(sx, sy, Copyright_msg2, GR_RESIZE_MENU); }
void player_select_draw_list() { int idx; if (gr_screen.res == 1) { Max_lines = 145/gr_get_font_height(); //Make the max number of lines dependent on the font height. 145 and 85 are magic numbers, based on the window size in retail. } else { Max_lines = 85/gr_get_font_height(); } for (idx=0; idx<Max_lines; idx++) { // only draw as many pilots as we have if ((idx + Player_select_list_start) == Player_select_num_pilots) { break; } // if the currently selected pilot is this line, draw it highlighted if ( (idx + Player_select_list_start) == Player_select_pilot) { // if he's the active pilot and is also the current selection, super-highlight him gr_set_color_fast(&Color_text_active); } else { // otherwise draw him normally gr_set_color_fast(&Color_text_normal); } // draw the actual callsign gr_printf_menu(Choose_list_coords[gr_screen.res][0], Choose_list_coords[gr_screen.res][1] + (idx * gr_get_font_height()), Pilots[idx + Player_select_list_start]); } }
void hud_scrollback_init() { int i; scrollback_buttons *b; // pause all game sounds beam_pause_sounds(); audiostream_pause_all(); common_set_interface_palette("BriefingPalette"); // set the interface palette Ui_window.create(0, 0, gr_screen.max_w, gr_screen.max_h, 0); Ui_window.set_mask_bmap(Hud_mission_log_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); // 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 strings #ifndef MAKE_FS1 Ui_window.add_XSTR("Continue", 1069, Buttons[gr_screen.res][ACCEPT_BUTTON].xt, Buttons[gr_screen.res][ACCEPT_BUTTON].yt, &Buttons[gr_screen.res][ACCEPT_BUTTON].button, UI_XSTR_COLOR_PINK); Ui_window.add_XSTR("Events", 1070, Buttons[gr_screen.res][SHOW_EVENTS_BUTTON].xt, Buttons[gr_screen.res][SHOW_EVENTS_BUTTON].yt, &Buttons[gr_screen.res][SHOW_EVENTS_BUTTON].button, UI_XSTR_COLOR_GREEN); Ui_window.add_XSTR("Objectives", 1071, Buttons[gr_screen.res][SHOW_OBJS_BUTTON].xt, Buttons[gr_screen.res][SHOW_OBJS_BUTTON].yt, &Buttons[gr_screen.res][SHOW_OBJS_BUTTON].button, UI_XSTR_COLOR_GREEN); Ui_window.add_XSTR("Messages", 1072, Buttons[gr_screen.res][SHOW_MSGS_BUTTON].xt, Buttons[gr_screen.res][SHOW_MSGS_BUTTON].yt, &Buttons[gr_screen.res][SHOW_MSGS_BUTTON].button, UI_XSTR_COLOR_GREEN); #endif // 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_UP); Buttons[gr_screen.res][SCROLL_DOWN_BUTTON].button.set_hotkey(KEY_DOWN); Background_bitmap = bm_load(Hud_mission_log_fname[gr_screen.res]); #ifdef MAKE_FS1 Status_bitmap = bm_load(Hud_mission_log_status_fname[gr_screen.res]); #endif message_log_init_scrollback(Hud_mission_log_list_coords[gr_screen.res][2]); if (Scrollback_mode == SCROLLBACK_MODE_EVENT_LOG) Scroll_max = Num_log_lines * gr_get_font_height(); else if (Scrollback_mode == SCROLLBACK_MODE_OBJECTIVES) Scroll_max = Num_obj_lines * gr_get_font_height(); else Scroll_max = hud_query_scrollback_size(); Num_obj_lines = ML_objectives_init(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_objective_x_coord[gr_screen.res]); hud_scroll_reset(); }
// 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 barracks_display_pilot_callsigns(int prospective_pilot) { int y = 0; int cur_pilot_idx = List_scroll_offset; int multi = 0; if (Player_sel_mode == PLAYER_SELECT_MODE_MULTI) { multi = 1; } int font_height = gr_get_font_height(); while (y + font_height <= Barracks_list_coords[gr_screen.res][BARRACKS_H_COORD]) { if (cur_pilot_idx >= Num_pilots) break; if (!stricmp(Cur_pilot->callsign, Pilots[cur_pilot_idx]) && multi) { gr_set_color_fast(&Color_text_active); } else { if (cur_pilot_idx == Selected_line) { gr_set_color_fast(&Color_text_selected); } else if (cur_pilot_idx == prospective_pilot) { gr_set_color_fast(&Color_text_subselected); } else { gr_set_color_fast(&Color_text_normal); } } gr_printf_menu(Barracks_list_coords[gr_screen.res][BARRACKS_X_COORD], Barracks_list_coords[gr_screen.res][BARRACKS_Y_COORD] + y, Pilots[cur_pilot_idx]); gr_set_bitmap(Rank_pips_bitmaps + Pilot_ranks[cur_pilot_idx]); gr_bitmap(Barracks_list_coords[gr_screen.res][BARRACKS_X_COORD] - 34, Barracks_list_coords[gr_screen.res][BARRACKS_Y_COORD] + y, GR_RESIZE_MENU); y += font_height; cur_pilot_idx++; } }
void stats_underline_text(int sx, int sy, char *text) { int w,h,fh; gr_get_string_size(&w,&h,text); fh=gr_get_font_height(); gr_line(sx-1, sy+fh, sx+w+1, sy+fh); }
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); } }
// game_play_help_set_title() will display the title for the help screen and // set the font for the rest of the screen void gameplay_help_set_title(const char *title) { int sy=TITLE_Y; char buf[128]; gr_set_color_fast(&Color_bright); gr_printf_menu(0x8000,sy,title); sprintf(buf, XSTR( "Page %d of %d", 132), Current_help_page+1, Gp_last_screen+1); gr_printf_menu(0x8000,sy+gr_get_font_height()+2,buf); gr_set_color_fast(&Color_normal); }
// 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); } }
// ---------------------------------------------------------------------- // hud_init_msg_window() // // Called from HUD_init(), which is called from game_level_init() // void hud_init_msg_window() { int i, h; MSG_WINDOW_WIDTH = gr_screen.clip_width - 20; Hud_list_start = 0; Hud_list_end = 0; for (i=0; i<SCROLL_BUFFER_LINES; i++) HUD_pending[i].text[0] = HUD_pending[i].text[MAX_HUD_LINE_LEN - 1] = 0; for ( i=0; i < MAX_ACTIVE_BUFFER_LINES; i++ ) { HUD_active_msgs_list[i].total_life = 1; } Scroll_time_id = 1; // determine the height of the msg window, which depends on the font height gr_set_font(FONT1); h = gr_get_font_height(); //ACTIVE_BUFFER_LINES = Players[Player_num].HUD_config.num_msg_window_lines; // ACTIVE_BUFFER_LINES = HUD_config.num_msg_window_lines; ACTIVE_BUFFER_LINES = 4; MSG_WINDOW_FONT_HEIGHT = h; MSG_WINDOW_HEIGHT = MSG_WINDOW_FONT_HEIGHT * (ACTIVE_BUFFER_LINES-1); // starting a mission, free the scroll-back buffers, but only if we've been // through this function once already if ( HUD_msg_inited == TRUE ) { hud_free_scrollback_list(); } list_init( &Msg_scrollback_free_list ); list_init( &Msg_scrollback_used_list ); // first slot is reserved for dummy node for (i=1; i < MAX_MSG_SCROLLBACK_LINES; i++) { Msg_scrollback_lines[i].text = NULL; list_append(&Msg_scrollback_free_list, &Msg_scrollback_lines[i]); } Active_index=0; Scroll_needed=0; Scroll_in_progress=0; OLD_ACTIVE_BUFFER_LINES = ACTIVE_BUFFER_LINES; HUD_init_fixed_text(); HUD_msg_inited = TRUE; }
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); } } }
int hotkey_line_query_visible(int n) { int y; if ((n < 0) || (n >= Num_lines)) return 0; y = Hotkey_lines[n].y - Hotkey_lines[Scroll_offset].y; if ((y < 0) || (y + gr_get_font_height() > Hotkey_list_coords[gr_screen.res][3])) return 0; return 1; }
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); } }
// called once a frame during show goals state to process events and render the screen void mission_show_goals_do_frame(float frametime) { int k, i, y, z; int font_height = gr_get_font_height(); k = Goals_screen_ui_window.process(); switch (k) { case KEY_ESC: mission_goal_exit(); break; case KEY_DOWN: goal_screen_scroll_down(); break; case KEY_UP: goal_screen_scroll_up(); break; default: // do nothing break; } // end switch for (i=0; i<NUM_GOAL_SCREEN_BUTTONS; i++){ if (Goal_buttons[i].button.pressed()){ goal_screen_button_pressed(i); } } GR_MAYBE_CLEAR_RES(Goals_screen_bg_bitmap); if (Goals_screen_bg_bitmap >= 0) { gr_set_bitmap(Goals_screen_bg_bitmap); gr_bitmap(0, 0, GR_RESIZE_MENU); } Goals_screen_ui_window.draw(); y = 0; z = Scroll_offset; while (y + font_height <= Goal_screen_text_h) { Goal_text.display(z, y); y += font_height; z++; } Primary_goal_list.icons_display(Scroll_offset); Secondary_goal_list.icons_display(Scroll_offset); Bonus_goal_list.icons_display(Scroll_offset); gr_flip(); }
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); }
// renders the stuff common to all 3 tech room tabs void tech_common_render() { char buf[256]; int y, z, font_height; // render description in its box gr_set_color_fast(&Color_text_normal); techroom_render_desc(Tech_desc_coords[gr_screen.res][SHIP_X_COORD], Tech_desc_coords[gr_screen.res][SHIP_Y_COORD], Tech_desc_coords[gr_screen.res][SHIP_H_COORD]); font_height = gr_get_font_height(); // draw the list of entries y = 0; z = List_offset; while (y + font_height <= Tech_list_coords[gr_screen.res][SHIP_H_COORD]) { if (z >= Current_list_size) { break; } if (z == Cur_entry) { 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); } memset( buf, 0, sizeof(buf) ); strncpy(buf, Current_list[z].name, sizeof(buf) - 1); if (Lcl_gr) lcl_translate_ship_name_gr(buf); gr_force_fit_string(buf, 255, Tech_list_coords[gr_screen.res][SHIP_W_COORD]); gr_string(Tech_list_coords[gr_screen.res][SHIP_X_COORD], Tech_list_coords[gr_screen.res][SHIP_Y_COORD] + y, buf, GR_RESIZE_MENU); List_buttons[z - List_offset].update_dimensions(Tech_list_coords[gr_screen.res][SHIP_X_COORD], Tech_list_coords[gr_screen.res][SHIP_Y_COORD] + y, Tech_list_coords[gr_screen.res][SHIP_W_COORD], font_height); List_buttons[z - List_offset].enable(1); y += font_height; z++; } // disable the rest of the list buttons z -= List_offset; while (z < LIST_BUTTONS_MAX) { List_buttons[z++].disable(); } }
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++; } }
// game_play_help_set_title() will display the title for the help screen and // set the font for the rest of the screen void gameplay_help_set_title(const char *title) { int sy=TITLE_Y; char buf[128]; gr_set_color_fast(&Color_bright); int w; gr_get_string_size(&w, NULL, title); gr_printf_menu((gr_screen.clip_width_unscaled - w) / 2,sy,"%s", title); sprintf(buf, XSTR("Page %d of %d", 132), Current_help_page + 1, Gp_last_screen + 1); gr_get_string_size(&w, NULL, buf); gr_printf_menu((gr_screen.clip_width_unscaled - w) / 2, sy + gr_get_font_height() + 2, "%s", buf); gr_set_color_fast(&Color_normal); }
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); } }
// Draw the message text nicely formatted in the popup void popup_draw_msg_text(popup_info *pi, int flags) { int sx, sy, i, w, h; int line_index; int line_count; // figure out the starting display line_index = popup_calc_starting_index(pi); // figure out the starting y: sy = popup_calc_starting_y(pi, flags); // draw title if required if ( flags & (PF_TITLE | PF_TITLE_BIG) ) { popup_draw_title(sy, pi->title, flags); sy += gr_get_font_height(); } // draw body if ( flags & PF_BODY_BIG ) { gr_set_font(FONT2); } else { gr_set_font(FONT1); } popup_set_text_color(flags); line_count = 0; for ( i = line_index; i < pi->nlines; i++, line_count++ ) { // if we've already displayed the max # of lines if(line_count >= Popup_max_display[gr_screen.res]){ break; } gr_get_string_size(&w, &h, pi->msg_lines[i]); sx = fl2i(Title_coords[gr_screen.res][4] - w/2.0f + 0.5f); gr_string(sx, sy + line_count * h, pi->msg_lines[i], GR_RESIZE_MENU); } // maybe draw "more" h = 10; if(i < pi->nlines){ gr_set_color_fast(&Color_more_bright); gr_string(Title_coords[gr_screen.res][4], sy + (Popup_max_display[gr_screen.res]) * h, XSTR("More", 459), GR_RESIZE_MENU); } gr_set_font(FONT1); // reset back to regular font size }
void HudGaugeThrottle::renderMatchSpeedIcon(int x, int y) { if (Match_speed_draw_background) { // One pixel boundary renderRect(x, y, Match_speed_icon_width + 2, gr_get_font_height() + 2); gr_set_color_fast(&Color_black); renderPrintf(x + 1, y + 1, "%c", Match_speed_icon); setGaugeColor(); } else { renderPrintf(x, y, "%c", Match_speed_icon); } }
void ML_objectives_do_frame(int scroll_offset) { int y, z; int font_height = gr_get_font_height(); y = 0; z = scroll_offset; while (y + font_height <= Goal_screen_text_h) { Goal_text.display(z, y); y += font_height; z++; } Primary_goal_list.icons_display(scroll_offset); Secondary_goal_list.icons_display(scroll_offset); Bonus_goal_list.icons_display(scroll_offset); }
// how many lines to skip int hud_get_scroll_max_pos() { int max = 0, font_height = gr_get_font_height(); if (Scrollback_mode == SCROLLBACK_MODE_MSGS_LOG) { int count = 0; line_node *ptr; // number of pixels in excess of what can be displayed int excess = Scroll_max - Hud_mission_log_list_coords[gr_screen.res][3]; if (EMPTY(&Msg_scrollback_used_list) || !HUD_msg_inited) { max = 0; } else { ptr = GET_FIRST(&Msg_scrollback_used_list); while (ptr != END_OF_LIST(&Msg_scrollback_used_list)) { if (ptr->source != HUD_SOURCE_HIDDEN) { if (excess > 0) { excess -= font_height; count++; } if (excess <= 0) { max = count; break; } // spacing between lines excess -= ptr->y; } ptr = GET_NEXT(ptr); } } } else { max = (Scroll_max - Hud_mission_log_list_coords[gr_screen.res][3]) / font_height; } if (max < 0) max = 0; return max; }
void hud_goto_pos(int delta) { int pos=0, font_height = gr_get_font_height(); if (Scrollback_mode == SCROLLBACK_MODE_MSGS_LOG) { int count = 0, y = 0; line_node *ptr; if (EMPTY(&Msg_scrollback_used_list) || !HUD_msg_inited) return; ptr = GET_FIRST(&Msg_scrollback_used_list); while (ptr != END_OF_LIST(&Msg_scrollback_used_list)) { if (ptr->source != HUD_SOURCE_HIDDEN) { if (count == Scroll_offset) { pos = y; break; } y += font_height + ptr->y; count++; } ptr = GET_NEXT(ptr); } Scroll_offset = count = y = 0; ptr = GET_FIRST(&Msg_scrollback_used_list); while (ptr != END_OF_LIST(&Msg_scrollback_used_list)) { if (ptr->source != HUD_SOURCE_HIDDEN) { if (y <= pos + delta) Scroll_offset = count; y += font_height + ptr->y; count++; } ptr = GET_NEXT(ptr); } } else { pos = Scroll_offset * font_height; pos += delta; Scroll_offset = pos / font_height; } }
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); } }
// write out the current description in the bottom window void techroom_render_desc(int xo, int yo, int ho) { int y, z, len, font_height; char line[MAX_TEXT_LINE_LEN + 1]; font_height = gr_get_font_height(); y = 0; z = Text_offset; while (y + font_height <= ho) { if (z >= Text_size){ 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(xo, yo + y, line, GR_RESIZE_MENU); y += font_height; z++; } // maybe output 'more' indicator if ( z < Text_size ) { // can be scrolled down int more_txt_x = Tech_desc_coords[gr_screen.res][0] + (Tech_desc_coords[gr_screen.res][2]/2) - 10; // FIXME should move these to constants since they don't move int more_txt_y = Tech_desc_coords[gr_screen.res][1] + Tech_desc_coords[gr_screen.res][3]; // located below brief text, centered int w, h; 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? } }
void pilot_manage_display_pilot_callsigns(int prospective_pilot) { int y = 0; int cur_pilot_idx = List_scroll_offset; int multi = 0; if (Player_sel_mode == PLAYER_SELECT_MODE_MULTI) { multi = 1; } int font_height = gr_get_font_height(); //cur_pilot_idx = 1; while (y + font_height <= Pilot_manage_list_coords[gr_screen.res][PM_H_COORD]) { if (cur_pilot_idx >= Num_pilots) break; if (!stricmp(Cur_pilot->callsign, Pilots[cur_pilot_idx]) && (is_pilot_multi(Cur_pilot) == multi)) { if ((cur_pilot_idx == Selected_line) || (cur_pilot_idx == prospective_pilot)) { gr_set_color_fast(&Color_text_active_hi); } else { gr_set_color_fast(&Color_text_active); } } else { if (cur_pilot_idx == Selected_line) { gr_set_color_fast(&Color_text_selected); } else if (cur_pilot_idx == prospective_pilot) { gr_set_color_fast(&Color_text_subselected); } else { gr_set_color_fast(&Color_text_normal); } } gr_printf(Pilot_manage_list_coords[gr_screen.res][PM_X_COORD], Pilot_manage_list_coords[gr_screen.res][PM_Y_COORD] + y, Pilots[cur_pilot_idx]); gr_set_bitmap(Rank_pips_bitmaps + Pilot_ranks[cur_pilot_idx]); gr_bitmap(Pilot_manage_list_coords[gr_screen.res][PM_X_COORD] - 34, Pilot_manage_list_coords[gr_screen.res][PM_Y_COORD] + y); y += font_height; cur_pilot_idx++; } }