aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/kb_act.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-11-13 00:26:46 +0000
committerGitHub <noreply@github.com>2022-11-13 00:26:46 +0000
commitd237401bb97c1fa2d6ee87220d49e4b3343e7201 (patch)
tree241b421ac76c69044378b008e1233bfc066fadd3 /NorthstarDLL/kb_act.cpp
parentbf09852285941e20a04731443d03c693e3f8ba2d (diff)
downloadNorthstarLauncher-d237401bb97c1fa2d6ee87220d49e4b3343e7201.tar.gz
NorthstarLauncher-d237401bb97c1fa2d6ee87220d49e4b3343e7201.zip
allow kb_act.lst to be compiled from multiple mods (#298)
* allow kb_act.lst to be compiled from multiple mods * fixup formatting * add a couple extra comments because i really did not add enough
Diffstat (limited to 'NorthstarDLL/kb_act.cpp')
-rw-r--r--NorthstarDLL/kb_act.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/NorthstarDLL/kb_act.cpp b/NorthstarDLL/kb_act.cpp
new file mode 100644
index 00000000..5fe71cdb
--- /dev/null
+++ b/NorthstarDLL/kb_act.cpp
@@ -0,0 +1,45 @@
+#include "pch.h"
+#include "modmanager.h"
+#include "filesystem.h"
+
+#include <fstream>
+
+const char* KB_ACT_PATH = "scripts\\kb_act.lst";
+
+// compiles the file kb_act.lst, that defines entries for keybindings in the options menu
+void ModManager::BuildKBActionsList()
+{
+ spdlog::info("Building kb_act.lst");
+
+ fs::create_directories(GetCompiledAssetsPath() / "scripts");
+ std::ofstream soCompiledKeys(GetCompiledAssetsPath() / KB_ACT_PATH, std::ios::binary);
+
+ // write vanilla file's content to compiled file
+ soCompiledKeys << R2::ReadVPKOriginalFile(KB_ACT_PATH);
+
+ for (Mod& mod : m_LoadedMods)
+ {
+ if (!mod.m_bEnabled)
+ continue;
+
+ // write content of each modded file to compiled file
+ std::ifstream siModKeys(mod.m_ModDirectory / "kb_act.lst");
+
+ if (siModKeys.good())
+ soCompiledKeys << siModKeys.rdbuf() << std::endl;
+
+ siModKeys.close();
+ }
+
+ soCompiledKeys.close();
+
+ // push to overrides
+ ModOverrideFile overrideFile;
+ overrideFile.m_pOwningMod = nullptr;
+ overrideFile.m_Path = KB_ACT_PATH;
+
+ if (m_ModFiles.find(KB_ACT_PATH) == m_ModFiles.end())
+ m_ModFiles.insert(std::make_pair(KB_ACT_PATH, overrideFile));
+ else
+ m_ModFiles[KB_ACT_PATH] = overrideFile;
+}