Skip to content

Commit dacf46f

Browse files
committed
Automatic merge of T1.5.1-1288-g58b2418aa6 and 14 pull requests
- Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #891 at 9a1d6b2: Auto save - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #952 at 8347095: Investigation - Pulsing graphics - Pull request #953 at a519452: Fix Lights Crash on Corrupt Shapes - Pull request #954 at e4ba0d7: Multiple Track Profiles & Superelevation Rewrite - Pull request #972 at e90a2aa: On Map window color changed switch or signal is not changed - Pull request #981 at 10d297f: Multiple type trainset lightglows - Pull request #982 at efcf19c: WEB based Switch Panel enhancement: Alerter - Pull request #984 at 0f8122e: Player train switching for timetable mode - Pull request #986 at 5d7e692: Fix: The TrainCarOperations window does not resize correctly. - Pull request #987 at 232e8fb: fix: Temporary workaround for building with NET 5+ - Pull request #900 at c27f32d: DMI updates - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder
16 parents aa40f6c + 58b2418 + d00beb9 + 9a1d6b2 + 1f5ba4c + 8347095 + a519452 + e4ba0d7 + e90a2aa + 10d297f + efcf19c + 0f8122e + 5d7e692 + 232e8fb + c27f32d + f92de76 commit dacf46f

File tree

5 files changed

+144
-3
lines changed

5 files changed

+144
-3
lines changed

Source/Menu/Options.Designer.cs

Lines changed: 73 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/Menu/Options.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ public OptionsForm(UserSettings settings, UpdateManager updateManager, bool init
165165
comboPressureUnit.Text = Settings.PressureUnit;
166166
comboOtherUnits.Text = settings.Units;
167167
checkEnableTCSScripts.Checked = !Settings.DisableTCSScripts; // Inverted as "Enable scripts" is better UI than "Disable scripts"
168+
checkAutoSaveActive.Checked = Settings.AutoSaveActive;
169+
ButtonAutoSave15.Checked = checkAutoSaveActive.Checked & Settings.AutoSaveInterval == 15;
170+
ButtonAutoSave30.Checked = checkAutoSaveActive.Checked & Settings.AutoSaveInterval == 30;
171+
ButtonAutoSave60.Checked = checkAutoSaveActive.Checked & Settings.AutoSaveInterval == 60;
168172

169173
// Audio tab
170174
numericSoundVolumePercent.Value = Settings.SoundVolumePercent;
@@ -456,6 +460,8 @@ void buttonOK_Click(object sender, EventArgs e)
456460
Settings.PressureUnit = comboPressureUnit.SelectedValue.ToString();
457461
Settings.Units = comboOtherUnits.SelectedValue.ToString();
458462
Settings.DisableTCSScripts = !checkEnableTCSScripts.Checked; // Inverted as "Enable scripts" is better UI than "Disable scripts"
463+
Settings.AutoSaveActive = checkAutoSaveActive.Checked;
464+
Settings.AutoSaveInterval = ButtonAutoSave15.Checked ? 15 : ButtonAutoSave30.Checked ? 30 : 60;
459465

460466
// Audio tab
461467
Settings.SoundVolumePercent = (int)numericSoundVolumePercent.Value;
@@ -807,6 +813,50 @@ private void checkPerformanceTuner_Click(object sender, EventArgs e)
807813
labelPerformanceTunerTarget.Enabled = checkPerformanceTuner.Checked;
808814
}
809815

816+
private void checkAutoSave_checkchanged(object sender, EventArgs e)
817+
{
818+
if (checkAutoSaveActive.Checked)
819+
{
820+
ButtonAutoSave15.Enabled = true;
821+
ButtonAutoSave15.Checked = Settings.AutoSaveInterval == 15;
822+
ButtonAutoSave30.Enabled = true;
823+
ButtonAutoSave30.Checked = Settings.AutoSaveInterval == 30;
824+
ButtonAutoSave60.Enabled = true;
825+
ButtonAutoSave60.Checked = Settings.AutoSaveInterval == 60;
826+
}
827+
else
828+
{
829+
ButtonAutoSave15.Checked = false;
830+
ButtonAutoSave15.Enabled = false;
831+
ButtonAutoSave30.Checked = false;
832+
ButtonAutoSave30.Enabled = false;
833+
ButtonAutoSave60.Checked = false;
834+
ButtonAutoSave60.Enabled = false;
835+
}
836+
}
837+
838+
private void buttonAutoSaveInterval_checkchanged(object sender, EventArgs e)
839+
{
840+
if (ButtonAutoSave15.Checked)
841+
{
842+
Settings.AutoSaveInterval = 15;
843+
ButtonAutoSave30.Checked = false;
844+
ButtonAutoSave60.Checked = false;
845+
}
846+
else if (ButtonAutoSave30.Checked)
847+
{
848+
Settings.AutoSaveInterval = 30;
849+
ButtonAutoSave15.Checked = false;
850+
ButtonAutoSave60.Checked = false;
851+
}
852+
else if (ButtonAutoSave60.Checked)
853+
{
854+
Settings.AutoSaveInterval = 60;
855+
ButtonAutoSave15.Checked = false;
856+
ButtonAutoSave30.Checked = false;
857+
}
858+
}
859+
810860
#region Help for Options
811861
// The icons all share the same code which assumes they are named according to a simple scheme as follows:
812862
// 1. To add a new Help Icon, copy an existing one and paste it onto the tab.

Source/ORTS.Settings/UserSettings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ public enum DirectXFeature
168168
public String Units { get; set; }
169169
[Default(false)]
170170
public bool DisableTCSScripts { get; set; }
171+
[Default(false)]
172+
public bool AutoSaveActive { get; set; }
173+
[Default (15)]
174+
public int AutoSaveInterval { get; set; }
171175

172176
// Audio settings:
173177
[Default(100)]

Source/RunActivity/Viewer3D/Popups/QuitWindow.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void buttonQuit_Click(Control arg1, Point arg2)
7070
void buttonSave_Click(Control arg1, Point arg2)
7171
{
7272
GameStateRunActivity.Save();
73+
Owner.Viewer.LastSave = Owner.Viewer.RealTime + 60 * Owner.Viewer.Simulator.Settings.AutoSaveInterval;
7374
}
7475

7576
void buttonContinue_Click(Control arg1, Point arg2)

Source/RunActivity/Viewer3D/Viewer.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public class Viewer
7979
/// Monotonically increasing time value (in seconds) for the game/viewer. Starts at 0 and only ever increases, at real-time.
8080
/// </summary>
8181
public double RealTime { get; private set; }
82+
public double LastSave = -1;
8283
InfoDisplay InfoDisplay;
8384
public WindowManager WindowManager { get; private set; }
8485
public MessagesWindow MessagesWindow { get; private set; } // Game message window (special, always visible)
@@ -307,6 +308,8 @@ public Viewer(Simulator simulator, Orts.Viewer3D.Processes.Game game)
307308
Settings = simulator.Settings;
308309
Use3DCabProperty = Settings.GetSavingProperty<bool>("Use3DCab");
309310

311+
LastSave = Simulator.Settings.AutoSaveInterval * 60;
312+
310313
RenderProcess = game.RenderProcess;
311314
UpdaterProcess = game.UpdaterProcess;
312315
LoaderProcess = game.LoaderProcess;
@@ -758,6 +761,14 @@ public void Update(RenderFrame frame, float elapsedRealTime)
758761
RealTime += elapsedRealTime;
759762
var elapsedTime = new ElapsedTime(Simulator.GetElapsedClockSeconds(elapsedRealTime), elapsedRealTime);
760763

764+
// auto save
765+
if (Simulator.Settings.AutoSaveActive && RealTime > LastSave && !Simulator.Paused)
766+
{
767+
GameStateRunActivity.Save();
768+
LastSave = RealTime + Simulator.Settings.AutoSaveInterval * 60;
769+
}
770+
771+
// show message
761772
if (ComposeMessageWindow.Visible == true)
762773
{
763774
UserInput.Handled();
@@ -973,7 +984,11 @@ void HandleUserInput(ElapsedTime elapsedTime)
973984
Simulator.GameSpeed = 1;
974985
Simulator.Confirmer.ConfirmWithPerCent(CabControl.SimulationSpeed, CabSetting.Off, Simulator.GameSpeed * 100);
975986
}
976-
if (UserInput.IsPressed(UserCommand.GameSave)) { GameStateRunActivity.Save(); }
987+
if (UserInput.IsPressed(UserCommand.GameSave))
988+
{
989+
GameStateRunActivity.Save();
990+
LastSave = RealTime + 60 * Simulator.Settings.AutoSaveInterval;
991+
}
977992
if (UserInput.IsPressed(UserCommand.DisplayHelpWindow)) if (UserInput.IsDown(UserCommand.DisplayNextWindowTab)) HelpWindow.TabAction(); else HelpWindow.Visible = !HelpWindow.Visible;
978993
if (UserInput.IsPressed(UserCommand.DisplayTrackMonitorWindow)) if (UserInput.IsDown(UserCommand.DisplayNextWindowTab)) TrackMonitorWindow.TabAction(); else TrackMonitorWindow.Visible = !TrackMonitorWindow.Visible;
979994
if (UserInput.IsPressed(UserCommand.DisplayTrainDrivingWindow)) if (UserInput.IsDown(UserCommand.DisplayNextWindowTab)) TrainDrivingWindow.TabAction(); else TrainDrivingWindow.Visible = !TrainDrivingWindow.Visible;

0 commit comments

Comments
 (0)