[TABLE]
[TR]
[TD]float RenderText(const std::string text, const ImVec2& position, float size, ImVec4 color, bool center, ImFont* DefaultFont)[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]{[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] ImDrawList* Draw = ImGui::GetWindowDrawList();[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD] std::stringstream stream(text);[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] std::string line;[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD] float y = 0.0f;[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] int i = 0;[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD] while (std::getline(stream, line))[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] {[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] ImVec2 textSize = DefaultFont->CalcTextSizeA(size, FLT_MAX, 0.0f, line.c_str());[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD] if (center)[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] {[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] Draw->AddText(DefaultFont, size, { (position.x - textSize.x / 2.0f) + 1.0f, (position.y + textSize.y * i) + 1.0f }, ImGui::GetColorU32(ImVec4(0.0f, 0.0f, 0.0f, color.w)), line.c_str());[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] Draw->AddText(DefaultFont, size, { (position.x - textSize.x / 2.0f) - 1.0f, (position.y + textSize.y * i) - 1.0f }, ImGui::GetColorU32(ImVec4(0.0f, 0.0f, 0.0f, color.w)), line.c_str());[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] Draw->AddText(DefaultFont, size, { (position.x - textSize.x / 2.0f) + 1.0f, (position.y + textSize.y * i) - 1.0f }, ImGui::GetColorU32(ImVec4(0.0f, 0.0f, 0.0f, color.w)), line.c_str());[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] Draw->AddText(DefaultFont, size, { (position.x - textSize.x / 2.0f) - 1.0f, (position.y + textSize.y * i) + 1.0f }, ImGui::GetColorU32(ImVec4(0.0f, 0.0f, 0.0f, color.w)), line.c_str());[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD] Draw->AddText(DefaultFont, size, { position.x - textSize.x / 2.0f, position.y + textSize.y * i }, ImGui::GetColorU32(color), line.c_str());[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] }[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] else[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] {[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] Draw->AddText(DefaultFont, size, { (position.x) + 1.0f, (position.y + textSize.y * i) + 1.0f }, ImGui::GetColorU32(ImVec4(0.0f, 0.0f, 0.0f, color.w)), line.c_str());[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] Draw->AddText(DefaultFont, size, { (position.x) - 1.0f, (position.y + textSize.y * i) - 1.0f }, ImGui::GetColorU32(ImVec4(0.0f, 0.0f, 0.0f, color.w)), line.c_str());[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] Draw->AddText(DefaultFont, size, { (position.x) + 1.0f, (position.y + textSize.y * i) - 1.0f }, ImGui::GetColorU32(ImVec4(0.0f, 0.0f, 0.0f, color.w)), line.c_str());[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] Draw->AddText(DefaultFont, size, { (position.x) - 1.0f, (position.y + textSize.y * i) + 1.0f }, ImGui::GetColorU32(ImVec4(0.0f, 0.0f, 0.0f, color.w)), line.c_str());[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD] Draw->AddText(DefaultFont, size, { position.x, position.y + textSize.y * i }, ImGui::GetColorU32(color), line.c_str());[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] }[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD] y = position.y + textSize.y * (i + 1);[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] i++;[/TD]
[/TR]
[TR]
[TD][/TD]
[TD] }[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD] return y;[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]}[/TD]
[/TR]
[/TABLE]