diff --git a/entry.cpp b/entry.cpp index 0be8b4f4..81750a8d 100644 --- a/entry.cpp +++ b/entry.cpp @@ -1,10 +1,9 @@ // included by default in every geode project - #include GEODE_API bool GEODE_CALL geode_implicit_load(geode::Mod* m) { - geode::Mod::setSharedMod(m); - geode::log::releaseSchedules(m); - geode::Loader::get()->releaseScheduledFunctions(m); - return true; + geode::Mod::setSharedMod(m); + geode::log::releaseSchedules(m); + geode::Loader::get()->releaseScheduledFunctions(m); + return true; } diff --git a/loader/include/Geode/loader/Loader.hpp b/loader/include/Geode/loader/Loader.hpp index 2a4a1a1f..ed96597f 100644 --- a/loader/include/Geode/loader/Loader.hpp +++ b/loader/include/Geode/loader/Loader.hpp @@ -79,8 +79,6 @@ namespace geode { void updateAllDependencies(); - void releaseScheduledFunctions(Mod* mod); - friend class Mod; friend class CustomLoader; friend struct ModInfo; @@ -93,6 +91,9 @@ namespace geode { void updateResourcePaths(); void updateModResources(Mod* mod); + // used internally in geode_implicit_load + void releaseScheduledFunctions(Mod* mod); + friend bool GEODE_CALL ::geode_implicit_load(Mod*); public: diff --git a/loader/include/Geode/loader/Mod.hpp b/loader/include/Geode/loader/Mod.hpp index b3ed0423..56e8d58d 100644 --- a/loader/include/Geode/loader/Mod.hpp +++ b/loader/include/Geode/loader/Mod.hpp @@ -331,6 +331,7 @@ namespace geode { template static inline GEODE_HIDDEN Mod* sharedMod = nullptr; + // used internally in geode_implicit_load template static inline GEODE_HIDDEN void setSharedMod(Mod* mod) { sharedMod<> = mod; diff --git a/loader/src/hooks/MenuLayer.cpp b/loader/src/hooks/MenuLayer.cpp index c9ba2c71..1f198e14 100644 --- a/loader/src/hooks/MenuLayer.cpp +++ b/loader/src/hooks/MenuLayer.cpp @@ -59,7 +59,7 @@ static void updateIndexProgress(UpdateStatus status, std::string const& info, ui template - requires std::is_base_of_v +requires std::is_base_of_v T* setIDSafe(CCNode* node, int index, char const* id) { if constexpr (std::is_same_v) { if (auto child = getChild(node, index)) { @@ -86,7 +86,6 @@ struct CustomMenuLayer : Modify { bool init() { if (!MenuLayer::init()) return false; - // set IDs to everything this->setID("main-menu-layer"); setIDSafe(this, 0, "main-menu-bg"); diff --git a/loader/src/internal/InternalMod.cpp b/loader/src/internal/InternalMod.cpp index 87e37a07..b3002bd9 100644 --- a/loader/src/internal/InternalMod.cpp +++ b/loader/src/internal/InternalMod.cpp @@ -42,6 +42,7 @@ static ModInfo getInternalModInfo() { InternalMod::InternalMod() : Mod(getInternalModInfo()) { m_saveDirPath = Loader::get()->getGeodeSaveDirectory() / GEODE_MOD_DIRECTORY / m_info.m_id; + ghc::filesystem::create_directories(m_saveDirPath); // make sure spritesheets get added diff --git a/loader/src/load/Loader.cpp b/loader/src/load/Loader.cpp index 7ca27849..4be61695 100644 --- a/loader/src/load/Loader.cpp +++ b/loader/src/load/Loader.cpp @@ -37,9 +37,9 @@ void Loader::createDirectories() { auto tempDir = this->getGeodeDirectory() / GEODE_TEMP_DIRECTORY; auto confDir = this->getGeodeDirectory() / GEODE_CONFIG_DIRECTORY; - #ifdef GEODE_IS_MACOS +#ifdef GEODE_IS_MACOS ghc::filesystem::create_directory(this->getSaveDirectory()); - #endif +#endif ghc::filesystem::create_directories(resDir); ghc::filesystem::create_directory(confDir); @@ -426,13 +426,22 @@ ghc::filesystem::path Loader::getGameDirectory() const { return ghc::filesystem::path(CCFileUtils::sharedFileUtils()->getWritablePath2().c_str()); } +#ifdef GEODE_IS_WINDOWS + #include +#endif + ghc::filesystem::path Loader::getSaveDirectory() const { - // not using ~/Library/Caches - #ifdef GEODE_IS_MACOS +// not using ~/Library/Caches +#ifdef GEODE_IS_MACOS return ghc::filesystem::path("/Users/Shared/Geode"); - #else +#elif defined(GEODE_IS_WINDOWS) + return ghc::filesystem::path( + std::filesystem::weakly_canonical(CCFileUtils::sharedFileUtils()->getWritablePath().c_str()) + .string() + ); +#else return ghc::filesystem::path(CCFileUtils::sharedFileUtils()->getWritablePath().c_str()); - #endif +#endif } ghc::filesystem::path Loader::getGeodeDirectory() const { diff --git a/loader/src/main.cpp b/loader/src/main.cpp index 57cde5ac..f406886a 100644 --- a/loader/src/main.cpp +++ b/loader/src/main.cpp @@ -118,7 +118,9 @@ int geodeEntry(void* platformData) { "internal tools and Geode can not be loaded. " "(InternalLoader::get returned nullptr)" ); + return 1; } + if (!geode::core::hook::initialize()) { InternalLoader::platformMessageBox( "Unable to load Geode!", @@ -126,7 +128,9 @@ int geodeEntry(void* platformData) { "internal tools and Geode can not be loaded. " "(Unable to set up hook manager)" ); + return 1; } + geode_implicit_load(InternalMod::get()); if (!InternalLoader::get()->setup()) {