mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-23 07:57:51 -05:00
loader stuff
- remove InternalLoader info alerts - make sure mods that need early load are early loaded
This commit is contained in:
parent
4e6559966f
commit
d95c2f3e3c
6 changed files with 12 additions and 33 deletions
|
@ -207,10 +207,13 @@ namespace geode {
|
||||||
* closed, the value is automatically saved under the key
|
* closed, the value is automatically saved under the key
|
||||||
* @param key Key of the saved value
|
* @param key Key of the saved value
|
||||||
* @param value Value
|
* @param value Value
|
||||||
|
* @returns The old value
|
||||||
*/
|
*/
|
||||||
template<class T>
|
template<class T>
|
||||||
void setSavedValue(std::string const& key, T const& value) {
|
T setSavedValue(std::string const& key, T const& value) {
|
||||||
|
auto old = this->getSavedValue<T>(key);
|
||||||
m_saved[key] = value;
|
m_saved[key] = value;
|
||||||
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,6 +13,8 @@ struct CustomLoadingLayer : Modify<CustomLoadingLayer, LoadingLayer> {
|
||||||
CustomLoadingLayer() : m_updatingResources(false) {}
|
CustomLoadingLayer() : m_updatingResources(false) {}
|
||||||
|
|
||||||
bool init(bool fromReload) {
|
bool init(bool fromReload) {
|
||||||
|
Loader::get()->waitForModsToBeLoaded();
|
||||||
|
|
||||||
if (!LoadingLayer::init(fromReload)) return false;
|
if (!LoadingLayer::init(fromReload)) return false;
|
||||||
|
|
||||||
auto winSize = CCDirector::sharedDirector()->getWinSize();
|
auto winSize = CCDirector::sharedDirector()->getWinSize();
|
||||||
|
|
|
@ -115,22 +115,6 @@ bool InternalLoader::platformConsoleOpen() const {
|
||||||
return m_platformConsoleOpen;
|
return m_platformConsoleOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InternalLoader::shownInfoAlert(std::string const& key) {
|
|
||||||
if (m_shownInfoAlerts.count(key)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
m_shownInfoAlerts.insert(key);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InternalLoader::saveInfoAlerts(nlohmann::json& json) {
|
|
||||||
json["alerts"] = m_shownInfoAlerts;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InternalLoader::loadInfoAlerts(nlohmann::json& json) {
|
|
||||||
m_shownInfoAlerts = json["alerts"].get<std::unordered_set<std::string>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InternalLoader::downloadLoaderResources() {
|
void InternalLoader::downloadLoaderResources() {
|
||||||
auto version = this->getVersion().toString();
|
auto version = this->getVersion().toString();
|
||||||
auto tempResourcesZip = dirs::getTempDir() / "new.zip";
|
auto tempResourcesZip = dirs::getTempDir() / "new.zip";
|
||||||
|
|
|
@ -39,14 +39,10 @@ protected:
|
||||||
std::vector<std::function<void(void)>> m_gdThreadQueue;
|
std::vector<std::function<void(void)>> m_gdThreadQueue;
|
||||||
mutable std::mutex m_gdThreadMutex;
|
mutable std::mutex m_gdThreadMutex;
|
||||||
bool m_platformConsoleOpen = false;
|
bool m_platformConsoleOpen = false;
|
||||||
std::unordered_set<std::string> m_shownInfoAlerts;
|
|
||||||
|
|
||||||
std::vector<std::pair<Hook*, Mod*>> m_internalHooks;
|
std::vector<std::pair<Hook*, Mod*>> m_internalHooks;
|
||||||
bool m_readyToHook;
|
bool m_readyToHook;
|
||||||
|
|
||||||
void saveInfoAlerts(nlohmann::json& json);
|
|
||||||
void loadInfoAlerts(nlohmann::json& json);
|
|
||||||
|
|
||||||
void downloadLoaderResources();
|
void downloadLoaderResources();
|
||||||
|
|
||||||
bool loadHooks();
|
bool loadHooks();
|
||||||
|
@ -64,13 +60,6 @@ public:
|
||||||
|
|
||||||
static nlohmann::json processRawIPC(void* rawHandle, std::string const& buffer);
|
static nlohmann::json processRawIPC(void* rawHandle, std::string const& buffer);
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a one-time event has been shown to the user,
|
|
||||||
* and set it to true if not. Will return the previous
|
|
||||||
* state of the event before setting it to true
|
|
||||||
*/
|
|
||||||
bool shownInfoAlert(std::string const& key);
|
|
||||||
|
|
||||||
void queueInGDThread(ScheduledFunction func);
|
void queueInGDThread(ScheduledFunction func);
|
||||||
void executeGDThreadQueue();
|
void executeGDThreadQueue();
|
||||||
|
|
||||||
|
|
|
@ -447,14 +447,15 @@ void LocalModInfoPopup::onUninstall(CCObject*) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalModInfoPopup::onEnableMod(CCObject* sender) {
|
void LocalModInfoPopup::onEnableMod(CCObject* sender) {
|
||||||
if (!InternalLoader::get()->shownInfoAlert("mod-disable-vs-unload")) {
|
if (!Mod::get()->setSavedValue("shown-disable-vs-unload-info", true)) {
|
||||||
FLAlertLayer::create(
|
FLAlertLayer::create(
|
||||||
"Notice",
|
"Notice",
|
||||||
"You may still see some effects of the mod left, and you may "
|
"<cb>Disabling</c> a <cy>mod</c> removes its hooks & patches and "
|
||||||
|
"calls its user-defined disable function if one exists. You may "
|
||||||
|
"still see some effects of the mod left however, and you may "
|
||||||
"need to <cg>restart</c> the game to have it fully unloaded.",
|
"need to <cg>restart</c> the game to have it fully unloaded.",
|
||||||
"OK"
|
"OK"
|
||||||
)
|
)->show();
|
||||||
->show();
|
|
||||||
if (m_layer) m_layer->updateAllStates(nullptr);
|
if (m_layer) m_layer->updateAllStates(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ ModCell* ModCell::create(
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModCell::onEnable(CCObject* sender) {
|
void ModCell::onEnable(CCObject* sender) {
|
||||||
if (!InternalLoader::get()->shownInfoAlert("mod-disable-vs-unload")) {
|
if (!Mod::get()->setSavedValue("shown-disable-vs-unload-info", true)) {
|
||||||
FLAlertLayer::create(
|
FLAlertLayer::create(
|
||||||
"Notice",
|
"Notice",
|
||||||
"<cb>Disabling</c> a <cy>mod</c> removes its hooks & patches and "
|
"<cb>Disabling</c> a <cy>mod</c> removes its hooks & patches and "
|
||||||
|
|
Loading…
Reference in a new issue