From 863e1602ff30b405810ef4846902ca9f1568d7b0 Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Wed, 29 Jan 2025 07:18:36 +0000 Subject: [PATCH] imgui_utils: expose lerp values to BREATHE_MOTION macro --- UnleashedRecomp/ui/achievement_menu.cpp | 2 +- UnleashedRecomp/ui/imgui_utils.h | 2 +- UnleashedRecomp/ui/installer_wizard.cpp | 2 +- UnleashedRecomp/ui/message_window.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/UnleashedRecomp/ui/achievement_menu.cpp b/UnleashedRecomp/ui/achievement_menu.cpp index fdb9b3c..df3f986 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 = BREATHE_MOTION(breatheStart, 0.92f); + auto alpha = BREATHE_MOTION(1.0f, 0.65f, 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 f3b25f6..cc32128 100644 --- a/UnleashedRecomp/ui/imgui_utils.h +++ b/UnleashedRecomp/ui/imgui_utils.h @@ -15,7 +15,7 @@ #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) +#define BREATHE_MOTION(start, end, time, rate) Lerp(start, end, (sin((ImGui::GetTime() - time) * (2.0f * M_PI / rate)) + 1.0f) / 2.0f) inline void SetGradient(const ImVec2& min, const ImVec2& max, ImU32 top, ImU32 bottom) { diff --git a/UnleashedRecomp/ui/installer_wizard.cpp b/UnleashedRecomp/ui/installer_wizard.cpp index f3c50cf..13b100c 100644 --- a/UnleashedRecomp/ui/installer_wizard.cpp +++ b/UnleashedRecomp/ui/installer_wizard.cpp @@ -588,7 +588,7 @@ static void DrawScanlineBars() { // Breathing animation static auto breatheStart = ImGui::GetTime(); - breatheMotion = BREATHE_MOTION(breatheStart, 1.5f); + breatheMotion = BREATHE_MOTION(1.0f, 0.55f, breatheStart, 1.5f); } DrawTextWithOutline diff --git a/UnleashedRecomp/ui/message_window.cpp b/UnleashedRecomp/ui/message_window.cpp index f32b10e..9c7898d 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 = BREATHE_MOTION(breatheStart, 0.92f); + auto alpha = BREATHE_MOTION(1.0f, 0.55f, breatheStart, 0.92f); auto colour = IM_COL32(255, 255, 255, 255 * alpha); auto width = Scale(11);