feat: load remote map config and constrain tile bounds

This commit is contained in:
2026-03-20 16:19:12 +08:00
parent 8e6291885d
commit 1ecb4809df
8 changed files with 552 additions and 15 deletions

View File

@@ -1,10 +1,12 @@
import { MapEngine, type MapEngineStageRect, type MapEngineViewState } from '../../engine/map/mapEngine'
import { loadRemoteMapConfig } from '../../utils/remoteMapConfig'
type MapPageData = MapEngineViewState & {
showDebugPanel: boolean
}
const INTERNAL_BUILD_VERSION = 'map-build-75'
const INTERNAL_BUILD_VERSION = 'map-build-82'
const REMOTE_GAME_CONFIG_URL = 'https://oss-mbh5.colormaprun.com/wxmini/test/qyds-001/game.json'
let mapEngine: MapEngine | null = null
@@ -36,6 +38,7 @@ Page({
onReady() {
this.measureStageAndCanvas()
this.loadMapConfigFromRemote()
},
onUnload() {
@@ -45,6 +48,33 @@ Page({
}
},
loadMapConfigFromRemote() {
const currentEngine = mapEngine
if (!currentEngine) {
return
}
loadRemoteMapConfig(REMOTE_GAME_CONFIG_URL)
.then((config) => {
if (mapEngine !== currentEngine) {
return
}
currentEngine.applyRemoteMapConfig(config)
})
.catch((error) => {
if (mapEngine !== currentEngine) {
return
}
const errorMessage = error && error.message ? error.message : '未知错误'
this.setData({
configStatusText: `载入失败: ${errorMessage}`,
statusText: `远程地图配置载入失败: ${errorMessage} (${INTERNAL_BUILD_VERSION})`,
})
})
},
measureStageAndCanvas() {
const page = this
const applyStage = (rawRect?: Partial<WechatMiniprogram.BoundingClientRectCallbackResult>) => {
@@ -179,6 +209,18 @@ Page({

View File

@@ -49,6 +49,14 @@
</view>
<scroll-view class="info-panel" scroll-y enhanced show-scrollbar="true">
<view class="info-panel__row">
<text class="info-panel__label">Build</text>
<text class="info-panel__value">{{buildVersion}}</text>
</view>
<view class="info-panel__row info-panel__row--stack">
<text class="info-panel__label">Config</text>
<text class="info-panel__value">{{configStatusText}}</text>
</view>
<view class="info-panel__row">
<text class="info-panel__label">Heading Mode</text>
<text class="info-panel__value">{{orientationModeText}}</text>
@@ -73,16 +81,11 @@
<text class="info-panel__label">Status</text>
<text class="info-panel__value">{{statusText}}</text>
</view>
<view class="control-row">
<view class="control-chip control-chip--secondary" bindtap="handleToggleDebugPanel">{{showDebugPanel ? '隐藏调试' : '查看调试'}}</view>
</view>
<block wx:if="{{showDebugPanel}}">
<view class="info-panel__row">
<text class="info-panel__label">Build</text>
<text class="info-panel__value">{{buildVersion}}</text>
</view>
<view class="info-panel__row">
<text class="info-panel__label">Renderer</text>
<text class="info-panel__value">{{renderMode}}</text>
@@ -161,3 +164,5 @@
</view>
</scroll-view>
</view>