diff options
| author | untodesu <kirill@untode.su> | 2025-07-01 03:08:39 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-07-01 03:08:39 +0500 |
| commit | 458e0005690ea9d579588a0a12368fc2c2c9a93a (patch) | |
| tree | 588a9ca6cb3c76d9193b5bd4601d64f0e50e8c8c /src/game/client/status_lines.cc | |
| parent | c7b0c8e0286a1b2bb7ec55e579137dfc3b22eeb9 (diff) | |
| download | voxelius-458e0005690ea9d579588a0a12368fc2c2c9a93a.tar.bz2 voxelius-458e0005690ea9d579588a0a12368fc2c2c9a93a.zip | |
I hyper-focued on refactoring again
- I put a cool-sounding "we are number one" remix on repeat and straight
up grinded the entire repository to a better state until 03:09 AM. I
guess I have something wrong in my brain that makes me do this shit
Diffstat (limited to 'src/game/client/status_lines.cc')
| -rw-r--r-- | src/game/client/status_lines.cc | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/src/game/client/status_lines.cc b/src/game/client/status_lines.cc deleted file mode 100644 index ea7293c..0000000 --- a/src/game/client/status_lines.cc +++ /dev/null @@ -1,79 +0,0 @@ -#include "client/pch.hh" - -#include "client/status_lines.hh" - -#include "client/globals.hh" -#include "client/imdraw_ext.hh" - -static float line_offsets[STATUS_COUNT]; -static ImFont* line_fonts[STATUS_COUNT]; - -static ImVec4 line_text_colors[STATUS_COUNT]; -static ImVec4 line_shadow_colors[STATUS_COUNT]; -static std::string line_strings[STATUS_COUNT]; -static std::uint64_t line_spawns[STATUS_COUNT]; -static float line_fadeouts[STATUS_COUNT]; - -void status_lines::init(void) -{ - for(unsigned int i = 0U; i < STATUS_COUNT; ++i) { - line_text_colors[i] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f); - line_shadow_colors[i] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f); - line_strings[i] = std::string(); - line_spawns[i] = UINT64_MAX; - line_fadeouts[i] = 0.0f; - } -} - -void status_lines::init_late(void) -{ - line_offsets[STATUS_DEBUG] = 64.0f; - line_offsets[STATUS_HOTBAR] = 40.0f; -} - -void status_lines::layout(void) -{ - line_fonts[STATUS_DEBUG] = globals::font_debug; - line_fonts[STATUS_HOTBAR] = globals::font_chat; - - auto viewport = ImGui::GetMainViewport(); - auto draw_list = ImGui::GetForegroundDrawList(); - - for(unsigned int i = 0U; i < STATUS_COUNT; ++i) { - auto offset = line_offsets[i] * globals::gui_scale; - auto& text = line_strings[i]; - auto* font = line_fonts[i]; - - auto size = font->CalcTextSizeA(font->FontSize, FLT_MAX, 0.0f, text.c_str(), text.c_str() + text.size()); - auto pos = ImVec2(0.5f * (viewport->Size.x - size.x), viewport->Size.y - offset); - - auto spawn = line_spawns[i]; - auto fadeout = line_fadeouts[i]; - auto alpha = std::exp(-1.0f * std::pow(1.0e-6f * static_cast<float>(globals::curtime - spawn) / fadeout, 10.0f)); - - auto& color = line_text_colors[i]; - auto& shadow = line_shadow_colors[i]; - auto color_U32 = ImGui::GetColorU32(ImVec4(color.x, color.y, color.z, color.w * alpha)); - auto shadow_U32 = ImGui::GetColorU32(ImVec4(shadow.x, shadow.y, shadow.z, color.w * alpha)); - - imdraw_ext::text_shadow(text, pos, color_U32, shadow_U32, font, draw_list); - } -} - -void status_lines::set(unsigned int line, const std::string& text, const ImVec4& color, float fadeout) -{ - line_text_colors[line] = ImVec4(color.x, color.y, color.z, color.w); - line_shadow_colors[line] = ImVec4(color.x * 0.1f, color.y * 0.1f, color.z * 0.1f, color.w); - line_strings[line] = std::string(text); - line_spawns[line] = globals::curtime; - line_fadeouts[line] = fadeout; -} - -void status_lines::unset(unsigned int line) -{ - line_text_colors[line] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f); - line_shadow_colors[line] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f); - line_strings[line] = std::string(); - line_spawns[line] = UINT64_C(0); - line_fadeouts[line] = 0.0f; -} |
