diff --git a/changelog.d/20261115-v2-feature-switches.md b/changelog.d/20261115-v2-feature-switches.md index 421ee37..b6b3c3e 100644 --- a/changelog.d/20261115-v2-feature-switches.md +++ b/changelog.d/20261115-v2-feature-switches.md @@ -4,4 +4,4 @@ type: added audience: admins title: Switches for the Custom Races V2 subclasses, Hero Races and the /dev menu --- -Modules now has Subclasses and Hero Races (turn off subclasses, the Thin Twins or the Two-Headed Ogre, two players per character) and Dev Menu (the GM /dev editor). Servers without them show them as not part of the server. +The Custom Races settings now hold Subclasses and Hero Races (subclasses, the Thin Twins, the Two-Headed Ogre, two players per character) and the GM /dev menu, each with its own switch. diff --git a/crates/coa-core/src/addons.rs b/crates/coa-core/src/addons.rs index 1a266f6..ab0ca57 100644 --- a/crates/coa-core/src/addons.rs +++ b/crates/coa-core/src/addons.rs @@ -76,6 +76,8 @@ pub struct AddonView { pub update_available: bool, /// Folders of this addon that are in the client but were not installed by the Manager. pub foreign_folders: Vec, + /// Installed by something else, shown so nobody looks for it twice: `custom-races` (the client patch). + pub bundled: Option, } fn catalog() -> Result> { @@ -128,11 +130,42 @@ pub fn list(client: &Path) -> Result> { license: entry.license, needs: entry.needs, repo: entry.repo, + bundled: None, } }) + .chain(std::iter::once(dev_menu(&dir))) .collect()) } +/// The /dev menu addon of Custom Races V2: the client patch installs it and switches it with the patch. +fn dev_menu(dir: &Path) -> AddonView { + let mut description = BTreeMap::new(); + for (lang, text) in [ + ("en", "The in-game /dev editor for game masters. It comes with the Custom Races V2 client patch and is switched with it."), + ("ru", "Внутриигровой редактор /dev для гейм-мастеров. Ставится вместе с клиентским патчем Custom Races V2 и включается вместе с ним."), + ("de", "Der /dev-Editor im Spiel für Spielleiter. Er kommt mit dem Client-Patch Custom Races V2 und wird mit ihm geschaltet."), + ("fr", "L'éditeur /dev en jeu pour les maîtres du jeu. Il vient avec le patch client Custom Races V2 et s'active avec lui."), + ("es", "El editor /dev del juego para los máster. Viene con el parche de cliente Custom Races V2 y se activa con él."), + ("zh", "供游戏管理员使用的游戏内 /dev 编辑器。随 Custom Races V2 客户端补丁安装,并随补丁一起开关。"), + ] { + description.insert(lang.to_string(), text.to_string()); + } + AddonView { + id: "coa-dev-menu".into(), + name: "CoA Dev Menu".into(), + description, + author: "ilusixn".into(), + license: "see repository".into(), + needs: None, + repo: "https://github.com/ilusixn/ilusixn-dev-menu".into(), + size: 0, + installed: dir.join("CoA_DevMenu/CoA_DevMenu.toc").is_file(), + update_available: false, + foreign_folders: Vec::new(), + bundled: Some("custom-races".into()), + } +} + /// The git blob id of `bytes` (what the catalog records for each file). fn git_blob_sha1(bytes: &[u8]) -> String { let mut hasher = Sha1::new(); @@ -364,6 +397,8 @@ mod tests { fn the_catalog_is_valid_and_pins_every_addon() { let entries = catalog().unwrap(); assert!(entries.len() >= 4); + let views = list(Path::new("C:/no-such-client")).unwrap(); + assert_eq!(views.iter().filter(|v| v.bundled.is_some()).count(), 1, "the dev menu is shown, not installable"); for e in &entries { assert_eq!(e.commit.len(), 40, "{}", e.id); assert!(e.archive.starts_with("https://codeload.github.com/") && e.archive.ends_with(&e.commit)); diff --git a/crates/coa-core/src/modules.rs b/crates/coa-core/src/modules.rs index 058a396..6bf02bd 100644 --- a/crates/coa-core/src/modules.rs +++ b/crates/coa-core/src/modules.rs @@ -48,6 +48,10 @@ pub struct Entry { /// Not shown on the Modules page; its settings are offered elsewhere (a server setting card). #[serde(default)] pub hidden: bool, + /// A part of another module, switched and set up inside that module's settings (Custom Races V2 brings + /// subclasses and the /dev menu). + #[serde(default)] + pub part_of: Option, } fn yes() -> bool { @@ -111,6 +115,7 @@ pub struct ModuleView { pub page: Option, pub hidden: bool, pub compatibility: String, + pub part_of: Option, } pub fn list(root: &Path) -> Vec { @@ -256,6 +261,7 @@ fn list_in(cat: &[Entry], root: &Path) -> Vec { icon: e.icon, page: e.page, hidden: e.hidden, + part_of: e.part_of, } }) .collect() @@ -734,6 +740,7 @@ mod tests { icon: String::new(), page: None, hidden: false, + part_of: None, }; vec![ one( @@ -1379,6 +1386,7 @@ mod tests { icon: String::new(), page: None, hidden: false, + part_of: None, }; let cat = vec![compat]; let v = list_in(&cat, &root).remove(0); diff --git a/modules/catalog.json b/modules/catalog.json index 6874527..81a4b9a 100644 --- a/modules/catalog.json +++ b/modules/catalog.json @@ -182,7 +182,9 @@ "status": "early", "icon": "races", "enable_key": "Subclass.Enable", - "default_on": true + "default_on": true, + "part_of": "custom-races", + "hidden": true }, { "id": "dev-menu", @@ -201,7 +203,9 @@ "status": "early", "icon": "sparkles", "enable_key": "DevMenu.Enable", - "default_on": true + "default_on": true, + "part_of": "custom-races", + "hidden": true }, { "id": "time-is-time", diff --git a/src/dev/mock.ts b/src/dev/mock.ts index 746e740..522d171 100644 --- a/src/dev/mock.ts +++ b/src/dev/mock.ts @@ -42,7 +42,7 @@ export {}; if(cmd==="pending_update") return null; if(cmd==="plugin:app|version") return "0.8.2"; if(cmd==="release_history") throw new Error("Offline demo: using bundled notes"); - if(cmd==="addons_list"||cmd==="addons_install"||cmd==="addons_remove"){const w=window as any;w.__addons=w.__addons??{dragonui:"old"};if(cmd==="addons_install"){await new Promise(r=>setTimeout(r,700));w.__addons[args.addon]="new";}if(cmd==="addons_remove")delete w.__addons[args.addon];return addonCatalog.addons.map((a:any)=>({id:a.id,name:a.name,description:a.description,author:a.author,license:a.license,needs:a.needs??null,repo:a.repo,size:a.files.reduce((s:number,f:any)=>s+f.size,0),installed:a.id in w.__addons,updateAvailable:w.__addons[a.id]==="old",foreignFolders:a.id==="coacombat"&&!(a.id in w.__addons)?["CoACombat"]:[]}));} + if(cmd==="addons_list"||cmd==="addons_install"||cmd==="addons_remove"){const w=window as any;w.__addons=w.__addons??{dragonui:"old"};if(cmd==="addons_install"){await new Promise(r=>setTimeout(r,700));w.__addons[args.addon]="new";}if(cmd==="addons_remove")delete w.__addons[args.addon];return addonCatalog.addons.map((a:any)=>({id:a.id,name:a.name,description:a.description,author:a.author,license:a.license,needs:a.needs??null,repo:a.repo,size:a.files.reduce((s:number,f:any)=>s+f.size,0),installed:a.id in w.__addons,updateAvailable:w.__addons[a.id]==="old",foreignFolders:a.id==="coacombat"&&!(a.id in w.__addons)?["CoACombat"]:[],bundled:null as string|null})).concat([{id:"coa-dev-menu",name:"CoA Dev Menu",description:{en:"The in-game /dev editor for game masters.",ru:"Внутриигровой редактор /dev для гейм-мастеров. Ставится вместе с клиентским патчем Custom Races V2 и включается вместе с ним."},author:"ilusixn",license:"see repository",needs:null,repo:"https://github.com/ilusixn/ilusixn-dev-menu",size:0,installed:true,updateAvailable:false,foreignFolders:[],bundled:"custom-races"}]);} if(cmd==="restart_schedule"||cmd==="restart_schedule_save"){const w=window as any;w.__sched=w.__sched??{enabled:false,time:"05:00",warningMinutes:5};if(cmd==="restart_schedule_save"){const s=args.schedule;if(s.enabled&&!/^([01]\d|2[0-3]):[0-5]\d$/.test(s.time))throw new Error("The restart time must be HH:MM, for example 05:00.");w.__sched={...s};}return {schedule:w.__sched,supported:true};} if(cmd==="mysql_custom"||cmd==="mysql_custom_save"){const w=window as any;if(cmd==="mysql_custom_save")w.__my=args.text;const text:string=w.__my??"";const applied=text.split("\n").map((l:string)=>l.trim()).filter((l:string)=>l&&!l.startsWith("#")&&!/^(port|datadir|basedir|bind[-_]address)\b/i.test(l)).map((l:string)=>l+"\n").join("");return {text,applied};} if(cmd==="realm_names"||cmd==="realm_rename"){const w=window as any;w.__rn=w.__rn??{};const defs:[number,string][]=[[1,"Conquest of Azeroth"],[2,"Wildcard"]];if(cmd==="realm_rename"){await new Promise(r=>setTimeout(r,300));const n=(args.name??"").trim();if(n.length>32||n.includes('"'))throw new Error("The realm name can have at most 32 characters.");if(n)w.__rn[args.realmId]=n;else delete w.__rn[args.realmId];}return defs.map(([id,d])=>({id,name:w.__rn[id]??d,defaultName:d,custom:id in w.__rn}));} @@ -91,7 +91,7 @@ export {}; if(cmd==="realmlist_save"){const w=window as any;const rl=w.__rl;if(args.profileId){const p=rl.profiles.find((x: any)=>x.id===args.profileId);p.name=args.name;p.data=args.data;return p;}if(rl.profiles.some((x: any)=>x.name.toLowerCase()===String(args.name).toLowerCase()))throw {human:{code:"unknown",title:"",message:"",actions:[]},technical:"A realmlist with that name already exists."};const p={id:String(args.name).toLowerCase().replace(/[^a-z0-9]+/g,"-"),name:args.name,data:(/\s/.test(args.data.trim())?args.data.trim():"set realmlist "+args.data.trim())+"\r\n"};rl.profiles.push(p);return p;} if(cmd==="realmlist_delete"){const rl=(window as any).__rl;rl.profiles=rl.profiles.filter((x: any)=>x.id!==args.profileId);return null;} if(cmd==="account_delete") return null; - if(cmd==="modules_list") return [{id:"companions",name:"CoA Companions",description:{en:"Companion bots for groups, dungeons and your guild.",ru:"Боты-компаньоны для групп, подземелий и гильдии."},repo:"https://github.com/Corfirean/mod-coa-playerbots",installed:true,enabled:modState["companions"],switchable:true,status:"beta",icon:"bot",page:"bots"},{id:"content-scaling",name:"Content Scaling",description:{en:"Scales dungeons and raids to your group, with solo modes.",ru:"Подстраивает подземелья и рейды под вашу группу, есть соло-режимы."},repo:"https://github.com/Corfirean/mod-coa-content-scaling",installed:true,enabled:modState["content-scaling"],switchable:true,status:"early",icon:"scaling",page:null},{id:"tbc-content",name:"TBC Content",description:{en:"Outland dungeons and raids, scaled to your level range.",ru:"Подземелья и рейды Запределья, подогнанные под ваши уровни."},repo:"https://github.com/Corfirean/mod-coa-content-scaling/tree/main/content-packs/mod-coa-tbc-content",installed:true,enabled:modState["tbc-content"],switchable:true,status:"early",icon:"tbc",page:null},{id:"wotlk-content",name:"WotLK Content",description:{en:"Northrend dungeons and raids, scaled to your level range.",ru:"Подземелья и рейды Нордскола, подогнанные под ваши уровни."},repo:"https://github.com/Corfirean/mod-coa-content-scaling/tree/main/content-packs/mod-coa-wotlk-content",installed:true,enabled:modState["wotlk-content"],switchable:true,status:"early",icon:"wotlk",page:null},{id:"ah-bot",name:"Auction House Bot",description:{en:"Fills the auction house with realistic, adjustable listings.",ru:"Наполняет аукцион реалистичными настраиваемыми лотами."},repo:"https://github.com/Corfirean/azerothcore-wotlk-coa",installed:true,enabled:modState["ah-bot"] ?? false,switchable:true,status:"early",icon:"gavel",page:null,hidden:false},{id:"npc-enchanter",name:"NPC Enchanter",description:{en:"An NPC that enchants your gear for you.",ru:"НПС, который зачаровывает ваше снаряжение."},repo:"https://github.com/azerothcore/mod-npc-enchanter",installed:true,enabled:modState["npc-enchanter"],switchable:true,status:"early",icon:"sparkles",page:null,hidden:false},{id:"playerbots",name:"SQUID's Playerbots",description:{en:"An alternative bot system with random bots and full AI.",ru:"Альтернативная система ботов со случайными ботами и полным ИИ."},repo:"https://github.com/Zyth45/mod-playerbots",installed:true,enabled:modState["playerbots"] ?? false,switchable:true,status:"early",icon:"swords",page:"bots",hidden:false},{id:"client-compat",name:"Client compatibility",description:{en:"Client-server link and appearance unlocks.",ru:"Связь клиента с сервером и разблокировка внешних видов."},repo:"https://github.com/Corfirean/azerothcore-wotlk-coa",installed:true,enabled:modState["client-compat"],switchable:false,status:"release",icon:"plug",page:null,hidden:true}, ...moduleCatalog.modules.filter(m => ["time-is-time", "custom-races", "subclass", "dev-menu"].includes(m.id)).map(m => ({...m, installed:true, enabled:modState[m.id] ?? true, switchable:true, page:null, hidden:false}))].map(m => ({...m, has_settings: !["tbc-content", "wotlk-content"].includes(m.id), compatibility: realm !== "coa" ? (["companions", "playerbots"].includes(m.id) ? "unsupported" : m.id === "client-compat" ? "compatible" : "experimental") : "compatible", switchable: realm !== "coa" && ["companions", "playerbots"].includes(m.id) ? false : m.switchable})); + if(cmd==="modules_list") return [{id:"companions",name:"CoA Companions",description:{en:"Companion bots for groups, dungeons and your guild.",ru:"Боты-компаньоны для групп, подземелий и гильдии."},repo:"https://github.com/Corfirean/mod-coa-playerbots",installed:true,enabled:modState["companions"],switchable:true,status:"beta",icon:"bot",page:"bots"},{id:"content-scaling",name:"Content Scaling",description:{en:"Scales dungeons and raids to your group, with solo modes.",ru:"Подстраивает подземелья и рейды под вашу группу, есть соло-режимы."},repo:"https://github.com/Corfirean/mod-coa-content-scaling",installed:true,enabled:modState["content-scaling"],switchable:true,status:"early",icon:"scaling",page:null},{id:"tbc-content",name:"TBC Content",description:{en:"Outland dungeons and raids, scaled to your level range.",ru:"Подземелья и рейды Запределья, подогнанные под ваши уровни."},repo:"https://github.com/Corfirean/mod-coa-content-scaling/tree/main/content-packs/mod-coa-tbc-content",installed:true,enabled:modState["tbc-content"],switchable:true,status:"early",icon:"tbc",page:null},{id:"wotlk-content",name:"WotLK Content",description:{en:"Northrend dungeons and raids, scaled to your level range.",ru:"Подземелья и рейды Нордскола, подогнанные под ваши уровни."},repo:"https://github.com/Corfirean/mod-coa-content-scaling/tree/main/content-packs/mod-coa-wotlk-content",installed:true,enabled:modState["wotlk-content"],switchable:true,status:"early",icon:"wotlk",page:null},{id:"ah-bot",name:"Auction House Bot",description:{en:"Fills the auction house with realistic, adjustable listings.",ru:"Наполняет аукцион реалистичными настраиваемыми лотами."},repo:"https://github.com/Corfirean/azerothcore-wotlk-coa",installed:true,enabled:modState["ah-bot"] ?? false,switchable:true,status:"early",icon:"gavel",page:null,hidden:false},{id:"npc-enchanter",name:"NPC Enchanter",description:{en:"An NPC that enchants your gear for you.",ru:"НПС, который зачаровывает ваше снаряжение."},repo:"https://github.com/azerothcore/mod-npc-enchanter",installed:true,enabled:modState["npc-enchanter"],switchable:true,status:"early",icon:"sparkles",page:null,hidden:false},{id:"playerbots",name:"SQUID's Playerbots",description:{en:"An alternative bot system with random bots and full AI.",ru:"Альтернативная система ботов со случайными ботами и полным ИИ."},repo:"https://github.com/Zyth45/mod-playerbots",installed:true,enabled:modState["playerbots"] ?? false,switchable:true,status:"early",icon:"swords",page:"bots",hidden:false},{id:"client-compat",name:"Client compatibility",description:{en:"Client-server link and appearance unlocks.",ru:"Связь клиента с сервером и разблокировка внешних видов."},repo:"https://github.com/Corfirean/azerothcore-wotlk-coa",installed:true,enabled:modState["client-compat"],switchable:false,status:"release",icon:"plug",page:null,hidden:true}, ...moduleCatalog.modules.filter(m => ["time-is-time", "custom-races", "subclass", "dev-menu"].includes(m.id)).map(m => ({...m, installed:true, enabled:modState[m.id] ?? true, switchable:true, page:null, hidden:(m as any).hidden ?? false}))].map(m => ({...m, has_settings: !["tbc-content", "wotlk-content"].includes(m.id), compatibility: realm !== "coa" ? (["companions", "playerbots"].includes(m.id) ? "unsupported" : m.id === "client-compat" ? "compatible" : "experimental") : "compatible", switchable: realm !== "coa" && ["companions", "playerbots"].includes(m.id) ? false : m.switchable})); if(cmd==="module_set_enabled"){ if(args.enabled && ["companions","playerbots"].includes(args.module) && modState[args.module === "companions" ? "playerbots" : "companions"]) throw {human:{code:"bot_modules_conflict",title:"",message:"",actions:[]},technical:"Only one bot system may be enabled."}; modState[args.module]=args.enabled; return null; } if(cmd==="all_settings") return [{key:"Visibility.Distance.Continents",value:"100",default:"90",doc:"Description: Visibility distance on continents. Range: 45-250 Default: 90",changed:true},{key:"Death.SicknessLevel",value:"11",default:"11",doc:"Description: Character level up to which characters get resurrection sickness. Default: 11",changed:false},{key:"Rate.Drop.Item.Epic",value:"3",default:"1",doc:"Description: Drop rates for money and items based on quality. Default: 1",changed:true},{key:"Instance.ResetTimeHour",value:"4",default:"4",doc:"Description: Hour of the day when the global instance reset occurs. Range: 0-23 Default: 4 - (04:00 AM)",changed:false},{key:"PlayerLimit",value:"1000",default:"1000",doc:"Description: Maximum number of players in the world.",changed:false}]; if(cmd==="all_settings_save") return Object.keys(args&&args.changes||{}); diff --git a/src/i18n/locales/de.ts b/src/i18n/locales/de.ts index 7af3c5b..5ef7bf5 100644 --- a/src/i18n/locales/de.ts +++ b/src/i18n/locales/de.ts @@ -788,6 +788,9 @@ const de: Partial> = { "sched.unsupported": "Dieser Server kann das noch nicht: Aktualisiere ihn auf einen Build mit dem neuen Launcher.", "client.clearCache": "Spiel-Cache vor jedem Start leeren", "client.clearCacheHint": "Das Spiel merkt sich Kreaturen, Gegenstände und Quests vom Server (Cache/WDB). Nach einem Server-Update zeigen sie sonst alte Namen und Werte; der Cache füllt sich in Sekunden wieder.", + "addons.withServer": "Kommt mit dem Server und wird mit ihm aktualisiert.", + "addons.withRaces": "Mit dem Client-Patch Custom Races V2 installiert und mit ihm geschaltet; der Manager installiert ihn nicht separat.", + "addons.withRacesMissing": "Kommt mit dem Client-Patch Custom Races V2 (Module, Custom Races); installiere den Patch, um ihn zu bekommen.", "addons.title": "Addons", "addons.hint": "Community-Addons für Conquest of Azeroth. Jedes kommt in einer geprüften Version vom GitHub seines Autors; jede Datei wird vor der Installation in Interface/AddOns geprüft. Schließe zuerst das Spiel.", "addons.by": "von {author}", diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index 8d2cbd2..59371c1 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -72,6 +72,9 @@ const en = { "sched.unsupported": "This server cannot do it yet: update the server to a build with the new launcher.", "client.clearCache": "Clear the game cache before every Play", "client.clearCacheHint": "The game remembers creatures, items and quests it got from a server (Cache/WDB). After a server update they can show old names and stats; the cache fills again within seconds.", + "addons.withServer": "Comes with the server and is updated with it.", + "addons.withRaces": "Installed with the Custom Races V2 client patch and switched with it; the Manager does not install it separately.", + "addons.withRacesMissing": "Comes with the Custom Races V2 client patch (Modules, Custom Races); install the patch to get it.", "addons.title": "Addons", "addons.hint": "Community addons for Conquest of Azeroth. Each comes from its author's GitHub at a checked version; every file is verified before it is installed into Interface/AddOns. Close the game first.", "addons.by": "by {author}", diff --git a/src/i18n/locales/es.ts b/src/i18n/locales/es.ts index 42e30bd..c8127c9 100644 --- a/src/i18n/locales/es.ts +++ b/src/i18n/locales/es.ts @@ -788,6 +788,9 @@ const es: Partial> = { "sched.unsupported": "Este servidor aún no puede hacerlo: actualízalo a una versión con el nuevo lanzador.", "client.clearCache": "Vaciar la caché del juego antes de cada inicio", "client.clearCacheHint": "El juego recuerda criaturas, objetos y misiones recibidos del servidor (Cache/WDB). Tras actualizar el servidor pueden mostrar nombres y estadísticas antiguos; la caché se llena de nuevo en segundos.", + "addons.withServer": "Viene con el servidor y se actualiza con él.", + "addons.withRaces": "Instalado con el parche de cliente Custom Races V2 y activado con él; el Manager no lo instala por separado.", + "addons.withRacesMissing": "Viene con el parche de cliente Custom Races V2 (Módulos, Custom Races); instala el parche para tenerlo.", "addons.title": "Addons", "addons.hint": "Addons de la comunidad para Conquest of Azeroth. Cada uno viene del GitHub de su autor en una versión comprobada; cada archivo se verifica antes de instalarlo en Interface/AddOns. Cierra antes el juego.", "addons.by": "de {author}", diff --git a/src/i18n/locales/fr.ts b/src/i18n/locales/fr.ts index 15df480..e8384bd 100644 --- a/src/i18n/locales/fr.ts +++ b/src/i18n/locales/fr.ts @@ -788,6 +788,9 @@ const fr: Partial> = { "sched.unsupported": "Ce serveur ne le permet pas encore : mettez-le à jour vers une version avec le nouveau lanceur.", "client.clearCache": "Vider le cache du jeu avant chaque lancement", "client.clearCacheHint": "Le jeu garde les créatures, objets et quêtes reçus du serveur (Cache/WDB). Après une mise à jour du serveur, ils peuvent montrer d'anciens noms et statistiques ; le cache se remplit en quelques secondes.", + "addons.withServer": "Fourni avec le serveur et mis à jour avec lui.", + "addons.withRaces": "Installé avec le patch client Custom Races V2 et activé avec lui ; le Manager ne l'installe pas séparément.", + "addons.withRacesMissing": "Fourni avec le patch client Custom Races V2 (Modules, Custom Races) ; installez le patch pour l'obtenir.", "addons.title": "Addons", "addons.hint": "Addons de la communauté pour Conquest of Azeroth. Chacun vient du GitHub de son auteur dans une version vérifiée ; chaque fichier est contrôlé avant l'installation dans Interface/AddOns. Fermez d'abord le jeu.", "addons.by": "par {author}", diff --git a/src/i18n/locales/ru.ts b/src/i18n/locales/ru.ts index 128306d..a4958ff 100644 --- a/src/i18n/locales/ru.ts +++ b/src/i18n/locales/ru.ts @@ -75,6 +75,9 @@ const ru: Partial> = { "sched.unsupported": "Этот сервер пока так не умеет: обновите его до сборки с новым лаунчером.", "client.clearCache": "Очищать кэш игры перед каждым запуском", "client.clearCacheHint": "Игра запоминает существ, предметы и задания, полученные от сервера (Cache/WDB). После обновления сервера там остаются старые названия и характеристики; кэш снова заполняется за секунды.", + "addons.withServer": "Поставляется вместе с сервером и обновляется вместе с ним.", + "addons.withRaces": "Установлен вместе с клиентским патчем Custom Races V2 и включается вместе с ним; отдельно Manager его не ставит.", + "addons.withRacesMissing": "Поставляется с клиентским патчем Custom Races V2 (Модули → Custom Races); установите патч, чтобы он появился.", "addons.title": "Аддоны", "addons.hint": "Аддоны сообщества для Conquest of Azeroth. Каждый берётся с GitHub автора в проверенной версии; перед установкой в Interface/AddOns проверяется каждый файл. Сначала закройте игру.", "addons.by": "автор: {author}", diff --git a/src/i18n/locales/zh.ts b/src/i18n/locales/zh.ts index 73767a6..332fce4 100644 --- a/src/i18n/locales/zh.ts +++ b/src/i18n/locales/zh.ts @@ -73,6 +73,9 @@ const zh = { "sched.unsupported": "此服务器暂不支持:请将服务器更新到带有新启动器的版本。", "client.clearCache": "每次启动前清空游戏缓存", "client.clearCacheHint": "游戏会保存从服务器获得的生物、物品和任务(Cache/WDB)。服务器更新后,这些缓存可能显示旧的名称和属性;缓存会在几秒内重新生成。", + "addons.withServer": "随服务器提供,并随服务器一起更新。", + "addons.withRaces": "随 Custom Races V2 客户端补丁安装并一起开关;Manager 不会单独安装它。", + "addons.withRacesMissing": "随 Custom Races V2 客户端补丁提供(模块 → Custom Races);安装补丁后即可获得。", "addons.title": "插件", "addons.hint": "Conquest of Azeroth 的社区插件。每个插件都来自作者的 GitHub 的已核验版本;安装到 Interface/AddOns 前会逐个校验文件。请先关闭游戏。", "addons.by": "作者:{author}", diff --git a/src/lib/api.ts b/src/lib/api.ts index 86e9da6..29d87f5 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -58,7 +58,7 @@ export interface StatusView { } export type RealmMode = "coa" | "wildcard" | "reborn"; -export interface AddonView { id: string; name: string; description: Record; author: string; license: string; needs: string | null; repo: string; size: number; installed: boolean; updateAvailable: boolean; foreignFolders: string[] } +export interface AddonView { id: string; name: string; description: Record; author: string; license: string; needs: string | null; repo: string; size: number; installed: boolean; updateAvailable: boolean; foreignFolders: string[]; bundled?: string | null } export interface RestartSchedule { enabled: boolean; time: string; warningMinutes: number } export interface RestartScheduleView { schedule: RestartSchedule; supported: boolean } export interface CustomMysql { text: string; applied: string } @@ -236,6 +236,7 @@ export interface ModuleView { /** not shown on the Modules page */ hidden: boolean; compatibility?: "compatible" | "experimental" | "unsupported" | "requires-squid"; + part_of?: string | null; } export interface ModuleSetting { diff --git a/src/screens/AddonCatalog.tsx b/src/screens/AddonCatalog.tsx index b9dd648..02234ac 100644 --- a/src/screens/AddonCatalog.tsx +++ b/src/screens/AddonCatalog.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; import { ExternalLink, Loader2 } from "lucide-react"; -import { api, asUiError, type AddonView } from "@/lib/api"; +import { api, asUiError, type AddonView, type ClientInfo } from "@/lib/api"; import { Button } from "@/components/ui/button"; import { useI18n } from "@/i18n"; @@ -9,7 +9,7 @@ function megabytes(bytes: number): string { } /** Addons from the Manager's catalog: each pinned to a commit of its author's repository and checked file by file. */ -export function AddonCatalog({ serverId }: { serverId: string }) { +export function AddonCatalog({ serverId, companions, onCompanionsInstalled }: { serverId: string; companions?: ClientInfo["addon"] | null; onCompanionsInstalled?: () => void }) { const { t, locale } = useI18n(); const [addons, setAddons] = useState(null); const [working, setWorking] = useState(null); @@ -28,28 +28,49 @@ export function AddonCatalog({ serverId }: { serverId: string }) { finally { setWorking(null); } } + async function installCompanions() { + setWorking("coa-companions"); setError(null); + try { await api.installAddon(serverId); onCompanionsInstalled?.(); } + catch (e) { setError(asUiError(e).technical); } + finally { setWorking(null); } + } + return

{t("addons.title")}

{t("addons.hint")}

    + {companions &&
  • +
    + CoA Companions (CoABotUI) + {companions.installed && companions.up_to_date !== false && {companions.version ? t("client.installedVersion", { v: companions.version }) : t("addons.installed")}} + {companions.up_to_date === false && {t("addons.update")}} +
    +

    {t("client.addonWhat")}

    +

    {t("addons.withServer")}

    + {(!companions.installed || companions.up_to_date === false) &&
    } +
  • } {addons?.map(a =>
  • {a.name} - {t("addons.by", { author: a.author })} · {megabytes(a.size)} MB + {t("addons.by", { author: a.author })}{a.size > 0 ? ` · ${megabytes(a.size)} MB` : ""} {a.installed && !a.updateAvailable && {t("addons.installed")}} {a.updateAvailable && {t("addons.update")}}

    {a.description[locale] ?? a.description.en}

    {a.needs === "playerbots" &&

    {t("addons.needsSquid")}

    } + {a.bundled === "custom-races" &&

    {a.installed ? t("addons.withRaces") : t("addons.withRacesMissing")}

    } {a.foreignFolders.length > 0 && !a.installed &&

    {t("addons.foreign", { folders: a.foreignFolders.join(", ") })}

    } -
    + {!a.bundled &&
    {(!a.installed || a.updateAvailable) && } {a.installed && } -
    +
    }
  • )}
{error &&

{error}

} diff --git a/src/screens/ClientCard.tsx b/src/screens/ClientCard.tsx index d8705c1..3cd77f8 100644 --- a/src/screens/ClientCard.tsx +++ b/src/screens/ClientCard.tsx @@ -86,19 +86,11 @@ export function ClientCard({ serverId, remote = false }: { serverId: string; rem : t("client.versionUntracked")} {status?.update_available && {t("client.updateAvailable")}} - {!remote && <> -
{t("client.addon")}
-
- {info.addon.installed ? (info.addon.version ? t("client.installedVersion", { v: info.addon.version }) : t("client.installed")) : t("client.addonNotInstalled")} - {info.addon.up_to_date === false && {t("client.updateAvailable")}} - {t("client.addonWhat")} -
- }
{t("client.otherAddons")}
{t("client.leftAsIs", { n: info.other_addons })}
- + void refresh()} /> {!remote && (