2022-07-30 12:24:03 -04:00
|
|
|
#include <Geode/loader/Loader.hpp>
|
|
|
|
|
2023-03-10 14:33:24 -05:00
|
|
|
using namespace geode::prelude;
|
2022-07-30 12:24:03 -04:00
|
|
|
|
2022-10-13 07:00:41 -04:00
|
|
|
#include <Geode/modify/AppDelegate.hpp>
|
2022-11-09 13:03:53 -05:00
|
|
|
|
2023-12-23 05:32:44 -05:00
|
|
|
struct SaveLoader : Modify<SaveLoader, AppDelegate> {
|
2024-01-12 14:18:24 -05:00
|
|
|
static void onModify(const auto& self) {
|
|
|
|
if (!Loader::get()->isForwardCompatMode())
|
|
|
|
return;
|
|
|
|
log::warn("save disabled in forward compat");
|
|
|
|
for (const auto& [_, hook] : self.m_hooks) {
|
|
|
|
hook->setAutoEnable(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-23 05:32:44 -05:00
|
|
|
void trySaveGame(bool p0) {
|
|
|
|
log::info("Saving mod data...");
|
|
|
|
log::pushNest();
|
2022-07-30 12:24:03 -04:00
|
|
|
|
2023-12-23 05:32:44 -05:00
|
|
|
auto begin = std::chrono::high_resolution_clock::now();
|
2022-07-30 12:24:03 -04:00
|
|
|
|
2023-12-23 05:32:44 -05:00
|
|
|
(void)Loader::get()->saveData();
|
2023-11-11 11:38:01 -05:00
|
|
|
|
2023-12-23 05:32:44 -05:00
|
|
|
auto end = std::chrono::high_resolution_clock::now();
|
|
|
|
auto time = std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count();
|
|
|
|
log::info("Took {}s", static_cast<float>(time) / 1000.f);
|
2023-11-11 11:38:01 -05:00
|
|
|
|
2023-12-23 05:32:44 -05:00
|
|
|
log::popNest();
|
2022-11-09 13:03:53 -05:00
|
|
|
|
2023-12-23 05:32:44 -05:00
|
|
|
return AppDelegate::trySaveGame(p0);
|
|
|
|
}
|
|
|
|
};
|