From f4d67e759e158a2fd69bfabdc1c5a756a1464690 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Fri, 22 Apr 2022 00:36:25 +0900 Subject: [PATCH] =?UTF-8?q?refac:=20MapViewer=EC=97=90=EC=84=9C=20modelVal?= =?UTF-8?q?ue=EB=A5=BC=20Legacy=20=EB=B2=84=EC=A0=84=EA=B3=BC=20=EB=A7=9E?= =?UTF-8?q?=EC=B6=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/ts/PageCachedMap.vue | 2 +- hwe/ts/PageGlobalDiplomacy.vue | 2 +- hwe/ts/PageHistory.vue | 2 +- hwe/ts/components/MapViewer.vue | 30 +++++++++++++++++++----------- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/hwe/ts/PageCachedMap.vue b/hwe/ts/PageCachedMap.vue index 065a5029..c37859b4 100644 --- a/hwe/ts/PageCachedMap.vue +++ b/hwe/ts/PageCachedMap.vue @@ -7,7 +7,7 @@ :server-nick="serverNick" :serverID="serverID" :map-name="unwrap(gameConstStore?.gameConst.mapName)" - :model-value="cachedMap" + :map-data="cachedMap" :is-detail-map="true" :city-position="cityPosition" :format-city-info="formatCityInfoText" diff --git a/hwe/ts/PageGlobalDiplomacy.vue b/hwe/ts/PageGlobalDiplomacy.vue index 777a49fe..0fd12379 100644 --- a/hwe/ts/PageGlobalDiplomacy.vue +++ b/hwe/ts/PageGlobalDiplomacy.vue @@ -119,7 +119,7 @@ :server-nick="serverNick" :serverID="serverID" :map-name="unwrap(gameConstStore?.gameConst.mapName)" - :model-value="map" + :map-data="map" :is-detail-map="true" :city-position="cityPosition" :format-city-info="formatCityInfoText" diff --git a/hwe/ts/PageHistory.vue b/hwe/ts/PageHistory.vue index a2299f91..45eb7372 100644 --- a/hwe/ts/PageHistory.vue +++ b/hwe/ts/PageHistory.vue @@ -16,7 +16,7 @@ :server-nick="serverNick" :serverID="queryServerID" :map-name="unwrap(gameConstStore?.gameConst.mapName)" - :model-value="history.map" + :map-data="history.map" :is-detail-map="true" :city-position="cityPosition" :format-city-info="formatCityInfoText" diff --git a/hwe/ts/components/MapViewer.vue b/hwe/ts/components/MapViewer.vue index 7013e813..0866631d 100644 --- a/hwe/ts/components/MapViewer.vue +++ b/hwe/ts/components/MapViewer.vue @@ -1,6 +1,6 @@ @@ -193,6 +193,7 @@ const { sourceType: cursorType } = useMouse(); const emit = defineEmits<{ (event: "city-click", city: MapCityParsed, e: MouseEvent | TouchEvent): void; (event: "parsed", drawable: MapCityDrawable): void; + (event: 'update:modelValue', value: MapCityParsed): void; }>(); const isFullWidth = ref(true); @@ -239,17 +240,23 @@ const props = defineProps({ required: true, }, - modelValue: { + mapData: { type: Object as PropType, required: true, }, + + modelValue: { + type: Object as PropType, + default: undefined, + required: false, + } }); -const mapResult = toRef(props, "modelValue"); +const mapData = toRef(props, "mapData"); const mapTheme = toRef(props, "mapName"); function getTitleColor(): string | undefined { - const { startYear, year } = mapResult.value; + const { startYear, year } = mapData.value; if (year < startYear + 1) { return "magenta"; @@ -262,11 +269,11 @@ function getTitleColor(): string | undefined { } } -const drawableMap = ref(convertCityObjs(props.modelValue)); +const drawableMap = ref(convertCityObjs(props.mapData)); const activatedCity = ref(); function getBeginGameLimitTooltip(): string | undefined { - const { startYear, year, month } = mapResult.value; + const { startYear, year, month } = mapData.value; if (year > startYear + 3) return undefined; const [remainYear, remainMonth] = parseYearMonth(joinYearMonth(startYear + 3, 0) - joinYearMonth(year, month)); @@ -281,7 +288,7 @@ function getTitleTooltip(): string { result.push(beginLimit); } - const { startYear, year } = mapResult.value; + const { startYear, year } = mapData.value; const maxTechLevel = gameConstStore.value.gameConst.maxTechLevel; const currentTechLimit = getMaxRelativeTechLevel(startYear, year, maxTechLevel); @@ -297,7 +304,7 @@ function getTitleTooltip(): string { } function getMapSeasonClassName(): string { - const { month } = mapResult.value; + const { month } = mapData.value; if (month <= 3) { return "map_spring"; @@ -422,7 +429,7 @@ function convertCityObjs(obj: MapResult): MapCityDrawable { return result; } watch( - () => props.modelValue, + () => props.mapData, (mapInfo) => { activatedCity.value = undefined; drawableMap.value = convertCityObjs(mapInfo); @@ -446,6 +453,7 @@ function cityClick(city: MapCityParsed, $event: MouseEvent | TouchEvent): void { } } emit("city-click", city, $event); + emit("update:modelValue", city); } function clickOutside($event: MouseEvent): void {