コード例 #1
0
        private static async Task <ArgumentHandleResult> ProcessRaceQuick(CustomUriRequest custom)
        {
            var preset = GetSettings(custom.Params, @"preset") ?? throw new Exception(@"Settings are not specified");

            var assists = GetSettings(custom.Params, @"assists");

            if (assists != null && !UserPresetsControl.LoadSerializedPreset(AssistsViewModel.Instance.PresetableKey, assists))
            {
                AssistsViewModel.Instance.ImportFromPresetData(assists);
            }

            if (custom.Params.GetFlag("loadPreset"))
            {
                QuickDrive.Show(serializedPreset: preset, forceAssistsLoading: custom.Params.GetFlag("loadAssists"));
                return(ArgumentHandleResult.SuccessfulShow);
            }

            if (!await QuickDrive.RunAsync(serializedPreset: preset, forceAssistsLoading: custom.Params.GetFlag("loadAssists")))
            {
                NonfatalError.Notify(AppStrings.Common_CannotStartRace, AppStrings.Arguments_CannotStartRace_Commentary);
                return(ArgumentHandleResult.Failed);
            }

            return(ArgumentHandleResult.Successful);
        }
コード例 #2
0
        private void OnDriveTitleLinkDrop(object sender, DragEventArgs e)
        {
            var raceGridEntry = e.Data.GetData(RaceGridEntry.DraggableFormat) as RaceGridEntry;
            var carObject     = e.Data.GetData(CarObject.DraggableFormat) as CarObject;
            var trackObject   = e.Data.GetData(TrackObjectBase.DraggableFormat) as TrackObject;
            var weatherObject = e.Data.GetData(WeatherObject.DraggableFormat) as WeatherObject;
            var carSkinObject = e.Data.GetData(CarSkinObject.DraggableFormat) as CarSkinObject;

            if (carSkinObject != null)
            {
                carObject = CarsManager.Instance.GetById(carSkinObject.CarId);
            }

            if (raceGridEntry != null || carObject != null)
            {
                QuickDrive.Show(carObject ?? raceGridEntry.Car, carSkinObject?.Id ?? raceGridEntry?.CarSkin?.Id);
            }
            else if (trackObject != null)
            {
                QuickDrive.Show(track: trackObject);
            }
            else if (weatherObject != null)
            {
                QuickDrive.Show(weatherId: weatherObject.Id);
            }
            else
            {
                e.Effects = DragDropEffects.None;
                return;
            }

            e.Effects = DragDropEffects.Copy;
            FancyHints.DragForContentSection.MaskAsUnnecessary();
        }
コード例 #3
0
        private static string _selectNextTrackLayoutId; // TODO

        protected override void OnItemDoubleClick(AcObjectNew obj)
        {
            if (obj is TrackObjectBase track)
            {
                QuickDrive.Show(track: track);
            }
        }
コード例 #4
0
        private static ArgumentHandleResult ProcessSharedRaceGridPreset(SharedEntry shared, byte[] data)
        {
            var result = ShowDialog(shared);

            switch (result)
            {
            case Choise.Save:
            case Choise.ApplyAndSave:
                var filename = FileUtils.EnsureUnique(Path.Combine(
                                                          PresetsManager.Instance.GetDirectory(RaceGridViewModel.PresetableKeyValue), @"Loaded", shared.GetFileName()));
                Directory.CreateDirectory(Path.GetDirectoryName(filename) ?? "");
                File.WriteAllBytes(filename, data);
                if (result == Choise.ApplyAndSave)
                {
                    RaceGridViewModel.LoadPreset(filename);
                    QuickDrive.NavigateToPage();
                }
                return(ArgumentHandleResult.SuccessfulShow);

            case Choise.Apply:
                RaceGridViewModel.LoadSerializedPreset(data.ToUtf8String());
                QuickDrive.NavigateToPage();
                return(ArgumentHandleResult.SuccessfulShow);

            default:
                return(ArgumentHandleResult.Failed);
            }
        }
コード例 #5
0
 protected override void OnItemDoubleClick(AcObjectNew obj)
 {
     if (obj is WeatherObject weather)
     {
         QuickDrive.Show(weatherId: weather.Id);
     }
 }
コード例 #6
0
        private static async Task <ArgumentHandleResult> ProcessSharedQuickDrivePreset(SharedEntry shared, byte[] data)
        {
            var result = ShowDialog(shared, AppStrings.Arguments_Shared_JustGo);

            switch (result)
            {
            case Choise.Save:
            case Choise.ApplyAndSave:
                var filename = FileUtils.EnsureUnique(Path.Combine(
                                                          PresetsManager.Instance.GetDirectory(QuickDrive.PresetableKeyValue), @"Loaded", shared.GetFileName()));
                Directory.CreateDirectory(Path.GetDirectoryName(filename) ?? "");
                File.WriteAllBytes(filename, data);
                if (result == Choise.ApplyAndSave)
                {
                    QuickDrive.LoadPreset(filename);
                }
                return(ArgumentHandleResult.SuccessfulShow);

            case Choise.Apply:
                QuickDrive.LoadSerializedPreset(data.ToUtf8String());
                return(ArgumentHandleResult.SuccessfulShow);

            case Choise.Extra:     // just go
                if (!await QuickDrive.RunAsync(serializedPreset: data.ToUtf8String()))
                {
                    throw new InformativeException(AppStrings.Common_CannotStartRace, AppStrings.Arguments_CannotStartRace_Commentary);
                }

                return(ArgumentHandleResult.SuccessfulShow);

            default:
                return(ArgumentHandleResult.Failed);
            }
        }
コード例 #7
0
        public void SetCarObjectMenu(ContextMenu menu, CarObject car, CarSkinObject skin)
        {
            menu.AddItem("Manage setups", () => CarSetupsListPage.Open(car))
            .AddItem("Manage skins", () => CarSkinsListPage.Open(car))
            .AddSeparator();
            CarBlock.OnShowroomContextMenu(menu, car, skin);

            menu.AddSeparator();

            var ratingBar = new RatingBar {
                Rating = car.Rating ?? 0
            };

            ratingBar.SetBinding(RatingBar.RatingProperty, new Binding("Rating")
            {
                Source = car
            });
            menu.AddItem(new MenuItem {
                StaysOpenOnClick = true,
                Header           = new DockPanel {
                    Margin   = new Thickness(0d, 0d, -40d, 0d),
                    Children =
                    {
                        new TextBlock       {
                            Text = "Rating:", Width = 80
                        },
                        ratingBar,
                        new FavouriteButton {
                            IsChecked = car.IsFavourite
                        }
                    }
                }
            });
            menu.AddItem(new MenuItem {
                StaysOpenOnClick = true,
                Header           = new DockPanel {
                    Margin   = new Thickness(0d, 0d, -40d, 0d),
                    Children =
                    {
                        new TextBlock  {
                            Text = "Notes:", Width = 80
                        },
                        new NotesBlock {
                            AcObject = car
                        }
                    }
                }
            });

            menu.AddSeparator();

            if (!QuickDrive.IsActive())
            {
                menu.AddItem("Open car in Quick Drive", () => QuickDrive.Show(car, skin?.Id));
            }

            menu.AddItem("Open car in Content tab", () => CarsListPage.Show(car, skin?.Id))
            .AddItem(AppStrings.Toolbar_Folder, car.ViewInExplorer);
        }
コード例 #8
0
 public void InitializeQuickDrivePresets()
 {
     if (QuickDrivePresets == null)
     {
         QuickDrivePresets = _helper.Create(QuickDrive.PresetableKeyValue, p => {
             QuickDrive.RunPreset(p.Filename, SelectedObject, SelectedObject.SelectedSkin?.Id);
         });
     }
 }
コード例 #9
0
 public void InitializeQuickDrivePresets()
 {
     if (QuickDrivePresets == null)
     {
         QuickDrivePresets = _helper.Create(QuickDrive.PresetableKeyValue, p => {
             QuickDrive.RunPreset(p.Filename, track: SelectedTrackConfiguration);
         });
     }
 }
コード例 #10
0
        private static string _selectNextTrackLayoutId; // TODO

        protected override void OnItemDoubleClick(AcObjectNew obj)
        {
            var track = obj as TrackObjectBase;

            if (track == null)
            {
                return;
            }
            QuickDrive.Show(track: track);
        }
コード例 #11
0
        protected override void OnItemDoubleClick(AcObjectNew obj)
        {
            var weather = obj as WeatherObject;

            if (weather == null)
            {
                return;
            }
            QuickDrive.Show(weather: weather);
        }
コード例 #12
0
ファイル: MainWindow.xaml.cs プロジェクト: WildGenie/actools
        private void TitleLinkDrive_OnDrop(object sender, DragEventArgs e)
        {
            var raceGridEntry = e.Data.GetData(RaceGridEntry.DraggableFormat) as RaceGridEntry;
            var carObject     = e.Data.GetData(CarObject.DraggableFormat) as CarObject;

            if (raceGridEntry == null && carObject == null)
            {
                e.Effects = DragDropEffects.None;
                return;
            }

            QuickDrive.Show(carObject ?? raceGridEntry.Car, raceGridEntry?.CarSkin?.Id);
            e.Effects = DragDropEffects.Copy;
        }
コード例 #13
0
        public void SetCarObjectMenu(ContextMenu menu, CarObject car, CarSkinObject skin)
        {
            menu.AddItem("Manage setups", () => CarSetupsListPage.Open(car))
            .AddItem("Manage skins", () => CarSkinsListPage.Open(car))
            .AddSeparator();
            CarBlock.OnShowroomContextMenu(menu, car, skin);

            menu.AddSeparator();

            if (!QuickDrive.IsActive())
            {
                menu.AddItem("Open car in Quick Drive", () => QuickDrive.Show(car, skin?.Id));
            }

            menu.AddItem("Open car in Content tab", () => CarsListPage.Show(car, skin?.Id))
            .AddItem(AppStrings.Toolbar_Folder, car.ViewInExplorer);
        }
コード例 #14
0
        public void SetTrackObjectMenu(ContextMenu menu, TrackObjectBase track)
        {
            var mainTrack = track.MainTrackObject;

            mainTrack.SkinsManager.EnsureLoaded();
            if (mainTrack.EnabledOnlySkins.Count > 0)
            {
                foreach (var skinObject in mainTrack.EnabledOnlySkins)
                {
                    var item = new MenuItem {
                        Header           = skinObject.DisplayName.ToTitle(),
                        IsCheckable      = true,
                        StaysOpenOnClick = true,
                        ToolTip          = skinObject.Description
                    };

                    item.SetBinding(MenuItem.IsCheckedProperty, new Binding {
                        Path   = new PropertyPath(nameof(skinObject.IsActive)),
                        Source = skinObject
                    });

                    menu.Items.Add(item);
                }
                menu.AddSeparator();
            }

            menu.AddItem("Manage skins", () => TrackSkinsListPage.Open(track.MainTrackObject));
            menu.AddSeparator();

            if (!QuickDrive.IsActive())
            {
                menu.AddItem("Open track in Quick Drive", () => QuickDrive.Show(track: track));
            }

            menu.AddItem("Open track in Content tab", () => TracksListPage.Show(track), isEnabled: InternalUtils.IsAllRight)
            .AddItem(AppStrings.Toolbar_Folder, track.ViewInExplorer);
        }
コード例 #15
0
        private async Task <ArgumentHandleResult> ProcessUriRequestObsolete(string request)
        {
            string key, param;
            NameValueCollection query;

            {
                var splitted = request.Split(new[] { '/' }, 2);
                if (splitted.Length != 2)
                {
                    return(ArgumentHandleResult.FailedShow);
                }

                key   = splitted[0];
                param = splitted[1];

                var index = param.IndexOf('?');
                if (index != -1)
                {
                    query = HttpUtility.ParseQueryString(param.SubstringExt(index + 1));
                    param = param.Substring(0, index);
                }
                else
                {
                    query = null;
                }
            }

            switch (key)
            {
            case "quickdrive":
                var preset = Convert.FromBase64String(param).ToUtf8String();
                if (!QuickDrive.RunSerializedPreset(preset))
                {
                    NonfatalError.Notify(AppStrings.Common_CannotStartRace, AppStrings.Arguments_CannotStartRace_Commentary);
                    return(ArgumentHandleResult.Failed);
                }
                break;

            case "race":
                var raceIni = Convert.FromBase64String(param).ToUtf8String();
                await GameWrapper.StartAsync(new Game.StartProperties {
                    PreparedConfig = IniFile.Parse(raceIni)
                });

                break;

            case "open":
            case "install":
                var address = Convert.FromBase64String(param).ToUtf8String();
                var path    = await LoadRemoveFile(address, query?.Get(@"name"));

                if (string.IsNullOrWhiteSpace(path))
                {
                    return(ArgumentHandleResult.FailedShow);
                }

                try {
                    if (!FileUtils.Exists(path))
                    {
                        return(ArgumentHandleResult.FailedShow);
                    }
                } catch (Exception) {
                    return(ArgumentHandleResult.FailedShow);
                }

                return(await ProcessInputFile(path));
            }

            return(ArgumentHandleResult.Successful);
        }
コード例 #16
0
        private static async Task <ArgumentHandleResult> ProcessUriRequestObsolete(string request)
        {
            string key, param;
            NameValueCollection query;

            {
                var splitted = request.Split(new[] { '/' }, 2);
                if (splitted.Length != 2)
                {
                    return(ArgumentHandleResult.FailedShow);
                }

                key   = splitted[0];
                param = splitted[1];

                var index = param.IndexOf('?');
                if (index != -1)
                {
                    query = HttpUtility.ParseQueryString(param.SubstringExt(index + 1));
                    param = param.Substring(0, index);
                }
                else
                {
                    query = null;
                }
            }

            switch (key)
            {
            case "quickdrive":
                var preset = Convert.FromBase64String(param).ToUtf8String();
                if (!await QuickDrive.RunAsync(serializedPreset: preset))
                {
                    NonfatalError.Notify(AppStrings.Common_CannotStartRace, AppStrings.Arguments_CannotStartRace_Commentary);
                    return(ArgumentHandleResult.Failed);
                }
                break;

            case "race":
                var raceIni = Convert.FromBase64String(param).ToUtf8String();
                await GameWrapper.StartAsync(new Game.StartProperties {
                    PreparedConfig = IniFile.Parse(raceIni)
                });

                break;

            case "open":
                var address = Convert.FromBase64String(param).ToUtf8String();
                try {
                    return(await ProcessInputFile(await LoadRemoveFile(address, query?.Get(@"name"))));
                } catch (Exception e) when(e.IsCancelled())
                {
                    return(ArgumentHandleResult.Failed);
                } catch (Exception e) {
                    Logging.Warning(e);
                    return(ArgumentHandleResult.FailedShow);
                }

            case "install":
                return(await ContentInstallationManager.Instance.InstallAsync(param, new ContentInstallationParams(true))
                            ? ArgumentHandleResult.Successful : ArgumentHandleResult.Failed);
            }

            return(ArgumentHandleResult.Successful);
        }
コード例 #17
0
        public void SetTrackObjectMenu(ContextMenu menu, TrackObjectBase track)
        {
            var mainTrack = track.MainTrackObject;

            mainTrack.SkinsManager.EnsureLoaded();
            if (mainTrack.EnabledOnlySkins.Count > 0)
            {
                foreach (var skinObject in mainTrack.EnabledOnlySkins)
                {
                    var item = new MenuItem {
                        Header           = skinObject.DisplayName.ToTitle(),
                        IsCheckable      = true,
                        StaysOpenOnClick = true,
                        ToolTip          = skinObject.Description
                    };

                    item.SetBinding(MenuItem.IsCheckedProperty, new Binding {
                        Path   = new PropertyPath(nameof(skinObject.IsActive)),
                        Source = skinObject
                    });

                    menu.Items.Add(item);
                }
                menu.AddSeparator();
            }

            menu.AddItem("Manage skins", () => TrackSkinsListPage.Open(track.MainTrackObject));

            menu.AddSeparator();

            var ratingBar = new RatingBar {
                Rating = track.MainTrackObject.Rating ?? 0
            };

            ratingBar.SetBinding(RatingBar.RatingProperty, new Binding("Rating")
            {
                Source = track.MainTrackObject
            });
            menu.AddItem(new MenuItem {
                StaysOpenOnClick = true,
                Header           = new DockPanel {
                    Margin   = new Thickness(0d, 0d, -40d, 0d),
                    Children =
                    {
                        new TextBlock       {
                            Text = "Rating:", Width = 80
                        },
                        ratingBar,
                        new FavouriteButton {
                            IsChecked = track.MainTrackObject.IsFavourite
                        }
                    }
                }
            });
            menu.AddItem(new MenuItem {
                StaysOpenOnClick = true,
                Header           = new DockPanel {
                    Margin   = new Thickness(0d, 0d, -40d, 0d),
                    Children =
                    {
                        new TextBlock  {
                            Text = "Notes:", Width = 80
                        },
                        new NotesBlock {
                            AcObject = track.MainTrackObject
                        }
                    }
                }
            });

            menu.AddSeparator();

            if (!QuickDrive.IsActive())
            {
                menu.AddItem("Open track in Quick Drive", () => QuickDrive.Show(track: track));
            }

            menu.AddItem("Open track in Content tab", () => TracksListPage.Show(track), isEnabled: InternalUtils.IsAllRight)
            .AddItem(AppStrings.Toolbar_Folder, track.ViewInExplorer);
        }
コード例 #18
0
 public void SetupHotlap(CarObject car, TrackObjectBase track)
 {
     QuickDrive.ShowHotlap(car, track: track);
 }
コード例 #19
0
 public static Task ShotAndApply(TrackSkinObject track)
 {
     return(ShotAndApply(track.PreviewImage, track.Enabled, () => QuickDrive.RunAsync(trackSkin: track)));
 }
コード例 #20
0
 public Task <bool> RunHotlapAsync(CarObject car, TrackObjectBase track)
 {
     return(QuickDrive.RunAsync(car, track: track, mode: QuickDrive.ModeHotlap));
 }
コード例 #21
0
 public void SetupHotlap(CarObject car, TrackObjectBase track)
 {
     QuickDrive.Show(car, track: track, mode: QuickDrive.ModeHotlap);
 }
コード例 #22
0
 public void RunHotlap(CarObject car, TrackObjectBase track)
 {
     QuickDrive.RunHotlap(car, track: track);
 }