diff options
author | BobTheBob9 <for.oliver.kirkham@gmail.com> | 2022-08-16 01:12:59 +0100 |
---|---|---|
committer | BobTheBob9 <for.oliver.kirkham@gmail.com> | 2022-08-16 01:12:59 +0100 |
commit | 082f3893215797268d7ac8c1000ebe371f276af7 (patch) | |
tree | b5cc677a49635a9244559e235d4915c064c9f6c4 /NorthstarDLL/scriptsrson.cpp | |
parent | b30a385fc25dad05e568ae8538f5aa3656c5c8d4 (diff) | |
download | NorthstarLauncher-082f3893215797268d7ac8c1000ebe371f276af7.tar.gz NorthstarLauncher-082f3893215797268d7ac8c1000ebe371f276af7.zip |
lots of stuff idk
Diffstat (limited to 'NorthstarDLL/scriptsrson.cpp')
-rw-r--r-- | NorthstarDLL/scriptsrson.cpp | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/NorthstarDLL/scriptsrson.cpp b/NorthstarDLL/scriptsrson.cpp index 0aaab277..1e0ded27 100644 --- a/NorthstarDLL/scriptsrson.cpp +++ b/NorthstarDLL/scriptsrson.cpp @@ -1,64 +1,64 @@ -#include "pch.h"
-#include "modmanager.h"
-#include "scriptsrson.h"
-#include "filesystem.h"
-#include "squirrel.h"
-
-#include <fstream>
-
-void ModManager::BuildScriptsRson()
-{
- spdlog::info("Building custom scripts.rson");
- fs::path MOD_SCRIPTS_RSON_PATH = fs::path(GetCompiledAssetsPath() / MOD_SCRIPTS_RSON_SUFFIX);
- fs::remove(MOD_SCRIPTS_RSON_PATH);
-
- std::string scriptsRson = R2::ReadVPKOriginalFile(VPK_SCRIPTS_RSON_PATH);
- scriptsRson += "\n\n// START MODDED SCRIPT CONTENT\n\n"; // newline before we start custom stuff
-
- for (Mod& mod : m_LoadedMods)
- {
- if (!mod.m_bEnabled)
- continue;
-
- // this isn't needed at all, just nice to have imo
- scriptsRson += "// MOD: ";
- scriptsRson += mod.Name;
- scriptsRson += ":\n\n";
-
- for (ModScript& script : mod.Scripts)
- {
- /* should create something with this format for each script
- When: "CONTEXT"
- Scripts:
- [
- _coolscript.gnut
- ]*/
-
- scriptsRson += "When: \"";
- scriptsRson += script.RunOn;
- scriptsRson += "\"\n";
-
- scriptsRson += "Scripts:\n[\n\t";
- scriptsRson += script.Path;
- scriptsRson += "\n]\n\n";
- }
- }
-
- fs::create_directories(MOD_SCRIPTS_RSON_PATH.parent_path());
-
- std::ofstream writeStream(MOD_SCRIPTS_RSON_PATH, std::ios::binary);
- writeStream << scriptsRson;
- writeStream.close();
-
- ModOverrideFile overrideFile;
- overrideFile.m_pOwningMod = nullptr;
- overrideFile.m_Path = VPK_SCRIPTS_RSON_PATH;
-
- if (m_ModFiles.find(VPK_SCRIPTS_RSON_PATH) == m_ModFiles.end())
- m_ModFiles.insert(std::make_pair(VPK_SCRIPTS_RSON_PATH, overrideFile));
- else
- m_ModFiles[VPK_SCRIPTS_RSON_PATH] = overrideFile;
-
- // todo: for preventing dupe scripts in scripts.rson, we could actually parse when conditions with the squirrel vm, just need a way to
- // get a result out of squirrelmanager.ExecuteCode this would probably be the best way to do this, imo
-}
\ No newline at end of file +#include "pch.h" +#include "modmanager.h" +#include "scriptsrson.h" +#include "filesystem.h" +#include "squirrel.h" + +#include <fstream> + +void ModManager::BuildScriptsRson() +{ + spdlog::info("Building custom scripts.rson"); + fs::path MOD_SCRIPTS_RSON_PATH = fs::path(GetCompiledAssetsPath() / MOD_SCRIPTS_RSON_SUFFIX); + fs::remove(MOD_SCRIPTS_RSON_PATH); + + std::string scriptsRson = R2::ReadVPKOriginalFile(VPK_SCRIPTS_RSON_PATH); + scriptsRson += "\n\n// START MODDED SCRIPT CONTENT\n\n"; // newline before we start custom stuff + + for (Mod& mod : m_LoadedMods) + { + if (!mod.m_bEnabled) + continue; + + // this isn't needed at all, just nice to have imo + scriptsRson += "// MOD: "; + scriptsRson += mod.Name; + scriptsRson += ":\n\n"; + + for (ModScript& script : mod.Scripts) + { + /* should create something with this format for each script + When: "CONTEXT" + Scripts: + [ + _coolscript.gnut + ]*/ + + scriptsRson += "When: \""; + scriptsRson += script.RunOn; + scriptsRson += "\"\n"; + + scriptsRson += "Scripts:\n[\n\t"; + scriptsRson += script.Path; + scriptsRson += "\n]\n\n"; + } + } + + fs::create_directories(MOD_SCRIPTS_RSON_PATH.parent_path()); + + std::ofstream writeStream(MOD_SCRIPTS_RSON_PATH, std::ios::binary); + writeStream << scriptsRson; + writeStream.close(); + + ModOverrideFile overrideFile; + overrideFile.m_pOwningMod = nullptr; + overrideFile.m_Path = VPK_SCRIPTS_RSON_PATH; + + if (m_ModFiles.find(VPK_SCRIPTS_RSON_PATH) == m_ModFiles.end()) + m_ModFiles.insert(std::make_pair(VPK_SCRIPTS_RSON_PATH, overrideFile)); + else + m_ModFiles[VPK_SCRIPTS_RSON_PATH] = overrideFile; + + // todo: for preventing dupe scripts in scripts.rson, we could actually parse when conditions with the squirrel vm, just need a way to + // get a result out of squirrelmanager.ExecuteCode this would probably be the best way to do this, imo +} |