搜索和整理大型模组设置
More languages
More actions
使用 Modloader 现有的设置分组,将模组页面整理为多个标签页,并为较长的多选列表添加搜索和可选分类。这些功能均为可选。只有玩家更改选项时,已保存的值才会改变。模组继续使用现有的本地化文件。
大型模组页面有哪些变化
此功能适用于模组在 extended.mod.json 中声明的设置。它使用现有的模组设置页面、已保存的设置值和模组本地化文件,不会新增另一套设置存储。
整理较长的多选列表
对于 multiselect,value 仍然是数组,可选项仍在 options 中声明。选项超过 12 个时会自动显示搜索控件。示例还对选项进行分组,并将设置组放到独立的页面标签页中。
{
"schemaVersion": 1,
"enabled": true,
"settings": {
"showEffects": {
"value": true,
"label": "Show effects",
"control": "toggle"
},
"excludeItems": {
"value": [],
"label": "Excluded items",
"description": "Choose items this mod should ignore.",
"control": "multiselect",
"options": {
"Twigs": { "label": "Twigs", "group": "Materials" },
"Stone": { "label": "Stone", "group": "Materials" },
"Resin": { "label": "Resin", "group": "Materials" },
"Plant Fiber": { "label": "Plant Fiber", "group": "Materials" },
"Shroud Wood": { "label": "Shroud Wood", "group": "Materials" },
"Fossilized Bone": { "label": "Fossilized Bone", "group": "Materials" },
"Metal Scraps": { "label": "Metal Scraps", "group": "Materials" },
"Fire Fly": { "label": "Fire Fly", "group": "Creatures" },
"Fell Wispwyvern": { "label": "Fell Wispwyvern", "group": "Creatures" },
"Hollow Halls": { "label": "Hollow Halls", "group": "Creatures" },
"Bronze Arrows": { "label": "Bronze Arrows", "group": "Ammunition" },
"Explosive Arrows": { "label": "Explosive Arrows", "group": "Ammunition" },
"Poison Arrows": { "label": "Poison Arrows", "group": "Ammunition" }
}
}
},
"groups": [
{ "label": "General", "settings": ["showEffects"] },
{ "label": "Excluded items", "settings": ["excludeItems"], "tab": true }
]
}
例如 Twigs 这样的选项键就是为模组保存的值。"Twigs": "Twigs" 这样的字符串标签仍然可用。对象形式可以增加显示用的 label 和可选的 group。分类标签页用于划分多选列表中的选项。搜索会在所有分类中同时匹配显示标签和已保存的值。计数会显示当前可见、总数和已选项数。“仅显示已选项”只隐藏未选项,不会取消选择。勾选状态变化时仍更新原来的已保存数组,较长列表则在设置区域内滚动。
翻译模组标签和页面标签
模组编写的标签放在现有的 locales/<code>.json 文件中。Search、Only selected 和 All 等共享控件使用玩家选择的 Modloader 通用语言。
{
"settings": {
"excludeItems": {
"options": {
"Twigs": "Twigs",
"Stone": "Stone",
"Fire Fly": "Fire Fly",
"Bronze Arrows": "Bronze Arrows"
},
"optionGroups": {
"Materials": "Materials",
"Creatures": "Creatures",
"Ammunition": "Ammunition"
}
}
},
"groups": [
{ "label": "General" },
{ "label": "Excluded items" }
]
}
现有格式请参阅模组本地化指南。
将设置组放到独立标签页
实际示例可见 [ShroudForge World Editor 的 extended.mod.json](https://github.com/bonsaibauer/shroudforge/blob/1.8.0/mods/world-editor/extended.mod.json),其中 Keyboard shortcuts、Blueprint placement 和 Native entity operations 分组均使用 tab: true。
已保存值和兼容性
现有字符串选项标签、已保存数组、未设置 tab 的分组以及未使用 optionGroups 的本地化文件无需迁移即可继续使用。只有选项超过 12 个的多选列表才显示搜索控件。分组选项对象、tab: true 和本地化文件中的 optionGroups 需要 ShroudForge 1.8.0 或更新版本。旧版本会拒绝无法识别的字段。