Skip to content

Commit 7bbadcf

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 06b8a9e: 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 0fb4d1c: 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 90cd9e2 + 4cad067 + 3539862 + d00beb9 + f92de76 + a055bca + 06b8a9e + 6c0785b + 1f5ba4c + 5866028 + 0a9d939 + 0fb4d1c + 7353625 + 5850660 + 9b0b04f + 4b4afe3 commit 7bbadcf

File tree

3 files changed

+243
-14
lines changed

3 files changed

+243
-14
lines changed

Source/Menu/MainForm.cs

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
using System.Runtime.InteropServices;
3434
using System.Threading;
3535
using System.Windows.Forms;
36+
using static ORTS.Notification;
3637
using Path = ORTS.Menu.Path;
3738

3839
namespace ORTS
@@ -1179,7 +1180,7 @@ private void AddDetails()
11791180
/// </summary>
11801181
/// <param name="info"></param>
11811182
/// <returns></returns>
1182-
private string[] HideStartParameters(string [] info)
1183+
private string[] HideStartParameters(string[] info)
11831184
{
11841185
var fullStartTime = info[0].TrimStart();
11851186
var startTimeArray = fullStartTime.Split('$');
@@ -1360,7 +1361,7 @@ void SelectComboBoxItem<T>(ComboBox comboBox, Func<T, bool> predicate)
13601361
var index = (int)UserSettings.Menu_SelectionIndex.Activity;
13611362
for (var i = 0; i < comboBox.Items.Count; i++)
13621363
{
1363-
if (comboBox.Items[i] is T && predicate((T)comboBox.Items[i]) || (Settings.Menu_Selection.Length > i && comboBox.Items[i].ToString() == Settings.Menu_Selection[index] ))
1364+
if (comboBox.Items[i] is T && predicate((T)comboBox.Items[i]) || (Settings.Menu_Selection.Length > i && comboBox.Items[i].ToString() == Settings.Menu_Selection[index]))
13641365
{
13651366
comboBox.SelectedIndex = i;
13661367
return;
@@ -1482,9 +1483,6 @@ void comboBoxTimetable_EnabledChanged(object sender, EventArgs e)
14821483
int LastNotificationViewed = 0;
14831484

14841485
List<Notification> NotificationList = new List<Notification>();
1485-
class Notification
1486-
{
1487-
}
14881486

14891487
private void pbNotificationsNone_Click(object sender, EventArgs e)
14901488
{
@@ -1527,23 +1525,48 @@ void ShowNotifications()
15271525
{
15281526
Win32.LockWindowUpdate(Handle);
15291527
ClearPanel();
1530-
AddNotifications();
1531-
FlowDetails();
1528+
PopulateNotificationList();
1529+
var notification = GetCurrentNotification();
1530+
notification.FlowNDetails();
15321531
Win32.LockWindowUpdate(IntPtr.Zero);
15331532
}
15341533

1535-
private void AddNotifications()
1534+
/// <summary>
1535+
/// Populate the Notifications list
1536+
/// </summary>
1537+
private void PopulateNotificationList()
15361538
{
1537-
//if (NotificationList.Count == 0)
1538-
if (NotificationList.Count != 0)
1539+
NotificationList.Clear();
1540+
if (NotificationList.Count == 0)
15391541
{
1540-
AddDetail("Notifications", new string[] { "No notifications are available." });
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);
15411554
}
15421555
else
15431556
{
1544-
AddDetail("Notification 1", new string[] { "This is a dummy notification." });
15451557
}
1546-
AddDetail("", new string[] { "Toggle icon to hide notifications." });
1558+
var notification = NotificationList.LastOrDefault();
1559+
new NTextControl(panelDetails, "").Add(notification);
1560+
new NTextControl(panelDetails, "(Toggle icon to hide notifications.)").Add(notification);
1561+
}
1562+
1563+
/// <summary>
1564+
/// INCOMPLETE
1565+
/// </summary>
1566+
/// <returns></returns>
1567+
Notification GetCurrentNotification()
1568+
{
1569+
return NotificationList[0];
15471570
}
15481571

15491572
#endregion Notifications

Source/Menu/MainForm.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
<data name="pbNotificationsNone.InitialImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
131131
<value>
132132
iVBORw0KGgoAAAANSUhEUgAAACUAAAAfCAYAAABgfwTIAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
133-
vQAADr0BR/uQrQAABk5JREFUWEfNmHlMVFcUxkdttdVWW621VYtaWtQqxlptG+JaG1Nj05j+0dQ0jYnV
133+
vAAADrwBlbxySQAABk5JREFUWEfNmHlMVFcUxkdttdVWW621VYtaWtQqxlptG+JaG1Nj05j+0dQ0jYnV
134134
NjGBGJeCOgouDSCDsrYqVFka6xJEkGU0ERgXGiCoKApI1SCKCMMMw5KBWd7p903mmbFOiLZCvMkv793l
135135
3fvdc5c5ZzQi8hJ4B8wD34LvwFLwBZgPPnIzFfgBXzAe+IBxYBR4DQwG00EA+AAMB0P5dDY1Te6Mjl7c
136136
qdOJefFiMfr5iXHSJDEvWiQoa7EVF4cqZvPnaPsuGERR7JDCXgWjwRjwpgccmEIoaArgwMxTFL8hats3

Source/Menu/Notification.cs

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
// COPYRIGHT 2009, 2010, 2011, 2012, 2013, 2014, 2015 by the Open Rails project.
2+
//
3+
// This file is part of Open Rails.
4+
//
5+
// Open Rails is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// Open Rails is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with Open Rails. If not, see <http://www.gnu.org/licenses/>.
17+
18+
using System;
19+
using System.Collections.Generic;
20+
using System.Drawing;
21+
using System.Linq;
22+
using System.Text;
23+
using System.Threading.Tasks;
24+
using System.Windows.Forms;
25+
26+
namespace ORTS
27+
{
28+
public class Notification
29+
{
30+
public List<NDetail> NDetailList = new List<NDetail>();
31+
32+
public class NDetail
33+
{
34+
public static readonly int TopPadding = 20;
35+
public static readonly int VerticalSpacing = 10;
36+
public static readonly int LeftPadding = 10;
37+
public static readonly int LeftPaddingIndented = 20;
38+
public static readonly int TitleHeight = 20;
39+
public static readonly int HeadingHeight = 30;
40+
public static readonly int TextHeight = 18;
41+
public static readonly int ButtonHeight = 30;
42+
public static readonly int RecordHeight = 15;
43+
public const int ScrollBarWidth = 20;
44+
45+
public Label Control;
46+
47+
public void Add(Notification notification)
48+
{
49+
notification.NDetailList.Add(this);
50+
}
51+
}
52+
53+
/// <summary>
54+
/// Title for the notification
55+
/// </summary>
56+
public class NTitleControl : NDetail
57+
{
58+
public NTitleControl(Panel panelDetails, DateTime date, string text)
59+
{
60+
var title = $"Notification 1/1: {date:dd-MMM-yyyy} - {text}";
61+
var left = LeftPadding;
62+
Control = new Label
63+
{
64+
Text = title,
65+
UseMnemonic = false,
66+
Font = new Font(panelDetails.Font, FontStyle.Bold),
67+
TextAlign = ContentAlignment.BottomLeft,
68+
Height = TitleHeight,
69+
Width = panelDetails.Width - ScrollBarWidth - left,
70+
Left = LeftPadding
71+
};
72+
panelDetails.Controls.Add(Control);
73+
}
74+
}
75+
public class NHeadingControl : NDetail
76+
{
77+
public NHeadingControl(Panel panelDetails, string text, Color color = default)
78+
{
79+
var left = LeftPadding;
80+
Control = new Label
81+
{
82+
ForeColor = color,
83+
Text = text,
84+
UseMnemonic = false,
85+
Font = new Font(panelDetails.Font, FontStyle.Bold),
86+
TextAlign = ContentAlignment.BottomLeft,
87+
Height = HeadingHeight,
88+
Width = panelDetails.Width - ScrollBarWidth - left,
89+
Left = left,
90+
Top = TopPadding,
91+
};
92+
panelDetails.Controls.Add(Control);
93+
}
94+
}
95+
public class NTextControl : NDetail
96+
{
97+
public NTextControl(Panel panelDetails, string text)
98+
{
99+
var left = LeftPaddingIndented;
100+
Control = new Label
101+
{
102+
Text = text,
103+
UseMnemonic = false,
104+
Font = new Font(panelDetails.Font, FontStyle.Regular),
105+
TextAlign = ContentAlignment.BottomLeft,
106+
Height = TextHeight,
107+
Width = panelDetails.Width - ScrollBarWidth - left,
108+
Left = left,
109+
};
110+
panelDetails.Controls.Add(Control);
111+
}
112+
}
113+
public class NButtonControl : NDetail
114+
{
115+
public Button Button;
116+
public NButtonControl(Panel panelDetails, string legend, int width, string description)
117+
{
118+
var buttonLeft = LeftPaddingIndented;
119+
Button = new Button
120+
{
121+
Margin = new Padding(20),
122+
Text = legend,
123+
UseMnemonic = false,
124+
Font = new Font(panelDetails.Font, FontStyle.Regular),
125+
TextAlign = ContentAlignment.MiddleCenter,
126+
Height = ButtonHeight,
127+
Width = width,
128+
Left = buttonLeft,
129+
Top = TopPadding,
130+
BackColor = SystemColors.ButtonFace
131+
};
132+
panelDetails.Controls.Add(Button);
133+
134+
var labelLeft = Button.Left + Button.Width + LeftPaddingIndented;
135+
Control = new Label
136+
{
137+
Margin = new Padding(20),
138+
Text = description,
139+
UseMnemonic = false,
140+
Font = new Font(panelDetails.Font, FontStyle.Regular),
141+
TextAlign = ContentAlignment.MiddleLeft,
142+
Height = ButtonHeight,
143+
Width = panelDetails.Width - ScrollBarWidth - labelLeft,
144+
Top = TopPadding,
145+
Left = labelLeft
146+
};
147+
panelDetails.Controls.Add(Control);
148+
}
149+
}
150+
public class NRecordControl : NDetail
151+
{
152+
public Label Field;
153+
public NRecordControl(Panel panelDetails, string label, int width, string field)
154+
{
155+
Control = new Label
156+
{
157+
Text = label + ":",
158+
UseMnemonic = false,
159+
Font = new Font(panelDetails.Font, FontStyle.Bold),
160+
TextAlign = ContentAlignment.BottomRight,
161+
Width = width,
162+
Height = RecordHeight,
163+
Left = LeftPadding,
164+
Top = TopPadding
165+
};
166+
panelDetails.Controls.Add(Control);
167+
168+
var left = width + LeftPadding;
169+
Field = new Label
170+
{
171+
Text = field,
172+
UseMnemonic = false,
173+
Font = new Font(panelDetails.Font, FontStyle.Regular),
174+
TextAlign = ContentAlignment.BottomLeft,
175+
Width = panelDetails.Width - ScrollBarWidth - left,
176+
Height = RecordHeight,
177+
Left = left,
178+
Top = TopPadding
179+
};
180+
panelDetails.Controls.Add(Field);
181+
}
182+
}
183+
184+
public void FlowNDetails()
185+
{
186+
var top = 2;
187+
foreach (var nDetail in NDetailList)
188+
{
189+
nDetail.Control.Top = top;
190+
191+
// Adjust details that have a second part.
192+
if (nDetail is NButtonControl)
193+
{
194+
((NButtonControl)nDetail).Button.Top = top;
195+
}
196+
if (nDetail is NRecordControl)
197+
{
198+
((NRecordControl)nDetail).Field.Top = top;
199+
}
200+
201+
top += nDetail.Control.Height + NDetail.VerticalSpacing;
202+
}
203+
}
204+
}
205+
206+
}

0 commit comments

Comments
 (0)