完善设置面板并整理动画阶段总结
This commit is contained in:
@@ -29,15 +29,37 @@ type ScaleRulerMajorMarkData = {
|
||||
topPx: number
|
||||
label: string
|
||||
}
|
||||
type SideButtonMode = 'all' | 'left' | 'right' | 'hidden'
|
||||
type SideButtonMode = 'shown' | 'hidden'
|
||||
type SideActionButtonState = 'muted' | 'default' | 'active'
|
||||
type SideButtonPlacement = 'left' | 'right'
|
||||
type CenterScaleRulerAnchorMode = 'screen-center' | 'compass-center'
|
||||
type UserNorthReferenceMode = 'magnetic' | 'true'
|
||||
type CompassTuningProfile = 'smooth' | 'balanced' | 'responsive'
|
||||
type SettingLockKey =
|
||||
| 'lockAnimationLevel'
|
||||
| 'lockSideButtonPlacement'
|
||||
| 'lockAutoRotate'
|
||||
| 'lockCompassTuning'
|
||||
| 'lockScaleRulerVisible'
|
||||
| 'lockScaleRulerAnchor'
|
||||
| 'lockNorthReference'
|
||||
| 'lockHeartRateDevice'
|
||||
type StoredUserSettings = {
|
||||
animationLevel?: AnimationLevel
|
||||
autoRotateEnabled?: boolean
|
||||
compassTuningProfile?: CompassTuningProfile
|
||||
northReferenceMode?: UserNorthReferenceMode
|
||||
sideButtonPlacement?: SideButtonPlacement
|
||||
showCenterScaleRuler?: boolean
|
||||
centerScaleRulerAnchorMode?: CenterScaleRulerAnchorMode
|
||||
lockAnimationLevel?: boolean
|
||||
lockSideButtonPlacement?: boolean
|
||||
lockAutoRotate?: boolean
|
||||
lockCompassTuning?: boolean
|
||||
lockScaleRulerVisible?: boolean
|
||||
lockScaleRulerAnchor?: boolean
|
||||
lockNorthReference?: boolean
|
||||
lockHeartRateDevice?: boolean
|
||||
}
|
||||
type MapPageData = MapEngineViewState & {
|
||||
showDebugPanel: boolean
|
||||
@@ -68,6 +90,16 @@ type MapPageData = MapEngineViewState & {
|
||||
compassTicks: CompassTickData[]
|
||||
compassLabels: CompassLabelData[]
|
||||
sideButtonMode: SideButtonMode
|
||||
sideButtonPlacement: SideButtonPlacement
|
||||
autoRotateEnabled: boolean
|
||||
lockAnimationLevel: boolean
|
||||
lockSideButtonPlacement: boolean
|
||||
lockAutoRotate: boolean
|
||||
lockCompassTuning: boolean
|
||||
lockScaleRulerVisible: boolean
|
||||
lockScaleRulerAnchor: boolean
|
||||
lockNorthReference: boolean
|
||||
lockHeartRateDevice: boolean
|
||||
sideToggleIconSrc: string
|
||||
sideButton2Class: string
|
||||
sideButton4Class: string
|
||||
@@ -334,12 +366,45 @@ function loadStoredUserSettings(): StoredUserSettings {
|
||||
if (normalized.northReferenceMode === 'magnetic' || normalized.northReferenceMode === 'true') {
|
||||
settings.northReferenceMode = normalized.northReferenceMode
|
||||
}
|
||||
if (typeof normalized.autoRotateEnabled === 'boolean') {
|
||||
settings.autoRotateEnabled = normalized.autoRotateEnabled
|
||||
}
|
||||
if (normalized.compassTuningProfile === 'smooth' || normalized.compassTuningProfile === 'balanced' || normalized.compassTuningProfile === 'responsive') {
|
||||
settings.compassTuningProfile = normalized.compassTuningProfile
|
||||
}
|
||||
if (normalized.sideButtonPlacement === 'left' || normalized.sideButtonPlacement === 'right') {
|
||||
settings.sideButtonPlacement = normalized.sideButtonPlacement
|
||||
}
|
||||
if (typeof normalized.showCenterScaleRuler === 'boolean') {
|
||||
settings.showCenterScaleRuler = normalized.showCenterScaleRuler
|
||||
}
|
||||
if (normalized.centerScaleRulerAnchorMode === 'screen-center' || normalized.centerScaleRulerAnchorMode === 'compass-center') {
|
||||
settings.centerScaleRulerAnchorMode = normalized.centerScaleRulerAnchorMode
|
||||
}
|
||||
if (typeof normalized.lockAnimationLevel === 'boolean') {
|
||||
settings.lockAnimationLevel = normalized.lockAnimationLevel
|
||||
}
|
||||
if (typeof normalized.lockSideButtonPlacement === 'boolean') {
|
||||
settings.lockSideButtonPlacement = normalized.lockSideButtonPlacement
|
||||
}
|
||||
if (typeof normalized.lockAutoRotate === 'boolean') {
|
||||
settings.lockAutoRotate = normalized.lockAutoRotate
|
||||
}
|
||||
if (typeof normalized.lockCompassTuning === 'boolean') {
|
||||
settings.lockCompassTuning = normalized.lockCompassTuning
|
||||
}
|
||||
if (typeof normalized.lockScaleRulerVisible === 'boolean') {
|
||||
settings.lockScaleRulerVisible = normalized.lockScaleRulerVisible
|
||||
}
|
||||
if (typeof normalized.lockScaleRulerAnchor === 'boolean') {
|
||||
settings.lockScaleRulerAnchor = normalized.lockScaleRulerAnchor
|
||||
}
|
||||
if (typeof normalized.lockNorthReference === 'boolean') {
|
||||
settings.lockNorthReference = normalized.lockNorthReference
|
||||
}
|
||||
if (typeof normalized.lockHeartRateDevice === 'boolean') {
|
||||
settings.lockHeartRateDevice = normalized.lockHeartRateDevice
|
||||
}
|
||||
return settings
|
||||
} catch {
|
||||
return {}
|
||||
@@ -351,26 +416,24 @@ function persistStoredUserSettings(settings: StoredUserSettings) {
|
||||
wx.setStorageSync(USER_SETTINGS_STORAGE_KEY, settings)
|
||||
} catch {}
|
||||
}
|
||||
|
||||
function toggleStoredSettingLock(settings: StoredUserSettings, key: SettingLockKey): StoredUserSettings {
|
||||
return {
|
||||
...settings,
|
||||
[key]: !settings[key],
|
||||
}
|
||||
}
|
||||
function buildSideButtonVisibility(mode: SideButtonMode) {
|
||||
return {
|
||||
sideButtonMode: mode,
|
||||
showLeftButtonGroup: mode === 'all' || mode === 'left' || mode === 'right',
|
||||
showRightButtonGroups: mode === 'all' || mode === 'right',
|
||||
showBottomDebugButton: mode !== 'hidden',
|
||||
showLeftButtonGroup: mode === 'shown',
|
||||
showRightButtonGroups: false,
|
||||
showBottomDebugButton: true,
|
||||
}
|
||||
}
|
||||
|
||||
function getNextSideButtonMode(currentMode: SideButtonMode): SideButtonMode {
|
||||
if (currentMode === 'all') {
|
||||
return 'left'
|
||||
}
|
||||
if (currentMode === 'left') {
|
||||
return 'right'
|
||||
}
|
||||
if (currentMode === 'right') {
|
||||
return 'hidden'
|
||||
}
|
||||
return 'left'
|
||||
return currentMode === 'shown' ? 'hidden' : 'shown'
|
||||
}
|
||||
function buildCompassTicks(): CompassTickData[] {
|
||||
const ticks: CompassTickData[] = []
|
||||
@@ -409,9 +472,6 @@ function getFallbackStageRect(): MapEngineStageRect {
|
||||
}
|
||||
|
||||
function getSideToggleIconSrc(mode: SideButtonMode): string {
|
||||
if (mode === 'left') {
|
||||
return '../../assets/btn_more2.png'
|
||||
}
|
||||
if (mode === 'hidden') {
|
||||
return '../../assets/btn_more1.png'
|
||||
}
|
||||
@@ -641,6 +701,15 @@ Page({
|
||||
hudPanelIndex: 0,
|
||||
configSourceText: '顺序赛配置',
|
||||
centerScaleRulerAnchorMode: 'screen-center',
|
||||
autoRotateEnabled: false,
|
||||
lockAnimationLevel: false,
|
||||
lockSideButtonPlacement: false,
|
||||
lockAutoRotate: false,
|
||||
lockCompassTuning: false,
|
||||
lockScaleRulerVisible: false,
|
||||
lockScaleRulerAnchor: false,
|
||||
lockNorthReference: false,
|
||||
lockHeartRateDevice: false,
|
||||
gameInfoTitle: '当前游戏',
|
||||
gameInfoSubtitle: '未开始',
|
||||
gameInfoLocalRows: [],
|
||||
@@ -653,6 +722,7 @@ Page({
|
||||
panelDistanceUnitText: '',
|
||||
panelProgressText: '0/0',
|
||||
showPunchHintBanner: true,
|
||||
sideButtonPlacement: 'left',
|
||||
gameSessionStatus: 'idle',
|
||||
gameModeText: '顺序赛',
|
||||
gpsLockEnabled: false,
|
||||
@@ -730,9 +800,9 @@ Page({
|
||||
centerScaleRulerMajorMarks: [],
|
||||
compassTicks: buildCompassTicks(),
|
||||
compassLabels: buildCompassLabels(),
|
||||
...buildSideButtonVisibility('left'),
|
||||
...buildSideButtonVisibility('shown'),
|
||||
...buildSideButtonState({
|
||||
sideButtonMode: 'left',
|
||||
sideButtonMode: 'shown',
|
||||
showGameInfoPanel: false,
|
||||
showSystemSettingsPanel: false,
|
||||
showCenterScaleRuler: false,
|
||||
@@ -787,6 +857,9 @@ Page({
|
||||
} as MapPageData
|
||||
|
||||
const derivedPatch: Partial<MapPageData> = {}
|
||||
if (typeof nextPatch.orientationMode === 'string') {
|
||||
nextData.autoRotateEnabled = nextPatch.orientationMode === 'heading-up'
|
||||
}
|
||||
if (
|
||||
this.data.showCenterScaleRuler
|
||||
&& hasAnyPatchKey(nextPatch as Record<string, unknown>, CENTER_SCALE_RULER_DEP_KEYS)
|
||||
@@ -886,9 +959,19 @@ Page({
|
||||
if (storedUserSettings.animationLevel) {
|
||||
mapEngine.handleSetAnimationLevel(storedUserSettings.animationLevel)
|
||||
}
|
||||
const initialAutoRotateEnabled = storedUserSettings.autoRotateEnabled !== false
|
||||
if (initialAutoRotateEnabled) {
|
||||
mapEngine.handleSetHeadingUpMode()
|
||||
} else {
|
||||
mapEngine.handleSetManualMode()
|
||||
}
|
||||
if (storedUserSettings.compassTuningProfile) {
|
||||
mapEngine.handleSetCompassTuningProfile(storedUserSettings.compassTuningProfile)
|
||||
}
|
||||
if (storedUserSettings.northReferenceMode) {
|
||||
mapEngine.handleSetNorthReferenceMode(storedUserSettings.northReferenceMode)
|
||||
}
|
||||
const initialSideButtonPlacement = storedUserSettings.sideButtonPlacement || 'left'
|
||||
|
||||
mapEngine.setDiagnosticUiEnabled(false)
|
||||
centerScaleRulerInputCache = {
|
||||
@@ -914,6 +997,16 @@ Page({
|
||||
hudPanelIndex: 0,
|
||||
configSourceText: '顺序赛配置',
|
||||
centerScaleRulerAnchorMode: initialCenterScaleRulerAnchorMode,
|
||||
autoRotateEnabled: initialAutoRotateEnabled,
|
||||
lockAnimationLevel: !!storedUserSettings.lockAnimationLevel,
|
||||
lockSideButtonPlacement: !!storedUserSettings.lockSideButtonPlacement,
|
||||
lockAutoRotate: !!storedUserSettings.lockAutoRotate,
|
||||
lockCompassTuning: !!storedUserSettings.lockCompassTuning,
|
||||
lockScaleRulerVisible: !!storedUserSettings.lockScaleRulerVisible,
|
||||
lockScaleRulerAnchor: !!storedUserSettings.lockScaleRulerAnchor,
|
||||
lockNorthReference: !!storedUserSettings.lockNorthReference,
|
||||
lockHeartRateDevice: !!storedUserSettings.lockHeartRateDevice,
|
||||
sideButtonPlacement: initialSideButtonPlacement,
|
||||
gameInfoTitle: '当前游戏',
|
||||
gameInfoSubtitle: '未开始',
|
||||
gameInfoLocalRows: [],
|
||||
@@ -996,9 +1089,9 @@ Page({
|
||||
stageFxClass: '',
|
||||
compassTicks: buildCompassTicks(),
|
||||
compassLabels: buildCompassLabels(),
|
||||
...buildSideButtonVisibility('left'),
|
||||
...buildSideButtonVisibility('shown'),
|
||||
...buildSideButtonState({
|
||||
sideButtonMode: 'left',
|
||||
sideButtonMode: 'shown',
|
||||
showGameInfoPanel: false,
|
||||
showSystemSettingsPanel: false,
|
||||
showCenterScaleRuler: initialShowCenterScaleRuler,
|
||||
@@ -1218,24 +1311,6 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
handleSetCompassTuningSmooth() {
|
||||
if (mapEngine) {
|
||||
mapEngine.handleSetCompassTuningProfile('smooth')
|
||||
}
|
||||
},
|
||||
|
||||
handleSetCompassTuningBalanced() {
|
||||
if (mapEngine) {
|
||||
mapEngine.handleSetCompassTuningProfile('balanced')
|
||||
}
|
||||
},
|
||||
|
||||
handleSetCompassTuningResponsive() {
|
||||
if (mapEngine) {
|
||||
mapEngine.handleSetCompassTuningProfile('responsive')
|
||||
}
|
||||
},
|
||||
|
||||
handleAutoRotateCalibrate() {
|
||||
if (mapEngine) {
|
||||
mapEngine.handleAutoRotateCalibrate()
|
||||
@@ -1338,11 +1413,14 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
handleClearPreferredHeartRateDevice() {
|
||||
if (mapEngine) {
|
||||
mapEngine.handleClearPreferredHeartRateDevice()
|
||||
}
|
||||
},
|
||||
handleClearPreferredHeartRateDevice() {
|
||||
if (this.data.lockHeartRateDevice) {
|
||||
return
|
||||
}
|
||||
if (mapEngine) {
|
||||
mapEngine.handleClearPreferredHeartRateDevice()
|
||||
}
|
||||
},
|
||||
|
||||
handleDebugHeartRateBlue() {
|
||||
if (mapEngine) {
|
||||
@@ -1462,6 +1540,7 @@ Page({
|
||||
const localRows = snapshot.localRows.concat([
|
||||
{ label: '比例尺开关', value: this.data.showCenterScaleRuler ? '开启' : '关闭' },
|
||||
{ label: '比例尺锚点', value: this.data.centerScaleRulerAnchorMode === 'compass-center' ? '指北针圆心' : '屏幕中心' },
|
||||
{ label: '按钮习惯', value: this.data.sideButtonPlacement === 'right' ? '右手' : '左手' },
|
||||
{ label: '比例尺可见', value: this.data.centerScaleRulerVisible ? 'true' : 'false' },
|
||||
{ label: '比例尺中心X', value: `${this.data.centerScaleRulerCenterXPx}px` },
|
||||
{ label: '比例尺零点Y', value: `${this.data.centerScaleRulerZeroYPx}px` },
|
||||
@@ -1575,7 +1654,7 @@ Page({
|
||||
handleSystemSettingsPanelTap() {},
|
||||
|
||||
handleSetAnimationLevelStandard() {
|
||||
if (!mapEngine) {
|
||||
if (this.data.lockAnimationLevel || !mapEngine) {
|
||||
return
|
||||
}
|
||||
mapEngine.handleSetAnimationLevel('standard')
|
||||
@@ -1586,7 +1665,7 @@ Page({
|
||||
},
|
||||
|
||||
handleSetAnimationLevelLite() {
|
||||
if (!mapEngine) {
|
||||
if (this.data.lockAnimationLevel || !mapEngine) {
|
||||
return
|
||||
}
|
||||
mapEngine.handleSetAnimationLevel('lite')
|
||||
@@ -1596,8 +1675,89 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
handleSetSideButtonPlacementLeft() {
|
||||
if (this.data.lockSideButtonPlacement) {
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
sideButtonPlacement: 'left',
|
||||
})
|
||||
persistStoredUserSettings({
|
||||
...loadStoredUserSettings(),
|
||||
sideButtonPlacement: 'left',
|
||||
})
|
||||
},
|
||||
|
||||
handleSetSideButtonPlacementRight() {
|
||||
if (this.data.lockSideButtonPlacement) {
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
sideButtonPlacement: 'right',
|
||||
})
|
||||
persistStoredUserSettings({
|
||||
...loadStoredUserSettings(),
|
||||
sideButtonPlacement: 'right',
|
||||
})
|
||||
},
|
||||
|
||||
handleSetAutoRotateEnabledOn() {
|
||||
if (this.data.lockAutoRotate || !mapEngine) {
|
||||
return
|
||||
}
|
||||
mapEngine.handleSetHeadingUpMode()
|
||||
persistStoredUserSettings({
|
||||
...loadStoredUserSettings(),
|
||||
autoRotateEnabled: true,
|
||||
})
|
||||
},
|
||||
|
||||
handleSetAutoRotateEnabledOff() {
|
||||
if (this.data.lockAutoRotate || !mapEngine) {
|
||||
return
|
||||
}
|
||||
mapEngine.handleSetManualMode()
|
||||
persistStoredUserSettings({
|
||||
...loadStoredUserSettings(),
|
||||
autoRotateEnabled: false,
|
||||
})
|
||||
},
|
||||
|
||||
handleSetCompassTuningSmooth() {
|
||||
if (this.data.lockCompassTuning || !mapEngine) {
|
||||
return
|
||||
}
|
||||
mapEngine.handleSetCompassTuningProfile('smooth')
|
||||
persistStoredUserSettings({
|
||||
...loadStoredUserSettings(),
|
||||
compassTuningProfile: 'smooth',
|
||||
})
|
||||
},
|
||||
|
||||
handleSetCompassTuningBalanced() {
|
||||
if (this.data.lockCompassTuning || !mapEngine) {
|
||||
return
|
||||
}
|
||||
mapEngine.handleSetCompassTuningProfile('balanced')
|
||||
persistStoredUserSettings({
|
||||
...loadStoredUserSettings(),
|
||||
compassTuningProfile: 'balanced',
|
||||
})
|
||||
},
|
||||
|
||||
handleSetCompassTuningResponsive() {
|
||||
if (this.data.lockCompassTuning || !mapEngine) {
|
||||
return
|
||||
}
|
||||
mapEngine.handleSetCompassTuningProfile('responsive')
|
||||
persistStoredUserSettings({
|
||||
...loadStoredUserSettings(),
|
||||
compassTuningProfile: 'responsive',
|
||||
})
|
||||
},
|
||||
|
||||
handleSetNorthReferenceMagnetic() {
|
||||
if (!mapEngine) {
|
||||
if (this.data.lockNorthReference || !mapEngine) {
|
||||
return
|
||||
}
|
||||
mapEngine.handleSetNorthReferenceMode('magnetic')
|
||||
@@ -1608,7 +1768,7 @@ Page({
|
||||
},
|
||||
|
||||
handleSetNorthReferenceTrue() {
|
||||
if (!mapEngine) {
|
||||
if (this.data.lockNorthReference || !mapEngine) {
|
||||
return
|
||||
}
|
||||
mapEngine.handleSetNorthReferenceMode('true')
|
||||
@@ -1618,6 +1778,18 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
handleToggleSettingLock(event: WechatMiniprogram.TouchEvent) {
|
||||
const key = event.currentTarget.dataset.key as SettingLockKey | undefined
|
||||
if (!key) {
|
||||
return
|
||||
}
|
||||
const nextValue = !this.data[key]
|
||||
this.setData({
|
||||
[key]: nextValue,
|
||||
} as Record<string, boolean>)
|
||||
persistStoredUserSettings(toggleStoredSettingLock(loadStoredUserSettings(), key))
|
||||
},
|
||||
|
||||
handleOverlayTouch() {},
|
||||
|
||||
handlePunchAction() {
|
||||
@@ -1674,16 +1846,24 @@ Page({
|
||||
}
|
||||
},
|
||||
handleToggleMapRotateMode() {
|
||||
if (!mapEngine) {
|
||||
if (!mapEngine || this.data.lockAutoRotate) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.data.orientationMode === 'heading-up') {
|
||||
mapEngine.handleSetManualMode()
|
||||
persistStoredUserSettings({
|
||||
...loadStoredUserSettings(),
|
||||
autoRotateEnabled: false,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
mapEngine.handleSetHeadingUpMode()
|
||||
persistStoredUserSettings({
|
||||
...loadStoredUserSettings(),
|
||||
autoRotateEnabled: true,
|
||||
})
|
||||
},
|
||||
handleToggleDebugPanel() {
|
||||
const nextShowDebugPanel = !this.data.showDebugPanel
|
||||
@@ -1788,6 +1968,9 @@ Page({
|
||||
},
|
||||
|
||||
handleSetCenterScaleRulerVisibleOn() {
|
||||
if (this.data.lockScaleRulerVisible) {
|
||||
return
|
||||
}
|
||||
this.applyCenterScaleRulerSettings(true, this.data.centerScaleRulerAnchorMode)
|
||||
persistStoredUserSettings({
|
||||
...loadStoredUserSettings(),
|
||||
@@ -1797,6 +1980,9 @@ Page({
|
||||
},
|
||||
|
||||
handleSetCenterScaleRulerVisibleOff() {
|
||||
if (this.data.lockScaleRulerVisible) {
|
||||
return
|
||||
}
|
||||
this.applyCenterScaleRulerSettings(false, this.data.centerScaleRulerAnchorMode)
|
||||
persistStoredUserSettings({
|
||||
...loadStoredUserSettings(),
|
||||
@@ -1806,6 +1992,9 @@ Page({
|
||||
},
|
||||
|
||||
handleSetCenterScaleRulerAnchorScreenCenter() {
|
||||
if (this.data.lockScaleRulerAnchor) {
|
||||
return
|
||||
}
|
||||
this.applyCenterScaleRulerSettings(this.data.showCenterScaleRuler, 'screen-center')
|
||||
persistStoredUserSettings({
|
||||
...loadStoredUserSettings(),
|
||||
@@ -1815,6 +2004,9 @@ Page({
|
||||
},
|
||||
|
||||
handleSetCenterScaleRulerAnchorCompassCenter() {
|
||||
if (this.data.lockScaleRulerAnchor) {
|
||||
return
|
||||
}
|
||||
this.applyCenterScaleRulerSettings(this.data.showCenterScaleRuler, 'compass-center')
|
||||
persistStoredUserSettings({
|
||||
...loadStoredUserSettings(),
|
||||
|
||||
Reference in New Issue
Block a user