@@ -59,13 +59,6 @@ public class MSTSLocomotiveViewer : MSTSWagonViewer
5959 public bool lemergencybuttonpressed = false ;
6060 CruiseControlViewer CruiseControlViewer ;
6161
62- public Dictionary < CABViewControlTypes , UserCommand [ ] > UserCommandControlTypes = new Dictionary < CABViewControlTypes , UserCommand [ ] > ( ) ;
63-
64- private bool IsMouseWheelChanged ;
65- private DateTime MouseWheelChangedTime ;
66- private int MouseWheelClicks ;
67- private UserCommand MouseWheelCommand ;
68-
6962 public MSTSLocomotiveViewer ( Viewer viewer , MSTSLocomotive car )
7063 : base ( viewer , car )
7164 {
@@ -149,34 +142,19 @@ public override void InitializeUserInputCommands()
149142 // Steam locomotives handle these differently, and might have set them already
150143 if ( ! UserInputCommands . ContainsKey ( UserCommand . ControlForwards ) )
151144 UserInputCommands . Add ( UserCommand . ControlForwards , new Action [ ] { Noop , ( ) => ReverserControlForwards ( ) } ) ;
152-
153145 if ( ! UserInputCommands . ContainsKey ( UserCommand . ControlBackwards ) )
154- {
155146 UserInputCommands . Add ( UserCommand . ControlBackwards , new Action [ ] { Noop , ( ) => ReverserControlBackwards ( ) } ) ;
156- UserCommandControlTypes . Add ( CABViewControlTypes . DIRECTION , new UserCommand [ ] { UserCommand . ControlForwards , UserCommand . ControlBackwards } ) ;
157- }
158147
159148 UserInputCommands . Add ( UserCommand . ControlThrottleIncrease , new Action [ ] { ( ) => Locomotive . StopThrottleIncrease ( ) , ( ) => Locomotive . StartThrottleIncrease ( ) } ) ;
160149 UserInputCommands . Add ( UserCommand . ControlThrottleDecrease , new Action [ ] { ( ) => Locomotive . StopThrottleDecrease ( ) , ( ) => Locomotive . StartThrottleDecrease ( ) } ) ;
161- UserCommandControlTypes . Add ( CABViewControlTypes . THROTTLE , new UserCommand [ ] { UserCommand . ControlThrottleIncrease , UserCommand . ControlThrottleDecrease } ) ;
162- UserCommandControlTypes . Add ( CABViewControlTypes . CP_HANDLE , new UserCommand [ ] { UserCommand . ControlThrottleIncrease , UserCommand . ControlThrottleDecrease } ) ;
163-
164150 UserInputCommands . Add ( UserCommand . ControlThrottleZero , new Action [ ] { Noop , ( ) => Locomotive . ThrottleToZero ( ) } ) ;
165-
166151 UserInputCommands . Add ( UserCommand . ControlGearUp , new Action [ ] { ( ) => StopGearBoxIncrease ( ) , ( ) => StartGearBoxIncrease ( ) } ) ;
167152 UserInputCommands . Add ( UserCommand . ControlGearDown , new Action [ ] { ( ) => StopGearBoxDecrease ( ) , ( ) => StartGearBoxDecrease ( ) } ) ;
168- UserCommandControlTypes . Add ( CABViewControlTypes . GEARS , new UserCommand [ ] { UserCommand . ControlGearUp , UserCommand . ControlGearDown } ) ;
169-
170153 UserInputCommands . Add ( UserCommand . ControlTrainBrakeIncrease , new Action [ ] { ( ) => Locomotive . StopTrainBrakeIncrease ( ) , ( ) => Locomotive . StartTrainBrakeIncrease ( null ) } ) ;
171154 UserInputCommands . Add ( UserCommand . ControlTrainBrakeDecrease , new Action [ ] { ( ) => Locomotive . StopTrainBrakeDecrease ( ) , ( ) => Locomotive . StartTrainBrakeDecrease ( null ) } ) ;
172- UserCommandControlTypes . Add ( CABViewControlTypes . TRAIN_BRAKE , new UserCommand [ ] { UserCommand . ControlTrainBrakeIncrease , UserCommand . ControlTrainBrakeDecrease } ) ;
173-
174155 UserInputCommands . Add ( UserCommand . ControlTrainBrakeZero , new Action [ ] { Noop , ( ) => Locomotive . StartTrainBrakeDecrease ( 0 , true ) } ) ;
175-
176156 UserInputCommands . Add ( UserCommand . ControlEngineBrakeIncrease , new Action [ ] { ( ) => Locomotive . StopEngineBrakeIncrease ( ) , ( ) => Locomotive . StartEngineBrakeIncrease ( null ) } ) ;
177157 UserInputCommands . Add ( UserCommand . ControlEngineBrakeDecrease , new Action [ ] { ( ) => Locomotive . StopEngineBrakeDecrease ( ) , ( ) => Locomotive . StartEngineBrakeDecrease ( null ) } ) ;
178- UserCommandControlTypes . Add ( CABViewControlTypes . ENGINE_BRAKE , new UserCommand [ ] { UserCommand . ControlEngineBrakeIncrease , UserCommand . ControlEngineBrakeDecrease } ) ;
179-
180158 UserInputCommands . Add ( UserCommand . ControlBrakemanBrakeIncrease , new Action [ ] { ( ) => Locomotive . StopBrakemanBrakeIncrease ( ) , ( ) => Locomotive . StartBrakemanBrakeIncrease ( null ) } ) ;
181159 UserInputCommands . Add ( UserCommand . ControlBrakemanBrakeDecrease , new Action [ ] { ( ) => Locomotive . StopBrakemanBrakeDecrease ( ) , ( ) => Locomotive . StartBrakemanBrakeDecrease ( null ) } ) ;
182160 UserInputCommands . Add ( UserCommand . ControlDynamicBrakeIncrease , new Action [ ] { ( ) => Locomotive . StopDynamicBrakeIncrease ( ) , ( ) => Locomotive . StartDynamicBrakeIncrease ( null ) } ) ;
@@ -335,7 +313,7 @@ public override void HandleUserInput(ElapsedTime elapsedTime)
335313
336314 foreach ( var command in UserInputCommands . Keys )
337315 {
338- if ( UserInput . IsPressed ( command ) || IsMouseWheelRotated ( command ) )
316+ if ( UserInput . IsPressed ( command ) )
339317 {
340318 UserInputCommands [ command ] [ 1 ] ( ) ;
341319 //Debrief eval
@@ -354,59 +332,7 @@ public override void HandleUserInput(ElapsedTime elapsedTime)
354332 //Debrief eval
355333 if ( lemergencybuttonpressed && ! Locomotive . EmergencyButtonPressed ) lemergencybuttonpressed = false ;
356334 }
357- else if ( IsMouseWheelChanged && ( DateTime . Now . Subtract ( MouseWheelChangedTime ) . TotalMilliseconds > ( 500 * MouseWheelClicks ) ) && ( command == MouseWheelCommand ) )
358- {
359- UserInputCommands [ command ] [ 0 ] ( ) ;
360- //Debrief eval
361- if ( lemergencybuttonpressed && ! Locomotive . EmergencyButtonPressed ) lemergencybuttonpressed = false ;
362- IsMouseWheelChanged = false ;
363- }
364- }
365- }
366-
367- bool IsMouseWheelRotated ( UserCommand command )
368- {
369- if ( UserInput . IsMouseWheelChanged )
370- {
371- if ( Viewer . Camera is CabCamera && ( this as MSTSLocomotiveViewer ) . _hasCabRenderer )
372- {
373- var cabRenderer = ( this as MSTSLocomotiveViewer ) . _CabRenderer ;
374- foreach ( var controlRenderer in cabRenderer . ControlMap . Values )
375- {
376- if ( ( Viewer . Camera as CabCamera ) . SideLocation == controlRenderer . Control . CabViewpoint && controlRenderer is ICabViewMouseControlRenderer mouseRenderer )
377- {
378- if ( mouseRenderer . IsMouseWithin ( ) )
379- {
380- UserCommand [ ] userCommands ;
381- UserCommandControlTypes . TryGetValue ( controlRenderer . Control . ControlType . Type , out userCommands ) ;
382- if ( userCommands != null )
383- {
384- // check if user command (e.g. ControlThrottleIncrease) equals control type (e.g. THROTTLE)
385- if ( ( ( command == userCommands [ 0 ] ) && ( UserInput . MouseWheelChange > 0 ) ) ||
386- ( ( command == userCommands [ 1 ] ) && ( UserInput . MouseWheelChange < 0 ) ) )
387- {
388- if ( ! IsMouseWheelChanged )
389- {
390- IsMouseWheelChanged = true ;
391- MouseWheelChangedTime = DateTime . Now ;
392- MouseWheelClicks = 1 ;
393- MouseWheelCommand = command ;
394- }
395- else
396- {
397- MouseWheelClicks += 1 ;
398- }
399- return true ;
400- }
401- }
402- break ;
403- }
404- }
405- }
406- }
407335 }
408-
409- return false ;
410336 }
411337
412338 /// <summary>
@@ -1773,8 +1699,6 @@ public interface ICabViewMouseControlRenderer
17731699 void HandleUserInput ( ) ;
17741700 string GetControlName ( ) ;
17751701 string ControlLabel { get ; }
1776- Rectangle DestinationRectangleGet ( ) ;
1777- bool isMouseControl ( ) ;
17781702 }
17791703
17801704 /// <summary>
@@ -2110,24 +2034,11 @@ public CabViewDiscreteRenderer(Viewer viewer, MSTSLocomotive locomotive, CVCWith
21102034 ChangedValue = ( value ) =>
21112035 {
21122036 IntermediateValue %= 0.5f ;
2113- if ( UserInput . IsMouseLeftButtonDown )
2114- {
21152037 IntermediateValue += NormalizedMouseMovement ( ) ;
2116- }
2117- else
2118- {
2119- // mousewheel
2120- IntermediateValue += ( float ) UserInput . MouseWheelChange / 700 ;
2121- }
21222038 return IntermediateValue > 0.5f ? 1 : IntermediateValue < - 0.5f ? - 1 : 0 ;
21232039 } ;
21242040 break ;
2125- default :
2126- ChangedValue = ( value ) =>
2127- {
2128- return value + NormalizedMouseMovement ( ) ;
2129- } ;
2130- break ;
2041+ default : ChangedValue = ( value ) => value + NormalizedMouseMovement ( ) ; break ;
21312042 }
21322043 // Determine the cab view control index shown when combined control is at the split position
21332044 // Find the index of the next value LARGER than the split value
@@ -2422,22 +2333,11 @@ public virtual int GetDrawIndex()
24222333 /// </summary>
24232334 float NormalizedMouseMovement ( )
24242335 {
2425- if ( UserInput . IsMouseLeftButtonDown )
2426- {
24272336 return ( ControlDiscrete . Orientation > 0
24282337 ? ( float ) UserInput . MouseMoveY / ( float ) Control . Height
24292338 : ( float ) UserInput . MouseMoveX / ( float ) Control . Width )
24302339 * ( ControlDiscrete . Direction > 0 ? - 1 : 1 ) ;
24312340 }
2432- else
2433- {
2434- // mousewheel
2435- return ( ControlDiscrete . Orientation > 0
2436- ? ( float ) UserInput . MouseWheelChange / ( float ) 1500
2437- : ( float ) UserInput . MouseWheelChange / ( float ) 1500 )
2438- * ( ControlDiscrete . Direction > 0 ? - 1 : 1 ) ;
2439- }
2440- }
24412341
24422342 public bool IsMouseWithin ( )
24432343 {
@@ -2955,16 +2855,6 @@ protected int PercentToIndex(float percent)
29552855
29562856 return index ;
29572857 }
2958-
2959- public Rectangle DestinationRectangleGet ( )
2960- {
2961- return DestinationRectangle ;
2962- }
2963-
2964- public bool isMouseControl ( )
2965- {
2966- return ControlDiscrete . MouseControl ;
2967- }
29682858 }
29692859
29702860 /// <summary>
0 commit comments