Exemplo n.º 1
0
        /// <summary>
        /// Does basic checks to the profile (is modded but supposed to be vanilla, are mods in the wrong directory, ...)
        /// </summary>
        /// <returns>true if the game can be launched, false otherwise</returns>
        public bool CheckCurrentProfile()
        {
            if (Instance.Profiles.CurrentProfile == 0 && GameScanner.IsGTAModded())
            {
                Log.Warn("GTA V is modded while the selected profile is \"Vanilla\" !");

                MessageBoxResult result = Messages.Show(this.Window, "ModsOnVanilla", "Warn", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning);

                if (result == MessageBoxResult.Yes)
                {
                    string name = Instance.GetNewProfileName();
                    this.Profiles.Add(name);
                    this.Profiles.CurrentProfile = Instance.Profiles.Count - 1;
                    this.UiManager.Profiles.Add(name);
                    this.UiManager.SelectedProfile = this.UiManager.Profiles.Count - 1;
                    this.SaveProfiles();
                    return(true);
                }
                else if (result == MessageBoxResult.No)
                {
                    PopupDeletingMods popup = new PopupDeletingMods();
                    this.CurrentThread = popup.StartThread();
                    popup.ShowDialog();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (Instance.Profiles.CurrentProfile != 0 && Directory.Exists(Path.Combine(this.Settings.GetProfileFolder(), this.Profiles[this.Profiles.CurrentProfile])))
            {
                string path = Path.Combine(this.Settings.GetProfileFolder(), this.Profiles[this.Profiles.CurrentProfile]);

                if (Directory.GetFileSystemEntries(path).GetLength(0) != 0)
                {
                    MessageBoxResult result = Messages.Show(this.Window, "UpdateProfile", "UpdateProfile", MessageBoxButton.YesNo, MessageBoxImage.Question);

                    if (result == MessageBoxResult.Yes)
                    {
                        PopupMoveMods popup = new PopupMoveMods(path);
                        this.CurrentThread = popup.StartThread();
                        popup.ShowDialog();
                    }
                }

                return(true);
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 2
0
        private void DeleteSelectedProfile(object sender, EventArgs e)
        {
            if (this.UiManager.SelectedProfile == 0)
            {
                Messages.Show(this.Window, "CantDeleteProfile", "Impossible", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            else
            {
                MessageBoxResult result = Messages.Show(this.Window, "SureDelete", "Sure", MessageBoxButton.YesNo, MessageBoxImage.Question);

                if (result == MessageBoxResult.Yes)
                {
                    string selected = this.UiManager.Profiles[this.UiManager.SelectedProfile];
                    int    index    = this.UiManager.SelectedProfile;
                    if (Directory.Exists(Path.Combine(this.Settings.GetProfileFolder(), selected)))
                    {
                        IOUtils.Delete(Path.Combine(this.Settings.GetProfileFolder(), selected));
                    }
                    this.Profiles.Remove(selected);
                    this.UiManager.Profiles.Remove(selected);

                    if (index == this.Profiles.CurrentProfile)
                    {
                        PopupDeletingMods popup = new PopupDeletingMods();
                        this.CurrentThread = popup.StartThread();
                        popup.ShowDialog();
                        if (!popup.CreatedModdedState)
                        {
                            this.Profiles.CurrentProfile = 0;
                        }
                    }
                    else if (index < this.Profiles.CurrentProfile)
                    {
                        this.Profiles.CurrentProfile--;
                    }
                    this.UiManager.SelectedProfile = this.Profiles.CurrentProfile;

                    this.SaveProfiles();
                }
            }
        }