feat: 사령부의 턴 선택기에 고급 모드 적용 (#212)
- 사령부 턴 페이지를 vue3 setup 형태로 변경 - 턴 조작기 함수 중 공용 함수 분리 - 사령부 턴 조작기 코드 범위를 다시 조정 - 사령부 일반 모드, 고급 모드 이원화 - 사령부에서 다른 수뇌의 턴 '복사하기' 제공 Co-authored-by: Hide_D <hided62@gmail.com> Reviewed-on: https://storage.hided.net/gitea/devsam/core/pulls/212 Co-authored-by: hide_d <hided62@gmail.com> Co-committed-by: hide_d <hided62@gmail.com>
This commit is contained in:
@@ -1,18 +1,51 @@
|
||||
import type { TurnObj } from '@/defs';
|
||||
import { ref } from 'vue';
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
|
||||
export class StoredActionsHelper {
|
||||
public readonly recentActions = ref<TurnObj[]>([]);
|
||||
public readonly storedActions = ref(new Map<string, [number[], TurnObj][]>());
|
||||
public readonly clipboard = ref<[number[], TurnObj][] | undefined>(undefined);
|
||||
public readonly activatedCategory = ref<string>("");
|
||||
public readonly isEditMode = ref(false);
|
||||
|
||||
public readonly recentActionsKey: string;
|
||||
public readonly storedActionsKey: string;
|
||||
public readonly clipboardKey: string;
|
||||
public readonly activatedCategoryKey: string;
|
||||
public readonly editModeKey: string;
|
||||
|
||||
constructor(protected serverNick: string, protected type: 'general' | 'nation', protected mapName: string, protected unitSet: string, protected maxRecent = 10) {
|
||||
this.recentActionsKey = `${serverNick}_${mapName}_${unitSet}_${type}RecentActions`;
|
||||
this.storedActionsKey = `${serverNick}_${mapName}_${unitSet}_${type}StoredActions`;
|
||||
const typeKey = `${serverNick}_${mapName}_${unitSet}_${type}`;
|
||||
this.recentActionsKey = `${typeKey}RecentActions`;
|
||||
this.storedActionsKey = `${typeKey}StoredActions`;
|
||||
this.clipboardKey = `${typeKey}Clipboard`;
|
||||
this.activatedCategoryKey = `${typeKey}ActivatedCategory`;
|
||||
this.editModeKey = `${serverNick}_${type}_isEditMode`;
|
||||
|
||||
this.loadRecentActions();
|
||||
this.loadStoredActions();
|
||||
|
||||
const rawClipboard = localStorage.getItem(this.clipboardKey);
|
||||
if (rawClipboard !== null) {
|
||||
this.clipboard.value = JSON.parse(rawClipboard);
|
||||
}
|
||||
watch(this.clipboard, (newValue) => {
|
||||
localStorage.setItem(this.clipboardKey, JSON.stringify(newValue));
|
||||
});
|
||||
|
||||
const rawActivatedCategory = localStorage.getItem(this.activatedCategoryKey);
|
||||
if (rawActivatedCategory !== null) {
|
||||
this.activatedCategory.value = JSON.parse(rawActivatedCategory);
|
||||
}
|
||||
watch(this.activatedCategory, (newValue) => {
|
||||
localStorage.setItem(this.activatedCategoryKey, JSON.stringify(newValue));
|
||||
});
|
||||
|
||||
this.isEditMode.value = localStorage.getItem(this.editModeKey) === '1';
|
||||
watch(this.isEditMode, (newValue) => {
|
||||
localStorage.setItem(this.editModeKey, newValue ? '1' : '0')
|
||||
})
|
||||
}
|
||||
|
||||
loadRecentActions() {
|
||||
|
||||
Reference in New Issue
Block a user