diff --git a/Core/ConfigValues.h b/Core/ConfigValues.h index debeee4808f9..f6e7558ed10e 100644 --- a/Core/ConfigValues.h +++ b/Core/ConfigValues.h @@ -128,4 +128,5 @@ enum class BackgroundAnimation { OFF = 0, FLOATING_SYMBOLS = 1, RECENT_GAMES = 2, + WAVE = 3, }; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 8240e451374e..3d2b64b6176e 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -880,7 +880,7 @@ void GameSettingsScreen::CreateViews() { if (backgroundChoice_ != nullptr) { backgroundChoice_->OnClick.Handle(this, &GameSettingsScreen::OnChangeBackground); } - static const char *backgroundAnimations[] = { "No animation", "Floating symbols", "Recent games" }; + static const char *backgroundAnimations[] = { "No animation", "Floating symbols", "Recent games", "Waves" }; systemSettings->Add(new PopupMultiChoice(&g_Config.iBackgroundAnimation, sy->T("UI background animation"), backgroundAnimations, 0, ARRAY_SIZE(backgroundAnimations), sy->GetName(), screenManager())); systemSettings->Add(new ItemHeader(sy->T("Help the PPSSPP team"))); diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 485613e4eb03..5e5c5d907169 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -79,6 +79,35 @@ class Animation { virtual void Draw(UIContext &dc, double t, float alpha) = 0; }; +class WaveAnimation : public Animation { +public: + void Draw(UIContext &dc, double t, float alpha) override { + const uint32_t color = colorAlpha(0xFFFFFFFF, alpha * 0.2f); + const float speed = 1.0; + + Bounds bounds = dc.GetBounds(); + dc.Flush(); + dc.BeginNoTex(); + + t *= speed; + for (int x = 0; x < bounds.w; ++x) { + float i = x * 1280/bounds.w; + + float wave0 = sin(i*0.005+t*0.8)*0.05 + sin(i*0.002+t*0.25)*0.02 + sin(i*0.001+t*0.3)*0.03 + 0.625; + float wave1 = sin(i*0.0044+t*0.4)*0.07 + sin(i*0.003+t*0.1)*0.02 + sin(i*0.001+t*0.3)*0.01 + 0.625; + dc.Draw()->RectVGradient(x, wave0*bounds.h, pixel_in_dps_x, (1.0-wave0)*bounds.h, color, 0x00000000); + dc.Draw()->RectVGradient(x, wave1*bounds.h, pixel_in_dps_x, (1.0-wave1)*bounds.h, color, 0x00000000); + + // Add some "antialiasing" + dc.Draw()->RectVGradient(x, wave0*bounds.h-3*pixel_in_dps_y, pixel_in_dps_x, 3*pixel_in_dps_y, 0x00000000, color); + dc.Draw()->RectVGradient(x, wave1*bounds.h-3*pixel_in_dps_y, pixel_in_dps_x, 3*pixel_in_dps_y, 0x00000000, color); + } + + dc.Flush(); + dc.Begin(); + } +}; + class FloatingSymbolsAnimation : public Animation { public: ~FloatingSymbolsAnimation() override {} @@ -236,6 +265,9 @@ void DrawBackground(UIContext &dc, float alpha) { case BackgroundAnimation::RECENT_GAMES: g_Animation.reset(new RecentGamesAnimation()); break; + case BackgroundAnimation::WAVE: + g_Animation.reset(new WaveAnimation()); + break; default: g_Animation.reset(nullptr); }