diff --git a/hwe/ts/PartialReservedCommand.vue b/hwe/ts/PartialReservedCommand.vue
index 64a31151..87b7ab7f 100644
--- a/hwe/ts/PartialReservedCommand.vue
+++ b/hwe/ts/PartialReservedCommand.vue
@@ -281,6 +281,7 @@ queryActionHelper.selectTurn(...$event);
anchor=".commandSelectFormAnchor"
ref="commandSelectForm"
@on-close="chooseCommand($event)"
+ v-model:activatedCategory="activatedCategory"
/>
@@ -673,6 +675,7 @@ const storedActionsHelper = new StoredActionsHelper(staticValues.serverNick, 'ge
const recentActions = storedActionsHelper.recentActions;
const storedActions = storedActionsHelper.storedActions;
+const activatedCategory = storedActionsHelper.activatedCategory;
async function eraseSelectedTurnList(releaseSelect = true): Promise {
const result = await reserveCommandDirect([[
@@ -685,10 +688,7 @@ async function eraseSelectedTurnList(releaseSelect = true): Promise {
return result;
}
-
-
-
-const clipboard = ref<[number[], TurnObj][] | undefined>(undefined);
+const clipboard = storedActionsHelper.clipboard;
async function clipboardCut(releaseSelect = true) {
clipboardCopy(false);
diff --git a/hwe/ts/components/CommandSelectForm.vue b/hwe/ts/components/CommandSelectForm.vue
index 4affe6d3..369f6387 100644
--- a/hwe/ts/components/CommandSelectForm.vue
+++ b/hwe/ts/components/CommandSelectForm.vue
@@ -69,9 +69,6 @@ import type { CommandItem } from "@/defs";
import { BButton } from "bootstrap-vue-3";
import { ref, defineProps, defineEmits, defineExpose, type PropType, watch, onMounted } from "vue";
-const chosenCategory = ref("-");
-const chosenSubList = ref([]);
-
interface CategoryDecoration {
name: string,
altName?: string,
@@ -101,9 +98,23 @@ const props = defineProps({
type: Boolean,
required: false,
default: true,
+ },
+ activatedCategory: {
+ type: String,
+ required: false,
+ default: "",
}
})
+const chosenCategory = ref('-');
+const chosenSubList = ref([]);
+
+const categories = new Set(props.commandList.map(({category})=>category));
+
+watch(()=>props.activatedCategory, (newValue)=>{
+ chosenCategory.value = newValue;
+})
+
const showForm = ref(false);
function convCategoryDeco(category: string): CategoryDecoration {
@@ -140,17 +151,25 @@ watch(() => props.commandList, updateCommandList);
updateCommandList(props.commandList);
watch(chosenCategory, (category) => {
- console.log('sel', category);
const itemInfo = commandList.value?.get(category);
if (itemInfo === undefined) {
console.error(`category 없음: ${category}`);
return;
}
chosenSubList.value = itemInfo.values;
+ if(props.activatedCategory !== category){
+ emits('update:activatedCategory', category);
+ }
});
onMounted(() => {
- chosenCategory.value = props.commandList[0].category;
+ if(!categories.has(props.activatedCategory)){
+ chosenCategory.value = props.commandList[0].category;
+ }
+ else{
+ chosenCategory.value = props.activatedCategory;
+ }
+
});
function show(): void {
@@ -171,6 +190,7 @@ function close(category?: string): void {
const emits = defineEmits<{
(event: 'onClose', command?: string): void,
+ (event: 'update:activatedCategory', category: string): void,
}>();
defineExpose({
diff --git a/hwe/ts/util/StoredActionsHelper.ts b/hwe/ts/util/StoredActionsHelper.ts
index 70f3cf87..c91b3ad3 100644
--- a/hwe/ts/util/StoredActionsHelper.ts
+++ b/hwe/ts/util/StoredActionsHelper.ts
@@ -1,18 +1,44 @@
import type { TurnObj } from '@/defs';
-import { ref } from 'vue';
+import { ref, watch } from 'vue';
export class StoredActionsHelper {
public readonly recentActions = ref([]);
public readonly storedActions = ref(new Map());
+ public readonly clipboard = ref<[number[], TurnObj][] | undefined>(undefined);
+ public readonly activatedCategory = ref("");
+
public readonly recentActionsKey: string;
public readonly storedActionsKey: string;
+ public readonly clipboardKey: string;
+ public readonly activatedCategoryKey: 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`;
+ this.clipboardKey = `${serverNick}_${mapName}_${unitSet}_${type}Clipboard`;
+ this.activatedCategoryKey = `${serverNick}_${mapName}_${unitSet}_${type}ActivatedCategory`;
this.loadRecentActions();
this.loadStoredActions();
+
+ const rawClipboard = localStorage.getItem(this.clipboardKey);
+ if(rawClipboard !== null){
+ this.clipboard.value = JSON.parse(rawClipboard);
+ }
+
+ const rawActivatedCategory = localStorage.getItem(this.activatedCategoryKey);
+ if(rawActivatedCategory !== null){
+ this.activatedCategory.value = JSON.parse(rawActivatedCategory);
+ }
+
+ watch(this.clipboard, (newValue)=>{
+ console.log(newValue);
+ localStorage.setItem(this.clipboardKey, JSON.stringify(newValue));
+ });
+
+ watch(this.activatedCategory, (newValue)=>{
+ localStorage.setItem(this.activatedCategoryKey, JSON.stringify(newValue));
+ });
}
loadRecentActions() {