mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-20 19:25:56 +00:00
Bots at start on the Bots page and the main card; adding companions raises the start limit; large batches are created offline with equipment when the server is stopped
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f7d29b09ef
commit
79846186ea
11 files changed
+262
-6
No files matched your search
@@ -527,6 +527,22 @@ const de: Partial<Record<keyof typeof en, string>> = {
|
||||
"fr.g.ts.4": "Tailscale muss bei euch beiden laufen, solange ihr spielt.",
|
||||
"fr.g.ts.admin": "Tailscale-Verwaltungsseite öffnen",
|
||||
"fr.g.ts.share": "So funktioniert das Teilen (tailscale.com)",
|
||||
|
||||
// Bots at start
|
||||
"comp.startTitle": "Bots beim Serverstart",
|
||||
"comp.startAuto": "Bots melden sich beim Serverstart automatisch an",
|
||||
"comp.startCount": "Wie viele sich anmelden",
|
||||
"comp.startSave": "Speichern",
|
||||
"comp.startSaved": "Gespeichert. Gilt ab dem nächsten Serverstart.",
|
||||
"comp.startHint": "Bots, die sich nicht anmelden, bleiben gespeichert und können später online gebracht werden.",
|
||||
"comp.startInvalid": "Gib eine ganze Zahl von 0 bis 5000 ein.",
|
||||
|
||||
// Overview start bots
|
||||
"overview.startBots": "Bots melden sich beim Start an: {n}",
|
||||
"overview.startBotsOff": "Bots melden sich beim Start nicht an",
|
||||
|
||||
// Offline bots
|
||||
"comp.offlineDone": "{n} Begleiter samt Ausrüstung erstellt. Sie melden sich beim Serverstart an.",
|
||||
};
|
||||
|
||||
export default de;
|
||||
@@ -527,6 +527,22 @@ const en = {
|
||||
"fr.g.ts.4": "Both of you must keep Tailscale running while you play.",
|
||||
"fr.g.ts.admin": "Open the Tailscale admin page",
|
||||
"fr.g.ts.share": "How sharing works (tailscale.com)",
|
||||
|
||||
// Bots at start
|
||||
"comp.startTitle": "Bots at server start",
|
||||
"comp.startAuto": "Bots log in automatically when the server starts",
|
||||
"comp.startCount": "How many log in",
|
||||
"comp.startSave": "Save",
|
||||
"comp.startSaved": "Saved. It applies the next time the server starts.",
|
||||
"comp.startHint": "Bots that do not log in stay saved and can be brought online later.",
|
||||
"comp.startInvalid": "Enter a whole number from 0 to 5000.",
|
||||
|
||||
// Overview start bots
|
||||
"overview.startBots": "Bots log in at start: {n}",
|
||||
"overview.startBotsOff": "Bots log in at start: off",
|
||||
|
||||
// Offline bots
|
||||
"comp.offlineDone": "Created {n} companions with their equipment. They log in when the server starts.",
|
||||
} as const;
|
||||
|
||||
export default en;
|
||||
@@ -527,6 +527,22 @@ const es: Partial<Record<keyof typeof en, string>> = {
|
||||
"fr.g.ts.4": "Tailscale debe seguir en marcha en ambos equipos mientras jugáis.",
|
||||
"fr.g.ts.admin": "Abrir la página de administración de Tailscale",
|
||||
"fr.g.ts.share": "Cómo funciona compartir (tailscale.com)",
|
||||
|
||||
// Bots at start
|
||||
"comp.startTitle": "Bots al iniciar el servidor",
|
||||
"comp.startAuto": "Los bots inician sesión automáticamente al arrancar el servidor",
|
||||
"comp.startCount": "Cuántos inician sesión",
|
||||
"comp.startSave": "Guardar",
|
||||
"comp.startSaved": "Guardado. Se aplica la próxima vez que se inicie el servidor.",
|
||||
"comp.startHint": "Los bots que no inician sesión quedan guardados y se pueden conectar más tarde.",
|
||||
"comp.startInvalid": "Introduce un número entero de 0 a 5000.",
|
||||
|
||||
// Overview start bots
|
||||
"overview.startBots": "Bots que inician sesión al arrancar: {n}",
|
||||
"overview.startBotsOff": "Bots al arrancar: desactivado",
|
||||
|
||||
// Offline bots
|
||||
"comp.offlineDone": "Se crearon {n} compañeros con su equipo. Iniciarán sesión cuando arranque el servidor.",
|
||||
};
|
||||
|
||||
export default es;
|
||||
@@ -527,6 +527,22 @@ const fr: Partial<Record<keyof typeof en, string>> = {
|
||||
"fr.g.ts.4": "Tailscale doit rester lancé chez vous deux pendant que vous jouez.",
|
||||
"fr.g.ts.admin": "Ouvrir la page d’administration de Tailscale",
|
||||
"fr.g.ts.share": "Comment fonctionne le partage (tailscale.com)",
|
||||
|
||||
// Bots at start
|
||||
"comp.startTitle": "Bots au démarrage du serveur",
|
||||
"comp.startAuto": "Les bots se connectent automatiquement au démarrage du serveur",
|
||||
"comp.startCount": "Combien se connectent",
|
||||
"comp.startSave": "Enregistrer",
|
||||
"comp.startSaved": "Enregistré. S’applique au prochain démarrage du serveur.",
|
||||
"comp.startHint": "Les bots qui ne se connectent pas restent enregistrés et peuvent être mis en ligne plus tard.",
|
||||
"comp.startInvalid": "Saisissez un nombre entier de 0 à 5000.",
|
||||
|
||||
// Overview start bots
|
||||
"overview.startBots": "Bots connectés au démarrage : {n}",
|
||||
"overview.startBotsOff": "Bots connectés au démarrage : aucun",
|
||||
|
||||
// Offline bots
|
||||
"comp.offlineDone": "{n} compagnons créés avec leur équipement. Ils se connecteront au démarrage du serveur.",
|
||||
};
|
||||
|
||||
export default fr;
|
||||
@@ -527,6 +527,22 @@ const ru: Partial<Record<keyof typeof en, string>> = {
|
||||
"fr.g.ts.4": "Пока вы играете, Tailscale должен быть запущен у обоих.",
|
||||
"fr.g.ts.admin": "Открыть страницу администрирования Tailscale",
|
||||
"fr.g.ts.share": "Как работает предоставление доступа (tailscale.com)",
|
||||
|
||||
// Bots at start
|
||||
"comp.startTitle": "Боты при запуске сервера",
|
||||
"comp.startAuto": "Боты входят в игру автоматически при запуске сервера",
|
||||
"comp.startCount": "Сколько входит",
|
||||
"comp.startSave": "Сохранить",
|
||||
"comp.startSaved": "Сохранено. Вступит в силу при следующем запуске сервера.",
|
||||
"comp.startHint": "Боты, которые не входят, остаются сохранёнными, их можно вывести в сеть позже.",
|
||||
"comp.startInvalid": "Введите целое число от 0 до 5000.",
|
||||
|
||||
// Overview start bots
|
||||
"overview.startBots": "Боты входят при запуске: {n}",
|
||||
"overview.startBotsOff": "Боты при запуске не входят",
|
||||
|
||||
// Offline bots
|
||||
"comp.offlineDone": "Создано компаньонов: {n}, сразу со снаряжением. Они войдут в игру при запуске сервера.",
|
||||
};
|
||||
|
||||
export default ru;
|
||||
+1
-1
@@ -292,7 +292,7 @@ export const api = {
|
||||
openLink: (url: string) => invoke<void>("open_link", { url }),
|
||||
performance: (id: string) => invoke<Performance | null>("get_performance", { id }),
|
||||
companionSizes: () => invoke<CompanionSizes>("companion_sizes"),
|
||||
addCompanions: (id: string, count: number) => invoke<{ spawned: string | null }>("add_companions", { id, count }),
|
||||
addCompanions: (id: string, count: number) => invoke<{ spawned: string | null; created: number | null }>("add_companions", { id, count }),
|
||||
clientInfo: (id: string) => invoke<ClientInfo | null>("client_info", { id }),
|
||||
setClient: (id: string, path: string) => invoke<ClientInfo>("set_client", { id, path }),
|
||||
setRealmlist: (id: string, host: string) => invoke<string[]>("client_realmlist", { id, host }),
|
||||
|
||||
@@ -16,6 +16,40 @@ export function CompanionsCard({ serverId }: { serverId: string }) {
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<UiError | null>(null);
|
||||
const [note, setNote] = useState<string | null>(null);
|
||||
// Start-up login: how many existing bots the server brings online by itself every time it starts.
|
||||
const [autoOn, setAutoOn] = useState(true);
|
||||
const [autoMax, setAutoMax] = useState("");
|
||||
const [startNote, setStartNote] = useState<string | null>(null);
|
||||
const [startBusy, setStartBusy] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
void api
|
||||
.settings(serverId, "bots")
|
||||
.then((v) => {
|
||||
const on = v.settings.find((s) => s.key === "CoaBots.AutoLoginOnStartup");
|
||||
const max = v.settings.find((s) => s.key === "CoaBots.AutoLogin.MaxCount");
|
||||
if (on) setAutoOn(on.value === true);
|
||||
if (max) setAutoMax(String(max.value));
|
||||
})
|
||||
.catch(() => {});
|
||||
}, [serverId]);
|
||||
|
||||
const maxNum = Number(autoMax);
|
||||
const maxValid = autoMax.trim() !== "" && Number.isInteger(maxNum) && maxNum >= 0 && maxNum <= 5000;
|
||||
|
||||
async function saveStart() {
|
||||
setStartBusy(true);
|
||||
setError(null);
|
||||
setStartNote(null);
|
||||
try {
|
||||
await api.save(serverId, "bots", { "CoaBots.AutoLoginOnStartup": autoOn, "CoaBots.AutoLogin.MaxCount": maxNum });
|
||||
setStartNote(t("comp.startSaved"));
|
||||
} catch (e) {
|
||||
setError(asUiError(e));
|
||||
} finally {
|
||||
setStartBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
void api.companionSizes().then(setSizes);
|
||||
@@ -52,7 +86,7 @@ export function CompanionsCard({ serverId }: { serverId: string }) {
|
||||
setNote(null);
|
||||
try {
|
||||
const r = await api.addCompanions(serverId, count);
|
||||
setNote(r.spawned ? t("comp.spawned", { n: count }) : t("comp.saved", { n: count }));
|
||||
setNote(r.created ? t("comp.offlineDone", { n: r.created }) : r.spawned ? t("comp.spawned", { n: count }) : t("comp.saved", { n: count }));
|
||||
} catch (e) {
|
||||
setError(asUiError(e));
|
||||
} finally {
|
||||
@@ -101,6 +135,32 @@ export function CompanionsCard({ serverId }: { serverId: string }) {
|
||||
{!running && <span className="text-xs text-muted">{t("comp.stoppedHint")}</span>}
|
||||
</div>
|
||||
{note && <p className="mt-3 text-sm text-ok" role="status">{note}</p>}
|
||||
|
||||
<div className="mt-5 border-t border-line pt-4">
|
||||
<h3 className="text-sm font-semibold">{t("comp.startTitle")}</h3>
|
||||
<label className="mt-2 flex cursor-pointer items-center gap-2 text-sm">
|
||||
<input type="checkbox" checked={autoOn} onChange={(e) => setAutoOn(e.target.checked)} />
|
||||
{t("comp.startAuto")}
|
||||
</label>
|
||||
<div className="mt-2 flex flex-wrap items-center gap-2 text-sm">
|
||||
<label htmlFor="start-max" className="text-muted">{t("comp.startCount")}</label>
|
||||
<input
|
||||
id="start-max"
|
||||
value={autoMax}
|
||||
onChange={(e) => setAutoMax(e.target.value)}
|
||||
inputMode="numeric"
|
||||
disabled={!autoOn}
|
||||
aria-invalid={!maxValid}
|
||||
className="w-24 rounded-md border border-line bg-bg px-3 py-1.5 text-right outline-none focus:border-gold disabled:opacity-40"
|
||||
/>
|
||||
<Button size="sm" variant="secondary" disabled={startBusy || (autoOn && !maxValid)} onClick={() => void saveStart()}>
|
||||
{t("comp.startSave")}
|
||||
</Button>
|
||||
</div>
|
||||
{autoOn && !maxValid && autoMax !== "" && <p className="mt-1 text-xs text-warn">{t("comp.startInvalid")}</p>}
|
||||
<p className="mt-1 text-xs text-muted">{t("comp.startHint")}</p>
|
||||
{startNote && <p className="mt-2 text-sm text-ok" role="status">{startNote}</p>}
|
||||
</div>
|
||||
{error && <p className="mt-3 text-sm text-bad" role="alert">{error.human.code === "unknown" ? error.technical : human(error.human).message}</p>}
|
||||
</Card>
|
||||
);
|
||||
|
||||
@@ -69,6 +69,18 @@ export function Overview({ server, onForget }: { server: ServerSummary; onForget
|
||||
const [client, setClient] = useState<ClientInfo | null>(null);
|
||||
const [playing, setPlaying] = useState(false);
|
||||
const [perf, setPerf] = useState<Performance | null>(null);
|
||||
const [startBots, setStartBots] = useState<number | null | undefined>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
void api
|
||||
.settings(server.id, "bots")
|
||||
.then((v) => {
|
||||
const on = v.settings.find((s) => s.key === "CoaBots.AutoLoginOnStartup");
|
||||
const max = v.settings.find((s) => s.key === "CoaBots.AutoLogin.MaxCount");
|
||||
setStartBots(on?.value === true && typeof max?.value === "number" ? max.value : null);
|
||||
})
|
||||
.catch(() => setStartBots(undefined));
|
||||
}, [server.id]);
|
||||
const alive = useRef(true);
|
||||
|
||||
const poll = useCallback(async () => {
|
||||
@@ -213,6 +225,9 @@ export function Overview({ server, onForget }: { server: ServerSummary; onForget
|
||||
<dd className="mt-0.5 text-lg">{pop ? `${pop.players_online}` : "—"}{pop && pop.bots_online > 0 ? <span className="ml-2 text-sm text-muted">{t("overview.companions", { n: pop.bots_online })}</span> : null}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
{startBots !== undefined && (
|
||||
<p className="mt-3 text-xs text-muted">{startBots === null ? t("overview.startBotsOff") : t("overview.startBots", { n: startBots })}</p>
|
||||
)}
|
||||
{perf && <TickRate perf={perf} />}
|
||||
|
||||
<div className="mt-7 flex items-center gap-4">
|
||||
|
||||
Reference in new issue
Block a user