Skip to content

Commit 6d8536e

Browse files
authored
Merge pull request #492 from CommitteeOfZero/backlog-entry-cap
Add cap to backlog entries
2 parents 53d32ec + 002afa0 commit 6d8536e

20 files changed

Lines changed: 448 additions & 276 deletions

CMakeLists.txt

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,78 @@ FetchContent_Declare(
892892
EXCLUDE_FROM_ALL
893893
)
894894

895+
FetchContent_Declare(
896+
boost_core
897+
GIT_TAG "boost-1.91.0"
898+
GIT_REPOSITORY "https://github.com/boostorg/core.git"
899+
SYSTEM
900+
EXCLUDE_FROM_ALL
901+
)
902+
903+
FetchContent_Declare(
904+
boost_config
905+
GIT_TAG "boost-1.91.0"
906+
GIT_REPOSITORY "https://github.com/boostorg/config.git"
907+
SYSTEM
908+
EXCLUDE_FROM_ALL
909+
)
910+
911+
FetchContent_Declare(
912+
boost_throwexception
913+
GIT_TAG "boost-1.91.0"
914+
GIT_REPOSITORY "https://github.com/boostorg/throw_exception.git"
915+
SYSTEM
916+
EXCLUDE_FROM_ALL
917+
)
918+
919+
FetchContent_Declare(
920+
boost_assert
921+
GIT_TAG "boost-1.91.0"
922+
GIT_REPOSITORY "https://github.com/boostorg/assert.git"
923+
SYSTEM
924+
EXCLUDE_FROM_ALL
925+
)
926+
927+
FetchContent_Declare(
928+
boost_preprocessor
929+
GIT_TAG "boost-1.91.0"
930+
GIT_REPOSITORY "https://github.com/boostorg/preprocessor.git"
931+
SYSTEM
932+
EXCLUDE_FROM_ALL
933+
)
934+
935+
FetchContent_Declare(
936+
boost_move
937+
GIT_TAG "boost-1.91.0"
938+
GIT_REPOSITORY "https://github.com/boostorg/move.git"
939+
SYSTEM
940+
EXCLUDE_FROM_ALL
941+
)
942+
943+
FetchContent_Declare(
944+
boost_typetraits
945+
GIT_TAG "boost-1.91.0"
946+
GIT_REPOSITORY "https://github.com/boostorg/type_traits.git"
947+
SYSTEM
948+
EXCLUDE_FROM_ALL
949+
)
950+
951+
FetchContent_Declare(
952+
boost_conceptcheck
953+
GIT_TAG "boost-1.91.0"
954+
GIT_REPOSITORY "https://github.com/boostorg/concept_check.git"
955+
SYSTEM
956+
EXCLUDE_FROM_ALL
957+
)
958+
959+
FetchContent_Declare(
960+
boost_circularbuffer
961+
GIT_TAG "boost-1.91.0"
962+
GIT_REPOSITORY "https://github.com/boostorg/circular_buffer.git"
963+
SYSTEM
964+
EXCLUDE_FROM_ALL
965+
)
966+
895967
if (NOT VCPKG_TOOLCHAIN)
896968
FetchContent_MakeAvailable(fmt)
897969
endif ()
@@ -904,6 +976,16 @@ FetchContent_MakeAvailable(readerwriterqueue)
904976
FetchContent_MakeAvailable(unordered_dense)
905977
FetchContent_MakeAvailable(magic_enum)
906978

979+
FetchContent_MakeAvailable(boost_core)
980+
FetchContent_MakeAvailable(boost_config)
981+
FetchContent_MakeAvailable(boost_throwexception)
982+
FetchContent_MakeAvailable(boost_assert)
983+
FetchContent_MakeAvailable(boost_preprocessor)
984+
FetchContent_MakeAvailable(boost_move)
985+
FetchContent_MakeAvailable(boost_typetraits)
986+
FetchContent_MakeAvailable(boost_conceptcheck)
987+
FetchContent_MakeAvailable(boost_circularbuffer)
988+
907989
if (NOT DEFINED IMPACTO_DISABLE_MMAP)
908990
list(APPEND Impacto_Src
909991
src/io/memorymappedfilestream.cpp
@@ -1080,6 +1162,7 @@ list(APPEND Impacto_Libs
10801162
utf8cpp
10811163
concurrentqueue
10821164
readerwriterqueue
1165+
Boost::circular_buffer
10831166
)
10841167

10851168
if (NOT DEFINED IMPACTO_DISABLE_LIBASS)

THIRDPARTY.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ All third-party code mentioned above is mandatory, included in the build process
4040
* [pugixml](https://github.com/zeux/pugixml)
4141
* [UTF8-CPP](https://github.com/nemtrif/utfcpp)
4242
* [magic_enum](https://github.com/Neargye/magic_enum)
43+
* [boost](https://boost.org)
4344

4445
**Sourcing and linkage:**
4546

@@ -764,7 +765,7 @@ Copyright 2014 Melissa O'Neill <oneill@pcg-random.org>
764765

765766
Licensed under the Apache License, Version 2.0. See below for license text.
766767

767-
# Ryujinx
768+
## Ryujinx
768769

769770
https://github.com/Ryujinx/Ryujinx/tree/eee639d6ba544fa5dd9352426d55e91bc54e157d/Ryujinx.Graphics/Graphics3d/Texture
770771

@@ -1000,6 +1001,12 @@ https://github.com/libass/libass
10001001

10011002
See below for license text (ISC)
10021003

1004+
## boost
1005+
1006+
https://boost.org
1007+
1008+
See below for license text (Boost Software License, Version 1.0)
1009+
10031010
# Generic license texts
10041011

10051012
## 2-clause BSD license

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.9.
1+
0.9.10.

src/games/cc/backlogmenu.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ using namespace Impacto::UI::Widgets::CC;
2020
using namespace Impacto::Profile::ScriptVars;
2121

2222
void BacklogMenu::MenuButtonOnClick(Widgets::BacklogEntry* target) {
23-
UI::BacklogMenu::MenuButtonOnClick(target);
23+
UI::BacklogMenu<BacklogEntry>::MenuButtonOnClick(target);
2424

2525
if (!target->AudioId.has_value())
2626
Audio::PlayInGroup(Audio::ACG_SE, "sysse", 4, false, 0.0f);
@@ -31,12 +31,12 @@ void BacklogMenu::Show() {
3131
CommonMenu::OnShow(FadeInDuration, FadeOutDuration, FadeAnimation);
3232
}
3333

34-
UI::BacklogMenu::Show();
34+
UI::BacklogMenu<BacklogEntry>::Show();
3535
}
3636

3737
void BacklogMenu::Hide() {
3838
Audio::Channels[Audio::AC_REV]->Stop(0.0f);
39-
UI::BacklogMenu::Hide();
39+
UI::BacklogMenu<BacklogEntry>::Hide();
4040
}
4141

4242
void BacklogMenu::UpdateVisibility() {
@@ -56,16 +56,18 @@ void BacklogMenu::UpdateVisibility() {
5656
IsFocused = false;
5757
if (UI::FocusedMenu) UI::FocusedMenu->IsFocused = true;
5858

59-
MainItems->Hide();
59+
for (auto& entry : Entries) {
60+
entry.Hide();
61+
}
6062
}
6163
}
6264

6365
void BacklogMenu::Update(float dt) {
64-
float prevScrollPos = *MainScrollbar->Value;
65-
UI::BacklogMenu::Update(dt);
66-
if (IsFocused && prevScrollPos != *MainScrollbar->Value) {
66+
float prevScrollPos = *MainScrollbar.Value;
67+
UI::BacklogMenu<BacklogEntry>::Update(dt);
68+
if (IsFocused && prevScrollPos != *MainScrollbar.Value) {
6769
if (auto* menu = dynamic_cast<UI::CCLCC::SystemMenu*>(UI::SystemMenuPtr)) {
68-
menu->BGPosition.y += (prevScrollPos - *MainScrollbar->Value) * 0.5f;
70+
menu->BGPosition.y += (prevScrollPos - *MainScrollbar.Value) * 0.5f;
6971
}
7072
}
7173
}
@@ -76,24 +78,27 @@ void BacklogMenu::Render() {
7678
const float opacity = glm::smoothstep(0.0f, 1.0f, FadeAnimation.Progress);
7779
const glm::vec4 transition(1.0f, 1.0f, 1.0f, opacity);
7880

79-
MainItems->Tint = transition;
80-
MainScrollbar->Tint = transition;
81-
8281
const float backgroundY =
83-
static_cast<float>(fmod(PageY - EntryYPadding - RenderingBounds.Y,
84-
BacklogBackground.Bounds.Height));
82+
static_cast<float>(fmod(PageY, BacklogBackground.Bounds.Height));
8583

8684
if (OpenedAsDirect) CommonMenu::DrawBgSprite<false>(State, FadeAnimation);
8785

88-
for (float yPos = backgroundY; yPos <= Profile::DesignHeight;
89-
yPos += BacklogBackground.Bounds.Height) {
86+
for (float yPos = backgroundY - Profile::DesignHeight;
87+
yPos <= Profile::DesignHeight; yPos += BacklogBackground.Bounds.Height) {
9088
Renderer->DrawSprite(BacklogBackground, {0.0f, yPos}, transition);
9189
}
9290

9391
RenderHighlight();
9492
Renderer->DrawSprite(BacklogHeaderSprite, BacklogHeaderPosition, transition);
95-
MainItems->Render();
96-
MainScrollbar->Render();
93+
94+
for (auto& entry : Entries) {
95+
if (!entry.Bounds.Intersects(RenderingBounds)) continue;
96+
entry.Tint = transition;
97+
entry.Render();
98+
}
99+
100+
MainScrollbar.Tint = transition;
101+
MainScrollbar.Render();
97102

98103
if (ScrWork[SW_SYSSUBMENUNO] == 1) {
99104
CommonMenu::DrawOverlay();

src/games/cc/backlogmenu.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,14 @@ namespace Impacto {
99
namespace UI {
1010
namespace CC {
1111

12-
class BacklogMenu : public UI::BacklogMenu, public CCLCC::CommonMenu {
12+
class BacklogMenu : public UI::BacklogMenu<Widgets::CC::BacklogEntry>,
13+
public CCLCC::CommonMenu {
1314
public:
1415
void Show() override;
1516
void Hide() override;
1617
void Render() override;
1718
void Update(float dt) override;
1819

19-
Widgets::BacklogEntry* CreateBacklogEntry(
20-
int id, Vm::BufferOffsetContext scrCtx, std::optional<int> audioId,
21-
int characterId, glm::vec2 pos, const RectF& hoverBounds) const override {
22-
return new Widgets::CC::BacklogEntry(id, scrCtx, audioId, characterId, pos,
23-
hoverBounds);
24-
}
25-
2620
void MenuButtonOnClick(Widgets::BacklogEntry* target) override;
2721

2822
private:

src/games/chlcc/backlogmenu.cpp

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void BacklogMenu::Show() {
2828
FromSystemMenuTransition->StartIn();
2929
}
3030
IsFocused = true;
31-
UI::BacklogMenu::Show();
31+
UI::BacklogMenu<BacklogEntry>::Show();
3232
}
3333
}
3434

@@ -70,15 +70,21 @@ void BacklogMenu::Render() {
7070
Renderer->DisableScissor();
7171
RenderHighlight({0.0f, yOffset});
7272
}
73-
MainItems->RenderingBounds.Y += yOffset;
74-
MainItems->Move({0.0f, yOffset});
75-
MainItems->Render();
76-
MainItems->Move({0.0f, -yOffset});
77-
MainItems->RenderingBounds.Y -= yOffset;
78-
79-
MainScrollbar->Move({0.0f, yOffset});
80-
MainScrollbar->Render();
81-
MainScrollbar->Move({0.0f, -yOffset});
73+
74+
Renderer->EnableScissor();
75+
Renderer->SetScissorRect(RectF(RenderingBounds).Translate({0.0f, yOffset}));
76+
for (auto& entry : Entries) {
77+
if (!entry.Bounds.Intersects(RenderingBounds)) continue;
78+
79+
entry.Move({0.0f, yOffset});
80+
entry.Render();
81+
entry.Move({0.0f, -yOffset});
82+
}
83+
Renderer->DisableScissor();
84+
85+
MainScrollbar.Move({0.0f, yOffset});
86+
MainScrollbar.Render();
87+
MainScrollbar.Move({0.0f, -yOffset});
8288
}
8389

8490
void BacklogMenu::Update(float dt) {
@@ -97,16 +103,18 @@ void BacklogMenu::Update(float dt) {
97103
systemMenuCHG == 0 && (sysMenuCt == 0 || GetFlag(SF_SYSTEMMENU)) &&
98104
State == Hiding) {
99105
State = Hidden;
100-
MainItems->Hide();
106+
107+
for (auto& entry : Entries) {
108+
entry.Hide();
109+
}
101110
} else if (MenuTransition.IsIn() && sysMenuCt == 10000 &&
102111
(systemMenuCHG == 0 || systemMenuCHG == 64) &&
103112
GetFlag(SF_BACKLOGMENU) && State == Showing) {
104113
State = Shown;
105-
MainItems->HasFocus = true;
106114
}
107115

108116
if (State != Hidden) {
109-
UI::BacklogMenu::Update(dt);
117+
UI::BacklogMenu<BacklogEntry>::Update(dt);
110118
MenuTransition.Update(dt);
111119
FromSystemMenuTransition->Update(dt);
112120
if (MenuTransition.Direction == AnimationDirection::Out &&

src/games/chlcc/backlogmenu.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,15 @@ namespace Impacto {
88
namespace UI {
99
namespace CHLCC {
1010

11-
class BacklogMenu : public UI::BacklogMenu, public CommonMenu {
11+
class BacklogMenu : public UI::BacklogMenu<Widgets::CHLCC::BacklogEntry>,
12+
public CommonMenu {
1213
public:
1314
BacklogMenu();
1415

1516
void Show() override;
1617
void Hide() override;
1718
void Update(float dt) override;
1819
void Render() override;
19-
20-
Widgets::BacklogEntry* CreateBacklogEntry(
21-
int id, Vm::BufferOffsetContext scrCtx, std::optional<int> audioId,
22-
int characterId, glm::vec2 pos, const RectF& hoverBounds) const override {
23-
return new Widgets::CHLCC::BacklogEntry(id, scrCtx, audioId, characterId,
24-
pos, hoverBounds);
25-
}
2620
};
2721

2822
} // namespace CHLCC

src/games/mo6tw/backlogmenu.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,24 @@ using namespace Impacto::Profile::MO6TW::BacklogMenu;
1515
void BacklogMenu::Render() {
1616
if (State == Hidden) return;
1717

18-
float opacity = glm::smoothstep(0.0f, 1.0f, FadeAnimation.Progress);
19-
glm::vec4 col(1.0f, 1.0f, 1.0f, opacity);
20-
MainItems->Tint = col;
21-
MainScrollbar->Tint = col;
18+
const float opacity = glm::smoothstep(0.0f, 1.0f, FadeAnimation.Progress);
19+
const glm::vec4 col(1.0f, 1.0f, 1.0f, opacity);
2220

2321
Renderer->DrawSprite(BacklogBackground, glm::vec2(0.0f), col);
2422
RenderHighlight();
25-
MainItems->Render();
26-
MainScrollbar->Render();
23+
24+
Renderer->EnableScissor();
25+
Renderer->SetScissorRect(RenderingBounds);
26+
for (auto& entry : Entries) {
27+
if (!entry.Bounds.Intersects(RenderingBounds)) continue;
28+
29+
entry.Tint = col;
30+
entry.Render();
31+
}
32+
Renderer->DisableScissor();
33+
34+
MainScrollbar.Tint = col;
35+
MainScrollbar.Render();
2736
}
2837

2938
void BacklogMenu::UpdateVisibility() {
@@ -35,7 +44,9 @@ void BacklogMenu::UpdateVisibility() {
3544
IsFocused = false;
3645
if (UI::FocusedMenu) UI::FocusedMenu->IsFocused = true;
3746

38-
MainItems->Hide();
47+
for (auto& entry : Entries) {
48+
entry.Hide();
49+
}
3950
}
4051
}
4152

src/games/mo6tw/backlogmenu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Impacto {
66
namespace UI {
77
namespace MO6TW {
88

9-
class BacklogMenu : public UI::BacklogMenu {
9+
class BacklogMenu : public UI::BacklogMenu<Widgets::BacklogEntry> {
1010
public:
1111
void Render() override;
1212

src/pch.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@
2424
#include <ankerl/unordered_dense.h>
2525
#include <span>
2626
#include <glm/glm.hpp>
27-
#include <magic_enum/magic_enum.hpp>
27+
#include <magic_enum/magic_enum.hpp>
28+
#include <boost/circular_buffer.hpp>

0 commit comments

Comments
 (0)