aboutsummaryrefslogtreecommitdiff
path: root/primedev/mods/compiled/kb_act.cpp
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2023-12-27 00:32:01 +0000
committerGitHub <noreply@github.com>2023-12-27 01:32:01 +0100
commitf5ab6fb5e8be7b73e6003d4145081d5e0c0ce287 (patch)
tree90f2c6a4885dbd181799e2325cf33588697674e1 /primedev/mods/compiled/kb_act.cpp
parentbb8ed59f6891b1196c5f5bbe7346cd171c8215fa (diff)
downloadNorthstarLauncher-f5ab6fb5e8be7b73e6003d4145081d5e0c0ce287.tar.gz
NorthstarLauncher-f5ab6fb5e8be7b73e6003d4145081d5e0c0ce287.zip
Folder restructuring from primedev (#624)v1.21.2-rc3v1.21.2
Copies of over the primedev folder structure for easier cherry-picking of further changes Co-authored-by: F1F7Y <filip.bartos07@proton.me>
Diffstat (limited to 'primedev/mods/compiled/kb_act.cpp')
-rw-r--r--primedev/mods/compiled/kb_act.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/primedev/mods/compiled/kb_act.cpp b/primedev/mods/compiled/kb_act.cpp
new file mode 100644
index 00000000..6117fd28
--- /dev/null
+++ b/primedev/mods/compiled/kb_act.cpp
@@ -0,0 +1,44 @@
+#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 << 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;
+}