diff --git a/docs/launcher.md b/docs/launcher.md index 942662c..88c03e1 100644 --- a/docs/launcher.md +++ b/docs/launcher.md @@ -1088,8 +1088,10 @@ starts every update): downloads run side by side, and the checkout operations wa one at a time. Installs, uninstalls and builds waiting together run as one operation of their kind: one save backup, and the builds in parallel. A failed one opens the operation log. -Clicking a row opens the mod's page: its README (Overview, drawn as GitHub-flavoured Markdown with Markdig; images -show their alt text, HTML is left out, relative links open the mod's folder on GitHub), its shared settings editor +Mod names, descriptions and settings labels use the selected interface language when a translation exists. Search +matches both the manifest text and its translation. Clicking a row opens the mod's page: its README (Overview, +drawn as GitHub-flavoured Markdown with Markdig; images show their alt text, HTML is left out, relative links open +the mod's folder on GitHub), its shared settings editor (all declared types below; written to `data/mods/.json`, which holds only what differs from the defaults, and a running Gateway reloads the mod), and its releases (Versions, each installable). The page scrolls as one, its heading and tabs with it; the back button stays above it, and the settings' Save bar below it on the Settings tab. Right-clicking a diff --git a/src/Launcher.Core/ModSettingsForm.cs b/src/Launcher.Core/ModSettingsForm.cs index e81abcd..f7dda9b 100644 --- a/src/Launcher.Core/ModSettingsForm.cs +++ b/src/Launcher.Core/ModSettingsForm.cs @@ -160,18 +160,18 @@ public static string Show(JsonNode? value, ModSetting? setting = null) { string text = (input as string ?? "").Trim().Replace(',', '.'); if (!double.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out double number) || !double.IsFinite(number)) - { error = L.Text("{0}: not a number", setting.Title); return null; } + { error = L.Text("{0}: not a number", L.Text(setting.Title)); return null; } if (setting.IsPercent) number /= 100; - if (setting.Type == "integer" && number != Math.Floor(number)) { error = L.Text("{0}: not a whole number", setting.Title); return null; } + if (setting.Type == "integer" && number != Math.Floor(number)) { error = L.Text("{0}: not a whole number", L.Text(setting.Title)); return null; } if (number < setting.Min || number > setting.Max) - { error = L.Text("{0}: from {1} to {2}", setting.Title, Show(JsonValue.Create(setting.Min ?? double.MinValue), setting), Show(JsonValue.Create(setting.Max ?? double.MaxValue), setting)); return null; } + { error = L.Text("{0}: from {1} to {2}", L.Text(setting.Title), Show(JsonValue.Create(setting.Min ?? double.MinValue), setting), Show(JsonValue.Create(setting.Max ?? double.MaxValue), setting)); return null; } return JsonValue.Create(number); } case "text": { string text = input as string ?? ""; if (text.Length < (setting.MinLength ?? 0) || text.Length > (setting.MaxLength ?? int.MaxValue)) - { error = L.Text("{0}: from {1} to {2} characters", setting.Title, setting.MinLength ?? 0, setting.MaxLength ?? int.MaxValue); return null; } + { error = L.Text("{0}: from {1} to {2} characters", L.Text(setting.Title), setting.MinLength ?? 0, setting.MaxLength ?? int.MaxValue); return null; } return JsonValue.Create(text); } case "choice": @@ -181,7 +181,7 @@ public static string Show(JsonNode? value, ModSetting? setting = null) var option = setting.Options.FirstOrDefault(o => Show(o.Value) == text || o.Label == text); if (option.Value is not null) return option.Value.DeepClone(); if (setting.Source.Length > 0 && text.Length > 0) return JsonValue.Create(text); - error = L.Text("{0}: choose one of its options", setting.Title); + error = L.Text("{0}: choose one of its options", L.Text(setting.Title)); return null; } case "choices": @@ -190,18 +190,18 @@ public static string Show(JsonNode? value, ModSetting? setting = null) .Select(t => (JsonNode)JsonValue.Create(t)); var list = new JsonArray(values.Select(v => v.DeepClone()).ToArray()); if (list.Count < (setting.MinItems ?? 0) || list.Count > (setting.MaxItems ?? int.MaxValue)) - { error = L.Text("{0}: choose from {1} to {2}", setting.Title, setting.MinItems ?? 0, setting.MaxItems ?? list.Count); return null; } + { error = L.Text("{0}: choose from {1} to {2}", L.Text(setting.Title), setting.MinItems ?? 0, setting.MaxItems ?? list.Count); return null; } return list; } default: - error = L.Text("{0}: edit this setting in the file", setting.Title); + error = L.Text("{0}: edit this setting in the file", L.Text(setting.Title)); return null; } } public static string? Validate(ModSetting setting, JsonNode? value) { - string? Invalid() => L.Text("{0}: the value does not match its declaration", setting.Title); + string? Invalid() => L.Text("{0}: the value does not match its declaration", L.Text(setting.Title)); if (value is null) return Invalid(); var kind = value.GetValueKind(); double Num(JsonNode n) => double.Parse(n.ToJsonString(), CultureInfo.InvariantCulture); diff --git a/src/Launcher.Core/Resources/Strings.resx b/src/Launcher.Core/Resources/Strings.resx index 5961f99..22e26ae 100644 --- a/src/Launcher.Core/Resources/Strings.resx +++ b/src/Launcher.Core/Resources/Strings.resx @@ -135,6 +135,9 @@ Pinned: + + Common currency preset + Built files and confirmed runtime status are separate. LocalExile watches mod files independently of Gateway code hot reload. Building or reloading resets the mod’s in-memory state and can reload dependents. Disabling a dependency can unload other mods. Changes affect every character on this Gateway. @@ -663,6 +666,9 @@ Ready to capture newly loaded areas. + + Worn pets collect selected currency with per-character filters and an immediate pause switch. + Closes the game; the servers keep running @@ -795,6 +801,9 @@ Set up LocalExile + + An optional native 20-slot extra backpack for every character class. + {0} is not a mod id Waypoint can use @@ -2082,6 +2091,9 @@ This checkout has modified tracked files. Friendship + + Only the 20 currencies listed in the README; explicit rules override it. + Could not open Waypoint @@ -2290,6 +2302,9 @@ This checkout has modified tracked files. Switch completed. + + Pet movement speed + This name is unused by your current leagues. @@ -3181,6 +3196,9 @@ This checkout has modified tracked files. Red–green friendly + + cells + release {0} has no {1} with its .sha256 @@ -3327,6 +3345,9 @@ Current saves are unchanged. This backup will no longer be available to restore. Game + + Character profiles + You can delete the folder yourself: {0} @@ -3369,6 +3390,9 @@ Current saves are unchanged. This backup will no longer be available to restore. Not signed in to Steam. + + Item overrides + Mod choices apply across all leagues. Saved choices do not confirm live load status. @@ -3601,6 +3625,9 @@ Search limits reached; other checkouts may exist. Browse to any location. · not made here + + Pickup radius + It also deletes the {0:0.#} GB already downloaded. @@ -4146,6 +4173,9 @@ Switching to it builds and runs that code on this computer with your rights, liv Crafting and trade + + Pet Loot + Settings @@ -4335,6 +4365,9 @@ Switching to it builds and runs that code on this computer with your rights, liv This LocalExile folder already has a game client, so nothing needs copying. + + Stackable divination cards + Loading areas … @@ -5336,6 +5369,9 @@ Dependencies: {3} Characters on selected account + + Pickup enabled + Search branches and pull requests @@ -5538,6 +5574,9 @@ Owned servers will stop. Automatic backup is {2}. Source, client and login keys {0}: {1} modifiers. {2} lines are left out (red): the crafter has no modifier worded so. + + All stackable currency + game settings are shared with your normal game @@ -6360,6 +6399,9 @@ Owned servers will stop. Automatic backup is {2}. Source, client and login keys More mod actions + + Multiplier for following, collecting and returning; 1 is normal speed, 2 is double speed. + Default sockets; e.g. RRGB a 4-link, RR GB two pairs @@ -6561,6 +6603,9 @@ Owned servers will stop. Automatic backup is {2}. Source, client and login keys Tree + + Exact item name or metadata id: 0 blocks, 1-65535 is the minimum ground stack. + Rare pack anchor @@ -6633,6 +6678,9 @@ Owned servers will stop. Automatic backup is {2}. Source, client and login keys Select an account + + Extra Backpack + Type @@ -6831,6 +6879,9 @@ Owned servers will stop. Automatic backup is {2}. Source, client and login keys What is finished stays finished, and a partial copy is kept. Continue picks up from here, now or another day. + + Pet gold pickup + the release would overwrite {0}, which holds your own data; nothing was changed @@ -7150,6 +7201,9 @@ Last reported Gateway event. Open Gateway output for details. Unavailable + + Default for characters without a saved profile. + {0} backups for {1} @@ -8812,6 +8866,9 @@ Mods at backup: Generate map + + Stackable map fragments + Game status diff --git a/src/Launcher.Core/Resources/Strings.ru.resx b/src/Launcher.Core/Resources/Strings.ru.resx index 32a45e7..ef47692 100644 --- a/src/Launcher.Core/Resources/Strings.ru.resx +++ b/src/Launcher.Core/Resources/Strings.ru.resx @@ -135,6 +135,9 @@ Закреплённые: + + Набор обычных валют + Собранные файлы и подтверждённое состояние запущенных модов отображаются отдельно. LocalExile отслеживает файлы модов независимо от горячей перезагрузки кода Gateway. Сборка или перезагрузка сбрасывает состояние мода в памяти и может перезагрузить зависимые моды. Отключение зависимости может выгрузить другие моды. Изменения затрагивают всех персонажей на этом Gateway. @@ -663,6 +666,9 @@ Готово к записи новых загружаемых областей. + + Призванные питомцы собирают выбранную валюту. Фильтры настраиваются для каждого персонажа, сбор можно сразу приостановить. + Закрывает игру; серверы продолжают работать @@ -795,6 +801,9 @@ Настройка LocalExile + + Дополнительный встроенный рюкзак на 20 ячеек для любого класса персонажа. + {0} — не тот идентификатор мода, который Waypoint может использовать @@ -2082,6 +2091,9 @@ Дружба + + Только 20 видов валюты из README. Правила для отдельных предметов имеют приоритет. + Не удалось открыть Waypoint @@ -2290,6 +2302,9 @@ Переключение завершено. + + Скорость передвижения питомца + Это имя не используется существующими лигами. @@ -3181,6 +3196,9 @@ Красный–зелёный + + клетки + в выпуске {0} нет {1} с файлом .sha256 @@ -3327,6 +3345,9 @@ Игра + + Профили персонажей + Вы можете удалить папку сами: {0} @@ -3369,6 +3390,9 @@ Вход в Steam не выполнен. + + Правила для отдельных предметов + Выбор модов действует во всех лигах. Сохранённый выбор не подтверждает их загрузку на сервере. @@ -3601,6 +3625,9 @@ · создан не здесь + + Радиус сбора + Также будут удалены уже загруженные {0:0.#} ГБ. @@ -4146,6 +4173,9 @@ Ремесло и торговля + + Сбор добычи питомцем + Настройки @@ -4335,6 +4365,9 @@ В этой папке LocalExile уже есть игровой клиент, копировать ничего не нужно. + + Складываемые гадальные карты + Загрузка областей … @@ -5336,6 +5369,9 @@ Персонажи выбранного аккаунта + + Сбор включён + Поиск веток и запросов на слияние @@ -5538,6 +5574,9 @@ {0}: свойств: {1}. Пропущено строк: {2} (красные): у конструктора нет свойства с таким текстом. + + Вся складываемая валюта + настройки игры общие с вашей обычной игрой @@ -6360,6 +6399,9 @@ Другие действия с модом + + Множитель скорости следования, сбора и возвращения. 1 — обычная скорость, 2 — двойная. + Гнёзда по умолчанию; например RRGB — 4 связанных, RR GB — две пары @@ -6561,6 +6603,9 @@ Дерево + + Точное имя предмета или ID метаданных. 0 запрещает сбор, 1–65535 задаёт минимальный размер стопки на земле. + Точка редкой группы @@ -6633,6 +6678,9 @@ Выберите аккаунт + + Дополнительный рюкзак + Тип @@ -6831,6 +6879,9 @@ Готовое останется готовым, а незавершённая копия сохранена. «Продолжить» начнёт с этого места — сейчас или в другой день. + + Сбор золота питомцем + выпуск перезаписал бы {0}, где хранятся ваши данные; ничего не изменено @@ -7150,6 +7201,9 @@ Недоступно + + По умолчанию для персонажей без сохранённого профиля. + Резервных копий: {0} · {1} @@ -8812,6 +8866,9 @@ Создать карту + + Складываемые фрагменты карт + Состояние игры diff --git a/src/Launcher.Core/Resources/Strings.zh-CN.resx b/src/Launcher.Core/Resources/Strings.zh-CN.resx index 96ca2fd..b1df138 100644 --- a/src/Launcher.Core/Resources/Strings.zh-CN.resx +++ b/src/Launcher.Core/Resources/Strings.zh-CN.resx @@ -135,6 +135,9 @@ 已固定: + + 常用通货预设 + 已构建的文件与已确认的运行状态分开显示。LocalExile 监视模组文件,与 Gateway 代码热重载相互独立。构建或重新加载会重置模组的内存状态,并可能重新加载依赖它的模组。禁用某个依赖项可能会卸载其他模组。更改会影响此 Gateway 上的所有角色。 @@ -663,6 +666,9 @@ 已准备好采集新加载的区域。 + + 装备的宠物会拾取所选通货,可按角色设置过滤规则,并可随时暂停。 + 关闭游戏;服务器保持运行 @@ -795,6 +801,9 @@ 安装 LocalExile + + 所有职业均可启用的原生 20 格扩展背包。 + {0} 不是 Waypoint 能使用的模组 ID @@ -2082,6 +2091,9 @@ 友谊 + + 仅包含 README 列出的 20 种通货。单项规则优先。 + 无法打开 Waypoint @@ -2290,6 +2302,9 @@ 切换完成。 + + 宠物移动速度 + 当前赛季尚未使用此名称。 @@ -3181,6 +3196,9 @@ 红绿色盲友好 + + 格 + 发行版 {0} 中没有附带 .sha256 的 {1} @@ -3327,6 +3345,9 @@ 游戏 + + 角色配置 + 你可以自己删除该文件夹:{0} @@ -3369,6 +3390,9 @@ 未登录 Steam。 + + 物品单项规则 + 模组选择适用于所有赛季。已保存的选项不代表实际加载状态。 @@ -3601,6 +3625,9 @@ · 非在此创建 + + 拾取半径 + 同时会删除已下载的 {0:0.#} GB。 @@ -4146,6 +4173,9 @@ 工艺与交易 + + 宠物拾取 + 设置 @@ -4335,6 +4365,9 @@ 此 LocalExile 文件夹中已有游戏客户端,无需复制。 + + 可堆叠命运卡 + 正在加载区域 … @@ -5336,6 +5369,9 @@ 所选账号的角色 + + 启用拾取 + 搜索分支和拉取请求 @@ -5538,6 +5574,9 @@ {0}:{1} 个词缀。有 {2} 行被忽略(红色):物品制作器中没有这样措辞的词缀。 + + 所有可堆叠通货 + 游戏设置与你平常的游戏共用 @@ -6360,6 +6399,9 @@ 更多模组操作 + + 跟随、拾取和返回时的移速倍率。1 为正常速度,2 为双倍速度。 + 默认插槽;例如 RRGB 为 4 连,RR GB 为两组 2 连 @@ -6561,6 +6603,9 @@ 树木 + + 使用物品全名或元数据 ID。0 表示不拾取,1–65535 表示最低地面堆叠数量。 + 稀有怪物群锚点 @@ -6633,6 +6678,9 @@ 选择账号 + + 额外背包 + 类型 @@ -6831,6 +6879,9 @@ 已完成的部分会保留,已复制的部分也会保留。点击“继续”即可从此处接着进行,现在或改天都可以。 + + 宠物拾取金币 + 发行版会覆盖存有你自己数据的 {0};未做任何更改 @@ -7150,6 +7201,9 @@ Gateway 最近报告的事件。打开 Gateway 输出查看详情。 不可用 + + 供尚无保存配置的角色使用。 + {1} 的 {0} 个备份 @@ -8812,6 +8866,9 @@ Gateway 最近报告的事件。打开 Gateway 输出查看详情。 生成地图 + + 可堆叠地图碎片 + 游戏状态 diff --git a/src/Waypoint.Linux/Views/ModsTab.axaml.cs b/src/Waypoint.Linux/Views/ModsTab.axaml.cs index 9897120..32c457d 100644 --- a/src/Waypoint.Linux/Views/ModsTab.axaml.cs +++ b/src/Waypoint.Linux/Views/ModsTab.axaml.cs @@ -573,7 +573,7 @@ void RefreshPage() PageTitle.Text = title; string author = entry?.Author is { Length: > 0 } a ? a : item?.Author ?? ""; PageByline.Text = author.Length > 0 ? L.Text("by {0}", author) : ""; - PageDescription.Text = entry?.Description is { Length: > 0 } d ? d : item?.Listing.Description ?? ""; + PageDescription.Text = entry?.Description is { Length: > 0 } d ? L.Text(d) : item?.Description ?? ""; PageTags.ItemsSource = ModsText.Tags(item, entry); PageStats.Text = ModsText.Stats(item, entry); PageEnabled.IsVisible = entry is not null; diff --git a/src/Waypoint/ModBrowser.cs b/src/Waypoint/ModBrowser.cs index 4306c3a..ec562ba 100644 --- a/src/Waypoint/ModBrowser.cs +++ b/src/Waypoint/ModBrowser.cs @@ -34,7 +34,7 @@ sealed record BrowseItem(ModSource Source, ModListing Listing, ModRelease? Relea /// A project without a release installs as source, built later with the .NET 10 SDK. public bool NeedsBuild => Release is null && Listing.IsProject; - public string Title => Listing.Name; + public string Title => L.Text(Listing.Name); public string Byline => L.Text("by {0}", Listing.Author.Length > 0 ? Listing.Author : Source.Owner); public string VersionText => Offer switch { @@ -52,7 +52,7 @@ sealed record BrowseItem(ModSource Source, ModListing Listing, ModRelease? Relea public bool IsUpdate => Offer == ModOffer.Update; public string Origin => Release is not null ? L.Text("Release {0}", Release.Tag) : Listing.IsProject ? L.Text("No release: installs the source") : L.Text("Scripts: no build needed"); - public string SearchText => $"{Listing.Id} {Listing.Name} {Listing.Author} {Listing.Description}"; + public string SearchText => $"{Listing.Id} {Listing.Name} {Listing.Author} {Listing.Description} {Title} {Description}"; public string Initial => ModsText.Initial(Title); public ModIconKind Icon => ModsText.Icon(Listing.Id); /// The installed mod's own icon.png, else the repository's. @@ -60,7 +60,7 @@ sealed record BrowseItem(ModSource Source, ModListing Listing, ModRelease? Relea public ModIconImage? IconImage => ModsText.IconImage(IconFile); /// Without an icon.png of its own, a mod shows its symbol. public bool ShowSymbol => IconImage is null; - public string Description => Listing.Description; + public string Description => L.Text(Listing.Description); public bool HasDescription => Description.Length > 0; public string Metadata => Author; /// The LocalExile versions it declares; the list shows these, not the mod's own version. @@ -195,7 +195,7 @@ public static string Heading(ModSort column, ModSort by, bool descending) /// A row of My Mods: an installed mod, and what a repository offers of it (for Update and its latest version). sealed record InstalledRow(ModEntry Entry, BrowseItem? Offer) { - public string Title => Entry.Name.Length > 0 ? Entry.Name : Offer?.Title ?? Entry.Id; + public string Title => Entry.Name.Length > 0 ? L.Text(Entry.Name) : Offer?.Title ?? Entry.Id; public string Initial => ModsText.Initial(Title); public ModIconKind Icon => ModsText.Icon(Entry.Id); /// The installed mod's own icon.png, else its repository's. @@ -203,7 +203,7 @@ sealed record InstalledRow(ModEntry Entry, BrowseItem? Offer) public ModIconImage? IconImage => ModsText.IconImage(IconFile); /// Without an icon.png of its own, a mod shows its symbol. public bool ShowSymbol => IconImage is null; - public string Description => Entry.Description.Length > 0 ? Entry.Description : Offer?.Listing.Description ?? ""; + public string Description => Entry.Description.Length > 0 ? L.Text(Entry.Description) : Offer?.Description ?? ""; public bool HasDescription => Description.Length > 0; public string Metadata => string.Join(" · ", new[] { Author, Entry.IsScript ? L.Text("Script mod") : "" }.Where(s => s.Length > 0)); /// The LocalExile versions its installed mod.json declares, else what its repository's listing does. diff --git a/src/Waypoint/ModsTab.xaml.cs b/src/Waypoint/ModsTab.xaml.cs index baa9236..e2c39b1 100644 --- a/src/Waypoint/ModsTab.xaml.cs +++ b/src/Waypoint/ModsTab.xaml.cs @@ -594,7 +594,7 @@ void RefreshPage() PageTitle.Text = title; string author = entry?.Author is { Length: > 0 } a ? a : item?.Author ?? ""; PageByline.Text = author.Length > 0 ? L.Text("by {0}", author) : ""; - PageDescription.Text = entry?.Description is { Length: > 0 } d ? d : item?.Listing.Description ?? ""; + PageDescription.Text = entry?.Description is { Length: > 0 } d ? L.Text(d) : item?.Description ?? ""; PageTags.ItemsSource = ModsText.Tags(item, entry); PageStats.Text = ModsText.Stats(item, entry); PageEnabled.Visibility = entry is null ? Visibility.Collapsed : Visibility.Visible; diff --git a/src/Waypoint/SettingsEditor.cs b/src/Waypoint/SettingsEditor.cs index 451852b..9156a99 100644 --- a/src/Waypoint/SettingsEditor.cs +++ b/src/Waypoint/SettingsEditor.cs @@ -87,7 +87,7 @@ void BuildGroup(StackPanel panel, IReadOnlyList settings, Func settings, Func>(StringComparer.Ordinal); var values = value as JsonObject; BuildGroup(inner, setting.Children ?? [], s => ModSettingsForm.Merge(s, values?.FirstOrDefault(p => p.Key.Equals(s.Name, StringComparison.OrdinalIgnoreCase)).Value), readers); + var declared = readers.Keys.ToHashSet(StringComparer.OrdinalIgnoreCase); return () => { - var result = values?.DeepClone() as JsonObject ?? new JsonObject(); + var result = new JsonObject(); + if (values is not null) + foreach (var (key, previous) in values) + if (!declared.Contains(key)) result[key] = previous?.DeepClone(); foreach (var (name, read) in readers) result[name] = read()?.DeepClone(); return result; }; @@ -119,7 +123,7 @@ void BuildGroup(StackPanel panel, IReadOnlyList settings, Func JsonValue.Create(toggle.IsChecked == true); break; case "integer" or "number": read = Number(control, setting, value); break; @@ -133,20 +137,20 @@ void BuildGroup(StackPanel panel, IReadOnlyList settings, Func new JsonArray(low(), high()); break; case "choice" when setting.Options.Count > 0: var choice = new ComboBox { MinWidth = 120, HorizontalAlignment = HorizontalAlignment.Stretch }; - foreach (var option in setting.Options) choice.Items.Add(new ComboBoxItem { Content = option.Label, Tag = option.Value }); + foreach (var option in setting.Options) choice.Items.Add(new ComboBoxItem { Content = L.Text(option.Label), Tag = option.Value }); choice.SelectedItem = choice.Items.OfType().FirstOrDefault(i => ModSettingsForm.Equal((JsonNode?)i.Tag, value)); - A11y.SetName(choice, setting.Title); + A11y.SetName(choice, L.Text(setting.Title)); choice.SelectionChanged += (_, _) => Change(); control.Children.Add(choice); read = () => (choice.SelectedItem as ComboBoxItem)?.Tag is JsonNode chosen ? chosen.DeepClone() : null; break; case "choices": var selected = value as JsonArray ?? []; - var boxes = setting.Options.Select(o => (o.Value, Box: new CheckBox { Content = o.Label, IsChecked = selected.Any(v => ModSettingsForm.Equal(v, o.Value)), Margin = new Thickness(0, 3, 0, 3) })).ToArray(); + var boxes = setting.Options.Select(o => (o.Value, Box: new CheckBox { Content = L.Text(o.Label), IsChecked = selected.Any(v => ModSettingsForm.Equal(v, o.Value)), Margin = new Thickness(0, 3, 0, 3) })).ToArray(); // A list of labels needs the width: it stays under the description, with no control column. foreach (var (_, box) in boxes) { text.Children.Add(box); CheckChanged(box, Change); } read = () => new JsonArray(boxes.Where(b => b.Box.IsChecked == true).Select(b => b.Value.DeepClone()).ToArray()); break; default: var entry = new TextBox { Text = ModSettingsForm.Show(value) }; - A11y.SetName(entry, setting.Title); + A11y.SetName(entry, L.Text(setting.Title)); entry.TextChanged += (_, _) => Change(); control.Children.Add(entry); read = () => JsonValue.Create(entry.Text ?? ""); break; } @@ -188,7 +192,7 @@ static Border Card(Element content) Func Number(StackPanel panel, ModSetting setting, JsonNode? value) { var text = new TextBox { Text = ModSettingsForm.Show(value, setting), Width = 84, VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Right }; - A11y.SetName(text, setting.Title); + A11y.SetName(text, L.Text(setting.Title)); string initialText = text.Text ?? ""; var line = new DockPanel(); DockPanel.SetDock(text, Dock.Right); @@ -200,7 +204,7 @@ static Border Card(Element content) if (setting.Min is { } min && setting.Max is { } max && min < max && double.IsFinite(min) && double.IsFinite(max)) { slider = new Slider { Minimum = min * scale, Maximum = max * scale, Margin = new Thickness(0, 0, 12, 0), VerticalAlignment = VerticalAlignment.Center }; - A11y.SetName(slider, setting.Title); + A11y.SetName(slider, L.Text(setting.Title)); #if WINDOWS slider.IsSnapToTickEnabled = setting.Step is not null || setting.Type == "integer"; slider.TickFrequency = (setting.Step ?? 1) * scale; @@ -251,7 +255,7 @@ void Add(JsonNode? current, string key = "") if (setting.Options.Count > 0) { var keys = new ComboBox { HorizontalAlignment = HorizontalAlignment.Stretch }; - foreach (var option in setting.Options) keys.Items.Add(new ComboBoxItem { Content = option.Label, Tag = ModSettingsForm.Show(option.Value) }); + foreach (var option in setting.Options) keys.Items.Add(new ComboBoxItem { Content = L.Text(option.Label), Tag = ModSettingsForm.Show(option.Value) }); keys.SelectedItem = keys.Items.OfType().FirstOrDefault(i => (string?)i.Tag == key); row.Children.Add(keys); keys.SelectionChanged += (_, _) => Change(); readKey = () => (keys.SelectedItem as ComboBoxItem)?.Tag as string ?? ""; } @@ -288,7 +292,7 @@ void Add(JsonNode? current, string key = "") "list" or "choices" => new JsonArray(), "map" or "group" => new JsonObject(), "choice" when setting.Options.Count > 0 => setting.Options[0].Value.DeepClone(), _ => JsonValue.Create(""), }; - static string Heading(ModSetting s) => s.Title + (s.Format == "percent" ? " (%)" : s.Format == "duration" ? " (" + L.Text("seconds") + ")" : s.Format == "multiplier" ? " (×)" : s.Unit.Length > 0 ? " (" + s.Unit + ")" : ""); + static string Heading(ModSetting s) => L.Text(s.Title) + (s.Format == "percent" ? " (%)" : s.Format == "duration" ? " (" + L.Text("seconds") + ")" : s.Format == "multiplier" ? " (×)" : s.Unit.Length > 0 ? " (" + L.Text(s.Unit) + ")" : ""); static void Description(StackPanel panel, ModSetting s) { void Add(string text) @@ -297,7 +301,7 @@ void Add(string text) Themed(hint, TextBlock.ForegroundProperty, "Shell.TextSecondary"); panel.Children.Add(hint); } - if (s.Description.Length > 0) Add(s.Description); + if (s.Description.Length > 0) Add(L.Text(s.Description)); if (s.Source.Length > 0) Add(L.Text("Enter a game value of type: {0}", s.Source)); if (s.Applies == "restart") Add(L.Text("Applies when the Gateway restarts.")); if (s.Applies == "nextArea") Add(L.Text("Applies in the next area.")); diff --git a/tests/Waypoint.Tests/SettingsFormTests.cs b/tests/Waypoint.Tests/SettingsFormTests.cs index 364a6fe..d13304a 100644 --- a/tests/Waypoint.Tests/SettingsFormTests.cs +++ b/tests/Waypoint.Tests/SettingsFormTests.cs @@ -17,6 +17,9 @@ public class SettingsFormTests : IDisposable "name":{"type":"text","default":"abc","pattern":"[a-z]+","maxLength":8}, "weights":{"type":"list","default":[1],"item":{"type":"number","min":0,"max":5},"maxItems":3}, "bonuses":{"type":"map","default":{"a":1},"options":["a","b"],"value":{"type":"integer","min":0}}, + "profiles":{"type":"map","default":{},"value":{"type":"group","settings":{ + "enabled":{"type":"bool","default":true},"speed":{"type":"number","default":2,"min":0.25,"max":10} + }}}, "advanced":{"type":"group","advanced":true,"when":{"enabled":true},"settings":{ "delay":{"type":"number","default":2,"format":"duration","min":0}, "nested":{"type":"group","settings":{"active":{"type":"bool","default":false}}} @@ -125,6 +128,26 @@ public void Editor_sliders_and_exact_values_share_the_same_validated_value() Assert.Null(failure); } [Fact] + public void Editor_saves_profile_fields_once_and_preserves_undeclared_fields() + { + Exception? failure = null; + var thread = new Thread(() => + { + try + { + var form = Load("""{"profiles":{"Player":{"Enabled":false,"Speed":3,"future":42}}}"""); + var profile = Assert.IsType(new SettingsEditor(form).Values()["profiles"]!["Player"]); + Assert.Equal(3, profile.Count); + Assert.False(profile["enabled"]!.GetValue()); + Assert.Equal(3, profile["speed"]!.GetValue()); + Assert.Equal(42, profile["future"]!.GetValue()); + } + catch (Exception e) { failure = e; } + }); + thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); + Assert.Null(failure); + } + [Fact] public void A_narrow_card_puts_its_control_under_its_text_and_a_wide_one_beside_it() { Exception? failure = null;