static void draw_page_3d_scene (ui_object *obj, void *arg) { entity *en; viewpoint vp; vec3d *pos, vec; en = get_local_entity_safe_ptr (get_ui_object_item_number (obj)); if (en) { pos = get_local_entity_vec3d_ptr (en, VEC3D_TYPE_POSITION); ASSERT (pos); get_3d_unit_vector_from_heading_and_pitch (&vec, page_3d_heading, page_3d_pitch); vp.x = pos->x + (page_3d_distance * vec.x); vp.y = pos->y + (page_3d_distance * vec.y); vp.z = pos->z + (page_3d_distance * vec.z); invert_3d_vector (&vec); get_matrix3x3_from_unit_vec3d (vp.attitude, &vec); draw_campaign_screen_3d_scene (obj, &vp); } }
static void notify_weapon_loading_page_change_weapon (ui_object *obj, void *arg) { entity *en; ui_object *gunship_page; int hardpoint; ASSERT (obj); hardpoint = get_ui_object_item_number2 (obj); gunship_page = get_ui_object_parent (obj); ASSERT (gunship_page); en = get_local_entity_safe_ptr (get_ui_object_item_number (gunship_page)); ASSERT (en); if (get_helicopter_allowed_to_rearm (en)) { weapon_loading_select_next_weapon (en, hardpoint); } rebuild_default_payload_list (en); }
static void notify_send_message (ui_object *obj, void *arg) { entity *target; const char *text; target = get_local_entity_safe_ptr (get_ui_object_item_number (chat_send_button)); if (target) { text = get_ui_object_text (chat_current_text); if (text) { if (strlen (text) > 0) { send_text_message (get_pilot_entity (), target, MESSAGE_TEXT_PILOT_STRING, text); return; } } } }
static void chat_input_function (ui_object *obj, void *arg) { entity // Jabberwock 040213 Chat send after Enter *target; const char *text; text = get_ui_object_text (chat_input); if (text) { if (strlen (text) > 0) { set_ui_object_text (chat_current_text, get_ui_object_text (chat_input)); // Jabberwock 040213 Chat send after Enter target = get_local_entity_safe_ptr (get_ui_object_item_number (chat_send_button)); if (target) { send_text_message (get_pilot_entity (), target, MESSAGE_TEXT_PILOT_STRING, text); } // Jabberwock 040202 ends } } set_ui_object_drawable (chat_current_text, TRUE); set_ui_object_drawable (chat_input, FALSE); }
void notify_award_clicked_medal (ui_object *obj, void *arg) { player_log_type *player; int *medals, medal_number, graphic_number; player = get_current_player_log (); medals = player->side_log[player_log_current_side].medals; medal_number = graphic_number = get_ui_object_item_number (obj); // account for double graphics on last 2 medals if (graphic_number == 10) { graphic_number = 11; } else if (graphic_number == 11) { graphic_number = 13; } if (player_log_current_side == ENTITY_SIDE_RED_FORCE) { if (medals [medal_number] == 0) { set_ui_object_drawable (us_medal_objects [graphic_number], TRUE); medals [medal_number] = 1; } else { set_ui_object_drawable (us_medal_objects [graphic_number], FALSE); medals [medal_number] = 0; } } else { if (medals [medal_number] == 0) { set_ui_object_drawable (russian_medal_objects [graphic_number], TRUE); medals [medal_number] = 1; } else { set_ui_object_drawable (russian_medal_objects [graphic_number], FALSE); medals [medal_number] = 0; } } }
static void draw_page_map (ui_object *obj, void *arg) { entity *en; en = get_local_entity_safe_ptr (get_ui_object_item_number (campaign_page [CAMPAIGN_PAGE_BASE])); ASSERT (en); draw_2d_map (obj, arg); }
static void notify_default_payload_list (ui_object *obj, void *arg) { entity *en; int config_type; en = get_local_entity_safe_ptr (get_ui_object_item_number (page_member_list)); if (en) { if (get_helicopter_allowed_to_rearm (en)) { config_type = get_ui_object_item_number (obj); if (config_type != ENTITY_INDEX_DONT_CARE) { ASSERT ( (config_type == INT_TYPE_AIR_TO_SURFACE_WEAPON_CONFIG_TYPE) || (config_type == INT_TYPE_AIR_TO_AIR_WEAPON_CONFIG_TYPE) || (config_type == INT_TYPE_SCOUT_WEAPON_CONFIG_TYPE) ); set_client_server_entity_int_value (en, INT_TYPE_WEAPON_CONFIG_TYPE, get_local_entity_int_value (en, config_type)); weapon_loading_update_currently_selected_weapons (en); if (en == get_gunship_entity ()) { set_flight_dynamics_mass (); } } } rebuild_default_payload_list (en); } }
void campaign_screen_update_chat_page_pilot (entity *en) { entity *current_target; current_target = get_local_entity_safe_ptr (get_ui_object_item_number (chat_send_button)); if (current_target == en) { set_ui_object_item_number (chat_send_button, get_local_entity_safe_index (get_session_entity ())); } build_chat_target_list (); }
void notify_target_list (ui_object *obj, void *arg) { int index; index = get_ui_object_item_number (obj); if (index != ENTITY_INDEX_DONT_CARE) { set_ui_object_item_number (chat_send_button, index); build_chat_target_list (); } }
void highlight_russian_medal_info (ui_object *obj, void *arg) { player_log_type *player; char name_text [128], info_text [128]; int medal_number, medal_count; player = get_current_player_log (); medal_number = get_ui_object_item_number (obj); medal_count = player->side_log [player_log_current_side].medals [medal_number]; if ( (medal_number != MEDAL_MASTER_AVIATOR) && (medal_number != MEDAL_SENIOR_AVIATOR) && (medal_number != MEDAL_ARMY_AVIATOR) ) { sprintf (name_text, "(%d) %s", medal_count, russian_medal_info_array [medal_number].name); } else { sprintf (name_text, "%s", russian_medal_info_array [medal_number].name); } sprintf (info_text, "%s", russian_medal_info_array [medal_number].info); if ((int) arg == BUTTON_STATE_DOWN) { set_ui_object_text (medals_text_name, name_text); set_ui_object_text (medals_text_info, info_text); } else { set_ui_object_text (medals_text_name, ""); set_ui_object_text (medals_text_info, ""); } }
static int response_to_base_destroyed (campaign_screen_messages message, entity *sender) { if (get_local_entity_safe_index (sender) == get_ui_object_item_number (campaign_page [CAMPAIGN_PAGE_BASE])) { if (get_ui_object_drawable (campaign_page [CAMPAIGN_PAGE_BASE])) { // // Not sure yet.... For now display the map page // show_map_page (); } set_ui_object_item_number (campaign_page [CAMPAIGN_PAGE_BASE], ENTITY_INDEX_DONT_CARE); } return TRUE; }
static void notify_member_list (ui_object *obj, void *arg) { int index; entity *en, *group; index = get_ui_object_item_number (obj); en = get_local_entity_safe_ptr (index); ASSERT (en); set_ui_object_item_number (page_member_list, index); group = get_local_entity_parent (en, LIST_TYPE_MEMBER); ASSERT (group); show_weapon_loading_page (group, FALSE); }
static void notify_base_destroy_button (ui_object *obj, void *arg) { entity *en; entity_sides side, new_side; int sub_type; if (get_comms_model () != COMMS_MODEL_SERVER) { return; } en = get_local_entity_safe_ptr (get_ui_object_item_number (campaign_page [CAMPAIGN_PAGE_BASE])); ASSERT (en); sub_type = get_local_entity_int_value (en, INT_TYPE_ENTITY_SUB_TYPE); if (keysite_database [sub_type].troop_insertion_target) { side = get_local_entity_int_value (en, INT_TYPE_SIDE); new_side = get_enemy_side (side); // create_troop_insertion_task (new_side, en, NULL, TRUE, 10.0, NULL, NULL); capture_keysite (en, new_side); } else { kill_client_server_entity (en); } }
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); } }
static void draw_chat_send_button (ui_object *obj, void *arg) { entity *current_target; rgb_colour *col; static const char *text; static char s [256]; sprintf (s, "%s: ", get_trans ("SEND TO")); current_target = get_local_entity_safe_ptr (get_ui_object_item_number (obj)); if (current_target) { switch (get_local_entity_type (current_target)) { case ENTITY_TYPE_SESSION: { strcat (s, get_trans ("CHAT_TARGET_ALL")); break; } case ENTITY_TYPE_FORCE: { strcat (s, get_local_entity_string (current_target, STRING_TYPE_FORCE_NAME)); break; } case ENTITY_TYPE_PILOT: { strcat (s, get_local_entity_string (current_target, STRING_TYPE_PILOTS_NAME)); break; } default: { current_target = NULL; build_chat_target_list (); break; } } } set_ui_object_text (obj, s); if (current_target) { text = get_ui_object_text (chat_current_text); if (text) { if (strlen (text) > 0) { set_ingame_ui_object_mouse_over_properties (obj); set_ui_object_notify_on (obj, NOTIFY_TYPE_BUTTON_DOWN); return; } } } set_ui_object_notify_on (obj, NOTIFY_TYPE_NONE); set_ui_object_highlightable (obj, FALSE); col = &ui_ingame_dead_text_colour; set_ui_object_font_colour (obj, col->r, col->g, col->b, col->a); }
static void update_base_page_objects (ui_object *obj, void *arg) { char s [128]; entity *base; entity_sub_types sub_type; base = get_local_entity_safe_ptr (get_ui_object_item_number (campaign_page [CAMPAIGN_PAGE_BASE])); ASSERT (base); sub_type = get_local_entity_int_value (base, INT_TYPE_ENTITY_SUB_TYPE); // // STATUS // { int status; status = get_local_entity_int_value (base, INT_TYPE_KEYSITE_USABLE_STATE); set_ui_object_text (base_page_status_box, get_trans ((char*) keysite_usable_state_names [status])); switch (status) { case KEYSITE_STATE_UNUSABLE: { set_ui_object_font_colour (base_page_status_box, ui_colour_red.r, ui_colour_red.g, ui_colour_red.b, ui_colour_red.a); break; } case KEYSITE_STATE_REPAIRING: { set_ui_object_font_colour (base_page_status_box, ui_colour_yellow.r, ui_colour_yellow.g, ui_colour_yellow.b, ui_colour_yellow.a); break; } default: { set_ui_object_font_colour (base_page_status_box, ui_colour_yellow.r, ui_colour_yellow.g, ui_colour_yellow.b, ui_colour_yellow.a); break; } } } // // Efficiency // { float efficiency; if (get_local_entity_float_value (base, FLOAT_TYPE_KEYSITE_MAXIMUM_STRENGTH) > 0.0) { efficiency = get_local_entity_float_value (base, FLOAT_TYPE_EFFICIENCY) * 100.0; sprintf (s, "%.0f%%", efficiency); } else { sprintf (s, "N/A", efficiency); } set_ui_object_text (base_page_efficiency_box, s); } // // Supplies // { float supplies; if (keysite_database [sub_type].report_ammo_level) { supplies = get_local_entity_float_value (base, FLOAT_TYPE_AMMO_SUPPLY_LEVEL); sprintf (s, "%.0f%%", supplies); set_ui_object_text (base_page_ammo_box, s); } else { set_ui_object_text (base_page_ammo_box, ""); } if (keysite_database [sub_type].report_fuel_level) { supplies = get_local_entity_float_value (base, FLOAT_TYPE_FUEL_SUPPLY_LEVEL); sprintf (s, "%.0f%%", supplies); set_ui_object_text (base_page_fuel_box, s); } else { set_ui_object_text (base_page_fuel_box, ""); } } // // Back Button // set_ui_object_drawable (page_back_button, get_campaign_history_valid ()); }
void show_base_page (entity *base, int force_update) { entity *previous; vec3d *pos; int x, z; char s [128]; ASSERT (base); ASSERT (get_local_entity_type (base) == ENTITY_TYPE_KEYSITE); if (force_update) { previous = NULL; } else { previous = get_local_entity_safe_ptr (get_ui_object_item_number (campaign_page [CAMPAIGN_PAGE_BASE])); } pos = get_local_entity_vec3d_ptr (base, VEC3D_TYPE_POSITION); ASSERT (pos); // // NAME // set_ui_object_text (base_page_title, get_local_entity_string (base, STRING_TYPE_KEYSITE_NAME)); // // TYPE // set_ui_object_text (base_page_type_box, get_trans (get_local_entity_string (base, STRING_TYPE_FULL_NAME))); // // LOCATION // get_x_sector (x, pos->x); get_z_sector (z, pos->z); sprintf (s, "[%03d, %03d]", x, z); set_ui_object_text (base_page_sector_box, s); // // 3D WINDOW // set_ui_object_item_number (page_3d_area, get_local_entity_index (base)); if (base != previous) { page_3d_heading = 0.0; page_3d_pitch = (PI * 0.25); page_3d_distance = max (50.0, get_local_entity_float_value (base, FLOAT_TYPE_RECON_DISTANCE)); } // // 2D MAP // set_ui_object_item_number (page_map_area, get_local_entity_index (base)); if (base != previous) { page_map_dimensions.x = pos->x; page_map_dimensions.z = pos->z; page_map_dimensions.subject_entity = base; } // display_campaign_page (CAMPAIGN_PAGE_BASE, get_local_entity_index (base), TRUE); }
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); }
static void update_weapon_loading_gunship_page (ui_object *obj, void *arg) { entity *en; gunship_types gunship; weapon_loading_hardpoint_types hardpoint; int count, fixed, auw, weapon_type; float mass; ui_object *button_object; rgb_colour *col; ASSERT (obj); en = get_local_entity_safe_ptr (get_ui_object_item_number (obj)); ASSERT (en); gunship = get_local_entity_int_value (en, INT_TYPE_GUNSHIP_TYPE); ASSERT (gunship < NUM_GUNSHIP_TYPES); if (get_helicopter_allowed_to_rearm (en)) { fixed = FALSE; } else { fixed = TRUE; } // // Set button text // for (hardpoint = 0; hardpoint < NUM_WEAPON_LOADING_HARDPOINT_TYPES; hardpoint ++) { if (weapon_loading_button_list [gunship][hardpoint].valid) { button_object = weapon_loading_button_list [gunship][hardpoint].button_ptr; weapon_type = weapon_loading_get_current_hardpoint_weapon (gunship, hardpoint); // // Set Text // if (weapon_type != ENTITY_SUB_TYPE_WEAPON_NO_WEAPON) { count = get_weapon_loading_hardpoint_weapon_count (en, hardpoint, weapon_type); sprintf (buffer, "%dx %s", count, weapon_database [weapon_type].weapon_loading_list_name); } else { sprintf (buffer, "%s", weapon_database [weapon_type].weapon_loading_list_name); } set_ui_object_text (button_object, buffer); // // Set Button Attributes // if ((fixed) || (weapon_loading_get_valid_weapon_count (en, hardpoint) < 2)) { set_ui_object_notify_on (button_object, NOTIFY_TYPE_NONE); set_ui_object_highlightable (button_object, FALSE); col = &ui_ingame_dead_text_colour; set_ui_object_font_colour (button_object, col->r, col->g, col->b, col->a); } else { set_ui_object_notify_on (button_object, NOTIFY_TYPE_BUTTON_DOWN); set_ingame_ui_object_mouse_over_properties (button_object); } } } // // All-Up-Weight (player only) // if (en == get_gunship_entity ()) { mass = set_flight_dynamics_mass (); convert_float_to_int (mass, &auw); sprintf (buffer, "%s: %dkg", get_trans ("All Up Weight"), auw); set_ui_object_text (page_auw_text, buffer); } else { set_ui_object_text (page_auw_text, ""); } // // Fuel Page (player only) // if (en == get_gunship_entity ()) { sprintf (buffer, " %.0fkg", get_current_flight_dynamics_fuel_weight ()); set_ui_object_text (page_fuel_gauge, buffer); set_ui_object_drawable (page_fuel_text, TRUE); set_ui_object_drawable (page_fuel_gauge, TRUE); draw_weapon_loading_gauge (page_fuel_gauge, get_dynamics_normalised_fuel_value ()); } else { set_ui_object_drawable (page_fuel_text, FALSE); set_ui_object_drawable (page_fuel_gauge, FALSE); } // // Damage Page (player only) // set_ui_object_drawable (page_repairing_text, FALSE); set_ui_object_drawable (page_repairing_gauge, FALSE); if (en == get_gunship_entity ()) { int repair_index; float level, repair_time; if (current_flight_dynamics->repairing_damage != DYNAMICS_DAMAGE_NONE) { repair_index = get_dynamics_damage_currently_repairing_type (); repair_time = dynamics_damage_database [repair_index].repair_time; if (repair_time == 0.0) { level = 1.0; } else { level = 1.0 - (current_flight_dynamics->damage_repair_time / repair_time); level = bound (level, 0.0, 1.0); } sprintf (buffer, " %s", get_trans (dynamics_damage_database [repair_index].name)); set_ui_object_text (page_repairing_gauge, buffer); set_ui_object_drawable (page_repairing_text, TRUE); set_ui_object_drawable (page_repairing_gauge, TRUE); draw_weapon_loading_gauge (page_repairing_gauge, level); } } }