Skip to content
Open
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
20 changes: 19 additions & 1 deletion profiles/cclcc/hud/systemmenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ root.SystemMenu = {
SystemMenuFrame = "SystemMenuFrame",
SystemMenuMask = "SystemMenuMask",

SmokeX = 0,
SmokeY = 580,
SmokeBoundsX = 20,
SmokeBoundsY = 1550,
SmokeBoundsWidth = 1920,
SmokeBoundsHeight = 500,
SmokeAnimationBoundsXOffset = 20,
SmokeAnimationBoundsXMax = 1919,
SmokeOpacityNormal = 0.15,
SmokeAnimationDurationIn = 32,
SmokeAnimationDurationOut = 32,
SmokeSprite = "SystemMenuSmoke",

BGDispOffsetTopLeft = {X=-1200, Y= -330},
BGDispOffsetBottomLeft = {X=-1200, Y= 2080},
BGDispOffsetTopRight = {X=2520, Y= -330},
Expand Down Expand Up @@ -148,5 +161,10 @@ root.Sprites["SystemMenuFrame"] = {

root.Sprites["SystemMenuMask"] = {
Sheet = "MenuChip",
Bounds = { X = 154, Y = 140, Width = 1900, Height = 1061 },
Bounds = { X = 154, Y = 141, Width = 1900, Height = 1060 },
};

root.Sprites["SystemMenuSmoke"] = {
Sheet = "MenuChip",
Bounds = { X = 0, Y = 1638, Width = 2000, Height = 410 },
};
2 changes: 1 addition & 1 deletion profiles/cclcc/hud/titlemenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ root.Sprites["TitleMenuMenu"] = {

root.Sprites["TitleMenuOverlay"] = {
Sheet = "MenuChip",
Bounds = { X = 154, Y = 140, Width = 1900, Height = 1061 },
Bounds = { X = 154, Y = 141, Width = 1900, Height = 1060 },
};

root.Sprites["TitleMenuSmoke"] = {
Expand Down
33 changes: 33 additions & 0 deletions src/games/cclcc/systemmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ SystemMenu::SystemMenu() {
ItemsFade.DurationIn = ItemsFadeInDuration;
ItemsFade.DurationOut = ItemsFadeOutDuration;

SmokeAnimation.DurationIn = SmokeAnimationDurationIn;
SmokeAnimation.DurationOut = SmokeAnimationDurationOut;

auto onClick = [this](auto* btn) { return MenuButtonOnClick(btn); };

MainItems = new Widgets::Group(this);
Expand Down Expand Up @@ -98,6 +101,7 @@ void SystemMenu::Show() {
State = Showing;
MenuTransition.StartIn();
MenuFade.StartIn();
SmokeAnimation.StartIn();
// If the function was called due to a submenu opening directly,
// then don't take over focus
if (!((ScrWork[SW_SYSMENUCT] == 32 && ScrWork[SW_SYSSUBMENUCT]) ||
Expand Down Expand Up @@ -132,6 +136,7 @@ void SystemMenu::Hide() {
MenuFade.StartOut();
MenuTransition.StartOut();
ItemsFade.StartOut();
SmokeAnimation.StartOut();
if (LastFocusedMenu != 0) {
UI::FocusedMenu = LastFocusedMenu;
LastFocusedMenu->IsFocused = true;
Expand All @@ -144,6 +149,7 @@ void SystemMenu::Hide() {

void SystemMenu::Update(float dt) {
UpdateInput(dt);
SmokeAnimation.Update(dt);

if (State == Shown &&
((GetFlag(SF_TITLEMODE) || ScrWork[SW_SYSMENUCT] < 32) ||
Expand Down Expand Up @@ -292,12 +298,39 @@ void SystemMenu::Render() {
RectF{0, 0, Profile::DesignWidth, Profile::DesignHeight},
glm::vec4{tint, alpha});

DrawSmoke(ScrWork[SW_SYSMENUCT] / 128.0f);

MainItems->Tint =
glm::vec4(tint, glm::smoothstep(0.0f, 1.0f, ItemsFade.Progress));
MainItems->Render();
}
}

void SystemMenu::DrawSmoke(float opacity) {
Renderer->SetBlendMode(RendererBlendMode::Additive);
glm::vec4 col = glm::vec4(1.0f);
col.a = opacity;
SmokeSprite.Bounds = RectF(
SmokeBoundsWidth - (SmokeAnimationBoundsXMax * SmokeAnimation.Progress) +
SmokeAnimationBoundsXOffset,
SmokeBoundsY,
SmokeBoundsWidth -
(SmokeAnimationBoundsXMax * (1.0f - SmokeAnimation.Progress)),
SmokeBoundsHeight);
Renderer->DrawSprite(SmokeSprite, glm::vec2(SmokeX, SmokeY), col);
SmokeSprite.Bounds = RectF(
SmokeBoundsX, SmokeBoundsY,
SmokeBoundsWidth - (SmokeAnimationBoundsXMax * SmokeAnimation.Progress),
SmokeBoundsHeight);
Renderer->DrawSprite(
SmokeSprite,
glm::vec2(SmokeBoundsWidth - (SmokeAnimationBoundsXMax *
(1.0f - SmokeAnimation.Progress)),
SmokeY),
col);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like the idea of modifying this profile variable's bounds...
I'd make a local copy of the sprite and modify that instead

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

void SystemMenu::Init() {
BGPosition = {CALCrnd((int)BGRandPosRange.x), CALCrnd((int)BGRandPosRange.y)};
SetFlag(SF_SYSTEMMENUCAPTURE, true);
Expand Down
3 changes: 3 additions & 0 deletions src/games/cclcc/systemmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class SystemMenu : public Menu {
void UpdateInput(float dt) override;
void Update(float dt) override;
void Render() override;
void DrawSmoke(float opacity);

Animation SmokeAnimation;

void MenuButtonOnClick(Widgets::Button* target);
Sprite ScreenCap;
Expand Down
2 changes: 2 additions & 0 deletions src/games/cclcc/titlemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ void TitleMenu::DrawMainMenuBackGraphics() {
}

void TitleMenu::DrawSmoke(float opacity) {
Renderer->SetBlendMode(RendererBlendMode::Additive);
glm::vec4 col = glm::vec4(1.0f);
col.a = opacity;
SmokeSprite.Bounds = RectF(
Expand All @@ -673,6 +674,7 @@ void TitleMenu::DrawSmoke(float opacity) {
(1.0f - SmokeAnimation.Progress)),
SmokeY),
col);
Renderer->SetBlendMode(RendererBlendMode::Normal);
}

void TitleMenu::ShowContinueItems() {
Expand Down
21 changes: 21 additions & 0 deletions src/profile/games/cclcc/systemmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ void Configure() {
ItemsFadeInDuration = EnsureGetMember<float>("ItemsFadeInDuration");
ItemsFadeOutDuration = EnsureGetMember<float>("ItemsFadeOutDuration");

SmokeOpacityNormal = EnsureGetMember<float>("SmokeOpacityNormal");
SmokeX = EnsureGetMember<float>("SmokeX");
SmokeY = EnsureGetMember<float>("SmokeY");
SmokeBoundsX = EnsureGetMember<float>("SmokeBoundsX");
SmokeBoundsY = EnsureGetMember<float>("SmokeBoundsY");
SmokeBoundsWidth = EnsureGetMember<float>("SmokeBoundsWidth");
SmokeBoundsHeight = EnsureGetMember<float>("SmokeBoundsHeight");
SmokeAnimationBoundsXOffset =
EnsureGetMember<float>("SmokeAnimationBoundsXOffset");
SmokeAnimationBoundsXMax = EnsureGetMember<float>("SmokeAnimationBoundsXMax");
SmokeAnimationDurationIn = EnsureGetMember<float>("SmokeAnimationDurationIn");
SmokeAnimationDurationOut =
EnsureGetMember<float>("SmokeAnimationDurationOut");

GetMemberArray<glm::vec2>(
std::span(MenuEntriesPositions, Profile::SystemMenu::MenuEntriesNum),
"MenuEntriesPositions");
Expand All @@ -29,6 +43,7 @@ void Configure() {
SystemMenuFrame = EnsureGetMember<Sprite>("SystemMenuFrame");
MenuButtonGuide = EnsureGetMember<Sprite>("MenuButtonGuide");
SystemMenuMask = EnsureGetMember<Sprite>("SystemMenuMask");
SmokeSprite = EnsureGetMember<Sprite>("SmokeSprite");

BGDispOffsetTopLeft = EnsureGetMember<glm::vec2>("BGDispOffsetTopLeft");
BGDispOffsetBottomLeft = EnsureGetMember<glm::vec2>("BGDispOffsetBottomLeft");
Expand All @@ -45,6 +60,12 @@ void Configure() {

BGTranslationOffset = EnsureGetMember<glm::vec2>("BGTranslationOffset");

UI::CCLCC::SystemMenu* menu = new UI::CCLCC::SystemMenu();

menu->SmokeAnimation.LoopMode = AnimationLoopMode::Loop;
menu->SmokeAnimation.DurationIn = SmokeAnimationDurationIn;
menu->SmokeAnimation.DurationOut = SmokeAnimationDurationOut;
Comment on lines +63 to +67
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The menu pointer is already created and pushed a couple lines below? The durations are also already set in the constructor


auto drawType = Game::DrawComponentType::_from_integral_unchecked(
EnsureGetMember<uint8_t>("DrawType"));

Expand Down
13 changes: 13 additions & 0 deletions src/profile/games/cclcc/systemmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,26 @@ inline Sprite SystemMenuBG;
inline Sprite MenuButtonGuide;
inline Sprite SystemMenuFrame;
inline Sprite SystemMenuMask;
inline Sprite SmokeSprite;
inline float MoveInDuration;
inline float MoveOutDuration;
inline float ItemsFadeInDuration;
inline float ItemsFadeOutDuration;
inline glm::vec2 MenuEntriesPositions[MenuEntriesNumMax];
inline RectF MenuEntriesButtonBounds[MenuEntriesNumMax];

inline float SmokeOpacityNormal;
inline float SmokeX;
inline float SmokeY;
inline float SmokeBoundsX;
inline float SmokeBoundsY;
inline float SmokeBoundsWidth;
inline float SmokeBoundsHeight;
Comment on lines +26 to +31
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use a glm::vec2 and a RectF

inline float SmokeAnimationBoundsXOffset;
inline float SmokeAnimationBoundsXMax;
inline float SmokeAnimationDurationIn;
inline float SmokeAnimationDurationOut;

inline glm::vec2 BGDispOffsetTopLeft;
inline glm::vec2 BGDispOffsetBottomLeft;
inline glm::vec2 BGDispOffsetTopRight;
Expand Down
Loading