installer_wizard: added breathing anim to title during installation

This commit is contained in:
Hyper 2025-01-29 07:13:47 +00:00
parent cb57e337b8
commit d5d2e83a10
4 changed files with 47 additions and 27 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);