Skip to content

Commit 2f1a3be

Browse files
committed
port to v5, remove tutorial, use event export macro
1 parent c3a8a97 commit 2f1a3be

10 files changed

Lines changed: 33 additions & 269 deletions

include/TextureLoader.hpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@
88
#include <vector>
99
#include <string>
1010

11+
#ifdef MY_MOD_ID
12+
#undef MY_MOD_ID
13+
#endif
14+
#define MY_MOD_ID "geode.texture-loader"
15+
1116
namespace geode::texture_loader {
1217

1318
inline bool isLoaded() {
14-
return geode::Loader::get()->isModLoaded("geode.texture-loader");
19+
return geode::Loader::get()->isModLoaded(MY_MOD_ID);
1520
}
1621

1722
struct Pack {
@@ -26,21 +31,7 @@ struct Pack {
2631
std::filesystem::path resourcesPath;
2732
};
2833

29-
namespace impl {
30-
using EventGetAvailablePacks = geode::DispatchEvent<std::vector<Pack>*>;
31-
using EventGetAppliedPacks = geode::DispatchEvent<std::vector<Pack>*>;
32-
}
33-
34-
inline std::vector<Pack> getAvailablePacks() {
35-
std::vector<Pack> result;
36-
impl::EventGetAvailablePacks("geode.texture-loader/v1/get-available-packs", &result).post();
37-
return result;
38-
}
39-
40-
inline std::vector<Pack> getAppliedPacks() {
41-
std::vector<Pack> result;
42-
impl::EventGetAppliedPacks("geode.texture-loader/v1/get-applied-packs", &result).post();
43-
return result;
44-
}
34+
inline std::vector<Pack> getAvailablePacks() GEODE_EVENT_EXPORT_NORES(&getAvailablePacks, ());
35+
inline std::vector<Pack> getAppliedPacks() GEODE_EVENT_EXPORT_NORES(&getAppliedPacks, ());
4536

4637
}

mod.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"geode": "4.7.0",
3-
"version": "v1.8.2",
2+
"geode": "5.0.0-beta.3",
3+
"version": "1.9.0",
44
"gd": {
5-
"win": "2.2074",
6-
"android": "2.2074",
7-
"mac": "2.2074",
8-
"ios": "2.2074"
5+
"win": "2.2081",
6+
"android": "2.2081",
7+
"mac": "2.2081",
8+
"ios": "2.2081"
99
},
1010
"id": "geode.texture-loader",
1111
"name": "Texture Loader",

src/API.cpp

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
1+
#define GEODE_DEFINE_EVENT_EXPORTS
12
#include "../include/TextureLoader.hpp"
23

34
#include "PackManager.hpp"
45

56
using namespace geode;
67

7-
namespace ext = geode::texture_loader;
8+
namespace api = geode::texture_loader;
89

9-
template <class>
10-
struct ToFilterImpl;
11-
12-
template <class... Args>
13-
struct ToFilterImpl<geode::DispatchEvent<Args...>> {
14-
using type = geode::DispatchFilter<Args...>;
15-
};
16-
17-
template <class T>
18-
using ToFilter = typename ToFilterImpl<T>::type;
19-
20-
ext::Pack convertPack(std::shared_ptr<Pack> const& pack) {
21-
ext::Pack res;
10+
api::Pack convertPack(std::shared_ptr<Pack> const& pack) {
11+
api::Pack res;
2212
res.id = pack->getID();
2313
res.name = pack->getDisplayName();
2414
res.path = pack->getOriginPath();
@@ -32,14 +22,9 @@ ext::Pack convertPack(std::shared_ptr<Pack> const& pack) {
3222
return res;
3323
}
3424

35-
$execute {
36-
new EventListener(+[](std::vector<ext::Pack>* res) {
37-
*res = utils::ranges::map<std::vector<ext::Pack>>(PackManager::get()->getAvailablePacks(), convertPack);
38-
return ListenerResult::Stop;
39-
}, ToFilter<ext::impl::EventGetAvailablePacks>("geode.texture-loader/v1/get-available-packs"));
40-
41-
new EventListener(+[](std::vector<ext::Pack>* res) {
42-
*res = utils::ranges::map<std::vector<ext::Pack>>(PackManager::get()->getAppliedPacks(), convertPack);
43-
return ListenerResult::Stop;
44-
}, ToFilter<ext::impl::EventGetAppliedPacks>("geode.texture-loader/v1/get-applied-packs"));
45-
}
25+
std::vector<api::Pack> api::getAvailablePacks() {
26+
return utils::ranges::map<std::vector<api::Pack>>(PackManager::get()->getAvailablePacks(), convertPack);
27+
}
28+
std::vector<api::Pack> api::getAppliedPacks() {
29+
return utils::ranges::map<std::vector<api::Pack>>(PackManager::get()->getAppliedPacks(), convertPack);
30+
}

src/PackInfoPopup.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ std::filesystem::path PackInfoPopup::getPathInPack(const char* filename) const {
6262
}
6363
}
6464

65-
bool PackInfoPopup::setup(std::shared_ptr<Pack> pack) {
66-
m_pack = pack;
65+
bool PackInfoPopup::init() {
66+
if (!Popup::init(320.f, 200.f, this->getPathInPack("GJ_square01.png").string().c_str())) return false;
6767

6868
auto title = WackyBypassFont::create(
69-
pack->getDisplayName().c_str(),
69+
m_pack->getDisplayName().c_str(),
7070
this->getPathInPack("goldFont.fnt")
7171
);
7272
title->setPosition(
@@ -145,10 +145,7 @@ bool PackInfoPopup::setup(std::shared_ptr<Pack> pack) {
145145
PackInfoPopup* PackInfoPopup::create(const std::shared_ptr<Pack>& pack) {
146146
auto ret = new PackInfoPopup;
147147
ret->m_pack = pack;
148-
if (ret->initAnchored(
149-
320.f, 200.f, pack,
150-
ret->getPathInPack("GJ_square01.png").string().c_str()
151-
)) {
148+
if (ret->init()) {
152149
ret->autorelease();
153150
return ret;
154151
}

src/PackInfoPopup.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55

66
using namespace geode::prelude;
77

8-
class PackInfoPopup : public Popup<std::shared_ptr<Pack>> {
8+
class PackInfoPopup : public Popup {
99
protected:
1010
std::shared_ptr<Pack> m_pack;
1111

12-
bool setup(std::shared_ptr<Pack> pack) override;
12+
bool init();
1313

1414
std::filesystem::path getPathInPack(const char* filename) const;
15-
1615
public:
1716
static PackInfoPopup* create(const std::shared_ptr<Pack>& pack);
1817
};

src/PackSelectPopup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class $modify(ReloadMenuLayer, MenuLayer) {
3737
static CCSize LAYER_SIZE = { 230.f, 210.f };
3838

3939
bool PackSelectPopup::init() {
40-
if (!Popup<>::initAnchored(440.f, 290.f, "GJ_square01.png")) return false;
40+
if (!Popup::init(440.f, 290.f)) return false;
4141

4242
GameManager::get()->fadeInMenuMusic();
4343

src/PackSelectPopup.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class PackNode;
1010

1111
using namespace geode::prelude;
1212

13-
class PackSelectPopup : public Popup<> {
13+
class PackSelectPopup : public Popup {
1414
protected:
1515
ScrollLayer* m_availableList = nullptr;
1616
ScrollLayer* m_appliedList = nullptr;
@@ -19,8 +19,7 @@ class PackSelectPopup : public Popup<> {
1919
size_t m_lastDragIdx = size_t(-1);
2020
PackListType m_dragListFrom, m_dragListTo;
2121

22-
bool setup() override { return true; }
23-
bool init() override;
22+
bool init();
2423

2524
void updateList(
2625
ScrollLayer* list,

src/Tutorial.cpp

Lines changed: 0 additions & 150 deletions
This file was deleted.

src/Tutorial.hpp

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)