Enhance map layout and room definitions by adding optional labels for rooms and updating the API to support new room naming conventions. Introduce additional room types and localization strings for improved user experience in both English and Russian. Refactor map view logic to accommodate new room attributes and ensure accurate rendering in the UI. Update tests to validate changes in room structure and localization.
This commit is contained in:
@@ -52,6 +52,9 @@ public sealed class RoomNode
|
||||
|
||||
public required string Floor { get; init; }
|
||||
|
||||
/// <summary>Optional designation such as a classroom number. The def label still supplies the noun.</summary>
|
||||
public string? Label { get; init; }
|
||||
|
||||
public IReadOnlyList<SlotFill> Slots { get; init; } = [];
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public static class MapView
|
||||
MapNodeKind.Room,
|
||||
room.Id,
|
||||
room.Floor,
|
||||
LabelOf(catalog, locale, DefKind.Room, room.Def),
|
||||
RoomName(catalog, locale, room),
|
||||
items,
|
||||
PositionsOf(catalog, locale, DefKind.Room, room.Def)));
|
||||
}
|
||||
@@ -117,12 +117,17 @@ public static class MapView
|
||||
private static string FloorName(DefCatalog catalog, string locale, FloorNode floor)
|
||||
{
|
||||
var defLabel = LabelOf(catalog, locale, DefKind.Floor, floor.Def);
|
||||
if (string.IsNullOrWhiteSpace(floor.Label))
|
||||
{
|
||||
return defLabel;
|
||||
}
|
||||
return string.IsNullOrWhiteSpace(floor.Label) ? defLabel : $"{defLabel} {floor.Label}";
|
||||
}
|
||||
|
||||
return defLabel == floor.Def ? floor.Label : $"{defLabel} {floor.Label}";
|
||||
/// <summary>
|
||||
/// Same rule as floors: <see cref="RoomNode.Label"/> is "1A", not a replacement for "Classroom".
|
||||
/// Do not treat "label equals defName" as "untranslated" — English classrooms are named Classroom.
|
||||
/// </summary>
|
||||
private static string RoomName(DefCatalog catalog, string locale, RoomNode room)
|
||||
{
|
||||
var defLabel = LabelOf(catalog, locale, DefKind.Room, room.Def);
|
||||
return string.IsNullOrWhiteSpace(room.Label) ? defLabel : $"{defLabel} {room.Label}";
|
||||
}
|
||||
|
||||
private static string LabelOf(DefCatalog catalog, string locale, DefKind kind, string defName) =>
|
||||
|
||||
Reference in New Issue
Block a user