Add mock GPS simulator and configurable location sources
This commit is contained in:
@@ -18,6 +18,7 @@ type MapPageData = MapEngineViewState & {
|
||||
statusBarHeight: number
|
||||
topInsetHeight: number
|
||||
hudPanelIndex: number
|
||||
mockBridgeUrlDraft: string
|
||||
panelTimerText: string
|
||||
panelMileageText: string
|
||||
panelDistanceValueText: string
|
||||
@@ -30,7 +31,7 @@ type MapPageData = MapEngineViewState & {
|
||||
showRightButtonGroups: boolean
|
||||
showBottomDebugButton: boolean
|
||||
}
|
||||
const INTERNAL_BUILD_VERSION = 'map-build-166'
|
||||
const INTERNAL_BUILD_VERSION = 'map-build-172'
|
||||
const REMOTE_GAME_CONFIG_URL = 'https://oss-mbh5.colormaprun.com/wxmini/test/game.json'
|
||||
let mapEngine: MapEngine | null = null
|
||||
function buildSideButtonVisibility(mode: SideButtonMode) {
|
||||
@@ -105,6 +106,14 @@ Page({
|
||||
panelProgressText: '0/0',
|
||||
gameSessionStatus: 'idle',
|
||||
gameModeText: '顺序赛',
|
||||
locationSourceMode: 'real',
|
||||
locationSourceText: '真实定位',
|
||||
mockBridgeConnected: false,
|
||||
mockBridgeStatusText: '未连接',
|
||||
mockBridgeUrlText: 'wss://gs.gotomars.xyz/mock-gps',
|
||||
mockBridgeUrlDraft: 'wss://gs.gotomars.xyz/mock-gps',
|
||||
mockCoordText: '--',
|
||||
mockSpeedText: '--',
|
||||
panelSpeedValueText: '0',
|
||||
panelTelemetryTone: 'blue',
|
||||
panelHeartRateZoneNameText: '--',
|
||||
@@ -151,7 +160,19 @@ Page({
|
||||
|
||||
mapEngine = new MapEngine(INTERNAL_BUILD_VERSION, {
|
||||
onData: (patch) => {
|
||||
this.setData(patch)
|
||||
const nextPatch = patch as Partial<MapPageData>
|
||||
if (
|
||||
typeof nextPatch.mockBridgeUrlText === 'string'
|
||||
&& this.data.mockBridgeUrlDraft === this.data.mockBridgeUrlText
|
||||
) {
|
||||
this.setData({
|
||||
...nextPatch,
|
||||
mockBridgeUrlDraft: nextPatch.mockBridgeUrlText,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.setData(nextPatch)
|
||||
},
|
||||
})
|
||||
|
||||
@@ -170,6 +191,14 @@ Page({
|
||||
panelProgressText: '0/0',
|
||||
gameSessionStatus: 'idle',
|
||||
gameModeText: '顺序赛',
|
||||
locationSourceMode: 'real',
|
||||
locationSourceText: '真实定位',
|
||||
mockBridgeConnected: false,
|
||||
mockBridgeStatusText: '未连接',
|
||||
mockBridgeUrlText: 'wss://gs.gotomars.xyz/mock-gps',
|
||||
mockBridgeUrlDraft: 'wss://gs.gotomars.xyz/mock-gps',
|
||||
mockCoordText: '--',
|
||||
mockSpeedText: '--',
|
||||
panelSpeedValueText: '0',
|
||||
panelTelemetryTone: 'blue',
|
||||
panelHeartRateZoneNameText: '--',
|
||||
@@ -382,6 +411,42 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
handleSetRealLocationMode() {
|
||||
if (mapEngine) {
|
||||
mapEngine.handleSetRealLocationMode()
|
||||
}
|
||||
},
|
||||
|
||||
handleSetMockLocationMode() {
|
||||
if (mapEngine) {
|
||||
mapEngine.handleSetMockLocationMode()
|
||||
}
|
||||
},
|
||||
|
||||
handleConnectMockLocationBridge() {
|
||||
if (mapEngine) {
|
||||
mapEngine.handleConnectMockLocationBridge()
|
||||
}
|
||||
},
|
||||
|
||||
handleMockBridgeUrlInput(event: WechatMiniprogram.Input) {
|
||||
this.setData({
|
||||
mockBridgeUrlDraft: event.detail.value,
|
||||
})
|
||||
},
|
||||
|
||||
handleSaveMockBridgeUrl() {
|
||||
if (mapEngine) {
|
||||
mapEngine.handleSetMockLocationBridgeUrl(this.data.mockBridgeUrlDraft)
|
||||
}
|
||||
},
|
||||
|
||||
handleDisconnectMockLocationBridge() {
|
||||
if (mapEngine) {
|
||||
mapEngine.handleDisconnectMockLocationBridge()
|
||||
}
|
||||
},
|
||||
|
||||
handleConnectHeartRate() {
|
||||
if (mapEngine) {
|
||||
mapEngine.handleConnectHeartRate()
|
||||
|
||||
Reference in New Issue
Block a user