示例#1
0
	void MultiPlayerMenu::onDraw(Renderer2D &out) const {
		FRect back_quad((float2)m_window_size);

		out.addFilledRect(back_quad, mulAlpha(ColorId::black, m_visible_time * 0.8f));
		HudLayer::onDraw(out);

		if(!m_message.empty()) {
			double msg_time = getTime() - m_message_time;
			double alpha = min(1.0, 5.0 - msg_time);

			if(msg_time < 5.0)
				m_font->draw(out, rect() + float2(spacing, 0.0f),
						     {mulAlpha(m_message_color, alpha), mulAlpha(ColorId::black, alpha), HAlign::left, VAlign::bottom}, m_message);
		}
	}
示例#2
0
	void HudItemDesc::onDraw(Renderer2D &out) const {
		HudLayer::onDraw(out);
		FRect rect = this->rect();

		if(!m_item.isDummy()) {
			float ypos = topOffset() + rect.y();

			FRect uv_rect;
			auto texture = m_item.guiImage(false, uv_rect);
			float2 size(texture->width() * uv_rect.width(), texture->height() * uv_rect.height());

			float2 pos = (float2)(int2)(float2(rect.center().x - size.x * 0.5f, ypos));
			out.addFilledRect(FRect(pos, pos + size), uv_rect, {texture, mulAlpha(ColorId::white, alpha())});

			ypos += size.y + 10.0f;
			FRect desc_rect(rect.x() + 5.0f, ypos, rect.ex() - 5.0f, rect.ey() - 5.0f);
			// TODO: fix drawing of text that does not fit
		
			string params_desc;
			if(m_item.type() == ItemType::weapon)
				params_desc = Weapon(m_item).paramDesc();
			else if(m_item.type() == ItemType::ammo)
				params_desc = Ammo(m_item).paramDesc();
			else if(m_item.type() == ItemType::armour)
				params_desc = Armour(m_item).paramDesc();

			m_font->draw(out, float2(rect.x() + 5.0f, ypos), {titleColor(), titleShadowColor()}, params_desc);
		}
	}
示例#3
0
	void HudTargetInfo::onDraw(Renderer2D &out) const {
		HudLayer::onDraw(out);

		HealthStatus health = healthStatusFromHP(m_health);
		const char *health_desc = toString(health);

		Color text_color = (Color)mulAlpha(ColorId::white, alpha());
		Color shadow_color = (Color)mulAlpha(ColorId::black, alpha());
		Color health_color = (Color)mulAlpha(s_health_colors[health], alpha());
		
		FRect font_rect = rect() + float2(layer_spacing, 0.0f);
		font_rect.max.y = font_rect.min.y + font_rect.height() / 4.0f;
		float2 offset = float2(0.0f, font_rect.height());
		m_font->draw(out, font_rect, {text_color, shadow_color, HAlign::left, VAlign::center}, m_name);

		font_rect += offset;
		m_font->draw(out, font_rect, {health_color, shadow_color, HAlign::left, VAlign::center}, health_desc);
		
		font_rect += offset;
		m_font->draw(out, font_rect, {text_color, shadow_color, HAlign::left, VAlign::center}, format("k/d: %d/%d", m_kills, m_deaths));

		font_rect += offset;
		m_font->draw(out, font_rect, {text_color, shadow_color, HAlign::left, VAlign::center}, format("Hit chance: %.0f%%", m_hit_chance * 100.0f));
	}