private async Task <UpdateReport> UpdateData()
        {
            Task <UpdateReport> update = Task.Run(() => realm.Update(true, new ConsoleProgressReporter()));
            await update;

            return(update.Result);
        }
Esempio n. 2
0
        public async Task Start()
        {
            string directory = await GetInstallationDirectory();

            Stopwatch sw = new Stopwatch();

            sw.Start();

            if (File.Exists("SaintCoinach.History.zip"))
            {
                File.Delete("SaintCoinach.History.zip");
            }

            // Unzip definitions
            if (Directory.Exists("./Definitions/"))
            {
                Directory.Delete("./Definitions/", true);
            }

            ZipFile.ExtractToDirectory("./Modules/SaintCoinach/Definitions.zip", "./Definitions/");

            // TODO get language from language service?
            ARealmReversed realm = new ARealmReversed(directory, Language.English);

            try
            {
                if (!realm.IsCurrentVersion)
                {
                    realm.Update(true, this);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(@"Failed to update Saint Coinach", ex);
            }

            Log.Write("Reading data", @"Saint Coinach");

            this.Items                  = this.Load <IItem, Item, ItemWrapper>(realm);
            this.Races                  = this.Load <IRace, Race, RaceWrapper>(realm);
            this.Tribes                 = this.Load <ITribe, Tribe, TribeWrapper>(realm);
            this.Dyes                   = this.Load <IDye, Stain, DyeWrapper>(realm);
            this.BaseNPCs               = this.Load <INpcBase, ENpcBase, NpcBaseWrapper>(realm);
            this.Territories            = this.Load <ITerritoryType, TerritoryType, TerritoryTypeWrapper>(realm);
            this.Weathers               = this.Load <IWeather, Weather, WeatherWrapper>(realm);
            this.CharacterMakeCustomize = this.Load <ICharaMakeCustomize, CharaMakeCustomize, CharacterMakeCustomizeWrapper>(realm);
            this.CharacterMakeTypes     = this.Load <ICharaMakeType, CharaMakeType, CharacterMakeTypeWrapper>(realm);
            this.ResidentNPCs           = this.Load <INpcResident, ENpcResident, NpcResidentWrapper>(realm);
            this.Titles                 = this.Load <ITitle, Title, TitleWrapper>(realm);
            this.Statuses               = this.Load <IStatus, Status, StatusWrapper>(realm);

            Log.Write("Finished Reading data", @"Saint Coinach");
            Log.Write("Initialization took " + sw.ElapsedMilliseconds + "ms", @"Saint Coinach");
        }
Esempio n. 3
0
        private static void Main(string[] args)
        {
            var dataPath = @"G:\Program Files (x86)\SquareEnix\FINAL FANTASY XIV - A Realm Reborn";

            if (args.Length > 0)
            {
                dataPath = args[0];
                args     = args.Skip(1).ToArray();
            }
            if (string.IsNullOrWhiteSpace(dataPath))
            {
                dataPath = SearchForDataPaths().FirstOrDefault(System.IO.Directory.Exists);
            }
            if (string.IsNullOrWhiteSpace(dataPath) || !System.IO.Directory.Exists(dataPath))
            {
                Console.WriteLine($"Need data!  The path '{dataPath}' doesn't exist.");
                return;
            }

            var realm = new ARealmReversed(dataPath, @"SaintCoinach.History.zip", Ex.Language.English, @"app_data.sqlite");

            realm.Packs.GetPack(new IO.PackIdentifier("exd", IO.PackIdentifier.DefaultExpansion, 0)).KeepInMemory = true;

            Console.WriteLine("Game version: {0}", realm.GameVersion);
            Console.WriteLine("Definition version: {0}", realm.DefinitionVersion);

            if (!realm.IsCurrentVersion)
            {
                Console.Write("Update is available, perform update (Y/n)? ");
                var updateQuery = Console.ReadLine();
                if (string.IsNullOrEmpty(updateQuery) || string.Equals("y", updateQuery, StringComparison.OrdinalIgnoreCase))
                {
                    var stopWatch = new System.Diagnostics.Stopwatch();
                    stopWatch.Start();
                    realm.Update(true, new ConsoleProgressReporter());
                    stopWatch.Stop();
                    Console.WriteLine(stopWatch.Elapsed);
                }
                else
                {
                    Console.WriteLine("Skipping update");
                }
            }

            var cns = new Tharga.Toolkit.Console.Command.Base.ClientConsole();
            var cmd = new RootCommand(cns);

            Setup(cmd, realm);

            (new CommandEngine(cmd)).Run(args);
        }
Esempio n. 4
0
        public static string UpdateRealm()
        {
            string updates = string.Empty;

            if (!realm.IsCurrentVersion)
            {
                const bool IncludeDataChanges = true;
                var        updateReport       = realm.Update(IncludeDataChanges);
                foreach (var change in updateReport.Changes)
                {
                    updates += $"{change.SheetName} {change.ChangeType}\r\n";
                }
                return(updates);
            }
            else
            {
                return("Running current version.");
            }
        }
Esempio n. 5
0
        public async Task Start()
        {
            IInjectionService injection = Services.Get <IInjectionService>();

            string directory = injection.GamePath;

            if (!IsValidInstallation(directory))
            {
                throw new Exception("Invalid FFXIV installation");
            }

            bool forceUpdate = false;

            Stopwatch sw = new Stopwatch();

            sw.Start();

            if (forceUpdate)
            {
                if (File.Exists("SaintCoinach.History.zip"))
                {
                    File.Delete("SaintCoinach.History.zip");
                }

                if (Directory.Exists("./Definitions/"))
                {
                    Directory.Delete("./Definitions/", true);
                }
            }

            // Unzip definitions
            if (!Directory.Exists("./Definitions/"))
            {
                ZipFile.ExtractToDirectory("./Modules/SaintCoinach/bin/Definitions.zip", "./Definitions/");
            }

            // TODO get language from language service?
            ARealmReversed realm = new ARealmReversed(directory, Language.English);

            try
            {
                if (!realm.IsCurrentVersion)
                {
                    realm.Update(true, this);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(@"Failed to update Saint Coinach", ex);
            }

            List <Task> tasks = new List <Task>();

            tasks.Add(Task.Run(() => this.Items                  = this.Load <Table <IItem>, IItem, Item, ItemWrapper>(realm)));
            tasks.Add(Task.Run(() => this.Races                  = this.Load <Table <IRace>, IRace, Race, RaceWrapper>(realm)));
            tasks.Add(Task.Run(() => this.Tribes                 = this.Load <Table <ITribe>, ITribe, Tribe, TribeWrapper>(realm)));
            tasks.Add(Task.Run(() => this.Dyes                   = this.Load <Table <IDye>, IDye, Stain, DyeWrapper>(realm)));
            tasks.Add(Task.Run(() => this.BaseNPCs               = this.Load <Table <INpcBase>, INpcBase, ENpcBase, NpcBaseWrapper>(realm)));
            tasks.Add(Task.Run(() => this.Territories            = this.Load <Table <ITerritoryType>, ITerritoryType, TerritoryType, TerritoryTypeWrapper>(realm)));
            tasks.Add(Task.Run(() => this.Weathers               = this.Load <Table <IWeather>, IWeather, Weather, WeatherWrapper>(realm)));
            tasks.Add(Task.Run(() => this.CharacterMakeCustomize = this.Load <CustomizeTable, ICharaMakeCustomize, CharaMakeCustomize, CharacterMakeCustomizeWrapper>(realm)));
            tasks.Add(Task.Run(() => this.CharacterMakeTypes     = this.Load <Table <ICharaMakeType>, ICharaMakeType, CharaMakeType, CharacterMakeTypeWrapper>(realm)));
            tasks.Add(Task.Run(() => this.ResidentNPCs           = this.Load <Table <INpcResident>, INpcResident, ENpcResident, NpcResidentWrapper>(realm)));
            tasks.Add(Task.Run(() => this.Titles                 = this.Load <Table <ITitle>, ITitle, Title, TitleWrapper>(realm)));
            tasks.Add(Task.Run(() => this.Statuses               = this.Load <Table <IStatus>, IStatus, Status, StatusWrapper>(realm)));

            foreach (Task t in tasks)
            {
                await t;
            }

            Log.Write("Initialization took " + sw.ElapsedMilliseconds + "ms", @"Saint Coinach");
        }
Esempio n. 6
0
        private static void Main(string[] args)
        {
            var dataPath = "TODO: DataPath";//Properties.Settings.Default.DataPath;

            if (args.Length > 0)
            {
                dataPath = args[0];
                args     = args.Skip(1).ToArray();
            }
            if (string.IsNullOrWhiteSpace(dataPath))
            {
                dataPath = SearchForDataPaths().FirstOrDefault(p => System.IO.Directory.Exists(p));
            }
            if (string.IsNullOrWhiteSpace(dataPath) || !System.IO.Directory.Exists(dataPath))
            {
                Console.WriteLine($"Need data!  The path '{dataPath}' doesn't exist.");
                return;
            }

            var realm = new ARealmReversed(dataPath, @"SaintCoinach.History.zip", Ex.Language.English, @"app_data.sqlite");

            realm.Packs.GetPack(new IO.PackIdentifier("exd", IO.PackIdentifier.DefaultExpansion, 0)).KeepInMemory = true;

            Console.WriteLine("Game version: {0}", realm.GameVersion);
            Console.WriteLine("Definition version: {0}", realm.DefinitionVersion);

            if (!realm.IsCurrentVersion)
            {
                Console.Write("Update is available, perform update (Y/n)? ");
                //var updateQuery = Console.ReadLine();
                var updateQuery = "n";
                if (string.IsNullOrEmpty(updateQuery) || string.Equals("y", updateQuery, StringComparison.OrdinalIgnoreCase))
                {
                    var stopWatch = new System.Diagnostics.Stopwatch();
                    stopWatch.Start();
                    realm.Update(true, new ConsoleProgressReporter());
                    stopWatch.Stop();
                    Console.WriteLine(stopWatch.Elapsed);
                }
                else
                {
                    Console.WriteLine("Skipping update");
                }
            }

            // TODO: Original
            //var cns = new Tharga.Toolkit.Console.Command.Base.ClientConsole();
            // TODO: Me running command directly for testing
            var exd = new Commands.AllExdCommand(realm);

            exd.WriteEvent += (s, e) => {
                Console.WriteLine($"{e.OutputLevel.ToString()}: {e.Message}");
            };

            exd.Invoke(null);

            var cns = new ClientConsole();
            var cmd = new RootCommand(cns);

            Setup(cmd, realm);
            (new CommandEngine(cmd)).Start(args);
        }