Skip to content

Commit e2c6270

Browse files
committed
Automatic merge of T1.5.1-722-g01614a154 and 18 pull requests
- Pull request #570 at 3539862: Experimental glTF 2.0 support with PBR lighting - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #865 at 3b5a2fe: Dispatcher window improvements - Pull request #874 at f8dbeab: Dynamic brake controller refactoring - Pull request #875 at 43bf33e: Bug fix for https://bugs.launchpad.net/or/+bug/2036346 Player train switching doesn't work with 3D cabs - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder - Pull request #882 at 481ed9d: Blueprint/train car operations UI window - Pull request #885 at c81447b: feat: Add notifications to Menu - Pull request #886 at 685315b: Scene viewer extension to TrackViewer - Pull request #888 at d7daf62: docs: Document player application model - Pull request #890 at 39a9fa4: Allow depart early - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #893 at bf8876b: Signal errors - Pull request #894 at 794fddf: Correct Decrease Colour - Pull request #896 at 5866028: First implementation of https://blueprints.launchpad.net/or/+spec/specific-sounds-for-ai-trains - Pull request #897 at 0a9d939: feat: Improved system information collection - Pull request #898 at e271395: Extra line with all the arguments for debugging purposes in logfile - Pull request #900 at 42ea7ad: DMI updates
20 parents a609d1a + 01614a1 + 3539862 + d00beb9 + 3b5a2fe + f8dbeab + 43bf33e + f92de76 + 481ed9d + c81447b + 685315b + d7daf62 + 39a9fa4 + 1f5ba4c + bf8876b + 794fddf + 5866028 + 0a9d939 + e271395 + 42ea7ad commit e2c6270

File tree

7 files changed

+46
-15
lines changed

7 files changed

+46
-15
lines changed

Source/Contrib/TrackViewer/SceneViewer.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public class SceneViewer
6464
float DeltaX, DeltaY, DeltaZ;
6565
UndoDataSet DeltaContext;
6666
WorldLocation CursorLocation;
67+
readonly List<(int TileX, int TileZ)> FlaggedTiles = new List<(int, int)>();
6768

6869
public SceneViewer(TrackViewer trackViewer, string[] args)
6970
{
@@ -87,7 +88,10 @@ public SceneViewer(TrackViewer trackViewer, string[] args)
8788
RenderTargetUsage.PlatformContents,
8889
PresentInterval.Two);
8990

90-
SceneWindow = new SceneWindow(new SceneViewerHwndHost(Game.SwapChainWindow.Handle));
91+
SceneWindow = new SceneWindow(new SceneViewerHwndHost(Game.SwapChainWindow.Handle))
92+
{
93+
DataContext = this,
94+
};
9195

9296
// The primary window activation events should not affect RunActivity
9397
Game.Activated -= Game.ActivateRunActivity;
@@ -99,8 +103,6 @@ public SceneViewer(TrackViewer trackViewer, string[] args)
99103
SceneWindow.Deactivated += Game.DeactivateRunActivity;
100104
SceneWindow.Deactivated += new System.EventHandler((sender, e) => SetKeyboardInput(false));
101105

102-
SceneWindow.DataContext = this;
103-
104106
Game.ReplaceState(new GameStateRunActivity(new[] { "-start", "-viewer", Game.CurrentRoute.Path + "\\dummy\\.pat", "", "10:00", "1", "0" }));
105107
}
106108

@@ -138,12 +140,10 @@ public void Update(GameTime gameTime)
138140
}
139141
if (UserInput.IsPressed(UserCommand.EditorUndo))
140142
{
141-
SetDefaultMode();
142143
UndoCommand();
143144
}
144145
if (UserInput.IsPressed(UserCommand.EditorRedo))
145146
{
146-
SetDefaultMode();
147147
RedoCommand();
148148
}
149149
}
@@ -436,15 +436,16 @@ void UpdateViewUndoState()
436436
}
437437
}
438438

439-
void SetDefaultMode()
439+
public void SetDefaultMode()
440440
{
441441
SelectedObject = null;
442442
SelectedObjectChanged();
443443
EditorState = EditorState.Default;
444444
}
445445

446-
void UndoCommand()
446+
public void UndoCommand()
447447
{
448+
SetDefaultMode();
448449
if (UndoStack.Count > 1)
449450
{
450451
var undoDataSet = UndoStack.Pop();
@@ -453,8 +454,9 @@ void UndoCommand()
453454
}
454455
}
455456

456-
void RedoCommand()
457+
public void RedoCommand()
457458
{
459+
SetDefaultMode();
458460
if (RedoStack.Count > 0)
459461
{
460462
var undoDataSet = RedoStack.Pop();
@@ -477,10 +479,13 @@ void UndoRedo(UndoDataSet undoDataSet, bool undo)
477479
var newPosition = new WorldPosition(undoDataSet.ChangedStaticShape.Location);
478480
undoDataSet.ChangedStaticShape.Location.CopyFrom(undoDataSet.OldPosition);
479481
undoDataSet.OldPosition.CopyFrom(newPosition);
482+
var flag = (undoDataSet.ChangedStaticShape.Location.TileX, undoDataSet.ChangedStaticShape.Location.TileZ);
483+
if (!FlaggedTiles.Contains(flag))
484+
FlaggedTiles.Add(flag);
480485
}
481486
}
482487

483-
void StartObjectMove()
488+
public void StartObjectMove()
484489
{
485490
MovedObject = SelectedObject;
486491
MovedObjectOriginalPosition = new WorldPosition(MovedObject.Location);
@@ -516,7 +521,7 @@ void ApplyObjectMove()
516521
EditorState = EditorState.ObjectSelected;
517522
}
518523

519-
void StartHandleMove()
524+
public void StartHandleMove()
520525
{
521526
HandlePosition = new WorldPosition(SelectedObject.Location);
522527
HandleOriginalPosition = new WorldPosition(HandlePosition);

Source/Contrib/TrackViewer/UserInterface/SceneWindow.xaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,25 @@
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
xmlns:local="clr-namespace:ORTS.TrackViewer"
77
mc:Ignorable="d"
8+
Name="window"
89
d:DataContext="{d:DesignInstance local:SceneViewer, IsDesignTimeCreatable=False}"
910
Title="Scene View" SizeToContent="WidthAndHeight">
1011
<DockPanel LastChildFill="True">
1112
<Menu DockPanel.Dock="Top" Height="22" Name="menuMain" Width="Auto">
12-
<MenuItem Header="_Menu" Name="menuMenu">
13+
<MenuItem Header="_File">
1314
<MenuItem Header="Nothing to see here" Name="menuNothing" />
1415
</MenuItem>
16+
<MenuItem Header="_Edit">
17+
<MenuItem Header="_Undo" Name="menuUndo" Command="Undo" InputGestureText="Ctrl+Z"/>
18+
<MenuItem Header="_Redo" Name="menuRedo" Command="Redo" InputGestureText="Ctrl+Y"/>
19+
<Separator/>
20+
<MenuItem Header="_Move" Name="menuName" InputGestureText="M"/>
21+
<MenuItem Header="_Rotate" Name="menuRotate" InputGestureText="R"/>
22+
<MenuItem Header="Move _handle" Name="menuHandle" InputGestureText="H"/>
23+
</MenuItem>
24+
<MenuItem Header="_View">
25+
<MenuItem Header="Nothing to see here" Name="menuNothing3" />
26+
</MenuItem>
1527
</Menu>
1628
<StatusBar DockPanel.Dock="Bottom" Name="tvStatusbar" Height="22" VerticalAlignment="Bottom">
1729
<StatusBar.ItemsPanel>
@@ -167,4 +179,8 @@
167179
</Border>
168180
<Grid DockPanel.Dock="Bottom" x:Name="GraphicsHostElement" />
169181
</DockPanel>
182+
<Window.CommandBindings>
183+
<!--CommandBinding Command="Undo" Executed="{Binding UndoCommand}"/>
184+
<CommandBinding Command="Redo" Executed="{Binding RedoCommand}"/-->
185+
</Window.CommandBindings>
170186
</Window>

Source/Contrib/TrackViewer/UserInterface/SceneWindow.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,15 @@ private void FloatValidationTextBox(object sender, TextCompositionEventArgs e)
5151
{
5252
e.Handled = float.TryParse(e.Text, out var _);
5353
}
54+
55+
private void UndoCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
56+
{
57+
(DataContext as SceneViewer).UndoCommand();
58+
}
59+
60+
private void RedoCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
61+
{
62+
(DataContext as SceneViewer).RedoCommand();
63+
}
5464
}
5565
}

Source/RunActivity/Viewer3D/Processes/GameState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ internal virtual void EndRender(RenderFrame frame)
5252
/// <param name="frame">The new <see cref="RenderFrame"/> that needs populating.</param>
5353
/// <param name="totalRealSeconds">The total number of real-world seconds which have elapsed since the game was started.</param>
5454
[CallOnThread("Updater")]
55-
public virtual void Update(RenderFrame frame, double totalRealSeconds)
55+
internal virtual void Update(RenderFrame frame, double totalRealSeconds)
5656
{
5757
// By default, every update tries to trigger a load.
5858
if (Game.LoaderProcess.Finished)

Source/RunActivity/Viewer3D/Processes/GameStateRunActivity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ internal override void Dispose()
118118
base.Dispose();
119119
}
120120

121-
public override void Update(RenderFrame frame, double totalRealSeconds)
121+
internal override void Update(RenderFrame frame, double totalRealSeconds)
122122
{
123123
UpdateLoading();
124124

Source/RunActivity/Viewer3D/Processes/GameStateViewer3D.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ internal override void EndRender(RenderFrame frame)
8282
double[] AverageElapsedRealTime = new double[10];
8383
int AverageElapsedRealTimeIndex;
8484

85-
public override void Update(RenderFrame frame, double totalRealSeconds)
85+
internal override void Update(RenderFrame frame, double totalRealSeconds)
8686
{
8787
// Every 250ms, check for new things to load and kick off the loader.
8888
if (LastLoadRealTime + 0.25 < totalRealSeconds && Game.LoaderProcess.Finished)

Source/RunActivity/Viewer3D/Processes/RenderProcess.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void GDM_PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs
165165
pp.RenderTargetUsage = RenderTargetUsage.PreserveContents;
166166
}
167167

168-
public void Start()
168+
internal void Start()
169169
{
170170
Game.WatchdogProcess.Register(WatchdogToken);
171171

0 commit comments

Comments
 (0)