Ejemplo n.º 1
0
        /// <summary>
        /// Prepare shared cache file tree and ask for valid path when necessary.
        /// </summary>
        /// <returns></returns>
        private async Task PrepareSharedCache(bool forced = false)
        {
            // Call once to use registry value if avail, or force set invalid
            if (!forced)
            {
                SharedCacheReader.ValidateSCPath();
            }
            else
            {
                Settings.Default.IsSCPathValid = false;
            }

            // If called by button, choosing path is a must
            while (!Settings.Default.IsSCPathValid)
            {
                using (var dialog = new FolderBrowserDialog())
                {
                    dialog.Description = "Please select a valid Shared Cache path.\n" +
                                         "You can get this info from EVE Launcher settings.";
                    var dialogResult = dialog.ShowDialog();
                    if (dialogResult ==
                        System.Windows.Forms.DialogResult.OK &&
                        !String.IsNullOrWhiteSpace(dialog.SelectedPath))
                    {
                        SharedCacheReader.ValidateSCPath(dialog.SelectedPath);
                    }
                    if (dialogResult == System.Windows.Forms.DialogResult.Cancel)
                    {
                        if (forced)
                        {
                            return;                                    // no need to quit if user was specifying another path
                        }
                        System.Windows.Application.Current.Shutdown(); // only quit when cancelled on app launch
                    }
                }
            }

            StatusBar.DataContext      = UIStrings.GetInstance();
            InfoStackPanel.DataContext = UIStrings.GetInstance();

            _currentNode = null;
            // Read raw from resfileindex.txt
            // Disable path selector until loading is complete
            UIStrings.GetInstance().IsPathBtnEnabled = false;
            Debug.WriteLine("Creating SC list...");
            UIStrings.GetInstance().LoadingProgValue = 0;
            UIStrings.GetInstance().LoadingText      = "Reading Shared Cache index from " + Settings.Default.SCPath + "...";
            var scIndex = await SharedCacheReader.ReadSCIndex(Settings.Default.SCPath);

            // Parse raw into inherited structure
            Debug.WriteLine("SC list created. Creating SC tree..");
            UIStrings.GetInstance().LoadingText    = "Organizing " + scIndex.Count + " entries...";
            UIStrings.GetInstance().LoadingProgMax = scIndex.Count;
            var scTree = await SharedCacheParser.PopulateItemTree(scIndex);

            // Loading finished, bind DataContext and re-enable path chooser
            UIStrings.GetInstance().LoadingText = "Successfully parsed " + scIndex.Count + " entries.";
            TreeView.DataContext = new
            {
                SharedCacheTree = scTree
            };
            UIStrings.GetInstance().IsPathBtnEnabled = true;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initialization here: read settings etc
 /// </summary>
 private void InitializeSettings()
 {
     // Attempt to validate/read settings
     SharedCacheReader.ValidateSCPath();
 }