купить дизайн: yougame.biz/threads/155999
Дизайнер
-
Автор темы
- #1
C++:
#include "hud.h"
void watermark::render(size_t options) {
std::vector<std::string> logo = {"adobe", "sense"};
const auto accent = color(160, 200, 80);
std::vector<color> gradient = {color(100, 150, 200), color(180, 100, 160), color(180, 230, 100)};
std::string text = "";
const auto margins = 14;
if (options & FPS) {
const auto fps = std::to_string(static_cast<int>(1.f / interfaces::globals->m_abs_frame_time));
text += " | ";
/// ВНИМАНИЕ В КОДЕ ОБНАРУЖЕН ПОНАДУСЕРОВЫЙ ХОХЛОШВАЙН
/// СРОЧНАЯ ЭВАКУАЦИЯ!!!
{
const auto symbols = 3;
if (fps.size() < symbols)
for (auto i = 0; i <= symbols - fps.size(); ++i)
text += " ";
}
text += fps + "fps";
}
if (options & PING) {
const auto net_channel = interfaces::engine->get_net_channel_info();
if (net_channel) {
auto avg_latency = net_channel->get_avg_latency(FLOW_OUTGOING);
const static auto cl_updaterate = interfaces::convar_system->find_var("cl_updaterate");
auto adjust = 0.f;
if (cl_updaterate->get_float() > 0.001f) {
adjust = -0.5f / cl_updaterate->get_float();
avg_latency += adjust;
}
avg_latency = std::max(0.f, avg_latency);
adjust *= 1000.f;
{
const auto ms = std::to_string(static_cast<int>(avg_latency * 1000.f));
text += " | ";
{
const auto symbols = 2;
if (ms.size() < symbols)
for (auto i = 0; i <= symbols - ms.size(); ++i)
text += " ";
}
text += ms + "ms";
}
}
}
if (options & VELOCITY && globals::local_player->is_alive()) {
const auto vel = std::to_string(static_cast<int>(globals::local_player->m_velocity().length_2d()));
text += " | ";
{
const auto symbols = 2;
if (vel.size() < symbols)
for (auto i = 0; i <= symbols - vel.size(); ++i)
text += " ";
}
text += vel + "vel";
}
if (options & TICKRATE) {
text += " | " + std::to_string(static_cast<int>(1.f / interfaces::globals->m_tick_interval)) + " tick";
}
if (options & TIME) {
auto t = std::time(nullptr);
auto tm = *std::localtime(&t);
std::ostringstream tss;
tss << std::put_time(&tm, "%H:%M:%S");
text += " | " + tss.str();
}
/// Text measures.
const std::vector<float> logo_size = {render::measure_text(font::verdana_12, logo[0]).x,
render::measure_text(font::verdana_12, logo[1]).x};
const auto text_size = render::measure_text(font::verdana_12, text);
/// Complete string (logo + text) size.
const auto complete_size = text_size + vec2(logo_size[0] + logo_size[1], 0);
/// Main pos.
const auto pos = vec2(render::m_screen_size.x - complete_size.x - margins, margins);
/// Little bit paddings, to emplace gradient line
const auto text_pad = (options & GAY_LINE) ? 1 : 0;
/// Outline measures.
const auto outline_size = complete_size + 20;
const auto outline_pos = pos - 10;
//render::gradient(pos, size, m_style.m_col_accent);
/// Outer outline.
render::rect(outline_pos, outline_size, color(12, 12, 12));
/// Basic outline.
render::rect(outline_pos + 1, outline_size - 2, color(39, 39, 39));
/// Outlines of basic outline.
render::outline(outline_pos + 1, outline_size - 2, color(59, 59, 59));
render::outline(outline_pos + 5, outline_size - 10, color(59, 59, 59));
/// Background.
render::rect(outline_pos + 6, outline_size - 12, color(12, 12, 12));
if (options & GAY_LINE) {
///render::gradient(outline_pos + 7, vec2(outline_size.x - 14, 2), gradient);
{
render::gradient(outline_pos + 7, vec2(outline_size.x / 2 - 7, 2), gradient[0], gradient[1]);
render::gradient(outline_pos + 7 + vec2(outline_size.x / 2 - 7, 0), vec2(outline_size.x / 2 - 7, 2), gradient[1], gradient[2]);
}
render::rect(outline_pos + 7 + vec2(0, 1), vec2(outline_size.x - 14, 1), color(0, 0, 0, 200));
}
/// Logo.
render::text(pos + vec2(0.f, text_pad), font::verdana_12, logo[0], color(240, 240, 240, 200), EFFECT_SHADOW);
render::text(pos + vec2(logo_size[0], text_pad), font::verdana_12, logo[1], accent, EFFECT_SHADOW);
/// Main text.
render::text(pos + vec2(logo_size[0] + logo_size[1], text_pad), font::verdana_12, text, color(240, 240, 240, 200), EFFECT_SHADOW);
}
C++:
#pragma once
#include "../../globals.h"
/// Watermark options to draw.
enum e_watermark {
WATERMARK_NONE = 0, /// Default argument, only logo will be drawn.
GAY_LINE = (1 << 0),
FPS = (1 << 1),
PING = (1 << 2),
TICKRATE = (1 << 3),
VELOCITY = (1 << 4),
TIME = (1 << 5)
};
namespace watermark {
/// Entry function. Should be called in d3dx9 or paint hook.
void render(size_t options = WATERMARK_NONE);
}
watermark::render(GAY_LINE | FPS | PING | TICKRATE | VELOCITY | TIME);
Пожалуйста, зарегистрируйтесь или авторизуйтесь, чтобы увидеть содержимое.