Jump to content
Toggle menu
  • 64 articles
  • 37 files
  • 9 users
  • 4.6K edits
Shroudforge
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
This page is a translated version of the page Search and organize large mod settings and the translation is 100% complete.


Search and organize large mod settings



使用 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 或更新版本。舊版本會拒絕無法識別的欄位。