Skip to content

Commit 6f1f455

Browse files
committed
Automatic merge of T1.5.1-1204-g8bc1d82939 and 17 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 #885 at 45ca50d: 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 #952 at 8347095: Investigation - Pulsing graphics - Pull request #953 at a519452: Fix Lights Crash on Corrupt Shapes - Pull request #954 at 62061b8: Multiple Track Profiles & Superelevation Improvements - Pull request #962 at 46d0472: Fix pantographs on unpowered cars - Pull request #972 at e90a2aa: On Map window color changed switch or signal is not changed - Pull request #980 at a7406de: Downloading route content (Github, zip) second part - Pull request #981 at 10d297f: Multiple type trainset lightglows - Pull request #982 at efcf19c: WEB based Switch Panel enhancement: Alerter - Pull request #983 at 202316e: WEB based Switch Panel bug: DPU window - Pull request #984 at 0f8122e: Player train switching for timetable mode - Pull request #900 at c27f32d: DMI updates - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder
19 parents b970aa2 + 8bc1d82 + dfc715e + d00beb9 + 45ca50d + 9a1d6b2 + 1f5ba4c + 8347095 + a519452 + 62061b8 + 46d0472 + e90a2aa + a7406de + 10d297f + efcf19c + 202316e + 0f8122e + c27f32d + f92de76 commit 6f1f455

File tree

5 files changed

+35
-32
lines changed

5 files changed

+35
-32
lines changed

Source/Menu/MainForm.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,15 @@ public void UpdateNotificationPageAlert()
16131613
pbNotificationsSome.Visible = true;
16141614
lblNotificationCount.Visible = true;
16151615
lblNotificationCount.Text = $"{NotificationManager.NewPages.Count - NotificationManager.NewPages.Viewed}";
1616+
1617+
// If screen scaling != 100%, then the count doesn't lie on top of the red circle, so adjust its position.
1618+
if (NotificationManager.ScreenScaling != 1.0 & NotificationManager.ScreenAdjusted == false)
1619+
{
1620+
var adjustment = (int)((NotificationManager.ScreenScaling - 1.0) * 20); // 20 to adjust 125% by 5 pixels
1621+
lblNotificationCount.Top -= adjustment;
1622+
lblNotificationCount.Left -= adjustment;
1623+
NotificationManager.ScreenAdjusted = true;
1624+
}
16161625
}
16171626
else
16181627
{

Source/Menu/Menu.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<SpecificVersion>False</SpecificVersion>
3232
<HintPath>..\3rdPartyLibs\GNU.Gettext.WinForms.dll</HintPath>
3333
</Reference>
34+
<Reference Include="PresentationFramework" />
3435
<Reference Include="System.DirectoryServices" />
3536
<Reference Include="System.Net.Http" />
3637
<Reference Include="WindowsBase" />

Source/Menu/Notifications/NotificationManager.cs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// COPYRIGHT 2009, 2010, 2011, 2012, 2013, 2014, 2015 by the Open Rails project.
1+
// COPYRIGHT 2009 - 2024 by the Open Rails project.
22
//
33
// This file is part of Open Rails.
44
//
@@ -22,7 +22,9 @@
2222
using System.Linq;
2323
using System.Net;
2424
using System.Resources;
25+
using System.Runtime.InteropServices;
2526
using System.Text;
27+
using System.Windows;
2628
using System.Windows.Forms;
2729
using Newtonsoft.Json;
2830
using ORTS.Common;
@@ -75,6 +77,8 @@ public class PageTracking
7577
public Image FirstImage { get; private set; }
7678
public Image LastImage { get; private set; }
7779
public PageTracking NewPages { get; private set; }
80+
public double ScreenScaling { get; private set; }
81+
public bool ScreenAdjusted { get; set; }
7882

7983
public NotificationManager(MainForm mainForm, ResourceManager resources, UpdateManager updateManager, UserSettings settings, Panel panel)
8084
{
@@ -83,14 +87,20 @@ public NotificationManager(MainForm mainForm, ResourceManager resources, UpdateM
8387
this.Settings = settings;
8488
Panel = panel;
8589
NewPages = new PageTracking();
86-
90+
ScreenScaling = GetScalingFactor();
91+
8792
// Load images of arrows
8893
PreviousImage = (Image)resources.GetObject("Notification_previous");
8994
NextImage = (Image)resources.GetObject("Notification_next");
9095
FirstImage = (Image)resources.GetObject("Notification_first");
9196
LastImage = (Image)resources.GetObject("Notification_last");
9297
}
93-
98+
99+
public double GetScalingFactor()
100+
{
101+
return Screen.PrimaryScreen.Bounds.Width / SystemParameters.PrimaryScreenWidth;
102+
}
103+
94104
public void CheckNotifications()
95105
{
96106
try
@@ -100,8 +110,8 @@ public void CheckNotifications()
100110
CurrentPageIndex = 0;
101111
Notifications = GetNotifications();
102112
ParameterDictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
103-
104-
// To support testing, add any overriding values to the ValueDictionary
113+
114+
// To support testing, add any overriding values to the ParameterDictionary
105115
GetOverrideParameters()?.ParameterValueList.ForEach(i => ParameterDictionary.Add(i.Parameter, i.Value));
106116
LogOverrideParameters();
107117

@@ -220,7 +230,7 @@ public void PopulatePage()
220230

221231
Page.NDetailList.Add(new NTitleControl(Panel, CurrentPageIndex + 1, list.Count, n.Date, n.Title));
222232

223-
// Check constraints foPageNoem
233+
// Check criteria for each item and add the successful items to the current page
224234
foreach (var item in n.ItemList)
225235
{
226236
if (AreItemChecksMet(item)) AddItemToPage(Page, item);
@@ -280,6 +290,11 @@ private bool AreNotificationChecksMet(Notification notification)
280290
return true;
281291
}
282292

293+
/// <summary>
294+
/// For the checks in the item, compares parameter values with criteria values
295+
/// </summary>
296+
/// <param name="item"></param>
297+
/// <returns></returns>
283298
private bool AreItemChecksMet(Item item)
284299
{
285300
if (item.IncludeIf != null || item.IncludeIfNot != null)

Source/Menu/Notifications/Notifications.cs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// COPYRIGHT 2009, 2010, 2011, 2012, 2013, 2014, 2015 by the Open Rails project.
1+
// COPYRIGHT 2009 - 2024 by the Open Rails project.
22
//
33
// This file is part of Open Rails.
44
//
@@ -73,51 +73,29 @@ public class Item
7373
public string Color { get; set; } = "black";
7474
public int Indent { get; set; } = 140;
7575
}
76-
//public class Met
77-
//{
78-
// public List<Item> ItemList { get; set; }
79-
// public List<CheckId> CheckIdList { get; set; }
80-
//}
81-
//public class CheckId
82-
//{
83-
// public string Id { get; set; }
84-
//}
8576

8677
public class Check
8778
{
8879
public string Id { get; set; }
8980
public List<AnyOf> AnyOfList { get; set; }
90-
//public List<Item> UnmetItemList { get; set; }
9181
}
9282

93-
//public class CheckAllOf
94-
//{
95-
// public List<Criteria> AllOfList { get; set; }
96-
//}
9783
public class AnyOf
9884
{
9985
public List<Criteria> AllOfList { get; set; }
10086
}
10187

102-
//public class Excludes : CheckAllOf
103-
//{
104-
//}
105-
106-
//public class Includes : CheckAllOf
107-
//{
108-
//}
109-
11088
class Contains : Criteria { }
11189
class NotContains : Criteria { }
11290

113-
// Not implemented yet
91+
// Not implemented as not needed yet
11492
// String comparison, not numerical
11593
class NoLessThan : Criteria { }
11694
class NoMoreThan : Criteria { }
11795

11896
public class Criteria
11997
{
120-
// System Information "examples"
98+
// System Information "examples"
12199
public string Property { get; set; } // installed_version, direct3d, runtime, system, memory, cpu, gpu
122100
public string Value { get; set; } // {{new_version}}, {{10_0}}
123101
}

Source/ORTS.Common/SystemInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static SystemInfo()
6969
{
7070
// Likely to catch multiple exceptions like:
7171
// Exception thrown: 'System.IO.InvalidDataException' in ORTS.Menu.dll
72-
//Trace.WriteLine(error);
72+
Trace.WriteLine(error);
7373
}
7474

7575
NativeMethods.GlobalMemoryStatusEx(MemoryStatusExtended);

0 commit comments

Comments
 (0)