Ejemplo n.º 1
0
        private void ButtonUpdateAurora_Click(object sender, EventArgs e)
        {
            try
            {
                var installation = new GameInstallation(_auroraVersionRegistry.CurrentAuroraVersion, Program.AuroraLoaderExecutableDirectory);
                var thread       = new Thread(() =>
                {
                    var aurora_files = Installer.GetLatestAuroraFiles();
                    Installer.UpdateAurora(installation, aurora_files);
                });
                thread.Start();

                var progress = new FormProgress(thread)
                {
                    Text = "Updating Aurora"
                };
                progress.ShowDialog();
                RefreshAuroraInstallData();
            }
            catch (Exception ecp)
            {
                Log.Error("Failed to update Aurora", ecp);
                Program.OpenBrowser(@"http://aurora2.pentarch.org/index.php?board=276.0");
            }
        }
Ejemplo n.º 2
0
        public static void UpdateAurora(GameInstallation current, Dictionary <string, string> aurora_files)
        {
            var update = SemVersion.Parse(aurora_files["Version"]);

            if (current.InstalledVersion.Version.Major == update.Major)
            {
                aurora_files.Remove("Major");

                if (current.InstalledVersion.Version.Minor == update.Minor)
                {
                    aurora_files.Remove("Minor");

                    if (current.InstalledVersion.Version.Patch == update.Patch)
                    {
                        aurora_files.Remove("Patch");
                        aurora_files.Remove("Rev"); // deprecated
                    }
                }
            }

            foreach (var piece in aurora_files.Keys.ToList())
            {
                if (!piece.Equals("Major") && !piece.Equals("Minor") && !piece.Equals("Patch") && !piece.Equals("Rev"))
                {
                    aurora_files.Remove(piece);
                }
            }

            if (aurora_files.Count > 0)
            {
                DownloadAuroraPieces(current.InstallationPath, aurora_files);
            }
        }
Ejemplo n.º 3
0
        private static void UninstallDbMods(GameInstallation installation, ModRegistry registry)
        {
            var installed = registry.Mods.Where(m => m.Installed && m.Type == ModType.DATABASE).ToList();

            using (var connection = new SQLiteConnection(GetConnectionString(installation)))
            {
                connection.Open();

                var sql     = "SELECT * FROM sqlite_master WHERE name ='A_THIS_SAVE_IS_MODDED' and type='table';";
                var command = new SQLiteCommand(sql, connection);
                var reader  = command.ExecuteReader();
                if (!reader.Read())
                {
                    reader.Close();
                    connection.Close();
                    return;
                }
                else
                {
                    reader.Close();
                }

                sql     = "SELECT * FROM A_THIS_SAVE_IS_MODDED";
                command = new SQLiteCommand(sql, connection);
                reader  = command.ExecuteReader();

                while (reader.Read())
                {
                    var name = reader[0].ToString();
                    var mod  = installed.FirstOrDefault(m => m.Name.Equals(name));

                    if (mod == null)
                    {
                        throw new Exception($"Installed db mod {name} not found");
                    }
                    else
                    {
                        var file = Path.Combine(mod.Installation.ModFolder, "uninstall.sql");
                        if (!File.Exists(file))
                        {
                            throw new Exception($"Db mod {name} uninstall.sql not found");
                        }

                        sql     = File.ReadAllText(file);
                        sql    += $"\nDELETE FROM A_THIS_SAVE_IS_MODDED\nWHERE ModName = '{name}';";
                        command = new SQLiteCommand(sql, connection);
                        command.ExecuteNonQuery();

                        Log.Debug($"Uninstalled db mod: {name}");
                    }
                }

                reader.Close();
                connection.Close();
            }
        }
Ejemplo n.º 4
0
        public static List <Process> Launch(GameInstallation installation, ModRegistry registry, IList <Mod> mods, Mod executableMod = null)
        {
            if (mods.Any(mod => mod.Type == ModType.EXE))
            {
                throw new Exception("Use the other parameter");
            }

            UninstallThemeMods(installation, registry);
            UninstallDbMods(installation, registry);

            var processes = new List <Process>();

            foreach (var mod in mods.Where(mod => mod.Type == ModType.THEME))
            {
                Log.Debug($"Theme: {mod.Name}");
                InstallThemeMod(mod, installation);
            }
            foreach (var mod in mods.Where(mod => mod.Type == ModType.ROOTUTILITY))
            {
                Log.Debug("Root Utility: " + mod.Name);
                CopyToFolder(mod, installation.InstallationPath);
                var process = Run(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), mod.Installation.ExecuteCommand);
                processes.Add(process);
            }
            foreach (var mod in mods.Where(mod => mod.Type == ModType.UTILITY))
            {
                Log.Debug("Utility: " + mod.Name);
                var process = Run(mod.Installation.ModFolder, mod.Installation.ExecuteCommand);
                processes.Add(process);
            }
            foreach (var mod in mods.Where(mod => mod.Type == ModType.DATABASE))
            {
                Log.Debug("Database: " + mod.Name);
                InstallDbMod(mod, installation);
            }

            if (executableMod != null)
            {
                CopyToFolder(executableMod, installation.InstallationPath);
                var process = Run(Program.AuroraLoaderExecutableDirectory, executableMod.Installation.ExecuteCommand);
                processes.Insert(0, process);
            }
            else
            {
                var process = Run(installation.InstallationPath, "Aurora.exe");
                processes.Insert(0, process);
            }

            return(processes);
        }
Ejemplo n.º 5
0
        private static void UninstallThemeMods(GameInstallation installation, ModRegistry registry)
        {
            var installed = registry.Mods.Where(m => m.Installed && m.Type == ModType.THEME).ToList();

            foreach (var mod in installed)
            {
                foreach (var file in Directory.EnumerateFiles(mod.Installation.ModFolder, "*.*", SearchOption.AllDirectories))
                {
                    var out_file = Path.Combine(installation.InstallationPath, Path.GetRelativePath(mod.Installation.ModFolder, file));
                    if (File.Exists(out_file))
                    {
                        File.Delete(out_file);
                    }
                }

                Log.Debug($"Uninstalled theme mod: {mod.Name}");
            }
        }
Ejemplo n.º 6
0
        private static void InstallAurora()
        {
            var installation = new GameInstallation(new AuroraVersion("0.0.0", ""), Program.AuroraLoaderExecutableDirectory);
            var thread       = new Thread(() =>
            {
                var aurora_files = Installer.GetLatestAuroraFiles();
                Installer.DownloadAuroraPieces(Program.AuroraLoaderExecutableDirectory, aurora_files);
            });

            thread.Start();

            var progress = new FormProgress(thread)
            {
                Text = "Installing Aurora"
            };

            progress.ShowDialog();
        }
Ejemplo n.º 7
0
        private static void InstallDbMod(Mod mod, GameInstallation installation)
        {
            const string TABLE = "CREATE TABLE IF NOT EXISTS A_THIS_SAVE_IS_MODDED (ModName Text PRIMARY KEY);";

            using (var connection = new SQLiteConnection(GetConnectionString(installation)))
            {
                connection.Open();
                var table = new SQLiteCommand(TABLE, connection);
                table.ExecuteNonQuery();

                var files = Directory.EnumerateFiles(mod.Installation.ModFolder, "*.sql").ToList();
                try
                {
                    var uninstall = files.Single(f => Path.GetFileName(f).Equals("uninstall.sql"));
                    files.Remove(uninstall);
                }
                catch (Exception)
                {
                    Log.Debug($"No uninstall for db mod: {mod.Name}");
                }

                foreach (var file in files)
                {
                    var sql     = File.ReadAllText(file);
                    var command = new SQLiteCommand(sql, connection);
                    command.ExecuteNonQuery();

                    sql = $"INSERT INTO A_THIS_SAVE_IS_MODDED(ModName)" +
                          $"SELECT '{mod.Name}'" +
                          $"WHERE NOT EXISTS(SELECT 1 FROM A_THIS_SAVE_IS_MODDED WHERE ModName = '{mod.Name}');";

                    command = new SQLiteCommand(sql, connection);
                    command.ExecuteNonQuery();

                    Log.Debug($"Installed db mod: {mod.Name}");
                }

                connection.Close();
            }
        }
Ejemplo n.º 8
0
        private void StartGame()
        {
            lock (this)
            {
                if (AuroraThread != null)
                {
                    MessageBox.Show("Already running Aurora.");
                    return;
                }
            }

            ButtonSinglePlayer.Enabled  = false;
            ButtonMultiPlayer.Enabled   = false;
            ButtonInstallAurora.Enabled = false;
            ButtonUpdateAurora.Enabled  = false;

            var mods = _modRegistry.Mods.Where(mod =>
                                               (ListDatabaseMods.CheckedItems != null && ListDatabaseMods.CheckedItems.Contains(mod.Name)) ||
                                               (ListUtilities.CheckedItems != null && ListUtilities.CheckedItems.Contains(mod.Name))).ToList();

            Mod executableMod;

            if (ComboSelectLaunchExe.SelectedItem != null && (string)ComboSelectLaunchExe.SelectedItem != "Base game")
            {
                executableMod = _modRegistry.Mods.Single(mod => mod.Name == (string)ComboSelectLaunchExe.SelectedItem);
            }
            else
            {
                executableMod = null;
            }
            var installation = new GameInstallation(_auroraVersionRegistry.CurrentAuroraVersion, Program.AuroraLoaderExecutableDirectory);
            var process      = Launcher.Launch(installation, _modRegistry, mods, executableMod)[0];

            AuroraThread = new Thread(() => RunGame(process))
            {
                IsBackground = true
            };

            AuroraThread.Start();
        }
Ejemplo n.º 9
0
        public static string GetConnectionString(GameInstallation installation)
        {
            var db = Path.Combine(installation.InstallationPath, "AuroraDB.db");

            return($"Data Source={db};Version=3;New=False;Compress=True;");
        }
Ejemplo n.º 10
0
 private static void InstallThemeMod(Mod mod, GameInstallation installation)
 {
     Program.CopyDirectory(mod.Installation.ModFolder, installation.InstallationPath);
     Log.Debug($"Installed theme mod: {mod.Name}");
 }
Ejemplo n.º 11
0
 public FormMain(IConfiguration configuration)
 {
     InitializeComponent();
     _configuration    = configuration;
     _gameInstallation = new GameInstallation(configuration);
 }