diff options
Diffstat (limited to 'NorthstarDLL/scriptmodmenu.cpp')
-rw-r--r-- | NorthstarDLL/scriptmodmenu.cpp | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/NorthstarDLL/scriptmodmenu.cpp b/NorthstarDLL/scriptmodmenu.cpp index 767ede91..d2f35285 100644 --- a/NorthstarDLL/scriptmodmenu.cpp +++ b/NorthstarDLL/scriptmodmenu.cpp @@ -1,33 +1,32 @@ #include "pch.h" -#include "scriptmodmenu.h" #include "modmanager.h" #include "squirrel.h" // array<string> function NSGetModNames() -SQRESULT SQ_GetModNames(void* sqvm) +SQRESULT SQ_GetModNames(HSquirrelVM* sqvm) { - ClientSq_newarray(sqvm, 0); + g_pSquirrel<ScriptContext::UI>->newarray(sqvm, 0); - for (Mod& mod : g_ModManager->m_loadedMods) + for (Mod& mod : g_pModManager->m_LoadedMods) { - ClientSq_pushstring(sqvm, mod.Name.c_str(), -1); - ClientSq_arrayappend(sqvm, -2); + g_pSquirrel<ScriptContext::UI>->pushstring(sqvm, mod.Name.c_str()); + g_pSquirrel<ScriptContext::UI>->arrayappend(sqvm, -2); } return SQRESULT_NOTNULL; } // bool function NSIsModEnabled(string modName) -SQRESULT SQ_IsModEnabled(void* sqvm) +SQRESULT SQ_IsModEnabled(HSquirrelVM* sqvm) { - const SQChar* modName = ClientSq_getstring(sqvm, 1); + const SQChar* modName = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 1); // manual lookup, not super performant but eh not a big deal - for (Mod& mod : g_ModManager->m_loadedMods) + for (Mod& mod : g_pModManager->m_LoadedMods) { if (!mod.Name.compare(modName)) { - ClientSq_pushbool(sqvm, mod.Enabled); + g_pSquirrel<ScriptContext::UI>->pushbool(sqvm, mod.m_bEnabled); return SQRESULT_NOTNULL; } } @@ -36,17 +35,17 @@ SQRESULT SQ_IsModEnabled(void* sqvm) } // void function NSSetModEnabled(string modName, bool enabled) -SQRESULT SQ_SetModEnabled(void* sqvm) +SQRESULT SQ_SetModEnabled(HSquirrelVM* sqvm) { - const SQChar* modName = ClientSq_getstring(sqvm, 1); - const SQBool enabled = ClientSq_getbool(sqvm, 2); + const SQChar* modName = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 1); + const SQBool enabled = g_pSquirrel<ScriptContext::UI>->getbool(sqvm, 2); // manual lookup, not super performant but eh not a big deal - for (Mod& mod : g_ModManager->m_loadedMods) + for (Mod& mod : g_pModManager->m_LoadedMods) { if (!mod.Name.compare(modName)) { - mod.Enabled = enabled; + mod.m_bEnabled = enabled; return SQRESULT_NULL; } } @@ -55,16 +54,16 @@ SQRESULT SQ_SetModEnabled(void* sqvm) } // string function NSGetModDescriptionByModName(string modName) -SQRESULT SQ_GetModDescription(void* sqvm) +SQRESULT SQ_GetModDescription(HSquirrelVM* sqvm) { - const SQChar* modName = ClientSq_getstring(sqvm, 1); + const SQChar* modName = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 1); // manual lookup, not super performant but eh not a big deal - for (Mod& mod : g_ModManager->m_loadedMods) + for (Mod& mod : g_pModManager->m_LoadedMods) { if (!mod.Name.compare(modName)) { - ClientSq_pushstring(sqvm, mod.Description.c_str(), -1); + g_pSquirrel<ScriptContext::UI>->pushstring(sqvm, mod.Description.c_str()); return SQRESULT_NOTNULL; } } @@ -73,16 +72,16 @@ SQRESULT SQ_GetModDescription(void* sqvm) } // string function NSGetModVersionByModName(string modName) -SQRESULT SQ_GetModVersion(void* sqvm) +SQRESULT SQ_GetModVersion(HSquirrelVM* sqvm) { - const SQChar* modName = ClientSq_getstring(sqvm, 1); + const SQChar* modName = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 1); // manual lookup, not super performant but eh not a big deal - for (Mod& mod : g_ModManager->m_loadedMods) + for (Mod& mod : g_pModManager->m_LoadedMods) { if (!mod.Name.compare(modName)) { - ClientSq_pushstring(sqvm, mod.Version.c_str(), -1); + g_pSquirrel<ScriptContext::UI>->pushstring(sqvm, mod.Version.c_str()); return SQRESULT_NOTNULL; } } @@ -91,16 +90,16 @@ SQRESULT SQ_GetModVersion(void* sqvm) } // string function NSGetModDownloadLinkByModName(string modName) -SQRESULT SQ_GetModDownloadLink(void* sqvm) +SQRESULT SQ_GetModDownloadLink(HSquirrelVM* sqvm) { - const SQChar* modName = ClientSq_getstring(sqvm, 1); + const SQChar* modName = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 1); // manual lookup, not super performant but eh not a big deal - for (Mod& mod : g_ModManager->m_loadedMods) + for (Mod& mod : g_pModManager->m_LoadedMods) { if (!mod.Name.compare(modName)) { - ClientSq_pushstring(sqvm, mod.DownloadLink.c_str(), -1); + g_pSquirrel<ScriptContext::UI>->pushstring(sqvm, mod.DownloadLink.c_str()); return SQRESULT_NOTNULL; } } @@ -109,16 +108,16 @@ SQRESULT SQ_GetModDownloadLink(void* sqvm) } // int function NSGetModLoadPriority(string modName) -SQRESULT SQ_GetModLoadPriority(void* sqvm) +SQRESULT SQ_GetModLoadPriority(HSquirrelVM* sqvm) { - const SQChar* modName = ClientSq_getstring(sqvm, 1); + const SQChar* modName = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 1); // manual lookup, not super performant but eh not a big deal - for (Mod& mod : g_ModManager->m_loadedMods) + for (Mod& mod : g_pModManager->m_LoadedMods) { if (!mod.Name.compare(modName)) { - ClientSq_pushinteger(sqvm, mod.LoadPriority); + g_pSquirrel<ScriptContext::UI>->pushinteger(sqvm, mod.LoadPriority); return SQRESULT_NOTNULL; } } @@ -127,16 +126,16 @@ SQRESULT SQ_GetModLoadPriority(void* sqvm) } // bool function NSIsModRequiredOnClient(string modName) -SQRESULT SQ_IsModRequiredOnClient(void* sqvm) +SQRESULT SQ_IsModRequiredOnClient(HSquirrelVM* sqvm) { - const SQChar* modName = ClientSq_getstring(sqvm, 1); + const SQChar* modName = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 1); // manual lookup, not super performant but eh not a big deal - for (Mod& mod : g_ModManager->m_loadedMods) + for (Mod& mod : g_pModManager->m_LoadedMods) { if (!mod.Name.compare(modName)) { - ClientSq_pushbool(sqvm, mod.RequiredOnClient); + g_pSquirrel<ScriptContext::UI>->pushbool(sqvm, mod.RequiredOnClient); return SQRESULT_NOTNULL; } } @@ -145,20 +144,20 @@ SQRESULT SQ_IsModRequiredOnClient(void* sqvm) } // array<string> function NSGetModConvarsByModName(string modName) -SQRESULT SQ_GetModConvars(void* sqvm) +SQRESULT SQ_GetModConvars(HSquirrelVM* sqvm) { - const SQChar* modName = ClientSq_getstring(sqvm, 1); - ClientSq_newarray(sqvm, 0); + const SQChar* modName = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 1); + g_pSquirrel<ScriptContext::UI>->newarray(sqvm, 0); // manual lookup, not super performant but eh not a big deal - for (Mod& mod : g_ModManager->m_loadedMods) + for (Mod& mod : g_pModManager->m_LoadedMods) { if (!mod.Name.compare(modName)) { for (ModConVar* cvar : mod.ConVars) { - ClientSq_pushstring(sqvm, cvar->Name.c_str(), -1); - ClientSq_arrayappend(sqvm, -2); + g_pSquirrel<ScriptContext::UI>->pushstring(sqvm, cvar->Name.c_str()); + g_pSquirrel<ScriptContext::UI>->arrayappend(sqvm, -2); } return SQRESULT_NOTNULL; @@ -169,35 +168,36 @@ SQRESULT SQ_GetModConvars(void* sqvm) } // void function NSReloadMods() -SQRESULT SQ_ReloadMods(void* sqvm) +SQRESULT SQ_ReloadMods(HSquirrelVM* sqvm) { - g_ModManager->LoadMods(); + g_pModManager->LoadMods(); return SQRESULT_NULL; } -void InitialiseScriptModMenu(HMODULE baseAddress) +ON_DLL_LOAD_CLIENT_RELIESON("client.dll", ScriptModMenu, ClientSquirrel, (CModule module)) { - g_UISquirrelManager->AddFuncRegistration("array<string>", "NSGetModNames", "", "Returns the names of all loaded mods", SQ_GetModNames); - g_UISquirrelManager->AddFuncRegistration( + g_pSquirrel<ScriptContext::UI>->AddFuncRegistration( + "array<string>", "NSGetModNames", "", "Returns the names of all loaded mods", SQ_GetModNames); + g_pSquirrel<ScriptContext::UI>->AddFuncRegistration( "bool", "NSIsModEnabled", "string modName", "Returns whether a given mod is enabled", SQ_IsModEnabled); - g_UISquirrelManager->AddFuncRegistration( + g_pSquirrel<ScriptContext::UI>->AddFuncRegistration( "void", "NSSetModEnabled", "string modName, bool enabled", "Sets whether a given mod is enabled", SQ_SetModEnabled); - g_UISquirrelManager->AddFuncRegistration( + g_pSquirrel<ScriptContext::UI>->AddFuncRegistration( "string", "NSGetModDescriptionByModName", "string modName", "Returns a given mod's description", SQ_GetModDescription); - g_UISquirrelManager->AddFuncRegistration( + g_pSquirrel<ScriptContext::UI>->AddFuncRegistration( "string", "NSGetModVersionByModName", "string modName", "Returns a given mod's version", SQ_GetModVersion); - g_UISquirrelManager->AddFuncRegistration( + g_pSquirrel<ScriptContext::UI>->AddFuncRegistration( "string", "NSGetModDownloadLinkByModName", "string modName", "Returns a given mod's download link", SQ_GetModDownloadLink); - g_UISquirrelManager->AddFuncRegistration( + g_pSquirrel<ScriptContext::UI>->AddFuncRegistration( "bool", "NSIsModRequiredOnClient", "string modName", "Returns whether a given mod is required on connecting clients", SQ_IsModRequiredOnClient); - g_UISquirrelManager->AddFuncRegistration( + g_pSquirrel<ScriptContext::UI>->AddFuncRegistration( "int", "NSGetModLoadPriority", "string modName", "Returns a given mod's load priority", SQ_GetModLoadPriority); - g_UISquirrelManager->AddFuncRegistration( + g_pSquirrel<ScriptContext::UI>->AddFuncRegistration( "array<string>", "NSGetModConvarsByModName", "string modName", "Returns the names of all a given mod's cvars", SQ_GetModConvars); - g_UISquirrelManager->AddFuncRegistration("void", "NSReloadMods", "", "Reloads mods", SQ_ReloadMods); + g_pSquirrel<ScriptContext::UI>->AddFuncRegistration("void", "NSReloadMods", "", "Reloads mods", SQ_ReloadMods); } |