int add_message_to_campaign_log (int index) { int hours, minutes, seconds; char *s; message_log_type *message; rgb_colour *col = NULL; message = get_message_log (index); ASSERT (message); if (message->type == MESSAGE_TEXT_PILOT_STRING) { get_digital_clock_int_values (message->time_of_day, &hours, &minutes, &seconds); s = (char *) malloc_fast_mem (strlen (message->string) + 20); sprintf (s, "[%02d:%02d] %s", hours, minutes, message->string); col = &(message->colour); ASSERT (col); add_to_pop_up_list (s, chat_message_list, NULL, index, -1, *col); free_mem (s); return TRUE; } else { return FALSE; } }
void draw_high_score_table_to_ui_object_list (ui_object *blue_list_object, ui_object *red_list_object) { char buffer [256]; int loop; pilot_score_type *item; rgb_colour *col; ui_object *list; for (loop = 0; loop < NUM_TABLE_ENTRIES; loop ++) { item = &pilot_high_score_table [loop]; if (item->valid) { if (item->side == ENTITY_SIDE_BLUE_FORCE) { col = &ui_colour_blue; list = blue_list_object; } else { col = &ui_colour_orange; list = red_list_object; } sprintf (buffer, "%s: %d", item->name, item->kills); add_to_pop_up_list (buffer, list, NULL, UI_LIST_NO_SELECTION, UI_FONT_ARIAL_14, *col); } } }
static void dedicated_server_build_player_list (void) { entity *force, *pilot; entity_sides side; rgb_colour col; ui_object_destroy_list_items (player_list); force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE); while (force) { pilot = get_local_entity_first_child (force, LIST_TYPE_PILOT); while (pilot) { if (pilot != get_pilot_entity ()) { side = (entity_sides) get_local_entity_int_value (pilot, INT_TYPE_SIDE); col.r = 255; col.g = 255; col.b = 255; col.a = 255; add_to_pop_up_list (get_local_entity_string (pilot, STRING_TYPE_PILOTS_NAME), player_list, NULL, 0, UI_FONT_ARIAL_16, col); } pilot = get_local_entity_child_succ (pilot, LIST_TYPE_PILOT); } force = get_local_entity_child_succ (force, LIST_TYPE_FORCE); } }
void rebuild_default_payload_list (entity *en) { int fixed; ui_object *new_item; ASSERT (en); ui_object_destroy_list_items (page_default_payload_list); if (get_local_entity_int_value (en, INT_TYPE_GUNSHIP_TYPE) < NUM_GUNSHIP_TYPES) { fixed = (!get_helicopter_allowed_to_rearm (en)); } else { fixed = TRUE; } // sprintf (buffer, "%s", get_trans ("Air to Ground")); new_item = add_to_pop_up_list (buffer, page_default_payload_list, NULL, INT_TYPE_AIR_TO_SURFACE_WEAPON_CONFIG_TYPE, UI_FONT_ARIAL_14, ui_ingame_dead_text_colour); if (!fixed) { set_ingame_ui_object_mouse_over_properties (new_item); set_ui_object_notify_on (new_item, NOTIFY_TYPE_BUTTON_DOWN); } else { set_ui_object_notify_on (new_item, NOTIFY_TYPE_NONE); } // sprintf (buffer, "%s", get_trans ("Air to Air")); new_item = add_to_pop_up_list (buffer, page_default_payload_list, NULL, INT_TYPE_AIR_TO_AIR_WEAPON_CONFIG_TYPE, UI_FONT_ARIAL_14, ui_ingame_dead_text_colour); if (!fixed) { set_ingame_ui_object_mouse_over_properties (new_item); set_ui_object_notify_on (new_item, NOTIFY_TYPE_BUTTON_DOWN); } else { set_ui_object_notify_on (new_item, NOTIFY_TYPE_NONE); } // sprintf (buffer, "%s", get_trans ("Scout")); new_item = add_to_pop_up_list (buffer, page_default_payload_list, NULL, INT_TYPE_SCOUT_WEAPON_CONFIG_TYPE, UI_FONT_ARIAL_14, ui_ingame_dead_text_colour); if (!fixed) { set_ingame_ui_object_mouse_over_properties (new_item); set_ui_object_notify_on (new_item, NOTIFY_TYPE_BUTTON_DOWN); } else { set_ui_object_notify_on (new_item, NOTIFY_TYPE_NONE); } }
void show_weapon_loading_page (entity *group, int force_update) { gunship_types type; int loop; entity *en, *pilot, *member; ui_object *new_item; ASSERT (group); // // Reconstruct List // if (force_update) { ui_object_destroy_list_items (page_member_list); set_ui_object_vslider_virtual_position (get_ui_object_vslider (page_member_area), 0.0); set_ui_object_item_number (page_member_list, ENTITY_INDEX_DONT_CARE); member = get_local_entity_first_child (group, LIST_TYPE_MEMBER); ASSERT (member); while (member) { sprintf (buffer, "1-%d %s", get_local_entity_int_value (member, INT_TYPE_GROUP_MEMBER_ID), get_local_entity_string (member, STRING_TYPE_SHORT_DISPLAY_NAME)); pilot = get_local_entity_first_child (member, LIST_TYPE_AIRCREW); if (pilot) { sprintf (buffer, "1-%d %s (%s)", get_local_entity_int_value (member, INT_TYPE_GROUP_MEMBER_ID), get_local_entity_string (member, STRING_TYPE_SHORT_DISPLAY_NAME), get_local_entity_string (pilot, STRING_TYPE_PILOTS_NAME)); } if (get_local_entity_int_value (member, INT_TYPE_GUNSHIP_TYPE) < NUM_GUNSHIP_TYPES) { new_item = add_to_pop_up_list (buffer, page_member_list, NULL, get_local_entity_safe_index (member), UI_FONT_ARIAL_14, ui_ingame_live_text_colour); set_ui_mouse_over_entity_function (new_item); set_ui_object_notify_on (new_item, NOTIFY_TYPE_BUTTON_DOWN); } else { new_item = add_to_pop_up_list (buffer, page_member_list, NULL, get_local_entity_safe_index (member), UI_FONT_ARIAL_14, ui_ingame_dead_text_colour); set_ui_object_notify_on (new_item, NOTIFY_TYPE_NONE); } if (member == get_gunship_entity ()) { set_ui_object_state (new_item, UI_OBJECT_STATE_ON); set_ui_object_item_number (page_member_list, get_local_entity_safe_index (member)); } member = get_local_entity_child_succ (member, LIST_TYPE_MEMBER); } resize_pop_up_list (page_member_list); } // // Show weapon loading page // for (loop = 0; loop < NUM_GUNSHIP_TYPES; loop ++) { set_ui_object_drawable (weapon_loading_page [loop], FALSE); set_ui_object_item_number (weapon_loading_page [loop], ENTITY_INDEX_DONT_CARE); } en = get_local_entity_safe_ptr (get_ui_object_item_number (page_member_list)); ASSERT (en); type = get_local_entity_int_value (en, INT_TYPE_GUNSHIP_TYPE); if (get_local_entity_int_value (en, INT_TYPE_GUNSHIP_TYPE) < NUM_GUNSHIP_TYPES) { weapon_loading_update_currently_selected_weapons (en); set_ui_object_drawable (weapon_loading_page [type], TRUE); set_ui_object_item_number (weapon_loading_page [type], get_local_entity_safe_index (en)); } // // Default payload list // rebuild_default_payload_list (en); display_campaign_page (CAMPAIGN_PAGE_WEAPON_LOADING, get_local_entity_safe_index (group), TRUE); }
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 build_chat_target_list (void) { ui_object *new_item; entity *force, *pilot, *current_target; static char s [128]; current_target = get_local_entity_safe_ptr (get_ui_object_item_number (chat_send_button)); ui_object_destroy_list_items (chat_target_list); sprintf (s, "%s", get_trans ("Side")); new_item = add_to_pop_up_list (s, chat_target_list, NULL, ENTITY_INDEX_DONT_CARE, UI_FONT_ARIAL_16, ui_ingame_dead_text_colour); // // All // ASSERT (get_session_entity ()); sprintf (s, "%s", get_trans ("CHAT_TARGET_ALL")); new_item = add_to_pop_up_list (s, chat_target_list, NULL, get_local_entity_safe_index (get_session_entity ()), UI_FONT_ARIAL_16, ui_ingame_live_text_colour); set_ingame_ui_object_mouse_over_properties (new_item); if (get_session_entity () == current_target) { set_ui_object_state (new_item, UI_OBJECT_STATE_ON); } // // Sides // force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE); while (force) { sprintf (s, "%s", get_local_entity_string (force, STRING_TYPE_FORCE_NAME)); new_item = add_to_pop_up_list (s, chat_target_list, NULL, get_local_entity_safe_index (force), UI_FONT_ARIAL_16, ui_ingame_live_text_colour); set_ingame_ui_object_mouse_over_properties (new_item); if (force == current_target) { set_ui_object_state (new_item, UI_OBJECT_STATE_ON); } force = get_local_entity_child_succ (force, LIST_TYPE_FORCE); } // // Sides // sprintf (s, "%s", get_trans ("UI_PILOTS")); new_item = add_to_pop_up_list (s, chat_target_list, NULL, ENTITY_INDEX_DONT_CARE, UI_FONT_ARIAL_16, ui_ingame_dead_text_colour); force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE); while (force) { pilot = get_local_entity_first_child (force, LIST_TYPE_PILOT); while (pilot) { if (pilot != get_pilot_entity ()) { sprintf (s, "%s", get_local_entity_string (pilot, STRING_TYPE_PILOTS_NAME)); new_item = add_to_pop_up_list (s, chat_target_list, NULL, get_local_entity_safe_index (pilot), UI_FONT_ARIAL_16, ui_ingame_live_text_colour); set_ingame_ui_object_mouse_over_properties (new_item); if (pilot == current_target) { set_ui_object_state (new_item, UI_OBJECT_STATE_ON); } } pilot = get_local_entity_child_succ (pilot, LIST_TYPE_PILOT); } force = get_local_entity_child_succ (force, LIST_TYPE_FORCE); } }
void build_save_file_list (void) { session_list_data_type *game_session; directory_file_list *directory_listing; ui_object *new_item; int valid_file; char *p, filename [256], extension [8]; ui_object_destroy_list_items (save_file_list); game_session = get_current_game_session (); ASSERT (game_session); sprintf (full_filename, "%s//%s//*.", game_session->data_path, game_session->campaign_directory); sprintf (extension, "%s", game_type_extensions [get_game_type ()]); extension [2] = extension [1]; extension [1] = extension [0]; extension [0] = 'S'; strcat (full_filename, extension); directory_listing = get_first_directory_file (full_filename); if (directory_listing) { valid_file = TRUE; while (valid_file) { if (get_directory_file_type (directory_listing) == DIRECTORY_FILE_TYPE_FILE) { sprintf (filename, get_directory_file_filename (directory_listing)); p = strchr (filename, '.'); if (p) { *p = '\0'; } new_item = add_to_pop_up_list (filename, save_file_list, NULL, ENTITY_INDEX_DONT_CARE, UI_FONT_ARIAL_16, ui_ingame_live_text_colour); set_ingame_ui_object_mouse_over_properties (new_item); } valid_file = get_next_directory_file (directory_listing); } destroy_directory_file_list (directory_listing); } resize_pop_up_list (save_file_list); }