refac: 구 jQuery Map wrapper를 Vue3 렌더러로 변경

This commit is contained in:
2022-04-22 02:07:32 +09:00
parent 913f4214d7
commit 4bf67aa5e1
8 changed files with 561 additions and 513 deletions
-16
View File
@@ -31,22 +31,6 @@
#container {
width: 500px;
margin: 0 auto;
.world_map {
width: 500px;
height: calc((500px + 20px) * 500 / 700);
}
.map_title {
transform-origin: 0px 0px;
transform: scale(calc(500 / 700));
margin-bottom: calc(-20px * 200 / 700);
}
.map_body {
transform-origin: 0px 0px;
transform: scale(calc(500 / 700));
}
}
-133
View File
@@ -1,133 +0,0 @@
<template>
<div :id="uuid" :class="['world_map', `map_theme_${mapName}`, 'draw_required']">
<div
class="map_title obj_tooltip"
data-bs-toggle="tooltip"
data-bs-placement="top"
data-tooltip-class="map_title_tooltiptext"
>
<span class="map_title_text" />
<span class="tooltiptext" />
</div>
<div class="map_body">
<div class="map_bglayer1" />
<div class="map_bglayer2" />
<div class="map_bgroad" />
<div class="map_button_stack">
<button
type="button"
class="btn btn-primary map_toggle_cityname btn-sm btn-minimum"
data-bs-toggle="button"
aria-pressed="false"
autocomplete="off"
>
도시명 표기</button
><br />
<button
type="button"
class="btn btn-secondary map_toggle_single_tap btn-sm btn-minimum"
data-bs-toggle="button"
aria-pressed="false"
autocomplete="off"
>
두번 도시 이동
</button>
</div>
</div>
<div class="city_tooltip">
<div class="city_name" />
<div class="nation_name" />
</div>
</div>
</template>
<script lang="ts">
import "@/../css/map.css";
import { reloadWorldMap, type loadMapOption, type MapCityParsed } from "@/map";
import { defineComponent, onMounted, type PropType, ref } from "vue";
import { v4 as uuidv4 } from "uuid";
export type { MapCityParsed };
export default defineComponent({
props: {
mapName: {
type: String,
required: true,
},
isDetailMap: { type: Boolean, default: undefined, required: false },
clickableAll: { type: Boolean, default: undefined, required: false },
selectCallback: {
type: Function as PropType<loadMapOption["selectCallback"]>,
default: undefined,
required: false,
},
hrefTemplate: { type: String, default: undefined, required: false },
useCachedMap: { type: Boolean, default: undefined, required: false },
year: { type: Number, default: undefined, required: false },
month: { type: Number, default: undefined, required: false },
aux: {
type: Object as PropType<loadMapOption["aux"]>,
default: undefined,
required: false,
},
neutralView: { type: Boolean, default: undefined, required: false },
showMe: { type: Boolean, default: undefined, required: false },
targetJson: { type: String, default: undefined, required: false },
reqType: {
type: String as PropType<loadMapOption["reqType"]>,
default: undefined,
},
dynamicMapTheme: { type: Boolean, default: undefined, required: false },
callback: {
type: Function as PropType<loadMapOption["callback"]>,
default: undefined,
},
startYear: { type: Number, default: undefined, required: false },
modelValue: {
type: Object as PropType<MapCityParsed>,
default: undefined,
required: false,
},
},
emits: ["update:modelValue", "loaded"],
setup(props, { emit }) {
const uuid = uuidv4();
const modelValue = ref(props.modelValue);
onMounted(async () => {
const option: loadMapOption = {
isDetailMap: props.isDetailMap,
clickableAll: props.clickableAll,
selectCallback: (city) => {
modelValue.value = city;
emit("update:modelValue", city);
},
hrefTemplate: props.hrefTemplate,
useCachedMap: props.useCachedMap,
year: props.year,
month: props.month,
aux: props.aux,
neutralView: props.neutralView,
showMe: props.showMe,
targetJson: props.targetJson,
reqType: props.reqType,
dynamicMapTheme: props.dynamicMapTheme,
callback: (a, rawObject) => {
emit("loaded", [a, rawObject]);
},
startYear: props.startYear,
};
await reloadWorldMap(option, `#${uuid}`);
});
return {
uuid,
};
},
});
</script>
+92 -65
View File
@@ -1,13 +1,17 @@
<template>
<TopBackBar v-model:searchable="searchable" :title="commandName" type="chief" />
<div class="bg0">
<MapLegacyTemplate
<div v-if="asyncReady" class="bg0">
<MapViewer
v-if="map"
v-model="selectedCityObj"
:server-nick="serverNick"
:serverID="serverID"
:map-name="unwrap(gameConstStore?.gameConst.mapName)"
:mapData="map"
:isDetailMap="false"
:clickableAll="true"
:neutralView="true"
:useCachedMap="true"
:mapName="mapName"
:cityPosition="cityPosition"
:formatCityInfo="formatCityInfoText"
:image-path="imagePath"
/>
<div>
타국에게 원조합니다.<br />
@@ -71,16 +75,9 @@
</template>
<script lang="ts">
import MapLegacyTemplate, { type MapCityParsed } from "@/components/MapLegacyTemplate.vue";
import SelectNation from "@/processing/SelectNation.vue";
import SelectAmount from "@/processing/SelectAmount.vue";
import { defineComponent, ref } from "vue";
import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
import { getProcSearchable, type procNationItem, type procNationList } from "../processingRes";
declare const staticValues: {
serverNick: string;
serverID: string;
mapName: string;
commandName: string;
};
@@ -100,60 +97,90 @@ declare const procRes: {
amountGuide: number[];
};
export default defineComponent({
components: {
MapLegacyTemplate,
SelectNation,
SelectAmount,
TopBackBar,
BottomBar,
},
setup() {
const nationList = new Map<number, procNationItem>();
for (const nationItem of procRes.nationList) {
nationList.set(nationItem.id, nationItem);
}
declare const getCityPosition: () => CityPositionMap;
declare const formatCityInfo: (city: MapCityParsedRaw) => MapCityParsed;
</script>
const goldAmount = ref(procRes.minAmount);
const riceAmount = ref(procRes.minAmount);
<script lang="ts" setup>
import MapViewer, { type CityPositionMap, type MapCityParsed, type MapCityParsedRaw } from "@/components/MapViewer.vue";
import SelectNation from "@/processing/SelectNation.vue";
import SelectAmount from "@/processing/SelectAmount.vue";
import { ref, watch, onMounted, provide } from "vue";
import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
import { getProcSearchable, type procNationItem, type procNationList } from "../processingRes";
import type { MapResult } from "@/defs";
import { SammoAPI } from "@/SammoAPI";
import { getGameConstStore, type GameConstStore } from "@/GameConstStore";
const selectedNationID = ref(procRes.nationList[0]?.id);
const selectedCityObj = ref(); //mapping용
const serverNick = staticValues.serverNick;
const serverID = staticValues.serverID;
async function submit(e: Event) {
const event = new CustomEvent<Args>("customSubmit", {
detail: {
amountList: [goldAmount.value, riceAmount.value],
destNationID: selectedNationID.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
const cityPosition = getCityPosition();
const formatCityInfoText = formatCityInfo;
const imagePath = window.pathConfig.gameImage;
return {
searchable: getProcSearchable(),
mapName: staticValues.mapName,
goldAmount,
riceAmount,
nationList,
selectedNationID,
selectedCityObj,
currentNationLevel: procRes.currentNationLevel,
levelInfo: procRes.levelInfo,
minAmount: ref(procRes.minAmount),
maxAmount: ref(procRes.maxAmount),
amountGuide: procRes.amountGuide,
commandName: staticValues.commandName,
submit,
};
},
watch: {
selectedCityObj(city: MapCityParsed) {
if (!city.nationID) {
return;
}
this.selectedNationID = city.nationID;
const asyncReady = ref<boolean>(false);
const gameConstStore = ref<GameConstStore>();
provide("gameConstStore", gameConstStore);
const storeP = getGameConstStore().then((store) => {
gameConstStore.value = store;
});
void Promise.all([storeP]).then(() => {
asyncReady.value = true;
});
const nationList = new Map<number, procNationItem>();
for (const nationItem of procRes.nationList) {
nationList.set(nationItem.id, nationItem);
}
const goldAmount = ref(procRes.minAmount);
const riceAmount = ref(procRes.minAmount);
const currentNationLevel = procRes.currentNationLevel;
const levelInfo = procRes.levelInfo;
const minAmount = ref(procRes.minAmount);
const maxAmount = ref(procRes.maxAmount);
const amountGuide = procRes.amountGuide;
const selectedNationID = ref(procRes.nationList[0]?.id);
const map = ref<MapResult>();
async function submit(e: Event) {
const event = new CustomEvent<Args>("customSubmit", {
detail: {
amountList: [goldAmount.value, riceAmount.value],
destNationID: selectedNationID.value,
},
},
});
unwrap(e.target).dispatchEvent(event);
}
const searchable = getProcSearchable();
const selectedCityObj = ref<MapCityParsed>();
const commandName = ref(staticValues.commandName);
watch(selectedCityObj, (city?: MapCityParsed) => {
if (city === undefined) {
return;
}
if (city.nationID === undefined) {
return;
}
selectedNationID.value = city.nationID;
});
onMounted(async () => {
try {
map.value = await SammoAPI.Global.GetMap({ neutralView: 0, showMe: 1 });
} catch (e) {
console.error(e);
}
});
</script>
+119 -82
View File
@@ -1,13 +1,17 @@
<template>
<TopBackBar v-model:searchable="searchable" :title="commandName" type="chief" />
<div class="bg0">
<MapLegacyTemplate
<div v-if="asyncReady" class="bg0">
<MapViewer
v-if="map"
v-model="selectedCityObj"
:server-nick="serverNick"
:serverID="serverID"
:map-name="unwrap(gameConstStore?.gameConst.mapName)"
:mapData="map"
:isDetailMap="false"
:clickableAll="true"
:neutralView="true"
:useCachedMap="true"
:mapName="mapName"
:cityPosition="cityPosition"
:formatCityInfo="formatCityInfoText"
:image-path="imagePath"
/>
<div>
@@ -42,10 +46,28 @@
</template>
<script lang="ts">
import MapLegacyTemplate, { type MapCityParsed } from "@/components/MapLegacyTemplate.vue";
declare const staticValues: {
serverNick: string;
serverID: string;
currentCity: number;
commandName: string;
};
declare const procRes: {
troops: procTroopList;
generals: procGeneralRawItemList;
generalsKey: procGeneralKey[];
};
declare const getCityPosition: () => CityPositionMap;
declare const formatCityInfo: (city: MapCityParsedRaw) => MapCityParsed;
</script>
<script lang="ts" setup>
import MapViewer, { type CityPositionMap, type MapCityParsed, type MapCityParsedRaw } from "@/components/MapViewer.vue";
import SelectCity from "@/processing/SelectCity.vue";
import SelectGeneral from "@/processing/SelectGeneral.vue";
import { defineComponent, ref } from "vue";
import { ref, watch, onMounted, provide } from "vue";
import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
@@ -59,89 +81,104 @@ import {
type procTroopList,
} from "../processingRes";
import { getNpcColor } from "@/common_legacy";
import type { MapResult } from '@/defs';
import { SammoAPI } from '@/SammoAPI';
import { getGameConstStore, type GameConstStore } from '@/GameConstStore';
declare const staticValues: {
mapName: string;
currentCity: number;
commandName: string;
};
const serverNick = staticValues.serverNick;
const serverID = staticValues.serverID;
declare const procRes: {
distanceList: Record<number, number[]>;
cities: [number, string][];
troops: procTroopList;
generals: procGeneralRawItemList;
generalsKey: procGeneralKey[];
};
const cityPosition = getCityPosition();
const formatCityInfoText = formatCityInfo;
const imagePath = window.pathConfig.gameImage;
export default defineComponent({
components: {
MapLegacyTemplate,
SelectCity,
SelectGeneral,
TopBackBar,
BottomBar,
},
setup() {
const citiesMap = new Map<
number,
{
name: string;
info?: string;
}
>();
for (const [id, name] of procRes.cities) {
citiesMap.set(id, { name });
const asyncReady = ref<boolean>(false);
const gameConstStore = ref<GameConstStore>();
provide("gameConstStore", gameConstStore);
const storeP = getGameConstStore().then((store) => {
gameConstStore.value = store;
});
void Promise.all([storeP]).then(() => {
asyncReady.value = true;
});
const selectedCityID = ref(staticValues.currentCity);
const map = ref<MapResult>();
const citiesMap = ref(
new Map<
number,
{
name: string;
info?: string;
}
const generalList = convertGeneralList(procRes.generalsKey, procRes.generals);
const selectedCityID = ref(staticValues.currentCity);
function selectedCity(cityID: number) {
selectedCityID.value = cityID;
>()
);
watch(gameConstStore, (store)=>{
if(!store){
return;
}
const tmpCitiesMap = new Map<
number,
{
name: string;
info?: string;
}
>();
const selectedGeneralID = ref(generalList[0].no);
for(const city of Object.values(store.cityConst)){
tmpCitiesMap.set(city.id, {
name: city.name,
});
}
citiesMap.value = tmpCitiesMap;
})
function textHelpGeneral(gen: procGeneralItem): string {
const troops = !gen.troopID ? "" : `,${procRes.troops[gen.troopID].name}`;
const nameColor = getNpcColor(gen.npc);
const name = nameColor ? `<span style="color:${nameColor}">${gen.name}</span>` : gen.name;
return `${name} [${citiesMap.get(unwrap(gen.cityID))?.name}${troops}] (${gen.leadership}/${gen.strength}/${
gen.intel
}) <병${unwrap(gen.crew).toLocaleString()}/훈${gen.train}/사${gen.atmos}>`;
}
//TODO: onMount로 이전하고 장수 목록은 실시간으로 받아와야함
const generalList = convertGeneralList(procRes.generalsKey, procRes.generals);
const troops = procRes.troops;
async function submit(e: Event) {
const event = new CustomEvent<Args>("customSubmit", {
detail: {
destCityID: selectedCityID.value,
destGeneralID: selectedGeneralID.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
const selectedGeneralID = ref(generalList[0].no);
return {
searchable: getProcSearchable(),
mapName: ref(staticValues.mapName),
citiesMap: ref(citiesMap),
selectedCityID,
selectedGeneralID,
selectedCityObj: ref(undefined as MapCityParsed | undefined),
distanceList: procRes.distanceList,
troops: procRes.troops,
generalList,
commandName: staticValues.commandName,
selectedCity,
textHelpGeneral,
submit,
};
},
watch: {
selectedCityObj(city: MapCityParsed) {
this.selectedCityID = city.id;
function textHelpGeneral(gen: procGeneralItem): string {
const troops = !gen.troopID ? "" : `,${procRes.troops[gen.troopID].name}`;
const nameColor = getNpcColor(gen.npc);
const name = nameColor ? `<span style="color:${nameColor}">${gen.name}</span>` : gen.name;
return `${name} [${citiesMap.value.get(unwrap(gen.cityID))?.name}${troops}] (${gen.leadership}/${gen.strength}/${
gen.intel
}) <병${unwrap(gen.crew).toLocaleString()}/훈${gen.train}/사${gen.atmos}>`;
}
async function submit(e: Event) {
const event = new CustomEvent<Args>("customSubmit", {
detail: {
destCityID: selectedCityID.value,
destGeneralID: selectedGeneralID.value,
},
},
});
unwrap(e.target).dispatchEvent(event);
}
const searchable = getProcSearchable();
const selectedCityObj = ref<MapCityParsed>();
const commandName = ref(staticValues.commandName);
watch(selectedCityObj, (city?: MapCityParsed) => {
if (city === undefined) {
return;
}
selectedCityID.value = city.id;
});
onMounted(async () => {
try{
map.value = await SammoAPI.Global.GetMap({neutralView:0, showMe: 1});
}
catch(e){
console.error(e);
}
});
</script>
@@ -1,13 +1,17 @@
<template>
<TopBackBar v-model:searchable="searchable" :title="commandName" type="chief" />
<div class="bg0">
<MapLegacyTemplate
<div v-if="asyncReady" class="bg0">
<MapViewer
v-if="map"
v-model="selectedCityObj"
:server-nick="serverNick"
:serverID="serverID"
:map-name="unwrap(gameConstStore?.gameConst.mapName)"
:mapData="map"
:isDetailMap="false"
:clickableAll="true"
:neutralView="true"
:useCachedMap="true"
:mapName="mapName"
:cityPosition="cityPosition"
:formatCityInfo="formatCityInfoText"
:image-path="imagePath"
/>
<div>
@@ -50,19 +54,12 @@
</template>
<script lang="ts">
import MapLegacyTemplate, { type MapCityParsed } from "@/components/MapLegacyTemplate.vue";
import SelectNation from "@/processing/SelectNation.vue";
import { defineComponent, ref } from "vue";
import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
import { getProcSearchable, type procNationItem, type procNationList } from "../processingRes";
declare const staticValues: {
mapName: string,
commandName: string,
}
serverNick: string;
serverID: string;
mapName: string;
commandName: string;
};
declare const procRes: {
nationList: procNationList;
@@ -72,62 +69,88 @@ declare const procRes: {
month: number;
};
export default defineComponent({
components: {
MapLegacyTemplate,
SelectNation,
TopBackBar,
BottomBar,
},
setup() {
const nationList = new Map<number, procNationItem>();
for (const nationItem of procRes.nationList) {
nationList.set(nationItem.id, nationItem);
}
declare const getCityPosition: () => CityPositionMap;
declare const formatCityInfo: (city: MapCityParsedRaw) => MapCityParsed;
</script>
const selectedNationID = ref(procRes.nationList[0].id);
const selectedCityObj = ref(); //mapping용
<script lang="ts" setup>
import MapViewer, { type CityPositionMap, type MapCityParsed, type MapCityParsedRaw } from "@/components/MapViewer.vue";
import SelectNation from "@/processing/SelectNation.vue";
import { ref, watch, onMounted, provide } from "vue";
import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
import { getProcSearchable, type procNationItem, type procNationList } from "../processingRes";
import type { MapResult } from "@/defs";
import { SammoAPI } from "@/SammoAPI";
import { getGameConstStore, type GameConstStore } from "@/GameConstStore";
const selectedYear = ref(procRes.minYear);
const selectedMonth = ref(procRes.month);
function selectedNation(nationID: number) {
selectedNationID.value = nationID;
}
const serverNick = staticValues.serverNick;
const serverID = staticValues.serverID;
async function submit(e: Event) {
const event = new CustomEvent<Args>("customSubmit", {
detail: {
destNationID: selectedNationID.value,
year: selectedYear.value,
month: selectedMonth.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
const cityPosition = getCityPosition();
const formatCityInfoText = formatCityInfo;
const imagePath = window.pathConfig.gameImage;
return {
searchable: getProcSearchable(),
...procRes,
selectedYear,
selectedMonth,
mapName: staticValues.mapName,
nationList: ref(nationList),
selectedCityObj,
selectedNationID,
commandName: staticValues.commandName,
selectedNation,
submit,
};
},
watch: {
selectedCityObj(city: MapCityParsed) {
if (!city.nationID) {
return;
}
this.selectedNationID = city.nationID;
const asyncReady = ref<boolean>(false);
const gameConstStore = ref<GameConstStore>();
provide("gameConstStore", gameConstStore);
const storeP = getGameConstStore().then((store) => {
gameConstStore.value = store;
});
void Promise.all([storeP]).then(() => {
asyncReady.value = true;
});
const nationList = new Map<number, procNationItem>();
for (const nationItem of procRes.nationList) {
nationList.set(nationItem.id, nationItem);
}
const selectedNationID = ref(procRes.nationList[0].id);
const map = ref<MapResult>();
const minYear = procRes.minYear;
const maxYear = procRes.maxYear;
const selectedYear = ref(procRes.minYear);
const selectedMonth = ref(procRes.month);
async function submit(e: Event) {
const event = new CustomEvent<Args>("customSubmit", {
detail: {
destNationID: selectedNationID.value,
year: selectedYear.value,
month: selectedMonth.value,
},
},
});
unwrap(e.target).dispatchEvent(event);
}
const searchable = getProcSearchable();
const selectedCityObj = ref<MapCityParsed>();
const commandName = ref(staticValues.commandName);
watch(selectedCityObj, (city?: MapCityParsed) => {
if (city === undefined) {
return;
}
if (city.nationID === undefined) {
return;
}
selectedNationID.value = city.nationID;
});
onMounted(async () => {
try {
map.value = await SammoAPI.Global.GetMap({ neutralView: 0, showMe: 1 });
} catch (e) {
console.error(e);
}
});
</script>
+97 -73
View File
@@ -1,13 +1,17 @@
<template>
<TopBackBar v-model:searchable="searchable" :title="commandName" type="chief" />
<div class="bg0">
<MapLegacyTemplate
<div v-if="asyncReady" class="bg0">
<MapViewer
v-if="map"
v-model="selectedCityObj"
:server-nick="serverNick"
:serverID="serverID"
:map-name="unwrap(gameConstStore?.gameConst.mapName)"
:mapData="map"
:isDetailMap="false"
:clickableAll="true"
:neutralView="true"
:useCachedMap="true"
:mapName="mapName"
:cityPosition="cityPosition"
:formatCityInfo="formatCityInfoText"
:image-path="imagePath"
/>
<div>
선택된 국가에 피장파장을 발동합니다.<br />
@@ -39,16 +43,9 @@
</template>
<script lang="ts">
import MapLegacyTemplate, { type MapCityParsed } from "@/components/MapLegacyTemplate.vue";
import SelectNation from "@/processing/SelectNation.vue";
import { defineComponent, ref } from "vue";
import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
import { getProcSearchable, type procNationItem, type procNationList } from "../processingRes";
declare const staticValues: {
serverNick: string;
serverID: string;
mapName: string;
commandName: string;
};
@@ -67,70 +64,97 @@ declare const procRes: {
>;
};
export default defineComponent({
components: {
MapLegacyTemplate,
SelectNation,
TopBackBar,
BottomBar,
},
setup() {
const nationList = new Map<number, procNationItem>();
for (const nationItem of procRes.nationList) {
nationList.set(nationItem.id, nationItem);
}
declare const getCityPosition: () => CityPositionMap;
declare const formatCityInfo: (city: MapCityParsedRaw) => MapCityParsed;
</script>
<script lang="ts" setup>
import MapViewer, { type CityPositionMap, type MapCityParsed, type MapCityParsedRaw } from "@/components/MapViewer.vue";
import SelectNation from "@/processing/SelectNation.vue";
import { ref, watch, onMounted, provide } from "vue";
import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
import { getProcSearchable, type procNationItem, type procNationList } from "../processingRes";
import type { MapResult } from "@/defs";
import { SammoAPI } from "@/SammoAPI";
import { getGameConstStore, type GameConstStore } from "@/GameConstStore";
const selectedNationID = ref(procRes.nationList[0].id);
const selectedCityObj = ref(); //mapping용
const serverNick = staticValues.serverNick;
const serverID = staticValues.serverID;
const commandTypesOption: { html: string; value: string }[] = [];
for (const [commandTypeID, commandTypeInfo] of Object.entries(procRes.availableCommandTypeList)) {
const notAvailable = commandTypeInfo.remainTurn > 0;
const notAvailableText = notAvailable ? " (불가)" : "";
const name = `${commandTypeInfo.name}${notAvailableText}`;
const html = notAvailable ? `<span style='color:red;'>${name}</span>` : name;
commandTypesOption.push({
html,
value: commandTypeID,
});
}
const cityPosition = getCityPosition();
const formatCityInfoText = formatCityInfo;
const imagePath = window.pathConfig.gameImage;
const selectedCommandID = ref(Object.keys(procRes.availableCommandTypeList)[0]);
const asyncReady = ref<boolean>(false);
const gameConstStore = ref<GameConstStore>();
provide("gameConstStore", gameConstStore);
const storeP = getGameConstStore().then((store) => {
gameConstStore.value = store;
});
function selectedNation(nationID: number) {
selectedNationID.value = nationID;
}
void Promise.all([storeP]).then(() => {
asyncReady.value = true;
});
async function submit(e: Event) {
const event = new CustomEvent<Args>("customSubmit", {
detail: {
destNationID: selectedNationID.value,
commandType: selectedCommandID.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
return {
searchable: getProcSearchable(),
...procRes,
...staticValues,
selectedCommandID,
commandTypesOption,
nationList: ref(nationList),
selectedCityObj,
selectedNationID,
selectedNation,
submit,
};
},
watch: {
selectedCityObj(city: MapCityParsed) {
if (!city.nationID) {
return;
}
this.selectedNationID = city.nationID;
const nationList = new Map<number, procNationItem>();
for (const nationItem of procRes.nationList) {
nationList.set(nationItem.id, nationItem);
}
const selectedNationID = ref(procRes.nationList[0].id);
const map = ref<MapResult>();
const delayCnt = procRes.delayCnt;
const postReqTurn = procRes.postReqTurn;
const commandTypesOption: { html: string; value: string }[] = [];
for (const [commandTypeID, commandTypeInfo] of Object.entries(procRes.availableCommandTypeList)) {
const notAvailable = commandTypeInfo.remainTurn > 0;
const notAvailableText = notAvailable ? " (불가)" : "";
const name = `${commandTypeInfo.name}${notAvailableText}`;
const html = notAvailable ? `<span style='color:red;'>${name}</span>` : name;
commandTypesOption.push({
html,
value: commandTypeID,
});
}
const selectedCommandID = ref(Object.keys(procRes.availableCommandTypeList)[0]);
async function submit(e: Event) {
const event = new CustomEvent<Args>("customSubmit", {
detail: {
destNationID: selectedNationID.value,
commandType: selectedCommandID.value,
},
},
});
unwrap(e.target).dispatchEvent(event);
}
const searchable = getProcSearchable();
const selectedCityObj = ref<MapCityParsed>();
const commandName = ref(staticValues.commandName);
watch(selectedCityObj, (city?: MapCityParsed) => {
if (city === undefined) {
return;
}
if (city.nationID === undefined) {
return;
}
selectedNationID.value = city.nationID;
});
onMounted(async () => {
try {
map.value = await SammoAPI.Global.GetMap({ neutralView: 0, showMe: 1 });
} catch (e) {
console.error(e);
}
});
</script>
+69 -15
View File
@@ -1,13 +1,17 @@
<template>
<TopBackBar v-model:searchable="searchable" :title="commandName" :type="procEntryMode" />
<div class="bg0">
<MapLegacyTemplate
<div v-if="asyncReady" class="bg0">
<MapViewer
v-if="map"
v-model="selectedCityObj"
:server-nick="serverNick"
:serverID="serverID"
:map-name="unwrap(gameConstStore?.gameConst.mapName)"
:mapData="map"
:isDetailMap="false"
:clickableAll="true"
:neutralView="true"
:useCachedMap="true"
:mapName="mapName"
:cityPosition="cityPosition"
:formatCityInfo="formatCityInfoText"
:image-path="imagePath"
/>
<div v-if="commandName == '강행'">
@@ -78,31 +82,58 @@
<script lang="ts">
declare const staticValues: {
mapName: string;
serverNick: string,
serverID: string,
currentCity: number;
commandName: string;
entryInfo: ["General" | "Nation", unknown];
};
declare const procRes: {
distanceList: Record<number, number[]>;
cities: [number, string][];
};
declare const getCityPosition: () => CityPositionMap;
declare const formatCityInfo: (city: MapCityParsedRaw) => MapCityParsed;
</script>
<script lang="ts" setup>
import MapLegacyTemplate, { type MapCityParsed } from "@/components/MapLegacyTemplate.vue";
import MapViewer, { type CityPositionMap, type MapCityParsed, type MapCityParsedRaw} from '@/components/MapViewer.vue';
import SelectCity from "@/processing/SelectCity.vue";
import CityBasedOnDistance from "@/processing/CitiesBasedOnDistance.vue";
import { ref, type Ref, watch } from "vue";
import { ref, type Ref, watch, onMounted, provide } from "vue";
import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
import { pick as JosaPick } from "@util/JosaUtil";
import { getProcSearchable } from "./processingRes";
import type { MapResult } from '@/defs';
import { SammoAPI } from '@/SammoAPI';
import { getGameConstStore, type GameConstStore } from '@/GameConstStore';
const serverNick = staticValues.serverNick;
const serverID = staticValues.serverID;
const cityPosition = getCityPosition();
const formatCityInfoText = formatCityInfo;
const imagePath = window.pathConfig.gameImage;
const asyncReady = ref<boolean>(false);
const gameConstStore = ref<GameConstStore>();
provide("gameConstStore", gameConstStore);
const storeP = getGameConstStore().then((store) => {
gameConstStore.value = store;
});
void Promise.all([storeP]).then(() => {
asyncReady.value = true;
});
const { distanceList } = procRes;
const selectedCityID = ref(staticValues.currentCity);
const map = ref<MapResult>();
const citiesMap = ref(
new Map<
number,
@@ -112,11 +143,26 @@ const citiesMap = ref(
}
>()
);
for (const [id, name] of procRes.cities) {
citiesMap.value.set(id, { name });
}
watch(gameConstStore, (store)=>{
if(!store){
return;
}
const tmpCitiesMap = new Map<
number,
{
name: string;
info?: string;
}
>();
for(const city of Object.values(store.cityConst)){
tmpCitiesMap.set(city.id, {
name: city.name,
});
}
citiesMap.value = tmpCitiesMap;
})
const selectedCityID = ref(staticValues.currentCity);
function selected(cityID: number) {
selectedCityID.value = cityID;
@@ -132,7 +178,6 @@ async function submit(e: Event) {
}
const searchable = getProcSearchable();
const mapName = staticValues.mapName;
const procEntryMode: Ref<"chief" | "normal"> = ref(staticValues.entryInfo[0] == "Nation" ? "chief" : "normal");
const selectedCityObj = ref<MapCityParsed>();
@@ -144,4 +189,13 @@ watch(selectedCityObj, (city?: MapCityParsed) => {
}
selectedCityID.value = city.id;
});
onMounted(async () => {
try{
map.value = await SammoAPI.Global.GetMap({neutralView:0, showMe: 1});
}
catch(e){
console.error(e);
}
});
</script>
+93 -61
View File
@@ -1,13 +1,17 @@
<template>
<TopBackBar v-model:searchable="searchable" :title="commandName" :type="procEntryMode" />
<div class="bg0">
<MapLegacyTemplate
<div v-if="asyncReady" class="bg0">
<MapViewer
v-if="map"
v-model="selectedCityObj"
:server-nick="serverNick"
:serverID="serverID"
:map-name="unwrap(gameConstStore?.gameConst.mapName)"
:mapData="map"
:isDetailMap="false"
:clickableAll="true"
:neutralView="true"
:useCachedMap="true"
:mapName="mapName"
:cityPosition="cityPosition"
:formatCityInfo="formatCityInfoText"
:image-path="imagePath"
/>
<div v-if="commandName == '선전포고'">
@@ -66,17 +70,9 @@
</template>
<script lang="ts">
import MapLegacyTemplate, { type MapCityParsed } from "@/components/MapLegacyTemplate.vue";
import SelectNation from "@/processing/SelectNation.vue";
import { defineComponent, ref } from "vue";
import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
import { getProcSearchable, type procNationItem, type procNationList } from "./processingRes";
declare const staticValues: {
mapName: string;
serverNick: string;
serverID: string;
commandName: string;
entryInfo: ["General" | "Nation", unknown];
};
@@ -85,55 +81,91 @@ declare const procRes: {
startYear: number;
};
export default defineComponent({
components: {
MapLegacyTemplate,
SelectNation,
TopBackBar,
BottomBar,
declare const getCityPosition: () => CityPositionMap;
declare const formatCityInfo: (city: MapCityParsedRaw) => MapCityParsed;
</script>
<script lang="ts" setup>
import MapViewer, { type CityPositionMap, type MapCityParsed, type MapCityParsedRaw } from "@/components/MapViewer.vue";
import SelectNation from "@/processing/SelectNation.vue";
import { ref, type Ref, watch, onMounted, provide } from "vue";
import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
import { getProcSearchable, type procNationItem, type procNationList } from "./processingRes";
import { getGameConstStore, type GameConstStore } from "@/GameConstStore";
import { SammoAPI } from "@/SammoAPI";
import type { MapResult } from "@/defs";
const serverNick = staticValues.serverNick;
const serverID = staticValues.serverID;
const startYear = procRes.startYear;
const cityPosition = getCityPosition();
const formatCityInfoText = formatCityInfo;
const imagePath = window.pathConfig.gameImage;
const asyncReady = ref<boolean>(false);
const gameConstStore = ref<GameConstStore>();
provide("gameConstStore", gameConstStore);
const storeP = getGameConstStore().then((store) => {
gameConstStore.value = store;
});
void Promise.all([storeP]).then(() => {
asyncReady.value = true;
});
const nationList = ref(new Map<number, procNationItem>());
watch(
() => procRes.nationList,
(newNationList) => {
const tmpNationList = new Map<number, procNationItem>();
for (const nationItem of newNationList) {
tmpNationList.set(nationItem.id, nationItem);
}
nationList.value = tmpNationList;
},
setup() {
const nationList = new Map<number, procNationItem>();
for (const nationItem of procRes.nationList) {
nationList.set(nationItem.id, nationItem);
}
{ immediate: true }
);
const selectedNationID = ref(procRes.nationList[0].id);
const selectedCityObj = ref(); //mapping용
const selectedNationID = ref(procRes.nationList[0].id);
function selectedNation(nationID: number) {
selectedNationID.value = nationID;
}
const map = ref<MapResult>();
async function submit(e: Event) {
const event = new CustomEvent<Args>("customSubmit", {
detail: {
destNationID: selectedNationID.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
return {
procEntryMode: (staticValues.entryInfo[0] == "Nation" ? "chief" : "normal") as 'chief'|'normal',
searchable: getProcSearchable(),
startYear: procRes.startYear,
mapName: staticValues.mapName,
nationList: ref(nationList),
selectedCityObj,
selectedNationID,
commandName: staticValues.commandName,
selectedNation,
submit,
};
},
watch: {
selectedCityObj(city: MapCityParsed) {
if (!city.nationID) {
return;
}
this.selectedNationID = city.nationID;
async function submit(e: Event) {
const event = new CustomEvent<Args>("customSubmit", {
detail: {
destNationID: selectedNationID.value,
},
},
});
unwrap(e.target).dispatchEvent(event);
}
const searchable = getProcSearchable();
const procEntryMode: Ref<"chief" | "normal"> = ref(staticValues.entryInfo[0] == "Nation" ? "chief" : "normal");
const selectedCityObj = ref<MapCityParsed>();
const commandName = ref(staticValues.commandName);
watch(selectedCityObj, (city?: MapCityParsed) => {
if (city === undefined) {
return;
}
if(city.nationID === undefined){
return;
}
selectedNationID.value = city.nationID;
});
onMounted(async () => {
try{
map.value = await SammoAPI.Global.GetMap({neutralView:0, showMe: 1});
}
catch(e){
console.error(e);
}
});
</script>