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 { #container {
width: 500px; width: 500px;
margin: 0 auto; 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> <template>
<TopBackBar v-model:searchable="searchable" :title="commandName" type="chief" /> <TopBackBar v-model:searchable="searchable" :title="commandName" type="chief" />
<div class="bg0"> <div v-if="asyncReady" class="bg0">
<MapLegacyTemplate <MapViewer
v-if="map"
v-model="selectedCityObj" v-model="selectedCityObj"
:server-nick="serverNick"
:serverID="serverID"
:map-name="unwrap(gameConstStore?.gameConst.mapName)"
:mapData="map"
:isDetailMap="false" :isDetailMap="false"
:clickableAll="true" :cityPosition="cityPosition"
:neutralView="true" :formatCityInfo="formatCityInfoText"
:useCachedMap="true" :image-path="imagePath"
:mapName="mapName"
/> />
<div> <div>
타국에게 원조합니다.<br /> 타국에게 원조합니다.<br />
@@ -71,16 +75,9 @@
</template> </template>
<script lang="ts"> <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: { declare const staticValues: {
serverNick: string;
serverID: string;
mapName: string; mapName: string;
commandName: string; commandName: string;
}; };
@@ -100,60 +97,90 @@ declare const procRes: {
amountGuide: number[]; amountGuide: number[];
}; };
export default defineComponent({ declare const getCityPosition: () => CityPositionMap;
components: { declare const formatCityInfo: (city: MapCityParsedRaw) => MapCityParsed;
MapLegacyTemplate, </script>
SelectNation,
SelectAmount,
TopBackBar,
BottomBar,
},
setup() {
const nationList = new Map<number, procNationItem>();
for (const nationItem of procRes.nationList) {
nationList.set(nationItem.id, nationItem);
}
const goldAmount = ref(procRes.minAmount); <script lang="ts" setup>
const riceAmount = ref(procRes.minAmount); 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 serverNick = staticValues.serverNick;
const selectedCityObj = ref(); //mapping용 const serverID = staticValues.serverID;
async function submit(e: Event) { const cityPosition = getCityPosition();
const event = new CustomEvent<Args>("customSubmit", { const formatCityInfoText = formatCityInfo;
detail: { const imagePath = window.pathConfig.gameImage;
amountList: [goldAmount.value, riceAmount.value],
destNationID: selectedNationID.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
return { const asyncReady = ref<boolean>(false);
searchable: getProcSearchable(), const gameConstStore = ref<GameConstStore>();
mapName: staticValues.mapName, provide("gameConstStore", gameConstStore);
goldAmount, const storeP = getGameConstStore().then((store) => {
riceAmount, gameConstStore.value = store;
nationList, });
selectedNationID,
selectedCityObj, void Promise.all([storeP]).then(() => {
currentNationLevel: procRes.currentNationLevel, asyncReady.value = true;
levelInfo: procRes.levelInfo, });
minAmount: ref(procRes.minAmount),
maxAmount: ref(procRes.maxAmount), const nationList = new Map<number, procNationItem>();
amountGuide: procRes.amountGuide, for (const nationItem of procRes.nationList) {
commandName: staticValues.commandName, nationList.set(nationItem.id, nationItem);
submit, }
};
}, const goldAmount = ref(procRes.minAmount);
watch: { const riceAmount = ref(procRes.minAmount);
selectedCityObj(city: MapCityParsed) {
if (!city.nationID) { const currentNationLevel = procRes.currentNationLevel;
return; const levelInfo = procRes.levelInfo;
} const minAmount = ref(procRes.minAmount);
this.selectedNationID = city.nationID; 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> </script>
+119 -82
View File
@@ -1,13 +1,17 @@
<template> <template>
<TopBackBar v-model:searchable="searchable" :title="commandName" type="chief" /> <TopBackBar v-model:searchable="searchable" :title="commandName" type="chief" />
<div class="bg0"> <div v-if="asyncReady" class="bg0">
<MapLegacyTemplate <MapViewer
v-if="map"
v-model="selectedCityObj" v-model="selectedCityObj"
:server-nick="serverNick"
:serverID="serverID"
:map-name="unwrap(gameConstStore?.gameConst.mapName)"
:mapData="map"
:isDetailMap="false" :isDetailMap="false"
:clickableAll="true" :cityPosition="cityPosition"
:neutralView="true" :formatCityInfo="formatCityInfoText"
:useCachedMap="true" :image-path="imagePath"
:mapName="mapName"
/> />
<div> <div>
@@ -42,10 +46,28 @@
</template> </template>
<script lang="ts"> <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 SelectCity from "@/processing/SelectCity.vue";
import SelectGeneral from "@/processing/SelectGeneral.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 { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args"; import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue"; import TopBackBar from "@/components/TopBackBar.vue";
@@ -59,89 +81,104 @@ import {
type procTroopList, type procTroopList,
} from "../processingRes"; } from "../processingRes";
import { getNpcColor } from "@/common_legacy"; import { getNpcColor } from "@/common_legacy";
import type { MapResult } from '@/defs';
import { SammoAPI } from '@/SammoAPI';
import { getGameConstStore, type GameConstStore } from '@/GameConstStore';
declare const staticValues: { const serverNick = staticValues.serverNick;
mapName: string; const serverID = staticValues.serverID;
currentCity: number;
commandName: string;
};
declare const procRes: { const cityPosition = getCityPosition();
distanceList: Record<number, number[]>; const formatCityInfoText = formatCityInfo;
cities: [number, string][]; const imagePath = window.pathConfig.gameImage;
troops: procTroopList;
generals: procGeneralRawItemList;
generalsKey: procGeneralKey[];
};
export default defineComponent({ const asyncReady = ref<boolean>(false);
components: { const gameConstStore = ref<GameConstStore>();
MapLegacyTemplate, provide("gameConstStore", gameConstStore);
SelectCity, const storeP = getGameConstStore().then((store) => {
SelectGeneral, gameConstStore.value = store;
TopBackBar, });
BottomBar,
}, void Promise.all([storeP]).then(() => {
setup() { asyncReady.value = true;
const citiesMap = new Map< });
number,
{ const selectedCityID = ref(staticValues.currentCity);
name: string;
info?: string; const map = ref<MapResult>();
} const citiesMap = ref(
>(); new Map<
for (const [id, name] of procRes.cities) { number,
citiesMap.set(id, { name }); {
name: string;
info?: string;
} }
>()
const generalList = convertGeneralList(procRes.generalsKey, procRes.generals); );
const selectedCityID = ref(staticValues.currentCity); watch(gameConstStore, (store)=>{
if(!store){
function selectedCity(cityID: number) { return;
selectedCityID.value = cityID; }
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 { //TODO: onMount로 이전하고 장수 목록은 실시간으로 받아와야함
const troops = !gen.troopID ? "" : `,${procRes.troops[gen.troopID].name}`; const generalList = convertGeneralList(procRes.generalsKey, procRes.generals);
const nameColor = getNpcColor(gen.npc); const troops = procRes.troops;
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}>`;
}
async function submit(e: Event) { const selectedGeneralID = ref(generalList[0].no);
const event = new CustomEvent<Args>("customSubmit", {
detail: {
destCityID: selectedCityID.value,
destGeneralID: selectedGeneralID.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
return { function textHelpGeneral(gen: procGeneralItem): string {
searchable: getProcSearchable(), const troops = !gen.troopID ? "" : `,${procRes.troops[gen.troopID].name}`;
mapName: ref(staticValues.mapName), const nameColor = getNpcColor(gen.npc);
citiesMap: ref(citiesMap), const name = nameColor ? `<span style="color:${nameColor}">${gen.name}</span>` : gen.name;
selectedCityID, return `${name} [${citiesMap.value.get(unwrap(gen.cityID))?.name}${troops}] (${gen.leadership}/${gen.strength}/${
selectedGeneralID, gen.intel
selectedCityObj: ref(undefined as MapCityParsed | undefined), }) <병${unwrap(gen.crew).toLocaleString()}/훈${gen.train}/사${gen.atmos}>`;
distanceList: procRes.distanceList, }
troops: procRes.troops,
generalList, async function submit(e: Event) {
commandName: staticValues.commandName, const event = new CustomEvent<Args>("customSubmit", {
selectedCity, detail: {
textHelpGeneral, destCityID: selectedCityID.value,
submit, destGeneralID: selectedGeneralID.value,
};
},
watch: {
selectedCityObj(city: MapCityParsed) {
this.selectedCityID = city.id;
}, },
}, });
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> </script>
@@ -1,13 +1,17 @@
<template> <template>
<TopBackBar v-model:searchable="searchable" :title="commandName" type="chief" /> <TopBackBar v-model:searchable="searchable" :title="commandName" type="chief" />
<div class="bg0"> <div v-if="asyncReady" class="bg0">
<MapLegacyTemplate <MapViewer
v-if="map"
v-model="selectedCityObj" v-model="selectedCityObj"
:server-nick="serverNick"
:serverID="serverID"
:map-name="unwrap(gameConstStore?.gameConst.mapName)"
:mapData="map"
:isDetailMap="false" :isDetailMap="false"
:clickableAll="true" :cityPosition="cityPosition"
:neutralView="true" :formatCityInfo="formatCityInfoText"
:useCachedMap="true" :image-path="imagePath"
:mapName="mapName"
/> />
<div> <div>
@@ -50,19 +54,12 @@
</template> </template>
<script lang="ts"> <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: { declare const staticValues: {
mapName: string, serverNick: string;
commandName: string, serverID: string;
} mapName: string;
commandName: string;
};
declare const procRes: { declare const procRes: {
nationList: procNationList; nationList: procNationList;
@@ -72,62 +69,88 @@ declare const procRes: {
month: number; month: number;
}; };
export default defineComponent({ declare const getCityPosition: () => CityPositionMap;
components: { declare const formatCityInfo: (city: MapCityParsedRaw) => MapCityParsed;
MapLegacyTemplate, </script>
SelectNation,
TopBackBar,
BottomBar,
},
setup() {
const nationList = new Map<number, procNationItem>();
for (const nationItem of procRes.nationList) {
nationList.set(nationItem.id, nationItem);
}
const selectedNationID = ref(procRes.nationList[0].id); <script lang="ts" setup>
const selectedCityObj = ref(); //mapping용 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) { const serverNick = staticValues.serverNick;
selectedNationID.value = nationID; const serverID = staticValues.serverID;
}
async function submit(e: Event) { const cityPosition = getCityPosition();
const event = new CustomEvent<Args>("customSubmit", { const formatCityInfoText = formatCityInfo;
detail: { const imagePath = window.pathConfig.gameImage;
destNationID: selectedNationID.value,
year: selectedYear.value,
month: selectedMonth.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
return { const asyncReady = ref<boolean>(false);
searchable: getProcSearchable(), const gameConstStore = ref<GameConstStore>();
...procRes, provide("gameConstStore", gameConstStore);
selectedYear, const storeP = getGameConstStore().then((store) => {
selectedMonth, gameConstStore.value = store;
mapName: staticValues.mapName, });
nationList: ref(nationList),
selectedCityObj, void Promise.all([storeP]).then(() => {
selectedNationID, asyncReady.value = true;
commandName: staticValues.commandName, });
selectedNation,
submit, const nationList = new Map<number, procNationItem>();
}; for (const nationItem of procRes.nationList) {
}, nationList.set(nationItem.id, nationItem);
watch: { }
selectedCityObj(city: MapCityParsed) {
if (!city.nationID) { const selectedNationID = ref(procRes.nationList[0].id);
return; const map = ref<MapResult>();
}
this.selectedNationID = city.nationID; 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> </script>
+97 -73
View File
@@ -1,13 +1,17 @@
<template> <template>
<TopBackBar v-model:searchable="searchable" :title="commandName" type="chief" /> <TopBackBar v-model:searchable="searchable" :title="commandName" type="chief" />
<div class="bg0"> <div v-if="asyncReady" class="bg0">
<MapLegacyTemplate <MapViewer
v-if="map"
v-model="selectedCityObj" v-model="selectedCityObj"
:server-nick="serverNick"
:serverID="serverID"
:map-name="unwrap(gameConstStore?.gameConst.mapName)"
:mapData="map"
:isDetailMap="false" :isDetailMap="false"
:clickableAll="true" :cityPosition="cityPosition"
:neutralView="true" :formatCityInfo="formatCityInfoText"
:useCachedMap="true" :image-path="imagePath"
:mapName="mapName"
/> />
<div> <div>
선택된 국가에 피장파장을 발동합니다.<br /> 선택된 국가에 피장파장을 발동합니다.<br />
@@ -39,16 +43,9 @@
</template> </template>
<script lang="ts"> <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: { declare const staticValues: {
serverNick: string;
serverID: string;
mapName: string; mapName: string;
commandName: string; commandName: string;
}; };
@@ -67,70 +64,97 @@ declare const procRes: {
>; >;
}; };
export default defineComponent({ declare const getCityPosition: () => CityPositionMap;
components: { declare const formatCityInfo: (city: MapCityParsedRaw) => MapCityParsed;
MapLegacyTemplate, </script>
SelectNation, <script lang="ts" setup>
TopBackBar, import MapViewer, { type CityPositionMap, type MapCityParsed, type MapCityParsedRaw } from "@/components/MapViewer.vue";
BottomBar, import SelectNation from "@/processing/SelectNation.vue";
}, import { ref, watch, onMounted, provide } from "vue";
setup() { import { unwrap } from "@/util/unwrap";
const nationList = new Map<number, procNationItem>(); import type { Args } from "@/processing/args";
for (const nationItem of procRes.nationList) { import TopBackBar from "@/components/TopBackBar.vue";
nationList.set(nationItem.id, nationItem); 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 serverNick = staticValues.serverNick;
const selectedCityObj = ref(); //mapping용 const serverID = staticValues.serverID;
const commandTypesOption: { html: string; value: string }[] = []; const cityPosition = getCityPosition();
for (const [commandTypeID, commandTypeInfo] of Object.entries(procRes.availableCommandTypeList)) { const formatCityInfoText = formatCityInfo;
const notAvailable = commandTypeInfo.remainTurn > 0; const imagePath = window.pathConfig.gameImage;
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]); const asyncReady = ref<boolean>(false);
const gameConstStore = ref<GameConstStore>();
provide("gameConstStore", gameConstStore);
const storeP = getGameConstStore().then((store) => {
gameConstStore.value = store;
});
function selectedNation(nationID: number) { void Promise.all([storeP]).then(() => {
selectedNationID.value = nationID; 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 { const nationList = new Map<number, procNationItem>();
searchable: getProcSearchable(), for (const nationItem of procRes.nationList) {
...procRes, nationList.set(nationItem.id, nationItem);
...staticValues, }
selectedCommandID,
commandTypesOption, const selectedNationID = ref(procRes.nationList[0].id);
nationList: ref(nationList),
selectedCityObj, const map = ref<MapResult>();
selectedNationID,
selectedNation, const delayCnt = procRes.delayCnt;
submit, const postReqTurn = procRes.postReqTurn;
};
}, const commandTypesOption: { html: string; value: string }[] = [];
watch: { for (const [commandTypeID, commandTypeInfo] of Object.entries(procRes.availableCommandTypeList)) {
selectedCityObj(city: MapCityParsed) { const notAvailable = commandTypeInfo.remainTurn > 0;
if (!city.nationID) { const notAvailableText = notAvailable ? " (불가)" : "";
return; const name = `${commandTypeInfo.name}${notAvailableText}`;
} const html = notAvailable ? `<span style='color:red;'>${name}</span>` : name;
this.selectedNationID = city.nationID; 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> </script>
+69 -15
View File
@@ -1,13 +1,17 @@
<template> <template>
<TopBackBar v-model:searchable="searchable" :title="commandName" :type="procEntryMode" /> <TopBackBar v-model:searchable="searchable" :title="commandName" :type="procEntryMode" />
<div class="bg0"> <div v-if="asyncReady" class="bg0">
<MapLegacyTemplate <MapViewer
v-if="map"
v-model="selectedCityObj" v-model="selectedCityObj"
:server-nick="serverNick"
:serverID="serverID"
:map-name="unwrap(gameConstStore?.gameConst.mapName)"
:mapData="map"
:isDetailMap="false" :isDetailMap="false"
:clickableAll="true" :cityPosition="cityPosition"
:neutralView="true" :formatCityInfo="formatCityInfoText"
:useCachedMap="true" :image-path="imagePath"
:mapName="mapName"
/> />
<div v-if="commandName == '강행'"> <div v-if="commandName == '강행'">
@@ -78,31 +82,58 @@
<script lang="ts"> <script lang="ts">
declare const staticValues: { declare const staticValues: {
mapName: string; serverNick: string,
serverID: string,
currentCity: number; currentCity: number;
commandName: string; commandName: string;
entryInfo: ["General" | "Nation", unknown]; entryInfo: ["General" | "Nation", unknown];
}; };
declare const procRes: { declare const procRes: {
distanceList: Record<number, number[]>; distanceList: Record<number, number[]>;
cities: [number, string][];
}; };
declare const getCityPosition: () => CityPositionMap;
declare const formatCityInfo: (city: MapCityParsedRaw) => MapCityParsed;
</script> </script>
<script lang="ts" setup> <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 SelectCity from "@/processing/SelectCity.vue";
import CityBasedOnDistance from "@/processing/CitiesBasedOnDistance.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 { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args"; import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue"; import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue"; import BottomBar from "@/components/BottomBar.vue";
import { pick as JosaPick } from "@util/JosaUtil"; import { pick as JosaPick } from "@util/JosaUtil";
import { getProcSearchable } from "./processingRes"; 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 { distanceList } = procRes;
const selectedCityID = ref(staticValues.currentCity);
const map = ref<MapResult>();
const citiesMap = ref( const citiesMap = ref(
new Map< new Map<
number, number,
@@ -112,11 +143,26 @@ const citiesMap = ref(
} }
>() >()
); );
for (const [id, name] of procRes.cities) { watch(gameConstStore, (store)=>{
citiesMap.value.set(id, { name }); 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) { function selected(cityID: number) {
selectedCityID.value = cityID; selectedCityID.value = cityID;
@@ -132,7 +178,6 @@ async function submit(e: Event) {
} }
const searchable = getProcSearchable(); const searchable = getProcSearchable();
const mapName = staticValues.mapName;
const procEntryMode: Ref<"chief" | "normal"> = ref(staticValues.entryInfo[0] == "Nation" ? "chief" : "normal"); const procEntryMode: Ref<"chief" | "normal"> = ref(staticValues.entryInfo[0] == "Nation" ? "chief" : "normal");
const selectedCityObj = ref<MapCityParsed>(); const selectedCityObj = ref<MapCityParsed>();
@@ -144,4 +189,13 @@ watch(selectedCityObj, (city?: MapCityParsed) => {
} }
selectedCityID.value = city.id; selectedCityID.value = city.id;
}); });
onMounted(async () => {
try{
map.value = await SammoAPI.Global.GetMap({neutralView:0, showMe: 1});
}
catch(e){
console.error(e);
}
});
</script> </script>
+93 -61
View File
@@ -1,13 +1,17 @@
<template> <template>
<TopBackBar v-model:searchable="searchable" :title="commandName" :type="procEntryMode" /> <TopBackBar v-model:searchable="searchable" :title="commandName" :type="procEntryMode" />
<div class="bg0"> <div v-if="asyncReady" class="bg0">
<MapLegacyTemplate <MapViewer
v-if="map"
v-model="selectedCityObj" v-model="selectedCityObj"
:server-nick="serverNick"
:serverID="serverID"
:map-name="unwrap(gameConstStore?.gameConst.mapName)"
:mapData="map"
:isDetailMap="false" :isDetailMap="false"
:clickableAll="true" :cityPosition="cityPosition"
:neutralView="true" :formatCityInfo="formatCityInfoText"
:useCachedMap="true" :image-path="imagePath"
:mapName="mapName"
/> />
<div v-if="commandName == '선전포고'"> <div v-if="commandName == '선전포고'">
@@ -66,17 +70,9 @@
</template> </template>
<script lang="ts"> <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: { declare const staticValues: {
mapName: string; serverNick: string;
serverID: string;
commandName: string; commandName: string;
entryInfo: ["General" | "Nation", unknown]; entryInfo: ["General" | "Nation", unknown];
}; };
@@ -85,55 +81,91 @@ declare const procRes: {
startYear: number; startYear: number;
}; };
export default defineComponent({ declare const getCityPosition: () => CityPositionMap;
components: { declare const formatCityInfo: (city: MapCityParsedRaw) => MapCityParsed;
MapLegacyTemplate, </script>
SelectNation, <script lang="ts" setup>
TopBackBar, import MapViewer, { type CityPositionMap, type MapCityParsed, type MapCityParsedRaw } from "@/components/MapViewer.vue";
BottomBar, 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() { { immediate: 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 selectedNationID = ref(procRes.nationList[0].id);
const selectedCityObj = ref(); //mapping용
function selectedNation(nationID: number) { const map = ref<MapResult>();
selectedNationID.value = nationID;
}
async function submit(e: Event) { async function submit(e: Event) {
const event = new CustomEvent<Args>("customSubmit", { const event = new CustomEvent<Args>("customSubmit", {
detail: { detail: {
destNationID: selectedNationID.value, 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;
}, },
}, });
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> </script>