aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/mods/compiled/kb_act.cpp
diff options
context:
space:
mode:
authorEmma Miler <emma.pi@protonmail.com>2022-12-19 19:32:16 +0100
committerGitHub <noreply@github.com>2022-12-19 19:32:16 +0100
commite04f3b36accccb590a2d51b4829256b9964ac3fd (patch)
tree20ee30c82e6f53e6e772be2e1b9613eebca12bf3 /NorthstarDLL/mods/compiled/kb_act.cpp
parent33f18a735986dcd136bf8ba70ad8331306c28227 (diff)
downloadNorthstarLauncher-e04f3b36accccb590a2d51b4829256b9964ac3fd.tar.gz
NorthstarLauncher-e04f3b36accccb590a2d51b4829256b9964ac3fd.zip
Restructuring (#365)
* Remove launcher proxy * Restructuring * More restructuring * Fix include dirs * Fix merge * Remove clang thing * Filters * Oops
Diffstat (limited to 'NorthstarDLL/mods/compiled/kb_act.cpp')
-rw-r--r--NorthstarDLL/mods/compiled/kb_act.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/NorthstarDLL/mods/compiled/kb_act.cpp b/NorthstarDLL/mods/compiled/kb_act.cpp
new file mode 100644
index 00000000..4a011dc7
--- /dev/null
+++ b/NorthstarDLL/mods/compiled/kb_act.cpp
@@ -0,0 +1,45 @@
+#include "pch.h"
+#include "mods/modmanager.h"
+#include "core/filesystem/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;
+}