void draw_special_restart_text (void) { char buffer [64]; int string_length; float x; // // display game name // if (current_game_session) { sprintf (buffer, "%s", current_game_session->title); string_length = ui_get_string_length ( buffer ); x = get_integer_screen_x_mid () - (string_length / 2); ui_display_text (buffer, x, 73 + iy_640_480); } // // display flashing message // if (flash_timer < 0.666) { set_ui_font_type (UI_FONT_ARIAL_14); set_ui_font_colour (ui_colour_yellow); sprintf ( buffer, get_trans ("PRESS SPACE") ); string_length = ui_get_string_length (buffer); ui_display_text (buffer, get_integer_screen_x_mid () - (string_length / 2), 420 + iy_640_480); } }
static void set_text_ui_object_text (ui_object *obj, char *text) { font_types old_font; int length; float pixel_length; area_ui_object *area; ui_object *parent; area = obj->data; if (area->text) { safe_free (area->text); } area->text = NULL; old_font = get_ui_font_type (); if (area->font_type != -1) { set_ui_font_type (area->font_type); } parent = get_ui_object_parent (obj); if (text) { length = strlen (text); pixel_length = ui_get_string_length (text); area->x_size_start = pixel_length + 5; area->y_size_start = ui_get_font_height () + LIST_ITEM_SPACING; if ((area->virtual_coords) && (parent)) { area->x_size_start /= get_ui_object_x_size (parent); area->y_size_start /= get_ui_object_y_size (parent); } area->text = (char *) safe_malloc ((sizeof (char) * length) + 1); strcpy (area->text, text); } if (parent) { set_ui_object_redraw (parent, TRUE); while ((parent) && (get_ui_object_clear (parent))) { parent = get_ui_object_parent (parent); if (parent) { set_ui_object_redraw (parent, TRUE); } } } else { set_ui_object_redraw (obj, TRUE); } set_ui_font_type (old_font); }
ui_object *add_to_pop_up_list_with_word_wrap (char *text, ui_object *obj, ui_object *next_item, int list_id, int font_type, rgb_colour font_colour) { font_types old_font, font; ui_object *item; char temp_text [256], word [128], *word_ptr, *text_ptr; int new_line_flag, max_string_length; old_font = get_ui_font_type (); font = get_ui_object_font_type (obj); set_ui_font_type (font); memset (temp_text, 0, sizeof (temp_text)); memset (word, 0, sizeof (word)); max_string_length = get_ui_object_x_size (obj); text_ptr = text; while ((*text_ptr != '\0')) { new_line_flag = FALSE; // get next word word_ptr = word; while (*text_ptr != '\0') { *word_ptr = *text_ptr; text_ptr ++; if (*word_ptr == ' ') { break; } word_ptr ++; if (*text_ptr == '\n') { text_ptr ++; new_line_flag = TRUE; break; } } // check word isn't longer than allowed space (causes an error if so...) debug_assert (ui_get_string_length (word) < max_string_length); // check that current string + word fits on line if ((ui_get_string_length (temp_text) + ui_get_string_length (word)) > max_string_length) { // if not display string add_to_pop_up_list (temp_text, obj, NULL, 0, -1, font_colour); // clear string memset (temp_text, 0, sizeof (temp_text)); } // add word to string strcat (temp_text, word); memset (word, 0, sizeof (word)); if (new_line_flag) { // if not display string add_to_pop_up_list (temp_text, obj, NULL, 0, -1, font_colour); // clear string memset (temp_text, 0, sizeof (temp_text)); } } if (strlen (temp_text) > 0) { item = add_to_pop_up_list (temp_text, obj, NULL, 0, -1, font_colour); } set_ui_font_type (old_font); return item; }
void draw_high_score_table (void) { char buffer [256]; int loop, length; screen *old_active_screen; pilot_score_type *item; old_active_screen = get_active_screen (); set_active_screen ( video_screen ); if ( lock_screen ( active_screen ) ) { // // draw leaderboard // for (loop = 0; loop < NUM_TABLE_ENTRIES; loop ++) { item = &pilot_high_score_table [loop]; if (item->valid) { set_ui_font_type (UI_FONT_ARIAL_14); if (item->side == ENTITY_SIDE_BLUE_FORCE) { set_ui_font_colour (ui_colour_blue); } else { set_ui_font_colour (ui_colour_orange); } length = ui_get_string_length (item->name); sprintf (buffer, "%s : %d", item->name, item->kills); // print text assuming game-exit overlay is 640x480 centred in the screen whatever res. ui_display_text (buffer, get_integer_screen_x_mid () - length, iy_640_480 + 180 + (loop * (ui_get_font_height () + 1))); } } // // update flash timer // flash_timer += (FLASH_RATE * get_delta_time ()); flash_timer = frac (flash_timer); unlock_screen ( active_screen ); } set_active_screen ( old_active_screen ); }