Skip to content

Commit e6ddd3d

Browse files
committed
Automatic merge of T1.5.1-794-g4cad06780 and 14 pull requests
- Pull request #570 at 3539862: Experimental glTF 2.0 support with PBR lighting - 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 a055bca: Blueprint/train car operations UI window - Pull request #885 at 8f94333: feat: Add notifications to Menu - Pull request #886 at 6c0785b: Scene viewer extension to TrackViewer - 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 #897 at 0a9d939: feat: Improved system information collection - Pull request #899 at 2985bc1: Duplex steam engines - Booster Engine addition - Pull request #903 at 7353625: Downloading route content (Github, zip) - Pull request #906 at 5850660: Bug fix for https://bugs.launchpad.net/or/+bug/2047299 Crash loading a 3Dcab-only loco - Pull request #907 at 9b0b04f: Bug fix for https://bugs.launchpad.net/or/+bug/2047300 Dynamic tracks disappear after long tunnel - Pull request #908 at 4b4afe3: feat: supports switching adhesion precisions
16 parents c0fe786 + 4cad067 + 3539862 + d00beb9 + f92de76 + a055bca + 8f94333 + 6c0785b + 1f5ba4c + 5866028 + 0a9d939 + 2985bc1 + 7353625 + 5850660 + 9b0b04f + 4b4afe3 commit e6ddd3d

File tree

3 files changed

+235
-69
lines changed

3 files changed

+235
-69
lines changed

Source/Menu/MainForm.cs

Lines changed: 144 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
using System.Resources;
3333
using System.Runtime.InteropServices;
3434
using System.Threading;
35+
using System.Threading.Tasks;
3536
using System.Windows.Forms;
3637
using static ORTS.Notification;
3738
using Path = ORTS.Menu.Path;
@@ -307,30 +308,49 @@ void MainForm_FormClosing(object sender, FormClosingEventArgs e)
307308
File.Delete(file);
308309
}
309310

311+
//void CheckForUpdate()
312+
//{
313+
// // This is known directly from the chosen channel so doesn't need to wait for the update check itself.
314+
// linkLabelChangeLog.Visible = !string.IsNullOrEmpty(UpdateManager.ChangeLogLink);
315+
316+
// new Task<UpdateManager>(this, () =>
317+
// {
318+
// UpdateManager.Check();
319+
// return null;
320+
// }, _ =>
321+
// {
322+
// if (UpdateManager.LastCheckError != null)
323+
// linkLabelUpdate.Text = catalog.GetString("Update check failed");
324+
//else if (UpdateManager.LastUpdate != null && UpdateManager.LastUpdate.Version != VersionInfo.Version)
325+
// linkLabelUpdate.Text = catalog.GetStringFmt("Update to {0}", UpdateManager.LastUpdate.Version);
326+
//else
327+
// linkLabelUpdate.Text = "";
328+
//linkLabelUpdate.Enabled = true;
329+
//linkLabelUpdate.Visible = linkLabelUpdate.Text.Length > 0;
330+
//// Update link's elevation icon and size/position.
331+
//if (UpdateManager.LastCheckError == null && UpdateManager.LastUpdate != null && UpdateManager.LastUpdate.Version != VersionInfo.Version && UpdateManager.UpdaterNeedsElevation)
332+
// linkLabelUpdate.Image = ElevationIcon;
333+
//else
334+
// linkLabelUpdate.Image = null;
335+
// });
336+
//}
310337
void CheckForUpdate()
311338
{
312-
// This is known directly from the chosen channel so doesn't need to wait for the update check itself.
313-
linkLabelChangeLog.Visible = !string.IsNullOrEmpty(UpdateManager.ChangeLogLink);
314-
315339
new Task<UpdateManager>(this, () =>
316340
{
317341
UpdateManager.Check();
318342
return null;
319343
}, _ =>
320344
{
321345
if (UpdateManager.LastCheckError != null)
346+
{
322347
linkLabelUpdate.Text = catalog.GetString("Update check failed");
323-
else if (UpdateManager.LastUpdate != null && UpdateManager.LastUpdate.Version != VersionInfo.Version)
324-
linkLabelUpdate.Text = catalog.GetStringFmt("Update to {0}", UpdateManager.LastUpdate.Version);
325-
else
326-
linkLabelUpdate.Text = "";
327-
linkLabelUpdate.Enabled = true;
328-
linkLabelUpdate.Visible = linkLabelUpdate.Text.Length > 0;
329-
// Update link's elevation icon and size/position.
330-
if (UpdateManager.LastCheckError == null && UpdateManager.LastUpdate != null && UpdateManager.LastUpdate.Version != VersionInfo.Version && UpdateManager.UpdaterNeedsElevation)
331-
linkLabelUpdate.Image = ElevationIcon;
332-
else
333-
linkLabelUpdate.Image = null;
348+
linkLabelChangeLog.Visible = true;
349+
}
350+
if (UpdateManager.LastUpdate != null)
351+
{
352+
SetUpdateNotification();
353+
}
334354
});
335355
}
336356

@@ -1479,6 +1499,9 @@ void comboBoxTimetable_EnabledChanged(object sender, EventArgs e)
14791499
// Will probably move this region and the Details region into separate files.
14801500

14811501
bool AreNotificationsVisible = false;
1502+
// New notifications are those with a date after the NotificationsReadDate.
1503+
// Notifications are listed in reverse date order, with the newest one at the front.
1504+
// We don't track the reading of each notification but set the NewNotificationCount = 0 after the last of the new ones has been read.
14821505
int NewNotificationCount = 1;
14831506
int LastNotificationViewed = 0;
14841507

@@ -1501,19 +1524,25 @@ private void ToggleNotifications()
15011524
{
15021525
if (AreNotificationsVisible == false)
15031526
{
1527+
AreNotificationsVisible = true; // Set before calling ShowNotifcations()
15041528
ShowNotifications();
15051529
FiddleNewNotificationCount();
15061530
}
15071531
else
15081532
{
1533+
AreNotificationsVisible = false;
15091534
ShowDetails();
15101535
}
1511-
AreNotificationsVisible = !AreNotificationsVisible;
15121536
}
15131537

15141538
private void FiddleNewNotificationCount()
15151539
{
15161540
LastNotificationViewed = 1;
1541+
UpdateNotificationAlert();
1542+
}
1543+
1544+
private void UpdateNotificationAlert()
1545+
{
15171546
if (LastNotificationViewed >= NewNotificationCount)
15181547
{
15191548
pbNotificationsSome.Visible = false;
@@ -1534,30 +1563,52 @@ void ShowNotifications()
15341563
/// <summary>
15351564
/// Populate the Notifications list
15361565
/// </summary>
1566+
//private void PopulateNotificationList()
1567+
//{
1568+
//NotificationList.Clear();
1569+
//if (NotificationList.Count == 0)
1570+
//{
1571+
// var newNotification = new Notification();
1572+
// NotificationList.Add(newNotification);
1573+
//new NHeadingControl(panelDetails, "This is a dummy notification", Color.OrangeRed).Add(newNotification);
1574+
//new NTitleControl(panelDetails, DateTime.Now, "Update is available").Add(newNotification);
1575+
//new NRecordControl(panelDetails, "Update mode", 140, "Stable").Add(newNotification);
1576+
//new NRecordControl(panelDetails, "Installed version", 140, "1.3.1").Add(newNotification);
1577+
//new NRecordControl(panelDetails, "New version available", 140, "1.4").Add(newNotification);
1578+
//new NButtonControl(panelDetails, "What's new", 90, "Find out on-line what's new in this version.").Add(newNotification);
1579+
//new NButtonControl(panelDetails, "Install", 90, "Install the new version.").Add(newNotification);
1580+
//new NHeadingControl(panelDetails, "Warning", Color.OrangeRed).Add(newNotification);
1581+
//new NTextControl(panelDetails, "The update from your current version may affect the behaviour of some of your content.").Add(newNotification);
1582+
//new NButtonControl(panelDetails, "Issue details", 90, "More details about this issue are available on-line.").Add(newNotification);
1583+
1584+
//new NTitleControl(panelDetails, new DateTime(2024, 8, 31, 0, 0, 0), "Update is available").Add(newNotification);
1585+
//new NRecordControl(panelDetails, "Update mode", 140, "Stable").Add(newNotification);
1586+
//new NRecordControl(panelDetails, "Installed version", 140, "1.6").Add(newNotification);
1587+
//new NRecordControl(panelDetails, "New version available", 140, "1.7").Add(newNotification);
1588+
//new NButtonControl(panelDetails, "What's new", 90, "Find out on-line what's new in this version.").Add(newNotification);
1589+
//new NHeadingControl(panelDetails, "Install Not Available", Color.OrangeRed).Add(newNotification);
1590+
//new NTextControl(panelDetails, "V1.7 cannot be installed on your system until the graphics card is upgraded.").Add(newNotification);
1591+
//new NButtonControl(panelDetails, "Graphics card", 90, "Find out on-line about graphics hardware needed.").Add(newNotification);
1592+
//new NHeadingControl(panelDetails, "More Realism", Color.Blue).Add(newNotification);
1593+
//new NTextControl(panelDetails, "This update supports graphics which are significantly more realistic.").Add(newNotification);
1594+
//new NButtonControl(panelDetails, "Enhancement", 90, "More details about this enhancement are available on-line.").Add(newNotification);
1595+
1596+
//}
1597+
//else
1598+
//{
1599+
//}
1600+
//var notification = NotificationList.LastOrDefault();
1601+
//new NTextControl(panelDetails, "").Add(notification);
1602+
//new NTextControl(panelDetails, "(Toggle icon to hide notifications.)").Add(notification);
1603+
//}
1604+
15371605
private void PopulateNotificationList()
15381606
{
1539-
NotificationList.Clear();
1540-
if (NotificationList.Count == 0)
1541-
{
1542-
var newNotification = new Notification();
1543-
NotificationList.Add(newNotification);
1544-
new NHeadingControl(panelDetails, "This is a dummy notification", Color.OrangeRed).Add(newNotification);
1545-
new NTitleControl(panelDetails, DateTime.Now, "Update is available").Add(newNotification);
1546-
new NRecordControl(panelDetails, "Update mode", 140, "Stable").Add(newNotification);
1547-
new NRecordControl(panelDetails, "Installed version", 140, "1.3.1").Add(newNotification);
1548-
new NRecordControl(panelDetails, "New version available", 140, "1.4").Add(newNotification);
1549-
new NButtonControl(panelDetails, "What's new", 90, "Find out on-line what's new in this version.").Add(newNotification);
1550-
new NButtonControl(panelDetails, "Install", 90, "Install the new version.").Add(newNotification);
1551-
new NHeadingControl(panelDetails, "Warning", Color.OrangeRed).Add(newNotification);
1552-
new NTextControl(panelDetails, "The update from your current version may affect the behaviour of some of your content.").Add(newNotification);
1553-
new NButtonControl(panelDetails, "Issue details", 90, "More details about this issue are available on-line.").Add(newNotification);
1554-
}
1555-
else
1556-
{
1557-
}
1607+
SetUpdateNotification();
1608+
15581609
var notification = NotificationList.LastOrDefault();
1559-
new NTextControl(panelDetails, "").Add(notification);
1560-
new NTextControl(panelDetails, "(Toggle icon to hide notifications.)").Add(notification);
1610+
new NTextControl(notification, "").Add();
1611+
new NTextControl(notification, "(Toggle icon to hide notifications.)").Add();
15611612
}
15621613

15631614
/// <summary>
@@ -1569,6 +1620,63 @@ Notification GetCurrentNotification()
15691620
return NotificationList[0];
15701621
}
15711622

1623+
/// <summary>
1624+
/// Ultimately there will be a list of notifications downloaded for openrails/content.
1625+
/// Until then, there is a single notification announcing either that a new update is available or the installation is up to date.
1626+
/// </summary>
1627+
void SetUpdateNotification()
1628+
{
1629+
NewNotificationCount = (IsUpdateAvailable()) ? 1 : 0;
1630+
UpdateNotificationAlert();
1631+
NotificationList.Clear();
1632+
var newNotification = new Notification(panelDetails);
1633+
if (IsUpdateAvailable())
1634+
{
1635+
NewNotificationCount = 1;
1636+
if (AreNotificationsVisible)
1637+
{
1638+
new NTitleControl(newNotification, UpdateManager.LastUpdate.Date, "Update is available").Add();
1639+
new NRecordControl(newNotification, "Update mode", 140, UpdateManager.ChannelName).Add();
1640+
new NRecordControl(newNotification, "Installed version", 140, VersionInfo.VersionOrBuild).Add();
1641+
new NRecordControl(newNotification, "New version available", 140, UpdateManager.LastUpdate.Version).Add();
1642+
new NLinkControl(newNotification, "What's new", 90, "Find out on-line what's new in this version.", this, UpdateManager.ChangeLogLink).Add();
1643+
new NUpdateControl(newNotification, "Install", 90, "Install the new version.", this).Add();
1644+
}
1645+
}
1646+
else
1647+
{
1648+
NewNotificationCount = 0;
1649+
if (AreNotificationsVisible)
1650+
{
1651+
var channelName = UpdateManager.ChannelName == "" ? "None" : UpdateManager.ChannelName;
1652+
new NTitleControl(newNotification, DateTime.Now, "Installation is up to date").Add();
1653+
new NRecordControl(newNotification, "Update mode", 140, channelName).Add();
1654+
new NRecordControl(newNotification, "Installed version", 140, VersionInfo.VersionOrBuild).Add();
1655+
new NRecordControl(newNotification, "New version available", 140, "none").Add();
1656+
}
1657+
}
1658+
NotificationList.Add(newNotification);
1659+
}
1660+
1661+
bool IsUpdateAvailable()
1662+
{
1663+
return UpdateManager.LastUpdate != null
1664+
&& UpdateManager.LastUpdate.Version != VersionInfo.Version;
1665+
}
1666+
1667+
// 3 should be enough, but is there a way to get unlimited buttons?
1668+
public void Button0_Click(object sender, EventArgs e)
1669+
{
1670+
GetCurrentNotification().DoButton(UpdateManager, 0);
1671+
}
1672+
public void Button1_Click(object sender, EventArgs e)
1673+
{
1674+
GetCurrentNotification().DoButton(UpdateManager, 1);
1675+
}
1676+
public void Button2_Click(object sender, EventArgs e)
1677+
{
1678+
GetCurrentNotification().DoButton(UpdateManager, 2);
1679+
}
15721680
#endregion Notifications
15731681
}
15741682
}

0 commit comments

Comments
 (0)