aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/scriptmodmenu.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-10-06 21:46:32 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-10-06 21:46:32 +0100
commit900855c0036aa9a6a6305e3f17a41a55640bdfaf (patch)
tree2f6a3c07549927b600ec3b1a8389a0062a684a53 /NorthstarDedicatedTest/scriptmodmenu.cpp
parent51df18abbc0c344b56f88e0a66b6b46d6aca375c (diff)
downloadNorthstarLauncher-900855c0036aa9a6a6305e3f17a41a55640bdfaf.tar.gz
NorthstarLauncher-900855c0036aa9a6a6305e3f17a41a55640bdfaf.zip
add mod enabling/disabling
Diffstat (limited to 'NorthstarDedicatedTest/scriptmodmenu.cpp')
-rw-r--r--NorthstarDedicatedTest/scriptmodmenu.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/scriptmodmenu.cpp b/NorthstarDedicatedTest/scriptmodmenu.cpp
index ca7d047d..74319f56 100644
--- a/NorthstarDedicatedTest/scriptmodmenu.cpp
+++ b/NorthstarDedicatedTest/scriptmodmenu.cpp
@@ -18,6 +18,43 @@ SQInteger SQ_GetModNames(void* sqvm)
return 1;
}
+// bool NSIsModEnabled(string modName)
+SQInteger SQ_IsModEnabled(void* sqvm)
+{
+ const SQChar* modName = ClientSq_getstring(sqvm, 1);
+
+ // manual lookup, not super performant but eh not a big deal
+ for (Mod* mod : g_ModManager->m_loadedMods)
+ {
+ if (!mod->Name.compare(modName))
+ {
+ ClientSq_pushbool(sqvm, mod->Enabled);
+ return 1;
+ }
+ }
+
+ return 0; // return null
+}
+
+// void NSSetModEnabled(string modName, bool enabled)
+SQInteger SQ_SetModEnabled(void* sqvm)
+{
+ const SQChar* modName = ClientSq_getstring(sqvm, 1);
+ const SQBool enabled = ClientSq_getbool(sqvm, 2);
+
+ // manual lookup, not super performant but eh not a big deal
+ for (Mod* mod : g_ModManager->m_loadedMods)
+ {
+ if (!mod->Name.compare(modName))
+ {
+ mod->Enabled = enabled;
+ return 0; // return null
+ }
+ }
+
+ return 0; // return null
+}
+
// string NSGetModDescriptionByModName(string modName)
SQInteger SQ_GetModDescription(void* sqvm)
{
@@ -127,6 +164,8 @@ void InitialiseScriptModMenu(HMODULE baseAddress)
return;
g_UISquirrelManager->AddFuncRegistration("array<string>", "NSGetModNames", "", "Returns the names of all loaded mods", SQ_GetModNames);
+ g_UISquirrelManager->AddFuncRegistration("bool", "NSIsModEnabled", "string modName", "Returns whether a given mod is enabled", SQ_IsModEnabled);
+ g_UISquirrelManager->AddFuncRegistration("void", "NSSetModEnabled", "string modName, bool enabled", "Sets whether a given mod is enabled", SQ_SetModEnabled);
g_UISquirrelManager->AddFuncRegistration("string", "NSGetModDescriptionByModName", "string modName", "Returns a given mod's description", SQ_GetModDescription);
g_UISquirrelManager->AddFuncRegistration("string", "NSGetModVersionByModName", "string modName", "Returns a given mod's version", SQ_GetModVersion);
g_UISquirrelManager->AddFuncRegistration("string", "NSGetModDownloadLinkByModName", "string modName", "Returns a given mod's download link", SQ_GetModDownloadLink);