From d5d2e83a10e0a368f19f059eb0f66b65b910a7c7 Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Wed, 29 Jan 2025 07:13:47 +0000 Subject: [PATCH] installer_wizard: added breathing anim to title during installation --- UnleashedRecomp/ui/achievement_menu.cpp | 2 +- UnleashedRecomp/ui/imgui_utils.h | 2 + UnleashedRecomp/ui/installer_wizard.cpp | 68 ++++++++++++++++--------- UnleashedRecomp/ui/message_window.cpp | 2 +- 4 files changed, 47 insertions(+), 27 deletions(-) diff --git a/UnleashedRecomp/ui/achievement_menu.cpp b/UnleashedRecomp/ui/achievement_menu.cpp index bae8ba9..fdb9b3c 100644 --- a/UnleashedRecomp/ui/achievement_menu.cpp +++ b/UnleashedRecomp/ui/achievement_menu.cpp @@ -81,7 +81,7 @@ static void DrawSelectionContainer(ImVec2 min, ImVec2 max) auto drawList = ImGui::GetForegroundDrawList(); static auto breatheStart = ImGui::GetTime(); - auto alpha = Lerp(1.0f, 0.65f, (sin((ImGui::GetTime() - breatheStart) * (2.0f * M_PI / (55.0f / 60.0f))) + 1.0f) / 2.0f); + auto alpha = BREATHE_MOTION(breatheStart, 0.92f); auto colour = IM_COL32(255, 255, 255, 255 * alpha); auto commonWidth = Scale(11); diff --git a/UnleashedRecomp/ui/imgui_utils.h b/UnleashedRecomp/ui/imgui_utils.h index 1c407e8..f3b25f6 100644 --- a/UnleashedRecomp/ui/imgui_utils.h +++ b/UnleashedRecomp/ui/imgui_utils.h @@ -15,6 +15,8 @@ #define CENTRE_TEXT_HORZ(min, max, textSize) min.x + ((max.x - min.x) - textSize.x) / 2 #define CENTRE_TEXT_VERT(min, max, textSize) min.y + ((max.y - min.y) - textSize.y) / 2 +#define BREATHE_MOTION(start, rate) Lerp(1.0f, 0.55f, (sin((ImGui::GetTime() - start) * (2.0f * M_PI / rate)) + 1.0f) / 2.0f) + inline void SetGradient(const ImVec2& min, const ImVec2& max, ImU32 top, ImU32 bottom) { auto callbackData = AddImGuiCallback(ImGuiCallback::SetGradient); diff --git a/UnleashedRecomp/ui/installer_wizard.cpp b/UnleashedRecomp/ui/installer_wizard.cpp index 944bde7..f3c50cf 100644 --- a/UnleashedRecomp/ui/installer_wizard.cpp +++ b/UnleashedRecomp/ui/installer_wizard.cpp @@ -580,38 +580,56 @@ static void DrawScanlineBars() SetShaderModifier(IMGUI_SHADER_MODIFIER_NONE); // Installer text - const std::string &headerText = Localise(g_currentPage == WizardPage::Installing ? "Installer_Header_Installing" : "Installer_Header_Installer"); + auto& headerText = Localise(g_currentPage == WizardPage::Installing ? "Installer_Header_Installing" : "Installer_Header_Installer"); auto alphaMotion = ComputeMotionInstaller(g_appearTime, g_disappearTime, TITLE_ANIMATION_TIME, TITLE_ANIMATION_DURATION); - DrawTextWithOutline(g_dfsogeistdFont, Scale(42.0f), { g_aspectRatioOffsetX + Scale(285.0f), Scale(57.0f) }, IM_COL32(255, 195, 0, 255 * alphaMotion), headerText.c_str(), 4, IM_COL32(0, 0, 0, 255 * alphaMotion), IMGUI_SHADER_MODIFIER_TITLE_BEVEL); + auto breatheMotion = 1.0f; + + if (g_currentPage == WizardPage::Installing) + { + // Breathing animation + static auto breatheStart = ImGui::GetTime(); + breatheMotion = BREATHE_MOTION(breatheStart, 1.5f); + } + + DrawTextWithOutline + ( + g_dfsogeistdFont, + Scale(42), + { g_aspectRatioOffsetX + Scale(285), Scale(57) }, + IM_COL32(255, 195, 0, 255 * alphaMotion * breatheMotion), + headerText.c_str(), 4, + IM_COL32(0, 0, 0, 255 * alphaMotion * breatheMotion), + IMGUI_SHADER_MODIFIER_TITLE_BEVEL + ); auto drawLine = [&](bool top) - { - float y = top ? height : (res.y - height); + { + float y = top ? height : (res.y - height); - const uint32_t TOP_COLOR0 = IM_COL32(222, 255, 189, 7 * scanlinesAlpha); - const uint32_t TOP_COLOR1 = IM_COL32(222, 255, 189, 65 * scanlinesAlpha); - const uint32_t BOTTOM_COLOR0 = IM_COL32(173, 255, 156, 65 * scanlinesAlpha); - const uint32_t BOTTOM_COLOR1 = IM_COL32(173, 255, 156, 7 * scanlinesAlpha); + const uint32_t TOP_COLOR0 = IM_COL32(222, 255, 189, 7 * scanlinesAlpha); + const uint32_t TOP_COLOR1 = IM_COL32(222, 255, 189, 65 * scanlinesAlpha); + const uint32_t BOTTOM_COLOR0 = IM_COL32(173, 255, 156, 65 * scanlinesAlpha); + const uint32_t BOTTOM_COLOR1 = IM_COL32(173, 255, 156, 7 * scanlinesAlpha); - drawList->AddRectFilledMultiColor( - { 0.0f, y - Scale(2.0f) }, - { res.x, y }, - top ? TOP_COLOR0 : BOTTOM_COLOR1, - top ? TOP_COLOR0 : BOTTOM_COLOR1, - top ? TOP_COLOR1 : BOTTOM_COLOR0, - top ? TOP_COLOR1 : BOTTOM_COLOR0); + drawList->AddRectFilledMultiColor( + { 0.0f, y - Scale(2.0f) }, + { res.x, y }, + top ? TOP_COLOR0 : BOTTOM_COLOR1, + top ? TOP_COLOR0 : BOTTOM_COLOR1, + top ? TOP_COLOR1 : BOTTOM_COLOR0, + top ? TOP_COLOR1 : BOTTOM_COLOR0); - drawList->AddRectFilledMultiColor( - { 0.0f, y + Scale(1.0f) }, - { res.x, y + Scale(3.0f) }, - top ? BOTTOM_COLOR0 : TOP_COLOR1, - top ? BOTTOM_COLOR0 : TOP_COLOR1, - top ? BOTTOM_COLOR1 : TOP_COLOR0, - top ? BOTTOM_COLOR1 : TOP_COLOR0); + drawList->AddRectFilledMultiColor( + { 0.0f, y + Scale(1.0f) }, + { res.x, y + Scale(3.0f) }, + top ? BOTTOM_COLOR0 : TOP_COLOR1, + top ? BOTTOM_COLOR0 : TOP_COLOR1, + top ? BOTTOM_COLOR1 : TOP_COLOR0, + top ? BOTTOM_COLOR1 : TOP_COLOR0); - const uint32_t CENTER_COLOR = IM_COL32(115, 178, 104, 255 * scanlinesAlpha); - drawList->AddRectFilled({ 0.0f, y }, { res.x, y + Scale(1.0f) }, CENTER_COLOR); - }; + const uint32_t CENTER_COLOR = IM_COL32(115, 178, 104, 255 * scanlinesAlpha); + drawList->AddRectFilled({ 0.0f, y }, { res.x, y + Scale(1.0f) }, CENTER_COLOR); + }; // Top bar line drawLine(true); diff --git a/UnleashedRecomp/ui/message_window.cpp b/UnleashedRecomp/ui/message_window.cpp index 1b0dfb0..f32b10e 100644 --- a/UnleashedRecomp/ui/message_window.cpp +++ b/UnleashedRecomp/ui/message_window.cpp @@ -216,7 +216,7 @@ void DrawButton(int rowIndex, float yOffset, float width, float height, std::str if (isSelected) { static auto breatheStart = ImGui::GetTime(); - auto alpha = Lerp(1.0f, 0.75f, (sin((ImGui::GetTime() - breatheStart) * (2.0f * M_PI / (55.0f / 60.0f))) + 1.0f) / 2.0f); + auto alpha = BREATHE_MOTION(breatheStart, 0.92f); auto colour = IM_COL32(255, 255, 255, 255 * alpha); auto width = Scale(11);