Expand SCUM configuration catalog
This commit is contained in:
@@ -115,7 +115,7 @@ export function ServerConfigEditor({ instance, operations, requester, onClose }:
|
|||||||
{message && <ResultBadge status={error ? "failed" : "pending"} label={message} />}
|
{message && <ResultBadge status={error ? "failed" : "pending"} label={message} />}
|
||||||
{error && workspace && <ErrorState title="配置操作失败" reason={error} diagnosticId={`server-config:${instance.id}:${selectedFile?.key ?? "unknown"}`} compact />}
|
{error && workspace && <ErrorState title="配置操作失败" reason={error} diagnosticId={`server-config:${instance.id}:${selectedFile?.key ?? "unknown"}`} compact />}
|
||||||
{loading && <LoadingState label="正在读取配置文件…" compact />}
|
{loading && <LoadingState label="正在读取配置文件…" compact />}
|
||||||
{!loading && mode === "friendly" && <div className="file-workbench-fields">{fields.length === 0 && <span className="provider-id">该配置文件没有声明可视化字段,请切换到源码模式。</span>}{fields.map((field) => <ConfigField key={field.key} field={field} value={values[field.key] ?? ""} onChange={(value) => setValues((current) => ({ ...current, [field.key]: value }))} />)}</div>}
|
{!loading && mode === "friendly" && <div className="file-workbench-fields">{fields.length === 0 && <span className="provider-id">该配置文件没有声明可视化字段,请切换到源码模式。</span>}{configFieldGroups(fields).map((group) => <div key={group.label} className="file-workbench-group"><h4>{group.label}</h4>{group.fields.map((field) => <ConfigField key={field.key} field={field} value={values[field.key] ?? ""} onChange={(value) => setValues((current) => ({ ...current, [field.key]: value }))} />)}</div>)}</div>}
|
||||||
{!loading && mode === "source" && <div className="file-workbench-raw"><textarea className="file-workbench-raw-editor" value={raw} spellCheck={false} onChange={(event) => setRaw(event.target.value)} aria-label={`${selectedFile?.label ?? "配置文件"}源码`} /><small>保存会把完整原文交给 Run 写回服务器工作区。</small></div>}
|
{!loading && mode === "source" && <div className="file-workbench-raw"><textarea className="file-workbench-raw-editor" value={raw} spellCheck={false} onChange={(event) => setRaw(event.target.value)} aria-label={`${selectedFile?.label ?? "配置文件"}源码`} /><small>保存会把完整原文交给 Run 写回服务器工作区。</small></div>}
|
||||||
<div className="action-strip file-workbench-actions"><button type="button" className="primary-command" disabled={loading || saving || !snapshot} onClick={() => void save()}><Save size={14} /><span>{saving ? "保存中…" : "保存配置"}</span></button><button type="button" className="icon-command" onClick={onClose}>取消</button></div>
|
<div className="action-strip file-workbench-actions"><button type="button" className="primary-command" disabled={loading || saving || !snapshot} onClick={() => void save()}><Save size={14} /><span>{saving ? "保存中…" : "保存配置"}</span></button><button type="button" className="icon-command" onClick={onClose}>取消</button></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -131,5 +131,14 @@ function ConfigField({ field, value, onChange }: { field: PluginConfigFieldRespo
|
|||||||
return <label className="file-workbench-field"><span><strong>{field.label}</strong><small>{field.description}{field.restartImpact === "restart-required" ? " · 修改后需要重启" : ""}</small></span>{field.control === "boolean" ? <select value={value || field.defaultValue || "false"} onChange={(event) => onChange(event.target.value)}><option value="true">是</option><option value="false">否</option></select> : <input type={inputType} min={field.minimum} max={field.maximum} value={value} placeholder={field.defaultValue ?? ""} onChange={(event) => onChange(event.target.value)} />}</label>;
|
return <label className="file-workbench-field"><span><strong>{field.label}</strong><small>{field.description}{field.restartImpact === "restart-required" ? " · 修改后需要重启" : ""}</small></span>{field.control === "boolean" ? <select value={value || field.defaultValue || "false"} onChange={(event) => onChange(event.target.value)}><option value="true">是</option><option value="false">否</option></select> : <input type={inputType} min={field.minimum} max={field.maximum} value={value} placeholder={field.defaultValue ?? ""} onChange={(event) => onChange(event.target.value)} />}</label>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function configFieldGroups(fields: PluginConfigFieldResponse[]): Array<{ label: string; fields: PluginConfigFieldResponse[] }> {
|
||||||
|
const groups = new Map<string, PluginConfigFieldResponse[]>();
|
||||||
|
for (const field of fields) {
|
||||||
|
const label = field.configKey.startsWith("scum.Server") || field.configKey.startsWith("scum.Welcome") || field.configKey.startsWith("scum.Message") ? "服务器基础" : field.configKey.includes("Zombie") || field.configKey.includes("Character") || field.configKey.includes("Animal") ? "世界与生物" : field.configKey.includes("Vehicle") || field.configKey.includes("Fuel") ? "载具" : field.configKey.includes("Raid") || field.configKey.includes("Quest") || field.configKey.includes("NewPlayer") ? "玩法规则" : "其他设置";
|
||||||
|
groups.set(label, [...(groups.get(label) ?? []), field]);
|
||||||
|
}
|
||||||
|
return [...groups.entries()].map(([label, groupFields]) => ({ label, fields: groupFields }));
|
||||||
|
}
|
||||||
|
|
||||||
function configOperationKey(operation: string, serverId: string, fileKey: string): string { return `web:server-config:${operation}:${serverId}:${fileKey}`; }
|
function configOperationKey(operation: string, serverId: string, fileKey: string): string { return `web:server-config:${operation}:${serverId}:${fileKey}`; }
|
||||||
function formatReadTime(value: string): string { const date = new Date(value); return Number.isNaN(date.getTime()) ? value : date.toLocaleString("zh-CN"); }
|
function formatReadTime(value: string): string { const date = new Date(value); return Number.isNaN(date.getTime()) ? value : date.toLocaleString("zh-CN"); }
|
||||||
|
|||||||
@@ -15,7 +15,25 @@ export const configurationCatalog: readonly SCUMConfigField[] = [
|
|||||||
{ key: "allow-first-person", fileKey: "scum-server-settings", configKey: "scum.AllowFirstPerson", label: "允许第一人称", description: "允许玩家使用第一人称视角。", control: "boolean", defaultValue: "True", restartImpact: "restart-required" },
|
{ key: "allow-first-person", fileKey: "scum-server-settings", configKey: "scum.AllowFirstPerson", label: "允许第一人称", description: "允许玩家使用第一人称视角。", control: "boolean", defaultValue: "True", restartImpact: "restart-required" },
|
||||||
{ key: "allow-third-person", fileKey: "scum-server-settings", configKey: "scum.AllowThirdPerson", label: "允许第三人称", description: "允许玩家使用第三人称视角。", control: "boolean", defaultValue: "True", restartImpact: "restart-required" },
|
{ key: "allow-third-person", fileKey: "scum-server-settings", configKey: "scum.AllowThirdPerson", label: "允许第三人称", description: "允许玩家使用第三人称视角。", control: "boolean", defaultValue: "True", restartImpact: "restart-required" },
|
||||||
{ key: "allow-global-chat", fileKey: "scum-server-settings", configKey: "scum.AllowGlobalChat", label: "允许公频聊天", description: "允许玩家使用公频聊天。", control: "boolean", defaultValue: "True", restartImpact: "none" },
|
{ key: "allow-global-chat", fileKey: "scum-server-settings", configKey: "scum.AllowGlobalChat", label: "允许公频聊天", description: "允许玩家使用公频聊天。", control: "boolean", defaultValue: "True", restartImpact: "none" },
|
||||||
{ key: "disable-base-building", fileKey: "scum-server-settings", configKey: "scum.DisableBaseBuilding", label: "禁用建家", description: "是否完全禁止玩家建造基地。", control: "boolean", defaultValue: "False", restartImpact: "restart-required" }
|
{ key: "disable-base-building", fileKey: "scum-server-settings", configKey: "scum.DisableBaseBuilding", label: "禁用建家", description: "是否完全禁止玩家建造基地。", control: "boolean", defaultValue: "False", restartImpact: "restart-required" },
|
||||||
|
{ key: "allow-map-screen", fileKey: "scum-server-settings", configKey: "scum.AllowMapScreen", label: "允许地图", description: "是否允许玩家打开地图。", control: "boolean", defaultValue: "True", restartImpact: "none" },
|
||||||
|
{ key: "allow-kill-claiming", fileKey: "scum-server-settings", configKey: "scum.AllowKillClaiming", label: "允许领取击杀", description: "是否允许玩家领取击杀奖励。", control: "boolean", defaultValue: "True", restartImpact: "none" },
|
||||||
|
{ key: "allow-coma", fileKey: "scum-server-settings", configKey: "scum.AllowComa", label: "允许昏迷", description: "是否启用昏迷机制。", control: "boolean", defaultValue: "True", restartImpact: "restart-required" },
|
||||||
|
{ key: "allow-mines-and-traps", fileKey: "scum-server-settings", configKey: "scum.AllowMinesAndTraps", label: "允许地雷和陷阱", description: "是否允许使用地雷和陷阱。", control: "boolean", defaultValue: "False", restartImpact: "restart-required" },
|
||||||
|
{ key: "allow-events", fileKey: "scum-server-settings", configKey: "scum.AllowEvents", label: "允许服务器事件", description: "是否启用服务器事件。", control: "boolean", defaultValue: "True", restartImpact: "restart-required" },
|
||||||
|
{ key: "logout-timer", fileKey: "scum-server-settings", configKey: "scum.LogoutTimer", label: "下线倒计时", description: "玩家下线前的倒计时秒数。", control: "number", minimum: 0, maximum: 3600, defaultValue: "60", restartImpact: "restart-required" },
|
||||||
|
{ key: "fame-gain-multiplier", fileKey: "scum-server-settings", configKey: "scum.FameGainMultiplier", label: "声望获取倍率", description: "玩家获得声望的倍率。", control: "number", minimum: 0, maximum: 100, defaultValue: "1", restartImpact: "none" },
|
||||||
|
{ key: "max-allowed-characters", fileKey: "scum-server-settings", configKey: "scum.MaxAllowedCharacters", label: "世界角色上限", description: "世界中同时存在的角色数量上限。", control: "number", minimum: -1, maximum: 10000, defaultValue: "500", restartImpact: "restart-required" },
|
||||||
|
{ key: "max-allowed-zombies", fileKey: "scum-server-settings", configKey: "scum.MaxAllowedZombies", label: "僵尸上限", description: "世界中同时存在的僵尸数量上限。", control: "number", minimum: -1, maximum: 10000, defaultValue: "300", restartImpact: "restart-required" },
|
||||||
|
{ key: "max-allowed-animals", fileKey: "scum-server-settings", configKey: "scum.MaxAllowedAnimals", label: "动物上限", description: "世界中同时存在的动物数量上限。", control: "number", minimum: -1, maximum: 10000, defaultValue: "-1", restartImpact: "restart-required" },
|
||||||
|
{ key: "exterior-zombie-amount", fileKey: "scum-server-settings", configKey: "scum.ExteriorZombieAmountModifier", label: "室外僵尸倍率", description: "室外僵尸数量倍率。", control: "number", minimum: 0, maximum: 100, defaultValue: "3.9", restartImpact: "restart-required" },
|
||||||
|
{ key: "interior-zombie-amount", fileKey: "scum-server-settings", configKey: "scum.InteriorZombieAmountModifier", label: "室内僵尸倍率", description: "室内僵尸数量倍率。", control: "number", minimum: 0, maximum: 100, defaultValue: "2.8", restartImpact: "restart-required" },
|
||||||
|
{ key: "fuel-drain-multiplier", fileKey: "scum-server-settings", configKey: "scum.FuelDrainFromEngineMultiplier", label: "车辆耗油倍率", description: "车辆发动机燃油消耗倍率。", control: "number", minimum: 0, maximum: 100, defaultValue: "1", restartImpact: "none" },
|
||||||
|
{ key: "vehicle-inactivity-time", fileKey: "scum-server-settings", configKey: "scum.MaximumTimeOfVehicleInactivity", label: "车辆不活跃时间", description: "车辆不活跃后被处理的时间。", control: "text", defaultValue: "168:10:00", restartImpact: "restart-required" },
|
||||||
|
{ key: "log-vehicle-destroyed", fileKey: "scum-server-settings", configKey: "scum.LogVehicleDestroyed", label: "记录车辆摧毁", description: "是否记录车辆被摧毁事件。", control: "boolean", defaultValue: "True", restartImpact: "none" },
|
||||||
|
{ key: "raid-protection-type", fileKey: "scum-server-settings", configKey: "scum.RaidProtectionType", label: "抄家保护类型", description: "服务器抄家保护规则类型。", control: "number", minimum: 0, maximum: 10, defaultValue: "3", restartImpact: "restart-required" },
|
||||||
|
{ key: "quests-enabled", fileKey: "scum-server-settings", configKey: "scum.QuestsEnabled", label: "启用任务", description: "是否启用商人任务系统。", control: "boolean", defaultValue: "True", restartImpact: "none" },
|
||||||
|
{ key: "new-player-protection", fileKey: "scum-server-settings", configKey: "scum.EnableNewPlayerProtection", label: "新人保护", description: "是否启用新人保护。", control: "boolean", defaultValue: "True", restartImpact: "restart-required" }
|
||||||
];
|
];
|
||||||
export const vehicleSpawnCatalog: readonly SCUMVehicleSpawnOption[] = [{ code: "BPC_Laika_C", label: "Laika" }, { code: "BPC_WolfsWagen_C", label: "WolfsWagen" }];
|
export const vehicleSpawnCatalog: readonly SCUMVehicleSpawnOption[] = [{ code: "BPC_Laika_C", label: "Laika" }, { code: "BPC_WolfsWagen_C", label: "WolfsWagen" }];
|
||||||
export const stateFieldCatalog: readonly Omit<SCUMStateField, "value" | "editable" | "reason">[] = [{ key: "skills.running", label: "跑步技能", minimum: 0, maximum: 1000000 }, { key: "attributes.strength", label: "力量属性", minimum: 1, maximum: 8 }, { key: "attributes.stamina", label: "体力", minimum: 0, maximum: 100000 }, { key: "attributes.dexterity", label: "敏捷", minimum: 0, maximum: 100000 }, { key: "attributes.intelligence", label: "智力", minimum: 0, maximum: 100000 }];
|
export const stateFieldCatalog: readonly Omit<SCUMStateField, "value" | "editable" | "reason">[] = [{ key: "skills.running", label: "跑步技能", minimum: 0, maximum: 1000000 }, { key: "attributes.strength", label: "力量属性", minimum: 1, maximum: 8 }, { key: "attributes.stamina", label: "体力", minimum: 0, maximum: 100000 }, { key: "attributes.dexterity", label: "敏捷", minimum: 0, maximum: 100000 }, { key: "attributes.intelligence", label: "智力", minimum: 0, maximum: 100000 }];
|
||||||
|
|||||||
@@ -704,6 +704,60 @@
|
|||||||
"control": "boolean",
|
"control": "boolean",
|
||||||
"defaultValue": "False",
|
"defaultValue": "False",
|
||||||
"restartImpact": "restart-required"
|
"restartImpact": "restart-required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "allow-map-screen", "fileKey": "scum-server-settings", "configKey": "scum.AllowMapScreen", "label": "允许地图", "description": "是否允许玩家打开地图。", "control": "boolean", "defaultValue": "True", "restartImpact": "none"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "allow-kill-claiming", "fileKey": "scum-server-settings", "configKey": "scum.AllowKillClaiming", "label": "允许领取击杀", "description": "是否允许玩家领取击杀奖励。", "control": "boolean", "defaultValue": "True", "restartImpact": "none"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "allow-coma", "fileKey": "scum-server-settings", "configKey": "scum.AllowComa", "label": "允许昏迷", "description": "是否启用昏迷机制。", "control": "boolean", "defaultValue": "True", "restartImpact": "restart-required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "allow-mines-and-traps", "fileKey": "scum-server-settings", "configKey": "scum.AllowMinesAndTraps", "label": "允许地雷和陷阱", "description": "是否允许使用地雷和陷阱。", "control": "boolean", "defaultValue": "False", "restartImpact": "restart-required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "allow-events", "fileKey": "scum-server-settings", "configKey": "scum.AllowEvents", "label": "允许服务器事件", "description": "是否启用服务器事件。", "control": "boolean", "defaultValue": "True", "restartImpact": "restart-required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "logout-timer", "fileKey": "scum-server-settings", "configKey": "scum.LogoutTimer", "label": "下线倒计时", "description": "玩家下线前的倒计时秒数。", "control": "number", "minimum": 0, "maximum": 3600, "defaultValue": "60", "restartImpact": "restart-required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "fame-gain-multiplier", "fileKey": "scum-server-settings", "configKey": "scum.FameGainMultiplier", "label": "声望获取倍率", "description": "玩家获得声望的倍率。", "control": "number", "minimum": 0, "maximum": 100, "defaultValue": "1", "restartImpact": "none"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "max-allowed-characters", "fileKey": "scum-server-settings", "configKey": "scum.MaxAllowedCharacters", "label": "世界角色上限", "description": "世界中同时存在的角色数量上限。", "control": "number", "minimum": 0, "maximum": 10000, "defaultValue": "500", "restartImpact": "restart-required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "max-allowed-zombies", "fileKey": "scum-server-settings", "configKey": "scum.MaxAllowedZombies", "label": "僵尸上限", "description": "世界中同时存在的僵尸数量上限。", "control": "number", "minimum": 0, "maximum": 10000, "defaultValue": "300", "restartImpact": "restart-required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "max-allowed-animals", "fileKey": "scum-server-settings", "configKey": "scum.MaxAllowedAnimals", "label": "动物上限", "description": "世界中同时存在的动物数量上限。", "control": "number", "minimum": 0, "maximum": 10000, "defaultValue": "-1", "restartImpact": "restart-required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "exterior-zombie-amount", "fileKey": "scum-server-settings", "configKey": "scum.ExteriorZombieAmountModifier", "label": "室外僵尸倍率", "description": "室外僵尸数量倍率。", "control": "number", "minimum": 0, "maximum": 100, "defaultValue": "3.9", "restartImpact": "restart-required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "interior-zombie-amount", "fileKey": "scum-server-settings", "configKey": "scum.InteriorZombieAmountModifier", "label": "室内僵尸倍率", "description": "室内僵尸数量倍率。", "control": "number", "minimum": 0, "maximum": 100, "defaultValue": "2.8", "restartImpact": "restart-required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "fuel-drain-multiplier", "fileKey": "scum-server-settings", "configKey": "scum.FuelDrainFromEngineMultiplier", "label": "车辆耗油倍率", "description": "车辆发动机燃油消耗倍率。", "control": "number", "minimum": 0, "maximum": 100, "defaultValue": "1", "restartImpact": "none"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "vehicle-inactivity-time", "fileKey": "scum-server-settings", "configKey": "scum.MaximumTimeOfVehicleInactivity", "label": "车辆不活跃时间", "description": "车辆不活跃后被处理的时间。", "control": "text", "defaultValue": "168:10:00", "restartImpact": "restart-required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "log-vehicle-destroyed", "fileKey": "scum-server-settings", "configKey": "scum.LogVehicleDestroyed", "label": "记录车辆摧毁", "description": "是否记录车辆被摧毁事件。", "control": "boolean", "defaultValue": "True", "restartImpact": "none"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "raid-protection-type", "fileKey": "scum-server-settings", "configKey": "scum.RaidProtectionType", "label": "抄家保护类型", "description": "服务器抄家保护规则类型。", "control": "number", "minimum": 0, "maximum": 10, "defaultValue": "3", "restartImpact": "restart-required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "quests-enabled", "fileKey": "scum-server-settings", "configKey": "scum.QuestsEnabled", "label": "启用任务", "description": "是否启用商人任务系统。", "control": "boolean", "defaultValue": "True", "restartImpact": "none"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "new-player-protection", "fileKey": "scum-server-settings", "configKey": "scum.EnableNewPlayerProtection", "label": "新人保护", "description": "是否启用新人保护。", "control": "boolean", "defaultValue": "True", "restartImpact": "restart-required"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user