Example #1
0
        public void enableMod(LocalMod mod)
        {
            mod.enabled = true;
            this.updateConfig(mod);
            ScrollsFilter.clearHooks();
            String modLoaderPath           = Platform.getGlobalScrollsInstallPath() + "ModLoader" + System.IO.Path.DirectorySeparatorChar;
            TypeDefinitionCollection types = AssemblyFactory.GetAssembly(modLoaderPath + "Assembly-CSharp.dll").MainModule.Types;

            loader.loadModsStatic(types);
            loader.addPatchHooks();
            loader.loadMod(mod);
        }
Example #2
0
 public void disableMod(LocalMod mod, bool rebuild)
 {
     mod.enabled = false;
     this.updateConfig(mod);
     loader._unloadMod(mod);
     if (rebuild)
     {
         ScrollsFilter.clearHooks();
         String modLoaderPath           = Platform.getModLoaderPath() + System.IO.Path.DirectorySeparatorChar;
         TypeDefinitionCollection types = AssemblyFactory.GetAssembly(modLoaderPath + "Assembly-CSharp.dll").MainModule.Types;
         loader.loadModsStatic(types);
         loader.addPatchHooks();
     }
 }
Example #3
0
        public void PatchScrollsWindows()
        {
            String URL;

            if (Platform.getOS() == Platform.OS.Win)
            {
                URL = "http://download.scrolls.com/client/windows.zip";
            }
            else
            {
                URL = "http://download.scrolls.com/client/mac.zip";
            }

            String gameFolder = Path.GetFullPath(Directory.GetParent(Platform.getGlobalScrollsInstallPath()).Parent.Parent.Parent.FullName) + Path.DirectorySeparatorChar;

            //wait
            WebClientTimeOut webClient = new WebClientTimeOut();

            if (File.Exists(gameFolder + "game.zip"))
            {
                File.Delete(gameFolder + "game.zip");
            }
            try
            {
                webClient.DownloadFile(URL, gameFolder + "game.zip");
            }
            catch (WebException)
            {
                App.Popups.KillCurrentPopup();
                App.Popups.ShowOk(null, "info", "Error", "And error occured while downloading the update.", "OK");
                return;
            }

            //backup assembly
            String backupPath = gameFolder + "ScrollsModLoader.dll";

            if (File.Exists(backupPath))
            {
                File.Delete(backupPath);
            }
            File.Copy(Platform.getGlobalScrollsInstallPath() + "ScrollsModLoader.dll", backupPath);

            //backup modloader folder
            String modBackupPath = gameFolder + "ModLoader" + Path.DirectorySeparatorChar;

            if (Directory.Exists(modBackupPath))
            {
                Extensions.DeleteDirectory(modBackupPath);
            }
            Directory.Move(Platform.getGlobalScrollsInstallPath() + "ModLoader", modBackupPath);
            File.Delete(modBackupPath + "mods.ini");
            File.Delete(modBackupPath + "Assembly-CSharp.dll");

            if (Platform.getOS() == Platform.OS.Win)
            {
                Extensions.DeleteDirectory(gameFolder + "game");
            }
            else
            {
                Extensions.DeleteDirectory(gameFolder + "MacScrolls.app");
            }

            //extract
            ZipFile zip = ZipFile.Read(gameFolder + "game.zip");

            foreach (ZipEntry e in zip)
            {
                e.Extract(gameFolder + "game");
            }

            //move assembly
            File.Copy(backupPath, Platform.getGlobalScrollsInstallPath() + "ScrollsModLoader.dll");
            // File.Delete(backupPath);

            //move modloader folder back
            Directory.Move(modBackupPath, Platform.getGlobalScrollsInstallPath() + "ModLoader");

            //make new repatch backup
            File.Copy(Platform.getGlobalScrollsInstallPath() + "Assembly-CSharp.dll", Platform.getGlobalScrollsInstallPath() + "ModLoader" + Path.DirectorySeparatorChar + "Assembly-CSharp.dll");

            //make sure mods get hooks set with new version
            File.Delete(Platform.getGlobalScrollsInstallPath() + "ModLoader" + Path.DirectorySeparatorChar + "mods.ini");
            ScrollsFilter.clearHooks();
            Console.WriteLine("Cleared Hooks");

            //repatch
            Patcher patcher = new Patcher();

            if (!patcher.patchAssembly(Platform.getGlobalScrollsInstallPath()))
            {
                if (!patcher.safeModePatchAssembly())
                {
                    Dialogs.showNotification("Summoner patch failed", "Summoner failed in patch itself into the updated files. It will uninstall itself. For more informations visit scrollsguide.com/summoner");
                    File.Delete(Platform.getGlobalScrollsInstallPath() + "ScrollsModLoader.dll");
                    Extensions.DeleteDirectory(Platform.getGlobalScrollsInstallPath() + "ModLoader");
                }
            }

            Console.WriteLine("Now restarting the game...");

            //restart the game
            Platform.RestartGame();
        }