added fullbright
This commit is contained in:
1 parent
fafeee709f
commit
b1634d195c
21 files changed
+1263
-204
No files matched your search
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
#include <cstdio>
|
||||
#include "module.h"
|
||||
#include "../gui/fonts.h"
|
||||
#include "../gui/theme.h"
|
||||
|
||||
class watermark : public module {
|
||||
public:
|
||||
watermark()
|
||||
: module("watermark", "self-explanatory", category::hud, VK_F6) {
|
||||
hud_pos = ImVec2(10.f, 10.f);
|
||||
background_ = &add_toggle("background", true);
|
||||
scale_ = &add_float("scale", 1.f, 0.7f, 2.5f);
|
||||
const ImVec4 fg = theme::fg();
|
||||
color_ = &add_color("color", fg.x, fg.y, fg.z);
|
||||
}
|
||||
|
||||
bool is_hud() const override { return true; }
|
||||
|
||||
ImVec2 hud_size() const override {
|
||||
const float s = scale_->float_value;
|
||||
const ImVec2 label = fonts::text_size(fonts::body, fonts::k_body_size, "amnesia");
|
||||
const ImVec2 value = fonts::text_size(fonts::semibold, fonts::k_body_size, "| welcome, ian | 000 fps | 0 ping"); // fixed width, no jitter
|
||||
return ImVec2((pad_x * 2.f + label.x + gap + value.x) * s,
|
||||
(pad_y * 2.f + value.y) * s);
|
||||
}
|
||||
|
||||
void on_render() override {
|
||||
const float s = scale_->float_value;
|
||||
const float fs = fonts::k_body_size * s;
|
||||
|
||||
char buf[64];
|
||||
snprintf(buf, sizeof(buf), "| welcome, ian | %.0f fps | 0 ping", ImGui::GetIO().Framerate);
|
||||
|
||||
ImDrawList* dl = ImGui::GetBackgroundDrawList();
|
||||
const ImVec2 size = hud_size();
|
||||
const ImVec2 q(hud_pos.x + size.x, hud_pos.y + size.y);
|
||||
|
||||
if (background_->bool_value) { // a launcher card: Surface fill, Line border
|
||||
dl->AddRectFilled(hud_pos, q, theme::u32(theme::with_alpha(theme::surface(), 0.85f)), 10.f * s);
|
||||
dl->AddRect(hud_pos, q, theme::u32(theme::line()), 10.f * s, 0, 1.f);
|
||||
}
|
||||
|
||||
const ImVec2 label = fonts::text_size(fonts::body, fonts::k_body_size, "amnesia");
|
||||
const float y = hud_pos.y + (size.y - label.y * s) * 0.5f;
|
||||
float x = hud_pos.x + pad_x * s;
|
||||
|
||||
if (!background_->bool_value) { // no card: a soft shadow keeps it readable
|
||||
const ImU32 shadow = theme::u32(theme::with_alpha(theme::bg(), 0.7f));
|
||||
dl->AddText(fonts::body, fs, ImVec2(x + s, y + s), shadow, "amnesia");
|
||||
dl->AddText(fonts::semibold, fs, ImVec2(x + (label.x + gap) * s + s - 5, y + s), shadow, buf);
|
||||
}
|
||||
|
||||
dl->AddText(fonts::body, fs, ImVec2(x, y), theme::u32(theme::muted()), "amnesia");
|
||||
x += (label.x + gap) * s;
|
||||
dl->AddText(fonts::semibold, fs, ImVec2(x, y), setting_color(*color_), buf);
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr float pad_x = 12.f;
|
||||
static constexpr float pad_y = 7.f;
|
||||
static constexpr float gap = 6.f;
|
||||
setting* background_ = nullptr;
|
||||
setting* scale_ = nullptr;
|
||||
setting* color_ = nullptr;
|
||||
};
|
||||
Reference in new issue
Block a user