Skip to content

Commit 685315b

Browse files
committed
Revert the public decorations
1 parent 697a4b6 commit 685315b

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
@@ -83,7 +83,7 @@ internal override void EndRender(RenderFrame frame)
8383
double[] AverageElapsedRealTime = new double[10];
8484
int AverageElapsedRealTimeIndex;
8585

86-
public override void Update(RenderFrame frame, double totalRealSeconds)
86+
internal override void Update(RenderFrame frame, double totalRealSeconds)
8787
{
8888
// Every 250ms, check for new things to load and kick off the loader.
8989
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
@@ -157,7 +157,7 @@ void GDM_PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs
157157
pp.RenderTargetUsage = RenderTargetUsage.PreserveContents;
158158
}
159159

160-
public void Start()
160+
internal void Start()
161161
{
162162
Game.WatchdogProcess.Register(WatchdogToken);
163163

0 commit comments

Comments
 (0)