UMassBattleEditorSettings
Source/MassBattleEditor/Public/Settings/MassBattleEditorSettings.h
概述Overview
属于编辑器而不是项目的 MassBattle 设置:它描述插件对这个用户「看起来怎样」、烘焙时复制哪个资产,而不是游戏怎样运行。面板位置是 Editor Preferences → Plugins → MassBattle——不是 Project Settings——值按项目、按用户存进 EditorPerProjectUserSettings.ini,因此共享同一仓库的两个人可以各用各的语言与各自的模板选择。
MassBattle settings that belong to the editor rather than to the project: they describe how the plugin looks to this user and which assets a bake copies, not how a game behaves. The section lives under Editor Preferences → Plugins → MassBattle — not Project Settings — and values are stored per project per user in EditorPerProjectUserSettings.ini, so two people sharing a repository can each keep their own language and template choices.
面板分五组:Localization(工具跟随哪种语言)、UI(tooltip 与欢迎窗口)、Bake Templates(每次单位烘焙都会复制的 Niagara 系统与渲染器蓝图)、Slot Atlas(被当作模板使用的图集母材质——每个产物网格都指向一份它的逐网格副本,而不是这个资产本身)与 Sprite(为生成的 MI_{name} 提供父材质的 sprite 母材质)。前两组只改工具在编辑器里的表现;后三组决定烘焙复制或实例化哪个资产,是此面板里唯一会影响烘焙产出的设置。语言这一组最终生效的值由 ResolveCulture 计算:覆盖值指向本插件发布的语言时用它,否则把编辑器语言限定到已发布的语言(都不匹配时用英语)。
The panel has five groups: Localization (the language the tools speak), UI (tooltips and the welcome window), Bake Templates (the Niagara system and renderer Blueprint every unit bake duplicates), and Slot Atlas / Sprite (an atlas master used as a template, where every output mesh points at its own per-mesh copy of it rather than at the asset itself, and the sprite master that parents the generated MI_{name}). The first two change only how the tools behave in the editor; the last three decide which asset a bake copies or instantiates, and are the only settings here that change what a bake produces. Within Localization, the culture actually in effect is computed by ResolveCulture: the override when it names a shipped culture, otherwise the editor language clamped to one this plugin ships (English when nothing matches).
继承Inheritance
设置项Settings
五组共九个属性,全部是 Config 属性(会落盘到 ini)。四个资产指针由构造函数用插件出厂默认预置,因此新工程打开面板看到的是真实资产而不是 None;预置只改变显示,在你另选资产之前不会写入任何东西。
Nine properties in five groups, all Config properties (persisted to the ini). The constructor pre-fills the four asset pointers with the plugin's factory defaults, so a fresh project sees real assets in the pickers instead of None; seeding changes only what is displayed — nothing is written until you pick another asset.
Localization
两项配合:第二项只有第一项关闭时才可编辑——编辑条件上的切换按钮被刻意隐藏,所以它不会多出一行「勾选以覆盖」。
The two rows work together: the second is editable only while the first is off — the condition toggle itself is hidden, so it never adds a “tick to override” row.
| 名称Name | 类型Type | 默认值Default | 说明Description |
|---|---|---|---|
bFollowEditorLanguage |
bool |
true |
让 MassBattle 工具跟随编辑器语言。编辑器语言不是本插件发布了译文的语言时,使用英语。显示名为 Follow Editor Language。Runs the MassBattle tools in the editor's own language. When the editor language is not one this plugin ships a translation for, English is used. Display name: Follow Editor Language. |
PluginLanguage |
FString |
构造函数预置为编辑器当前语言(限定到已发布语言后的结果)Seeded by the constructor with the editor's current language, clamped to a shipped one | 关闭「跟随编辑器语言」时使用的语言。取值必须是随本插件发布的 locres 的 culture 名;下拉框从 GetLanguageOptions 取项。显示名为 Plugin Language。已保存的配置值优先于构造时的预置。The language used when Follow Editor Language is off. The value must be a culture name whose locres ships with this plugin; the dropdown is fed by GetLanguageOptions. Display name: Plugin Language. A saved config value wins over the constructor seed. |
UI
三项都只影响工具在编辑器里的表现,不改变任何烘焙产物。
All three affect only how the tools behave in the editor; none changes a bake's output.
| 名称Name | 类型Type | 默认值Default | 说明Description |
|---|---|---|---|
bShowTooltips |
bool |
true |
是否显示本插件各编辑器面板的 tooltip。关闭时被包装的 tooltip 文本为空,Slate 会直接跳过空 tooltip(不会留下空框)。下一次悬停即生效——无需重建面板,也无需重启编辑器。显示名为 Show Tooltips。Shows this plugin's tooltips in its editor panels. When off, every wrapped tooltip reads empty and Slate skips empty tooltips entirely (no empty box). Applies on the next hover — no panel rebuild, no editor restart. Display name: Show Tooltips. |
WelcomeDismissedVersion |
FString |
空(表示从未关闭过欢迎窗口)Empty (the welcome window was never dismissed) | 用户关掉欢迎窗口时记下的插件版本。编辑器启动时会拿它与运行中插件的 VersionName 比较,因此每个版本只介绍自己一次。显示名为 Welcome Dismissed Version。The plugin version whose welcome window the user closed. The startup gate compares it with the running plugin's VersionName, so each version introduces itself once. Display name: Welcome Dismissed Version. |
bShowWelcomeOnStartup |
bool |
true |
编辑器启动时显示欢迎/更新窗口,直到用「Don't show this on startup again」关掉它。显示名为 Show Welcome on Startup。Shows the welcome / what's-new window when the editor starts, until it is closed with “Don't show this on startup again”. Display name: Show Welcome on Startup. |
Bake Templates
| 名称Name | 类型Type | 默认值Default | 说明Description |
|---|---|---|---|
NSTemplate |
TSoftObjectPtr<UNiagaraSystem> |
/MassBattle/Core/Templates/NS_AgentRenderer_Template.NS_AgentRenderer_Template |
每次烘焙复制成单位 Niagara 系统(NS_{name})的资产。Mesh VAT 与 Sprite 两条管线共用这一个模板。显示名为 Niagara System Template。The asset each bake duplicates into the unit's Niagara system (NS_{name}). The Mesh VAT and Sprite pipelines share this one template. Display name: Niagara System Template. |
RendererTemplate |
TSoftClassPtr<AMassBattleAgentRenderer> |
/MassBattle/Core/Templates/BP_AgentRenderer_Template.BP_AgentRenderer_Template_C |
每次烘焙按单位复制(Renderer_{name})的渲染器蓝图类。显示名为 Renderer Template。The renderer Blueprint class duplicated per unit (Renderer_{name}) on every bake. Display name: Renderer Template. |
留空时这两行都会回落到插件出厂默认——烘焙不会因为字段为空而停下来——解析集中在 MassBattleBakeTemplatePaths.h:随包模板 ini 里有这一键时用 ini 的值,否则用上表「默认值」栏给出的内置路径。四条资产路径(两个模板、Slot Atlas 母材质、Sprite 母材质)都按同一条规则解析。
When either row is empty it falls back to the plugin's factory default — the bake never stops because the field is blank — resolved in MassBattleBakeTemplatePaths.h: a key present in the plugin's bundled template ini wins, otherwise the built-in path listed in the Default column above is used. All four asset paths (the two templates and the Slot Atlas / Sprite masters) follow this one rule.
Slot Atlas
| 名称Name | 类型Type | 默认值Default | 说明Description |
|---|---|---|---|
SlotAtlasMaster |
TSoftObjectPtr<UMaterialInterface> |
/MassBattle/Core/Templates/M_SlotAtlasMaster.M_SlotAtlasMaster |
槽位图集烘焙写出的网格所用的模板材质:每个产物网格都指向它自己的一份逐网格副本(<副本所在目录>/<CopyName>_SlotAtlasMaster,每次烘焙写出),永不直接使用配置的这个资产本身——槽合并不产出材质实例。副本必须声明烘焙会用到的全部二十四个参数:八张图集贴图 BaseColorTex、NormalTex、MetallicTex、RoughnessTex、SpecularTex、AOTex、EmissiveTex、OpacityTex,八个开关 MB_Use<Channel>Tex,八条回落值 MB_<Channel>Fallback;副本声明少了哪个,烘焙在写入任何东西之前按名字拒绝。管线需要的动画接线(VAT 播放、顶点色等)由副本承载,因此就在这个材质上实现。整条清空则 Bake Atlas 拒绝。显示名为 Atlas Master Material。Template material for the meshes the Slot Atlas bake writes: every output mesh points at its own per-mesh copy of this material (<the copy's own folder>/<CopyName>_SlotAtlasMaster, written on every bake), never at this asset itself — slot merge creates no material instance. A copy must declare all twenty-four parameters the bake routes: the eight atlas textures BaseColorTex, NormalTex, MetallicTex, RoughnessTex, SpecularTex, AOTex, EmissiveTex, OpacityTex, the eight switches MB_Use<Channel>Tex and the eight fallbacks MB_<Channel>Fallback — or the bake refuses the mesh by name before anything is written into it. Any animation wiring the pipeline needs (VAT playback, vertex color, …) is carried by the copy, so it is authored on this material. Clear it entirely and Bake Atlas refuses. Display name: Atlas Master Material. |
Sprite
| 名称Name | 类型Type | 默认值Default | 说明Description |
|---|---|---|---|
SpriteMasterMaterial |
TSoftObjectPtr<UMaterialInterface> |
构造函数预置:新安装显示随包模板 ini 的 /MassBattle/Core/Templates/M_SpriteMaster.M_SpriteMaster;ini 缺失时用内置的 /MassBattle/Core/Templates/M_SpriteMasterMF.M_SpriteMasterMFSeeded by the constructor: a fresh install shows the bundled template ini's /MassBattle/Core/Templates/M_SpriteMaster.M_SpriteMaster; when the ini is absent the built-in /MassBattle/Core/Templates/M_SpriteMasterMF.M_SpriteMasterMF is used |
sprite 烘焙产物材质实例(MI_{name})的父材质,仅在图集资产自身没有 MasterMaterial 时使用:图集自带母材质时仍用图集那一份,这里只是回落,绝不覆盖。两边都没有时 sprite 材质实例会被跳过(Generate 会记一行),无头烘焙则直接拒绝。选择器限定为材质接口类资产。显示名为 Sprite Master Material。Parent for the sprite bake's material instance (MI_{name}), used only when the atlas asset carries no master of its own: an atlas that names its own MasterMaterial keeps using that one — this is a fallback, never an override. Empty, plus an atlas with no master, skips the sprite material instance (Generate logs it) and makes the headless bake refuse. The picker accepts material-interface assets only. Display name: Sprite Master Material. |
Slot Atlas 与 Sprite 两行的预置规则与上面两个模板相同:构造函数用插件出厂默认填好选择器,另选资产会覆盖并保存,「重置为默认值」回到同一份。产物与清空的代价则各不相同:槽位图集母材质不产出任何材质实例——烘焙把每个已合并网格指到它自己的一份逐网格副本上——整条清空时 Bake Atlas 直接拒绝;sprite 母材质为空、且图集自身也没带母材质时,跳过 sprite 材质实例。
The Slot Atlas and Sprite rows are seeded by the same rule as the two templates: the constructor fills the picker with the plugin's factory default, picking another asset overrides and persists, and Reset to Defaults returns to it. What each bake produces, and what clearing the row costs, differ: the atlas master yields no material instance at all — the bake points every merged mesh at its own per-mesh copy of it — and clearing it entirely makes Bake Atlas refuse, while an empty sprite master plus an atlas with no master of its own skips the sprite material instance.
公开方法Public Methods
把 PluginLanguage 预置为编辑器当前语言(ResolveEditorCulture() 的结果),这样取消勾选「跟随编辑器语言」时,起点是用户已经在看的语言,而不是跳到另一种语言。同时用插件出厂默认预置四个资产指针(两个烘焙模板与两个母材质),只影响选择器显示什么。已保存的配置值在反序列化时覆盖这些预置。
Seeds PluginLanguage with the editor's current language (the result of ResolveEditorCulture()), so unchecking Follow Editor Language starts from what the user already sees instead of jumping to another language. It also seeds the four asset pointers (the two bake templates and the two masters) with the plugin's factory defaults, changing only what the pickers display. A saved config value overwrites these seeds during deserialization.
Input
无参数。
No parameters.
Output
无返回值。副作用:写入 PluginLanguage 与四个资产指针的初始值。
No return value. Side effect: writes the initial values of PluginLanguage and the four asset pointers.
决定这页设置出现在编辑器偏好的哪个分类下。固定返回 "Plugins",与其它插件的设置段归在一起。
Decides which Editor Preferences category hosts this settings page. Returns "Plugins", grouping it with every other plugin's settings section.
Input
无参数。
No parameters.
Output
返回 FName("Plugins")。无副作用。
Returns FName("Plugins"). No side effects.
算出实际生效的 culture。两条分支:关闭「跟随编辑器语言」且 PluginLanguage 确实在已发布列表里时,返回覆盖值本身;否则返回 ResolveEditorCulture()。覆盖值写了不受支持的语言时不会报错,而是静默回落到编辑器语言。
Computes the culture actually in effect. Two branches: when Follow Editor Language is off and PluginLanguage really is a shipped culture, the override is returned as-is; otherwise ResolveEditorCulture() is returned. An override naming an unsupported culture does not error — it silently falls back to the editor language.
Input
无参数(读取本对象的两个字段)。
No parameters (reads the object's two fields).
Output
返回一个已发布的 culture 名(如 zh-Hans、ja、en)。无副作用。
Returns one shipped culture name (e.g. zh-Hans, ja, en). No side effects.
把编辑器语言限定到本插件发布过的 culture:语言名整串命中就直接用;带脚本/地区的标签(如 zh-Hans-CN、en-US)取它的头段;裸 zh 按地区判断——标签含 Hant / TW / HK / MO 用 zh-Hant,否则用 zh-Hans;其余一律回落到 en。
Clamps the editor language to a culture this plugin ships: an exact name is used as-is; a tag carrying a script or region (zh-Hans-CN, en-US) contributes its head; a bare zh is decided by region — tags containing Hant / TW / HK / MO map to zh-Hant, everything else to zh-Hans; anything else falls back to en.
Input
无参数(读取引擎当前语言)。
No parameters (reads the engine's current language).
Output
返回一个已发布的 culture 名;永不返回空串。无副作用。
Returns one shipped culture name; never an empty string. No side effects.
本插件随包的 culture 列表,按菜单顺序返回:zh-Hans、zh-Hant、en、ja、ko、de、fr、es、es-419、it、pt-BR、pl、ru、tr、ar。这份列表同时决定语言下拉框的内容与解析时的合法集合。
The cultures this plugin ships, in menu order: zh-Hans, zh-Hant, en, ja, ko, de, fr, es, es-419, it, pt-BR, pl, ru, tr, ar. This one list feeds both the language dropdown and the legal set used during resolution.
Input
无参数。
No parameters.
Output
返回一份静态数组的常量引用(不要修改它)。无副作用。
Returns a const reference to a static array (do not modify it). No side effects.
生成语言下拉框的条目:每个已发布 culture 一条,ValueString 是 culture 名,DisplayName 是该 culture 自己的语言写法(取不到文化对象时退回 culture 名本身)。面板用它作为 Plugin Language 的选项来源。
Builds the language dropdown's entries: one per shipped culture, with ValueString set to the culture name and DisplayName to that culture's own name (falling back to the culture name when the culture object cannot be resolved). The panel uses it as the option source for Plugin Language.
Input
无参数。
No parameters.
Output
返回与 GetSupportedCultures() 等长的选项数组,顺序一致。无副作用。
Returns an option array as long as GetSupportedCultures(), in the same order. No side effects.
包装面板的 tooltip 文本,让「显示 tooltip」开关能把它静音。返回的是绑定属性:每次悬停都会重读设置,所以切换开关不需要重建面板。用法是在 .ToolTipText(...) 处套一层:.ToolTipText(MassBattleToolTip(LOCTEXT("X", "...")))。开关关闭时属性解析为空文本,而 Slate 不会为空文本弹出 tooltip。
Wraps a panel's tooltip text so the Show Tooltips switch can silence it. It returns a bound attribute: the setting is re-read on every hover, so flipping the switch needs no rebuild. Apply it at the .ToolTipText(...) call site: .ToolTipText(MassBattleToolTip(LOCTEXT("X", "..."))). When the switch is off the attribute resolves to empty text, and Slate never spawns a tooltip for empty text.
Input
| 参数Parameter | 类型Type | 说明Description |
|---|---|---|
InTip |
TAttribute<FText> |
面板原本要显示的 tooltip 文本。The tooltip text the panel would otherwise show. |
Output
返回 TAttribute<FText>:开关打开时取得 InTip 的原值,关闭时为空文本。副作用仅限读取默认设置对象,不修改任何状态。
Returns a TAttribute<FText>: InTip's original value while the switch is on, empty text while it is off. The only side effect is reading the default settings object; no state is modified.
管线角色Pipeline Role
本类只持有编辑器侧的偏好:语言选择与解析(ResolveCulture / GetLanguageOptions 与两个钳制助手)、tooltip 开关(由 MassBattleToolTip 在每个悬停处读取),以及四个烘焙模板/母材质指针(由烘焙管线取用)。它不加载译文、不切换语言,也不执行烘焙——译文归引擎本地化系统,烘焙归各工具。把它放在 EditorPerProjectUserSettings 的意义在于:同一个项目里,每位美术/策划/程序可以各自选择界面语言与模板,而仓库里不会因此产生差异。
This class only holds editor-side preferences: the language choice and its resolution (ResolveCulture / GetLanguageOptions plus the two clamp helpers), the tooltip switch (read on every hover through MassBattleToolTip), and the four bake template / master material pointers (consumed by the bake pipelines). It loads no translations, switches no language and runs no bake — translations belong to the engine's localization system and bakes belong to the individual tools. Storing it in EditorPerProjectUserSettings is the point: within one project each artist, designer or programmer can pick their own UI language and templates without creating a repository difference.
补充说明Notes
① 按项目、按用户:设置写进 EditorPerProjectUserSettings.ini,换机器、换用户会回到各自的偏好,同一项目里的两个人也能各用各的语言与模板;它是 Editor Preferences 的一段,不是 Project Settings。② 英语永远可用:插件里的每条字符串都以英语写就,所以 en 是永远存在的译文;任何无法匹配的语言都回落到它。③ 覆盖值不会报错:手改 ini 写入不受支持的语言名时,解析静默回落到编辑器语言,界面不会因此变空。④ 中文的简繁判断按地区标签:裸 zh 不会被猜成「按标签长度」——只有含 Hant/TW/HK/MO 的标签才走繁体。⑤ 资产预置只改变显示:工程没保存过值时,选择器显示插件出厂默认;在你另选资产之前不会往 ini 写任何东西,「重置为默认值」回到同一个答案。
① Per project, per user: the values go into EditorPerProjectUserSettings.ini, so another machine or another user starts from their own preference, and two people on the same project can keep different languages and templates. It is an Editor Preferences section, not Project Settings. ② English is always available: every string in this plugin is authored in English, so en is the translation that always exists, and every unmatched language falls back to it. ③ An override never errors: hand-editing the ini to an unsupported culture name makes resolution fall back to the editor language silently — the UI never goes blank. ④ Simplified vs Traditional is decided by region tags: a bare zh is not guessed from the tag's length — only tags containing Hant/TW/HK/MO take the Traditional route. ⑤ Asset seeding only changes what is displayed: with no saved value the pickers show the plugin's factory default, nothing is written to the ini until you pick another asset, and Reset to Defaults returns to the same answer.