Ejemplo n.º 1
0
        private async Task SaveAndExit()
        {
            if (_useDiscordRpc && !Properties.Settings.Default.UseDiscordRpc) // previously enabled
            {
                DiscordIntegration.Deinitialize();
            }

            if (Properties.Settings.Default.AssetsLanguage != Languages_CbBox.SelectedIndex)
            {
                Properties.Settings.Default.AssetsLanguage = Languages_CbBox.SelectedIndex;
                await Localizations.SetLocalization(Properties.Settings.Default.AssetsLanguage, true).ConfigureAwait(false);
            }


            if (!_inputPath.Equals(Properties.Settings.Default.PakPath) ||
                !_outputPath.Equals(Properties.Settings.Default.OutputPath) ||
                _useEnglish != Properties.Settings.Default.UseEnglish)
            {
                DarkMessageBoxHelper.Show(Properties.Resources.PathChangedRestart, Properties.Resources.PathChanged, MessageBoxButton.OK, MessageBoxImage.Information);
                DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[Restarting]", "Path(s) changed");

                Properties.Settings.Default.Save();
                Process.Start(Process.GetCurrentProcess().MainModule.FileName);
                Application.Current.Shutdown();
            }
            else
            {
                Properties.Settings.Default.Save();
                DebugHelper.WriteUserSettings();
                DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[Window]", "Closing General Settings");
            }
        }
Ejemplo n.º 2
0
        private async Task LoadPakFiles(EPakLoader mode)
        {
            ListBoxVm.gameFiles.Clear();
            DataGridVm.dataGridViewModel.Clear();
            ImageBoxVm.imageBoxViewModel.Reset();
            StatusBarVm.statusBarViewModel.Reset();
            AvalonEditVm.avalonEditViewModel.Reset();
            PakPropertiesVm.pakPropertiesViewModel.Reset();
            SortedTreeviewVm.gameFilesPath.Childrens.Clear();
            AssetPropertiesVm.assetPropertiesViewModel.Reset();

            await Task.Run(async() =>
            {
                if (mode == EPakLoader.Single)
                {
                    StatusBarVm.statusBarViewModel.Set($"{Properties.Settings.Default.PakPath}\\{PakFile.FileName}", Properties.Resources.Loading);
                    DebugHelper.WriteLine("{0} {1} {2} {3}", "[FModel]", "[PakMenuItemViewModel]", "[Loader]", $"{PakFile.FileName} was selected ({mode})");
                }
                else
                {
                    StatusBarVm.statusBarViewModel.Set(Properties.Settings.Default.PakPath, Properties.Resources.Loading);
                    DebugHelper.WriteLine("{0} {1} {2} {3}", "[FModel]", "[PakMenuItemViewModel]", "[Loader]", $"All PAK files were selected ({mode})");
                }

                foreach (PakFileReader pakFile in MenuItems.pakFiles.GetPakFileReaders())
                {
                    if (pakFile.AesKey == null)
                    {
                        continue;
                    }

                    if (!Globals.CachedPakFiles.ContainsKey(pakFile.FileName))
                    {
                        pakFile.ReadIndex(pakFile.AesKey);
                        Globals.CachedPakFiles[pakFile.FileName] = pakFile;

                        if (mode != EPakLoader.Single)
                        {
                            StatusBarVm.statusBarViewModel.Set(string.Format(Properties.Resources.MountedPakTo, pakFile.FileName, pakFile.MountPoint), Properties.Resources.Loading);
                        }
                    }
                }

                if (mode == EPakLoader.Single)
                {
                    PakPropertiesVm.pakPropertiesViewModel.Set(PakFile);
                }
                await Localizations.SetLocalization(Properties.Settings.Default.AssetsLanguage, false).ConfigureAwait(false);
                PopulateTreeviewViewModel(mode);
            }).ContinueWith(t =>
            {
                DiscordIntegration.Update(
                    $"{Globals.CachedPakFiles.Count}/{MenuItems.pakFiles.GetPakCount()} {Properties.Resources.PakFiles}",
                    string.Format("{0} - {1}", Globals.Game,
                                  mode == EPakLoader.All ? Properties.Resources.AllFiles :
                                  mode == EPakLoader.New ? Properties.Resources.NewFiles :
                                  mode == EPakLoader.Modified ? Properties.Resources.ModifiedFiles :
                                  mode == EPakLoader.NewModified ? Properties.Resources.NewModifiedFiles :
                                  mode == EPakLoader.Single ? Header.Substring(0, Header.LastIndexOf("-WindowsClient.pak")) :
                                  string.Empty
                                  ));

                if (t.Exception != null)
                {
                    Tasks.TaskCompleted(t.Exception);
                }
                else
                {
                    StatusBarVm.statusBarViewModel.Set(
                        mode == EPakLoader.Single ?
                        $"{Properties.Settings.Default.PakPath}\\{PakFile.FileName}" :
                        Properties.Settings.Default.PakPath,
                        Properties.Resources.Success);
                }
            },
                            TaskScheduler.FromCurrentSynchronizationContext());

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }