MCPcopy Create free account
hub / github.com/davemoore22/sorcery / draw_text

Method draw_text

src/core/ui.cpp:1230–1256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1228
1229auto Sorcery::UI::draw_text_with_layer(const std::string string,
1230 const ImColor colour, const ImVec2 pos,
1231 const Enums::Layout::Font font) -> void {
1232
1233 with_Window(WINDOW_LAYER_TEXTS, nullptr,
1234 ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs |
1235 ImGuiWindowFlags_NoBackground) {
1236
1237 set_Font(fontstore->get_current_font(font).value());
1238
1239 const auto x{std::invoke([&] {
1240 if (pos.x == -1) {
1241 const auto viewport{ImGui::GetMainViewport()};
1242 const auto width{ImGui::CalcTextSize(string.c_str())};
1243 return (viewport->Size.x - width.x) / 2;
1244 } else
1245 return static_cast<float>(pos.x);
1246 })};
1247 const auto y{std::invoke([&] {
1248 if (pos.y == -1) {
1249 const auto viewport{ImGui::GetMainViewport()};
1250 const auto height{ImGui::CalcTextSize(string.c_str())};
1251 return (viewport->Size.y - height.y) / 2;
1252 } else
1253 return static_cast<float>(pos.y);
1254 })};
1255
1256 set_StyleColor(ImGuiCol_Text, ImVec4{colour});
1257 ImGui::SetCursorScreenPos(ImVec2{x, y});
1258 ImGui::TextUnformatted(string.c_str());
1259 }

Callers 3

_drawMethod · 0.80
displayMethod · 0.80
displayMethod · 0.80

Calls 1

get_current_fontMethod · 0.80

Tested by

no test coverage detected