Skip to content

Commit

Permalink
Refactored backlog menu
Browse files Browse the repository at this point in the history
  • Loading branch information
PringlesGang committed Sep 18, 2024
1 parent c29a899 commit 3242328
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 76 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ set(Impacto_Src
src/games/chlcc/trophymenuentry.cpp
src/games/chlcc/delusiontrigger.cpp

src/games/cc/backlogmenu.cpp
src/games/cc/dialoguebox.cpp
src/games/cc/titlemenu.cpp
src/games/cc/sysmesbox.cpp
Expand All @@ -183,6 +184,7 @@ set(Impacto_Src
src/games/cclcc/savesystem.cpp
src/games/cclcc/systemmenu.cpp

src/games/mo6tw/backlogmenu.cpp
src/games/mo6tw/dialoguebox.cpp
src/games/mo6tw/sysmesbox.cpp
src/games/mo6tw/systemmenu.cpp
Expand Down
68 changes: 68 additions & 0 deletions src/games/cc/backlogmenu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include "backlogmenu.h"

#include "../../profile/game.h"
#include "../../ui/backlogmenu.h"
#include "../../profile/ui/systemmenu.h"
#include "../../profile/ui/backlogmenu.h"
#include "../../profile/games/cc/backlogmenu.h"
#include "../../profile/games/cclcc/systemmenu.h"

namespace Impacto {
namespace UI {
namespace CC {

using namespace Impacto::UI::CC;
using namespace Impacto::Profile::BacklogMenu;
using namespace Impacto::Profile::CC::BacklogMenu;

BacklogMenu::BacklogMenu() : UI::BacklogMenu::BacklogMenu() {
switch (Impacto::Profile::SystemMenu::Type) {
default:
MaskSprite = nullptr;
break;
case UI::SystemMenuType::CCLCC:
MaskSprite = &Profile::CCLCC::SystemMenu::MenuMask;
break;
/* Enable once CC system menu is properly seperated
case UI::SystemMenuType::CC:
MaskSprite = &Profile::CC::SystemMenu::MenuMask;
break;
*/
}
}

void BacklogMenu::Render() {
if (State == Hidden) return;

glm::vec4 transition(1.0f, 1.0f, 1.0f, FadeAnimation.Progress);
glm::vec4 maskTint = glm::vec4(1.0f);
maskTint.a = 0.50 * FadeAnimation.Progress;

MainItems->Tint = transition;

int repeatHeight = BacklogBackgroundRepeatHeight;
float backgroundY =
fmod(PageY - EntryYPadding - RenderingBounds.Y, repeatHeight);
Renderer->DrawSprite(BacklogBackground, glm::vec2(0.0f, backgroundY),
transition);
Renderer->DrawSprite(BacklogBackground,
glm::vec2(0.0f, backgroundY + repeatHeight), transition);

RenderHighlight();
Renderer->DrawSprite(BacklogHeaderSprite, BacklogHeaderPosition, transition);
MainItems->Render();
MainScrollbar->Render();

if (MaskSprite != nullptr)
Renderer->DrawSprite(
*MaskSprite,
RectF(0.0f, 0.0f, Profile::DesignWidth, Profile::DesignHeight),
maskTint);

Renderer->DrawSprite(BacklogControlsSprite, BacklogControlsPosition,
transition);
}

} // namespace CC
} // namespace UI
} // namespace Impacto
18 changes: 7 additions & 11 deletions src/games/cc/backlogmenu.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "../../ui/backlogmenu.h"
#include "../../spritesheet.h"

namespace Impacto {
namespace UI {
Expand All @@ -10,17 +11,12 @@ class BacklogMenu : public UI::BacklogMenu {
public:
BacklogMenu();

void Init();

void Show();
void Hide();
void UpdateInput();
void Update(float dt);
void Render();
};


private:
const Sprite* MaskSprite;
};

} // namespace CC
} // namespace UI
} // namespace Impacto
} // namespace CC
} // namespace UI
} // namespace Impacto
30 changes: 30 additions & 0 deletions src/games/mo6tw/backlogmenu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "backlogmenu.h"

#include "../../ui/backlogmenu.h"
#include "../../profile/ui/backlogmenu.h"
#include "../../profile/games/mo6tw/backlogmenu.h"
#include "../../profile/games/mo6tw/systemmenu.h"

namespace Impacto {
namespace UI {
namespace MO6TW {

using namespace Impacto::UI::MO6TW;
using namespace Impacto::Profile::BacklogMenu;
using namespace Impacto::Profile::MO6TW::BacklogMenu;

void BacklogMenu::Render() {
if (State == Hidden) return;

glm::vec4 col(1.0f, 1.0f, 1.0f, FadeAnimation.Progress);
MainItems->Tint = col;

Renderer->DrawSprite(BacklogBackground, glm::vec2(0.0f), col);
RenderHighlight();
MainItems->Render();
MainScrollbar->Render();
}

} // namespace MO6TW
} // namespace UI
} // namespace Impacto
16 changes: 16 additions & 0 deletions src/games/mo6tw/backlogmenu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include "../../ui/backlogmenu.h"

namespace Impacto {
namespace UI {
namespace MO6TW {

class BacklogMenu : public UI::BacklogMenu {
public:
void Render();
};

} // namespace MO6TW
} // namespace UI
} // namespace Impacto
3 changes: 2 additions & 1 deletion src/profile/games/cc/backlogmenu.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "backlogmenu.h"
#include "../../profile_internal.h"
#include "../../../ui/ui.h"
#include "../../../games/cc/backlogmenu.h"

namespace Impacto {
namespace Profile {
Expand All @@ -22,7 +23,7 @@ void Configure() {
auto drawType = Game::DrawComponentType::_from_integral_unchecked(
EnsureGetMemberInt("DrawType"));

UI::BacklogMenuPtr = new UI::BacklogMenu();
UI::BacklogMenuPtr = new UI::CC::BacklogMenu();
UI::Menus[drawType].push_back(UI::BacklogMenuPtr);
}

Expand Down
3 changes: 2 additions & 1 deletion src/profile/games/mo6tw/backlogmenu.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "backlogmenu.h"
#include "../../profile_internal.h"
#include "../../../ui/ui.h"
#include "../../../games/mo6tw/backlogmenu.h"

namespace Impacto {
namespace Profile {
Expand All @@ -11,7 +12,7 @@ void Configure() {
auto drawType = Game::DrawComponentType::_from_integral_unchecked(
EnsureGetMemberInt("DrawType"));

UI::BacklogMenuPtr = new UI::BacklogMenu();
UI::BacklogMenuPtr = new UI::MO6TW::BacklogMenu();
UI::Menus[drawType].push_back(UI::BacklogMenuPtr);
}

Expand Down
59 changes: 1 addition & 58 deletions src/ui/backlogmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,64 +157,7 @@ void BacklogMenu::RenderHighlight() const {
}
}

void BacklogMenu::Render() {
if (State == Hidden || Type == +BacklogMenuType::None) return;

switch (Type) {
case BacklogMenuType::MO6TW: {
glm::vec4 col(1.0f, 1.0f, 1.0f, FadeAnimation.Progress);
MainItems->Tint = col;

Renderer->DrawSprite(BacklogBackground, glm::vec2(0.0f), col);
RenderHighlight();
MainItems->Render();
MainScrollbar->Render();
}
case BacklogMenuType::CC: {
using namespace Impacto::Profile::CC::BacklogMenu;
glm::vec4 transition(1.0f, 1.0f, 1.0f, FadeAnimation.Progress);
glm::vec4 maskTint = glm::vec4(1.0f);
maskTint.a = 0.85f * FadeAnimation.Progress;

Sprite* menuMask = nullptr;
switch (Impacto::Profile::SystemMenu::Type) {
default:
break;
// TODO: implement for CC
case UI::SystemMenuType::CCLCC:
menuMask = &Profile::CCLCC::SystemMenu::MenuMask;
break;
}

MainItems->Tint = transition;

int repeatHeight =
Profile::CC::BacklogMenu::BacklogBackgroundRepeatHeight;
float backgroundY =
fmod(PageY - EntryYPadding - RenderingBounds.Y, repeatHeight);
Renderer->DrawSprite(BacklogBackground, glm::vec2(0.0f, backgroundY),
transition);
Renderer->DrawSprite(BacklogBackground,
glm::vec2(0.0f, backgroundY + repeatHeight),
transition);

RenderHighlight();
Renderer->DrawSprite(BacklogHeaderSprite, BacklogHeaderPosition,
transition);
MainItems->Render();
MainScrollbar->Render();

if (menuMask != nullptr)
Renderer->DrawSprite(
*menuMask,
RectF(0.0f, 0.0f, Profile::DesignWidth, Profile::DesignHeight),
maskTint);

Renderer->DrawSprite(BacklogControlsSprite, BacklogControlsPosition,
transition);
}
}
}
void BacklogMenu::Render() {}

void BacklogMenu::AddMessage(uint8_t* str, int audioId) {
if (!GetFlag(SF_REVADDDISABLE) || ScrWork[SW_MESWIN0TYPE] == 0) {
Expand Down
10 changes: 5 additions & 5 deletions src/ui/backlogmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ class BacklogMenu : public Menu {
public:
BacklogMenu();

void Show();
void Hide();
void Update(float dt);
void Render();
virtual void Show();
virtual void Hide();
virtual void Update(float dt);
virtual void Render();

void AddMessage(uint8_t* str, int audioId = -1);
void MenuButtonOnClick(Widgets::BacklogEntry* target);
void Clear();

float PageY = 0.0f;

private:
protected:
int CurrentId = 0;
float ItemsHeight = 0.0f;
glm::vec2 CurrentEntryPos;
Expand Down

0 comments on commit 3242328

Please sign in to comment.