Beispiel #1
0
	ignore_units_display_context(const display_context & dc)
		: um_()
		, gm_(&dc.map())
		, tm_(&dc.teams())
		, lbls_(&dc.hidden_label_categories())
	{
		static unit_map empty_unit_map;
		um_ = &empty_unit_map;
	}
Beispiel #2
0
/**
 * This is a test used to see if we should bother with the overhead of actually
 * creating a label. Conditions that can change during unit movement (disregarding
 * potential WML events) should not be listed here; they belong in hidden().
 */
bool terrain_label::viewable(const display_context & dc) const
{
	if ( !parent_->enabled() )
		return false;

	// In the editor, all labels are viewable.
	if ( dc.teams().empty() )
		return true;

	// Observers are not privvy to team labels.
	const bool can_see_team_labels = !dc.is_observer();

	// Global labels are shown unless covered by a team label.
	if ( team_name_.empty() )
		return !can_see_team_labels || parent_->visible_global_label(loc_);

	// Team labels are only shown to members of the team.
	return can_see_team_labels  &&  parent_->team_name() == team_name_;
}
static stuff_list_adder add_unit_entry(stuff_list_adder& progress, const unit& u, const display_context& dc)
{

	Uint32 team_color = game_config::tc_info(dc.get_team(u.side()).color())[0];
	std::stringstream s;

	s << '(' << u.get_location() << ')';
	progress.widget("loc", s.str());

	s.str("");
	s << "<span color='#" << std::hex << team_color << std::dec;
	s << "'>side=" << u.side() << "</span>";
	progress.widget("side", s.str(), true);

	if(u.can_recruit()) {
		progress.widget("leader", "<span color='yellow'>LEADER</span> ", true);
	}

	s.str("");
	s << "id=\"" << u.id() << '"';
	progress.widget("id", s.str());

	progress.widget("type", u.type_id());

	s.str("");
	s << "L" << u.level();
	progress.widget("level", s.str());

	s.str("");
	s << u.experience() << '/' << u.max_experience() << " xp";
	progress.widget("xp", s.str());

	s.str("");
	s << u.hitpoints() << '/' << u.max_hitpoints() << " hp";
	progress.widget("hp", s.str());

	progress.widget("traits", utils::join(u.get_traits_list(), ", "));

	return progress;
}