Exemplo n.º 1
0
        private void OnSaveImage(object sender, RoutedEventArgs e)
        {
            Application.Current.Dispatcher.Invoke(delegate
            {
                if (ImagePreview.Source == null)
                {
                    return;
                }
                var saveFileDialog = new SaveFileDialog
                {
                    Title            = "Save Image",
                    FileName         = "Preview.png",
                    InitialDirectory = UserSettings.Default.OutputDirectory,
                    Filter           = "Png Files (*.png)|*.png|All Files (*.*)|*.*"
                };

                if (!(bool)saveFileDialog.ShowDialog())
                {
                    return;
                }
                using var fileStream = new FileStream(saveFileDialog.FileName, FileMode.Create);
                var encoder          = new PngBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create((BitmapSource)ImagePreview.Source));
                encoder.Save(fileStream);

                if (!File.Exists(saveFileDialog.FileName))
                {
                    return;
                }
                Log.Information("{FileName} successfully saved", saveFileDialog.FileName.SubstringAfterLast('\\'));
                FLogger.AppendInformation();
                FLogger.AppendText($"Successfully saved '{saveFileDialog.FileName.SubstringAfterLast('\\')}'", Constants.WHITE, true);
            });
Exemplo n.º 2
0
 private static void SaveCheck(string path, string fileName)
 {
     if (File.Exists(path))
     {
         Log.Information("{FileName} successfully saved", fileName);
         FLogger.AppendInformation();
         FLogger.AppendText($"Successfully saved '{fileName}'", Constants.WHITE, true);
     }
     else
     {
         Log.Error("{FileName} could not be saved", fileName);
         FLogger.AppendError();
         FLogger.AppendText($"Could not save '{fileName}'", Constants.WHITE, true);
     }
 }
Exemplo n.º 3
0
        private async Task FilterNewOrModifiedFilesToDisplay(CancellationToken cancellationToken)
        {
            var openFileDialog = new OpenFileDialog
            {
                Title            = "Select a backup file older than your current game version",
                InitialDirectory = Path.Combine(UserSettings.Default.OutputDirectory, "Backups"),
                Filter           = "FBKP Files (*.fbkp)|*.fbkp|All Files (*.*)|*.*",
                Multiselect      = false
            };

            if (!(bool)openFileDialog.ShowDialog())
            {
                return;
            }

            FLogger.AppendInformation();
            FLogger.AppendText($"Backup file older than current game version is '{openFileDialog.FileName.SubstringAfterLast("\\")}'", Constants.WHITE, true);

            await using var fileStream   = new FileStream(openFileDialog.FileName, FileMode.Open);
            await using var memoryStream = new MemoryStream();

            if (fileStream.ReadUInt32() == _IS_LZ4)
            {
                fileStream.Position -= 4;
                await using var compressionStream = LZ4Stream.Decode(fileStream);
                await compressionStream.CopyToAsync(memoryStream, cancellationToken).ConfigureAwait(false);
            }
            else
            {
                await fileStream.CopyToAsync(memoryStream, cancellationToken).ConfigureAwait(false);
            }

            memoryStream.Position   = 0;
            await using var archive = new FStreamArchive(fileStream.Name, memoryStream);
            var entries = new List <VfsEntry>();

            switch (UserSettings.Default.LoadingMode)
            {
            case ELoadingMode.AllButNew:
            {
                var paths = new Dictionary <string, int>();
                while (archive.Position < archive.Length)
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    archive.Position += 29;
                    paths[archive.ReadString().ToLower()[1..]] = 0;
Exemplo n.º 4
0
        private void OnClick(object sender, RoutedEventArgs e)
        {
            if (_applicationView.MapViewer.MapImage == null)
            {
                return;
            }
            var path = Path.Combine(UserSettings.Default.OutputDirectory, "Textures", "MiniMap.png");

            var saveFileDialog = new SaveFileDialog
            {
                Title            = "Save MiniMap",
                FileName         = "MiniMap.png",
                InitialDirectory = path.SubstringBeforeLast('\\'),
                Filter           = "PNG Files (*.png)|*.png|All Files (*.*)|*.*"
            };

            if (!(bool)saveFileDialog.ShowDialog())
            {
                return;
            }
            path = saveFileDialog.FileName;

            using var fileStream = new FileStream(path, FileMode.Create);
            var encoder = new PngBitmapEncoder();

            encoder.Frames.Add(BitmapFrame.Create(_applicationView.MapViewer.GetImageToSave()));
            encoder.Save(fileStream);

            if (File.Exists(path))
            {
                Log.Information("MiniMap.png successfully saved");
                FLogger.AppendInformation();
                FLogger.AppendText("Successfully saved 'MiniMap.png'", Constants.WHITE, true);
            }
            else
            {
                Log.Error("MiniMap.png could not be saved");
                FLogger.AppendError();
                FLogger.AppendText("Could not save 'MiniMap.png'", Constants.WHITE, true);
            }
        }
Exemplo n.º 5
0
        public override async void Execute(LoadingModesViewModel contextViewModel, object parameter)
        {
            if (_applicationView.CUE4Parse.GameDirectory.HasNoFile)
            {
                return;
            }
            if (_applicationView.CUE4Parse.Game == FGame.FortniteGame &&
                _applicationView.CUE4Parse.Provider.MappingsContainer == null)
            {
                FLogger.AppendError();
                FLogger.AppendText("Mappings could not get pulled, extracting assets might not work properly. If so, press F12 or please restart.", Constants.WHITE, true);
            }
#if DEBUG
            var loadingTime = Stopwatch.StartNew();
#endif
            _applicationView.CUE4Parse.AssetsFolder.Folders.Clear();
            _applicationView.CUE4Parse.SearchVm.SearchResults.Clear();
            MainWindow.YesWeCats.LeftTabControl.SelectedIndex = 1;     // folders tab

            await _applicationView.CUE4Parse.LoadLocalizedResources(); // load locres if not already loaded

            Helper.CloseWindow <AdonisWindow>("Search View");          // close search window if opened

            await _threadWorkerView.Begin(async cancellationToken =>
            {
                // filter what to show
                switch (UserSettings.Default.LoadingMode)
                {
                case ELoadingMode.Single:
                case ELoadingMode.Multiple:
                    {
                        var l = (IList)parameter;
                        if (l.Count < 1)
                        {
                            return;
                        }

                        var directoryFilesToShow = l.Cast <FileItem>();
                        FilterDirectoryFilesToDisplay(cancellationToken, directoryFilesToShow);
                        break;
                    }

                case ELoadingMode.All:
                    {
                        FilterDirectoryFilesToDisplay(cancellationToken, null);
                        break;
                    }

                case ELoadingMode.AllButNew:
                case ELoadingMode.AllButModified:
                    {
                        await FilterNewOrModifiedFilesToDisplay(cancellationToken).ConfigureAwait(false);
                        break;
                    }

                default: throw new ArgumentOutOfRangeException();
                }

                _discordHandler.UpdatePresence(_applicationView.CUE4Parse);
            });

#if DEBUG
            loadingTime.Stop();
            FLogger.AppendDebug();
            FLogger.AppendText($"{_applicationView.CUE4Parse.SearchVm.SearchResults.Count} packages and a lot of localized resources loaded in {loadingTime.Elapsed.TotalSeconds.ToString("F3", CultureInfo.InvariantCulture)} seconds", Constants.WHITE, true);
#endif
        }