mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-20 03:25:56 +00:00
Phase 9: Player Mode screen for portable characters and host runtime in the app
Characters screen (realms, make portable, preflight with the projection warning, one-click Play, status chips, saved versions, diagnostics), Tauri commands, runtime started and stopped with the application, native pin recorded on make-portable, degraded state derived from stored projection, history in words instead of session identifiers, live test for make-portable then arm. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
aab0c28e1a
commit
5abba832e5
11 files changed
+1054
-19
No files matched your search
@@ -836,6 +836,132 @@ const en = {
|
||||
"upd.current": "You are up to date (version {v}).",
|
||||
"client.job.checking": "Checking the client…",
|
||||
"client.job.updating": "Updating the client",
|
||||
"nav.characters": "Characters",
|
||||
"q.characters": "Which of my characters can play where?",
|
||||
"portable.title": "Characters",
|
||||
"portable.intro": "Your characters are kept safe by the Manager. Pick a realm and press Play: the Manager prepares the character there and saves your progress when you log out.",
|
||||
"portable.runtime.stopped": "The part of the Manager that follows your game is not running. Restart the Manager.",
|
||||
"portable.realms.title": "Realms",
|
||||
"portable.realms.none": "No realm yet. Add a realm file you were given by the person who runs the server.",
|
||||
"portable.realm.online": "Running",
|
||||
"portable.realm.stopped": "Not running",
|
||||
"portable.realm.unreachable": "Cannot be reached",
|
||||
"portable.realm.cap": "level cap {cap}",
|
||||
"portable.realm.setup": "needs a setting before it can follow your game",
|
||||
"portable.realm.installed": "your server",
|
||||
"portable.realm.prepared": "added from a file",
|
||||
"portable.realm.remove": "Remove this realm",
|
||||
"portable.realm.add": "Add a realm file…",
|
||||
"portable.realm.fileType": "Realm file",
|
||||
"portable.characters.title": "Your characters",
|
||||
"portable.characters.none": "No characters yet. Use “Make an existing character portable” to bring one in from a realm.",
|
||||
"portable.level": "level {level}",
|
||||
"portable.revision": "saved version {n}",
|
||||
"portable.lastSync": "Last saved {when}",
|
||||
"portable.activeOn": "playing on {realm}",
|
||||
"portable.copy.projected": "plays here as level {level}",
|
||||
"portable.copy.synced": "version {n} on this realm",
|
||||
"portable.play.button": "Play on a realm…",
|
||||
"portable.play.title": "Play {name}",
|
||||
"portable.play.realm": "Realm",
|
||||
"portable.play.checking": "Checking the realm…",
|
||||
"portable.play.account": "Your game account on this realm",
|
||||
"portable.play.accountHint": "The account name you log in with. The Manager remembers it.",
|
||||
"portable.play.go": "Play",
|
||||
"portable.play.ready": "Ready. Start the game and log in with this character.",
|
||||
"portable.play.next": "Connect the game to {address}.",
|
||||
"portable.play.launch": "Launch the game",
|
||||
"portable.history.button": "Saved versions",
|
||||
"portable.history.created": "Saved from {realm}",
|
||||
"portable.history.play": "Progress saved while playing on {realm}",
|
||||
"portable.history.other": "Saved from {realm}",
|
||||
"portable.history.title": "Saved versions of {name}",
|
||||
"portable.make.button": "Make an existing character portable",
|
||||
"portable.make.title": "Make a character portable",
|
||||
"portable.make.text": "Pick a character that already exists on a realm. The Manager keeps a safe copy that can play on other realms. The character must be logged out.",
|
||||
"portable.make.noRealm": "None of your realms can be reached right now.",
|
||||
"portable.make.loading": "Looking at the realm’s characters…",
|
||||
"portable.make.none": "Every character of this realm is already portable.",
|
||||
"portable.make.do": "Make portable",
|
||||
"portable.make.done": "{name} is now portable.",
|
||||
"portable.blocker.online": "is logged in",
|
||||
"portable.blocker.deleted": "is deleted",
|
||||
"portable.blocker.bot_account": "belongs to a bot account",
|
||||
"portable.blocker.active_challenge": "a challenge is in progress",
|
||||
"portable.blocker.active_game_mode": "a game mode such as hardcore is active",
|
||||
"portable.blocker.active_custom_trial": "a trial is in progress",
|
||||
"portable.blocker.pending_manastorm_caches": "rewards are waiting to be delivered",
|
||||
"portable.blocker.unclassified_state": "has data the Manager does not know yet",
|
||||
"portable.cancel": "Cancel",
|
||||
"portable.close": "Close",
|
||||
"portable.details": "Technical details",
|
||||
"portable.status.ready": "Ready",
|
||||
"portable.status.syncing": "Syncing",
|
||||
"portable.status.preparing": "Preparing character",
|
||||
"portable.status.waiting_login": "Waiting for game login",
|
||||
"portable.status.playing": "Playing",
|
||||
"portable.status.saving": "Saving progress",
|
||||
"portable.status.offline": "Offline",
|
||||
"portable.status.compat_warning": "Compatibility warning",
|
||||
"portable.status.update_required": "Update required",
|
||||
"portable.status.conflict": "Conflict requires action",
|
||||
"portable.status.incompatible": "Not compatible",
|
||||
"portable.status.error": "Problem",
|
||||
"portable.verdict.compatible": "This realm takes your character completely.",
|
||||
"portable.verdict.degraded": "This realm takes your character with a limit.",
|
||||
"portable.verdict.incompatible": "This realm cannot take this character.",
|
||||
"portable.degraded.text": "You can play. What this realm cannot show stays safely stored with your character and comes back on a realm that can.",
|
||||
"portable.projection.title": "This realm has level cap {cap}.",
|
||||
"portable.projection.text": "Your level-{from} character will play here as level {to}.",
|
||||
"portable.projection.safe": "Your full level-{from} progression is preserved.",
|
||||
"portable.step.prepare": "The Manager will put your character on this realm.",
|
||||
"portable.step.arm": "Your character is on this realm and up to date.",
|
||||
"portable.step.resume": "Your character is already prepared on this realm.",
|
||||
"portable.step.restart": "This realm has to be restarted to receive your latest progress. The Manager does it for you when it runs the server.",
|
||||
"portable.step.resolve": "The copy on this realm and your saved character both changed. Choose what to keep.",
|
||||
"portable.step.blocked": "Nothing was changed.",
|
||||
"portable.step.offline": "The realm is not running. Start it, then try again.",
|
||||
"portable.resolve.canonical": "Use my saved character",
|
||||
"portable.resolve.detach": "Detach the realm’s copy",
|
||||
"portable.resolve.help": "“Use my saved character” replaces the realm’s copy with your saved one. “Detach” leaves the realm’s copy as an ordinary character that the Manager no longer follows.",
|
||||
"portable.note.held_wardrobe": "{held} appearance(s) this realm cannot show stay stored with your character.",
|
||||
"portable.note.held_collection": "Some collected items this realm does not know stay stored with your account.",
|
||||
"portable.note.held_extension": "Data of a module this realm does not have ({namespace}) stays stored with your character.",
|
||||
"portable.note.unsupported_wardrobe": "This realm cannot show selected appearances; they stay stored.",
|
||||
"portable.note.unsupported_collection": "This realm does not keep this kind of collection; it stays stored.",
|
||||
"portable.note.unsupported_extension": "A module’s data cannot be used here; it stays stored.",
|
||||
"portable.note.blocked_ruleset": "This character is for another kind of realm.",
|
||||
"portable.note.blocked_format": "This realm reads another version of the character format. Update the Manager or the realm.",
|
||||
"portable.note.blocked_online_import": "This realm cannot take characters while it runs. Update the realm.",
|
||||
"portable.note.blocked_sessions": "This realm cannot follow a game session. Ask its owner to enable portable play.",
|
||||
"portable.note.blocked_client_data": "The game data the Manager sees is not the data the realm loaded.",
|
||||
"portable.note.blocked_progression": "The realm’s level cap is not known yet or cannot be handled. Start the realm and try again.",
|
||||
"portable.note.realm_offline": "The realm cannot be reached.",
|
||||
"portable.note.realm_unknown": "The Manager has not seen this realm running yet.",
|
||||
"portable.note.conflict": "Both the realm’s copy and your saved character changed.",
|
||||
"portable.note.unreadable": "The realm’s copy could not be read.",
|
||||
"portable.note.generic": "{detail}",
|
||||
"portable.err.realm_offline": "The realm is not running or cannot be reached.",
|
||||
"portable.err.realm_missing": "That realm is not known.",
|
||||
"portable.err.character_missing": "That character is not known.",
|
||||
"portable.err.incompatible": "This realm cannot take this character. Nothing was changed.",
|
||||
"portable.err.conflict": "The realm’s copy and your saved character both changed.",
|
||||
"portable.err.update_required": "The realm has to be restarted before it can take your latest progress.",
|
||||
"portable.err.needs_account": "Enter your game account on this realm.",
|
||||
"portable.err.account_missing": "The realm has no game account with that name.",
|
||||
"portable.err.busy": "Another character is being prepared. Wait a moment.",
|
||||
"portable.err.storage": "The Manager could not use its own storage.",
|
||||
"portable.err.stopped": "The part of the Manager that follows your game is not running.",
|
||||
"portable.err.already_on_realm": "This character is already on that realm.",
|
||||
"portable.err.session_open": "This character is in play on that realm.",
|
||||
"portable.err.realm_unreadable": "The realm answered in a way the Manager does not understand.",
|
||||
"portable.err.not_prepared": "Only a realm added from a file can be removed here.",
|
||||
"portable.err.launch": "The game could not be started. Check the client in Settings.",
|
||||
"portable.err.other": "Something went wrong. Nothing was lost.",
|
||||
"portable.diag.title": "Diagnostics",
|
||||
"portable.diag.text": "A report for a bug report: realms, versions, sessions and recent problems. No passwords and no character data.",
|
||||
"portable.diag.copy": "Copy diagnostics",
|
||||
"portable.diag.copied": "Copied.",
|
||||
} as const;
|
||||
|
||||
export default en;
|
||||
@@ -834,6 +834,132 @@ const ru: Partial<Record<keyof typeof en, string>> = {
|
||||
"upd.current": "У вас последняя версия ({v}).",
|
||||
"client.job.checking": "Проверка клиента…",
|
||||
"client.job.updating": "Обновление клиента",
|
||||
"nav.characters": "Персонажи",
|
||||
"q.characters": "Какие мои персонажи где могут играть?",
|
||||
"portable.title": "Персонажи",
|
||||
"portable.intro": "Менеджер хранит ваших персонажей в безопасности. Выберите реалм и нажмите «Играть»: Менеджер сам подготовит персонажа и сохранит прогресс, когда вы выйдете из игры.",
|
||||
"portable.runtime.stopped": "Часть Менеджера, которая следит за игрой, не работает. Перезапустите Менеджер.",
|
||||
"portable.realms.title": "Реалмы",
|
||||
"portable.realms.none": "Реалмов пока нет. Добавьте файл реалма, который вам дал тот, кто держит сервер.",
|
||||
"portable.realm.online": "Работает",
|
||||
"portable.realm.stopped": "Не запущен",
|
||||
"portable.realm.unreachable": "Недоступен",
|
||||
"portable.realm.cap": "предел уровня {cap}",
|
||||
"portable.realm.setup": "нужна настройка, чтобы следить за игрой",
|
||||
"portable.realm.installed": "ваш сервер",
|
||||
"portable.realm.prepared": "добавлен из файла",
|
||||
"portable.realm.remove": "Убрать этот реалм",
|
||||
"portable.realm.add": "Добавить файл реалма…",
|
||||
"portable.realm.fileType": "Файл реалма",
|
||||
"portable.characters.title": "Ваши персонажи",
|
||||
"portable.characters.none": "Персонажей пока нет. Нажмите «Сделать существующего персонажа переносимым», чтобы взять одного с реалма.",
|
||||
"portable.level": "{level} уровень",
|
||||
"portable.revision": "сохранённая версия {n}",
|
||||
"portable.lastSync": "Последнее сохранение: {when}",
|
||||
"portable.activeOn": "играет на {realm}",
|
||||
"portable.copy.projected": "здесь играет как {level} уровень",
|
||||
"portable.copy.synced": "на реалме версия {n}",
|
||||
"portable.play.button": "Играть на реалме…",
|
||||
"portable.play.title": "Играть: {name}",
|
||||
"portable.play.realm": "Реалм",
|
||||
"portable.play.checking": "Проверяю реалм…",
|
||||
"portable.play.account": "Ваш игровой аккаунт на этом реалме",
|
||||
"portable.play.accountHint": "Имя аккаунта, под которым вы входите в игру. Менеджер его запомнит.",
|
||||
"portable.play.go": "Играть",
|
||||
"portable.play.ready": "Готово. Запустите игру и войдите этим персонажем.",
|
||||
"portable.play.next": "Подключите игру к {address}.",
|
||||
"portable.play.launch": "Запустить игру",
|
||||
"portable.history.button": "Сохранённые версии",
|
||||
"portable.history.created": "Сохранён с реалма {realm}",
|
||||
"portable.history.play": "Прогресс сохранён во время игры на реалме {realm}",
|
||||
"portable.history.other": "Сохранён с реалма {realm}",
|
||||
"portable.history.title": "Сохранённые версии: {name}",
|
||||
"portable.make.button": "Сделать существующего персонажа переносимым",
|
||||
"portable.make.title": "Сделать персонажа переносимым",
|
||||
"portable.make.text": "Выберите персонажа, который уже есть на реалме. Менеджер сохранит надёжную копию, которая сможет играть на других реалмах. Персонаж должен быть не в игре.",
|
||||
"portable.make.noRealm": "Сейчас ни один ваш реалм недоступен.",
|
||||
"portable.make.loading": "Смотрю персонажей реалма…",
|
||||
"portable.make.none": "Все персонажи этого реалма уже переносимые.",
|
||||
"portable.make.do": "Сделать переносимым",
|
||||
"portable.make.done": "{name} теперь переносимый.",
|
||||
"portable.blocker.online": "сейчас в игре",
|
||||
"portable.blocker.deleted": "удалён",
|
||||
"portable.blocker.bot_account": "принадлежит аккаунту бота",
|
||||
"portable.blocker.active_challenge": "идёт испытание",
|
||||
"portable.blocker.active_game_mode": "включён режим вроде хардкора",
|
||||
"portable.blocker.active_custom_trial": "идёт испытание",
|
||||
"portable.blocker.pending_manastorm_caches": "ждут доставки награды",
|
||||
"portable.blocker.unclassified_state": "есть данные, которых Менеджер ещё не знает",
|
||||
"portable.cancel": "Отмена",
|
||||
"portable.close": "Закрыть",
|
||||
"portable.details": "Технические подробности",
|
||||
"portable.status.ready": "Готов",
|
||||
"portable.status.syncing": "Синхронизация",
|
||||
"portable.status.preparing": "Готовлю персонажа",
|
||||
"portable.status.waiting_login": "Жду входа в игру",
|
||||
"portable.status.playing": "В игре",
|
||||
"portable.status.saving": "Сохраняю прогресс",
|
||||
"portable.status.offline": "Недоступен",
|
||||
"portable.status.compat_warning": "Есть ограничения",
|
||||
"portable.status.update_required": "Нужно обновление",
|
||||
"portable.status.conflict": "Нужно ваше решение",
|
||||
"portable.status.incompatible": "Не подходит",
|
||||
"portable.status.error": "Проблема",
|
||||
"portable.verdict.compatible": "Этот реалм принимает персонажа полностью.",
|
||||
"portable.verdict.degraded": "Этот реалм принимает персонажа с ограничением.",
|
||||
"portable.verdict.incompatible": "Этот реалм не может принять этого персонажа.",
|
||||
"portable.degraded.text": "Играть можно. То, что реалм не может показать, остаётся в сохранности у персонажа и вернётся на реалме, который это умеет.",
|
||||
"portable.projection.title": "На этом реалме предел уровня — {cap}.",
|
||||
"portable.projection.text": "Ваш персонаж {from} уровня будет играть здесь как {to} уровня.",
|
||||
"portable.projection.safe": "Весь прогресс {from} уровня сохраняется.",
|
||||
"portable.step.prepare": "Менеджер сам поставит персонажа на этот реалм.",
|
||||
"portable.step.arm": "Персонаж уже на этом реалме и актуален.",
|
||||
"portable.step.resume": "Персонаж уже подготовлен на этом реалме.",
|
||||
"portable.step.restart": "Реалм нужно перезапустить, чтобы он получил ваш последний прогресс. Менеджер сделает это сам, если держит этот сервер.",
|
||||
"portable.step.resolve": "И копия на реалме, и ваш сохранённый персонаж изменились. Выберите, что оставить.",
|
||||
"portable.step.blocked": "Ничего не изменено.",
|
||||
"portable.step.offline": "Реалм не запущен. Запустите его и попробуйте снова.",
|
||||
"portable.resolve.canonical": "Взять мой сохранённый",
|
||||
"portable.resolve.detach": "Отвязать копию на реалме",
|
||||
"portable.resolve.help": "«Взять мой сохранённый» заменит копию на реалме вашим сохранённым персонажем. «Отвязать» оставит копию на реалме обычным персонажем, за которым Менеджер больше не следит.",
|
||||
"portable.note.held_wardrobe": "{held} внешн. вид(ов), которые реалм не умеет показывать, остаются у персонажа.",
|
||||
"portable.note.held_collection": "Часть коллекций, которых реалм не знает, остаётся у вашего аккаунта.",
|
||||
"portable.note.held_extension": "Данные модуля, которого нет на реалме ({namespace}), остаются у персонажа.",
|
||||
"portable.note.unsupported_wardrobe": "Этот реалм не показывает выбранный внешний вид; он остаётся сохранённым.",
|
||||
"portable.note.unsupported_collection": "Этот реалм не хранит такую коллекцию; она остаётся сохранённой.",
|
||||
"portable.note.unsupported_extension": "Данные модуля здесь не используются; они остаются сохранёнными.",
|
||||
"portable.note.blocked_ruleset": "Этот персонаж — для реалма другого типа.",
|
||||
"portable.note.blocked_format": "Реалм читает другую версию формата персонажа. Обновите Менеджер или реалм.",
|
||||
"portable.note.blocked_online_import": "Этот реалм не принимает персонажей, пока работает. Обновите реалм.",
|
||||
"portable.note.blocked_sessions": "Этот реалм не может следить за игровой сессией. Попросите владельца включить переносимую игру.",
|
||||
"portable.note.blocked_client_data": "Игровые данные, которые видит Менеджер, не те, что загрузил реалм.",
|
||||
"portable.note.blocked_progression": "Предел уровня реалма пока неизвестен или не поддерживается. Запустите реалм и попробуйте снова.",
|
||||
"portable.note.realm_offline": "Реалм недоступен.",
|
||||
"portable.note.realm_unknown": "Менеджер ещё не видел этот реалм запущенным.",
|
||||
"portable.note.conflict": "Изменились и копия на реалме, и ваш сохранённый персонаж.",
|
||||
"portable.note.unreadable": "Копию на реалме не удалось прочитать.",
|
||||
"portable.note.generic": "{detail}",
|
||||
"portable.err.realm_offline": "Реалм не запущен или недоступен.",
|
||||
"portable.err.realm_missing": "Такой реалм неизвестен.",
|
||||
"portable.err.character_missing": "Такой персонаж неизвестен.",
|
||||
"portable.err.incompatible": "Этот реалм не может принять этого персонажа. Ничего не изменено.",
|
||||
"portable.err.conflict": "И копия на реалме, и ваш сохранённый персонаж изменились.",
|
||||
"portable.err.update_required": "Реалм нужно перезапустить, чтобы он принял ваш последний прогресс.",
|
||||
"portable.err.needs_account": "Введите ваш игровой аккаунт на этом реалме.",
|
||||
"portable.err.account_missing": "На реалме нет игрового аккаунта с таким именем.",
|
||||
"portable.err.busy": "Сейчас готовится другой персонаж. Подождите немного.",
|
||||
"portable.err.storage": "Менеджер не смог использовать собственное хранилище.",
|
||||
"portable.err.stopped": "Часть Менеджера, которая следит за игрой, не работает.",
|
||||
"portable.err.already_on_realm": "Этот персонаж уже есть на том реалме.",
|
||||
"portable.err.session_open": "Этот персонаж сейчас в игре на том реалме.",
|
||||
"portable.err.realm_unreadable": "Реалм ответил так, что Менеджер не понимает.",
|
||||
"portable.err.not_prepared": "Здесь можно убрать только реалм, добавленный из файла.",
|
||||
"portable.err.launch": "Не удалось запустить игру. Проверьте клиент в настройках.",
|
||||
"portable.err.other": "Что-то пошло не так. Ничего не потеряно.",
|
||||
"portable.diag.title": "Диагностика",
|
||||
"portable.diag.text": "Отчёт для сообщения об ошибке: реалмы, версии, сессии и недавние проблемы. Без паролей и без данных персонажей.",
|
||||
"portable.diag.copy": "Скопировать диагностику",
|
||||
"portable.diag.copied": "Скопировано.",
|
||||
};
|
||||
|
||||
export default ru;
|
||||
@@ -0,0 +1,123 @@
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
export type PlayStatus =
|
||||
| "ready" | "syncing" | "preparing" | "waiting_login" | "playing" | "saving" | "offline"
|
||||
| "compat_warning" | "update_required" | "conflict" | "incompatible" | "error";
|
||||
|
||||
export interface CopyView {
|
||||
realm_id: string;
|
||||
realm_name: string;
|
||||
status: PlayStatus;
|
||||
synced_revision: number;
|
||||
behind: boolean;
|
||||
projected_level: number | null;
|
||||
degraded: boolean;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface CharacterView {
|
||||
id: string;
|
||||
name: string;
|
||||
class_name: string;
|
||||
race: string;
|
||||
level: number;
|
||||
revision: number;
|
||||
updated_at: string;
|
||||
active_realm: string | null;
|
||||
status: PlayStatus;
|
||||
copies: CopyView[];
|
||||
}
|
||||
|
||||
export interface RealmView {
|
||||
id: string;
|
||||
name: string;
|
||||
kind: "installed" | "prepared";
|
||||
address: string;
|
||||
online: boolean;
|
||||
database_ok: boolean;
|
||||
level_cap: number | null;
|
||||
portable: "ready" | "setup" | "unknown";
|
||||
game_account: string | null;
|
||||
installed_id: string | null;
|
||||
}
|
||||
|
||||
export interface Note { code: string; params: Record<string, string>; detail: string }
|
||||
export type Verdict = "compatible" | "degraded" | "incompatible";
|
||||
export type Step = "prepare" | "arm" | "resume" | "restart" | "resolve" | "blocked" | "offline";
|
||||
|
||||
export interface PreflightView {
|
||||
verdict: Verdict;
|
||||
step: Step;
|
||||
projection: [number, number] | null;
|
||||
notes: Note[];
|
||||
needs_account: boolean;
|
||||
}
|
||||
|
||||
export interface PlayView {
|
||||
status: PlayStatus;
|
||||
projection: [number, number] | null;
|
||||
notes: Note[];
|
||||
realm_address: string;
|
||||
realm_id: string;
|
||||
}
|
||||
|
||||
export interface LocalCharacterView {
|
||||
token: number;
|
||||
name: string;
|
||||
class_name: string;
|
||||
level: number;
|
||||
account: string;
|
||||
eligible: boolean;
|
||||
reasons: string[];
|
||||
}
|
||||
|
||||
export interface HistoryEntry { revision: number; at: string; source_realm: string; kind: "created" | "play" | "other" }
|
||||
export interface ErrorEntry { at: string; realm: string | null; message: string }
|
||||
|
||||
export interface PortableState {
|
||||
characters: CharacterView[];
|
||||
realms: RealmView[];
|
||||
operation: { character_id: string; realm_id: string; status: PlayStatus } | null;
|
||||
runtime: { running: boolean; last_tick_secs: number | null; sessions_open: number; errors: ErrorEntry[] };
|
||||
}
|
||||
|
||||
export interface PortableError { code: string; message: string; notes: Note[] }
|
||||
|
||||
export function asPortableError(e: unknown): PortableError {
|
||||
if (e && typeof e === "object" && "code" in e && "message" in e) return e as PortableError;
|
||||
return { code: "other", message: String(e), notes: [] };
|
||||
}
|
||||
|
||||
export type Resolve = "use_canonical" | "detach";
|
||||
|
||||
export const portable = {
|
||||
state: () => invoke<PortableState>("portable_state"),
|
||||
preflight: (character: string, realm: string) => invoke<PreflightView>("portable_preflight", { character, realm }),
|
||||
play: (character: string, realm: string, account?: string) => invoke<PlayView>("portable_play", { character, realm, account: account ?? null }),
|
||||
localCharacters: (realm: string) => invoke<LocalCharacterView[]>("portable_local_characters", { realm }),
|
||||
make: (realm: string, token: number) => invoke<CharacterView>("portable_make", { realm, token }),
|
||||
resolve: (character: string, realm: string, action: Resolve) => invoke<void>("portable_resolve", { character, realm, action }),
|
||||
history: (character: string) => invoke<HistoryEntry[]>("portable_history", { character }),
|
||||
addRealm: (path: string) => invoke<RealmView>("portable_add_realm", { path }),
|
||||
removeRealm: (realm: string) => invoke<void>("portable_remove_realm", { realm }),
|
||||
diagnostics: () => invoke<unknown>("portable_diagnostics"),
|
||||
launch: (realm: string) => invoke<void>("portable_launch", { realm }),
|
||||
};
|
||||
|
||||
/** The state of portable play, refreshed every second or so for as long as a screen shows it. The service itself runs without the screen. */
|
||||
export function usePortable(everyMs = 1200): { state: PortableState | null; refresh: () => Promise<void> } {
|
||||
const [state, setState] = useState<PortableState | null>(null);
|
||||
const busy = useRef(false);
|
||||
const refresh = useCallback(async () => {
|
||||
if (busy.current) return;
|
||||
busy.current = true;
|
||||
try { setState(await portable.state()); } catch { /* the service is not available; the screen says so */ } finally { busy.current = false; }
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
void refresh();
|
||||
const timer = setInterval(() => void refresh(), everyMs);
|
||||
return () => clearInterval(timer);
|
||||
}, [refresh, everyMs]);
|
||||
return { state, refresh };
|
||||
}
|
||||
@@ -0,0 +1,336 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { open } from "@tauri-apps/plugin-dialog";
|
||||
import { AlertTriangle, CheckCircle2, History, Loader2, Plus, ShieldAlert, Swords, Trash2, X } from "lucide-react";
|
||||
import { useT, type Key } from "@/i18n";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { cn } from "@/lib/utils";
|
||||
import {
|
||||
asPortableError, portable, usePortable,
|
||||
type CharacterView, type HistoryEntry, type LocalCharacterView, type Note, type PlayStatus,
|
||||
type PlayView, type PortableError, type PreflightView, type RealmView,
|
||||
} from "@/lib/portable";
|
||||
|
||||
const WORKING: PlayStatus[] = ["preparing", "syncing", "saving"];
|
||||
const LIVE: PlayStatus[] = ["playing", "waiting_login", "preparing", "syncing", "saving"];
|
||||
|
||||
function when(iso: string): string {
|
||||
const d = new Date(iso);
|
||||
return Number.isNaN(d.getTime()) ? iso : d.toLocaleString();
|
||||
}
|
||||
|
||||
function StatusChip({ status, degraded }: { status: PlayStatus; degraded?: boolean }) {
|
||||
const t = useT();
|
||||
const tone = status === "playing" ? "bg-ok/15 text-ok"
|
||||
: status === "conflict" || status === "incompatible" || status === "error" ? "bg-bad/15 text-bad"
|
||||
: status === "update_required" || status === "compat_warning" || status === "offline" ? "bg-warn/15 text-warn"
|
||||
: WORKING.includes(status) || status === "waiting_login" ? "bg-gold/15 text-gold"
|
||||
: "bg-white/5 text-muted";
|
||||
return <span className="inline-flex items-center gap-2">
|
||||
<span className={cn("inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium", tone)} data-status={status}>
|
||||
{WORKING.includes(status) && <Loader2 className="h-3 w-3 animate-spin" aria-hidden />}
|
||||
{t(`portable.status.${status}` as Key)}
|
||||
</span>
|
||||
{degraded && <span className="inline-flex items-center gap-1 rounded-full bg-warn/15 px-2.5 py-0.5 text-xs font-medium text-warn"><AlertTriangle className="h-3 w-3" aria-hidden />{t("portable.status.compat_warning")}</span>}
|
||||
</span>;
|
||||
}
|
||||
|
||||
/** The words of one line of the compatibility check. */
|
||||
function noteText(t: ReturnType<typeof useT>, n: Note): string {
|
||||
const key = `portable.note.${n.code}` as Key;
|
||||
const text = t(key, { ...n.params });
|
||||
return text === key ? t("portable.note.generic", { detail: n.detail }) : text;
|
||||
}
|
||||
|
||||
function Notes({ notes }: { notes: Note[] }) {
|
||||
const t = useT();
|
||||
const shown = notes.filter((n) => n.code !== "projection");
|
||||
if (!shown.length) return null;
|
||||
return <ul className="mt-3 space-y-1.5 text-sm text-muted">{shown.map((n, i) => <li key={i} className="flex gap-2"><AlertTriangle className="mt-0.5 h-4 w-4 shrink-0 text-warn" aria-hidden /><span className="selectable">{noteText(t, n)}</span></li>)}</ul>;
|
||||
}
|
||||
|
||||
function Projection({ from, to, cap }: { from: number; to: number; cap?: number | null }) {
|
||||
const t = useT();
|
||||
return <div className="mt-3 rounded-md border border-gold/40 bg-gold/10 p-3 text-sm" role="note">
|
||||
<p className="font-medium text-gold">{t("portable.projection.title", { cap: cap ?? to })}</p>
|
||||
<p className="mt-1">{t("portable.projection.text", { from, to })}</p>
|
||||
<p className="mt-1 text-muted">{t("portable.projection.safe", { from })}</p>
|
||||
</div>;
|
||||
}
|
||||
|
||||
function ErrorLine({ error }: { error: PortableError }) {
|
||||
const t = useT();
|
||||
const key = `portable.err.${error.code}` as Key;
|
||||
const text = t(key);
|
||||
return <div className="mt-3 text-sm text-bad" role="alert">
|
||||
<p>{text === key ? t("portable.err.other") : text}</p>
|
||||
<details className="mt-1 text-xs text-muted"><summary className="cursor-pointer">{t("portable.details")}</summary><p className="selectable mt-1">{error.message}</p></details>
|
||||
<Notes notes={error.notes} />
|
||||
</div>;
|
||||
}
|
||||
|
||||
// ---- Play --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function PlayDialog({ character, realms, initial, onClose, onChanged }: { character: CharacterView; realms: RealmView[]; initial: string; onClose: () => void; onChanged: () => void }) {
|
||||
const t = useT();
|
||||
const [realmId, setRealmId] = useState(initial);
|
||||
const realm = realms.find((r) => r.id === realmId)!;
|
||||
const [pre, setPre] = useState<PreflightView | null>(null);
|
||||
const [account, setAccount] = useState(realm.game_account ?? "");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [done, setDone] = useState<PlayView | null>(null);
|
||||
const [error, setError] = useState<PortableError | null>(null);
|
||||
const [launching, setLaunching] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
setPre(null); setError(null); setDone(null); setAccount(realm.game_account ?? "");
|
||||
void portable.preflight(character.id, realmId).then((p) => { if (alive) setPre(p); }).catch((e) => { if (alive) setError(asPortableError(e)); });
|
||||
return () => { alive = false; };
|
||||
}, [character.id, realmId]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
async function play() {
|
||||
setBusy(true); setError(null);
|
||||
try { setDone(await portable.play(character.id, realmId, account.trim() || undefined)); onChanged(); }
|
||||
catch (e) { setError(asPortableError(e)); }
|
||||
finally { setBusy(false); }
|
||||
}
|
||||
async function launch() {
|
||||
setLaunching(true); setError(null);
|
||||
try { await portable.launch(realmId); } catch (e) { setError(asPortableError(e)); } finally { setLaunching(false); }
|
||||
}
|
||||
async function resolve(action: "use_canonical" | "detach") {
|
||||
setBusy(true); setError(null);
|
||||
try { await portable.resolve(character.id, realmId, action); onChanged(); setPre(await portable.preflight(character.id, realmId)); }
|
||||
catch (e) { setError(asPortableError(e)); }
|
||||
finally { setBusy(false); }
|
||||
}
|
||||
|
||||
const blocked = !pre || pre.step === "blocked" || pre.step === "offline" || pre.step === "resolve" || busy;
|
||||
return <div className="fixed inset-0 z-40 flex items-center justify-center bg-black/60 p-6" role="dialog" aria-modal="true" aria-labelledby="play-title">
|
||||
<Card className="max-h-full w-full max-w-xl overflow-y-auto p-6">
|
||||
<div className="flex items-start justify-between">
|
||||
<h2 id="play-title" className="text-lg font-semibold">{t("portable.play.title", { name: character.name })}</h2>
|
||||
<button onClick={onClose} aria-label={t("portable.cancel")} className="cursor-pointer text-muted hover:text-ink"><X className="h-5 w-5" /></button>
|
||||
</div>
|
||||
<label className="mt-4 block text-sm font-medium" htmlFor="play-realm">{t("portable.play.realm")}</label>
|
||||
<select id="play-realm" value={realmId} onChange={(e) => setRealmId(e.target.value)} disabled={busy || !!done} className="mt-1 w-full rounded-md border border-line bg-card px-3 py-2">
|
||||
{realms.map((r) => <option key={r.id} value={r.id}>{r.name}{r.level_cap ? ` · ${t("portable.realm.cap", { cap: r.level_cap })}` : ""}</option>)}
|
||||
</select>
|
||||
|
||||
{!pre && !error && <p className="mt-4 flex items-center gap-2 text-sm text-muted"><Loader2 className="h-4 w-4 animate-spin" aria-hidden />{t("portable.play.checking")}</p>}
|
||||
{pre && !done && <>
|
||||
<p className={cn("mt-4 flex items-center gap-2 text-sm font-medium", pre.verdict === "compatible" ? "text-ok" : pre.verdict === "degraded" ? "text-warn" : "text-bad")}>
|
||||
{pre.verdict === "compatible" ? <CheckCircle2 className="h-4 w-4" aria-hidden /> : <ShieldAlert className="h-4 w-4" aria-hidden />}
|
||||
{t(`portable.verdict.${pre.verdict}` as Key)}
|
||||
</p>
|
||||
{pre.projection && <Projection from={pre.projection[0]} to={pre.projection[1]} cap={realm.level_cap} />}
|
||||
{pre.verdict === "degraded" && <p className="mt-3 text-sm text-muted">{t("portable.degraded.text")}</p>}
|
||||
<Notes notes={pre.notes} />
|
||||
<p className="mt-3 text-sm text-muted">{t(`portable.step.${pre.step}` as Key)}</p>
|
||||
{pre.step === "resolve" && <div className="mt-3 flex flex-wrap gap-2">
|
||||
<Button size="sm" variant="primary" disabled={busy} onClick={() => void resolve("use_canonical")}>{t("portable.resolve.canonical")}</Button>
|
||||
<Button size="sm" disabled={busy} onClick={() => void resolve("detach")}>{t("portable.resolve.detach")}</Button>
|
||||
<Button size="sm" variant="ghost" disabled={busy} onClick={onClose}>{t("portable.cancel")}</Button>
|
||||
</div>}
|
||||
{pre.step === "resolve" && <p className="mt-2 text-xs text-muted">{t("portable.resolve.help")}</p>}
|
||||
{(pre.needs_account || realm.game_account === null) && pre.step === "prepare" && <div className="mt-4">
|
||||
<label htmlFor="play-account" className="block text-sm font-medium">{t("portable.play.account")}</label>
|
||||
<p className="text-xs text-muted">{t("portable.play.accountHint")}</p>
|
||||
<input id="play-account" value={account} onChange={(e) => setAccount(e.target.value)} disabled={busy} className="mt-1 w-full rounded-md border border-line bg-card px-3 py-2" autoComplete="off" />
|
||||
</div>}
|
||||
</>}
|
||||
{done && <div className="mt-4">
|
||||
<p className="flex items-center gap-2 text-sm font-medium text-ok"><CheckCircle2 className="h-4 w-4" aria-hidden />{t("portable.play.ready")}</p>
|
||||
{done.projection && <Projection from={done.projection[0]} to={done.projection[1]} cap={realm.level_cap} />}
|
||||
<Notes notes={done.notes} />
|
||||
<p className="mt-3 text-sm text-muted">{t("portable.play.next", { address: done.realm_address })}</p>
|
||||
</div>}
|
||||
{error && <ErrorLine error={error} />}
|
||||
<div className="mt-5 flex justify-end gap-2">
|
||||
<Button variant="ghost" onClick={onClose}>{done ? t("portable.close") : t("portable.cancel")}</Button>
|
||||
{!done && <Button variant="primary" disabled={blocked || (pre?.step === "prepare" && !account.trim() && realm.game_account === null)} onClick={() => void play()}>
|
||||
{busy && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}{busy ? t("portable.status.preparing") : t("portable.play.go")}
|
||||
</Button>}
|
||||
{done && <Button variant="primary" disabled={launching} onClick={() => void launch()}>{launching && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}{t("portable.play.launch")}</Button>}
|
||||
</div>
|
||||
</Card>
|
||||
</div>;
|
||||
}
|
||||
|
||||
// ---- Make portable ------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function MakeDialog({ realms, onClose, onChanged }: { realms: RealmView[]; onClose: () => void; onChanged: () => void }) {
|
||||
const t = useT();
|
||||
const usable = realms.filter((r) => r.database_ok);
|
||||
const [realmId, setRealmId] = useState(usable[0]?.id ?? "");
|
||||
const [list, setList] = useState<LocalCharacterView[] | null>(null);
|
||||
const [error, setError] = useState<PortableError | null>(null);
|
||||
const [busy, setBusy] = useState<number | null>(null);
|
||||
const [made, setMade] = useState<string | null>(null);
|
||||
useEffect(() => {
|
||||
if (!realmId) return;
|
||||
let alive = true;
|
||||
setList(null); setError(null);
|
||||
void portable.localCharacters(realmId).then((l) => { if (alive) setList(l); }).catch((e) => { if (alive) setError(asPortableError(e)); });
|
||||
return () => { alive = false; };
|
||||
}, [realmId]);
|
||||
async function make(c: LocalCharacterView) {
|
||||
setBusy(c.token); setError(null);
|
||||
try { const v = await portable.make(realmId, c.token); setMade(v.name); onChanged(); setList((l) => l?.filter((x) => x.token !== c.token) ?? null); }
|
||||
catch (e) { setError(asPortableError(e)); } finally { setBusy(null); }
|
||||
}
|
||||
return <div className="fixed inset-0 z-40 flex items-center justify-center bg-black/60 p-6" role="dialog" aria-modal="true" aria-labelledby="make-title">
|
||||
<Card className="max-h-full w-full max-w-2xl overflow-y-auto p-6">
|
||||
<div className="flex items-start justify-between">
|
||||
<h2 id="make-title" className="text-lg font-semibold">{t("portable.make.title")}</h2>
|
||||
<button onClick={onClose} aria-label={t("portable.close")} className="cursor-pointer text-muted hover:text-ink"><X className="h-5 w-5" /></button>
|
||||
</div>
|
||||
<p className="mt-1 text-sm text-muted">{t("portable.make.text")}</p>
|
||||
{usable.length === 0 ? <p className="mt-4 text-sm text-warn">{t("portable.make.noRealm")}</p> : <>
|
||||
<label htmlFor="make-realm" className="mt-4 block text-sm font-medium">{t("portable.play.realm")}</label>
|
||||
<select id="make-realm" value={realmId} onChange={(e) => setRealmId(e.target.value)} className="mt-1 w-full rounded-md border border-line bg-card px-3 py-2">
|
||||
{usable.map((r) => <option key={r.id} value={r.id}>{r.name}</option>)}
|
||||
</select>
|
||||
{!list && !error && <p className="mt-4 flex items-center gap-2 text-sm text-muted"><Loader2 className="h-4 w-4 animate-spin" aria-hidden />{t("portable.make.loading")}</p>}
|
||||
{list && list.length === 0 && <p className="mt-4 text-sm text-muted">{t("portable.make.none")}</p>}
|
||||
{list && list.length > 0 && <ul className="mt-4 divide-y divide-line rounded-md border border-line">
|
||||
{list.map((c) => <li key={c.token} className="flex items-center gap-3 px-3 py-2">
|
||||
<div className="min-w-0 flex-1"><p className="truncate font-medium">{c.name}</p><p className="text-xs text-muted">{c.class_name} · {t("portable.level", { level: c.level })}{c.account ? ` · ${c.account}` : ""}</p>
|
||||
{!c.eligible && <p className="text-xs text-warn">{c.reasons.map((r) => t(`portable.blocker.${r}` as Key)).join(", ")}</p>}</div>
|
||||
<Button size="sm" disabled={!c.eligible || busy !== null} onClick={() => void make(c)}>{busy === c.token && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}{t("portable.make.do")}</Button>
|
||||
</li>)}
|
||||
</ul>}
|
||||
</>}
|
||||
{made && <p className="mt-3 text-sm text-ok" role="status">{t("portable.make.done", { name: made })}</p>}
|
||||
{error && <ErrorLine error={error} />}
|
||||
</Card>
|
||||
</div>;
|
||||
}
|
||||
|
||||
// ---- History ------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function HistoryDialog({ character, onClose }: { character: CharacterView; onClose: () => void }) {
|
||||
const t = useT();
|
||||
const [list, setList] = useState<HistoryEntry[] | null>(null);
|
||||
const [error, setError] = useState<PortableError | null>(null);
|
||||
useEffect(() => { void portable.history(character.id).then(setList).catch((e) => setError(asPortableError(e))); }, [character.id]);
|
||||
return <div className="fixed inset-0 z-40 flex items-center justify-center bg-black/60 p-6" role="dialog" aria-modal="true" aria-labelledby="hist-title">
|
||||
<Card className="max-h-full w-full max-w-xl overflow-y-auto p-6">
|
||||
<div className="flex items-start justify-between">
|
||||
<h2 id="hist-title" className="text-lg font-semibold">{t("portable.history.title", { name: character.name })}</h2>
|
||||
<button onClick={onClose} aria-label={t("portable.close")} className="cursor-pointer text-muted hover:text-ink"><X className="h-5 w-5" /></button>
|
||||
</div>
|
||||
{!list && !error && <Loader2 className="mt-4 h-4 w-4 animate-spin" aria-hidden />}
|
||||
{list && <ul className="mt-4 divide-y divide-line text-sm">
|
||||
{list.map((h) => <li key={h.revision} className="flex gap-3 py-2"><span className="w-12 shrink-0 font-medium">#{h.revision}</span><span className="flex-1 text-muted">{when(h.at)} · {t(`portable.history.${h.kind}` as Key, { realm: h.source_realm })}</span></li>)}
|
||||
</ul>}
|
||||
{error && <ErrorLine error={error} />}
|
||||
</Card>
|
||||
</div>;
|
||||
}
|
||||
|
||||
// ---- the page ----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
export function PortablePage({ onOpenSettings }: { onOpenSettings?: () => void }) {
|
||||
const t = useT();
|
||||
const { state, refresh } = usePortable();
|
||||
const [playing, setPlaying] = useState<{ character: CharacterView; realm: string } | null>(null);
|
||||
const [history, setHistory] = useState<CharacterView | null>(null);
|
||||
const [making, setMaking] = useState(false);
|
||||
const [error, setError] = useState<PortableError | null>(null);
|
||||
const [copied, setCopied] = useState(false);
|
||||
const realms = state?.realms ?? [];
|
||||
const characters = state?.characters ?? [];
|
||||
const usable = useMemo(() => realms, [realms]);
|
||||
|
||||
async function addRealm() {
|
||||
setError(null);
|
||||
try {
|
||||
const file = await open({ multiple: false, filters: [{ name: t("portable.realm.fileType"), extensions: ["json"] }] });
|
||||
if (typeof file === "string") { await portable.addRealm(file); await refresh(); }
|
||||
} catch (e) { setError(asPortableError(e)); }
|
||||
}
|
||||
async function removeRealm(id: string) {
|
||||
setError(null);
|
||||
try { await portable.removeRealm(id); await refresh(); } catch (e) { setError(asPortableError(e)); }
|
||||
}
|
||||
async function copyDiagnostics() {
|
||||
try {
|
||||
const json = JSON.stringify(await portable.diagnostics(), null, 2);
|
||||
await navigator.clipboard.writeText(json);
|
||||
setCopied(true); setTimeout(() => setCopied(false), 2500);
|
||||
} catch (e) { setError(asPortableError(e)); }
|
||||
}
|
||||
|
||||
return <div>
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-2xl font-semibold">{t("portable.title")}</h1>
|
||||
<div className="flex gap-2">
|
||||
<Button size="sm" onClick={() => setMaking(true)} disabled={!realms.some((r) => r.database_ok)}><Plus className="h-4 w-4" aria-hidden />{t("portable.make.button")}</Button>
|
||||
</div>
|
||||
</div>
|
||||
<p className="mt-2 text-muted">{t("portable.intro")}</p>
|
||||
{state && !state.runtime.running && <p className="mt-3 text-sm text-warn" role="status">{t("portable.runtime.stopped")}</p>}
|
||||
{error && <ErrorLine error={error} />}
|
||||
|
||||
<h2 className="mt-8 text-lg font-semibold">{t("portable.realms.title")}</h2>
|
||||
<Card className="mt-3 divide-y divide-line">
|
||||
{usable.length === 0 && <p className="p-5 text-sm text-muted">{t("portable.realms.none")}</p>}
|
||||
{usable.map((r) => <div key={r.id} className="flex items-center gap-3 px-5 py-3" data-realm={r.id}>
|
||||
<span className={cn("h-2.5 w-2.5 rounded-full", r.online ? "bg-ok" : r.database_ok ? "bg-warn" : "bg-bad")} aria-hidden />
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="truncate font-medium">{r.name}</p>
|
||||
<p className="text-xs text-muted">
|
||||
{t(r.online ? "portable.realm.online" : r.database_ok ? "portable.realm.stopped" : "portable.realm.unreachable")}
|
||||
{r.level_cap ? ` · ${t("portable.realm.cap", { cap: r.level_cap })}` : ""}
|
||||
{r.portable === "setup" ? ` · ${t("portable.realm.setup")}` : ""}
|
||||
{` · ${t(r.kind === "installed" ? "portable.realm.installed" : "portable.realm.prepared")}`}
|
||||
</p>
|
||||
</div>
|
||||
{r.kind === "prepared" && <Button size="sm" variant="ghost" onClick={() => void removeRealm(r.id)} aria-label={t("portable.realm.remove")}><Trash2 className="h-4 w-4" aria-hidden /></Button>}
|
||||
</div>)}
|
||||
<div className="px-5 py-3"><Button size="sm" variant="ghost" onClick={() => void addRealm()}><Plus className="h-4 w-4" aria-hidden />{t("portable.realm.add")}</Button></div>
|
||||
</Card>
|
||||
|
||||
<h2 className="mt-8 text-lg font-semibold">{t("portable.characters.title")}</h2>
|
||||
{characters.length === 0 && <Card className="mt-3 p-5 text-sm text-muted">{t("portable.characters.none")}</Card>}
|
||||
<div className="mt-3 space-y-4">
|
||||
{characters.map((c) => <Card key={c.id} className="p-5" data-character={c.name}>
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<Swords className="h-5 w-5 text-gold" aria-hidden />
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-lg font-semibold">{c.name}</p>
|
||||
<p className="text-sm text-muted">{c.class_name} · {t("portable.level", { level: c.level })} · {t("portable.revision", { n: c.revision })}</p>
|
||||
<p className="text-xs text-muted">{t("portable.lastSync", { when: when(c.updated_at) })}{c.active_realm ? ` · ${t("portable.activeOn", { realm: c.active_realm })}` : ""}</p>
|
||||
</div>
|
||||
<StatusChip status={c.status} />
|
||||
</div>
|
||||
{c.copies.length > 0 && <ul className="mt-4 divide-y divide-line rounded-md border border-line text-sm">
|
||||
{c.copies.map((x) => <li key={x.realm_id} className="flex flex-wrap items-center gap-3 px-3 py-2">
|
||||
<span className="min-w-0 flex-1 truncate">{x.realm_name}</span>
|
||||
{x.projected_level && <span className="text-xs text-muted">{t("portable.copy.projected", { level: x.projected_level })}</span>}
|
||||
<span className="text-xs text-muted">{t("portable.copy.synced", { n: x.synced_revision })}</span>
|
||||
<StatusChip status={x.status} degraded={x.degraded} />
|
||||
</li>)}
|
||||
</ul>}
|
||||
<div className="mt-4 flex flex-wrap gap-2">
|
||||
<Button variant="primary" size="sm" disabled={realms.length === 0 || LIVE.includes(c.status) && c.status !== "waiting_login"} onClick={() => setPlaying({ character: c, realm: c.copies.find((x) => x.status === "waiting_login")?.realm_id ?? c.copies[0]?.realm_id ?? realms[0]!.id })}>{t("portable.play.button")}</Button>
|
||||
<Button size="sm" variant="ghost" onClick={() => setHistory(c)}><History className="h-4 w-4" aria-hidden />{t("portable.history.button")}</Button>
|
||||
</div>
|
||||
</Card>)}
|
||||
</div>
|
||||
|
||||
<h2 className="mt-8 text-lg font-semibold">{t("portable.diag.title")}</h2>
|
||||
<Card className="mt-3 p-5">
|
||||
<p className="text-sm text-muted">{t("portable.diag.text")}</p>
|
||||
{state && state.runtime.errors.length > 0 && <ul className="mt-3 space-y-1 text-xs text-bad">{state.runtime.errors.slice(-5).map((e, i) => <li key={i} className="selectable">{when(e.at)} · {e.message}</li>)}</ul>}
|
||||
<div className="mt-3 flex items-center gap-3"><Button size="sm" onClick={() => void copyDiagnostics()}>{t("portable.diag.copy")}</Button>{copied && <span className="text-sm text-ok" role="status">{t("portable.diag.copied")}</span>}</div>
|
||||
</Card>
|
||||
|
||||
{playing && <PlayDialog character={playing.character} realms={realms} initial={playing.realm} onClose={() => setPlaying(null)} onChanged={() => void refresh()} />}
|
||||
{making && <MakeDialog realms={realms} onClose={() => setMaking(false)} onChanged={() => void refresh()} />}
|
||||
{history && <HistoryDialog character={history} onClose={() => setHistory(null)} />}
|
||||
{onOpenSettings && null}
|
||||
</div>;
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Gauge, Settings } from "lucide-react";
|
||||
import { Gauge, Settings, Swords } from "lucide-react";
|
||||
import { api, asUiError, REMOTE_CLIENT_ID } from "@/lib/api";
|
||||
import { checkClient, startClientPolling, useClientStatus } from "@/lib/clientUpdate";
|
||||
import { ClientCard } from "@/screens/ClientCard";
|
||||
import { ClientDialog, type ClientDialogMode } from "@/screens/ClientDialog";
|
||||
import { AboutCard } from "@/screens/AboutCard";
|
||||
import { PortablePage } from "@/screens/PortablePage";
|
||||
import { LanguagePicker } from "@/components/LanguagePicker";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card } from "@/components/ui/card";
|
||||
@@ -15,7 +16,7 @@ import logo from "@/assets/logo.png";
|
||||
export function RemoteClient({ onHost }: { onHost: () => void }) {
|
||||
const t = useT();
|
||||
const human = useHuman();
|
||||
const [page, setPage] = useState<"overview" | "settings">("overview");
|
||||
const [page, setPage] = useState<"overview" | "characters" | "settings">("overview");
|
||||
const [host, setHost] = useState("");
|
||||
const [savedHost, setSavedHost] = useState("");
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -56,14 +57,14 @@ export function RemoteClient({ onHost }: { onHost: () => void }) {
|
||||
<nav className="flex w-60 shrink-0 flex-col border-r border-line bg-[#0b0c0e] p-3" aria-label={t("nav.main")}>
|
||||
<div className="flex items-center gap-2 px-3 pb-4 pt-2 text-sm font-semibold tracking-wide text-gold"><img src={logo} alt="" className="h-7 w-7" />{t("app.name")}</div>
|
||||
<ul className="flex flex-col gap-0.5">
|
||||
{(["overview", "settings"] as const).map(id => { const Icon = id === "overview" ? Gauge : Settings; return <li key={id}>
|
||||
<button onClick={() => setPage(id)} aria-current={page === id ? "page" : undefined} className={cn("flex h-10 w-full cursor-pointer items-center gap-3 rounded-md px-3 text-left text-[15px]", page === id ? "bg-white/[0.07] text-ink" : "text-muted hover:bg-white/5 hover:text-ink")}><Icon className="h-[18px] w-[18px]" aria-hidden />{t(id === "overview" ? "nav.overview" : "nav.settings")}</button>
|
||||
{(["overview", "characters", "settings"] as const).map(id => { const Icon = id === "overview" ? Gauge : id === "characters" ? Swords : Settings; return <li key={id}>
|
||||
<button onClick={() => setPage(id)} aria-current={page === id ? "page" : undefined} className={cn("flex h-10 w-full cursor-pointer items-center gap-3 rounded-md px-3 text-left text-[15px]", page === id ? "bg-white/[0.07] text-ink" : "text-muted hover:bg-white/5 hover:text-ink")}><Icon className="h-[18px] w-[18px]" aria-hidden />{t(id === "overview" ? "nav.overview" : id === "characters" ? "nav.characters" : "nav.settings")}</button>
|
||||
</li>; })}
|
||||
</ul>
|
||||
<div className="mt-auto border-t border-line pt-3"><Button variant="ghost" size="sm" className="w-full justify-start" onClick={onHost}>{t("remote.hostInstead")}</Button></div>
|
||||
</nav>
|
||||
<main className="h-full flex-1 overflow-y-auto px-10 py-8">
|
||||
{page === "settings" ? <><div className="flex items-center justify-between"><h1 className="text-2xl font-semibold">{t("nav.settings")}</h1><LanguagePicker /></div><AboutCard /></> : <>
|
||||
{page === "characters" ? <PortablePage /> : page === "settings" ? <><div className="flex items-center justify-between"><h1 className="text-2xl font-semibold">{t("nav.settings")}</h1><LanguagePicker /></div><AboutCard /></> : <>
|
||||
<div className="flex items-center justify-between"><h1 className="text-2xl font-semibold">{t("welcome.connect.title")}</h1><LanguagePicker /></div>
|
||||
<p className="mt-2 text-muted">{t("remote.intro")}</p>
|
||||
<Card className="mt-6 p-6">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { Archive, Bot, Bug, Gauge, Globe, Puzzle, Server, Settings, Terminal, Users, type LucideIcon } from "lucide-react";
|
||||
import { Archive, Bot, Bug, Gauge, Globe, Puzzle, Server, Settings, Swords, Terminal, Users, type LucideIcon } from "lucide-react";
|
||||
import { api, type ServerSummary } from "@/lib/api";
|
||||
import { useT, type Key } from "@/i18n";
|
||||
import logo from "@/assets/logo.png";
|
||||
@@ -14,11 +14,12 @@ import { FriendsPage } from "@/screens/FriendsPage";
|
||||
import { ReportPage } from "@/screens/ReportPage";
|
||||
import { ModulesPage } from "@/screens/ModulesPage";
|
||||
import { ConsolePage } from "@/screens/ConsolePage";
|
||||
import { PortablePage } from "@/screens/PortablePage";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { startServerUpdatePolling, useServerUpdate } from "@/lib/serverUpdate";
|
||||
import { startClientPolling } from "@/lib/clientUpdate";
|
||||
|
||||
type Page = "overview" | "bots" | "server" | "modules" | "players" | "friends" | "backups" | "console" | "report" | "settings";
|
||||
type Page = "overview" | "bots" | "server" | "modules" | "players" | "characters" | "friends" | "backups" | "console" | "report" | "settings";
|
||||
|
||||
const NAV: { id: Page; label: Key; icon: LucideIcon; question: Key }[] = [
|
||||
{ id: "overview", label: "nav.overview", icon: Gauge, question: "q.overview" },
|
||||
@@ -26,6 +27,7 @@ const NAV: { id: Page; label: Key; icon: LucideIcon; question: Key }[] = [
|
||||
{ id: "server", label: "nav.server", icon: Server, question: "q.server" },
|
||||
{ id: "modules", label: "nav.modules", icon: Puzzle, question: "q.modules" },
|
||||
{ id: "players", label: "nav.players", icon: Users, question: "q.players" },
|
||||
{ id: "characters", label: "nav.characters", icon: Swords, question: "q.characters" },
|
||||
{ id: "friends", label: "nav.friends", icon: Globe, question: "q.friends" },
|
||||
{ id: "backups", label: "nav.backups", icon: Archive, question: "q.backups" },
|
||||
{ id: "console", label: "nav.console", icon: Terminal, question: "q.console" },
|
||||
@@ -140,6 +142,8 @@ export function Shell(props: {
|
||||
<FriendsPage key={server.id} serverId={server.id} />
|
||||
) : page === "settings" ? (
|
||||
<SettingsHome key={server.id} serverId={server.id} />
|
||||
) : page === "characters" ? (
|
||||
<PortablePage key="characters" />
|
||||
) : page === "players" ? (
|
||||
<PlayersPage key={server.id} serverId={server.id} />
|
||||
) : page === "backups" ? (
|
||||
|
||||
Reference in new issue
Block a user