loader stuff

- remove InternalLoader info alerts
 - make sure mods that need early load are early loaded
This commit is contained in:
HJfod 2022-12-12 13:46:00 +02:00
parent 4e6559966f
commit d95c2f3e3c
6 changed files with 12 additions and 33 deletions

View file

@ -207,10 +207,13 @@ namespace geode {
* closed, the value is automatically saved under the key
* @param key Key of the saved value
* @param value Value
* @returns The old value
*/
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;
return old;
}
/**

View file

@ -13,6 +13,8 @@ struct CustomLoadingLayer : Modify<CustomLoadingLayer, LoadingLayer> {
CustomLoadingLayer() : m_updatingResources(false) {}
bool init(bool fromReload) {
Loader::get()->waitForModsToBeLoaded();
if (!LoadingLayer::init(fromReload)) return false;
auto winSize = CCDirector::sharedDirector()->getWinSize();

View file

@ -115,22 +115,6 @@ bool InternalLoader::platformConsoleOpen() const {
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() {
auto version = this->getVersion().toString();
auto tempResourcesZip = dirs::getTempDir() / "new.zip";

View file

@ -39,14 +39,10 @@ protected:
std::vector<std::function<void(void)>> m_gdThreadQueue;
mutable std::mutex m_gdThreadMutex;
bool m_platformConsoleOpen = false;
std::unordered_set<std::string> m_shownInfoAlerts;
std::vector<std::pair<Hook*, Mod*>> m_internalHooks;
bool m_readyToHook;
void saveInfoAlerts(nlohmann::json& json);
void loadInfoAlerts(nlohmann::json& json);
void downloadLoaderResources();
bool loadHooks();
@ -64,13 +60,6 @@ public:
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 executeGDThreadQueue();

View file

@ -447,14 +447,15 @@ void LocalModInfoPopup::onUninstall(CCObject*) {
}
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(
"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.",
"OK"
)
->show();
)->show();
if (m_layer) m_layer->updateAllStates(nullptr);
return;
}

View file

@ -146,7 +146,7 @@ ModCell* ModCell::create(
}
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(
"Notice",
"<cb>Disabling</c> a <cy>mod</c> removes its hooks & patches and "