Пример #1
0
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);
		}
	}
}
Пример #2
0
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 ());
}
Пример #3
0
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);
}