Skip to content

Commit

Permalink
Add highlights to CHLCC intro background
Browse files Browse the repository at this point in the history
  • Loading branch information
newo-2001 committed Oct 20, 2024
1 parent a69f9ae commit 6b4bda3
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 25 deletions.
80 changes: 75 additions & 5 deletions profiles/chlcc/hud/titlemenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ root.TitleMenu = {
PressToStartAnimDurationIn = 0.5,
PressToStartAnimDurationOut = 0.5,
PressToStartSprite = "TitleMenuPressToStart",
BackgroundSprite = "TitleMenuBackground",
IntroBackgroundSprite = "TitleMenuIntroBackground",
IntroBouncingStarSprite = "StarLogo",
IntroSmallStarSprite = "TitleMenuIntroSmallStar",
IntroBigStarSprite = "TitleMenuIntroBigStar",
IntroSmallStarSprite = "IntroSmallStar",
IntroExplodingStarAnimationDuration = 1.5,
IntroExplodingStarAnimationRotationDuration = 0.5,
IntroExplodingStarAnimationDistance = 315,
BackgroundSprite = "TitleMenuBackground",
IntroPanningAnimationDuration = 2.3,
IntroBigStarSprite = "IntroBigStar",
DelusionADVUnderSprite = "DelusionADVUnder", -- "DelusionADVUnderEnglish" with the TLed assets, "DelusionADVUnder" with the original ones
DelusionADVUnderX = 78, --74 with the TLed assets, 78 with the original ones
DelusionADVUnderY = 394, --396 with the TLed assets, 394 with the original ones
Expand Down Expand Up @@ -111,6 +112,25 @@ root.TitleMenu = {
IntroStarBounceAnimationSegmentCount = 7
};

root.TitleMenu.IntroHighlightSprites = {
"IntroBrightGreenHighlight",
"IntroSunHighlight",
"IntroGrayHighlight",
"IntroCrescentRainbowHighlight",
"IntroBlueHighlight",
"IntroWhiteHighlight",
"IntroBrownHighlight",
"IntroDiamondHighlight",
"IntroDarkGreenHighlight",
"IntroCircularRainbowHighlight"
};

-- Positions along the diagonal normalized between -1 and 1
root.TitleMenu.IntroHighlightPositions = {
-1.13, -1.00, -0.49, 0.00, 0.17,
0.30, 0.58, 0.69, 0.91, 1.12
};

for i = 0, 3 do
root.Sprites["TitleMenuEntry" .. i] = {
Sheet = "Title",
Expand Down Expand Up @@ -248,16 +268,66 @@ root.Sprites["TitleMenuIntroBackground"] = {
Bounds = { X = 0, Y = 0, Width = 1280, Height = 720 },
};

root.Sprites["TitleMenuIntroSmallStar"] = {
root.Sprites["IntroSmallStar"] = {
Sheet = "Title",
Bounds = { X = 1153, Y = 534, Width = 45, Height = 44 },
};

root.Sprites["TitleMenuIntroBigStar"] = {
root.Sprites["IntroBigStar"] = {
Sheet = "Title",
Bounds = { X = 1156, Y = 345, Width = 178, Height = 170 },
};

root.Sprites["IntroBrightGreenHighlight"] = {
Sheet = "Highlights",
Bounds = { X = 1536, Y = 0, Width = 256, Height = 256 },
};

root.Sprites["IntroSunHighlight"] = {
Sheet = "Highlights",
Bounds = { X = 0, Y = 0, Width = 512, Height = 512 },
};

root.Sprites["IntroGrayHighlight"] = {
Sheet = "Highlights",
Bounds = { X = 1536, Y = 256, Width = 256, Height = 256 },
};

root.Sprites["IntroCrescentRainbowHighlight"] = {
Sheet = "Highlights",
Bounds = { X = 0, Y = 512, Width = 512, Height = 512 },
};

root.Sprites["IntroBlueHighlight"] = {
Sheet = "Highlights",
Bounds = { X = 1280, Y = 256, Width = 256, Height = 256 },
};

root.Sprites["IntroWhiteHighlight"] = {
Sheet = "Highlights",
Bounds = { X = 1280, Y = 0, Width = 256, Height = 256 },
};

root.Sprites["IntroBrownHighlight"] = {
Sheet = "Highlights",
Bounds = { X = 1024, Y = 256, Width = 256, Height = 256 },
};

root.Sprites["IntroDiamondHighlight"] = {
Sheet = "Highlights",
Bounds = { X = 512, Y = 512, Width = 512, Height = 512 },
};

root.Sprites["IntroDarkGreenHighlight"] = {
Sheet = "Highlights",
Bounds = { X = 1024, Y = 0, Width = 256, Height = 256 },
};

root.Sprites["IntroCircularRainbowHighlight"] = {
Sheet = "Highlights",
Bounds = { X = 512, Y = 0, Width = 512, Height = 512 },
};

root.Sprites["TitleMenuBackground"] = {
Sheet = "TitleBg2",
Bounds = { X = 0, Y = 0, Width = 1280, Height = 720 },
Expand Down
11 changes: 8 additions & 3 deletions profiles/chlcc/sprites.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ root.SpriteSheets = {
DesignHeight = 1024
},
["AlbumThumbnailSheet"] = {
Path = {Mount = "system", Id = 1 },
Path = { Mount = "system", Id = 1 },
DesignWidth = 2048,
DesignHeight = 1024
},
["AlbumThumbnailSheet2"] = {
Path = {Mount = "system", Id = 2 },
Path = { Mount = "system", Id = 2 },
DesignWidth = 2048,
DesignHeight = 1024
},
Expand All @@ -29,6 +29,11 @@ root.SpriteSheets = {
DesignWidth = 2048,
DesignHeight = 720
},
["Highlights"] = {
Path = { Mount = "system", Id = 7 },
DesignWidth = 2048,
DesignHeight = 1024
},
["Menu"] = {
Path = { Mount = "system", Id = 8 },
DesignWidth = 2048,
Expand Down Expand Up @@ -101,4 +106,4 @@ root.SpriteSheets = {
},
};

root.Sprites = {};
root.Sprites = {};
56 changes: 47 additions & 9 deletions src/games/chlcc/titlemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "../../profile/games/chlcc/titlemenu.h"
#include "../../profile/scriptvars.h"
#include "../../profile/game.h"
#include "../../profile/profile.h"
#include <vector>

namespace Impacto {
Expand All @@ -21,6 +22,7 @@ namespace CHLCC {
using namespace Impacto::Profile::TitleMenu;
using namespace Impacto::Profile::CHLCC::TitleMenu;
using namespace Impacto::Profile::ScriptVars;
using namespace Impacto::Profile;
using namespace Impacto::Audio;

using namespace Impacto::UI::Widgets::CHLCC;
Expand Down Expand Up @@ -259,6 +261,7 @@ void TitleMenu::Hide() {

void TitleMenu::Update(float dt) {
UpdateInput();
IntroPanningAnimation.Update(dt);
IntroStarBounceAnimation.Update(dt);
IntroExplodingStarAnimation.Update(dt);
IntroExplodingStarRotationAnimation.Update(dt);
Expand Down Expand Up @@ -448,16 +451,28 @@ void TitleMenu::Render() {
}
}

inline void TitleMenu::DrawIntroAnimation() {
void TitleMenu::DrawIntroAnimation() {
Renderer->DrawSprite(IntroBackgroundSprite, glm::vec2(0.0f));

switch (TitleMenuIntroAnimationState) {
switch (IntroAnimationState) {

Check warning on line 457 in src/games/chlcc/titlemenu.cpp

View workflow job for this annotation

GitHub Actions / macos-arm64

enumeration value 'In' not handled in switch [-Wswitch]

Check warning on line 457 in src/games/chlcc/titlemenu.cpp

View workflow job for this annotation

GitHub Actions / macos-x64

enumeration value 'In' not handled in switch [-Wswitch]

Check warning on line 457 in src/games/chlcc/titlemenu.cpp

View workflow job for this annotation

GitHub Actions / android

enumeration value 'In' not handled in switch [-Wswitch]
case TitleMenuIntroAnimationState::Out: {
IntroStarBounceAnimation.StartIn();
TitleMenuIntroAnimationState = TitleMenuIntroAnimationState::BouncingStar;
IntroPanningAnimation.StartIn();
IntroAnimationState = TitleMenuIntroAnimationState::Panning;
return;
}
case TitleMenuIntroAnimationState::Panning: {
DrawIntroHighlights();

if (IntroPanningAnimation.IsIn()) {
IntroStarBounceAnimation.StartIn();
IntroAnimationState = TitleMenuIntroAnimationState::BouncingStar;
}

return;
}
case TitleMenuIntroAnimationState::BouncingStar: {
DrawIntroHighlights();

if (IntroStarBounceAnimation.GetCurrentSegmentIndex() == 1 &&
Audio::Channels[Audio::AC_SE0]->State == ACS_Paused) {
Audio::Channels[Audio::AC_SE0]->Resume();
Expand All @@ -469,15 +484,16 @@ inline void TitleMenu::DrawIntroAnimation() {
Renderer->DrawSprite(StarLogoSprite, position);

if (IntroStarBounceAnimation.IsIn()) {
TitleMenuIntroAnimationState =
TitleMenuIntroAnimationState::ExplodingStar;
IntroAnimationState = TitleMenuIntroAnimationState::ExplodingStar;
IntroExplodingStarAnimation.StartIn();
IntroExplodingStarRotationAnimation.StartIn();
}

return;
}
case TitleMenuIntroAnimationState::ExplodingStar: {
DrawIntroHighlights();

glm::vec2 origin = IntroStarBounceAnimation.GetPosition() -
IntroBouncingStarSprite.Bounds.Dimensions() / 2.0f;

Expand All @@ -499,17 +515,39 @@ inline void TitleMenu::DrawIntroAnimation() {
}

if (IntroExplodingStarAnimation.IsIn()) {
TitleMenuIntroAnimationState =
TitleMenuIntroAnimationState::FallingStars;
IntroAnimationState = TitleMenuIntroAnimationState::FallingStars;
IntroExplodingStarRotationAnimation.State = AS_Stopped;
}

return;
}
case TitleMenuIntroAnimationState::FallingStars: {
DrawIntroHighlights();
}
}
}

inline void TitleMenu::DrawTitleMenuBackGraphics() {
void TitleMenu::DrawIntroHighlights() const {
Renderer->SetBlendMode(RendererBlendMode::Additive);

for (size_t i = 0; i < IntroHighlightCount; i++) {
const Sprite& sprite = IntroHighlightSprites[i];

constexpr float scale = 1.5f;
float offset = IntroHighlightPositions[i];
glm::vec2 position =
glm::vec2(offset * DesignWidth / 2 + DesignWidth / 2,
offset * DesignHeight / 2 + DesignHeight / 2) -
sprite.Bounds.Dimensions() / 2.0f * scale;

Renderer->DrawSprite(sprite, position, {1.0f, 1.0f, 1.0f, 1.0f},
glm::vec2(scale));
}

Renderer->SetBlendMode(RendererBlendMode::Normal);
}

void TitleMenu::DrawTitleMenuBackGraphics() const {
Renderer->DrawSprite(BackgroundSprite, glm::vec2(0.0f));
Renderer->DrawSprite(SpinningCircleSprite,
glm::vec2(SpinningCircleX, SpinningCircleY),
Expand Down
10 changes: 6 additions & 4 deletions src/games/chlcc/titlemenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace Impacto {
namespace UI {
namespace CHLCC {

BETTER_ENUM(TitleMenuIntroAnimationState, int, Out, BouncingStar, ExplodingStar,
FallingStars, In)
BETTER_ENUM(TitleMenuIntroAnimationState, int, Out, Panning, BouncingStar,
ExplodingStar, FallingStars, In)

class TitleMenu : public Menu {
public:
Expand All @@ -30,6 +30,7 @@ class TitleMenu : public Menu {
Animation SecondaryItemsFadeInAnimation;
Animation SpinningCircleAnimation;

Animation IntroPanningAnimation;
PathAnimation IntroStarBounceAnimation;
Animation IntroExplodingStarAnimation;
Animation IntroExplodingStarRotationAnimation;
Expand All @@ -38,7 +39,8 @@ class TitleMenu : public Menu {
void SecondaryButtonOnClick(Widgets::Button* target);

void DrawIntroAnimation();
void DrawTitleMenuBackGraphics();
void DrawIntroHighlights() const;
void DrawTitleMenuBackGraphics() const;

private:
Widgets::Group* MainItems;
Expand All @@ -65,7 +67,7 @@ class TitleMenu : public Menu {
Widgets::CHLCC::TitleButton* Config;
Widgets::CHLCC::TitleButton* SystemSave;

TitleMenuIntroAnimationState TitleMenuIntroAnimationState =
TitleMenuIntroAnimationState IntroAnimationState =
TitleMenuIntroAnimationState::Out;
};

Expand Down
5 changes: 3 additions & 2 deletions src/pathanimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ float Ease(float progress, EasingFunction function) {
}
}

Check warning on line 24 in src/pathanimation.cpp

View workflow job for this annotation

GitHub Actions / linux

control reaches end of non-void function [-Wreturn-type]

Check warning on line 24 in src/pathanimation.cpp

View workflow job for this annotation

GitHub Actions / windows

'Impacto::Ease': not all control paths return a value

PathAnimation::PathAnimation(std::vector<PathSegment> path) : Path(path) {
PathAnimation::PathAnimation(std::vector<PathSegment> path)
: Path(std::move(path)) {
float totalDuration = 0;
for (const PathSegment& segment : path) {
for (const PathSegment& segment : Path) {
totalDuration += segment.Duration;
}

Expand Down
2 changes: 1 addition & 1 deletion src/pathanimation.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct PathSegment {

class PathAnimation : public Animation {
public:
PathAnimation() : PathAnimation(std::vector<PathSegment>()){};
PathAnimation() : PathAnimation(std::vector<PathSegment>()) {};
PathAnimation(std::vector<PathSegment> segments);

std::vector<PathSegment> Path;
Expand Down
12 changes: 11 additions & 1 deletion src/profile/games/chlcc/titlemenu.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "titlemenu.h"
#include "../../../log.h"
// #include "../../../window.h"
#include "../../../renderer/renderer.h"
#include "../../profile_internal.h"

Expand All @@ -16,6 +15,8 @@ namespace TitleMenu {

void Configure() {
IntroBackgroundSprite = EnsureGetMemberSprite("IntroBackgroundSprite");
IntroPanningAnimationDuration =
EnsureGetMemberFloat("IntroPanningAnimationDuration");
IntroBouncingStarSprite = EnsureGetMemberSprite("IntroBouncingStarSprite");
IntroSmallStarSprite = EnsureGetMemberSprite("IntroSmallStarSprite");
IntroBigStarSprite = EnsureGetMemberSprite("IntroBigStarSprite");
Expand Down Expand Up @@ -128,6 +129,12 @@ void Configure() {
IntroStarBounceAnimationSegmentCount,
"IntroStarBounceAnimationPath");

GetMemberSpriteArray(IntroHighlightSprites, IntroHighlightCount,
"IntroHighlightSprites");

GetMemberFloatArray(IntroHighlightPositions, IntroHighlightCount,
"IntroHighlightPositions");

UI::CHLCC::TitleMenu* menu = new UI::CHLCC::TitleMenu();
menu->PressToStartAnimation.DurationIn =
Profile::TitleMenu::PressToStartAnimDurationIn;
Expand All @@ -146,6 +153,9 @@ void Configure() {
menu->SpinningCircleAnimation.DurationIn = SpinningCircleAnimationDuration;
menu->SpinningCircleAnimation.DurationOut = SpinningCircleAnimationDuration;

menu->IntroPanningAnimation.DurationIn = IntroPanningAnimationDuration;
menu->IntroPanningAnimation.DurationOut = IntroPanningAnimationDuration;

menu->IntroStarBounceAnimation = PathAnimation(std::vector(
IntroStarBounceAnimationPath,
IntroStarBounceAnimationPath + IntroStarBounceAnimationSegmentCount));
Expand Down
6 changes: 6 additions & 0 deletions src/profile/games/chlcc/titlemenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ inline float SecondaryMenuSystemConfigY;
inline float SecondaryMenuSystemSaveY;

inline Sprite IntroBackgroundSprite;

constexpr size_t IntroHighlightCount = 10;
inline Sprite IntroHighlightSprites[IntroHighlightCount];
inline float IntroHighlightPositions[IntroHighlightCount];
inline float IntroPanningAnimationDuration;

inline Sprite IntroSmallStarSprite;
inline Sprite IntroBigStarSprite;

Expand Down

0 comments on commit 6b4bda3

Please sign in to comment.