From 15c319e85b93d90b79011ce8188ed24c302605a6 Mon Sep 17 00:00:00 2001 From: Leidtier Date: Sun, 18 Aug 2024 13:00:00 +0200 Subject: [PATCH] Added `Restart Mantella.exe` MCM entry --- Scripts/Source/MantellaMCM.psc | 1 + .../Source/MantellaMCM_AdvancedSettings.psc | 4 ++++ Scripts/Source/MantellaRepository.psc | 18 +++++++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Scripts/Source/MantellaMCM.psc b/Scripts/Source/MantellaMCM.psc index 9556ed5..ff4a506 100644 --- a/Scripts/Source/MantellaMCM.psc +++ b/Scripts/Source/MantellaMCM.psc @@ -89,6 +89,7 @@ int property oid_NPCAngerToggle auto ;gia int property oid_NPCPackageToggle auto int property oid_debugNPCSelectMode auto +int property oid_restartMantellaExe Auto int property oid_httpPort auto string property PAGE_GENERAL = "General" auto diff --git a/Scripts/Source/MantellaMCM_AdvancedSettings.psc b/Scripts/Source/MantellaMCM_AdvancedSettings.psc index 645f3d6..a9d13d5 100644 --- a/Scripts/Source/MantellaMCM_AdvancedSettings.psc +++ b/Scripts/Source/MantellaMCM_AdvancedSettings.psc @@ -9,6 +9,7 @@ endfunction function LeftColumn(MantellaMCM mcm, MantellaRepository Repository) global mcm.AddHeaderOption("Debug") + mcm.oid_restartMantellaExe = mcm.AddTextOption("Restart Mantella.exe", "") mcm.oid_debugNPCselectMode = mcm.AddToggleOption("NPC Debug Select Mode", Repository.NPCdebugSelectModeEnabled) endfunction @@ -53,5 +54,8 @@ function OptionUpdate(MantellaMCM mcm, int optionID, MantellaRepository Reposito if optionID == mcm.oid_debugNPCselectMode Repository.NPCdebugSelectModeEnabled =! Repository.NPCdebugSelectModeEnabled mcm.SetToggleOptionValue(mcm.oid_debugNPCselectMode, Repository.NPCdebugSelectModeEnabled) + elseif optionID == mcm.oid_restartMantellaExe + Repository.restartMantellaExe() + Debug.MessageBox("Restarting Mantella.exe... This can take a moment.") endIf endfunction diff --git a/Scripts/Source/MantellaRepository.psc b/Scripts/Source/MantellaRepository.psc index 478b52a..3d3acac 100644 --- a/Scripts/Source/MantellaRepository.psc +++ b/Scripts/Source/MantellaRepository.psc @@ -98,7 +98,7 @@ bool property NPCPackage auto Conditional bool property NPCDialogue auto ;gia bool property NPCdebugSelectModeEnabled auto - +; bool restartMantellaExe = False int property HttpPort auto @@ -106,6 +106,13 @@ event OnInit() assignDefaultSettings(0, true) endEvent +; event OnUpdate() +; If (restartMantellaExe) +; restartMantellaExe = false +; MantellaLauncher.LaunchMantellaExe() +; EndIf +; endEvent + ; lastVersion is the previous MCM version number defined in 'MantellaMCM.psc' before the new update is applied. ; Whenever a new repository value OR a new MCM setting is added, up the MCM version number returned by `ManatellaMCM.GetVersion()` ; and add the corresponding default value here in a block corresponding to the version number like the examples below @@ -244,6 +251,15 @@ bool Function IsVR() return Debug.GetVersionNumber() == "1.4.15.0" EndFunction +bool function restartMantellaExe() + ; restartMantellaExe = true + ; RegisterForSingleUpdate(1) + MantellaLauncher.LaunchMantellaExe() + ;Note: If you need to debug this call to the SKSE plugin, you need to call it from the commented out single update above instead + ; or the VS debugger will crash (due to being called from the MCM thread?). + ; Check the corresponding commented out OnUpdate at the beginning of the script. +EndFunction + Event OnKeyDown(int KeyCode) ;this function was previously in MantellaListener Script back in Mantella 0.9.2 ;this ensures the right key is pressed and only activated while not in menu mode