summaryrefslogtreecommitdiffstats
path: root/src/game/client/gui/imutils_text.cc
blob: 1621c42e8739c7f17e4f97ab5ed379bbfe97a4a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// SPDX-License-Identifier: BSD-2-Clause
// Copyright (c) 2025 Kirill Dmitrievich
// File: imutils_text.cc
// Description: Text with shadow

#include "client/pch.hh"

#include "client/gui/imutils_text.hh"

#include "client/globals.hh"

void imutils::text_nw(ImDrawList* list, std::string_view text, const ImVec2& pos, ImU32 color, ImU32 shadow, ImFont* font)
{
    assert(list);
    assert(font);

    imutils::text_nw(list, text, pos, color, shadow, font, font->LegacySize);
}

void imutils::text_nw(ImDrawList* list, std::string_view text, const ImVec2& pos, ImU32 color, ImU32 shadow, ImFont* font, float size)
{
    assert(list);
    assert(font);

    auto shift = static_cast<float>(globals::gui_scale);
    auto shadow_pos = ImVec2(pos.x + shift, pos.y + shift);

    list->AddText(font, size, shadow_pos, shadow, text.data(), text.data() + text.size());
    list->AddText(font, size, pos, color, text.data(), text.data() + text.size());
}

void imutils::text_wr(ImDrawList* list, std::string_view text, const ImVec2& pos, ImU32 color, ImU32 shadow, ImFont* font, float wrap)
{
    assert(list);
    assert(font);

    imutils::text_wr(list, text, pos, color, shadow, font, wrap, font->LegacySize);
}

void imutils::text_wr(ImDrawList* list, std::string_view text, const ImVec2& pos, ImU32 color, ImU32 shadow, ImFont* font, float wrap,
    float size)
{
    assert(list);
    assert(font);

    auto shift = static_cast<float>(globals::gui_scale);
    auto shadow_pos = ImVec2(pos.x + shift, pos.y + shift);

    list->AddText(font, size, shadow_pos, shadow, text.data(), text.data() + text.size(), wrap);
    list->AddText(font, size, pos, color, text.data(), text.data() + text.size(), wrap);
}