#include "config.hpp" #include #include #ifdef _WIN32 #include #endif namespace devour { static UnlockConfig g_config; UnlockConfig& Config::get() { return g_config; } std::string Config::defaultPath() { #ifdef _WIN32 char buf[MAX_PATH]{}; if (GetModuleFileNameA(nullptr, buf, MAX_PATH)) { std::filesystem::path exe(buf); return (exe.parent_path() / "DevourUnlocker.json").string(); } #endif return "DevourUnlocker.json"; } std::vector Config::allRobes() { return { "StraightJacket","Patchwork","CherryBlossom","Eggs","Poison","Web", "TownHard","TownNightmare","TownBooks","Horseshoes", "SlaughterhouseHard","SlaughterhouseNightmare","SlaughterhousePigs","BarbedWires", "Golden","ManorHard","ManorNightmare","ManorHeadsBuried","Feathers", "CarnivalHard","CarnivalNightmare","CarnivalDollHeads","Tickets", "Rose","Fire","Inmate","Electric","BlackWithGoldTrim","Hard","Nightmare" }; } std::vector Config::allCharacters() { return {"Molly","Nathan","Sam","Zara","Cultist","Kai","Anna","April","Frank"}; } std::vector Config::allPerks() { return { "Acceleration","Aftershock","Conservationist","Crawler","DuracellBunny","Evader", "FastWorker","FieldMedic","FirstResponder","FullyCharged","Immune","Inspired", "Keymaster","LongSighted","Patient","PowerfulInsight","Quartermaster","Regeneration", "Repellent","Speedy","SpeedWalker","StayBack","SupplyRunner","Tamed","Teamwork", "TeamLeader","Trapper","UnderPressure","CrawlerVent","ConservationistHard","PatientHard", "RegenerationHard" }; } std::vector Config::allPets() { return {"Crow","Pig","Goat","Rat","Spider","Cat","Pug"}; } std::vector Config::allFlashlights() { return {"Basic","UV","Battery","Gold","Carnival","Manor","Hospital","Infinity"}; } std::vector Config::allEmotes() { return {"Wave","Dance","Sit","Point","Laugh","Cry","Angry","Cheer","Clap","Taunt","Shrug","Bow"}; } std::vector Config::allOutfits() { return {"Default","Formal","Casual","Winter","Summer","Anniversary","Hard","Nightmare"}; } bool Config::load(const std::string& path) { std::ifstream f(path); if (!f) return false; std::string content((std::istreambuf_iterator(f)), {}); // Minimal JSON parse — avoid nlohmann dep for portability auto has = [&](const char* key, bool def) -> bool { auto pos = content.find(std::string("\"") + key + "\""); if (pos == std::string::npos) return def; auto colon = content.find(':', pos); if (colon == std::string::npos) return def; auto v = content.substr(colon+1, 20); if (v.find("true") != std::string::npos) return true; if (v.find("false") != std::string::npos) return false; return def; }; g_config.unlockRobes = has("unlockRobes", true); g_config.unlockCharacters = has("unlockCharacters", true); g_config.unlockPerks = has("unlockPerks", true); g_config.unlockFlashlights = has("unlockFlashlights", true); g_config.unlockEmotes = has("unlockEmotes", true); g_config.unlockPets = has("unlockPets", true); g_config.unlockOutfits = has("unlockOutfits", true); g_config.guiVisible = has("guiVisible", true); return true; } bool Config::save(const std::string& path) { std::ofstream f(path); if (!f) return false; auto& c = g_config; f << "{\n"; f << " \"unlockRobes\": " << (c.unlockRobes?"true":"false") << ",\n"; f << " \"unlockCharacters\": " << (c.unlockCharacters?"true":"false") << ",\n"; f << " \"unlockPerks\": " << (c.unlockPerks?"true":"false") << ",\n"; f << " \"unlockFlashlights\": " << (c.unlockFlashlights?"true":"false") << ",\n"; f << " \"unlockEmotes\": " << (c.unlockEmotes?"true":"false") << ",\n"; f << " \"unlockPets\": " << (c.unlockPets?"true":"false") << ",\n"; f << " \"unlockOutfits\": " << (c.unlockOutfits?"true":"false") << ",\n"; f << " \"guiVisible\": " << (c.guiVisible?"true":"false") << "\n"; f << "}\n"; return true; } } // namespace devour