From 8d8ebc8f86bad45d9ee7b1994a5ce3dd01731e4d Mon Sep 17 00:00:00 2001 From: cjakeman Date: Wed, 29 Apr 2020 14:02:17 +0100 Subject: [PATCH] GetValidWindowSize Ensures user's entry in Menu > Options > Video > Window Size is valid or ignores it. A user entered "1024X780", RunActivity.exe did not run and nothing in log file, so was stumped. --- Source/Menu/Options.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/Menu/Options.cs b/Source/Menu/Options.cs index 599dc8de..855d32dc 100644 --- a/Source/Menu/Options.cs +++ b/Source/Menu/Options.cs @@ -461,7 +461,8 @@ void buttonOK_Click(object sender, EventArgs e) Settings.DistantMountainsViewingDistance = (int)numericDistantMountainsViewingDistance.Value * 1000; Settings.ViewingFOV = (int)numericViewingFOV.Value; Settings.WorldObjectDensity = (int)numericWorldObjectDensity.Value; - Settings.WindowSize = comboWindowSize.Text; + Settings.WindowSize = GetValidWindowSize(); + Settings.DayAmbientLight = (int)trackDayAmbientLight.Value; Settings.DoubleWire = checkDoubleWire.Checked; @@ -538,6 +539,15 @@ void buttonOK_Click(object sender, EventArgs e) Settings.Save(); } + private string GetValidWindowSize() + { + // "1024X780" instead of "1024x780" then "Start" resulted in an immediate return to the Menu with no OpenRailsLog.txt and a baffled user. + var windowSizeArray = comboWindowSize.Text.ToLower().Replace(" ", "").Split('x'); + return (int.TryParse(windowSizeArray[0], out int width) && int.TryParse(windowSizeArray[1], out int height)) + ? $"{width}x{height}" + : Settings.WindowSize; // i.e. no change or message. Just ignore non-numeric entries + } + void buttonDefaultKeys_Click(object sender, EventArgs e) { if (DialogResult.Yes == MessageBox.Show(catalog.GetString("Remove all custom key assignments?"), Application.ProductName, MessageBoxButtons.YesNo)) -- 2.11.0.windows.1