Example #1
0
        private static int Initialize()
        {
            AppDomain curDomain = AppDomain.CurrentDomain;

            Fixes.UnhandledException.Install(curDomain);
            MelonUtils.Setup(curDomain);
            Assertions.LemonAssertMapping.Setup();

            if (!MonoLibrary.Setup() ||
                !MonoResolveManager.Setup())
            {
                return(1);
            }

            HarmonyInstance = new HarmonyLib.Harmony(BuildInfo.Name);

            Fixes.ForcedCultureInfo.Install();
            Fixes.InstancePatchFix.Install();
            Fixes.ProcessFix.Install();
            PatchShield.Install();

            MelonPreferences.Load();
            MelonLaunchOptions.Load();
            bHaptics.Load();

            MelonCompatibilityLayer.Setup();
            MelonCompatibilityLayer.SetupModules(MelonCompatibilityLayer.SetupType.OnPreInitialization);

            MelonHandler.LoadPlugins();
            MelonHandler.OnPreInitialization();

            return(0);
        }
Example #2
0
 public void SaveToFile(bool printmsg = true)
 {
     Preferences.IO.File currentfile = File;
     if (currentfile == null)
     {
         currentfile = MelonPreferences.DefaultFile;
     }
     foreach (MelonPreferences_Entry entry in Entries)
     {
         if (!(entry.DontSaveDefault && entry.GetValueAsString() == entry.GetDefaultValueAsString()) && entry.GetValueAsString() != null)
         {
             currentfile.InsertIntoDocument(Identifier, entry.Identifier, entry.Save());
         }
     }
     try
     {
         currentfile.Save();
     }
     catch (Exception ex)
     {
         MelonLogger.Error($"Error while Saving Preferences to {currentfile.FilePath}: {ex}");
         currentfile.WasError = true;
     }
     if (printmsg)
     {
         MelonLogger.Msg($"MelonPreferences Saved to {currentfile.FilePath}");
     }
     MelonHandler.OnPreferencesSaved();
 }
Example #3
0
        internal static int PreStart()
        {
            if (!MelonUtils.IsGameIl2Cpp())
            {
                GameVersionHandler.Setup();
            }

            MelonHandler.OnApplicationEarlyStart();

            if (MelonUtils.IsGameIl2Cpp())
            {
                if (MelonLaunchOptions.Core.EnableAssemblyGeneration)
                {
                    if (!Il2CppAssemblyGenerator.Run())
                    {
                        return(1);
                    }
                }

                HarmonyLib.Public.Patching.PatchManager.ResolvePatcher += HarmonyIl2CppMethodPatcher.TryResolve;

                GameVersionHandler.Setup();
            }

            return(0);
        }
Example #4
0
        internal static int Start()
        {
            if (!SupportModule.Initialize())
            {
                return(1);
            }

            AddUnityDebugLog();

            if (MelonLaunchOptions.Core.EnableBHapticsIntegration)
            {
                bHaptics.Start();
            }

            if (MelonLaunchOptions.Core.EnableCompatibilityLayers)
            {
                MelonCompatibilityLayer.SetupModules(MelonCompatibilityLayer.SetupType.OnApplicationStart);
            }

            MelonHandler.OnApplicationStart_Plugins();
            MelonHandler.LoadMods();
            MelonHandler.OnApplicationStart_Mods();

            MelonHandler.OnApplicationLateStart_Plugins();
            MelonHandler.OnApplicationLateStart_Mods();

            return(0);
        }
Example #5
0
        internal static void OnApplicationLateStart()
        {
            MelonHandler.OnApplicationLateStart_Plugins();
            MelonHandler.OnApplicationLateStart_Mods();

            MelonStartScreen.Finish();
        }
Example #6
0
        private static int Initialize()
        {
            Il2CppAssemblyGenerator.Load();
            bHaptics.Load();

            MelonHandler.LoadPlugins();
            MelonHandler.OnPreInitialization();

            return(0);
        }
Example #7
0
        private static int PreStart()
        {
            if (!MelonUtils.IsGameIl2Cpp())
            {
                GameVersionHandler.Setup();
            }

            MelonHandler.OnApplicationEarlyStart();

            return(MelonStartScreen.LoadAndRun(Il2CppGameSetup));
        }
Example #8
0
        internal static void Quit()
        {
            MelonHandler.OnApplicationQuit();
            MelonPreferences.Save();

            HarmonyInstance.UnpatchAll();
            bHaptics.Quit();

            MelonLogger.Flush();
            Fixes.QuitFix.Run();
        }
Example #9
0
 internal static void Quit()
 {
     MelonHandler.OnApplicationQuit();
     try { MelonPreferences.Save(); } catch (Exception ex) { MelonLogger.Error("MelonPreferences.Save Exception: " + ex.ToString()); MelonPreferences.WasError = true; }
     Harmony.HarmonyInstance.UnpatchAllInstances();
     try { bHaptics.Quit(); } catch (Exception ex) { MelonLogger.Error("bHaptics.Quit Exception: " + ex.ToString()); bHaptics.WasError = true; }
     MelonLogger.Flush();
     if (QuitFix())
     {
         System.Diagnostics.Process.GetCurrentProcess().Kill();
     }
 }
Example #10
0
 public static void SaveConfig()
 {
     foreach (KeyValuePair <string, Dictionary <string, MelonPreference> > prefsInSection in prefs)
     {
         foreach (KeyValuePair <string, MelonPreference> pref in prefsInSection.Value)
         {
             pref.Value.Value = pref.Value.ValueEdited;
             ConfigFile.SetString(prefsInSection.Key, pref.Key, pref.Value.Value);
         }
     }
     MelonHandler.OnModSettingsApplied();
     MelonLogger.Log("Config Saved!");
 }
Example #11
0
 private static void Start()
 {
     if (!SupportModule.Initialize())
     {
         return;
     }
     AddUnityDebugLog();
     try { bHaptics.Start(); } catch (Exception ex) { MelonLogger.Error("bHaptics.Start Exception: " + ex.ToString()); bHaptics.WasError = true; }
     MelonHandler.OnApplicationStart_Plugins();
     MelonHandler.LoadMods();
     Main.LegacySupport();
     MelonHandler.OnApplicationStart_Mods();
 }
Example #12
0
        internal static void Quit()
        {
            MelonHandler.OnApplicationQuit();
            MelonPreferences.Save();

            HarmonyInstance.UnpatchAll();

            if (MelonLaunchOptions.Core.EnableBHapticsIntegration)
            {
                bHaptics.Quit();
            }

            Fixes.QuitFix.Run();
        }
Example #13
0
        internal static void Quit()
        {
            MelonHandler.OnApplicationQuit();
            MelonPreferences.Save();

            HarmonyInstance.UnpatchSelf();
            bHaptics.Quit();

            MelonLogger.Flush();

            if (MelonLaunchOptions.Core.QuitFix)
            {
                Process.GetCurrentProcess().Kill();
            }
        }
Example #14
0
        internal static int Initialize(ConfigFile configFile)
        {
            AppDomain curDomain = AppDomain.CurrentDomain;

            HarmonyInstance = new HarmonyLib.Harmony(BuildInfo.Name);

            if (MelonLaunchOptions.Core.EnableFixes)
            {
                Fixes.UnhandledException.Run(curDomain);
                Fixes.InvariantCurrentCulture.Install();
            }

            try { MelonUtils.Setup(); } catch (Exception ex) { MelonLogger.Error($"MelonUtils.Setup Exception: {ex}"); throw; }

            if (MelonLaunchOptions.Core.EnableFixes)
            {
                Fixes.ApplicationBase.Run(curDomain);
                Fixes.ExtraCleanup.Run();
            }

            MelonPreferences.Load();
            MelonLaunchOptions.Load(configFile);

            if (MelonLaunchOptions.Core.EnableCompatibilityLayers)
            {
                MelonCompatibilityLayer.Setup();
            }

            if (MelonLaunchOptions.Core.EnablePatchShield)
            {
                PatchShield.Install();
            }

            if (MelonLaunchOptions.Core.EnableBHapticsIntegration)
            {
                bHaptics.Load();
            }

            if (MelonLaunchOptions.Core.EnableCompatibilityLayers)
            {
                MelonCompatibilityLayer.SetupModules(MelonCompatibilityLayer.SetupType.OnPreInitialization);
            }

            MelonHandler.LoadPlugins();
            MelonHandler.OnPreInitialization();

            return(0);
        }
Example #15
0
        private static int PreStart()
        {
            MelonHandler.OnApplicationEarlyStart();

            if (!Il2CppAssemblyGenerator.Run())
            {
                return(1);
            }

            if (MelonUtils.IsGameIl2Cpp())
            {
                HarmonyLib.Public.Patching.PatchManager.ResolvePatcher += HarmonyIl2CppMethodPatcher.TryResolve;
            }

            return(0);
        }
Example #16
0
        private static int Start()
        {
            if (!SupportModule.Setup())
            {
                return(1);
            }

            AddUnityDebugLog();
            bHaptics.Start();

            MelonCompatibilityLayer.SetupModules(MelonCompatibilityLayer.SetupType.OnApplicationStart);
            MelonHandler.OnApplicationStart_Plugins();
            MelonHandler.LoadMods();
            MelonStartScreen.DisplayModLoadIssuesIfNeeded();

            MelonHandler.OnApplicationStart_Mods();

            return(0);
        }
Example #17
0
        private static int Start()
        {
            if (!SupportModule.Initialize())
            {
                return(1);
            }

            AddUnityDebugLog();
            bHaptics.Start();

            MelonHandler.OnApplicationStart_Plugins();

            MelonHandler.LoadMods();
            MelonHandler.OnApplicationStart_Mods();

            MelonHandler.OnApplicationLateStart_Plugins();
            MelonHandler.OnApplicationLateStart_Mods();

            return(0);
        }
Example #18
0
        private static int Start()
        {
            bHaptics.Start();

            MelonHandler.OnApplicationStart_Plugins();
            MelonHandler.LoadMods();
            MelonHandler.OnPreSupportModule();

            if (!SupportModule.Setup())
            {
                return(1);
            }

            if (MelonUtils.IsGameIl2Cpp())
            {
                HarmonyLib.Public.Patching.PatchManager.ResolvePatcher += HarmonyIl2CppMethodPatcher.TryResolve;
            }
            MelonCompatibilityLayer.SetupModules(MelonCompatibilityLayer.SetupType.OnApplicationStart);
            AddUnityDebugLog();
            MelonHandler.OnApplicationStart_Mods();
            //MelonStartScreen.DisplayModLoadIssuesIfNeeded();

            return(0);
        }
Example #19
0
 private static int PreStart()
 {
     MelonHandler.OnApplicationEarlyStart();
     return(MelonStartScreen.LoadAndRun(Il2CppGameSetup));
 }
Example #20
0
 private static void Initialize()
 {
     MelonHandler.LoadPlugins();
     Main.LegacySupport();
     MelonHandler.OnPreInitialization();
 }
Example #21
0
 public void VRChat_OnUiManagerInit() => MelonHandler.VRChat_OnUiManagerInit();
 public void OnSceneWasUnloaded(int buildIndex, string sceneName) => MelonHandler.OnSceneWasUnloaded(buildIndex, sceneName);
 public void OnSceneWasInitialized(int buildIndex, string sceneName) => MelonHandler.OnSceneWasInitialized(buildIndex, sceneName);
 public void BONEWORKS_OnLoadingScreen() => MelonHandler.BONEWORKS_OnLoadingScreen();
 public void OnGUI() => MelonHandler.OnGUI();
 public void LateUpdate() => MelonHandler.OnLateUpdate();
 public void FixedUpdate() => MelonHandler.OnFixedUpdate();
 public void Update() => MelonHandler.OnUpdate();