fix(game-ui): 턴 입력기 모드를 서버별로 기억한다
This commit is contained in:
@@ -30,6 +30,7 @@ const props = withDefaults(
|
||||
commandTable: CommandTable | null;
|
||||
loading: boolean;
|
||||
storageKey: string;
|
||||
editModeStorageKey?: string;
|
||||
maxPushTurn?: number;
|
||||
compact?: boolean;
|
||||
mobile?: boolean;
|
||||
@@ -41,6 +42,7 @@ const props = withDefaults(
|
||||
autonomousUntil?: string | null;
|
||||
}>(),
|
||||
{
|
||||
editModeStorageKey: undefined,
|
||||
maxPushTurn: 6,
|
||||
compact: false,
|
||||
mobile: false,
|
||||
@@ -82,20 +84,20 @@ const editorElement = ref<HTMLElement | null>(null);
|
||||
const pickerElement = ref<HTMLElement | null>(null);
|
||||
const collapsedRowCount = 15;
|
||||
|
||||
const loadStorage = (key: string) => {
|
||||
storage.value = new CommandStorage(key);
|
||||
const loadStorage = (key: string, editModeKey: string | undefined) => {
|
||||
storage.value = new CommandStorage(key, { editModeKey });
|
||||
editMode.value = storage.value.editMode;
|
||||
activeCategory.value = storage.value.activeCategory;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadStorage(props.storageKey);
|
||||
loadStorage(props.storageKey, props.editModeStorageKey);
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.storageKey,
|
||||
(key, previousKey) => {
|
||||
if (key !== previousKey) loadStorage(key);
|
||||
() => [props.storageKey, props.editModeStorageKey] as const,
|
||||
([key, editModeKey], [previousKey, previousEditModeKey]) => {
|
||||
if (key !== previousKey || editModeKey !== previousEditModeKey) loadStorage(key, editModeKey);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -95,6 +95,18 @@ export const moveQueueRange = (
|
||||
return next.map((entry, index) => ({ turnList: [index], ...entry }));
|
||||
};
|
||||
|
||||
export const generalTurnEditorModeStorageKey = (profile: string | undefined, appBasePath: string): string => {
|
||||
const runtimeProfile = profile?.trim().split(':', 1)[0];
|
||||
const basePathProfile = appBasePath.split('/').find((segment) => segment.length > 0);
|
||||
const profileId = runtimeProfile || basePathProfile || 'default';
|
||||
return `core2026:profile:${encodeURIComponent(profileId)}:general-turn-editor`;
|
||||
};
|
||||
|
||||
interface CommandStorageOptions {
|
||||
maxRecent?: number;
|
||||
editModeKey?: string;
|
||||
}
|
||||
|
||||
export class CommandStorage {
|
||||
readonly recent = new Map<string, CommandPatternEntry>();
|
||||
readonly templates = new Map<string, CommandPatternEntry[]>();
|
||||
@@ -102,11 +114,13 @@ export class CommandStorage {
|
||||
editMode = false;
|
||||
activeCategory = '';
|
||||
private readonly key: string;
|
||||
private readonly editModeKey: string;
|
||||
private readonly maxRecent: number;
|
||||
|
||||
constructor(key: string, maxRecent = 10) {
|
||||
constructor(key: string, options: CommandStorageOptions = {}) {
|
||||
this.key = key;
|
||||
this.maxRecent = maxRecent;
|
||||
this.editModeKey = options.editModeKey ?? key;
|
||||
this.maxRecent = options.maxRecent ?? 10;
|
||||
this.load();
|
||||
}
|
||||
|
||||
@@ -126,12 +140,18 @@ export class CommandStorage {
|
||||
this.templates.set(name, entries);
|
||||
}
|
||||
this.clipboard = this.read<CommandPatternEntry[] | undefined>('clipboard', undefined);
|
||||
this.editMode = localStorage.getItem(`${this.key}:editMode`) === '1';
|
||||
const editModeStorageKey = `${this.editModeKey}:editMode`;
|
||||
let storedEditMode = localStorage.getItem(editModeStorageKey);
|
||||
if (storedEditMode === null && this.editModeKey !== this.key) {
|
||||
storedEditMode = localStorage.getItem(`${this.key}:editMode`);
|
||||
if (storedEditMode !== null) localStorage.setItem(editModeStorageKey, storedEditMode);
|
||||
}
|
||||
this.editMode = storedEditMode === '1';
|
||||
this.activeCategory = this.read('category', '');
|
||||
}
|
||||
|
||||
saveState(): void {
|
||||
localStorage.setItem(`${this.key}:editMode`, this.editMode ? '1' : '0');
|
||||
localStorage.setItem(`${this.editModeKey}:editMode`, this.editMode ? '1' : '0');
|
||||
localStorage.setItem(`${this.key}:category`, JSON.stringify(this.activeCategory));
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
import { computed, onUnmounted, ref, watch } from 'vue';
|
||||
import { addMinutes } from 'date-fns';
|
||||
import ReservedCommandEditor from '../command/ReservedCommandEditor.vue';
|
||||
import { generalTurnEditorModeStorageKey } from '../command/commandQueue';
|
||||
import { formatLocalDateTime, formatLocalTimeSeconds } from '../../utils/legacyDateTime';
|
||||
import { projectServerClock, sampleServerClock, type SampledServerClock } from '../../utils/serverClockProjection';
|
||||
import { gameFrontendRuntimeConfig } from '../../config/runtimeConfig';
|
||||
import type {
|
||||
CommandMapData,
|
||||
CommandMapLayout,
|
||||
@@ -38,6 +40,11 @@ const emit = defineEmits<{
|
||||
(event: 'repeat-general-turns', amount: number): void;
|
||||
}>();
|
||||
|
||||
const editModeStorageKey = generalTurnEditorModeStorageKey(
|
||||
gameFrontendRuntimeConfig.profile,
|
||||
gameFrontendRuntimeConfig.appBasePath
|
||||
);
|
||||
|
||||
const labelMap = computed(() => {
|
||||
const result = new Map<string, string>([['휴식', '휴식']]);
|
||||
for (const group of props.commandTable?.general ?? []) {
|
||||
@@ -140,6 +147,7 @@ onUnmounted(() => {
|
||||
:command-table="props.commandTable"
|
||||
:loading="props.loading"
|
||||
:storage-key="props.storageKey ?? `core2026:general:${props.general?.id ?? 0}`"
|
||||
:edit-mode-storage-key="editModeStorageKey"
|
||||
:current-time="currentServerTime"
|
||||
:map-data="props.mapData"
|
||||
:map-layout="props.mapLayout"
|
||||
|
||||
Reference in New Issue
Block a user