Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wave animation #14810

Merged
merged 2 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Core/ConfigValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,5 @@ enum class BackgroundAnimation {
OFF = 0,
FLOATING_SYMBOLS = 1,
RECENT_GAMES = 2,
WAVE = 3,
};
2 changes: 1 addition & 1 deletion UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
Expand Down
32 changes: 32 additions & 0 deletions UI/MiscScreens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down Expand Up @@ -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);
}
Expand Down