コード例 #1
0
        private static void Install_(this InstallerWindow ins)
        {
            ins.Invoke(() => ins.LogBox.Visible = true).SetMainEnabled(false);

            Directory.SetCurrentDirectory(ins.ExeMod.Dir.FullName);

            ins.Log("FEZ ").LogLine(ins.FezVersion);

            //Clean FEZ from any previous FEZMod installation
            ins.Uninstall();

            ins.Backup("Common.dll");
            ins.Backup("EasyStorage.dll");
            int v = int.Parse(ins.FezVersion.Substring(2));

            if (12 <= v)
            {
                ins.Backup("FNA.dll");
            }
            else
            {
                ins.Backup("MonoGame.Framework.dll");
            }
            ins.Backup("FezEngine.dll");
            ins.Backup("FEZ.exe");

            //Setup the files and MonoMod instances
            if (ins.VersionTabs.SelectedIndex == 0)
            {
                Tuple <string, string> t = ins.StableVersions[ins.StableVersionList.SelectedIndex];
                ins.Log("FEZMod Stable ").LogLine(t.Item1);
                if (!ins.UnzipMod(ins.DownloadCached(t.Item2, "stable" + t.Item1 + ".zip")))
                {
                    return;
                }
            }
            else if (ins.VersionTabs.SelectedIndex == 1)
            {
                Tuple <string, string> t = ins.NightlyVersions[ins.NightlyVersionList.SelectedIndex];
                ins.Log("FEZMod Nightly ").LogLine(t.Item1);
                if (!ins.UnzipMod(ins.DownloadCached(t.Item2, "devbuild" + t.Item1 + ".zip")))
                {
                    return;
                }
            }
            else if (ins.VersionTabs.SelectedIndex == 2)
            {
                string path = ins.ManualPathBox.Text;

                if (path.ToLower().EndsWith(".zip"))
                {
                    ins.LogLine("FEZMod Manual ZIP");
                    if (!ins.UnzipMod(File.OpenRead(path)))
                    {
                        return;
                    }
                }
                else
                {
                    ins.LogLine("FEZMod Manual Folder");

                    string   pathFez = ins.ExeMod.Dir.FullName;
                    string[] files   = Directory.GetFiles(path);
                    ins.InitProgress("Copying FEZMod", files.Length);
                    for (int i = 0; i < files.Length; i++)
                    {
                        string file = Path.GetFileName(files[i]);
                        if (!file.Contains(".mm."))
                        {
                            ins.SetProgress("Skipping: " + file, i);
                            continue;
                        }
                        ins.Log("Copying: ").LogLine(file);
                        ins.SetProgress("Copying: " + file, i);
                        string origPath = Path.Combine(pathFez, file);
                        File.Copy(files[i], origPath, true);
                    }
                    ins.EndProgress("Copying FEZMod complete.");
                }
            }

            if (Blacklist.Count != 0)
            {
                ins.LogLine();
                ins.Log(Blacklist.Count.ToString()).LogLine(" mods on the blacklist - removing them!");
                for (int i = 0; i < Blacklist.Count; i++)
                {
                    string blacklisted     = Blacklist[i];
                    string pathFez         = ins.ExeMod.Dir.FullName;
                    string blacklistedPath = Path.Combine(pathFez, blacklisted);
                    ins.Log(blacklisted).Log(" blacklisted - ");
                    if (!File.Exists(blacklistedPath))
                    {
                        ins.LogLine("Not found though.");
                        continue;
                    }
                    ins.LogLine("BURN THE WITCH!");
                    File.Delete(blacklistedPath);
                }
                ins.LogLine();
            }

            LogPath = Path.Combine(ins.ExeMod.Dir.FullName, "FEZModInstallLog.txt");
            if (File.Exists(LogPath))
            {
                File.Delete(LogPath);
            }

            ins.LogLine();
            ins.LogLine("Now comes the real \"modding\" / patching process.");
            ins.LogLine("It may seem like the Installer may be stuck sometimes. Go make");
            ins.LogLine("yourself a coffee in the meantime - it doesn't get stuck.");
            ins.LogLine("It may *crash*, though - and in this case, debug stuff appears");
            ins.LogLine("here. Please put that debug stuff onto http://hastebin.com/ and");
            ins.LogLine("send it to @0x0ade on Twitter or FEZMod on GitHub.");
            ins.LogLine();

            ins.LogLine("Modding Common.dll").InitProgress("Modding Common.dll", 5);
            ins.LogLine("Common.dll is not that huge - not much to say here.");
            ins.LogLine();
            if (!ins.Mod("Common.dll"))
            {
                return;
            }

            ins.LogLine("Modding EasyStorage.dll").SetProgress("Modding EasyStorage.dll", 1);
            ins.LogLine("EasyStorage.dll also isn't huge - most probably Steam and Android stuff.");
            ins.LogLine();
            if (!ins.Mod("EasyStorage.dll"))
            {
                return;
            }

            if (12 <= v)
            {
                ins.LogLine("Modding FNA.dll").SetProgress("Modding FNA.dll", 2);
                ins.LogLine("Future versions may replace \"modding\" with replacing.");
                ins.LogLine("FNA is the \"framework\" below FEZ and powering some other games, too.");
                ins.LogLine("It replaces MonoGame in FEZ 1.12+.");
                ins.LogLine();
                if (!ins.Mod("FNA.dll"))
                {
                    return;
                }
            }
            else
            {
                ins.LogLine("Modding MonoGame.Framework.dll").SetProgress("Modding MonoGame.Framework.dll", 2);
                ins.LogLine("Wait... where's FNA? Well, I guess you're using old FEZ.");
                ins.LogLine();
                if (!ins.Mod("MonoGame.Framework.dll"))
                {
                    return;
                }
            }

            ins.LogLine("Modding FezEngine.dll").SetProgress("Modding FezEngine.dll", 3);
            ins.LogLine("The Trixel Engine also becomes the \"FEZMod Engine.\"");
            ins.LogLine("If something low-level happens, for example loading textures,");
            ins.LogLine("music, handling geometry, inter-mod-communication,... it's here.");
            ins.LogLine();
            if (!ins.Mod("FezEngine.dll"))
            {
                return;
            }

            ins.LogLine("Modding FEZ.exe").SetProgress("Modding FEZ.exe", 4);
            ins.LogLine("This process will take the longest of all.");
            ins.LogLine("You won't see anything happening here, but don't panic:");
            ins.LogLine("If the installer crashes, an error log appears here.");
            ins.LogLine();
            if (!ins.Mod())
            {
                return;
            }

            ins.EndProgress("Modding complete.");
            ins.LogLine("Back with the coffee? We're done! Look at the top-right!");
            ins.LogLine("You should see [just installed]. Feel free to start FEZ.");
            ins.LogLine("If FEZ crashes with FEZMod, go to the FEZ folder (that one");
            ins.LogLine("where FEZ.exe is, basically the path at the top-right),");
            ins.LogLine("upload JAFM Log.txt somewhere and give it @0x0ade.");
            ins.LogLine("Good luck - Have fun!");
            ins.ExeSelected(ins.ExeMod.In.FullName, " [just installed]");
            ins.SetMainEnabled(true);
        }