Skip to content

Commit 66a88b5

Browse files
committed
Automatic merge of T1.5.1-1000-gd75170a62c and 20 pull requests
- Pull request #799 at dfc715e: Consolidated wind simulation - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder - Pull request #882 at 58b659d: Blueprint/train car operations UI window - Pull request #885 at 56c17fb: feat: Add notifications to Menu - Pull request #891 at 9a1d6b2: Auto save - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #896 at 5866028: First implementation of https://blueprints.launchpad.net/or/+spec/specific-sounds-for-ai-trains - Pull request #900 at c27f32d: DMI updates - Pull request #903 at 3e390b8: Downloading route content (Github, zip) - Pull request #912 at 359cfee: New Triple Valve Features Vol. 2 - Pull request #922 at abe2e52: Autopilot for timetable mode - Pull request #946 at 66f836c: Advanced track sounds - Pull request #949 at ce2bbe1: Oil Burning Locomotive - Pull request #950 at a98ff62: Ctrl-F5 showing yellow rectangles where mouse left button is active - Pull request #951 at 486081b: fix: Fix watchdog process state name - Pull request #952 at b2af1f5: Investigation - Pulsing graphics part 1 - Pull request #953 at a519452: Fix Lights Crash on Corrupt Shapes - Pull request #954 at 84c2f4b: Add Support for Multiple Track Profiles - Pull request #956 at 25193a8: Map settings saved
22 parents 0dd962f + d75170a + dfc715e + d00beb9 + f92de76 + 58b659d + 56c17fb + 9a1d6b2 + 1f5ba4c + 5866028 + c27f32d + 3e390b8 + 359cfee + abe2e52 + 66f836c + ce2bbe1 + a98ff62 + 486081b + b2af1f5 + a519452 + 84c2f4b + 25193a8 commit 66a88b5

File tree

3 files changed

+179
-28
lines changed

3 files changed

+179
-28
lines changed

Source/ORTS.Settings/UserSettings.cs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,50 @@ public string DirectXFeatureLevel
426426
[DoNotSave]
427427
public bool MultiplayerServer { get; set; }
428428

429+
// map settings
430+
[Default(false)]
431+
public bool Map_showTrainStateCheckbox { get; set; }
432+
[Default(false)]
433+
public bool Map_showTrainLabelsCheckbox { get; set; }
434+
[Default(false)]
435+
public bool Map_showSignalStateCheckbox { get; set; }
436+
[Default(false)]
437+
public bool Map_showSignalsCheckbox { get; set; }
438+
[Default(false)]
439+
public bool Map_showSwitchesCheckbox { get; set; }
440+
[Default(false)]
441+
public bool Map_showSidingLabelsCheckbox { get; set; }
442+
[Default(false)]
443+
public bool Map_showPlatformLabelsCheckbox { get; set; }
444+
[Default(false)]
445+
public bool Map_showPlatformsCheckbox { get; set; }
446+
[Default(true)]
447+
public bool Map_showTimeCheckbox { get; set; }
448+
[Default(false)]
449+
public bool Map_useAntiAliasingCheckbox { get; set; }
450+
[Default(true)]
451+
public bool Map_penaltyCheckbox { get; set; }
452+
[Default(true)]
453+
public bool Map_preferGreenCheckbox { get; set; }
454+
[Default(true)]
455+
public bool Map_allowJoiningCheckbox { get; set; }
456+
[Default(true)]
457+
public bool Map_allowThrowingSwitchesCheckbox { get; set; }
458+
[Default(true)]
459+
public bool Map_allowChangingSignalsCheckbox { get; set; }
460+
[Default(true)]
461+
public bool Map_drawPathCheckbox { get; set; }
462+
[Default(5000)]
463+
public int Map_mapResolutionUpDown { get; set; }
464+
[Default("light")]
465+
public string Map_rotateThemesButton { get; set; }
466+
[Default(true)]
467+
public bool Map_showActiveTrainsRadio { get; set; }
468+
[Default(false)]
469+
public bool Map_showAllTrainsRadio { get; set; }
470+
[Default(new[] { 104, 104, 800, 600 })]
471+
public int[] Map_MapViewer { get; set; }
472+
429473
// In-game settings:
430474
[Default(false)]
431475
public bool Letterbox2DCab { get; set; }
@@ -501,7 +545,7 @@ public string GetCacheFilePath(string type, string key)
501545
return Path.Combine(directory, hash + ".cache-or");
502546
}
503547

504-
PropertyInfo GetProperty(string name)
548+
public PropertyInfo GetProperty(string name)
505549
{
506550
return GetType().GetProperty(name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
507551
}

Source/RunActivity/Viewer3D/Map/MapDataProvider.cs

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -253,40 +253,42 @@ public float GetUnusedYLocation(float startX, float wantY, string name)
253253
return noFreeSlotFound;
254254

255255
var positionY = desiredPositionY;
256-
while (positionY >= 0 && positionY < F.alignedTextY.Length)
257-
{
258-
// If the line contains no text yet, put it there
259-
if (F.alignedTextNum[positionY] == 0)
260-
return SaveLabelLocation(startX, endX, positionY);
256+
if (F.alignedTextY != null) {
257+
while (positionY >= 0 && positionY < F.alignedTextY.Length)
258+
{
259+
// If the line contains no text yet, put it there
260+
if (F.alignedTextNum[positionY] == 0)
261+
return SaveLabelLocation(startX, endX, positionY);
261262

262-
var conflict = false;
263+
var conflict = false;
263264

264-
// Check if it intersects with any labels already in this row
265-
for (var col = 0; col < F.alignedTextNum[positionY]; col++)
266-
{
267-
var v = F.alignedTextY[positionY][col];
268-
//check conflict with a text, v.X is the start of the text, v.Y is the end of the text
269-
if (endX >= v.X && startX <= v.Y)
265+
// Check if it intersects with any labels already in this row
266+
for (var col = 0; col < F.alignedTextNum[positionY]; col++)
270267
{
271-
conflict = true;
272-
break;
268+
var v = F.alignedTextY[positionY][col];
269+
//check conflict with a text, v.X is the start of the text, v.Y is the end of the text
270+
if (endX >= v.X && startX <= v.Y)
271+
{
272+
conflict = true;
273+
break;
274+
}
273275
}
274-
}
275276

276-
if (conflict)
277-
{
278-
positionY--; // Try a different row: -1, -2, +2, +1
277+
if (conflict)
278+
{
279+
positionY--; // Try a different row: -1, -2, +2, +1
279280

280-
if (positionY - desiredPositionY <= -2) // Cannot move up (-ve Y), so try to move it down (+ve Y)
281-
positionY = desiredPositionY + 2; // Try +2 then +1
281+
if (positionY - desiredPositionY <= -2) // Cannot move up (-ve Y), so try to move it down (+ve Y)
282+
positionY = desiredPositionY + 2; // Try +2 then +1
282283

283-
if (positionY == desiredPositionY) // Back to original position again
284-
return noFreeSlotFound;
285-
}
286-
else
287-
{
288-
// Check that row has an unused column in its fixed size array
289-
return F.alignedTextNum[positionY] >= F.alignedTextY[positionY].Length ? noFreeSlotFound : SaveLabelLocation(startX, endX, positionY);
284+
if (positionY == desiredPositionY) // Back to original position again
285+
return noFreeSlotFound;
286+
}
287+
else
288+
{
289+
// Check that row has an unused column in its fixed size array
290+
return F.alignedTextNum[positionY] >= F.alignedTextY[positionY].Length ? noFreeSlotFound : SaveLabelLocation(startX, endX, positionY);
291+
}
290292
}
291293
}
292294
return noFreeSlotFound;

Source/RunActivity/Viewer3D/Map/MapForm.cs

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using System.Diagnostics;
2121
using System.Drawing;
2222
using System.Linq;
23+
using System.Reflection;
2324
using System.Text.RegularExpressions;
2425
using System.Windows.Forms;
2526
using GNU.Gettext;
@@ -193,6 +194,110 @@ void InitializeForm()
193194
float[] dashPattern = { 4, 2 };
194195
ZoomTargetPen.DashPattern = dashPattern;
195196
pathPen.DashPattern = dashPattern;
197+
198+
setDefaults(this);
199+
}
200+
201+
//
202+
// set the defaults for all the map controls which have a property in UserSettings.c
203+
// properties are stored in the registry or in a .ini file
204+
//
205+
private void setDefaults(System.Windows.Forms.Control controlToSet)
206+
{
207+
foreach (System.Windows.Forms.Control control in controlToSet.Controls)
208+
{
209+
// recursive call to find deeper controls
210+
setDefaults(control);
211+
}
212+
213+
string name = "Map_" + controlToSet.Name;
214+
PropertyInfo property = Viewer.Settings.GetProperty(name);
215+
if (property != null)
216+
{
217+
if (controlToSet is CheckBox checkBox)
218+
{
219+
checkBox.Checked = (bool)property.GetValue(Viewer.Settings);
220+
checkBox.CheckedChanged += c_ControlChanged;
221+
}
222+
if (controlToSet is NumericUpDown numericUpDown)
223+
{
224+
numericUpDown.Value = (int)property.GetValue(Viewer.Settings, null);
225+
numericUpDown.ValueChanged += c_ControlChanged;
226+
}
227+
if (controlToSet is Button button)
228+
{
229+
if (name.Equals("Map_rotateThemesButton"))
230+
{
231+
ThemeName = (string)property.GetValue(Viewer.Settings, null);
232+
Theme = MapThemeProvider.GetTheme(ThemeName);
233+
234+
ApplyThemeRecursively(this);
235+
MapCanvasColor = Theme.MapCanvasColor;
236+
TrackPen.Color = Theme.TrackColor;
237+
}
238+
button.Click += c_ControlChanged;
239+
}
240+
if (controlToSet is RadioButton radioButton)
241+
{
242+
radioButton.Checked = (bool)property.GetValue(Viewer.Settings);
243+
radioButton.CheckedChanged += c_ControlChanged;
244+
}
245+
if (controlToSet is MapViewer mapViewer)
246+
{
247+
Size size = new Size(
248+
((int[])property.GetValue(Viewer.Settings, null))[2],
249+
((int[])property.GetValue(Viewer.Settings, null))[3]);
250+
Size = size;
251+
252+
StartPosition = FormStartPosition.Manual;
253+
this.Location = new System.Drawing.Point(
254+
((int[])property.GetValue(Viewer.Settings, null))[0],
255+
((int[])property.GetValue(Viewer.Settings, null))[1]);
256+
257+
mapViewer.Resize += c_ControlChanged;
258+
mapViewer.Move += c_ControlChanged;
259+
}
260+
}
261+
}
262+
263+
//
264+
// save the setting of a map control
265+
//
266+
void c_ControlChanged(object sender, EventArgs e)
267+
{
268+
if (sender is CheckBox checkBox)
269+
{
270+
string name = "Map_" + checkBox.Name;
271+
Viewer.Settings.GetProperty(name).SetValue(Viewer.Settings, checkBox.CheckState == CheckState.Checked, null);
272+
Viewer.Settings.Save(name);
273+
}
274+
if (sender is NumericUpDown numericUpDown)
275+
{
276+
string name = "Map_" + numericUpDown.Name;
277+
Viewer.Settings.GetProperty(name).SetValue(Viewer.Settings, (int)numericUpDown.Value, null);
278+
Viewer.Settings.Save(name);
279+
}
280+
if (sender is Button button)
281+
{
282+
string name = "Map_" + button.Name;
283+
Viewer.Settings.GetProperty(name).SetValue(Viewer.Settings, ThemeName, null);
284+
Viewer.Settings.Save(name);
285+
}
286+
if (sender is RadioButton radioButton)
287+
{
288+
string name = "Map_" + radioButton.Name;
289+
Viewer.Settings.GetProperty(name).SetValue(Viewer.Settings, radioButton.Checked, null);
290+
Viewer.Settings.Save(name);
291+
}
292+
if (sender is MapViewer mapViewer)
293+
{
294+
string name = "Map_" + mapViewer.Name;
295+
296+
int X = this.Bounds.X;
297+
int Y = this.Bounds.Y;
298+
Viewer.Settings.GetProperty(name).SetValue(Viewer.Settings, new int[] { X, Y, Size.Width, Size.Height }, null);
299+
Viewer.Settings.Save(name);
300+
}
196301
}
197302

198303
#region initData

0 commit comments

Comments
 (0)