Exemple #1
0
        void Awake()
        {
            Debug.Log("No awake de mod loader");
            gameObject.AddComponent <ClientDebuggerSide>();
            DontDestroyOnLoad(gameObject);

            try
            {
                //MainMenuMods = new ModPriorityOrganizer();
                //GameSceneMods = new ModPriorityOrganizer();
                SpecificSceneMods = new Dictionary <int, ModPriorityOrganizer>();
                //AllScenesMods = new ModPriorityOrganizer();

                string dllExecutingPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                string modListFilePath  = DirectorySearchTools.GetFilePathInDirectory(ModListOWFileName, dllExecutingPath);

                ModFolderAndList list = new ModFolderAndList();
                ClassSerializer.ReadFromFile(modListFilePath, list);

                MOWAP[] mods = SearchMods.GetModsMOWAPS(dllExecutingPath, list);
                SeparateModsMethod(mods);
            }
            catch (Exception ex)
            { Debug.Log(string.Format("Something went wrong while loading the mods: {0}  - {1} - {2}", ex.Message, ex.Source, ex.StackTrace)); }
        }
Exemple #2
0
        private void SaveModsButton_Click(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < ModEnableElement.ModEnableElements.Count; i++)
                {
                    if (ModEnableElement.ModEnableElements[i].json.FileName != ModDataHandler.dimowaModLoaderFile)
                    {
                        if (ModEnableElement.ModEnableElements[i].IsEnabled && allEnabledMods.IndexOf(ModEnableElement.ModEnableElements[i].json.FileName) < 0)
                        {
                            allEnabledMods.Add(ModEnableElement.ModEnableElements[i].json.FileName);
                        }
                        else if (!ModEnableElement.ModEnableElements[i].IsEnabled && allEnabledMods.IndexOf(ModEnableElement.ModEnableElements[i].json.FileName) > -1)
                        {
                            allEnabledMods.Remove(ModEnableElement.ModEnableElements[i].json.FileName);
                        }
                    }
                }

                ModFolderAndList modList = new ModFolderAndList()
                {
                    ModList   = allEnabledMods.ToArray(),
                    ModFolder = Config.ModsFolder
                };
                ClassSerializer.WriteToFile(Path.Combine(DirectorySearchTools.GetDirectoryInDirectory("Managed", Config.GameFolder), ModDataHandler.loaderModOWFile), modList);
                if (ModEnableElement.ModEnableElements[0].IsEnabled) //Primeiro elemento é sempre do loader
                {                                                    //DIMOWALoaderInstaller.Install()/.Unistall() consomem bastante ram e cpu quanto chamados com o .Save() e continuam consumindo ele em seguida, parece ser algo relacionado com o tamanho do DLL (como se ele estivesse carregando todo ele para salvar mas não largando esse objeto)
                    ;
                    if (ModDataHandler.DIMOWALoaderInstaller.Install())
                    {
                        string[] filesToCopy = { ModDataHandler.ManifestDoLoader.FileName };
                        foreach (string s in filesToCopy)
                        {
                            string fullPath = Path.Combine(DirectorySearchTools.GetDirectoryInDirectory("Managed", Config.GameFolder), s);
                            if (!File.Exists(fullPath))
                            {
                                File.Copy(DirectorySearchTools.GetFilePathInDirectory(ModDataHandler.ManifestDoLoader.FileName, Config.ModsFolder, Config.GameFolder), fullPath);
                            }
                        }
                        ModDataHandler.DIMOWALoaderInstaller.SaveModifications();
                        ModDataHandler.DIMOWALoaderInstaller.ResetLoaderInstaller();

                        ConsoleWindowHelper.Log("DIMOWAModLoader has been successfully installed");
                        foreach (var element in ModEnableElement.ModEnableElements)
                        {
                            element.UnlockElement();
                        }
                    }
                }
                else
                {
                    if (ModDataHandler.DIMOWALoaderInstaller.Uninstall())
                    {
                        ModDataHandler.DIMOWALoaderInstaller.SaveModifications();
                        ModDataHandler.DIMOWALoaderInstaller.ResetLoaderInstaller();

                        string[] filesToDelete = { ModDataHandler.ManifestDoLoader.FileName, ModDataHandler.loaderModOWFile };
                        foreach (string s in filesToDelete)
                        {
                            string fullPath = Path.Combine(DirectorySearchTools.GetDirectoryInDirectory("Managed", Config.GameFolder), s);
                            if (File.Exists(fullPath))
                            {
                                File.Delete(fullPath);
                            }
                        }

                        ConsoleWindowHelper.Log("DIMOWAModLoader has been successfully uninstalled");
                        for (int i = 1; i < ModEnableElement.ModEnableElements.Count; i++)
                        {
                            ModEnableElement.ModEnableElements[i].LockElement(Color.Gray);
                        }
                    }
                }

                ConsoleWindowHelper.Log("All the changes have been performed and saved");
            }
            catch (Exception ex)
            {
                ConsoleWindowHelper.FatalException("A Fatal Exception occured while saving: " + ex.Message + " check the Console Windows for more information.");
                ConsoleWindowHelper.Exception(string.Format("{0}: {1} {2}\nInner Exception Message: {3}", ex.Source, ex.Message, ex.StackTrace, ex.InnerException));
            }
        }