#include "UI.hpp" #include #include #include void ImGui::SetNextWindowSizeRelScreen(float xPercent, float yPercent, ImGuiCond cond) { auto vs = ImGui::GetMainViewport()->Size; ImGui::SetNextWindowSize({ vs.x * xPercent, vs.y * yPercent }, cond); } void ImGui::SetNextWindowCentered(ImGuiCond cond) { auto vs = ImGui::GetMainViewport()->Size; ImGui::SetNextWindowPos({ vs.x / 2, vs.y / 2 }, cond, { 0.5f, 0.5f }); } void ImGui::PushDisabled() { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f * ImGui::GetStyle().Alpha); } void ImGui::PopDisabled() { ImGui::PopItemFlag(); ImGui::PopStyleVar(); } bool ImGui::Button(const char* label, bool disabled) { return Button(label, ImVec2{}, disabled); } bool ImGui::Button(const char* label, const ImVec2& sizeArg, bool disabled) { if (disabled) PushDisabled(); bool res = ImGui::Button(label, sizeArg); if (disabled) PopDisabled(); return res; } void ImGui::ErrorIcon() { ImGui::PushStyleColor(ImGuiCol_Text, ImVec4{ 237 / 255.0f, 67 / 255.0f, 55 / 255.0f, 1.0f }); // #ED4337 ImGui::Text(ICON_FA_EXCLAMATION_CIRCLE); ImGui::PopStyleColor(); } void ImGui::ErrorMessage(const char* fmt, ...) { ErrorIcon(); SameLine(); va_list args; va_start(args, fmt); TextV(fmt, args); va_end(args); } void ImGui::WarningIcon() { ImGui::PushStyleColor(ImGuiCol_Text, ImVec4{ 255 / 255.0f, 184 / 255.0f, 24 / 255.0f, 1.0f }); // #FFB818 ImGui::Text(ICON_FA_EXCLAMATION_TRIANGLE); ImGui::PopStyleColor(); } void ImGui::WarningMessage(const char* fmt, ...) { WarningIcon(); SameLine(); va_list args; va_start(args, fmt); TextV(fmt, args); va_end(args); }