remove some funcs from Loader

This commit is contained in:
ConfiG 2024-01-13 00:49:42 +03:00
parent a0f70c8c35
commit 98b3a8fbf1
No known key found for this signature in database
GPG key ID: 44DA1983F524C11B
6 changed files with 22 additions and 94 deletions

View file

@ -49,16 +49,9 @@ namespace geode {
~Loader();
protected:
void createDirectories();
void updateModResources(Mod* mod);
void addSearchPaths();
Mod* takeNextMod();
public:
// TODO: do we want to expose all of these functions?
static Loader* get();
enum class LoadingState : uint8_t {
@ -74,9 +67,8 @@ namespace geode {
bool isForwardCompatMode();
// TODO: return void
Result<> saveData();
Result<> loadData();
void saveData();
void loadData();
VersionInfo getVersion();
VersionInfo minModVersion();
@ -91,25 +83,10 @@ namespace geode {
std::vector<Mod*> getAllMods();
std::vector<LoadProblem> getProblems() const;
void updateResources();
void updateResources(bool forceReload);
void queueInMainThread(ScheduledFunction func);
void waitForModsToBeLoaded();
/**
* Open the platform-specific external console (if one exists)
*/
void openPlatformConsole();
/**
* Close the platform-specific external console (if one exists)
*/
void closePlatformConsole();
bool didLastLaunchCrash() const;
bool userTriedToLoadDLLs() const;
friend class LoaderImpl;
friend Mod* takeNextLoaderMod();

View file

@ -132,7 +132,7 @@ struct CustomLoadingLayer : Modify<CustomLoadingLayer, LoadingLayer> {
void setupModResources() {
log::debug("Loading mod resources");
this->setSmallText("Loading mod resources");
Loader::get()->updateResources(true);
LoaderImpl::get()->updateResources(true);
this->continueLoadAssets();
}
@ -220,7 +220,7 @@ struct FallbackCustomLoadingLayer : Modify<FallbackCustomLoadingLayer, CCLayer>
// TODO: verify loader resources on fallback?
Loader::get()->updateResources(true);
LoaderImpl::get()->updateResources(true);
return true;
}

View file

@ -106,7 +106,7 @@ int geodeEntry(void* platformData) {
if (LoaderImpl::get()->isForwardCompatMode() ||
Mod::get()->getSettingValue<bool>("show-platform-console")) {
log::debug("Opening console");
Loader::get()->openPlatformConsole();
LoaderImpl::get()->openPlatformConsole();
}
// set up loader, load mods, etc.

View file

@ -1,3 +1,5 @@
#include <utility>
#include "LoaderImpl.hpp"
using namespace geode::prelude;
@ -15,23 +17,11 @@ bool Loader::isForwardCompatMode() {
return m_impl->isForwardCompatMode();
}
void Loader::createDirectories() {
return m_impl->createDirectories();
}
void Loader::updateModResources(Mod* mod) {
return m_impl->updateModResources(mod);
}
void Loader::addSearchPaths() {
return m_impl->addSearchPaths();
}
Result<> Loader::saveData() {
void Loader::saveData() {
return m_impl->saveData();
}
Result<> Loader::loadData() {
void Loader::loadData() {
return m_impl->loadData();
}
@ -79,28 +69,8 @@ std::vector<LoadProblem> Loader::getProblems() const {
return m_impl->getProblems();
}
void Loader::updateResources() {
return m_impl->updateResources();
}
void Loader::updateResources(bool forceReload) {
return m_impl->updateResources(forceReload);
}
void Loader::queueInMainThread(ScheduledFunction func) {
return m_impl->queueInMainThread(func);
}
void Loader::waitForModsToBeLoaded() {
return m_impl->waitForModsToBeLoaded();
}
void Loader::openPlatformConsole() {
return m_impl->openPlatformConsole();
}
void Loader::closePlatformConsole() {
return m_impl->closePlatformConsole();
return m_impl->queueInMainThread(std::move(func));
}
bool Loader::didLastLaunchCrash() const {
@ -110,7 +80,3 @@ bool Loader::didLastLaunchCrash() const {
Mod* Loader::takeNextMod() {
return m_impl->takeNextMod();
}
bool Loader::userTriedToLoadDLLs() const {
return m_impl->userTriedToLoadDLLs();
}

View file

@ -105,10 +105,6 @@ void Loader::Impl::addSearchPaths() {
CCFileUtils::get()->addPriorityPath(dirs::getModRuntimeDir().string().c_str());
}
void Loader::Impl::updateResources() {
this->updateResources(true);
}
void Loader::Impl::updateResources(bool forceReload) {
log::debug("Adding resources");
log::pushNest();
@ -154,7 +150,7 @@ bool Loader::Impl::isModVersionSupported(VersionInfo const& version) {
// Data saving
Result<> Loader::Impl::saveData() {
void Loader::Impl::saveData() {
for (auto& [id, mod] : m_mods) {
log::debug("{}", mod->getID());
log::pushNest();
@ -164,10 +160,9 @@ Result<> Loader::Impl::saveData() {
}
log::popNest();
}
return Ok();
}
Result<> Loader::Impl::loadData() {
void Loader::Impl::loadData() {
for (auto& [_, mod] : m_mods) {
log::debug("{}", mod->getID());
log::pushNest();
@ -177,7 +172,6 @@ Result<> Loader::Impl::loadData() {
}
log::popNest();
}
return Ok();
}
// Mod loading
@ -669,12 +663,6 @@ std::vector<LoadProblem> Loader::Impl::getProblems() const {
return m_problems;
}
void Loader::Impl::waitForModsToBeLoaded() {
log::debug("Waiting for mods to be loaded...");
// genius
log::warn("waitForModsToBeLoaded() does not wait for mods to be loaded!");
}
bool Loader::Impl::didLastLaunchCrash() const {
return crashlog::didLastLaunchCrash();
}
@ -713,17 +701,17 @@ bool Loader::Impl::loadHooks() {
}
void Loader::Impl::queueInMainThread(ScheduledFunction func) {
std::lock_guard<std::mutex> lock(m_gdThreadMutex);
m_gdThreadQueue.push_back(func);
std::lock_guard<std::mutex> lock(m_mainThreadMutex);
m_mainThreadQueue.push_back(func);
}
void Loader::Impl::executeGDThreadQueue() {
// copy queue to avoid locking mutex if someone is
// running addToGDThread inside their function
m_gdThreadMutex.lock();
auto queue = m_gdThreadQueue;
m_gdThreadQueue.clear();
m_gdThreadMutex.unlock();
m_mainThreadMutex.lock();
auto queue = m_mainThreadQueue;
m_mainThreadQueue.clear();
m_mainThreadMutex.unlock();
// call queue
for (auto const& func : queue) {

View file

@ -73,8 +73,8 @@ namespace geode {
LoadingState m_loadingState;
std::vector<utils::MiniFunction<void(void)>> m_gdThreadQueue;
mutable std::mutex m_gdThreadMutex;
std::vector<utils::MiniFunction<void(void)>> m_mainThreadQueue;
mutable std::mutex m_mainThreadMutex;
std::vector<std::pair<Hook*, Mod*>> m_uninitializedHooks;
bool m_readyToHook = false;
@ -132,8 +132,8 @@ namespace geode {
Result<> setup();
void forceReset();
Result<> saveData();
Result<> loadData();
void saveData();
void loadData();
VersionInfo getVersion();
VersionInfo minModVersion();
@ -155,11 +155,8 @@ namespace geode {
std::vector<Mod*> getAllMods();
std::vector<LoadProblem> getProblems() const;
void updateResources();
void updateResources(bool forceReload);
void waitForModsToBeLoaded();
bool didLastLaunchCrash() const;
matjson::Value processRawIPC(void* rawHandle, std::string const& buffer);