Esempio n. 1
0
        public void SetVersion(string dependency, string constraint)
        {
            if (dependency == null)
            {
                throw new ArgumentNullException(nameof(dependency));
            }
            if (!(constraint != string.Empty))
            {
                throw new ArgumentOutOfRangeException("constraint != string.Empty");
            }
            // TODO: What about deeper check; is this really a version denotation, etc..

            dependency = dependency.ToLower();
            lock (Versions) {
                if (constraint == null)
                {
                    if (Versions.ContainsKey(dependency))
                    {
                        Versions.Remove(dependency);
                    }
                    return;
                }
                Versions[dependency] = constraint;
            }
        }
Esempio n. 2
0
        public Dependency GetDesiredModVersion(ToggleableModProxy mod)
        {
            var name = mod.GetSerializationString().ToLower();

            return(Versions.ContainsKey(name)
                ? new Dependency(name, Versions[name])
                : new GlobalDependency(name));
        }
Esempio n. 3
0
        public System.Uri VersionUri(uint version_id)
        {
            if (!Versions.ContainsKey(version_id))
            {
                return(null);
            }

            PhotoVersion v = Versions [version_id];

            if (v != null)
            {
                return(v.Uri);
            }

            return(null);
        }
Esempio n. 4
0
        public void DeleteVersion(uint version_id, bool remove_original, bool keep_file)
        {
            if (version_id == OriginalVersionId && !remove_original)
            {
                throw new Exception("Cannot delete original version");
            }

            System.Uri uri = VersionUri(version_id);

            if (!keep_file)
            {
                if ((new Gnome.Vfs.Uri(uri.ToString())).Exists)
                {
                    if ((new Gnome.Vfs.Uri(uri.ToString()).Unlink()) != Result.Ok)
                    {
                        throw new System.UnauthorizedAccessException();
                    }
                }

                try {
                    string thumb_path = ThumbnailGenerator.ThumbnailPath(uri);
                    System.IO.File.Delete(thumb_path);
                } catch (System.Exception) {
                    //ignore an error here we don't really care.
                }
                PhotoStore.DeleteThumbnail(uri);
            }
            Versions.Remove(version_id);

            changes.RemoveVersion(version_id);

            do
            {
                version_id--;
                if (Versions.ContainsKey(version_id))
                {
                    DefaultVersionId = version_id;
                    break;
                }
            } while (version_id > OriginalVersionId);
        }
        static void Main(string[] args)
        {
            Console.WriteLine($"Modfall installer v{Ver}");
            InstallerPath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "-h":
                    DisplayHelp();
                    break;

                case "-exe":
                    i++;
                    if (i < args.Length)
                    {
                        ExePath = args[i];
                        Console.WriteLine($"Path to exe file: {ExePath}");
                    }
                    else
                    {
                        Console.WriteLine("The -exe parameter doesn't have a path specified. Usage: -exe \"path/to/towerfall.exe\"");
                    }
                    break;

                case "-v":
                    i++;
                    TargetVersion = args[i];
                    break;
                }
            }
            if (ExePath == "")
            {
                Console.WriteLine("Please provide the full path to the TowerFall.exe you want to mod.");
                ExePath = Console.ReadLine().Trim('"');
            }
            if (ExePath != "")
            {
                //DownloadNewestVersion();
                GetVersionList();
                PrintVersionList();
                if (TargetVersion == "")
                {
                    Console.WriteLine("Which version do you want to download? Newest is recommended. Type 'n' to get the newest version.");
getVersion:
                    string input = Console.ReadLine().Trim();
                    if (input.Trim('\'') == "n")
                    {
                        TargetVersion = Versions.Keys.ToArray()[0];
                    }
                    else if (Versions.ContainsKey(input))
                    {
                        TargetVersion = input;
                    }
                    else
                    {
                        goto getVersion;
                    }
                }
                else if (TargetVersion == "n")
                {
                    TargetVersion = Versions.Keys.ToArray()[0];
                }

                try
                {
                    tempPath = Path.Combine(InstallerPath, "Temp");
                    DownloadVersion(Versions[TargetVersion], "");
                    ExeFileName = Path.GetFileName(ExePath);
                    string origPath          = Path.Combine(Path.GetDirectoryName(ExePath), "orig");
                    string backupExeFileName = Path.Combine(origPath, ExeFileName);
                    Console.WriteLine($"Backing up .exe file to {backupExeFileName}");
                    if (!Directory.Exists(origPath))
                    {
                        Directory.CreateDirectory(origPath);
                    }
                    File.Copy(ExePath, backupExeFileName, true);
                    string newExeFileName = Path.Combine(tempPath, ExeFileName);
                    Console.WriteLine($"Copying {ExePath} to {newExeFileName}");
                    File.Copy(ExePath, newExeFileName, true);
                    RunMonomod();
                    foreach (string file in Directory.GetFiles(tempPath))
                    {
                        string dest = Path.Combine(Path.GetDirectoryName(ExePath), Path.GetFileName(file));
                        File.Copy(file, dest, true);
                    }

                    /*
                     * string source = Path.Combine(tempPath, $"MMHOOK_{Path.GetFileNameWithoutExtension(ExeFileName)}.dll");
                     * string dest = Path.Combine(Path.GetDirectoryName(ExePath), $"MMHOOK_{Path.GetFileNameWithoutExtension(ExeFileName)}.dll");
                     * Console.WriteLine($"Copying {source} to {dest}");
                     * File.Copy(source, dest, true);
                     *
                     * source = Path.Combine(tempPath, $"MONOMODDED_{ExeFileName}");
                     * dest = Path.Combine(Path.GetDirectoryName(ExePath), $"MONOMODDED_{ExeFileName}");
                     * Console.WriteLine($"Copying {source} to {dest}");
                     * File.Copy(source, dest, true);
                     * source = Path.Combine(tempPath, $"Modfall.CmdInstaller.exe");
                     * if (File.Exists(source))
                     * {
                     *  dest = Path.Combine(Path.GetDirectoryName(ExePath), "Modfall.CmdInstaller.exe");
                     *  File.Copy(source, dest, true);
                     * } */


                    Console.WriteLine("Clearing Temp folder...");
                    foreach (string f in Directory.GetFiles(tempPath))
                    {
                        File.Delete(f);
                    }
                    Console.WriteLine($"\nModfall version {TargetVersion} installed!\nPress any key to continue...");
                    Console.ReadLine();
                } catch (Exception e)
                {
                    Console.WriteLine($"{e.Message}: \n{e.StackTrace}");
                    Console.ReadLine();
                }
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine($"This file is only meant to be used from within Modfall.");
                return;
            }
            Console.WriteLine($"Modfall Updater");
            InstallerPath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "-h":
                    DisplayHelp();
                    break;

                case "-exe":
                    i++;
                    if (i < args.Length)
                    {
                        ExePath = args[i];
                        Console.WriteLine($"Path to exe file: {ExePath}");
                    }
                    else
                    {
                        Console.WriteLine("The -exe parameter doesn't have a path specified. Usage: -exe \"path/to/towerfall.exe\"");
                    }
                    break;

                case "-v":
                    i++;
                    TargetVersion = args[i];
                    break;

                case "-mod":
                    Thread.Sleep(2000);
                    i++;
                    ModDownloadUrl = args[i];
                    i++;
                    string oldModDir = args[i].Trim('"');
                    Console.WriteLine($"Deleting {oldModDir}...");
Delete:
                    try
                    {
                        Directory.Delete(oldModDir, true);
                    }
                    catch
                    {
                        // Some files were still locked, try again later
                        Console.WriteLine("Couldn't delete some files, trying again in 1 second...");
                        Thread.Sleep(1000);
                        goto Delete;
                    }

                    Console.WriteLine($"Downloading from {ModDownloadUrl}");
                    ExecuteCommandSilent($"curl -L -o mod.zip {ModDownloadUrl}");
                    Console.WriteLine("Unzipping...");
                    ZipFile file = ZipFile.Read(Path.Combine(InstallerPath, $"mod.zip"));
                    file.ExtractAll(oldModDir);
                    file.Dispose();
                    Console.WriteLine("Deleting zip...");
                    File.Delete(Path.Combine(InstallerPath, $"mod.zip"));
                    Console.WriteLine("Reopening the game...");
                    Process.Start(Path.Combine(InstallerPath, $"MONOMODDED_TowerFall.exe"));
                    return;
                }
            }
            if (ExePath == "")
            {
                Console.WriteLine("Please provide the full path to the TowerFall.exe you want to mod.");
                ExePath = Console.ReadLine().Trim('"');
            }
            if (ExePath != "")
            {
                //DownloadNewestVersion();
                GetVersionList();
                PrintVersionList();
                if (TargetVersion == "")
                {
                    Console.WriteLine("Which version do you want to download? Newest is recommended. Type 'n' to get the newest version.");
getVersion:
                    string input = Console.ReadLine().Trim();
                    if (input.Trim('\'') == "n")
                    {
                        TargetVersion = Versions.Keys.ToArray()[0];
                    }
                    else if (Versions.ContainsKey(input))
                    {
                        TargetVersion = input;
                    }
                    else
                    {
                        goto getVersion;
                    }
                }
                else if (TargetVersion == "n")
                {
                    TargetVersion = Versions.Keys.ToArray()[0];
                }

                try
                {
                    tempPath = Path.Combine(InstallerPath, "Temp");
                    DownloadVersion(Versions[TargetVersion], "");
                    ExeFileName = Path.GetFileName(ExePath);
                    string origPath          = Path.Combine(Path.GetDirectoryName(ExePath), "orig");
                    string backupExeFileName = Path.Combine(origPath, ExeFileName);
                    Console.WriteLine($"Backing up .exe file to {backupExeFileName}");
                    if (!Directory.Exists(origPath))
                    {
                        Directory.CreateDirectory(origPath);
                    }
                    File.Copy(ExePath, backupExeFileName, true);
                    string newExeFileName = Path.Combine(tempPath, ExeFileName);
                    Console.WriteLine($"Copying {ExePath} to {newExeFileName}");
                    File.Copy(ExePath, newExeFileName, true);
                    RunMonomod();
                    string source = Path.Combine(tempPath, $"MMHOOK_{Path.GetFileNameWithoutExtension(ExeFileName)}.dll");
                    string dest   = Path.Combine(Path.GetDirectoryName(ExePath), $"MMHOOK_{Path.GetFileNameWithoutExtension(ExeFileName)}.dll");
                    Console.WriteLine($"Copying {source} to {dest}");
                    File.Copy(source, dest, true);
                    source = Path.Combine(tempPath, $"MONOMODDED_{ExeFileName}");
                    dest   = Path.Combine(Path.GetDirectoryName(ExePath), $"MONOMODDED_{ExeFileName}");
                    Console.WriteLine($"Copying {source} to {dest}");
                    File.Copy(source, dest, true);
                    //source = Path.Combine(tempPath, "Modfall.CmdInstaller.exe");
                    //if (File.Exists(source))
                    //{
                    //    dest = Path.Combine(Path.GetDirectoryName(ExePath), "Modfall.CmdInstaller.exe");
                    //    File.Copy(source, dest, true);
                    //}
                    Console.WriteLine("Clearing Temp folder...");
                    foreach (string f in Directory.GetFiles(tempPath))
                    {
                        File.Delete(f);
                    }
                    Console.WriteLine($"\nModfall version {TargetVersion} installed!\nReopening the game...");
                    Process.Start(Path.Combine(Path.GetDirectoryName(ExePath), $"MONOMODDED_{ExeFileName}"));
                }
                catch (Exception e)
                {
                    Console.WriteLine($"{e.Message}: \n{e.StackTrace}");
                    Console.ReadLine();
                }
            }
        }