Skip to content

Commit

Permalink
fix: fix the compilation errors (hopefully)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fleeym committed Jan 26, 2025
1 parent 2ea5e36 commit e5c9162
Show file tree
Hide file tree
Showing 25 changed files with 165 additions and 155 deletions.
7 changes: 4 additions & 3 deletions jukebox/jukebox/hooks/custom_song_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class $modify(JBSongWidget, CustomSongWidget) {
bool searching = false;
std::unordered_map<int, Nongs*> assetNongData;
EventListener<NongManager::MultiAssetSizeTask> m_multiAssetListener;
std::unique_ptr<EventListener<EventFilter<event::SongStateChanged>>>
std::unique_ptr<
EventListener<EventFilter<jukebox::event::SongStateChanged>>>
m_songStateListener;
};

Expand All @@ -69,8 +70,8 @@ class $modify(JBSongWidget, CustomSongWidget) {
m_fields->firstRun = false;

m_fields->m_songStateListener = std::make_unique<
EventListener<EventFilter<event::SongStateChanged>>>(
([this](event::SongStateChanged* event) {
EventListener<EventFilter<jukebox::event::SongStateChanged>>>(
([this](jukebox::event::SongStateChanged* event) {
if (!m_songInfoObject) {
return ListenerResult::Propagate;
}
Expand Down
2 changes: 1 addition & 1 deletion jukebox/jukebox/hooks/music_download_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void JBMusicDownloadManager::onGetSongInfoCompleted(gd::string p1,
return;
}

event::GetSongInfo(obj->m_songName, obj->m_artistName, songID)
jukebox::event::GetSongInfo(obj->m_songName, obj->m_artistName, songID)
.post();
}

Expand Down
2 changes: 2 additions & 0 deletions jukebox/jukebox/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <jukebox/managers/nong_manager.hpp>
#include <jukebox/ui/indexes_setting.hpp>

using namespace geode::prelude;

$execute {
(void)Mod::get()->registerCustomSettingType("indexes",
&jukebox::IndexSetting::parse);
Expand Down
5 changes: 3 additions & 2 deletions jukebox/jukebox/managers/index_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
#include <jukebox/nong/nong.hpp>
#include <jukebox/ui/indexes_setting.hpp>

namespace jukebox {

using namespace geode::prelude;
using namespace jukebox::index;

namespace jukebox {

bool IndexManager::init() {
if (m_initialized) {
return true;
Expand Down
36 changes: 18 additions & 18 deletions jukebox/jukebox/managers/index_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,25 @@
#include <unordered_map>
#include <variant>

#include <matjson.hpp>
#include <Geode/Result.hpp>
#include <Geode/loader/Event.hpp>
#include <Geode/utils/Task.hpp>
#include <Geode/utils/general.hpp>
#include <matjson.hpp>

#include <jukebox/events/start_download.hpp>
#include <jukebox/nong/index.hpp>
#include <jukebox/nong/nong.hpp>

using namespace geode::prelude;

namespace jukebox {

class IndexManager {
protected:
bool m_initialized = false;

using FetchIndexTask = Task<Result<>, float>;
using DownloadSongTask = Task<Result<ByteVector>, float>;
using FetchIndexTask = geode::Task<geode::Result<>, float>;
using DownloadSongTask =
geode::Task<geode::Result<geode::ByteVector>, float>;

IndexManager() = default;

Expand All @@ -36,30 +35,31 @@ class IndexManager {
IndexManager& operator=(IndexManager&&) = delete;

// index url -> task listener
std::unordered_map<std::string, EventListener<FetchIndexTask>>
std::unordered_map<std::string, geode::EventListener<FetchIndexTask>>
m_indexListeners;

std::unordered_map<int, std::vector<index::IndexSongMetadata*>>
m_nongsForId;
// song id -> download song task
std::unordered_map<std::string, EventListener<DownloadSongTask>>
std::unordered_map<std::string, geode::EventListener<DownloadSongTask>>
m_downloadSongListeners;
// song id -> current download progress (used when opening NongDropdownLayer
// while a song is being downloaded)
std::unordered_map<std::string, float> m_downloadProgress;

EventListener<EventFilter<event::StartDownload>> m_downloadSignalListener{
this, &IndexManager::onDownloadStart};
geode::EventListener<geode::EventFilter<jukebox::event::StartDownload>>
m_downloadSignalListener{this, &IndexManager::onDownloadStart};

geode::ListenerResult onDownloadStart(event::StartDownload* e);
geode::ListenerResult onDownloadStart(jukebox::event::StartDownload* e);
void onDownloadProgress(int gdSongID, const std::string& uniqueId,
float progress);
void onDownloadFinish(
std::variant<index::IndexSongMetadata*, Song*>&& source,
Nongs* destination, ByteVector&& data);
Task<Result<matjson::Value>, float> fetchIndex(
Nongs* destination, geode::ByteVector&& data);
geode::Task<geode::Result<matjson::Value>, float> fetchIndex(
const index::IndexSource& index);
void onIndexFetched(const std::string& url, Result<matjson::Value>* r);
void onIndexFetched(const std::string& url,
geode::Result<matjson::Value>* r);

public:
bool init();
Expand All @@ -69,12 +69,12 @@ class IndexManager {

bool initialized() const { return m_initialized; }

Result<> fetchIndexes();
geode::Result<> fetchIndexes();

Result<> loadIndex(std::filesystem::path path);
Result<> loadIndex(matjson::Value&& jsonObj);
geode::Result<> loadIndex(std::filesystem::path path);
geode::Result<> loadIndex(matjson::Value&& jsonObj);

Result<std::vector<index::IndexSource>> getIndexes();
geode::Result<std::vector<index::IndexSource>> getIndexes();

std::optional<float> getSongDownloadProgress(const std::string& uniqueID);
std::optional<std::string> getIndexName(const std::string& indexID);
Expand All @@ -83,7 +83,7 @@ class IndexManager {

std::filesystem::path baseIndexesPath();

Result<> downloadSong(int gdSongID, const std::string& uniqueID);
geode::Result<> downloadSong(int gdSongID, const std::string& uniqueID);

void registerIndexNongs(Nongs* destination);

Expand Down
2 changes: 2 additions & 0 deletions jukebox/jukebox/managers/nong_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <jukebox/nong/nong_serialize.hpp>
#include <jukebox/utils/random_string.hpp>

using namespace geode::prelude;

namespace jukebox {

std::optional<Nongs*> NongManager::getNongs(int songID) {
Expand Down
31 changes: 16 additions & 15 deletions jukebox/jukebox/managers/nong_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#include <jukebox/events/song_error.hpp>
#include <jukebox/nong/nong.hpp>

using namespace geode::prelude;

namespace jukebox {

class NongManager {
Expand All @@ -37,16 +35,18 @@ class NongManager {
}
}

Result<> saveNongs(std::optional<int> saveId = std::nullopt);
EventListener<EventFilter<jukebox::event::SongError>> m_songErrorListener;
EventListener<EventFilter<jukebox::event::GetSongInfo>> m_songInfoListener;
Result<std::unique_ptr<Nongs>> loadNongsFromPath(
geode::Result<> saveNongs(std::optional<int> saveId = std::nullopt);
geode::EventListener<geode::EventFilter<jukebox::event::SongError>>
m_songErrorListener;
geode::EventListener<geode::EventFilter<jukebox::event::GetSongInfo>>
m_songInfoListener;
geode::Result<std::unique_ptr<Nongs>> loadNongsFromPath(
const std::filesystem::path& path);

Result<> migrateV2();
geode::Result<> migrateV2();

public:
using MultiAssetSizeTask = Task<std::string>;
using MultiAssetSizeTask = geode::Task<std::string>;
std::optional<Nongs*> m_currentlyPreparingNong;

bool init();
Expand All @@ -55,12 +55,13 @@ class NongManager {

std::filesystem::path baseManifestPath() {
static std::filesystem::path path =
Mod::get()->getSaveDir() / "manifest";
geode::Mod::get()->getSaveDir() / "manifest";
return path;
}

std::filesystem::path baseNongsPath() {
static std::filesystem::path path = Mod::get()->getSaveDir() / "nongs";
static std::filesystem::path path =
geode::Mod::get()->getSaveDir() / "nongs";
return path;
}

Expand Down Expand Up @@ -125,34 +126,34 @@ class NongManager {
* Add NONGs
* @param nong NONG to add
*/
Result<> addNongs(Nongs&& nong);
geode::Result<> addNongs(Nongs&& nong);

/**
* Set active song
* @param gdSongID the id of the song in GD
* @param uniqueID the unique id of the song in Jukebox
*/
Result<> setActiveSong(int gdSongID, std::string uniqueID);
geode::Result<> setActiveSong(int gdSongID, std::string uniqueID);

/**
* Delete a song
* @param gdSongID the id of the song in GD
* @param uniqueID the unique id of the song in Jukebox
*/
Result<> deleteSong(int gdSongID, std::string uniqueID);
geode::Result<> deleteSong(int gdSongID, std::string uniqueID);

/**
* Delete a song's audio file
* @param gdSongID the id of the song in GD
* @param uniqueID the unique id of the song in Jukebox
*/
Result<> deleteSongAudio(int gdSongID, std::string uniqueID);
geode::Result<> deleteSongAudio(int gdSongID, std::string uniqueID);

/**
* Delete all NONGs for a song ID
* @param gdSongID id of the song
*/
Result<> deleteAllSongs(int gdSongID);
geode::Result<> deleteAllSongs(int gdSongID);

/**
* Get a path to a song file
Expand Down
2 changes: 2 additions & 0 deletions jukebox/jukebox/ui/index_choose_popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include <jukebox/managers/index_manager.hpp>

using namespace geode::prelude;

namespace jukebox {

bool IndexChoosePopup::setup(
Expand Down
8 changes: 3 additions & 5 deletions jukebox/jukebox/ui/index_choose_popup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@
#include <Geode/cocos/label_nodes/CCLabelBMFont.h>
#include <Geode/ui/Popup.hpp>

using namespace geode::prelude;

namespace jukebox {

class IndexChoosePopup
: public Popup<std::vector<std::string>,
std::function<void(const std::string& indexID)>> {
: public geode::Popup<std::vector<std::string>,
std::function<void(const std::string& indexID)>> {
protected:
std::vector<std::string> m_indexIDs;
std::function<void(const std::string& indexID)> m_chooseIndex;
CCLabelBMFont* m_label = nullptr;
cocos2d::CCLabelBMFont* m_label = nullptr;
int m_currentIndex = 0;

bool setup(
Expand Down
2 changes: 2 additions & 0 deletions jukebox/jukebox/ui/indexes_popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <jukebox/nong/index.hpp>
#include <jukebox/ui/list/index_cell.hpp>

using namespace geode::prelude;

namespace jukebox {

using namespace jukebox::index;
Expand Down
7 changes: 3 additions & 4 deletions jukebox/jukebox/ui/indexes_popup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@

#include <jukebox/nong/index.hpp>

using namespace geode::prelude;

namespace jukebox {

using namespace jukebox::index;

using IndexesCallback = std::function<void(std::vector<IndexSource>)>;

class IndexesPopup : public Popup<std::vector<IndexSource>, IndexesCallback> {
class IndexesPopup
: public geode::Popup<std::vector<IndexSource>, IndexesCallback> {
protected:
std::vector<IndexSource> m_indexes;
IndexesCallback m_setIndexesCallback;
Expand All @@ -26,7 +25,7 @@ class IndexesPopup : public Popup<std::vector<IndexSource>, IndexesCallback> {
bool setup(std::vector<IndexSource>,
IndexesCallback setIndexesCallback) override;
void createList();
CCSize getPopupSize();
cocos2d::CCSize getPopupSize();
void onClose(CCObject*) override;
void onAdd(CCObject*);

Expand Down
2 changes: 1 addition & 1 deletion jukebox/jukebox/ui/indexes_setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace jukebox {

using namespace jukebox::index;

bool Indexes::operator==(const Indexes& other) {
bool Indexes::operator==(const Indexes& other) const {
return this->indexes == other.indexes;
}

Expand Down
18 changes: 8 additions & 10 deletions jukebox/jukebox/ui/indexes_setting.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,25 @@
#include <jukebox/nong/index.hpp>
#include <jukebox/nong/index_serialize.hpp>

using namespace geode::prelude;

namespace jukebox {

using namespace jukebox::index;

struct Indexes {
std::vector<IndexSource> indexes;
bool operator==(const Indexes& other);
bool operator==(const Indexes& other) const;
};

class IndexSetting : public SettingBaseValueV3<Indexes> {
class IndexSetting : public geode::SettingBaseValueV3<Indexes> {
public:
static Result<std::shared_ptr<SettingV3>> parse(const std::string& key,
const std::string& modID,
const matjson::Value& json);
static geode::Result<std::shared_ptr<SettingV3>> parse(
const std::string& key, const std::string& modID,
const matjson::Value& json);

SettingNodeV3* createNode(float width) override;
geode::SettingNodeV3* createNode(float width) override;
};

class IndexSettingNode : public SettingValueNodeV3<IndexSetting> {
class IndexSettingNode : public geode::SettingValueNodeV3<IndexSetting> {
protected:
CCMenuItemSpriteExtra* m_resetBtn;

Expand Down Expand Up @@ -73,6 +71,6 @@ struct matjson::Serialize<jukebox::Indexes> {
matjson::Serialize<jukebox::IndexSource>::fromJson(elem));
ret.indexes.push_back(source);
}
return Ok(ret);
return geode::Ok(ret);
}
};
2 changes: 2 additions & 0 deletions jukebox/jukebox/ui/list/index_cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include <jukebox/nong/index.hpp>

using namespace geode::prelude;

namespace jukebox {

bool IndexCell::init(IndexesPopup* parentPopup, IndexSource* index,
Expand Down
Loading

0 comments on commit e5c9162

Please sign in to comment.