mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Colored Symbols bg anim, move static vars into classes
This commit is contained in:
@@ -168,6 +168,7 @@ enum class BackgroundAnimation {
|
||||
WAVE = 3,
|
||||
MOVING_BACKGROUND = 4,
|
||||
BOUNCING_ICON = 5,
|
||||
FLOATING_SYMBOLS_COLORED = 6,
|
||||
};
|
||||
|
||||
// iOS only
|
||||
|
||||
@@ -1179,7 +1179,7 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
|
||||
|
||||
systemSettings->Add(new PopupMultiChoice(&g_Config.iNotificationPos, sy->T("Notification screen position"), positions, -1, ARRAY_SIZE(positions), I18NCat::DIALOG, screenManager()));
|
||||
|
||||
static const char *backgroundAnimations[] = { "No animation", "Floating symbols", "Recent games", "Waves", "Moving background", "Bouncing icon" };
|
||||
static const char *backgroundAnimations[] = { "No animation", "Floating symbols", "Recent games", "Waves", "Moving background", "Bouncing icon", "Colored floating symbols" };
|
||||
systemSettings->Add(new PopupMultiChoice(&g_Config.iBackgroundAnimation, sy->T("UI background animation"), backgroundAnimations, 0, ARRAY_SIZE(backgroundAnimations), I18NCat::SYSTEM, screenManager()));
|
||||
|
||||
PopupMultiChoiceDynamic *theme = systemSettings->Add(new PopupMultiChoiceDynamic(&g_Config.sThemeName, sy->T("Theme"), GetThemeInfoNames(), I18NCat::THEMES, screenManager()));
|
||||
|
||||
+30
-25
@@ -64,20 +64,6 @@
|
||||
#pragma execution_character_set("utf-8")
|
||||
#endif
|
||||
|
||||
static const ImageID symbols[4] = {
|
||||
ImageID("I_CROSS"),
|
||||
ImageID("I_CIRCLE"),
|
||||
ImageID("I_SQUARE"),
|
||||
ImageID("I_TRIANGLE"),
|
||||
};
|
||||
|
||||
static const uint32_t colors[4] = {
|
||||
0xC0FFFFFF,
|
||||
0xC0FFFFFF,
|
||||
0xC0FFFFFF,
|
||||
0xC0FFFFFF,
|
||||
};
|
||||
|
||||
static Draw::Texture *bgTexture;
|
||||
|
||||
class Animation {
|
||||
@@ -86,13 +72,6 @@ public:
|
||||
virtual void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) = 0;
|
||||
};
|
||||
|
||||
static constexpr float XFAC = 0.3f;
|
||||
static constexpr float YFAC = 0.3f;
|
||||
static constexpr float ZFAC = 0.12f;
|
||||
static constexpr float XSPEED = 0.05f;
|
||||
static constexpr float YSPEED = 0.05f;
|
||||
static constexpr float ZSPEED = 0.1f;
|
||||
|
||||
class MovingBackground : public Animation {
|
||||
public:
|
||||
void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) override {
|
||||
@@ -123,6 +102,13 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr float XFAC = 0.3f;
|
||||
static constexpr float YFAC = 0.3f;
|
||||
static constexpr float ZFAC = 0.12f;
|
||||
static constexpr float XSPEED = 0.05f;
|
||||
static constexpr float YSPEED = 0.05f;
|
||||
static constexpr float ZSPEED = 0.1f;
|
||||
|
||||
float lastX_ = 0.0f;
|
||||
float lastY_ = 0.0f;
|
||||
float lastZ_ = 1.0f + std::max(XFAC, YFAC);
|
||||
@@ -165,6 +151,10 @@ public:
|
||||
|
||||
class FloatingSymbolsAnimation : public Animation {
|
||||
public:
|
||||
FloatingSymbolsAnimation(bool is_colored) {
|
||||
this->is_colored = is_colored;
|
||||
}
|
||||
|
||||
void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) override {
|
||||
dc.Flush();
|
||||
dc.Begin();
|
||||
@@ -179,14 +169,19 @@ public:
|
||||
float y = ybase[i] + dc.GetBounds().y + 40 * cosf(i * 7.2f + t * 1.3f);
|
||||
float angle = (float)sin(i + t);
|
||||
int n = i & 3;
|
||||
ui_draw2d.DrawImageRotated(symbols[n], x, y, 1.0f, angle, colorAlpha(colors[n], alpha * 0.1f));
|
||||
Color color = is_colored ? colorAlpha(COLORS[n], alpha * 0.25f) : colorAlpha(DEFAULT_COLOR, alpha * 0.1f);
|
||||
ui_draw2d.DrawImageRotated(SYMBOLS[n], x, y, 1.0f, angle, color);
|
||||
}
|
||||
dc.Flush();
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr int COUNT = 100;
|
||||
static constexpr Color DEFAULT_COLOR = 0xC0FFFFFF;
|
||||
static constexpr Color COLORS[4] = { 0xFFE3B56F, 0xFF615BFF, 0xFFAA88F3, 0xFFC2CC7A, }; // X O D A
|
||||
static const ImageID SYMBOLS[4];
|
||||
|
||||
bool is_colored = false;
|
||||
float xbase[COUNT]{};
|
||||
float ybase[COUNT]{};
|
||||
float last_xres = 0;
|
||||
@@ -204,6 +199,13 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
const ImageID FloatingSymbolsAnimation::SYMBOLS[4] = {
|
||||
ImageID("I_CROSS"),
|
||||
ImageID("I_CIRCLE"),
|
||||
ImageID("I_SQUARE"),
|
||||
ImageID("I_TRIANGLE"),
|
||||
};
|
||||
|
||||
class RecentGamesAnimation : public Animation {
|
||||
public:
|
||||
void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) override {
|
||||
@@ -306,7 +308,7 @@ class BouncingIconAnimation : public Animation {
|
||||
float xpos = xbase + dc.GetBounds().x;
|
||||
float ypos = ybase + dc.GetBounds().y;
|
||||
ImageID icon = !color_ix && System_GetPropertyBool(SYSPROP_APP_GOLD) ? ImageID("I_ICONGOLD") : ImageID("I_ICON");
|
||||
ui_draw2d.DrawImage(icon, xpos, ypos, scale, colors[color_ix], ALIGN_CENTER);
|
||||
ui_draw2d.DrawImage(icon, xpos, ypos, scale, COLORS[color_ix], ALIGN_CENTER);
|
||||
dc.Flush();
|
||||
|
||||
// Switch direction if within border.
|
||||
@@ -338,7 +340,7 @@ class BouncingIconAnimation : public Animation {
|
||||
|
||||
private:
|
||||
static constexpr int COLOR_COUNT = 11;
|
||||
static constexpr Color colors[COLOR_COUNT] = { 0xFFFFFFFF, 0xFFFFFF00, 0xFFFF0000, 0xFF00FF00, 0xFF0000FF,
|
||||
static constexpr Color COLORS[COLOR_COUNT] = { 0xFFFFFFFF, 0xFFFFFF00, 0xFFFF0000, 0xFF00FF00, 0xFF0000FF,
|
||||
0xFF00FFFF, 0xFFFF00FF, 0xFF4111D1, 0xFF3577F3, 0xFFAA77FF, 0xFF623B84 };
|
||||
|
||||
float xbase = 0.0f;
|
||||
@@ -420,7 +422,7 @@ void DrawBackground(UIContext &dc, float alpha, float x, float y, float z) {
|
||||
|
||||
switch (g_CurBackgroundAnimation) {
|
||||
case BackgroundAnimation::FLOATING_SYMBOLS:
|
||||
g_Animation.reset(new FloatingSymbolsAnimation());
|
||||
g_Animation.reset(new FloatingSymbolsAnimation(false));
|
||||
break;
|
||||
case BackgroundAnimation::RECENT_GAMES:
|
||||
g_Animation.reset(new RecentGamesAnimation());
|
||||
@@ -434,6 +436,9 @@ void DrawBackground(UIContext &dc, float alpha, float x, float y, float z) {
|
||||
case BackgroundAnimation::BOUNCING_ICON:
|
||||
g_Animation.reset(new BouncingIconAnimation());
|
||||
break;
|
||||
case BackgroundAnimation::FLOATING_SYMBOLS_COLORED:
|
||||
g_Animation.reset(new FloatingSymbolsAnimation(true));
|
||||
break;
|
||||
default:
|
||||
g_Animation.reset(nullptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user