Add scenery list parser

This commit is contained in:
2026-02-11 14:40:16 +01:00
parent 9c639a87f5
commit 19a2ac8d59
11 changed files with 300 additions and 20 deletions

View File

@@ -1,16 +1,28 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 18
VisualStudioVersion = 18.1.11312.151 d18.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StarterNG", "StarterNG\StarterNG.csproj", "{D1E8A3A3-3269-415A-94AD-D6F370D7E4FD}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StarterNG", "StarterNG\StarterNG.csproj", "{D1E8A3A3-3269-415A-94AD-D6F370D7E4FD}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D1E8A3A3-3269-415A-94AD-D6F370D7E4FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D1E8A3A3-3269-415A-94AD-D6F370D7E4FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1E8A3A3-3269-415A-94AD-D6F370D7E4FD}.Debug|Any CPU.Build.0 = Debug|Any CPU {D1E8A3A3-3269-415A-94AD-D6F370D7E4FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1E8A3A3-3269-415A-94AD-D6F370D7E4FD}.Debug|x64.ActiveCfg = Debug|x64
{D1E8A3A3-3269-415A-94AD-D6F370D7E4FD}.Debug|x64.Build.0 = Debug|x64
{D1E8A3A3-3269-415A-94AD-D6F370D7E4FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {D1E8A3A3-3269-415A-94AD-D6F370D7E4FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1E8A3A3-3269-415A-94AD-D6F370D7E4FD}.Release|Any CPU.Build.0 = Release|Any CPU {D1E8A3A3-3269-415A-94AD-D6F370D7E4FD}.Release|Any CPU.Build.0 = Release|Any CPU
{D1E8A3A3-3269-415A-94AD-D6F370D7E4FD}.Release|x64.ActiveCfg = Release|x64
{D1E8A3A3-3269-415A-94AD-D6F370D7E4FD}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@@ -1,9 +1,15 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACultureInfo_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fab103317a9fe11e3738e327b94ff38c20438b33e5d64ea21aa6fe7297a2cd5b_003FCultureInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACursor_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fa7f93665b4356a06f3cf982169411cf193d28423c1b8ab119423d4fd19ccd1_003FCursor_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACursor_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fa7f93665b4356a06f3cf982169411cf193d28423c1b8ab119423d4fd19ccd1_003FCursor_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEncoding_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003F1675dc7b710feeeb3e0bc8728be8a947537155c199480fb23b776e81d459_003FEncoding_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AInputElement_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003F3a2dc32e584992fd11eb82d1a1da165d8e52d7c736fb38d90ce2e9de8ff31ab_003FInputElement_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AInputElement_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003F3a2dc32e584992fd11eb82d1a1da165d8e52d7c736fb38d90ce2e9de8ff31ab_003FInputElement_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMethodBaseInvoker_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F53428d95742549e8968df3e76ebd1d7de8e928_003Fce_003Fb6adf085_003FMethodBaseInvoker_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMethodBaseInvoker_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F53428d95742549e8968df3e76ebd1d7de8e928_003Fce_003Fb6adf085_003FMethodBaseInvoker_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANumber_002EParsing_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fde8a243f75215d958afa80cf80a41b4981a44efea7db93bffcdaf7bd6ba378c0_003FNumber_002EParsing_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AProcess_002EWindows_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fe4b93d8bba7294f6676125d63f2c965fc3e4293b7fac7f8460a64f1950f84d9_003FProcess_002EWindows_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AProcess_002EWindows_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fe4b93d8bba7294f6676125d63f2c965fc3e4293b7fac7f8460a64f1950f84d9_003FProcess_002EWindows_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AStarterNG_002EMainWindow_002Eg_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fe3e158158d7662e3d588342a349d6a29b4cf57_003FStarterNG_002EMainWindow_002Eg_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AStarterNG_002EMainWindow_002Eg_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fe3e158158d7662e3d588342a349d6a29b4cf57_003FStarterNG_002EMainWindow_002Eg_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASvgDocument_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fc89c4efb3d60208a50dd75ff12772229193779693bbd59534fd57d83f645d3d6_003FSvgDocument_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASvgDocument_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fc89c4efb3d60208a50dd75ff12772229193779693bbd59534fd57d83f645d3d6_003FSvgDocument_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fc7102cd0ffb8973777e61b1942c3fffac7e14016a511d055c3adf73ff91748_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AVisual_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003F85fdd7bdff5ab3bf6e3dd75da8acd9fff1826782ae485f15c5520f43334124_003FVisual_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AVisual_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003F85fdd7bdff5ab3bf6e3dd75da8acd9fff1826782ae485f15c5520f43334124_003FVisual_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AXmlTextReaderImpl_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fbc9697fd33d155285d293cdbafb62d6815c18a97c1f95c35a1ee118fc8965c87_003FXmlTextReaderImpl_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AXmlTextReaderImpl_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fbc9697fd33d155285d293cdbafb62d6815c18a97c1f95c35a1ee118fc8965c87_003FXmlTextReaderImpl_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/CustomBuildToolPath/@EntryValue">E:\Program Files\Microsoft Visual Studio\18\Community\MSBuild\Current\Bin\amd64\MSBuild.exe</s:String>
<s:Int64 x:Key="/Default/Environment/Hierarchy/Build/BuildTool/MsbuildVersion/@EntryValue">1179648</s:Int64></wpf:ResourceDictionary>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,50 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
namespace StarterNG.Classes;
public class Scenery
{
public List<string> Lines;
public List<Trainset> Trainsets;
public string Group;
public string Path;
public Scenery(string path)
{
this.Path = path;
Trainsets = new List<Trainset>();
if (!File.Exists(path))
throw new FileNotFoundException(path);
var encoding = Encoding.GetEncoding(1250); // Windows-1250
string content = File.ReadAllText(path, encoding);
// property scanning
var match = Regex.Match(
content,
@"^//\$l\s*([^\r\n]*)",
RegexOptions.Multiline
);
this.Group = match.Success ? match.Groups[1].Value : null;
// parsing trainsets
List<string> trainsetEntries = new List<string>();
Regex regex = new Regex(
@"trainset\b[\s\S]*?\bendtrainset\b",
RegexOptions.IgnoreCase
);
int idx = 0;
content = regex.Replace(content, match =>
{
trainsetEntries.Add(match.Value);
return $"{{{{{idx++}}}}}";
});
foreach (string trainsetEntry in trainsetEntries)
{
Trainsets.Add(new Trainset(trainsetEntry));
}
}
}

View File

@@ -0,0 +1,155 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Text.RegularExpressions;
namespace StarterNG.Classes;
public enum eDriverType
{
Headdriver,
Reardriver,
Passanger,
Nobody
}
public class Trainset
{
public string Name;
public string Track;
public float Offset;
public float Velocity;
public List<Dynamic> Vehicles;
public Trainset(string trainsetEntry)
{
Vehicles = new List<Dynamic>();
List<string> tokens = Regex
.Matches(trainsetEntry, @"\r\n|\n|[^\s]+")
.Select(m => m.Value)
.ToList();
for (int i = 0; i < tokens.Count; i++)
{
// handle comments
if (tokens[i].StartsWith("//"))
{
while (tokens[i] != "\n" && tokens.Count < i) i++;
}
// trainset properties
if (tokens[i] == "trainset")
{
i++;
this.Name = tokens[i++];
this.Track = tokens[i++];
this.Offset = float.Parse(tokens[i++], CultureInfo.InvariantCulture);
this.Velocity = float.Parse(tokens[i++], CultureInfo.InvariantCulture);
continue;
}
// skip entire assignments block
if (tokens[i] == "assignments")
{
while (tokens[i] != "endassignment") i++;
}
// load vehicles
if (tokens[i] == "node")
{
i++; // node keyword
Dynamic nodeDynamic = new Dynamic();
nodeDynamic.RangeMax = float.Parse(tokens[i++], CultureInfo.InvariantCulture);
nodeDynamic.RangeMin = float.Parse(tokens[i++], CultureInfo.InvariantCulture);
nodeDynamic.Name = tokens[i++];
i++; // dynamic keyword
nodeDynamic.DataFolder = tokens[i++];
nodeDynamic.SkinFile = tokens[i++];
nodeDynamic.MmdFile = tokens[i++];
i++; // skip offset
string driverType = tokens[i++];
switch (driverType)
{
case "headdriver":
nodeDynamic.DriverType = eDriverType.Headdriver;
break;
case "reardriver":
nodeDynamic.DriverType = eDriverType.Reardriver;
break;
case "passanger":
nodeDynamic.DriverType = eDriverType.Passanger;
break;
default:
nodeDynamic.DriverType = eDriverType.Nobody;
break;
}
nodeDynamic.couplingData = (byte)int.Parse(tokens[i++].Split('.')[0]);
nodeDynamic.Tail = "";
while (tokens[i] != "enddynamic")
{
nodeDynamic.Tail += " " + tokens[i];
i++;
}
Vehicles.Add(nodeDynamic);
}
}
}
public string GetTrainsetEntry()
{
string entry = "";
entry += "trainset ";
entry += this.Name + " ";
entry += this.Track + " ";
entry += this.Offset + " ";
entry += this.Velocity + " ";
entry += "\n";
foreach (Dynamic vehicle in Vehicles)
{
string driverType = "";
switch (vehicle.DriverType)
{
case eDriverType.Headdriver:
driverType = "headdriver";
break;
case eDriverType.Reardriver:
driverType = "reardriver";
break;
case eDriverType.Passanger:
driverType = "passanger";
break;
default:
driverType = "nobody";
break;
}
entry +=
$"node {vehicle.RangeMax} {vehicle.RangeMin} {vehicle.Name} dynamic {vehicle.DataFolder} {vehicle.SkinFile} {vehicle.MmdFile} {driverType} {vehicle.couplingData} {vehicle.Tail}\n";
}
return entry;
}
}
public class Dynamic
{
public float RangeMax;
public float RangeMin;
public string Name;
public string DataFolder;
public string SkinFile;
public string MmdFile;
public string PathName;
public float Offset;
public eDriverType DriverType;
public byte couplingData;
public string Tail;
}

View File

@@ -8,7 +8,7 @@
xmlns:svg="clr-namespace:Avalonia.Svg;assembly=Avalonia.Svg" xmlns:svg="clr-namespace:Avalonia.Svg;assembly=Avalonia.Svg"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="clr-namespace:StarterNG.Views" BackgroundStyle="Bubble" xmlns:views="clr-namespace:StarterNG.Views" BackgroundStyle="Bubble"
Title="MaSzyna - Symulator pojazdów szynowych" Height="600" Width="800"> Title="MaSzyna - Symulator pojazdów szynowych" Height="800" Width="1000">
<sukiUi:SukiSideMenu IsMenuExpanded="False"> <sukiUi:SukiSideMenu IsMenuExpanded="False">
<sukiUi:SukiSideMenu.Items> <sukiUi:SukiSideMenu.Items>
<!-- SCENARIUSZE --> <!-- SCENARIUSZE -->

View File

@@ -1,4 +1,5 @@
using System.Diagnostics; using System.Diagnostics;
using System.Text;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using SukiUI.Controls; using SukiUI.Controls;
@@ -8,6 +9,7 @@ public partial class MainWindow : SukiWindow
{ {
public MainWindow() public MainWindow()
{ {
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
InitializeComponent(); InitializeComponent();
} }
private void linkClick(object? sender, RoutedEventArgs e) private void linkClick(object? sender, RoutedEventArgs e)

View File

@@ -0,0 +1,8 @@
{
"profiles": {
"StarterNG": {
"commandName": "Project",
"workingDirectory": "E:\\Hirek\\Games\\Steam\\steamapps\\common\\MaSzyna"
}
}
}

View File

@@ -6,6 +6,7 @@
<BuiltInComInteropSupport>true</BuiltInComInteropSupport> <BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest> <ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault> <AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
@@ -30,10 +31,6 @@
<PackageReference Include="SukiUI" Version="6.0.3" /> <PackageReference Include="SukiUI" Version="6.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Assets\Logo\" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Remove="Assets\Logo\maszyna_black.svg" /> <None Remove="Assets\Logo\maszyna_black.svg" />
<AvaloniaResource Include="Assets\Logo\maszyna_black.svg" /> <AvaloniaResource Include="Assets\Logo\maszyna_black.svg" />

View File

@@ -7,7 +7,7 @@
x:Class="StarterNG.Views.Scenarios"> x:Class="StarterNG.Views.Scenarios">
<Grid Margin="16" ColumnSpacing="16" RowSpacing="16"> <Grid Margin="16" ColumnSpacing="16" RowSpacing="16">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="200" /> <ColumnDefinition Width="300" />
<ColumnDefinition /> <ColumnDefinition />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@@ -17,18 +17,8 @@
<RowDefinition Height="40" /> <RowDefinition Height="40" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<sukiUi:GroupBox Grid.RowSpan="2" Header="Scenerie"> <sukiUi:GroupBox Grid.RowSpan="2" Header="Scenerie">
<TreeView> <TreeView Name="sceneryList">
<TreeViewItem Header="Bałtyk">
<TreeViewItem Header="Bałtyk Euro 2012" />
<TreeViewItem Header="Bałtyk SKM 1" />
<TreeViewItem Header="Bałtyk SKM 2" />
</TreeViewItem>
<TreeViewItem Header="Linia 053">
<TreeViewItem Header="Linia 053 - poranek" />
<TreeViewItem Header="Linia 053 - południe" />
<TreeViewItem Header="Linia 053 - wieczór" />
<TreeViewItem Header="Linia 053 - noc" />
</TreeViewItem>
</TreeView> </TreeView>
</sukiUi:GroupBox> </sukiUi:GroupBox>
<sukiUi:GroupBox Grid.Column="1" Header="Pojazdy"> <sukiUi:GroupBox Grid.Column="1" Header="Pojazdy">

View File

@@ -1,13 +1,73 @@
using Avalonia; using System.Collections.Generic;
using System.IO;
using System.Linq;
using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using StarterNG.Classes;
namespace StarterNG.Views; namespace StarterNG.Views;
public partial class Scenarios : UserControl public partial class Scenarios : UserControl
{ {
public List<Scenery> sceneries;
public Scenarios() public Scenarios()
{ {
InitializeComponent(); InitializeComponent();
sceneries = new List<Scenery>();
// load sceneries
List<string> scnFiles = Directory.GetFiles("scenery/", "*.scn").ToList();
foreach (string scnFile in scnFiles)
{
// skip temp sceneries
if (Path.GetFileName(scnFile).StartsWith("$"))
continue;
// Parse all files
sceneries.Add(new Scenery(scnFile));
}
var groupNodes = new Dictionary<string, TreeViewItem>();
for (int i = 0; i < sceneries.Count; i++)
{
var scenery = sceneries[i];
// case 1: no group - put without parent
if (string.IsNullOrEmpty(scenery.Group))
{
sceneryList.Items.Add(new TreeViewItem
{
Header = Path.GetFileNameWithoutExtension(scenery.Path),
Tag = i
});
continue;
}
// case 2 - group scenery with others
if (!groupNodes.TryGetValue(scenery.Group, out var groupNode))
{
groupNode = new TreeViewItem
{
Header = scenery.Group,
IsExpanded = true
};
groupNodes[scenery.Group] = groupNode;
sceneryList.Items.Add(groupNode);
}
groupNode.Items.Add(new TreeViewItem
{
Header = Path.GetFileNameWithoutExtension(scenery.Path),
Tag = i
});
}
} }
} }