feat: chiefCenter 500px 재구현

- API: 사령턴 관련
- TopBackBar에 갱신 추가
This commit is contained in:
2021-12-25 21:51:47 +09:00
parent c961096b70
commit 5142c94f84
27 changed files with 1774 additions and 171 deletions
+56
View File
@@ -0,0 +1,56 @@
<template>
<div
:class="[`chiefBox${chiefLevel}`, 'subRows']"
v-for="(officer, idx) in [chiefList[chiefLevel]]"
:key="idx"
:style="style"
@click="$emit('click', this)"
>
<div
class="bg1 nameHeader"
:style="{
color: getNpcColor(officer.npcType ?? 0),
textDecoration: isMe ? 'underline' : undefined,
}"
>
{{ officer.name ?? "-" }}
</div>
<div class="bg1 center row gx-0">
<div class="col">{{ officer.officerLevelText }}</div>
<div class="col">{{ (officer.turnTime ?? " - ").slice(-5) }}</div>
</div>
<div
class="tableCell align-self-center"
v-for="(turn, idx) in officer.turn"
:key="idx"
:style="{
fontSize:
mb_strwidth(turn.brief) > 28
? `${28 / mb_strwidth(turn.brief)}em`
: undefined,
}"
>
{{ turn.brief }}
</div>
</div>
</template>
<script lang="ts">
import { getNpcColor } from "@/common_legacy";
import { mb_strwidth } from "@/util/mb_strwidth";
import { defineComponent } from "vue";
import VueTypes from "vue-types";
export default defineComponent({
props: {
chiefLevel: VueTypes.integer.isRequired,
style: VueTypes.object.isRequired,
chiefList: VueTypes.object.isRequired,
isMe: VueTypes.bool.isRequired,
},
emits: ["click"],
methods: {
mb_strwidth,
getNpcColor,
},
});
</script>
+83
View File
@@ -0,0 +1,83 @@
<template>
<div
:class="['subRows', 'c-bg2', 'chiefCommand']"
:style="style"
>
<div class="bg1 center row gx-0" style="font-size: 1.2em">
<div class="col-5 align-self-center text-end">
{{ officer.officerLevelText }} :
</div>
<div
class="col-7 align-self-center"
:style="{
color: getNpcColor(officer.npcType ?? 0),
}"
>
{{ officer.name }}
</div>
</div>
<div class="row gx-0" v-for="(turn, idx) in officer.turn" :key="idx">
<div class="col-2 time_pad f_tnum">
{{ turnTimes[idx] }}
</div>
<div
class="tableCell align-self-center col-10 center turn_pad"
:style="{
fontSize:
mb_strwidth(turn.brief) > 28
? `${28 / mb_strwidth(turn.brief)}em`
: undefined,
}"
>
{{ turn.brief }}
</div>
</div>
</div>
</template>
<script lang="ts">
import { getNpcColor } from "@/common_legacy";
import { ChiefResponse } from "@/defs";
import { formatTime } from "@/util/formatTime";
import { mb_strwidth } from "@/util/mb_strwidth";
import { parseTime } from "@/util/parseTime";
import addMinutes from "date-fns/esm/addMinutes/index";
import { range } from "lodash";
import { defineComponent, PropType } from "vue";
import VueTypes from "vue-types";
export default defineComponent({
props: {
style: VueTypes.object.isRequired,
officer: {
type: Object as PropType<ChiefResponse['chiefList'][0]>,
required: true,
},
turnTerm: VueTypes.integer.isRequired,
},
methods: {
getNpcColor,
mb_strwidth,
},
data() {
const turnTimes: string[] = [];
if (!this.officer.turnTime) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
for(const _ of range(this.officer.turn.length)){
turnTimes.push('-');
}
}
else{
const baseTurnTime = parseTime(this.officer.turnTime);
for(const idx of range(this.officer.turn.length)){
turnTimes.push(formatTime(addMinutes(baseTurnTime, idx * this.turnTerm), this.turnTerm >= 5 ? "HH:mm":"mm:ss"));
}
}
return {
turnTimes,
}
},
});
</script>
+471
View File
@@ -0,0 +1,471 @@
<template>
<div id="container" class="pageChiefCenter">
<TopBackBar title="사령부" reloadable @reload="reloadTable" />
<div
id="mainTable"
v-if="chiefList !== undefined"
:class="`${targetIsMe ? 'targetIsMe' : 'targetIsNotMe'}`"
>
<template
v-for="(chiefLevel, vidx) in [12, 10, 8, 6, 11, 9, 7, 5]"
:key="chiefLevel"
>
<div
v-if="vidx % 4 == 0"
:class="[
'turnIdx',
vidx == 0 && !targetIsMe ? undefined : 'only1000px',
]"
>
<div :class="['subRows', 'bg0']" :style="mainTableGridRows">
<div class="bg1">&nbsp;</div>
<div
v-for="idx in maxChiefTurn"
:class="[`turnIdxLeft`, 'align-self-center', 'center']"
:key="idx"
>
{{ idx }}
</div>
</div>
</div>
<div
v-for="(officer, idx) in [chiefList[chiefLevel]]"
:key="idx"
:class="[`${viewTarget == chiefLevel ? '' : 'only1000px'}`]"
>
<TopItem
v-if="officerLevel != chiefLevel"
:style="mainTableGridRows"
:officer="officer"
:turnTerm="turnTerm"
/>
<div class="commandBox" v-else>
<div
class="only1000px bg1 center row gx-0"
style="height: 24px; font-size: 1.2em"
>
<div class="col-5 align-self-center text-end">
{{ officer.officerLevelText }} :
</div>
<div
class="col-7 align-self-center"
:style="{
color: getNpcColor(officer.npcType ?? 0),
}"
>
{{ officer.name }}
</div>
</div>
<div
:class="[
'row',
'controlPad',
chiefLevel == officerLevel ? 'targetIsMe' : 'targetIsNotMe',
]"
>
<div class="col-3 col-md-12 order-md-last">
<div class="d-grid mb-1 py-1 only500px bg1 center">
<div
:style="{
color: getNpcColor(officer.npcType ?? 0),
fontSize: '1.2em',
}"
>
{{ officer.name }}
</div>
<div>{{ officer.officerLevelText }}</div>
</div>
<div class="row gx-1 gy-1 py-1">
<div class="col-md-4 mx-0 mb-0 mt-1 d-grid">
<div class="alert alert-primary mb-0 center" style="padding:0.5rem 0">
{{ serverNow }}
</div>
</div>
<b-dropdown class="col-md-4" left text="턴 선택">
<b-dropdown-item @click="selectAll(true)"
>모든턴</b-dropdown-item
>
<b-dropdown-item @click="selectStep(0, 2)"
>홀수턴</b-dropdown-item
>
<b-dropdown-item @click="selectStep(1, 2)"
>짝수턴</b-dropdown-item
>
<b-dropdown-divider></b-dropdown-divider>
<b-dropdown-text
v-for="spanIdx in [3, 4, 5, 6, 7]"
:key="spanIdx"
>
{{ spanIdx }} 간격<br />
<b-button-group>
<b-button
class="ignoreMe"
v-for="beginIdx in spanIdx"
:key="beginIdx"
@click="selectStep(beginIdx - 1, spanIdx)"
>{{ beginIdx }}</b-button
>
</b-button-group>
</b-dropdown-text>
</b-dropdown>
<b-dropdown class="col-md-4" text="반복">
<b-dropdown-item
v-for="turnIdx in maxPushTurn"
:key="turnIdx"
@click="repeatNationCommand(turnIdx)"
>{{ turnIdx }}
</b-dropdown-item>
</b-dropdown>
<b-dropdown
class="col-md-6"
split
text="당기기"
@click="pullNationCommandSingle"
>
<b-dropdown-item
v-for="turnIdx in maxPushTurn"
:key="turnIdx"
@click="pushNationCommand(-turnIdx)"
>{{ turnIdx }}
</b-dropdown-item>
</b-dropdown>
<b-dropdown
class="col-md-6"
split
text="미루기"
@click="pushNationCommandSingle"
>
<b-dropdown-item
v-for="turnIdx in maxPushTurn"
:key="turnIdx"
@click="pushNationCommand(turnIdx)"
>{{ turnIdx }}
</b-dropdown-item>
</b-dropdown>
</div>
</div>
<div class="col">
<ChiefReservedCommand
:key="idx"
:year="year"
:month="month"
:turn="officer.turn"
:turnTerm="turnTerm"
:commandList="commandList"
:turnTime="officer.turnTime"
:maxTurn="maxChiefTurn"
:maxPushTurn="Math.floor(maxChiefTurn / 2)"
:date="date"
v-model:selectedTurn="turnList"
@raiseReload="reloadTable()"
/>
</div>
</div>
</div>
</div>
<div
v-if="vidx % 4 == 3"
:class="[
'turnIdx',
vidx == 7 && !targetIsMe ? undefined : 'only1000px',
]"
>
<div :class="['subRows', 'bg0']" :style="mainTableGridRows">
<div class="bg1">&nbsp;</div>
<div
v-for="idx in maxChiefTurn"
:class="[`turnIdxRight`, 'align-self-center', 'center']"
:key="idx"
>
{{ idx }}
</div>
</div>
</div>
</template>
</div>
</div>
<div id="bottomChiefBox" v-if="chiefList">
<div id="bottomChiefList" class="c-bg2">
<template
v-for="(chiefLevel, vidx) in [12, 10, 8, 6, 11, 9, 7, 5]"
:key="chiefLevel"
>
<div
class="turnIdx subRows bg0"
:style="subTableGridRows"
v-if="vidx % 4 == 0"
>
<div class="bg1" style="grid-row: 1/3"></div>
<div v-for="idx in maxChiefTurn" :class="[`turnIdxLeft`]" :key="idx">
{{ idx }}
</div>
</div>
<BottomItem
:chiefLevel="chiefLevel"
:chiefList="chiefList"
:style="subTableGridRows"
:isMe="targetIsMe"
@click="viewTarget = chiefLevel"
/>
<div
class="turnIdx subRows bg0"
:style="subTableGridRows"
v-if="vidx % 4 == 3"
>
<div class="bg1" style="grid-row: 1/3"></div>
<div v-for="idx in maxChiefTurn" :class="`turnIdxRight`" :key="idx">
{{ idx }}
</div>
</div>
</template>
</div>
</div>
</template>
<script lang="ts">
import "@scss/common/bootstrap5.scss";
import "@scss/game_bg.scss";
import "../../css/config.css";
import { computed, defineComponent, reactive, ref, toRefs, watch } from "vue";
import ChiefReservedCommand from "@/components/ChiefReservedCommand.vue";
import TopBackBar from "@/components/TopBackBar.vue";
import VueTypes from "vue-types";
import { isString, range } from "lodash";
import { mb_strwidth } from "./util/mb_strwidth";
import { sammoAPI } from "./util/sammoAPI";
import { entriesWithType } from "./util/entriesWithType";
import { addMilliseconds } from "date-fns";
import { formatTime } from "./util/formatTime";
import { parseTime } from "./util/parseTime";
import { getNpcColor } from "./common_legacy";
import TopItem from "@/ChiefCenter/TopItem.vue";
import BottomItem from "@/ChiefCenter/BottomItem.vue";
import { ChiefResponse, OptionalFull } from "./defs";
function isDropdownChildren(e?: Event): boolean {
if (!e) {
return false;
}
if (!e.target) {
return false;
}
if (
(e.target as HTMLElement).classList.contains("dropdown-item") ||
(e.target as HTMLElement).classList.contains("dropdown-toggle-split") ||
(e.target as HTMLElement).classList.contains("ignoreMe")
) {
return true;
}
return false;
}
export default defineComponent({
components: {
TopBackBar,
ChiefReservedCommand,
TopItem,
BottomItem,
},
props: {
maxChiefTurn: VueTypes.number.isRequired,
},
watch: {
year() {
console.log(this.lastExecute);
},
},
methods: {
toggleTurn(turnIdx: number) {
if (this.turnList.has(turnIdx)) {
this.turnList.delete(turnIdx);
} else {
this.turnList.add(turnIdx);
}
},
selectTurn(turnIdx: number) {
this.turnList.clear();
this.turnList.add(turnIdx);
},
selectAll(e: Event | true) {
//NOTE: split 구현에 버그가 있어서, 수동으로 구분해야함
if (e !== true && isDropdownChildren(e)) {
return;
}
if (this.turnList.size * 3 > this.maxChiefTurn) {
this.turnList.clear();
} else {
for (let i = 0; i < this.maxChiefTurn; i++) {
this.turnList.add(i);
}
}
},
selectStep(begin: number, step: number) {
this.turnList.clear();
for (const idx of range(0, this.maxChiefTurn)) {
if ((idx - begin) % step == 0) {
this.turnList.add(idx);
}
}
},
async repeatNationCommand(amount: number) {
try {
await sammoAPI(`NationCommand/RepeatCommand`, { amount });
} catch (e) {
console.error(e);
alert(`실패했습니다: ${e}`);
return;
}
await this.reloadTable();
},
async pushNationCommand(amount: number) {
try {
await sammoAPI("NationCommand/PushCommand", { amount });
} catch (e) {
console.error(e);
alert(`실패했습니다: ${e}`);
return;
}
await this.reloadTable();
},
pushNationCommandSingle(e: Event) {
//NOTE: split 구현에 버그가 있어서, 수동으로 구분해야함
if (isDropdownChildren(e)) {
return;
}
void this.pushNationCommand(1);
},
pullNationCommandSingle(e: Event) {
//NOTE: split 구현에 버그가 있어서, 수동으로 구분해야함
if (isDropdownChildren(e)) {
return;
}
void this.pushNationCommand(-1);
},
},
setup(props) {
const viewTarget = ref<number | undefined>();
const turnList = ref(new Set<number>([2]));
const targetIsMe = ref<boolean>(false);
watch(viewTarget, (val) => {
console.log("targetChange!", val, targetIsMe);
if (val === undefined) {
targetIsMe.value = false;
return;
}
if (tableObj.officerLevel === undefined) {
targetIsMe.value = false;
}
targetIsMe.value = val === tableObj.officerLevel;
console.log("result", targetIsMe.value);
});
const tableObj = reactive<Omit<OptionalFull<ChiefResponse>, "result">>({
lastExecute: undefined,
year: undefined,
month: undefined,
turnTerm: undefined,
date: undefined,
chiefList: undefined,
isChief: undefined,
autorun_limit: undefined,
officerLevel: undefined,
commandList: undefined,
});
async function reloadTable(): Promise<void> {
try {
const response = await sammoAPI<ChiefResponse>(
"NationCommand/GetReservedCommand"
);
console.log(response);
for (const [key, value] of entriesWithType(response)) {
if (key === "result") {
continue;
}
if (key === "officerLevel") {
if (value < 5) {
tableObj.officerLevel = undefined;
} else {
tableObj.officerLevel = value as number;
}
continue;
}
//HACK:
tableObj[key as unknown as "year"] = value as unknown as undefined;
}
const serverNowObj = parseTime(response.date);
const clientNowObj = new Date();
timeDiff.value = serverNowObj.getTime() - clientNowObj.getTime();
if (viewTarget.value === undefined) {
viewTarget.value = tableObj.officerLevel;
}
} catch (e) {
if (isString(e)) {
alert(e);
}
console.error(e);
return;
}
}
//
const mainTableGridRows = computed(() => {
return {
gridTemplateRows: `24px repeat(${props.maxChiefTurn}, 30px)`,
};
});
const subTableGridRows = computed(() => {
return {
gridTemplateRows: `36px repeat(${props.maxChiefTurn + 1}, 1fr)`,
};
});
void reloadTable();
const serverNow = ref(formatTime(new Date(), "HH:mm:ss"));
const timeDiff = ref(0);
function updateNow() {
const serverNowObj = addMilliseconds(new Date(), timeDiff.value);
serverNow.value = formatTime(serverNowObj, "HH:mm:ss");
setTimeout(() => {
updateNow();
}, 1000 - serverNowObj.getMilliseconds());
}
setTimeout(() => {
updateNow();
}, 500);
return {
updateNow,
serverNow,
timeDiff,
turnList,
...toRefs(tableObj),
mb_strwidth,
mainTableGridRows,
subTableGridRows,
reloadTable,
getNpcColor,
viewTarget,
targetIsMe,
maxPushTurn: props.maxChiefTurn / 2,
};
},
});
</script>
<style lang="scss">
@import "@scss/chiefCenter.scss";
</style>
+4 -3
View File
@@ -497,7 +497,7 @@ export default defineComponent({
if (command.searchText) {
continue;
}
command.searchText = convertSearch초성(command.simpleName).join('|');
command.searchText = convertSearch초성(command.simpleName).join("|");
}
}
@@ -542,6 +542,7 @@ export default defineComponent({
@import "@scss/common/break_500px.scss";
@import "@scss/common/variables.scss";
@import "@scss/common/bootswatch_custom_variables.scss";
@import "@scss/game_bg.scss";
.commandPad {
background-color: $gray-900;
@@ -554,7 +555,7 @@ export default defineComponent({
//30, 70, 37.65, 160
}
@include media-1000px{
@include media-1000px {
.commandPad {
margin-left: 10px;
@@ -612,7 +613,7 @@ export default defineComponent({
.turn_pad {
white-space: nowrap;
background-color: rgba($base1color, 0.5);
background-color: $nbase2color;
}
.turn_pad .turn_text {
+1
View File
@@ -23,6 +23,7 @@
"ingame_vue": {
"v_inheritPoint": "v_inheritPoint.ts",
"v_board": "v_board.ts",
"v_chiefCenter": "v_chiefCenter.ts",
"v_NPCControl": "v_NPCControl.ts",
"v_join": "v_join.ts",
"v_main": "v_main.ts",
+1 -1
View File
@@ -19,7 +19,7 @@ export default defineComponent({
location.href = './';
}
else if(this.type == 'chief'){
location.href = 'b_chiefcenter.php';
location.href = 'v_chiefCenter.php';
}
else{
//TODO: window.close하려면 부모창이 있어야함!
+492
View File
@@ -0,0 +1,492 @@
<template>
<div class="commandPad chiefReservedCommand">
<div class="commandTable">
<template
v-for="(turnObj, turnIdx) in reservedCommandList"
:key="turnIdx"
>
<div class="idx_pad center d-grid" @click="toggleTurn(turnIdx)">
<b-button
size="sm"
:variant="
turnList.has(turnIdx)
? 'info'
: turnList.size == 0 && prevTurnList.has(turnIdx)
? 'success'
: 'primary'
"
>{{ turnIdx + 1 }}</b-button
>
</div>
<div
@click="selectTurn(turnIdx)"
class="time_pad center"
style="background-color: black; white-space: nowrap; overflow: hidden"
>
{{ turnObj.time }}
</div>
<div class="turn_pad center">
<span
class="turn_text"
:style="turnObj.style"
v-b-tooltip.hover
:title="turnObj.tooltip"
v-html="turnObj.brief"
></span>
</div>
</template>
</div>
<div class="row gx-0">
<div class="col-2 d-grid">
<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">
<v-multiselect
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 class="col-3 d-grid">
<b-button @click="reserveCommand()" variant="primary">실행</b-button>
</div>
</div>
</div>
</template>
<script lang="ts">
import addMinutes from "date-fns/esm/addMinutes";
import { stringifyUrl } from "query-string";
import { defineComponent, PropType } from "vue";
import { formatTime } from "@util/formatTime";
import { joinYearMonth } from "@util/joinYearMonth";
import { mb_strwidth } from "@util/mb_strwidth";
import { parseTime } from "@util/parseTime";
import { parseYearMonth } from "@util/parseYearMonth";
import { sammoAPI } from "@util/sammoAPI";
import { convertSearch초성 } from "@util/convertSearch초성";
import VueTypes from "vue-types";
type commandItem = {
value: string;
title: string;
compensation: number;
simpleName: string;
possible: boolean;
reqArg: boolean;
searchText?: string;
};
/*declare const commandList: {
category: string;
values: commandItem[];
}[];*/
type TurnObj = {
action: string;
brief: string;
arg: null | [] | Record<string, number | string | number[] | string[]>;
};
type TurnObjWithTime = TurnObj & {
time: string;
year?: number;
month?: number;
tooltip?: string;
style?: Record<string, unknown>;
};
const searchModeKey = `sammo_searchModeOn`;
export default defineComponent({
name: "NationReservedCommand",
props: {
maxTurn: VueTypes.integer.isRequired,
maxPushTurn: VueTypes.integer.isRequired,
date: VueTypes.string.isRequired,
year: VueTypes.integer.isRequired,
month: VueTypes.integer.isRequired,
turnTerm: VueTypes.integer.isRequired,
turnTime: VueTypes.string.isRequired,
selectedTurn: {
type: Object as PropType<Set<number>>,
required: false,
default: () => new Set(),
},
turn: {
type: Array as PropType<TurnObj[]>,
required: true,
},
commandList: {
type: Object as PropType<
{
category: string;
values: commandItem[];
}[]
>,
required: true,
},
},
emits: ["raiseReload", "update:selectedTurn"],
watch: {
date() {
this.triggerUpdateCommandList("date");
},
year() {
this.triggerUpdateCommandList("year");
},
month() {
this.triggerUpdateCommandList("month");
},
turnTime() {
this.triggerUpdateCommandList("turnTime");
},
commandList() {
this.triggerUpdateCommandList("commandList");
},
selectedTurn(val: Set<number>) {
console.log(val);
if (val === this.turnList) {
console.log("pass!");
return;
}
this.turnList.clear();
for (const t of val.values()) {
this.turnList.add(t);
}
},
turnList: {
handler() {
console.log(this.turnList);
this.$emit("update:selectedTurn", this.turnList);
},
deep: true,
},
},
methods: {
triggerUpdateCommandList(type?: string) {
console.log("try update", type);
this.updated = false;
setTimeout(() => {
this.updateCommandList();
}, 1);
},
toggleTurn(val: number) {
if (this.turnList.has(val)) {
this.turnList.delete(val);
} else {
this.turnList.add(val);
}
this.$emit("update:selectedTurn", this.turnList);
},
selectTurn(val: number) {
this.turnList.clear();
this.turnList.add(val);
this.$emit("update:selectedTurn", this.turnList);
},
updateCommandList() {
if (this.updated) {
return;
}
console.log("do update!");
const reservedCommandList: TurnObjWithTime[] = [];
let yearMonth = joinYearMonth(this.year, this.month);
const turnTime = parseTime(this.turnTime);
let nextTurnTime = new Date(turnTime);
const autorunLimitYearMonth = this.autorun_limit ?? yearMonth - 1;
const [autorunLimitYear, autorunLimitMonth] = parseYearMonth(
autorunLimitYearMonth
);
for (const obj of this.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,
this.turnTerm >= 5 ? "HH:mm" : "mm:ss"
),
tooltip: tooltip.length == 0 ? undefined : tooltip.join("\n"),
style,
});
yearMonth += 1;
nextTurnTime = addMinutes(nextTurnTime, this.turnTerm);
}
this.reservedCommandList = reservedCommandList;
const serverNowObj = parseTime(this.date);
const clientNowObj = new Date();
const timeDiff = serverNowObj.getTime() - clientNowObj.getTime();
this.timeDiff = timeDiff;
this.updated = true;
},
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 (this.listReqArgCommand.has(commandName)) {
document.location.href = stringifyUrl({
url: "v_processing.php",
query: {
command: commandName,
turnList: turnList.join("_"),
is_chief: true,
},
});
return;
}
try {
await sammoAPI("NationCommand/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;
}
this.$emit("raiseReload");
},
toggleSearchCommand() {
const searchModeOn = !this.searchModeOn;
this.searchModeOn = searchModeOn;
localStorage.setItem(searchModeKey, searchModeOn ? "1" : "0");
},
},
data() {
const serverNowObj = parseTime(this.date);
const clientNowObj = new Date();
const timeDiff = serverNowObj.getTime() - clientNowObj.getTime();
const listReqArgCommand = new Set<string>();
for (const commandCategories of this.commandList) {
if (!commandCategories.values) {
continue;
}
for (const commandObj of commandCategories.values) {
if (!commandObj.reqArg) {
continue;
}
listReqArgCommand.add(commandObj.value);
}
}
const selectedCommand = this.commandList[0].values[0];
for (const subCategory of this.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: this.maxTurn,
}).fill({
arg: null,
brief: "",
action: "",
year: undefined,
month: undefined,
time: "",
});
const prevTurnList = new Set([0]);
return {
updated: false,
listReqArgCommand,
serverNow: formatTime(serverNowObj, "HH:mm:ss"),
timeDiff,
prevTurnList,
turnList: this.selectedTurn,
selectedCommand,
reservedCommandList: emptyTurn,
autorun_limit: null as null | number,
searchModeOn,
};
},
mounted() {
this.updateCommandList();
},
});
</script>
<style lang="scss">
@import "@scss/common/break_500px.scss";
@import "@scss/common/variables.scss";
@import "@scss/common/bootswatch_custom_variables.scss";
.chiefReservedCommand {
background-color: $gray-900;
.commandTable {
width: 100%;
display: grid;
grid-template-columns: minmax(30px, 1fr) minmax(40px, 1fr) 5fr;
//30, 70, 37.65, 160
}
@include media-1000px {
.turn_pad {
overflow: hidden;
text-overflow: ellipsis;
}
.multiselect__content-wrapper {
margin-left: calc(-100% / 7 * 2);
width: calc(100% / 7 * 12);
}
.multiselect__single {
display: inline-block;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
}
@include media-500px {
.dropdown-item {
padding: 8px;
}
.multiselect__content-wrapper {
margin-left: calc(-100% / 7 * 2);
width: calc(100% / 7 * 12);
}
.commandPad {
margin-top: 10px;
margin-bottom: 10px;
.btn {
transition: none !important;
}
}
.month_pad,
.time_pad,
.turn_pad {
padding: 6px;
}
}
.month_pad:hover {
text-decoration: underline;
cursor: pointer;
}
.month_pad,
.time_pad,
.turn_pad {
display: flex;
justify-content: center;
align-items: center;
}
.turn_pad {
white-space: nowrap;
background-color: $nbase2color;
}
.turn_pad .turn_text {
display: inline-block;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
}
</style>
+33 -12
View File
@@ -1,8 +1,19 @@
<template>
<div class="bg0 back_bar">
<button type="button" class="btn btn-sammo-base2 back_btn" @click="back">
돌아가기
</button><b-button
돌아가기</button
><button
type="button"
v-if="reloadable"
class="btn btn-sammo-base2 reload_btn"
@click="reload"
>
갱신
</button>
<div v-else></div>
<h2 class="title">{{ title }}</h2>
<div>&nbsp;</div>
<b-button
class="btn-toggle-zoom"
:variant="toggleSearch ? 'info' : 'secondary'"
:pressed="toggleSearch"
@@ -10,8 +21,6 @@
@click="toggleSearch = !toggleSearch"
>{{ toggleSearch ? "검색 켜짐" : "검색 꺼짐" }}</b-button
>
<h2 class="title">{{ title }}</h2>
</div>
</template>
@@ -26,19 +35,22 @@ export default defineComponent({
if (this.type === "normal") {
location.href = "./";
} else if (this.type == "chief") {
location.href = "b_chiefcenter.php";
location.href = "v_chiefCenter.php";
} else {
//TODO: window.close하려면 부모창이 있어야함!
window.close();
}
},
reload() {
this.$emit("reload");
},
},
data() {
return {
toggleSearch: this.searchable,
};
},
emits: ["update:searchable"],
emits: ["update:searchable", "reload"],
watch: {
toggleSearch(val: boolean) {
this.$emit("update:searchable", val);
@@ -59,6 +71,11 @@ export default defineComponent({
default: undefined,
required: false,
},
reloadable: {
type: Boolean,
default: undefined,
required: false,
},
},
});
</script>
@@ -69,20 +86,24 @@ export default defineComponent({
max-width: 1000px;
width: 100%;
margin: auto;
display: grid;
grid-template-columns: 80px 80px 1fr 80px 80px;
position: relative;
height: 24pt;
}
.back_btn {
position: absolute;
left: 0;
.reload_btn {
height: 24pt;
margin-right: 2px;
}
.btn-toggle-zoom{
position: absolute;
.back_btn {
height: 24pt;
margin-right: 2px;
}
.btn-toggle-zoom {
height: 24pt;
right: 0;
}
.title {
+52 -2
View File
@@ -155,8 +155,58 @@ export type ToastType = {
}
export const keyScreenMode = 'sam.screenMode';
export type ScreenModeType = 'auto'|'500px'|'1000px';
export type ScreenModeType = 'auto' | '500px' | '1000px';
export declare type ValuesOf<T> = T[keyof T];
export const NoneValue = 'None' as const;
export const NoneValue = 'None' as const;
export type Optional<Type> = {
[Property in keyof Type]+?: Type[Property];
};
export type OptionalFull<Type> = {
[Property in keyof Type]: Type[Property]|undefined;
};
export type commandItem = {
value: string;
title: string;
compensation: number;
simpleName: string;
possible: boolean;
reqArg: boolean;
searchText?: string;
};
export type ChiefResponse = {
result: true;
lastExecute: string;
year: number;
month: number;
turnTerm: number;
date: string;
chiefList: Record<
number,
{
name: string | undefined;
turnTime: string | undefined;
officerLevelText: string;
officerLevel: number;
npcType: number;
turn: {
action: string;
brief: string;
arg: Record<string, unknown>;
}[];
}
>;
isChief: boolean;
autorun_limit: number;
officerLevel: number;
commandList: {
category: string;
values: commandItem[];
}[];
};
+15
View File
@@ -0,0 +1,15 @@
import { createApp } from 'vue'
import PageChiefCenter from '@/PageChiefCenter.vue';
import BootstrapVue3 from 'bootstrap-vue-3'
import 'bootstrap-vue-3/dist/bootstrap-vue-3.css'
import { setAxiosXMLHttpRequest } from '@util/setAxiosXMLHttpRequest';
import Multiselect from 'vue-multiselect';
declare const maxChiefTurn: number;
setAxiosXMLHttpRequest();
createApp(PageChiefCenter, {
maxChiefTurn,
}).use(BootstrapVue3).component('v-multiselect', Multiselect).mount('#app')
+1 -1
View File
@@ -47,7 +47,7 @@ async function submitCommand<T>(isChiefTurn: boolean, turnList: number[], comman
if (!isChiefTurn) {
window.location.href = './';
} else {
window.location.href = 'b_chiefcenter.php';
window.location.href = 'v_chiefCenter.php';
}
return data as unknown as T;