void set_ui_list_spacing_proportional_to_font (ui_object *list, float scaling) { int height, old_font; float proportion, spacing; old_font = get_ui_font_type (); set_ui_font_type (get_ui_object_font_type (list)); // get height height = ui_get_font_height (); // find proportion of ui_object used by font proportion = height / get_ui_object_y_size (list); // calc spacing value spacing = proportion * scaling; set_ui_object_list_box_y_space (list, spacing); set_ui_font_type ((font_types) old_font); }
static void set_text_ui_object_font_type (ui_object *obj, int font_id) { font_types this_font; area_ui_object *area; area = obj->data; area->font_type = font_id; this_font = get_ui_font_type (); set_ui_font_type (font_id); set_ui_object_y_size (obj, ui_get_font_height ()); set_ui_font_type (this_font); }
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 ); }
void brief_initialise_game (void) { //////////////////////////////////////// set_game_status (GAME_STATUS_UNINITIALISED); set_comms_model (COMMS_MODEL_SERVER); //////////////////////////////////////// //////////////////////////////////////// debug_watch ("Game status = %s", MT_STRING_PTR, &game_status_string); debug_watch ("Comms model = %s", MT_STRING_PTR, &comms_model_string); //////////////////////////////////////// //////////////////////////////////////// // // WARNING! INITIALISATION ORDER IS CRITICAL // // NOTE : MEMORY BLOCK SYSTEM CONSTRAINTS; // DO NOT USE REGISTER_EXIT_FUNCTION // FOR DEINITIALISATION. // //////////////////////////////////////// //////////////////////////////////////// // // INITIALISE GLOBAL OPTIONS // //////////////////////////////////////// debug_log ( "Initialising memory system" ); reset_safe_memory_counter (); reset_safe_memory_mapped_file_counter (); initialise_memory_block_system (); create_memory_block_configuration (memory_block_config, sizeof (memory_block_config) / sizeof (memory_block_configuration)); //////////////////////////////////////// // // INITIALISE GRAPHICS FILES // // NB. FIRST PASS CONVERSION ONLY // //////////////////////////////////////// debug_log ( "Installing graphics files" ); // // Check the graphics file format // { int red_mask, green_mask, blue_mask, alpha_mask; get_screen_pixel_format ( &red_mask, &green_mask, &blue_mask, &alpha_mask ); if ( ( red_mask != get_global_graphics_files_red_mask () ) || ( green_mask != get_global_graphics_files_green_mask () ) || ( blue_mask != get_global_graphics_files_blue_mask () ) || ( alpha_mask != get_global_graphics_files_alpha_mask () ) ) { set_global_graphics_files_red_mask ( red_mask ); set_global_graphics_files_green_mask ( green_mask ); set_global_graphics_files_blue_mask ( blue_mask ); set_global_graphics_files_alpha_mask ( alpha_mask ); set_global_graphics_files_wrong_format ( TRUE ); } } if ( (command_line_clean_graphics) || ( ( get_global_graphics_files_wrong_format () ) && ( !command_line_no_graphics_conversion ) ) ) { uninstall_graphics_files (); } if ((!get_global_graphics_files_installed ()) || command_line_new_graphics) { while (!install_graphics_files (GRAPHICS_CONVERSION_FIRST_PASS)); } debug_log ( "Opening graphics files" ); mopen_all_graphics_files (GRAPHICS_CONVERSION_FIRST_PASS); // // Reset the graphics file format change flag now // set_global_graphics_files_wrong_format ( FALSE ); debug_log ( "Installing event stack" ); initialise_event_stack (); debug_log ( "Installing ui" ); switch (command_line_run_mode) { /* case RUN_MODE_AITOOL: { push_event (aitool_events, "aitool events"); break; } */ case RUN_MODE_NORMAL: default: { push_event (ui_events, "ui events"); break; } } initialise_dinput_to_ascii_conversion_table (); debug_log ( "Initialising ui system" ); initialise_ui_system (2000); debug_log ( "Initialising ui font" ); // // Hack in to support all font resolutions // set_ui_font_resolution (get_global_3d_visual_screen_width (), get_global_3d_visual_screen_height ()); initialise_ui_font (); set_ui_font_type (UI_FONT_ARIAL_18); debug_log ( "Initialising ui objects" ); initialise_ui_objects (); debug_log ( "Initialising ui menus" ); //////////////////////////////////////// // // INITIALISE LANGUAGE DATABASE // //////////////////////////////////////// //ö initialise_language_database (); initialise_title_screen (); initialise_init_screen (); debug_log ( "Initialising ui mouseptr" ); initialise_mouse_pointer ((rgb_packed *) get_graphics_file_data (GRAPHICS_UI_COMMON_MOUSE_POINTER)); debug_log ( "Finished brief install" ); }