Skip to content

Commit

Permalink
cclcc-librarymenu: accessible menu and background
Browse files Browse the repository at this point in the history
  • Loading branch information
Enorovan committed Sep 15, 2024
1 parent c4e3824 commit 3d31d58
Show file tree
Hide file tree
Showing 13 changed files with 207 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ set(Impacto_Src
src/profile/games/cclcc/optionsmenu.cpp
src/profile/games/cclcc/tipsmenu.cpp
src/profile/games/cclcc/clearlistmenu.cpp
src/profile/games/cclcc/librarymenu.cpp
src/profile/games/cclcc/tipsnotification.cpp
src/profile/games/cclcc/mapsystem.cpp
src/profile/games/cclcc/delusiontrigger.cpp
Expand Down Expand Up @@ -174,6 +175,7 @@ set(Impacto_Src
src/games/cclcc/tipsmenu.cpp
src/games/cclcc/tipssystem.cpp
src/games/cclcc/clearlistmenu.cpp
src/games/cclcc/librarymenu.cpp
src/games/cclcc/tipsnotification.cpp
src/games/cclcc/mapsystem.cpp
src/games/cclcc/delusiontrigger.cpp
Expand Down Expand Up @@ -426,6 +428,7 @@ set(Impacto_Header
src/profile/games/cclcc/optionsmenu.h
src/profile/games/cclcc/tipsmenu.h
src/profile/games/cclcc/clearlistmenu.h
src/profile/games/cclcc/librarymenu.h
src/profile/games/cclcc/tipsnotification.h
src/profile/games/cclcc/mapsystem.h
src/profile/games/cclcc/delusiontrigger.h
Expand Down Expand Up @@ -484,6 +487,7 @@ set(Impacto_Header
src/games/cclcc/optionsmenu.h
src/games/cclcc/tipsmenu.h
src/games/cclcc/clearlistmenu.h
src/games/cclcc/librarymenu.h
src/games/cclcc/mapsystem.h
src/games/cclcc/delusiontrigger.h

Expand Down
11 changes: 9 additions & 2 deletions profiles/cclcc/hud/extramenus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@ root.ExtraMenus = {
ClearListMenu = {
DrawType = DrawComponentType.SystemMenu,
Type = ClearListMenuType.CCLCC,
BackgroundSprite = "ClearListBackground",
BackgroundSprite = "MenuBackground",
FadeInDuration = 0.2,
FadeOutDuration = 0.2,
ClearListBookLayerSprite = "ClearListBookLayer",
ClearListGuideSprite = "ClearListGuide",
ClearListGuideX = 0,
ClearListGuideY = 990,
ClearListMaskSprite = "ClearListMask"
},
LibraryMenu = {
DrawType = DrawComponentType.SystemMenu,
Type = LibraryMenuType.CCLCC,
BackgroundSprite = "MenuBackground",
FadeInDuration = 0.2,
FadeOutDuration = 0.2,
}
}

-- ClearList
root.Sprites["ClearListBackground"] = {
root.Sprites["MenuBackground"] = {
Sheet = "Title",
Bounds = { X = 0, Y = 1080, Width = 1920, Height = 1080 }
};
Expand Down
1 change: 1 addition & 0 deletions profiles/common/scriptvars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ root.ScriptVars = {
SF_SOUNDMENU=1357,
SF_MOVIEMENU=1358,
SF_ACHIEVEMENTMENU=1359,
SF_RETURNTITLE=1805,
SF_MOVIEPLAY=1823,
SF_SUBMENUEXIT=1830,
SF_LOADINGFROMSAVE=1835,
Expand Down
88 changes: 88 additions & 0 deletions src/games/cclcc/librarymenu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#include "librarymenu.h"

#include "clearlistmenu.h"

#include "../../profile/games/cclcc/librarymenu.h"
#include "../../profile/ui/backlogmenu.h"
#include "../../profile/dialogue.h"
#include "../../renderer/renderer.h"
#include "../../mem.h"
#include "../../profile/scriptvars.h"
#include "../../vm/interface/input.h"

namespace Impacto {
namespace UI {
namespace CCLCC {

using namespace Impacto::Profile::CCLCC::LibraryMenu;
using namespace Impacto::Profile::ScriptVars;

using namespace Impacto::Vm::Interface;

using namespace Impacto::UI::Widgets;

LibraryMenu::LibraryMenu() {
FadeAnimation.Direction = 1;
FadeAnimation.LoopMode = ALM_Stop;
FadeAnimation.DurationIn = FadeInDuration;
FadeAnimation.DurationOut = FadeOutDuration;
}

void LibraryMenu::Show() {
if (State != Shown) {
State = Showing;
FadeAnimation.StartIn();
if (UI::FocusedMenu != 0) {
LastFocusedMenu = UI::FocusedMenu;
LastFocusedMenu->IsFocused = false;
}
IsFocused = true;
UI::FocusedMenu = this;
}
}

void LibraryMenu::Hide() {
if (State != Hidden) {
State = Hiding;
FadeAnimation.StartOut();
if (LastFocusedMenu != 0) {
UI::FocusedMenu = LastFocusedMenu;
LastFocusedMenu->IsFocused = true;
} else {
UI::FocusedMenu = 0;
}
IsFocused = false;
}
}

void LibraryMenu::Update(float dt) {
if (ScrWork[SW_SYSSUBMENUCT] < 32 && State == Shown &&
(ScrWork[SW_SYSSUBMENUNO] == 8)) {
Hide();
} else if (ScrWork[SW_SYSSUBMENUCT] >= 32 && State == Hidden &&
(ScrWork[SW_SYSSUBMENUNO] == 8)) {
Show();
}
if (State == Shown && ScrWork[SW_SYSSUBMENUNO] == 8) {
UpdateInput();
}
FadeAnimation.Update(dt);
if (State == Showing && FadeAnimation.Progress == 1.0f) {
State = Shown;
} else if (State == Hiding && FadeAnimation.Progress == 0.0f) {
State = Hidden;
}
}

void LibraryMenu::Render() {
if (State != Hidden && ScrWork[SW_SYSSUBMENUCT] >= 32 &&
ScrWork[SW_SYSSUBMENUNO] == 8) {
glm::vec4 maskTint = glm::vec4(1.0f);
maskTint.a = 0.85f;
Renderer->DrawSprite(BackgroundSprite, glm::vec2(0.0f));
}
}

} // namespace CCLCC
} // namespace UI
} // namespace Impacto
23 changes: 23 additions & 0 deletions src/games/cclcc/librarymenu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include "../../ui/menu.h"

namespace Impacto {
namespace UI {
namespace CCLCC {

class LibraryMenu : public Menu {
public:
LibraryMenu();

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

Animation FadeAnimation;
};

} // namespace CCLCC
} // namespace UI
} // namespace Impacto
29 changes: 29 additions & 0 deletions src/profile/games/cclcc/librarymenu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "librarymenu.h"
#include "../../profile_internal.h"
#include "../../../ui/ui.h"
#include "../../../games/cclcc/librarymenu.h"
#include "../../../text.h"
#include "../../../game.h"

namespace Impacto {
namespace Profile {
namespace CCLCC {
namespace LibraryMenu {

void Configure() {
BackgroundSprite = EnsureGetMemberSprite("BackgroundSprite");

FadeInDuration = EnsureGetMemberFloat("FadeInDuration");
FadeOutDuration = EnsureGetMemberFloat("FadeOutDuration");

auto drawType = Game::DrawComponentType::_from_integral_unchecked(
EnsureGetMemberInt("DrawType"));

auto library = new UI::CCLCC::LibraryMenu();
UI::Menus[drawType].push_back(library);
}

} // namespace LibraryMenu
} // namespace CCLCC
} // namespace Profile
} // namespace Impacto
20 changes: 20 additions & 0 deletions src/profile/games/cclcc/librarymenu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include "../../../spritesheet.h"

namespace Impacto {
namespace Profile {
namespace CCLCC {
namespace LibraryMenu {

inline Sprite BackgroundSprite;

inline float FadeInDuration;
inline float FadeOutDuration;

void Configure();

} // namespace LibraryMenu
} // namespace CCLCC
} // namespace Profile
} // namespace Impacto
1 change: 1 addition & 0 deletions src/profile/profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ void MakeLuaProfile(std::string const& name) {
DefineEnumInt<UI::OptionsMenuType>(LuaState);
DefineEnumInt<UI::TrophyMenuType>(LuaState);
DefineEnumInt<UI::TipsMenuType>(LuaState);
DefineEnumInt<UI::LibraryMenuType>(LuaState);
DefineEnumInt<UI::ClearListMenuType>(LuaState);
DefineEnumInt<UI::AlbumMenuType>(LuaState);
DefineEnumInt<UI::MusicMenuType>(LuaState);
Expand Down
12 changes: 12 additions & 0 deletions src/profile/ui/extramenus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "../games/mo6tw/actorsvoicemenu.h"
#include "../games/mo6tw/musicmenu.h"
#include "../games/mo6tw/albummenu.h"
#include "../games/cclcc/librarymenu.h"
#include "../games/cclcc/clearlistmenu.h"
#include "../games/chlcc/clearlistmenu.h"
#include "../games/chlcc/moviemenu.h"
Expand All @@ -22,6 +23,17 @@ void Configure() {
if (TryPushMember("ExtraMenus")) {
AssertIs(LUA_TTABLE);

if (TryPushMember("LibraryMenu")) {
LibraryMenuType =
LibraryMenuType::_from_integral_unchecked(EnsureGetMemberInt("Type"));

if (LibraryMenuType == +LibraryMenuType::CCLCC) {
CCLCC::LibraryMenu::Configure();
}

Pop();
}

if (TryPushMember("ClearListMenu")) {
ClearListType = ClearListMenuType::_from_integral_unchecked(
EnsureGetMemberInt("Type"));
Expand Down
3 changes: 2 additions & 1 deletion src/profile/ui/extramenus.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#pragma once

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

namespace Impacto {
namespace Profile {
namespace ExtraMenus {

inline Impacto::UI::LibraryMenuType LibraryMenuType =
Impacto::UI::LibraryMenuType::None;
inline Impacto::UI::ClearListMenuType ClearListType =
Impacto::UI::ClearListMenuType::None;
inline Impacto::UI::AlbumMenuType AlbumType = Impacto::UI::AlbumMenuType::None;
Expand Down
1 change: 1 addition & 0 deletions src/scriptvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ V(SF_ALBUMMENU)
V(SF_CLEARLISTMENU)
V(SF_SOUNDMENU)
V(SF_MOVIEMENU)
V(SF_RETURNTITLE)
V(SF_MOVIEPLAY)
V(SF_ACHIEVEMENTMENU)
V(SF_EXTRA_ENA)
Expand Down
1 change: 1 addition & 0 deletions src/ui/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ BETTER_ENUM(TitleMenuType, int, None, RNE, Dash, CHLCC, MO6TW, MO8, CC, CCLCC)
BETTER_ENUM(OptionsMenuType, int, None, MO6TW, MO8, CHLCC, CCLCC)
BETTER_ENUM(TipsMenuType, int, None, MO6TW, CHLCC, CCLCC)
BETTER_ENUM(ClearListMenuType, int, None, MO6TW, CHLCC, CCLCC)
BETTER_ENUM(LibraryMenuType, int, None, CCLCC)
BETTER_ENUM(AlbumMenuType, int, None, MO6TW, CHLCC)
BETTER_ENUM(MusicMenuType, int, None, MO6TW, CHLCC)
BETTER_ENUM(MovieMenuType, int, None, MO6TW, CHLCC)
Expand Down
16 changes: 16 additions & 0 deletions src/vm/inst_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ VmInstruction(InstOption) {
"STUB instruction Option(type: Init)\n");
break;
case 1:
if (!((Interface::PADinputButtonWentDown & Interface::PAD1B) ||
(Interface::PADinputMouseWentDown & Interface::PAD1B))) {
ResetInstruction;
BlockThread;
} else {
SetFlag(SF_RETURNTITLE, true);
Interface::PADinputButtonWentDown |= Interface::PAD1A;
}
ImpLogSlow(LL_Warning, LC_VMStub,
"STUB instruction Option(type: Main)\n");
break;
Expand Down Expand Up @@ -295,6 +303,14 @@ VmInstruction(InstAlbum) {
"STUB instruction Album(type: EXmenuInit)\n");
break;
case 1: // EXmenuMain
if (!((Interface::PADinputButtonWentDown & Interface::PAD1B) ||
(Interface::PADinputMouseWentDown & Interface::PAD1B))) {
ResetInstruction;
BlockThread;
} else {
SetFlag(SF_RETURNTITLE, true);
Interface::PADinputButtonWentDown |= Interface::PAD1A;
}
ImpLogSlow(LL_Warning, LC_VMStub,
"STUB instruction Album(type: EXmenuMain)\n");
break;
Expand Down

0 comments on commit 3d31d58

Please sign in to comment.