Skip to content

Commit 50e8499

Browse files
committed
Merge branch 'master' into relay-valve
2 parents 8a2fb4e + d06a7b6 commit 50e8499

File tree

83 files changed

+5995
-4494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+5995
-4494
lines changed

.github/release.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- ignore-for-release
5+
authors:
6+
- appveyor
7+
- dependabot
8+
- github-actions
9+
categories:
10+
- title: New Features
11+
labels:
12+
- enhancement
13+
- title: Documentation and Localization
14+
labels:
15+
- documentation
16+
- locales
17+
- title: Bug Fixes
18+
labels:
19+
- bug
20+
- title: Other Changes
21+
labels:
22+
- "*"

Docs/Policies.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Project Policies
2+
3+
This document records the policies currently in place under which the Project Team operates.
4+
5+
## License
6+
7+
The [GNU Public License](http://www.gnu.org/licenses/licenses.html) allows a user to use Open Rails in any way, except that you may not distribute software containing part of Open Rails without respecting the license terms.
8+
9+
## Liability
10+
11+
Open Rails is intended for entertainment purposes only and, to avoid liability, is not suitable for professional applications.
12+
13+
## Code Submissions
14+
15+
[Code contributions](https://github.com/openrails/openrails/blob/master/Docs/Contributing.md) to our repository must be in Microsoft's C# language. An authorised developer may not change content in the official version of Open Rails without approval from another authorised developer.
16+
17+
## Content Compatibility
18+
19+
Open Rails will continue to maintain compatibility with content from previous official versions of Open Rails.
20+
21+
## File Formats
22+
23+
New types of content will use the JavaScript Object Notation (JSON).
24+
Existing types of content from previous official versions of Open Rails will continue to be loaded without change.
25+
26+
## Keyboard Assignments
27+
28+
New key assignments should obey the following rules where that is possible.
29+
30+
* Reserve digit keys for camera operations.
31+
* Reserve Fn keys for pop-up windows.
32+
* Reserve the Alt modifier for debug operations.
33+
* Reserve modifier+space (e.g. Ctrl+space) for future expansion using sequences of keys.
34+
35+
Existing key assignments may not be changed without community discussion and approval of the Open Rails Management Team.
36+
37+
## Crashes and Derailments
38+
39+
Open Rails simulates emergency events which bring a train to a standstill, such as a derailment, and provides both a visual indication and a notification of the problem.
40+
41+
Open Rails does not show rolling stock leaving the track due to crashes or derailments. We have many members from the rail industry who have spent their working lives preventing incidents that cause injuries and loss of life and we respect that point of view.

Docs/Readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ Open Rails is a free train simulator supporting the world's largest range of dig
1919
* [Join the community](http://www.openrails.org/share/community/?utm_campaign=documentation&utm_source=readme&utm_medium=referral)
2020
* [Report bugs or offer suggestions](http://www.openrails.org/contribute/reporting-bugs/?utm_campaign=documentation&utm_source=readme&utm_medium=referral)
2121
* [Create content](http://www.openrails.org/contribute/building-models/?utm_campaign=documentation&utm_source=readme&utm_medium=referral)
22+
* [How to propose and submit work](Contributing.md)
2223
* [Write code](http://www.openrails.org/contribute/developing-code/?utm_campaign=documentation&utm_source=readme&utm_medium=referral)
2324
* [Join the team](http://www.openrails.org/contribute/joining-the-team/?utm_campaign=documentation&utm_source=readme&utm_medium=referral)
24-
* [More details](Contributing.md)
25+
2526

2627
## Build status
2728

Source/Contrib/TrackViewer/Drawing/DrawColors.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ static class DrawColors
4646
public static ColorScheme colorsRoadsHotlight = new ColorScheme(HighlightType.Hotlight);
4747
public static ColorScheme colorsPathMain = new ColorScheme();
4848
public static ColorScheme colorsPathSiding = new ColorScheme();
49+
public static ColorScheme colorsEvent = new ColorScheme();
4950

5051
static ColorsGroupTrack trackGroupFlat = new ColorsGroupTrack();
5152
static ColorsGroupTrack roadTrackGroupFlat = new ColorsGroupTrack();
@@ -212,6 +213,11 @@ private static void SetItemColors(IPreferenceChanger preferenceChanger)
212213
TrackViewer.catalog.GetString("Select speedpost color"));
213214
itemColors.Speedpost = itemColor;
214215

216+
itemColor = new ColorWithHighlights(Color.DarkGray, 40);
217+
itemColor.MakeIntoUserPreference(preferenceChanger, "event",
218+
TrackViewer.catalog.GetString("Select event color"));
219+
itemColors.Event = itemColor;
220+
215221
itemColor = new ColorWithHighlights(Color.Blue, 40);
216222
itemColors.CandidateNode = itemColor;
217223

@@ -321,6 +327,7 @@ class ColorsGroupBasic {
321327
public ColorWithHighlights RoadCrossing { get; set; }
322328
public ColorWithHighlights Speedpost { get; set; }
323329
public ColorWithHighlights Siding { get; set; }
330+
public ColorWithHighlights Event { get; set; }
324331

325332
public ColorWithHighlights Text { get; set; }
326333
public ColorWithHighlights ClearWindowInset { get; set; }
@@ -362,6 +369,7 @@ class ColorScheme
362369
public Color RoadCrossing { get { return TrackItemColors.RoadCrossing.Colors[highlightType]; } }
363370
public Color Speedpost { get { return TrackItemColors.Speedpost.Colors[highlightType]; } }
364371
public Color Siding { get { return TrackItemColors.Siding.Colors[highlightType]; } }
372+
public Color Event { get { return TrackItemColors.Event.Colors[highlightType]; } }
365373

366374
public Color ActiveNode { get { return TrackItemColors.ActiveNode.Colors[highlightType]; } }
367375
public Color CandidateNode { get { return TrackItemColors.CandidateNode.Colors[highlightType]; } }

Source/Contrib/TrackViewer/Drawing/DrawTrackDB.cs

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public class RouteData
4545
public RoadTrackDB RoadTrackDB { get; set; }
4646
/// <summary>The signal config file containing, for instance, the information to distinguish normal and non-normal signals</summary>
4747
public SignalConfigurationFile SigcfgFile { get; set; }
48+
/// <summary>
49+
/// <summary>Activity names</summary>
50+
/// </summary>
51+
public List<string> ActivityNames = new List<string> { };
4852

4953
private string storedRoutePath;
5054
private Dictionary<uint, string> signalFileNames;
@@ -87,7 +91,7 @@ public RouteData(string routePath, MessageDelegate messageDelegate)
8791
}
8892
catch
8993
{
90-
}
94+
}
9195

9296
string ORfilepath = System.IO.Path.Combine(routePath, "OpenRails");
9397
if (File.Exists(ORfilepath + @"\sigcfg.dat"))
@@ -102,6 +106,72 @@ public RouteData(string routePath, MessageDelegate messageDelegate)
102106
{
103107
//sigcfgFile = null; // default initialization
104108
}
109+
110+
// read the activity location events and store them in the TrackDB.TrItemTable
111+
112+
ActivityNames.Clear();
113+
var directory = System.IO.Path.Combine(routePath, "ACTIVITIES");
114+
if (System.IO.Directory.Exists(directory))
115+
{
116+
// counting
117+
int cnt = 0;
118+
119+
foreach (var file in Directory.GetFiles(directory, "*.act"))
120+
{
121+
try
122+
{
123+
var activityFile = new ActivityFile(file);
124+
Events events = activityFile.Tr_Activity.Tr_Activity_File.Events;
125+
if (events != null)
126+
{
127+
for (int i = 0; i < events.EventList.Count; i++)
128+
{
129+
if (events.EventList[i].GetType() == typeof(EventCategoryLocation))
130+
{
131+
cnt++;
132+
}
133+
}
134+
}
135+
}
136+
catch { }
137+
}
138+
139+
// adding
140+
uint index = 0;
141+
foreach (var file in Directory.GetFiles(directory, "*.act"))
142+
{
143+
try
144+
{
145+
var activityFile = new ActivityFile(file);
146+
Events events = activityFile.Tr_Activity.Tr_Activity_File.Events;
147+
bool found = false;
148+
if (events != null)
149+
{
150+
for (int i = 0; i < events.EventList.Count; i++)
151+
{
152+
if (events.EventList[i].GetType() == typeof(EventCategoryLocation))
153+
{
154+
EventCategoryLocation eventCategoryLocation = (EventCategoryLocation)events.EventList[i];
155+
EventItem eventItem = new EventItem(
156+
activityFile.Tr_Activity.Tr_Activity_Header.Name + ":" + eventCategoryLocation.Name,
157+
eventCategoryLocation.Outcomes.DisplayMessage,
158+
eventCategoryLocation.TileX, eventCategoryLocation.TileZ,
159+
eventCategoryLocation.X, 0, eventCategoryLocation.Z,
160+
index);
161+
TrackDB.TrItemTable[index] = eventItem;
162+
index++;
163+
found = true;
164+
}
165+
}
166+
}
167+
if (found) {
168+
ActivityNames.Add(activityFile.Tr_Activity.Tr_Activity_Header.Name);
169+
}
170+
}
171+
catch { }
172+
}
173+
174+
}
105175
}
106176

107177
/// <summary>
@@ -176,6 +246,32 @@ public string GetSignalFilename(uint signalIndex)
176246
}
177247
}
178248

249+
/// <summary>
250+
/// represents an Activity Location EventItem
251+
/// </summary>
252+
/// defined in this trackviewer file because I want to keep changes localized to the TrackViewer
253+
254+
public class EventItem : TrItem
255+
{
256+
/// <summary>
257+
/// Default constructor, no file parsing used
258+
/// </summary>
259+
public EventItem(string itemName, string briefing, int tileX, int tileZ, float x, float y, float z, uint trItemId)
260+
{
261+
// ItemType is trEMPTY on purpose
262+
// so that Orts.Formats.Msts.TrItem.trItemType does not need a change
263+
ItemType = trItemType.trEMPTY;
264+
ItemName = itemName;
265+
TileX = tileX;
266+
TileZ = tileZ;
267+
X = x;
268+
Y = y;
269+
Z = z;
270+
TrItemId = trItemId;
271+
SData2 = briefing;
272+
}
273+
}
274+
179275
/// <summary>
180276
/// This is a big class where the drawing of everything in the track data base is done.
181277
/// This means tracks themselves (meaning so-called vector nodes that contain a number of sections,

Source/Contrib/TrackViewer/Drawing/DrawableTrackItem.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public static DrawableTrackItem CreateDrawableTrItem(TrItem originalTrItem)
7070
if (originalTrItem is RoadLevelCrItem){ return new DrawableRoadLevelCrItem(originalTrItem); }
7171
if (originalTrItem is CarSpawnerItem) { return new DrawableCarSpawnerItem(originalTrItem); }
7272
if (originalTrItem is CrossoverItem) { return new DrawableCrossoverItem(originalTrItem); }
73+
if (originalTrItem is EventItem) { return new DrawableEvent(originalTrItem); }
7374
return new DrawableEmptyItem(originalTrItem);
7475
}
7576

@@ -605,4 +606,51 @@ internal override bool Draw(DrawArea drawArea, ColorScheme colors, bool drawAlwa
605606
}
606607
}
607608
#endregion
609+
610+
#region DrawableEvent
611+
/// <summary>
612+
/// Represents a drawable event
613+
/// </summary>
614+
class DrawableEvent : DrawableTrackItem
615+
{
616+
private string ItemName;
617+
618+
/// <summary>
619+
/// Default constructor
620+
/// </summary>
621+
/// <param name="originalTrItem">The original track item that we are representing for drawing</param>
622+
public DrawableEvent(TrItem originalTrItem)
623+
: base(originalTrItem)
624+
{
625+
Description = "event";
626+
ItemName = originalTrItem.ItemName;
627+
}
628+
629+
/// <summary>
630+
/// Draw an event
631+
/// </summary>
632+
/// <param name="drawArea">The area to draw upon</param>
633+
/// <param name="colors">The colorscheme to use</param>
634+
/// <param name="drawAlways">Do we need to draw anyway, independent of settings?</param>
635+
internal override bool Draw(DrawArea drawArea, ColorScheme colors, bool drawAlways)
636+
{
637+
bool returnValue = false;
638+
if (String.IsNullOrEmpty(Properties.Settings.Default.CurrentActivityName) ||
639+
(ItemName.StartsWith(Properties.Settings.Default.CurrentActivityName + ":")))
640+
{
641+
if (Properties.Settings.Default.showEvents || drawAlways)
642+
{
643+
drawArea.DrawTexture(WorldLocation, "disc", 6f, 0, colors.Event);
644+
returnValue = true;
645+
}
646+
if (Properties.Settings.Default.showEventNames || drawAlways)
647+
{
648+
drawArea.DrawExpandingString(this.WorldLocation, ItemName);
649+
returnValue = true;
650+
}
651+
}
652+
return returnValue;
653+
}
654+
}
655+
#endregion
608656
}

Source/Contrib/TrackViewer/Editing/Charts/DrawPathChart.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ private void OnPathChanged()
161161
}
162162
pathData.Update(trainpath);
163163
chartWindow.Draw();
164-
chartWindow.SetTitle(pathEditor.CurrentTrainPath.PathName);
165164
}
166165

167166
/// <summary>

Source/Contrib/TrackViewer/Editing/Charts/PathChartWindow.xaml.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,6 @@ public void Draw()
9191
}
9292

9393
}
94-
95-
/// <summary>
96-
/// Set the title of the window
97-
/// </summary>
98-
/// <param name="newTitle"></param>
99-
public void SetTitle(string newTitle)
100-
{
101-
this.Title = newTitle;
102-
}
10394
#endregion
10495

10596
#region Window events

0 commit comments

Comments
 (0)