mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-21 11:25:56 +00:00
Read SQUID release settings and protect imported repack binaries
This commit is contained in:
1 parent
cd3a963f70
commit
f8301d7394
23 files changed
+257
-23
No files matched your search
@@ -193,6 +193,7 @@ export interface RealmProfile {
|
||||
export interface ModuleView {
|
||||
id: string;
|
||||
name: string;
|
||||
version?: string | null;
|
||||
description: Record<string, string>;
|
||||
repo: string;
|
||||
/** the module is part of this server build (its configuration exists) */
|
||||
@@ -216,6 +217,7 @@ export interface ModuleSetting {
|
||||
value: string;
|
||||
default: string | null;
|
||||
doc: string;
|
||||
field?: { key: string; type: string; title: string; description: string; group: string; group_title?: string | null; min?: number | null; max?: number | null } | null;
|
||||
}
|
||||
|
||||
export interface AllSetting {
|
||||
|
||||
@@ -173,7 +173,8 @@ for (const [category, categoryNames] of Object.entries(auctionCategories)) {
|
||||
{ min: 0, max: 1000, advanced: true },
|
||||
);
|
||||
}
|
||||
export function moduleField(key: string, locale: Locale): ModuleField | undefined {
|
||||
export function moduleField(key: string, locale: Locale, metadata?: ModuleSetting["field"]): ModuleField | undefined {
|
||||
if (metadata) return { title: metadata.title, description: metadata.description, type: metadata.type, category: metadata.group, advanced: false, min: metadata.min ?? undefined, max: metadata.max ?? undefined };
|
||||
const field = fields.find(f => f.key === key);
|
||||
if (field) return { ...field, title: text(field.title, locale), description: text(field.description, locale), category: "general", advanced: field.advanced ?? false, step: field.type === "range" ? 0.05 : undefined, options: field.options?.map(o => ({ value: o.value, label: text(o.label, locale) })) };
|
||||
const existing = [...bots.settings, ...server.settings].find(s => s.key === key);
|
||||
|
||||
@@ -24,7 +24,7 @@ function group(key: string, curated: boolean) {
|
||||
/** Use the same settings screen as Companions, backed only by shipped SQUID options. */
|
||||
export function squidSettingsView(items: ModuleSetting[], locale: Locale): SettingsView {
|
||||
const settings: SettingView[] = items.filter(s => s.key !== "AiPlayerbot.Enabled" && !s.key.startsWith("PlayerbotsDatabase") && !s.key.startsWith("Playerbots.Updates.")).map(s => {
|
||||
const field = moduleField(s.key, locale);
|
||||
const field = moduleField(s.key, locale, s.field);
|
||||
const type = field?.type === "bool" || field?.type === "int" || field?.type === "float" || field?.type === "enum" ? field.type : "string";
|
||||
const decode = (raw: string): JsonValue => {
|
||||
const value = raw.trim().replace(/^"|"$/g, "");
|
||||
@@ -35,11 +35,13 @@ export function squidSettingsView(items: ModuleSetting[], locale: Locale): Setti
|
||||
const value = decode(s.value), defaultValue = decode(s.default ?? s.value);
|
||||
return {
|
||||
key: s.key, type, title: field?.title ?? s.key, description: field?.description ?? s.doc,
|
||||
category: group(s.key, !!field), advanced: !field || !!field.advanced,
|
||||
category: s.field?.group ? "squid." + s.field.group : group(s.key, !!field), advanced: !field || !!field.advanced,
|
||||
min: field?.min, max: field?.max, options: field?.options ?? [],
|
||||
value, default: defaultValue, is_default: value === defaultValue, present: true, problem: null,
|
||||
drift: false, restartRequired: "world", dangerous: false,
|
||||
};
|
||||
});
|
||||
return { scope: "bots", categories: groups.map(g => ({ id: g.id, title: g.titles[languages.indexOf(locale)] })), settings, unknown_keys: 0, drift_keys: [], files: ["Core/configs/modules/playerbots.conf"] };
|
||||
const categories = new Map(groups.map(g => [g.id, g.titles[languages.indexOf(locale)]]));
|
||||
for (const item of items) if (item.field?.group) categories.set("squid." + item.field.group, item.field.group_title ?? categories.get("squid." + item.field.group) ?? item.field.group);
|
||||
return { scope: "bots", categories: [...categories].map(([id, title]) => ({ id, title })), settings, unknown_keys: 0, drift_keys: [], files: ["Core/configs/modules/playerbots.conf"] };
|
||||
}
|
||||
Reference in new issue
Block a user