예제 #1
0
        private async void GTAOLaunchButton_Click(object sender, RoutedEventArgs e)
        {
            MetroWindow metroWindow = (Application.Current.MainWindow as MetroWindow);

            this.GTAVLaunchProgress = await metroWindow.ShowProgressAsync("Launching Grand Theft Auto V", "Launching GTA Online with selected options. Please wait...", true);

            this.GTAVLaunchProgress.SetIndeterminate();

            string  gamePath  = SettingsHandler.GTAVDirectory;
            GTAVDRM targetDRM = SettingsHandler.IsSteamDRM ? GTAVDRM.Steam : GTAVDRM.Rockstar;

            this.GTAV             = new GTAV(gamePath, GTAVMode.Online, targetDRM);
            this.GTAV.GTAVExited += this.GTAVProcessExited;


            GTAOOptions gameOptions = new GTAOOptions
            {
                StraightToFreemode = (bool)this.OptionsToggleButton_StraightToFreemode.IsChecked
            };
            bool optionSetSuccess = await this.GTAV.SetOptions(gameOptions);

            if (!optionSetSuccess)
            {
                MessageDialogResult res = await metroWindow.ShowMessageAsync("Unable to set options",
                                                                             "Could not set launch options. Continue with launch?",
                                                                             MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No" });

                if (res == MessageDialogResult.Negative)
                {
                    await this.GTAVLaunchProgress.CloseAsync();

                    return;
                }
            }

            bool launchSuccess = this.GTAV.StartGTAO(gameOptions);

            if (launchSuccess)
            {
                this.GTAV.GTAVStarted += this.GTAVProcessStarted;

                this.GTAVLaunchProgress.SetTitle("Waiting for Grand Theft Auto V to launch");
                this.GTAVLaunchProgress.SetMessage("Waiting for Grand Theft Auto V to launch...");

                this.GTAVLaunchProgress.SetCancelable(true);
                this.GTAVLaunchProgress.Canceled += this.GTAVCancelWaitLaunch;
            }
            else
            {
                await this.GTAVLaunchProgress.CloseAsync();

                await metroWindow.ShowMessageAsync("Failed to launch Grand Theft Auto V", "Couldn't launch GTA Online. Please double check GTAV's directory/copy under Settings.", MessageDialogStyle.Affirmative);
            }
        }
예제 #2
0
        public static string GetDRMIdentifier(GTAVDRM targetDRM)
        {
            if (targetDRM == GTAVDRM.Steam)
            {
                return(SteamDRMIdentifier);
            }
            else if (targetDRM == GTAVDRM.Rockstar)
            {
                return(RockstarDRMIdentifier);
            }

            return(null);
        }
예제 #3
0
        public static List <string> GetExpectedLocationDirectories(GTAVDRM targetDRM)
        {
            if (targetDRM == GTAVDRM.Steam)
            {
                return(new List <string>()
                {
                    @"C:\Program Files\Steam\steamapps\common\Grand Theft Auto V",
                    @"C:\Program Files (x86)\Steam\steamapps\common\Grand Theft Auto V"
                });
            }
            else if (targetDRM == GTAVDRM.Rockstar)
            {
                return(new List <string>
                {
                    @"C:\Program Files\Rockstar Games\Grand Theft Auto V",
                    @"C:\Program Files (x86)\Rockstar Games\Grand Theft Auto V",
                });
            }

            return(null);
        }
예제 #4
0
 public GTAV(string gamePath, GTAVMode gameMode, GTAVDRM targetDRM)
 {
     this.GamePath  = gamePath;
     this.GameMode  = gameMode;
     this.TargetDRM = targetDRM;
 }
예제 #5
0
        private async void GTAVLaunchButton_Click(object sender, RoutedEventArgs e)
        {
            MetroWindow metroWindow = (Application.Current.MainWindow as MetroWindow);

            this.GTAVLaunchProgress = await metroWindow.ShowProgressAsync("Launching Grand Theft Auto V",
                                                                          "Launching GTAV Story with selected options. Please wait...");

            this.GTAVLaunchProgress.SetIndeterminate();

            string  gamePath  = SettingsHandler.GTAVDirectory;
            GTAVDRM targetDRM = SettingsHandler.IsSteamDRM ? GTAVDRM.Steam : GTAVDRM.Rockstar;

            this.GTAV             = new GTAV(gamePath, GTAVMode.Offline, targetDRM);
            this.GTAV.GTAVExited += this.GTAVProcessExited;

            if (this.ModsToggleButton_ScriptMods.IsChecked == true)
            {
                IList <ScriptMod> enabledScriptMods = this.ScriptModsUserControl.ScriptMods.Where(scriptMod => scriptMod.IsEnabled).ToList();
                if (enabledScriptMods.Any())
                {
                    this.IsScriptModsInserted = true;

                    this.GTAVLaunchProgress.SetTitle("Inserting script mods");
                    this.GTAVLaunchProgress.SetMessage("...");

                    foreach (ScriptMod scriptMod in enabledScriptMods)
                    {
                        this.GTAVLaunchProgress.SetMessage(scriptMod.Name + " - inserting...");
                        bool currScriptModInsertSuccess = await Task.Run(() => this.GTAV.InsertScriptMod(scriptMod));

                        if (!currScriptModInsertSuccess)
                        {
                            MessageDialogResult res = await metroWindow.ShowMessageAsync("Unable to insert a script mod into GTAV directory",
                                                                                         "Could not move files of '" + scriptMod.Name + "' over to GTAV directory. Skipping this mod. Continue launch?",
                                                                                         MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No" });

                            if (res == MessageDialogResult.Negative)
                            {
                                await this.MoveScriptModsBack();

                                if (this.GTAV.HasBackedUpExistingFiles)
                                {
                                    await this.RestoreBackedUpFiles();
                                }

                                await this.GTAVLaunchProgress.CloseAsync();

                                return;
                            }
                        }
                        else
                        {
                            scriptMod.IsInserted = true;
                            await this.ScriptModsUserControl.ScriptModAPI.UpdateScriptModIsInserted(scriptMod.Id, true);

                            await this.ScriptModsUserControl.ScriptModAPI.UpdateScriptModFilesWithPath(scriptMod.Id, scriptMod.FilesWithPath);

                            this.InsertedScriptMods.Add(scriptMod);
                        }
                    }
                }
            }

            if (this.ModsToggleButton_AssetMods.IsChecked == true)
            {
                IList <AssetMod> enabledAssetMods = this.AssetModsUserControl.AssetMods.Where(assetMod => assetMod.IsEnabled).ToList();
                if (enabledAssetMods.Any())
                {
                    this.IsAssetModsInserted = true;

                    this.GTAVLaunchProgress.SetTitle("Inserting asset mods");
                    this.GTAVLaunchProgress.SetMessage("...");

                    bool assetModDirCreateSuccess = this.GTAV.CreateDirectoryForAssetMods();
                    if (!assetModDirCreateSuccess)
                    {
                        MessageDialogResult res = await metroWindow.ShowMessageAsync("Unable to create directory for Asset Mods",
                                                                                     "Could not create directory 'mods' in GTAV directory. Skipping all asset mods insertion. Continue launch?",
                                                                                     MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No" });

                        if (res == MessageDialogResult.Negative)
                        {
                            await this.MoveScriptModsBack();

                            if (this.GTAV.HasBackedUpExistingFiles)
                            {
                                await this.RestoreBackedUpFiles();
                            }

                            await this.GTAVLaunchProgress.CloseAsync();

                            return;
                        }
                    }
                    else
                    {
                        foreach (AssetMod assetMod in enabledAssetMods)
                        {
                            this.GTAVLaunchProgress.SetMessage(assetMod.Name + " - inserting");
                            bool currAssetModInsertSuccess = await Task.Run(() => this.GTAV.InsertAssetMod(assetMod));

                            if (!currAssetModInsertSuccess)
                            {
                                MessageDialogResult res = await metroWindow.ShowMessageAsync("Unable to insert a modification into GTAV directory",
                                                                                             "Could not move files of a modification over to GTAV directory. Stopping asset mod insertion. Continue launch?",
                                                                                             MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No" });

                                if (res == MessageDialogResult.Negative)
                                {
                                    await this.MoveScriptModsBack();

                                    await this.MoveAssetModsBack();

                                    if (this.GTAV.HasBackedUpExistingFiles)
                                    {
                                        await this.RestoreBackedUpFiles();
                                    }

                                    await this.GTAVLaunchProgress.CloseAsync();

                                    return;
                                }
                            }
                            else
                            {
                                assetMod.IsInserted = true;
                                await this.AssetModsUserControl.AssetModAPI.UpdateAssetModIsInserted(assetMod.Id, true);

                                this.InsertedAssetMods.Add(assetMod);
                            }
                        }
                    }
                }
            }

            GTAVOptions gameOptions = new GTAVOptions
            {
                OfflineMode = (bool)this.OptionsToggleButton_OfflineMode.IsChecked
            };
            bool optionSetSuccess = await this.GTAV.SetOptions(gameOptions);

            if (!optionSetSuccess)
            {
                MessageDialogResult res = await metroWindow.ShowMessageAsync("Unable to set options",
                                                                             "Could not set launch options. Continue with launch?",
                                                                             MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No" });

                if (res == MessageDialogResult.Negative)
                {
                    await this.GTAVLaunchProgress.CloseAsync();

                    return;
                }
            }

            bool launchSuccess = this.GTAV.StartGTAV(gameOptions);

            if (launchSuccess)
            {
                this.GTAV.GTAVStarted += this.GTAVProcessStarted;

                this.GTAVLaunchProgress.SetTitle("Waiting for Grand Theft Auto V to launch");
                this.GTAVLaunchProgress.SetMessage("Waiting for Grand Theft Auto V to launch...");

                this.GTAVLaunchProgress.SetCancelable(true);
                this.GTAVLaunchProgress.Canceled += this.GTAVCancelWaitLaunch;
            }
            else
            {
                await metroWindow.ShowMessageAsync("Failed to launch Grand Theft Auto V", "Couldn't launch GTAV Story. Please double check GTAV's directory/copy under Settings.", MessageDialogStyle.Affirmative);

                this.GTAVProcessExited(this, null);
            }
        }