Skip to content

Commit 45e8945

Browse files
committed
Automatic merge of T1.5.1-757-gef6c1a8c8 and 17 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 #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 356b543: Blueprint/train car operations UI window - Pull request #885 at c81447b: feat: Add notifications to Menu - Pull request #886 at 167e2e4: 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
19 parents 3f9d5d6 + ef6c1a8 + 3539862 + d00beb9 + f8dbeab + 43bf33e + f92de76 + 356b543 + c81447b + 167e2e4 + d7daf62 + 39a9fa4 + 1f5ba4c + bf8876b + 794fddf + 5866028 + 0a9d939 + e271395 + 42ea7ad commit 45e8945

File tree

6 files changed

+189
-264
lines changed

6 files changed

+189
-264
lines changed

Source/Contrib/TrackViewer/Drawing/Labels/DrawLabels.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private void CreateContextMenu()
156156

157157
SetLocationMenuItem = new MenuItem() { Header = "View scene here" };
158158
SetLocationMenuItem.Click += new RoutedEventHandler((sender, e) => TrackViewer.menuControl.MenuSceneWindow_Click(sender, e));
159-
SetLocationMenuItem.Click += new RoutedEventHandler(async (sender, e) => await TrackViewer.SceneViewer?.SetCameraLocation(
159+
SetLocationMenuItem.Click += new RoutedEventHandler(async (sender, e) => await TrackViewer.SceneView?.SetCameraLocation(
160160
SetLocationMenuItem.CommandParameter as WorldLocation? ?? new WorldLocation()));
161161
ContextMenu.Items.Add(SetLocationMenuItem);
162162
}

Source/Contrib/TrackViewer/TrackViewer.cs

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ namespace ORTS.TrackViewer
5353
public class TrackViewer : Orts.Viewer3D.Processes.Game
5454
{
5555
#region Public members
56-
public SceneViewer SceneViewer { get; private set; }
5756
private static RenderTarget2D DummyRenderTarget;
5857
public bool IsTrackViewerWindowActive { get; private set; }
5958

@@ -132,6 +131,9 @@ public class TrackViewer : Orts.Viewer3D.Processes.Game
132131

133132
/// <summary>The fontmanager that we use to draw strings</summary>
134133
public FontManager fontManager;
134+
135+
public SceneView SceneView;
136+
135137
/// <summary>The command-line arguments</summary>
136138
private string[] commandLineArgs;
137139
#endregion
@@ -173,8 +175,8 @@ public TrackViewer(string[] args) : base(new ORTS.Settings.UserSettings(new[] {
173175
LanguageManager = new LanguageManager();
174176
LanguageManager.LoadLanguage(); // need this before all menus and stuff are initialized.
175177

176-
this.Activated += ActivateTrackViewer;
177-
this.Deactivated += DeactivateTrackViewer;
178+
Activated += ActivateTrackViewer;
179+
Deactivated += DeactivateTrackViewer;
178180

179181
PushState(new GameStateStandBy());
180182
}
@@ -236,9 +238,48 @@ protected override void Initialize()
236238
base.Initialize();
237239
}
238240

239-
public void InitializeSceneViewer(string[] args)
241+
public void InitializeSceneView(string[] args)
240242
{
241-
SceneViewer = SceneViewer ?? new SceneViewer(this, args);
243+
// Inject the secondary window into RunActivity
244+
SwapChainWindow = GameWindow.Create(this,
245+
GraphicsDevice.PresentationParameters.BackBufferWidth,
246+
GraphicsDevice.PresentationParameters.BackBufferHeight);
247+
248+
RenderFrame.FinalRenderTarget = new SwapChainRenderTarget(GraphicsDevice,
249+
SwapChainWindow.Handle,
250+
GraphicsDevice.PresentationParameters.BackBufferWidth,
251+
GraphicsDevice.PresentationParameters.BackBufferHeight,
252+
false,
253+
GraphicsDevice.PresentationParameters.BackBufferFormat,
254+
GraphicsDevice.PresentationParameters.DepthStencilFormat,
255+
1,
256+
RenderTargetUsage.PlatformContents,
257+
PresentInterval.Two);
258+
259+
SceneView = new SceneView(SwapChainWindow.Handle);
260+
261+
// The primary window activation events should not affect RunActivity
262+
Activated -= ActivateRunActivity;
263+
Deactivated -= DeactivateRunActivity;
264+
265+
/// A workaround for a MonoGame bug where the <see cref="Microsoft.Xna.Framework.Input.Keyboard.GetState()" />
266+
/// doesn't return the valid keyboard state. Needs to be enabled via reflection in a private method.
267+
var keyboardSetActive = typeof(Microsoft.Xna.Framework.Input.Keyboard)
268+
.GetMethod("SetActive", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
269+
270+
// The secondary window activation events should affect RunActivity
271+
SceneView.Activated += ActivateRunActivity;
272+
SceneView.Activated += new System.EventHandler((sender, e) => keyboardSetActive.Invoke(null, new object[] { true }));
273+
SceneView.Deactivated += DeactivateRunActivity;
274+
SceneView.Deactivated += new System.EventHandler((sender, e) => keyboardSetActive.Invoke(null, new object[] { false }));
275+
276+
ReplaceState(new GameStateRunActivity(new[] { "-start", "-viewer", CurrentRoute.Path + "\\dummy\\.pat", "", "10:00", "1", "0" }));
277+
}
278+
279+
public void ShowSceneView()
280+
{
281+
SceneView.Show();
282+
SceneView.Activate();
242283
}
243284

244285
/// <summary>
@@ -324,7 +365,11 @@ private void DrawLoadingMessage(string message)
324365
/// <param name="gameTime">Provides a snapshot of timing values.</param>
325366
protected override void Update(GameTime gameTime)
326367
{
327-
SceneViewer?.Update(gameTime);
368+
if (RenderProcess?.Viewer != null && SceneView != null)
369+
{
370+
SceneView.Viewer = SceneView.Viewer ?? RenderProcess.Viewer;
371+
SceneView.Update(gameTime);
372+
}
328373

329374
if (!this.IsTrackViewerWindowActive)
330375
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,8 +1232,8 @@ public void MenuSceneWindow_Click(object sender, RoutedEventArgs e)
12321232
{
12331233
if (trackViewer.CurrentRoute == null)
12341234
return;
1235-
trackViewer.InitializeSceneViewer(null);
1236-
trackViewer.SceneViewer.Show();
1235+
trackViewer.InitializeSceneView(null);
1236+
trackViewer.ShowSceneView();
12371237
}
12381238
}
12391239

Source/Contrib/TrackViewer/UserInterface/SceneWindow.xaml renamed to Source/Contrib/TrackViewer/UserInterface/SceneView.xaml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
1-
<Window x:Class="ORTS.TrackViewer.UserInterface.SceneWindow"
1+
<Window x:Class="ORTS.TrackViewer.UserInterface.SceneView"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6-
xmlns:local="clr-namespace:ORTS.TrackViewer"
6+
xmlns:local="clr-namespace:ORTS.TrackViewer.UserInterface"
77
mc:Ignorable="d"
8-
Name="window"
9-
d:DataContext="{d:DesignInstance local:SceneViewer, IsDesignTimeCreatable=False}"
108
Title="Scene View" SizeToContent="WidthAndHeight">
9+
<Window.CommandBindings>
10+
<CommandBinding Command="Undo" Executed="UndoCommand" CanExecute="UndoRedoCanExecute"/>
11+
<CommandBinding Command="Redo" Executed="RedoCommand" CanExecute="UndoRedoCanExecute"/>
12+
<CommandBinding Command="Stop" Executed="CancelCommand"/>
13+
<CommandBinding Command="MoveLeft" Executed="RotateCommand"/>
14+
<CommandBinding Command="MoveRight" Executed="MoveCommand"/>
15+
<CommandBinding Command="MoveUp" Executed="MoveHandleCommand"/>
16+
</Window.CommandBindings>
17+
<Window.InputBindings>
18+
<KeyBinding Key="Esc" Command="Stop"/><!--This doesn't work-->
19+
<KeyBinding Key="M" Command="MoveRight"/>
20+
<KeyBinding Key="R" Command="MoveLeft"/>
21+
<KeyBinding Key="H" Command="MoveUp"/>
22+
</Window.InputBindings>
1123
<DockPanel LastChildFill="True">
1224
<Menu DockPanel.Dock="Top" Height="22" Name="menuMain" Width="Auto">
1325
<MenuItem Header="_File">
@@ -17,9 +29,9 @@
1729
<MenuItem Header="_Undo" Name="menuUndo" Command="Undo" InputGestureText="Ctrl+Z"/>
1830
<MenuItem Header="_Redo" Name="menuRedo" Command="Redo" InputGestureText="Ctrl+Y"/>
1931
<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"/>
32+
<MenuItem Header="_Move" Name="menuName" Command="MoveRight" InputGestureText="M"/>
33+
<MenuItem Header="_Rotate" Name="menuRotate" Command="MoveLeft" InputGestureText="R"/>
34+
<MenuItem Header="Move _handle" Name="menuHandle" Command="MoveUp" InputGestureText="H"/>
2335
</MenuItem>
2436
<MenuItem Header="_View">
2537
<MenuItem Header="Nothing to see here" Name="menuNothing3" />
@@ -112,21 +124,21 @@
112124
<StatusBarItem Grid.Column="12">
113125
<Border BorderThickness="1 1 0 0" BorderBrush="Gray">
114126
<Border BorderThickness="0 0 1 1" BorderBrush="AntiqueWhite">
115-
<TextBlock Name="DeltaX" Width="55" TextAlignment="Right" Background="#FFF7DCDC"/>
127+
<TextBlock Name="DeltaXBlock" Width="55" TextAlignment="Right" Background="#FFF7DCDC"/>
116128
</Border>
117129
</Border>
118130
</StatusBarItem>
119131
<StatusBarItem Grid.Column="13">
120132
<Border BorderThickness="1 1 0 0" BorderBrush="Gray">
121133
<Border BorderThickness="0 0 1 1" BorderBrush="AntiqueWhite">
122-
<TextBlock Name="DeltaY" Width="55" TextAlignment="Right" Background="#FFC3CFFB"/>
134+
<TextBlock Name="DeltaYBlock" Width="55" TextAlignment="Right" Background="#FFC3CFFB"/>
123135
</Border>
124136
</Border>
125137
</StatusBarItem>
126138
<StatusBarItem Grid.Column="14">
127139
<Border BorderThickness="1 1 0 0" BorderBrush="Gray">
128140
<Border BorderThickness="0 0 1 1" BorderBrush="AntiqueWhite">
129-
<TextBlock Name="DeltaZ" Width="55" TextAlignment="Right" Background="#FFCDF9D8"/>
141+
<TextBlock Name="DeltaZBlock" Width="55" TextAlignment="Right" Background="#FFCDF9D8"/>
130142
</Border>
131143
</Border>
132144
</StatusBarItem>
@@ -179,8 +191,4 @@
179191
</Border>
180192
<Grid DockPanel.Dock="Bottom" x:Name="GraphicsHostElement" />
181193
</DockPanel>
182-
<Window.CommandBindings>
183-
<!--CommandBinding Command="Undo" Executed="{Binding UndoCommand}"/>
184-
<CommandBinding Command="Redo" Executed="{Binding RedoCommand}"/-->
185-
</Window.CommandBindings>
186194
</Window>

0 commit comments

Comments
 (0)