Ejemplo n.º 1
0
        public ChangeCarParentDialog(CarObject car) {
            InitializeComponent();
            DataContext = this;

            Buttons = new[] {
                OkButton, 
                CreateExtraDialogButton(ControlsStrings.CarParent_MakeIndependent, () => {
                    Car.ParentId = null;
                    Close();
                }),
                CancelButton
            };

            Car = car;
            Filter = car.Brand == null ? "" : @"brand:" + car.Brand;

            CarsListView = new ListCollectionView(CarsManager.Instance.LoadedOnly.Where(x => x.ParentId == null && x.Id != Car.Id).ToList()) {
                CustomSort = this
            };

            UpdateFilter();
            if (car.Parent == null) {
                CarsListView.MoveCurrentToPosition(0);
            } else {
                CarsListView.MoveCurrentTo(car.Parent);
            }

            Closing += CarParentEditor_Closing;
        }
        public LiteShowroomWrapperWithTools(ToolsKn5ObjectRenderer renderer, CarObject car, string skinId) : base(renderer, car.DisplayName) {
            _helper = new AttachedHelper(this, new LiteShowroomTools(renderer, car, skinId));
            GoToNormalMode();

            renderer.VisibleUi = false;
            Form.Move += OnMove;
        }
Ejemplo n.º 3
0
        public CarSpecsEditor(CarObject car) {
            _automaticallyRecalculate = ValuesStorage.GetBool(AutomaticallyRecalculateKey);

            InitializeComponent();
            DataContext = this;

            Buttons = new[] {
                OkButton,
                CreateExtraDialogButton(AppStrings.CarSpecs_FixFormats, FixValues),
                CreateExtraDialogButton(AppStrings.CarSpecs_UpdateCurves, UpdateCurves),
                CancelButton
            };

            _fixableInputs = new[] {
                PowerInput, TorqueInput, WeightInput, AccelerationInput, TopSpeedInput, PwRatioInput
            };

            foreach (var input in _fixableInputs) {
                input.PreviewMouseDown += FixableInput_MouseDown;
            }

            Car = car;
            TorqueGraph = car.SpecsTorqueCurve;
            PowerGraph = car.SpecsPowerCurve;

            Closing += CarSpecsEditor_Closing;
        }
            public ViewModel(string serializedPreset, CarObject carObject, string selectedSkinId) {
                ShowroomsManager.Instance.EnsureLoaded();
                PpFiltersManager.Instance.EnsureLoaded();

                SelectedCar = carObject;
                SelectedSkinId = selectedSkinId ?? SelectedCar.SelectedSkin?.Id;

                _saveable = new SaveHelper<SaveableData>("__CarOpenInShowroom", () => new SaveableData {
                    ShowroomId = SelectedShowroom?.Id,
                    FilterId = SelectedFilter?.Id,
                    CameraFov = CameraFov,
                    DisableSweetFx = DisableSweetFx,
                    DisableWatermark = DisableWatermark,
                }, o => {
                    if (o.ShowroomId != null) SelectedShowroom = ShowroomsManager.Instance.GetById(o.ShowroomId) ?? SelectedShowroom;
                    if (o.FilterId != null) SelectedFilter = PpFiltersManager.Instance.GetById(o.FilterId) ?? SelectedFilter;

                    CameraFov = o.CameraFov;
                    DisableWatermark = o.DisableWatermark;
                    DisableSweetFx = o.DisableSweetFx;
                }, () => {
                    SelectedShowroom = ShowroomsManager.Instance.GetDefault();
                    SelectedFilter = PpFiltersManager.Instance.GetDefault();
                    CameraFov = 30;
                    DisableWatermark = false;
                    DisableSweetFx = false;
                });

                if (string.IsNullOrEmpty(serializedPreset)) {
                    _saveable.Initialize();
                } else {
                    _saveable.Reset();
                    _saveable.FromSerializedString(serializedPreset);
                }
            }
        public CarTransmissionLossSelector(CarObject car) {
            Car = car;

            InitializeComponent();
            DataContext = this;

            Value = 13;
            Buttons = new[] { OkButton, CancelButton };
        }
Ejemplo n.º 6
0
 public LiteShowroomTools(ToolsKn5ObjectRenderer renderer, CarObject car, string skinId) {
     DataContext = new ViewModel(renderer, car, skinId);
     InputBindings.AddRange(new[] {
         new InputBinding(Model.PreviewSkinCommand, new KeyGesture(Key.PageUp)),
         new InputBinding(Model.NextSkinCommand, new KeyGesture(Key.PageDown)),
         new InputBinding(Model.Car.ViewInExplorerCommand, new KeyGesture(Key.F, ModifierKeys.Alt)),
         new InputBinding(Model.OpenSkinDirectoryCommand, new KeyGesture(Key.F, ModifierKeys.Control)),
         new InputBinding(new DelegateCommand(() => Model.Renderer?.Deselect()), new KeyGesture(Key.D, ModifierKeys.Control))
     });
     InitializeComponent();
     Buttons = new Button[0];
 }
        public UpgradeIconEditor_Editor() {
            var mainDialog = UpgradeIconEditor.Instance;
            if (mainDialog != null) {
                Car = mainDialog.Car;
                _key = @"__upgradeiconeditor_" + Car.Id;
            }

            DataContext = this;
            InitializeComponent();

            NewIconLabel.Text = _key != null ? ValuesStorage.GetString(_key, UpgradeIconEditor.TryToGuessLabel(Car?.DisplayName) ?? @"S1") : @"?";
            NewIconLabel_UpdateFontSize();

            FocusLabel();
        }
Ejemplo n.º 8
0
        public UpgradeIconEditor(CarObject car) {
            Car = car;
            _instance = new WeakReference<UpgradeIconEditor>(this);

            InitializeComponent();
            DataContext = this;

            Buttons = new[] {
                OkButton, 
                CreateExtraDialogButton(AppStrings.Common_SelectFile, SelectFile), 
                CreateExtraDialogButton(AppStrings.Common_ViewUserFolder, () => FilesStorage.Instance.OpenContentDirectoryInExplorer(ContentCategory.UpgradeIcons)),
                CancelButton
            };

            Closing += UpgradeIconEditor_Closing;
        }
Ejemplo n.º 9
0
        public BrandBadgeEditor(CarObject car) {
            Car = car;

            InitializeComponent();
            DataContext = this;
            Buttons = new[] {
                OkButton,
                CreateExtraDialogButton(AppStrings.Common_SelectFile, SelectFile),
                CreateExtraDialogButton(AppStrings.Common_ViewUserFolder, () => FilesStorage.Instance.OpenContentDirectoryInExplorer(ContentCategory.BrandBadges)),
                CancelButton
            };

            Closing += BrandBadgeEditor_Closing;

            FilesStorage.Instance.Watcher(ContentCategory.BrandBadges).Update += BrandBadgeEditor_Update;
            Icons = new BetterObservableCollection<FilesStorage.ContentEntry>(FilesStorage.Instance.GetContentDirectory(ContentCategory.BrandBadges));
            UpdateSelected();
        }
Ejemplo n.º 10
0
        private void SelectedCarChanged(CarObject value) {
            if (value != null) {
                value.SkinsManager.EnsureLoadedAsync().Forget();
                UpdateTunableVersions();
            }

            SelectedTunableVersion = value;
            OnPropertyChanged(nameof(SelectedCar));

            _openInShowroomCommand?.RaiseCanExecuteChanged();
            _openInCustomShowroomCommand?.RaiseCanExecuteChanged();
            _openInShowroomOptionsCommand?.RaiseCanExecuteChanged();
            CommandManager.InvalidateRequerySuggested(); // TODO

            if (value != null) {
                SelectedSkin = value.SelectedSkin;
            }

            if (_list != null) {
                _list.SelectedItem = value;
            }
        }
Ejemplo n.º 11
0
 public ViewModel([NotNull] CarObject car) {
     SelectedCar = car;
 }
Ejemplo n.º 12
0
            public ViewModel([NotNull] ToolsKn5ObjectRenderer renderer, CarObject carObject, string skinId) {
                if (renderer == null) throw new ArgumentNullException(nameof(renderer));

                Renderer = renderer;
                renderer.PropertyChanged += Renderer_PropertyChanged;
                renderer.Tick += Renderer_Tick;

                Car = carObject;
                Skin = skinId == null ? Car.SelectedSkin : Car.GetSkinById(skinId);
                Car.SkinsManager.EnsureLoadedAsync().Forget();

                Saveable = new SaveHelper<SaveableData>("__LiteShowroomTools", () => new SaveableData {
                    AmbientShadowDiffusion = AmbientShadowDiffusion,
                    AmbientShadowBrightness = AmbientShadowBrightness,
                    AmbientShadowIterations = AmbientShadowIterations,
                    AmbientShadowHideWheels = AmbientShadowHideWheels,
                    AmbientShadowFade = AmbientShadowFade,
                    LiveReload = Renderer.LiveReload,
                }, o => {
                    AmbientShadowDiffusion = o.AmbientShadowDiffusion;
                    AmbientShadowBrightness = o.AmbientShadowBrightness;
                    AmbientShadowIterations = o.AmbientShadowIterations;
                    AmbientShadowHideWheels = o.AmbientShadowHideWheels;
                    AmbientShadowFade = o.AmbientShadowFade ?? true;
                    Renderer.LiveReload = o.LiveReload;
                }, () => {
                    Reset(false);
                });
                Saveable.Initialize();
            }
Ejemplo n.º 13
0
 public virtual void OnSelectedUpdated(CarObject selectedCar, TrackObjectBase selectedTrack) {
 }
Ejemplo n.º 14
0
        private void UpdateTunableVersions() {
            if (_selectedCar == null) {
                TunableVersions.Clear();
                HasChildren = false;
                _previousTunableParent = null;
                return;
            }

            var parent = SelectedCar.ParentId == null ? SelectedCar : SelectedCar.Parent;
            if (parent == _previousTunableParent) {
                return;
            }

            if (parent == null) {
                TunableVersions.Clear();
                HasChildren = false;
                _previousTunableParent = null;
                return;
            }

            _previousTunableParent = parent;
            
            var children = parent.Children.Where(x => x.Enabled).ToList();
            HasChildren = children.Any();
            if (!HasChildren) {
                TunableVersions.Clear();
                return;
            }

            TunableVersions.ReplaceEverythingBy(new [] { parent }.Where(x => x.Enabled).Union(children));
            if (SelectedTunableVersion == null) {
                SelectedTunableVersion = SelectedCar;
            }
        }
Ejemplo n.º 15
0
        void List_WrappedValueChanged(object sender, WrappedValueChangedEventArgs e) {
            var car = e.NewValue as CarObject;
            if (car == null || SelectedCar == null) return;

            if (car.ParentId == SelectedCar.Id) {
                _previousTunableParent = null;
                UpdateTunableVersions();
            }
        }
Ejemplo n.º 16
0
        public SelectCarDialog(CarObject car) {
            _selectedCar = new DelayedPropertyWrapper<CarObject>(SelectedCarChanged);

            SelectedCar = car;
            _instance = new WeakReference<SelectCarDialog>(this);

            DataContext = this;
            InputBindings.AddRange(new[] {
                new InputBinding(OpenInShowroomCommand, new KeyGesture(Key.H, ModifierKeys.Control)),
                new InputBinding(OpenInShowroomOptionsCommand, new KeyGesture(Key.H, ModifierKeys.Control | ModifierKeys.Shift)),
                new InputBinding(OpenInCustomShowroomCommand, new KeyGesture(Key.H, ModifierKeys.Alt)),
                new InputBinding(OpenInCustomShowroomCommand, new KeyGesture(Key.H, ModifierKeys.Alt | ModifierKeys.Control))
            });
            InitializeComponent();

            CarBlock.BrandArea.PreviewMouseLeftButtonDown += (sender, args) => {
                Tabs.SelectedSource = BrandUri(SelectedCar.Brand);
            };

            CarBlock.ClassArea.PreviewMouseLeftButtonDown += (sender, args) => {
                Tabs.SelectedSource = ClassUri(SelectedCar.CarClass);
            };

            CarBlock.YearArea.PreviewMouseLeftButtonDown += (sender, args) => {
                Tabs.SelectedSource = YearUri(SelectedCar.Year);
            };

            CarBlock.CountryArea.PreviewMouseLeftButtonDown += (sender, args) => {
                Tabs.SelectedSource = CountryUri(SelectedCar.Country);
            };

            Buttons = new [] { OkButton, CancelButton };
        }
Ejemplo n.º 17
0
 public static CarObject Show(CarObject car = null) {
     var dialog = new SelectCarDialog(car ?? CarsManager.Instance.GetDefault());
     dialog.ShowDialog();
     return dialog.IsResultOk ? dialog.SelectedCar : null;
 }
Ejemplo n.º 18
0
 public CarEntry([NotNull] CarObject carObject) {
     CarObject = carObject;
 }
Ejemplo n.º 19
0
 public ViewModel(CarObject carObject, string selectedSkinId) : this(null, carObject, selectedSkinId) {
 }
Ejemplo n.º 20
0
 public static Task StartAsync(CarObject car, CarSkinObject skin = null) {
     return StartAsync(FileUtils.GetMainCarFilename(car.Location), skin?.Id);
 }
Ejemplo n.º 21
0
 private void SelectCarPopup_OnOpened(object sender, EventArgs e) {
     if (SelectedCar == null) {
         SelectedCar = LoadSelected() ?? Model?.PlayerCar ?? CarsManager.Instance.GetDefault();
     }
 }
Ejemplo n.º 22
0
 private void OnCarChanged(CarObject newValue) {
     if (newValue != null) {
         SourcePower = newValue.SpecsPowerCurve;
         SourceTorque = newValue.SpecsTorqueCurve;
     }
 }
Ejemplo n.º 23
0
 public override void OnSelectedUpdated(CarObject selectedCar, TrackObjectBase selectedTrack) {
     RaceGridViewModel.PlayerCar = selectedCar;
     RaceGridViewModel.PlayerTrack = selectedTrack;
 }
Ejemplo n.º 24
0
 public static Task StartAsync(CustomShowroomMode mode, CarObject car, CarSkinObject skin = null) {
     return StartAsync(mode, FileUtils.GetMainCarFilename(car.Location), skin?.Id);
 }
Ejemplo n.º 25
0
 private static int Compare(CarObject l, CarObject r) {
     var le = l.Enabled;
     return le != r.Enabled ? (le ? -1 : 1) : l.DisplayName.InvariantCompareTo(r.DisplayName);
 }
Ejemplo n.º 26
0
 public static bool Run(CarObject carObject, string selectedSkinId, string filterAcId = null) {
     return new ViewModel(string.Empty, carObject, selectedSkinId) {
         ForceFilterAcId = filterAcId
     }.Run();
 }
Ejemplo n.º 27
0
        public RaceGridEntry([NotNull] CarObject car) {
            if (car == null) throw new ArgumentNullException(nameof(car));

            _car = car;
            _aiLevel = null;
        }
Ejemplo n.º 28
0
 public static bool RunPreset(string presetFilename, CarObject carObject, string selectedSkinId) {
     return new ViewModel(File.ReadAllText(presetFilename), carObject, selectedSkinId).Run();
 }
Ejemplo n.º 29
0
 public CarSetupsDirectories(CarObject car) {
     EnabledDirectory = FileUtils.GetCarSetupsDirectory(car.Id);
 }
Ejemplo n.º 30
0
        public CarOpenInShowroomDialog(CarObject carObject, string selectedSkinId) {
            InitializeComponent();
            DataContext = new ViewModel(carObject, selectedSkinId);

            Buttons = new[] { GoButton, CloseButton };
        }