mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-21 15:54:58 +01:00
Keep each file's encoding in the copy written for a start
The copy carries the scenario includes put in place of their include lines, read as UTF-8 where they are, and it was written all in code page 1250. A name with a Polish letter in a UTF-8 include then no longer matched the same name in the files the simulator reads apart, and what 1250 lacks became '?'. Each part now goes out in the encoding of the file it came from, the scenery's own file too, as a save of a trainset already did.
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using StarterNG.Application.Abstractions;
|
||||
using StarterNG.Classes;
|
||||
using StarterNG.Infrastructure.Adapters;
|
||||
|
||||
namespace StarterNG.Domain.Sceneries;
|
||||
|
||||
@@ -67,6 +68,12 @@ public sealed class Scenery
|
||||
/// </summary>
|
||||
public IReadOnlyDictionary<string, FileStamp?> Sources { get; set; } = new Dictionary<string, FileStamp?>();
|
||||
|
||||
/// <summary>What its own file is written in, for the copy written for a start to be in the same.</summary>
|
||||
public Encoding TextEncoding { get; set; } = LegacyText.CodePage1250;
|
||||
|
||||
/// <summary>What each file put in place of its include is written in, by the name its marker carries.</summary>
|
||||
public IReadOnlyDictionary<string, Encoding> IncludeEncodings { get; set; } = new Dictionary<string, Encoding>();
|
||||
|
||||
public string DisplayName => System.IO.Path.GetFileNameWithoutExtension(Path);
|
||||
|
||||
public string LocalizedDescription(ISceneryTranslations translations) =>
|
||||
@@ -99,6 +106,13 @@ public sealed class Scenery
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="BuildExportContent"/> as the file to write: each part in the encoding of
|
||||
/// the file it came from, so the simulator gets every word as that file has it.
|
||||
/// </summary>
|
||||
public byte[] BuildExportBytes(bool skipDecorTrainsets, IRandomSource random) =>
|
||||
SceneryIncludes.Encode(BuildExportContent(skipDecorTrainsets, random), TextEncoding, IncludeEncodings);
|
||||
|
||||
private string AppendLooseVehicles(string text)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
Reference in New Issue
Block a user