mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Make site code formatting helper method
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
- Add support for all ISO language codes
|
||||
- Add support for all ISO region codes
|
||||
- Ensure ordering in output site tags
|
||||
- Make site code formatting helper method
|
||||
|
||||
### 2.2 (2021-12-30)
|
||||
- Fix Saturn header finding
|
||||
|
||||
@@ -892,22 +892,7 @@ namespace MPF.Library
|
||||
"\n", info.CommonDiscInfo.CommentsSpecialFields
|
||||
.OrderBy(kvp => kvp.Key)
|
||||
.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Value))
|
||||
.Select(kvp =>
|
||||
{
|
||||
bool isMultiLine = IsMultiLine(kvp.Key);
|
||||
string line = $"{kvp.Key.ShortName()}{(isMultiLine ? "\n" : " ")}";
|
||||
|
||||
// Special case for boolean fields
|
||||
if (kvp.Key == SiteCode.PostgapType || kvp.Key == SiteCode.VCD)
|
||||
{
|
||||
if (kvp.Value != true.ToString())
|
||||
return string.Empty;
|
||||
|
||||
return line.Trim();
|
||||
}
|
||||
|
||||
return $"{line}{kvp.Value}{(isMultiLine ? "\n" : string.Empty)}";
|
||||
})
|
||||
.Select(FormatSiteTag)
|
||||
.Where(s => !string.IsNullOrEmpty(s))
|
||||
) + "\n" + info.CommonDiscInfo.Comments;
|
||||
|
||||
@@ -930,22 +915,7 @@ namespace MPF.Library
|
||||
"\n", info.CommonDiscInfo.ContentsSpecialFields
|
||||
.OrderBy(kvp => kvp.Key)
|
||||
.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Value))
|
||||
.Select(kvp =>
|
||||
{
|
||||
bool isMultiLine = IsMultiLine(kvp.Key);
|
||||
string line = $"{kvp.Key.ShortName()}{(isMultiLine ? "\n" : " ")}";
|
||||
|
||||
// Special case for boolean fields
|
||||
if (kvp.Key == SiteCode.PostgapType || kvp.Key == SiteCode.VCD)
|
||||
{
|
||||
if (kvp.Value != true.ToString())
|
||||
return string.Empty;
|
||||
|
||||
return line.Trim();
|
||||
}
|
||||
|
||||
return $"{line}{kvp.Value}{(isMultiLine ? "\n" : string.Empty)}";
|
||||
})
|
||||
.Select(FormatSiteTag)
|
||||
.Where(s => !string.IsNullOrEmpty(s))
|
||||
) + "\n" + info.CommonDiscInfo.Contents;
|
||||
|
||||
@@ -1090,6 +1060,28 @@ namespace MPF.Library
|
||||
AddIfExists(output, key, string.Join(", ", value.Select(o => o.ToString())), indent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Format a single site tag to string
|
||||
/// </summary>
|
||||
/// <param name="kvp">KeyValuePair representing the site tag and value</param>
|
||||
/// <returns>String-formatted tag and value</returns>
|
||||
private static string FormatSiteTag(KeyValuePair<SiteCode?, string> kvp)
|
||||
{
|
||||
bool isMultiLine = IsMultiLine(kvp.Key);
|
||||
string line = $"{kvp.Key.ShortName()}{(isMultiLine ? "\n" : " ")}";
|
||||
|
||||
// Special case for boolean fields
|
||||
if (kvp.Key == SiteCode.PostgapType || kvp.Key == SiteCode.VCD)
|
||||
{
|
||||
if (kvp.Value != true.ToString())
|
||||
return string.Empty;
|
||||
|
||||
return line.Trim();
|
||||
}
|
||||
|
||||
return $"{line}{kvp.Value}{(isMultiLine ? "\n" : string.Empty)}";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Normalization
|
||||
|
||||
Reference in New Issue
Block a user