feat(WIP): 턴 선택기를 multiselect에서 modal form으로 변경
This commit is contained in:
+6
-2
@@ -203,9 +203,13 @@ $nations = $history['nations'];
|
|||||||
<td><?= banner() ?> </td>
|
<td><?= banner() ?> </td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
<?= WebUtil::printStaticValues([
|
||||||
|
'staticValues' => [
|
||||||
|
'serverNick' => DB::prefix(),
|
||||||
|
'serverID' => UniqueConst::$serverID,
|
||||||
|
]
|
||||||
|
])?>
|
||||||
<script>
|
<script>
|
||||||
window.serverNick = '<?= DB::prefix() ?>';
|
|
||||||
window.serverID = '<?= UniqueConst::$serverID ?>';
|
|
||||||
<?php if($isCurrent): ?>
|
<?php if($isCurrent): ?>
|
||||||
reloadWorldMap({
|
reloadWorldMap({
|
||||||
showMe: false,
|
showMe: false,
|
||||||
|
|||||||
+6
-2
@@ -98,9 +98,13 @@ $neutralStateCharMap = [
|
|||||||
<?= WebUtil::printCSS('css/map.css') ?>
|
<?= WebUtil::printCSS('css/map.css') ?>
|
||||||
<?= WebUtil::printCSS('css/history.css') ?>
|
<?= WebUtil::printCSS('css/history.css') ?>
|
||||||
<?= WebUtil::printDist('ts', ['common', 'map']) ?>
|
<?= WebUtil::printDist('ts', ['common', 'map']) ?>
|
||||||
|
<?= WebUtil::printStaticValues([
|
||||||
|
'staticValues' => [
|
||||||
|
'serverNick' => DB::prefix(),
|
||||||
|
'serverID' => UniqueConst::$serverID
|
||||||
|
],
|
||||||
|
]) ?>
|
||||||
<script>
|
<script>
|
||||||
window.serverNick = '<?= DB::prefix() ?>';
|
|
||||||
window.serverID = '<?= UniqueConst::$serverID ?>';
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
reloadWorldMap({
|
reloadWorldMap({
|
||||||
|
|||||||
+16
-3
@@ -126,19 +126,32 @@ if (!$otherTextInfo) {
|
|||||||
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css" />
|
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css" />
|
||||||
<?= WebUtil::printCSS('css/map.css') ?>
|
<?= WebUtil::printCSS('css/map.css') ?>
|
||||||
<?= WebUtil::printStaticValues([
|
<?= WebUtil::printStaticValues([
|
||||||
|
//deprecated, staticValues를 이용할 것
|
||||||
'serverName' => $serverName,
|
'serverName' => $serverName,
|
||||||
'serverCnt' => $serverCnt,
|
'serverCnt' => $serverCnt,
|
||||||
'serverNick' => DB::prefix(),
|
'serverNick' => DB::prefix(),
|
||||||
'serverID' => UniqueConst::$serverID,
|
'serverID' => UniqueConst::$serverID,
|
||||||
'maxTurn' => GameConst::$maxTurn,
|
'maxTurn' => GameConst::$maxTurn,
|
||||||
'maxPushTurn' => 12,
|
'maxPushTurn' => 12,
|
||||||
'commandList' => getCommandTable($generalObj),
|
|
||||||
'serverNow' => TimeUtil::now(false),
|
'serverNow' => TimeUtil::now(false),
|
||||||
'baseColor2' => GameConst::$basecolor2,
|
|
||||||
'lastExecuted' => $gameStor->turntime,
|
'lastExecuted' => $gameStor->turntime,
|
||||||
'isLocked' => $plock,
|
'isLocked' => $plock,
|
||||||
'isTournamentActive' => $isTournamentActive,
|
'isTournamentActive' => $isTournamentActive,
|
||||||
'isBettingActive' => $isBettingActive
|
'isBettingActive' => $isBettingActive,
|
||||||
|
'staticValues' => [
|
||||||
|
'serverName' => $serverName,
|
||||||
|
'serverCnt' => $serverCnt,
|
||||||
|
'serverNick' => DB::prefix(),
|
||||||
|
'serverID' => UniqueConst::$serverID,
|
||||||
|
'maxTurn' => GameConst::$maxTurn,
|
||||||
|
'maxPushTurn' => 12,
|
||||||
|
'commandList' => getCommandTable($generalObj),
|
||||||
|
'serverNow' => TimeUtil::now(false),
|
||||||
|
'lastExecuted' => $gameStor->turntime,
|
||||||
|
'isLocked' => $plock,
|
||||||
|
'isTournamentActive' => $isTournamentActive,
|
||||||
|
'isBettingActive' => $isBettingActive
|
||||||
|
]
|
||||||
]) ?>
|
]) ?>
|
||||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
+4
-2
@@ -16,8 +16,10 @@ include "func.php";
|
|||||||
<title>최근 지도</title>
|
<title>최근 지도</title>
|
||||||
<?= WebUtil::printJS('../d_shared/common_path.js') ?>
|
<?= WebUtil::printJS('../d_shared/common_path.js') ?>
|
||||||
<?= WebUtil::printStaticValues([
|
<?= WebUtil::printStaticValues([
|
||||||
'serverNick' => DB::prefix(),
|
'staticValues' => [
|
||||||
'serverID' => UniqueConst::$serverID
|
'serverNick' => DB::prefix(),
|
||||||
|
'serverID' => UniqueConst::$serverID
|
||||||
|
],
|
||||||
]) ?>
|
]) ?>
|
||||||
<?= WebUtil::printJS('d_shared/base_map.js') ?>
|
<?= WebUtil::printJS('d_shared/base_map.js') ?>
|
||||||
|
|
||||||
|
|||||||
+338
-426
@@ -6,26 +6,26 @@
|
|||||||
|
|
||||||
<div class="row gx-1">
|
<div class="row gx-1">
|
||||||
<div class="col d-grid">
|
<div class="col d-grid">
|
||||||
<b-dropdown left text="턴 선택">
|
<BDropdown left text="턴 선택">
|
||||||
<b-dropdown-item @click="selectTurn()">해제</b-dropdown-item>
|
<BDropdownItem @click="selectTurn()">해제</BDropdownItem>
|
||||||
<b-dropdown-item @click="selectAll(true)">모든턴</b-dropdown-item>
|
<BDropdownItem @click="selectAll(true)">모든턴</BDropdownItem>
|
||||||
<b-dropdown-item @click="selectStep(0, 2)">홀수턴</b-dropdown-item>
|
<BDropdownItem @click="selectStep(0, 2)">홀수턴</BDropdownItem>
|
||||||
<b-dropdown-item @click="selectStep(1, 2)">짝수턴</b-dropdown-item>
|
<BDropdownItem @click="selectStep(1, 2)">짝수턴</BDropdownItem>
|
||||||
<b-dropdown-divider></b-dropdown-divider>
|
<BDropdownDivider></BDropdownDivider>
|
||||||
|
|
||||||
<b-dropdown-text v-for="spanIdx in [3, 4, 5, 6, 7]" :key="spanIdx">
|
<BDropdownText v-for="spanIdx in [3, 4, 5, 6, 7]" :key="spanIdx">
|
||||||
{{ spanIdx }}턴 간격<br />
|
{{ spanIdx }}턴 간격
|
||||||
<b-button-group>
|
<br />
|
||||||
<b-button
|
<BButtonGroup>
|
||||||
|
<BButton
|
||||||
class="ignoreMe"
|
class="ignoreMe"
|
||||||
v-for="beginIdx in spanIdx"
|
v-for="beginIdx in spanIdx"
|
||||||
:key="beginIdx"
|
:key="beginIdx"
|
||||||
@click="selectStep(beginIdx - 1, spanIdx)"
|
@click="selectStep(beginIdx - 1, spanIdx)"
|
||||||
>{{ beginIdx }}</b-button
|
>{{ beginIdx }}</BButton>
|
||||||
>
|
</BButtonGroup>
|
||||||
</b-button-group>
|
</BDropdownText>
|
||||||
</b-dropdown-text>
|
</BDropdown>
|
||||||
</b-dropdown>
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="col alert alert-primary m-0 p-0"
|
class="col alert alert-primary m-0 p-0"
|
||||||
@@ -35,18 +35,15 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
"
|
"
|
||||||
>
|
>{{ formatTime(serverNow, "HH:mm:ss") }}</div>
|
||||||
{{ serverNow }}
|
|
||||||
</div>
|
|
||||||
<div class="col d-grid">
|
<div class="col d-grid">
|
||||||
<b-dropdown right text="반복">
|
<BDropdown right text="반복">
|
||||||
<b-dropdown-item
|
<BDropdownItem
|
||||||
v-for="turnIdx in maxPushTurn"
|
v-for="turnIdx in maxPushTurn"
|
||||||
:key="turnIdx"
|
:key="turnIdx"
|
||||||
@click="repeatGeneralCommand(turnIdx)"
|
@click="repeatGeneralCommand(turnIdx)"
|
||||||
>{{ turnIdx }}턴
|
>{{ turnIdx }}턴</BDropdownItem>
|
||||||
</b-dropdown-item>
|
</BDropdown>
|
||||||
</b-dropdown>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -56,8 +53,8 @@
|
|||||||
attribute="turnIdx"
|
attribute="turnIdx"
|
||||||
@dragStart="isDragToggle = true"
|
@dragStart="isDragToggle = true"
|
||||||
@dragDone="
|
@dragDone="
|
||||||
isDragToggle = false;
|
isDragToggle = false;
|
||||||
toggleTurn(...$event);
|
toggleTurn(...$event);
|
||||||
"
|
"
|
||||||
v-slot="{ selected }"
|
v-slot="{ selected }"
|
||||||
>
|
>
|
||||||
@@ -70,18 +67,17 @@
|
|||||||
:key="turnIdx"
|
:key="turnIdx"
|
||||||
class="idx_pad center d-grid"
|
class="idx_pad center d-grid"
|
||||||
>
|
>
|
||||||
<b-button
|
<BButton
|
||||||
size="sm"
|
size="sm"
|
||||||
:variant="
|
:variant="
|
||||||
(isDragToggle && selected.has(`${turnIdx}`))?'light':
|
(isDragToggle && selected.has(`${turnIdx}`)) ? 'light' :
|
||||||
turnList.has(turnIdx)
|
turnList.has(turnIdx)
|
||||||
? 'info'
|
? 'info'
|
||||||
: turnList.size == 0 && prevTurnList.has(turnIdx)
|
: turnList.size == 0 && prevTurnList.has(turnIdx)
|
||||||
? 'success'
|
? 'success'
|
||||||
: 'primary'
|
: 'primary'
|
||||||
"
|
"
|
||||||
>{{ turnIdx + 1 }}</b-button
|
>{{ turnIdx + 1 }}</BButton>
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
</DragSelect>
|
</DragSelect>
|
||||||
<DragSelect
|
<DragSelect
|
||||||
@@ -89,8 +85,8 @@
|
|||||||
attribute="turnIdx"
|
attribute="turnIdx"
|
||||||
@dragStart="isDragSingle = true"
|
@dragStart="isDragSingle = true"
|
||||||
@dragDone="
|
@dragDone="
|
||||||
isDragSingle = false;
|
isDragSingle = false;
|
||||||
selectTurn(...$event);
|
selectTurn(...$event);
|
||||||
"
|
"
|
||||||
v-slot="{ selected }"
|
v-slot="{ selected }"
|
||||||
>
|
>
|
||||||
@@ -131,9 +127,7 @@
|
|||||||
whiteSpace: 'nowrap',
|
whiteSpace: 'nowrap',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
}"
|
}"
|
||||||
>
|
>{{ turnObj.time }}</div>
|
||||||
{{ turnObj.time }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div :style="rowGridStyle">
|
<div :style="rowGridStyle">
|
||||||
<div
|
<div
|
||||||
@@ -157,130 +151,73 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row gx-1">
|
<div class="row gx-1">
|
||||||
<div class="col d-grid">
|
<div class="col d-grid">
|
||||||
<b-dropdown right split text="당기기" @click="pullGeneralCommandSingle">
|
<BDropdown right split text="당기기" @click="pullGeneralCommandSingle">
|
||||||
<b-dropdown-item
|
<BDropdownItem
|
||||||
v-for="turnIdx in maxPushTurn"
|
v-for="turnIdx in maxPushTurn"
|
||||||
:key="turnIdx"
|
:key="turnIdx"
|
||||||
@click="pushGeneralCommand(-turnIdx)"
|
@click="pushGeneralCommand(-turnIdx)"
|
||||||
>{{ turnIdx }}턴
|
>{{ turnIdx }}턴</BDropdownItem>
|
||||||
</b-dropdown-item>
|
</BDropdown>
|
||||||
</b-dropdown>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col d-grid">
|
<div class="col d-grid">
|
||||||
<b-dropdown right split text="미루기" @click="pushGeneralCommandSingle">
|
<BDropdown right split text="미루기" @click="pushGeneralCommandSingle">
|
||||||
<b-dropdown-item
|
<BDropdownItem
|
||||||
v-for="turnIdx in maxPushTurn"
|
v-for="turnIdx in maxPushTurn"
|
||||||
:key="turnIdx"
|
:key="turnIdx"
|
||||||
@click="pushGeneralCommand(turnIdx)"
|
@click="pushGeneralCommand(turnIdx)"
|
||||||
>{{ turnIdx }}턴
|
>{{ turnIdx }}턴</BDropdownItem>
|
||||||
</b-dropdown-item>
|
</BDropdown>
|
||||||
</b-dropdown>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col d-grid">
|
<div class="col d-grid">
|
||||||
<b-button @click="toggleViewMaxTurn">{{
|
<BButton @click="toggleViewMaxTurn">
|
||||||
flippedMaxTurn == viewMaxTurn ? "펼치기" : "접기"
|
{{
|
||||||
}}</b-button>
|
flippedMaxTurn == viewMaxTurn ? "펼치기" : "접기"
|
||||||
|
}}
|
||||||
|
</BButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row gx-0">
|
<div class="row gx-0">
|
||||||
<div class="col-2 d-grid">
|
<div class="col-2 d-grid"></div>
|
||||||
<b-button
|
|
||||||
:pressed="searchModeOn"
|
|
||||||
@click="toggleSearchCommand()"
|
|
||||||
:variant="searchModeOn ? 'info' : 'primary'"
|
|
||||||
v-b-tooltip.hover
|
|
||||||
title="검색 기능을 활성화합니다."
|
|
||||||
><i class="bi bi-search"></i
|
|
||||||
></b-button>
|
|
||||||
</div>
|
|
||||||
<div class="col-7">
|
<div class="col-7">
|
||||||
<v-multiselect
|
<BButton @click="commandSelectForm?.show()">{{ selectedCommand.title }}</BButton>
|
||||||
v-model="selectedCommand"
|
|
||||||
:allow-empty="false"
|
|
||||||
:options="commandList"
|
|
||||||
:group-select="false"
|
|
||||||
group-values="values"
|
|
||||||
group-label="category"
|
|
||||||
label="searchText"
|
|
||||||
track-by="value"
|
|
||||||
open-direction="top"
|
|
||||||
:show-labels="false"
|
|
||||||
selectLabel="선택(엔터)"
|
|
||||||
selectGroupLabel=""
|
|
||||||
selectedLabel="선택됨"
|
|
||||||
deselectLabel="해제(엔터)"
|
|
||||||
deselectGroupLabel=""
|
|
||||||
placeholder="턴 선택"
|
|
||||||
:maxHeight="400"
|
|
||||||
:searchable="searchModeOn"
|
|
||||||
>
|
|
||||||
<template v-slot:noResult>검색 결과가 없습니다.</template>
|
|
||||||
<template v-slot:option="props"
|
|
||||||
><!--FIXME: 카테고리-->
|
|
||||||
<template v-if="props.option.title">
|
|
||||||
<span
|
|
||||||
class="compensatePositive"
|
|
||||||
v-if="props.option.compensation > 0"
|
|
||||||
>▲</span
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="compensateNegative"
|
|
||||||
v-else-if="props.option.compensation < 0"
|
|
||||||
>▼</span
|
|
||||||
>
|
|
||||||
<span class="compensateNeutral" v-else></span>
|
|
||||||
<span :class="[props.option.possible ? '' : 'commandImpossible']">
|
|
||||||
{{ props.option.title }}
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="props.option.category">
|
|
||||||
{{ props.option.category }}
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
<template v-slot:singleLabel="props">
|
|
||||||
{{ props.option.simpleName }}
|
|
||||||
</template>
|
|
||||||
</v-multiselect>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-3 d-grid">
|
<div class="col-3 d-grid">
|
||||||
<b-button @click="reserveCommand()" variant="primary">실행</b-button>
|
<BButton @click="reserveCommand()" variant="primary">실행</BButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<CommandSelectForm :commandList="commandList" ref="commandSelectForm" @on-close="chooseCommand($event)" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
declare const staticValues: {
|
||||||
|
maxTurn: number,
|
||||||
|
maxPushTurn: number,
|
||||||
|
commandList: {
|
||||||
|
category: string;
|
||||||
|
values: CommandItem[];
|
||||||
|
}[],
|
||||||
|
serverNow: string,
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
import addMilliseconds from "date-fns/esm/addMilliseconds";
|
import addMilliseconds from "date-fns/esm/addMilliseconds";
|
||||||
import addMinutes from "date-fns/esm/addMinutes";
|
import addMinutes from "date-fns/esm/addMinutes";
|
||||||
import { isString, range } from "lodash";
|
import { isString, range } from "lodash";
|
||||||
import { stringifyUrl } from "query-string";
|
import { stringifyUrl } from "query-string";
|
||||||
import { defineComponent, ref, watch } from "vue";
|
import { onMounted, ref, watch } from "vue";
|
||||||
import { formatTime } from "@util/formatTime";
|
import { formatTime } from "@util/formatTime";
|
||||||
import { joinYearMonth } from "@util/joinYearMonth";
|
import { joinYearMonth } from "@util/joinYearMonth";
|
||||||
import { mb_strwidth } from "@util/mb_strwidth";
|
import { mb_strwidth } from "@util/mb_strwidth";
|
||||||
import { parseTime } from "@util/parseTime";
|
import { parseTime } from "@util/parseTime";
|
||||||
import { parseYearMonth } from "@util/parseYearMonth";
|
import { parseYearMonth } from "@util/parseYearMonth";
|
||||||
import { convertSearch초성 } from "./util/convertSearch초성";
|
|
||||||
import DragSelect from "@/components/DragSelect.vue";
|
import DragSelect from "@/components/DragSelect.vue";
|
||||||
import { SammoAPI } from "./SammoAPI";
|
import { SammoAPI } from "./SammoAPI";
|
||||||
|
import type { CommandItem } from "@/defs";
|
||||||
|
import CommandSelectForm from "@/components/CommandSelectForm.vue";
|
||||||
|
import { BButton, BButtonGroup, BDropdownItem, BDropdown, BDropdownText, BDropdownDivider } from "bootstrap-vue-3";
|
||||||
|
|
||||||
type commandItem = {
|
|
||||||
value: string;
|
|
||||||
title: string;
|
|
||||||
compensation: number;
|
|
||||||
simpleName: string;
|
|
||||||
possible: boolean;
|
|
||||||
reqArg: boolean;
|
|
||||||
searchText?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
declare const maxTurn: number;
|
|
||||||
declare const maxPushTurn: number;
|
|
||||||
declare const commandList: {
|
|
||||||
category: string;
|
|
||||||
values: commandItem[];
|
|
||||||
}[];
|
|
||||||
declare const serverNow: string;
|
|
||||||
type TurnObj = {
|
type TurnObj = {
|
||||||
action: string;
|
action: string;
|
||||||
brief: string;
|
brief: string;
|
||||||
@@ -306,7 +243,21 @@ type ReservedCommandResponse = {
|
|||||||
autorun_limit: null | number;
|
autorun_limit: null | number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const {
|
||||||
|
maxTurn,
|
||||||
|
maxPushTurn,
|
||||||
|
commandList,
|
||||||
|
} = staticValues;
|
||||||
|
|
||||||
|
|
||||||
const listReqArgCommand = new Set<string>();
|
const listReqArgCommand = new Set<string>();
|
||||||
|
const serverNow = ref(parseTime(staticValues.serverNow));
|
||||||
|
const clientNow = ref(new Date());
|
||||||
|
const timeDiff = ref(serverNow.value.getTime() - clientNow.value.getTime());
|
||||||
|
const selectedCommand = ref(staticValues.commandList[0].values[0]);
|
||||||
|
const commandSelectForm = ref<InstanceType<typeof CommandSelectForm> | null>(null);
|
||||||
|
|
||||||
for (const commandCategories of commandList) {
|
for (const commandCategories of commandList) {
|
||||||
if (!commandCategories.values) {
|
if (!commandCategories.values) {
|
||||||
continue;
|
continue;
|
||||||
@@ -336,307 +287,268 @@ function isDropdownChildren(e?: Event): boolean {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchModeKey = `sammo_searchModeOn`;
|
|
||||||
|
|
||||||
export default defineComponent({
|
setTimeout(() => {
|
||||||
name: "PartialReservedCommand",
|
updateNow();
|
||||||
components: {
|
}, 1000 - serverNow.value.getMilliseconds());
|
||||||
DragSelect,
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
updateNow() {
|
|
||||||
const serverNow = addMilliseconds(new Date(), this.timeDiff);
|
|
||||||
this.serverNow = formatTime(serverNow, "HH:mm:ss");
|
|
||||||
setTimeout(() => {
|
|
||||||
this.updateNow();
|
|
||||||
}, 1000 - serverNow.getMilliseconds());
|
|
||||||
},
|
|
||||||
toggleTurn(...turnList: number[] | string[]) {
|
|
||||||
for (let turnIdx of turnList) {
|
|
||||||
if (isString(turnIdx)) {
|
|
||||||
turnIdx = parseInt(turnIdx);
|
|
||||||
}
|
|
||||||
if (this.turnList.has(turnIdx)) {
|
|
||||||
this.turnList.delete(turnIdx);
|
|
||||||
} else {
|
|
||||||
this.turnList.add(turnIdx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
selectTurn(...turnList: number[] | string[]) {
|
|
||||||
this.turnList.clear();
|
|
||||||
for (const turnIdx of turnList) {
|
|
||||||
if (isString(turnIdx)) {
|
|
||||||
this.turnList.add(parseInt(turnIdx));
|
|
||||||
} else {
|
|
||||||
this.turnList.add(turnIdx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
selectAll(e: Event | true) {
|
|
||||||
//NOTE: split 구현에 버그가 있어서, 수동으로 구분해야함
|
|
||||||
if (e !== true && isDropdownChildren(e)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.turnList.size * 3 > this.maxTurn) {
|
|
||||||
this.turnList.clear();
|
|
||||||
} else {
|
|
||||||
for (let i = 0; i < this.maxTurn; i++) {
|
|
||||||
this.turnList.add(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
selectStep(begin: number, step: number) {
|
|
||||||
this.turnList.clear();
|
|
||||||
for (const idx of range(0, maxTurn)) {
|
|
||||||
if ((idx - begin) % step == 0) {
|
|
||||||
this.turnList.add(idx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
toggleViewMaxTurn() {
|
|
||||||
if (this.viewMaxTurn == this.flippedMaxTurn) {
|
|
||||||
this.viewMaxTurn = this.maxTurn;
|
|
||||||
} else {
|
|
||||||
this.viewMaxTurn = this.flippedMaxTurn;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async repeatGeneralCommand(amount: number) {
|
|
||||||
try {
|
|
||||||
await SammoAPI.Command.RepeatCommand({ amount });
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
alert(`실패했습니다: ${e}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await this.reloadCommandList();
|
|
||||||
},
|
|
||||||
async pushGeneralCommand(amount: number) {
|
|
||||||
try {
|
|
||||||
await SammoAPI.Command.PushCommand({ amount });
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
alert(`실패했습니다: ${e}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await this.reloadCommandList();
|
|
||||||
},
|
|
||||||
pushGeneralCommandSingle(e: Event) {
|
|
||||||
//NOTE: split 구현에 버그가 있어서, 수동으로 구분해야함
|
|
||||||
if (isDropdownChildren(e)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
void this.pushGeneralCommand(1);
|
|
||||||
},
|
|
||||||
pullGeneralCommandSingle(e: Event) {
|
|
||||||
//NOTE: split 구현에 버그가 있어서, 수동으로 구분해야함
|
|
||||||
if (isDropdownChildren(e)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
void this.pushGeneralCommand(-1);
|
|
||||||
},
|
|
||||||
async reloadCommandList() {
|
|
||||||
let result: ReservedCommandResponse;
|
|
||||||
try {
|
|
||||||
result = await SammoAPI.Command.GetReservedCommand();
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
alert(`실패했습니다: ${e}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const reservedCommandList: TurnObjWithTime[] = [];
|
const emptyTurn: TurnObjWithTime[] = Array.from<TurnObjWithTime>({
|
||||||
let yearMonth = joinYearMonth(result.year, result.month);
|
length: staticValues.maxTurn,
|
||||||
|
}).fill({
|
||||||
const turnTime = parseTime(result.turnTime);
|
arg: null,
|
||||||
let nextTurnTime = new Date(turnTime);
|
brief: "",
|
||||||
|
action: "",
|
||||||
const autorunLimitYearMonth = result.autorun_limit ?? yearMonth - 1;
|
year: undefined,
|
||||||
const [autorunLimitYear, autorunLimitMonth] = parseYearMonth(
|
month: undefined,
|
||||||
autorunLimitYearMonth
|
time: "",
|
||||||
);
|
|
||||||
|
|
||||||
for (const obj of result.turn) {
|
|
||||||
const [year, month] = parseYearMonth(yearMonth);
|
|
||||||
let tooltip: string[] = [];
|
|
||||||
let style: Record<string, unknown> = {};
|
|
||||||
|
|
||||||
const brief = obj.brief;
|
|
||||||
|
|
||||||
if (yearMonth <= autorunLimitYearMonth) {
|
|
||||||
if (obj.brief == "휴식") {
|
|
||||||
obj.brief = "휴식<small>(자율 행동)</small>";
|
|
||||||
}
|
|
||||||
style.color = "#aaffff";
|
|
||||||
|
|
||||||
tooltip.push(
|
|
||||||
`자율 행동 기간: ${autorunLimitYear}년 ${autorunLimitMonth}월까지`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mb_strwidth(brief) > 22) {
|
|
||||||
tooltip.push(brief);
|
|
||||||
}
|
|
||||||
|
|
||||||
reservedCommandList.push({
|
|
||||||
...obj,
|
|
||||||
year,
|
|
||||||
month,
|
|
||||||
time: formatTime(nextTurnTime, "HH:mm"),
|
|
||||||
tooltip: tooltip.length == 0 ? undefined : tooltip.join("\n"),
|
|
||||||
style,
|
|
||||||
});
|
|
||||||
|
|
||||||
yearMonth += 1;
|
|
||||||
nextTurnTime = addMinutes(nextTurnTime, result.turnTerm);
|
|
||||||
}
|
|
||||||
this.reservedCommandList = reservedCommandList;
|
|
||||||
|
|
||||||
const serverNowObj = parseTime(result.date);
|
|
||||||
const clientNowObj = new Date();
|
|
||||||
const timeDiff = serverNowObj.getTime() - clientNowObj.getTime();
|
|
||||||
this.timeDiff = timeDiff;
|
|
||||||
},
|
|
||||||
async reserveCommand() {
|
|
||||||
let turnList: number[];
|
|
||||||
if (this.turnList.size == 0) {
|
|
||||||
turnList = Array.from(this.prevTurnList.values());
|
|
||||||
} else {
|
|
||||||
turnList = Array.from(this.turnList.values());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (turnList.length == 0) {
|
|
||||||
turnList.push(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const commandName = this.selectedCommand.value;
|
|
||||||
|
|
||||||
if (listReqArgCommand.has(commandName)) {
|
|
||||||
document.location.href = stringifyUrl({
|
|
||||||
url: "v_processing.php",
|
|
||||||
query: {
|
|
||||||
command: commandName,
|
|
||||||
turnList: turnList.join("_"),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await SammoAPI.Command.ReserveCommand({
|
|
||||||
turnList,
|
|
||||||
action: commandName,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this.turnList.size > 0) {
|
|
||||||
this.prevTurnList.clear();
|
|
||||||
for (const v of this.turnList) {
|
|
||||||
this.prevTurnList.add(v);
|
|
||||||
}
|
|
||||||
this.turnList.clear();
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
alert(`실패했습니다: ${e}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await this.reloadCommandList();
|
|
||||||
},
|
|
||||||
toggleSearchCommand() {
|
|
||||||
const searchModeOn = !this.searchModeOn;
|
|
||||||
this.searchModeOn = searchModeOn;
|
|
||||||
localStorage.setItem(searchModeKey, searchModeOn ? "1" : "0");
|
|
||||||
},
|
|
||||||
chooseCommand(val: string){
|
|
||||||
this.selectedCommand = this.invCommandMap[val];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
const serverNowObj = parseTime(serverNow);
|
|
||||||
const clientNowObj = new Date();
|
|
||||||
const timeDiff = serverNowObj.getTime() - clientNowObj.getTime();
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
this.updateNow();
|
|
||||||
}, 1000 - serverNowObj.getMilliseconds());
|
|
||||||
|
|
||||||
const selectedCommand = commandList[0].values[0];
|
|
||||||
for (const subCategory of commandList) {
|
|
||||||
for (const command of subCategory.values) {
|
|
||||||
if (command.searchText) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
command.searchText = convertSearch초성(command.simpleName).join("|");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const searchModeOn = (localStorage.getItem(searchModeKey) ?? "0") != "0";
|
|
||||||
|
|
||||||
const emptyTurn: TurnObjWithTime[] = Array.from<TurnObjWithTime>({
|
|
||||||
length: maxTurn,
|
|
||||||
}).fill({
|
|
||||||
arg: null,
|
|
||||||
brief: "",
|
|
||||||
action: "",
|
|
||||||
year: undefined,
|
|
||||||
month: undefined,
|
|
||||||
time: "",
|
|
||||||
});
|
|
||||||
|
|
||||||
const prevTurnList = new Set([0]);
|
|
||||||
const turnList = new Set<number>();
|
|
||||||
|
|
||||||
return {
|
|
||||||
maxTurn,
|
|
||||||
|
|
||||||
maxPushTurn,
|
|
||||||
commandList,
|
|
||||||
serverNow: formatTime(serverNowObj, "HH:mm:ss"),
|
|
||||||
timeDiff,
|
|
||||||
prevTurnList,
|
|
||||||
turnList,
|
|
||||||
selectedCommand,
|
|
||||||
reservedCommandList: emptyTurn,
|
|
||||||
autorun_limit: null as null | number,
|
|
||||||
searchModeOn,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
setup() {
|
|
||||||
const flippedMaxTurn = 15;
|
|
||||||
const viewMaxTurn = ref(flippedMaxTurn);
|
|
||||||
const rowGridStyle = ref({
|
|
||||||
display: "grid",
|
|
||||||
gridTemplateRows: `repeat(${viewMaxTurn.value}, 29.4px)`,
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(viewMaxTurn, (val) => {
|
|
||||||
rowGridStyle.value.gridTemplateRows = `repeat(${val}, 29.4px)`;
|
|
||||||
});
|
|
||||||
|
|
||||||
const isDragSingle = ref(false);
|
|
||||||
const isDragToggle = ref(false);
|
|
||||||
|
|
||||||
const invCommandMap: Record<string, commandItem> = {};
|
|
||||||
for(const category of commandList){
|
|
||||||
for(const command of category.values){
|
|
||||||
invCommandMap[command.value] = command;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
isDragSingle,
|
|
||||||
isDragToggle,
|
|
||||||
flippedMaxTurn,
|
|
||||||
viewMaxTurn,
|
|
||||||
rowGridStyle,
|
|
||||||
invCommandMap,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
void this.reloadCommandList();
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const prevTurnList = ref(new Set([0]));
|
||||||
|
const turnList = ref(new Set<number>());
|
||||||
|
const reservedCommandList = ref(emptyTurn);
|
||||||
|
|
||||||
|
const flippedMaxTurn = 15;
|
||||||
|
const viewMaxTurn = ref(flippedMaxTurn);
|
||||||
|
const rowGridStyle = ref({
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateRows: `repeat(${viewMaxTurn.value}, 29.4px)`,
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(viewMaxTurn, (val) => {
|
||||||
|
rowGridStyle.value.gridTemplateRows = `repeat(${val}, 29.4px)`;
|
||||||
|
});
|
||||||
|
|
||||||
|
const isDragSingle = ref(false);
|
||||||
|
const isDragToggle = ref(false);
|
||||||
|
|
||||||
|
const invCommandMap: Record<string, CommandItem> = {};
|
||||||
|
for (const category of commandList) {
|
||||||
|
for (const command of category.values) {
|
||||||
|
invCommandMap[command.value] = command;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function updateNow() {
|
||||||
|
serverNow.value = addMilliseconds(new Date(), timeDiff.value);
|
||||||
|
setTimeout(() => {
|
||||||
|
updateNow();
|
||||||
|
}, 1000 - serverNow.value.getMilliseconds());
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleTurn(...reqTurnList: number[] | string[]) {
|
||||||
|
for (let turnIdx of reqTurnList) {
|
||||||
|
if (isString(turnIdx)) {
|
||||||
|
turnIdx = parseInt(turnIdx);
|
||||||
|
}
|
||||||
|
if (turnList.value.has(turnIdx)) {
|
||||||
|
turnList.value.delete(turnIdx);
|
||||||
|
} else {
|
||||||
|
turnList.value.add(turnIdx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectTurn(...reqTurnList: number[] | string[]) {
|
||||||
|
turnList.value.clear();
|
||||||
|
for (const turnIdx of reqTurnList) {
|
||||||
|
if (isString(turnIdx)) {
|
||||||
|
turnList.value.add(parseInt(turnIdx));
|
||||||
|
} else {
|
||||||
|
turnList.value.add(turnIdx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectAll(e: Event | true) {
|
||||||
|
//NOTE: split 구현에 버그가 있어서, 수동으로 구분해야함
|
||||||
|
if (e !== true && isDropdownChildren(e)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (turnList.value.size * 3 > maxTurn) {
|
||||||
|
turnList.value.clear();
|
||||||
|
} else {
|
||||||
|
for (let i = 0; i < maxTurn; i++) {
|
||||||
|
turnList.value.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectStep(begin: number, step: number) {
|
||||||
|
turnList.value.clear();
|
||||||
|
for (const idx of range(0, maxTurn)) {
|
||||||
|
if ((idx - begin) % step == 0) {
|
||||||
|
turnList.value.add(idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleViewMaxTurn() {
|
||||||
|
if (viewMaxTurn.value == flippedMaxTurn) {
|
||||||
|
viewMaxTurn.value = maxTurn;
|
||||||
|
} else {
|
||||||
|
viewMaxTurn.value = flippedMaxTurn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function repeatGeneralCommand(amount: number) {
|
||||||
|
try {
|
||||||
|
await SammoAPI.Command.RepeatCommand({ amount });
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
alert(`실패했습니다: ${e}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await reloadCommandList();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function pushGeneralCommand(amount: number) {
|
||||||
|
try {
|
||||||
|
await SammoAPI.Command.PushCommand({ amount });
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
alert(`실패했습니다: ${e}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await reloadCommandList();
|
||||||
|
}
|
||||||
|
|
||||||
|
function pushGeneralCommandSingle(e: Event) {
|
||||||
|
//NOTE: split 구현에 버그가 있어서, 수동으로 구분해야함
|
||||||
|
if (isDropdownChildren(e)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void pushGeneralCommand(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function pullGeneralCommandSingle(e: Event) {
|
||||||
|
//NOTE: split 구현에 버그가 있어서, 수동으로 구분해야함
|
||||||
|
if (isDropdownChildren(e)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void pushGeneralCommand(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function reloadCommandList() {
|
||||||
|
let result: ReservedCommandResponse;
|
||||||
|
try {
|
||||||
|
result = await SammoAPI.Command.GetReservedCommand();
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
alert(`실패했습니다: ${e}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let yearMonth = joinYearMonth(result.year, result.month);
|
||||||
|
|
||||||
|
const turnTime = parseTime(result.turnTime);
|
||||||
|
let nextTurnTime = new Date(turnTime);
|
||||||
|
|
||||||
|
const autorunLimitYearMonth = result.autorun_limit ?? yearMonth - 1;
|
||||||
|
const [autorunLimitYear, autorunLimitMonth] = parseYearMonth(
|
||||||
|
autorunLimitYearMonth
|
||||||
|
);
|
||||||
|
|
||||||
|
reservedCommandList.value = [];
|
||||||
|
for (const obj of result.turn) {
|
||||||
|
const [year, month] = parseYearMonth(yearMonth);
|
||||||
|
let tooltip: string[] = [];
|
||||||
|
let style: Record<string, unknown> = {};
|
||||||
|
|
||||||
|
const brief = obj.brief;
|
||||||
|
|
||||||
|
if (yearMonth <= autorunLimitYearMonth) {
|
||||||
|
if (obj.brief == "휴식") {
|
||||||
|
obj.brief = "휴식<small>(자율 행동)</small>";
|
||||||
|
}
|
||||||
|
style.color = "#aaffff";
|
||||||
|
|
||||||
|
tooltip.push(
|
||||||
|
`자율 행동 기간: ${autorunLimitYear}년 ${autorunLimitMonth}월까지`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mb_strwidth(brief) > 22) {
|
||||||
|
tooltip.push(brief);
|
||||||
|
}
|
||||||
|
|
||||||
|
reservedCommandList.value.push({
|
||||||
|
...obj,
|
||||||
|
year,
|
||||||
|
month,
|
||||||
|
time: formatTime(nextTurnTime, "HH:mm"),
|
||||||
|
tooltip: tooltip.length == 0 ? undefined : tooltip.join("\n"),
|
||||||
|
style,
|
||||||
|
});
|
||||||
|
|
||||||
|
yearMonth += 1;
|
||||||
|
nextTurnTime = addMinutes(nextTurnTime, result.turnTerm);
|
||||||
|
}
|
||||||
|
|
||||||
|
serverNow.value = parseTime(result.date);
|
||||||
|
clientNow.value = new Date();
|
||||||
|
timeDiff.value = serverNow.value.getTime() - clientNow.value.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function reserveCommand() {
|
||||||
|
let reqTurnList: number[];
|
||||||
|
if (turnList.value.size == 0) {
|
||||||
|
reqTurnList = Array.from(prevTurnList.value.values());
|
||||||
|
} else {
|
||||||
|
reqTurnList = Array.from(turnList.value.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reqTurnList.length == 0) {
|
||||||
|
reqTurnList.push(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const commandName = selectedCommand.value.value;
|
||||||
|
|
||||||
|
if (listReqArgCommand.has(commandName)) {
|
||||||
|
document.location.href = stringifyUrl({
|
||||||
|
url: "v_processing.php",
|
||||||
|
query: {
|
||||||
|
command: commandName,
|
||||||
|
turnList: reqTurnList.join("_"),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await SammoAPI.Command.ReserveCommand({
|
||||||
|
turnList,
|
||||||
|
action: commandName,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (turnList.value.size > 0) {
|
||||||
|
prevTurnList.value.clear();
|
||||||
|
for (const v of turnList.value) {
|
||||||
|
prevTurnList.value.add(v);
|
||||||
|
}
|
||||||
|
turnList.value.clear();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
alert(`실패했습니다: ${e}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await reloadCommandList();
|
||||||
|
}
|
||||||
|
|
||||||
|
function chooseCommand(val?: string) {
|
||||||
|
if(!val){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
selectedCommand.value = invCommandMap[val];
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
void reloadCommandList();
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@use "sass:color";
|
@use "sass:color";
|
||||||
|
|||||||
@@ -0,0 +1,135 @@
|
|||||||
|
<template>
|
||||||
|
<teleport to="body">
|
||||||
|
<div v-if="showForm">
|
||||||
|
<div class="commandCategory">
|
||||||
|
<div
|
||||||
|
class="categoryItem"
|
||||||
|
v-for="[categoryKey, { deco: categoryDeco }] of commandList"
|
||||||
|
:key="categoryKey"
|
||||||
|
><BButton @click="chosenCategory=categoryKey">{{ categoryDeco.altName ?? categoryDeco.name }}</BButton></div>
|
||||||
|
</div>
|
||||||
|
<div class="commandList">
|
||||||
|
<div
|
||||||
|
class="commandItem"
|
||||||
|
v-for="commandItem of chosenSubList"
|
||||||
|
:key="commandItem.value"
|
||||||
|
@click="close(commandItem.value)"
|
||||||
|
>
|
||||||
|
{{ commandItem.simpleName }}
|
||||||
|
<br />
|
||||||
|
<small>{{ commandItem.title }}</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="commandBottom">
|
||||||
|
<BButton @click="close()">닫기</BButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</teleport>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
/*
|
||||||
|
<template v-if="props.option.title">
|
||||||
|
<span class="compensatePositive" v-if="props.option.compensation > 0">▲</span>
|
||||||
|
<span class="compensateNegative" v-else-if="props.option.compensation < 0">▼</span>
|
||||||
|
<span class="compensateNeutral" v-else></span>
|
||||||
|
<span
|
||||||
|
:class="[props.option.possible ? '' : 'commandImpossible']"
|
||||||
|
>{{ props.option.title }}</span>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="props.option.category">{{ props.option.category }}</template>
|
||||||
|
</template>
|
||||||
|
<template v-slot:singleLabel="props">{{ props.option.simpleName }}</template>
|
||||||
|
*/
|
||||||
|
import type { CommandItem } from "@/defs";
|
||||||
|
import { BButton } from "bootstrap-vue-3";
|
||||||
|
import { ref, defineProps, defineEmits, defineExpose, type PropType, watch } from "vue";
|
||||||
|
|
||||||
|
const chosenCategory = ref<string>("");
|
||||||
|
const chosenSubList = ref<CommandItem[]>([]);
|
||||||
|
|
||||||
|
interface CategoryDecoration {
|
||||||
|
name: string,
|
||||||
|
altName?: string,
|
||||||
|
//icon?: string,
|
||||||
|
//color?: string,
|
||||||
|
//backgroundColor?: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
categoryInfo: {
|
||||||
|
type: Object as PropType<Record<string, Omit<CategoryDecoration, 'name'>>>,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
commandList: {
|
||||||
|
type: Object as PropType<{
|
||||||
|
category: string;
|
||||||
|
values: CommandItem[];
|
||||||
|
}[]>,
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const showForm = ref(false);
|
||||||
|
|
||||||
|
function convCategoryDeco(category: string): CategoryDecoration {
|
||||||
|
const itemInfo = props.categoryInfo?.[category];
|
||||||
|
if (!itemInfo) {
|
||||||
|
return {
|
||||||
|
name: category,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
name: category,
|
||||||
|
...itemInfo
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const commandList = ref(new Map<string, {
|
||||||
|
deco: CategoryDecoration,
|
||||||
|
values: CommandItem[],
|
||||||
|
}>());
|
||||||
|
|
||||||
|
function updateCommandList(rawCommandList: typeof props.commandList) {
|
||||||
|
commandList.value.clear();
|
||||||
|
for (const { category, values } of rawCommandList) {
|
||||||
|
commandList.value.set(category, {
|
||||||
|
deco: convCategoryDeco(category),
|
||||||
|
values
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
|
||||||
|
function show(): void {
|
||||||
|
showForm.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function close(category?: string): void {
|
||||||
|
showForm.value = false;
|
||||||
|
emits('onClose', category);
|
||||||
|
}
|
||||||
|
|
||||||
|
const emits = defineEmits<{
|
||||||
|
(event: 'onClose', command?: string): void,
|
||||||
|
}>();
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
show,
|
||||||
|
close
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
+1
-1
@@ -250,4 +250,4 @@ export type BettingInfo = {
|
|||||||
closeYearMonth: number;
|
closeYearMonth: number;
|
||||||
candidates: SelectItem[];
|
candidates: SelectItem[];
|
||||||
winner?: number[];
|
winner?: number[];
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -9,8 +9,12 @@ import { exportWindow } from '@util/exportWindow';
|
|||||||
import { htmlReady } from './util/htmlReady';
|
import { htmlReady } from './util/htmlReady';
|
||||||
import { initTooltip } from './legacy/initTooltip';
|
import { initTooltip } from './legacy/initTooltip';
|
||||||
|
|
||||||
declare const serverNick: string;
|
declare const staticValues: {
|
||||||
declare const serverID: string;
|
serverNick: string;
|
||||||
|
serverID: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { serverNick, serverID } = staticValues;
|
||||||
|
|
||||||
type CityPositionMap = {
|
type CityPositionMap = {
|
||||||
[cityID: number]: [string, number, number];
|
[cityID: number]: [string, number, number];
|
||||||
|
|||||||
@@ -76,8 +76,15 @@ if (!$commandObj->hasPermissionToReserve()) {
|
|||||||
<?= WebUtil::printJS('../d_shared/common_path.js') ?>
|
<?= WebUtil::printJS('../d_shared/common_path.js') ?>
|
||||||
<?= WebUtil::printJS('d_shared/base_map.js') ?>
|
<?= WebUtil::printJS('d_shared/base_map.js') ?>
|
||||||
<?= WebUtil::printStaticValues([
|
<?= WebUtil::printStaticValues([
|
||||||
'serverNick' => DB::prefix(),
|
'staticValues' => [
|
||||||
'serverID' => UniqueConst::$serverID,
|
'serverNick' => DB::prefix(),
|
||||||
|
'serverID' => UniqueConst::$serverID,
|
||||||
|
'commandName' => $commandObj->getName(),
|
||||||
|
'turnList' => $turnList,
|
||||||
|
'currentCity' => $general->getCityID(),
|
||||||
|
'currentNation' => $general->getNationID(),
|
||||||
|
'entryInfo' => [$isChiefTurn?'Nation':'General', $commandType]
|
||||||
|
],
|
||||||
'commandName' => $commandObj->getName(),
|
'commandName' => $commandObj->getName(),
|
||||||
'turnList' => $turnList,
|
'turnList' => $turnList,
|
||||||
'currentCity' => $general->getCityID(),
|
'currentCity' => $general->getCityID(),
|
||||||
|
|||||||
Reference in New Issue
Block a user