@@ -46,11 +46,11 @@ public VehicleViewModel(VehicleObject model) : base(model)
4646
4747 #region Road/Track Type Binding
4848
49- _ = this . WhenAnyValue ( x => x . Mode , x => x . Flags )
50- . Subscribe ( ( _ ) => this . RaisePropertyChanged ( nameof ( IsTrackTypeSettable ) ) ) ;
49+ // _ = this.WhenAnyValue(x => x.Mode, x => x.Flags)
50+ // .Subscribe((_) => this.RaisePropertyChanged(nameof(AnyRoadOrTrackType )));
5151
52- _ = this . WhenAnyValue ( x => x . IsTrackTypeSettable )
53- . Subscribe ( ( _ ) => this . RaisePropertyChanged ( nameof ( RoadOrTrackType ) ) ) ;
52+ // _ = this.WhenAnyValue(x => x.AnyRoadOrTrackType )
53+ // .Subscribe((_) => this.RaisePropertyChanged(nameof(RoadOrTrackType)));
5454
5555 #endregion
5656
@@ -163,7 +163,7 @@ public Speed16 RackSpeed
163163 set => model . RackSpeed = value ;
164164 }
165165
166- [ EnumProhibitValues < VehicleObjectFlags > ( VehicleObjectFlags . None , VehicleObjectFlags . RackRail ) ]
166+ [ EnumProhibitValues < VehicleObjectFlags > ( VehicleObjectFlags . None , VehicleObjectFlags . RackRail , VehicleObjectFlags . AnyRoadType ) ]
167167 public VehicleObjectFlags Flags
168168 {
169169 get => model . Flags ;
@@ -174,12 +174,26 @@ public VehicleObjectFlags Flags
174174 }
175175 }
176176
177- [ Browsable ( false ) ]
178- bool IsTrackTypeSettable
179- => ! model . Flags . HasFlag ( VehicleObjectFlags . AnyRoadType ) && ( model . Mode == TransportMode . Rail || model . Mode == TransportMode . Road ) ;
177+ [ ConditionTarget ]
178+ //bool IsTrackTypeSettable
179+ // => !model.Flags.HasFlag(VehicleObjectFlags.AnyRoadType) && (model.Mode == TransportMode.Rail || model.Mode == TransportMode.Road);
180+ public bool AnyRoadOrTrackType
181+ {
182+ get => model . Flags . HasFlag ( VehicleObjectFlags . AnyRoadType ) ;
183+ set
184+ {
185+ model . Flags = model . Flags . ToggleFlag ( VehicleObjectFlags . AnyRoadType , value ) ;
180186
187+ if ( RoadOrTrackType == null && model . Flags . HasFlag ( VehicleObjectFlags . AnyRoadType ) )
188+ {
189+ RoadOrTrackType = new ObjectModelHeader ( ) { Name = "<obj>" , ObjectSource = ObjectSource . Custom , ObjectType = ObjectType . Road } ;
190+ }
191+
192+ this . RaisePropertyChanged ( nameof ( RoadOrTrackType ) ) ;
193+ }
194+ }
181195 [ ConditionTarget ]
182- [ PropertyVisibilityCondition ( nameof ( IsTrackTypeSettable ) , true ) ]
196+ [ PropertyVisibilityCondition ( nameof ( AnyRoadOrTrackType ) , false ) ]
183197 public ObjectModelHeader ? RoadOrTrackType
184198 {
185199 get => model . RoadOrTrackType ;
0 commit comments