feat: 支持通用弹窗以及下一题二次确认
This commit is contained in:
@@ -11,6 +11,7 @@ import { ShareManager } from 'db://assets/scripts/utils/ShareManager';
|
||||
import { PassModal } from 'db://assets/prefabs/PassModal';
|
||||
import { WrongModal } from 'db://assets/prefabs/WrongModal';
|
||||
import { TimeoutModal } from 'db://assets/prefabs/TimeoutModal';
|
||||
import { CommonModal } from 'db://assets/prefabs/CommonModal';
|
||||
import { StaminaInfo, NextLevelData, SubmitShareLevel } from 'db://assets/scripts/types/ApiTypes';
|
||||
import { AchievementTitleManager } from 'db://assets/scripts/utils/AchievementTitleManager';
|
||||
import { applyRoundedCorner } from 'db://assets/scripts/utils/roundedMaterial.utils';
|
||||
@@ -191,6 +192,9 @@ export class PageLevel extends BaseView {
|
||||
@property(Prefab)
|
||||
timeoutModalPrefab: Prefab | null = null;
|
||||
|
||||
@property(Prefab)
|
||||
commonModalPrefab: Prefab | null = null;
|
||||
|
||||
/** 主图圆角材质 EffectAsset */
|
||||
@property(EffectAsset)
|
||||
roundedSpriteEffect: EffectAsset | null = null;
|
||||
@@ -266,6 +270,9 @@ export class PageLevel extends BaseView {
|
||||
/** 超时弹窗实例 */
|
||||
private _timeoutModalNode: Node | null = null;
|
||||
|
||||
/** 通用确认弹窗实例 */
|
||||
private _commonModalNode: Node | null = null;
|
||||
|
||||
/** 是否处于分享挑战模式 */
|
||||
private _isShareMode: boolean = false;
|
||||
|
||||
@@ -365,6 +372,7 @@ export class PageLevel extends BaseView {
|
||||
this._closePassModal();
|
||||
this._closeWrongModal();
|
||||
this._closeTimeoutModal();
|
||||
this._closeCommonModal();
|
||||
this._stopStaminaRecoverTimer();
|
||||
|
||||
// 清理事件监听
|
||||
@@ -501,6 +509,7 @@ export class PageLevel extends BaseView {
|
||||
|
||||
// 显示解锁按钮(单个统一按钮)
|
||||
this.showUnlockButton();
|
||||
this._refreshTipsModeUI();
|
||||
|
||||
// 根据答案字数创建输入格
|
||||
if (config.answer) {
|
||||
@@ -929,8 +938,10 @@ export class PageLevel extends BaseView {
|
||||
}
|
||||
|
||||
this.playClickSound();
|
||||
this._recordCurrentShareSubmission();
|
||||
void this.goToNextLevel();
|
||||
this._showShareNextConfirmModal(() => {
|
||||
this._recordCurrentShareSubmission();
|
||||
void this.goToNextLevel();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1119,9 +1130,7 @@ export class PageLevel extends BaseView {
|
||||
if (this.liveNode) {
|
||||
this.liveNode.active = !isPkMode;
|
||||
}
|
||||
if (this.tipsLayout) {
|
||||
this.tipsLayout.active = !isPkMode;
|
||||
}
|
||||
this._refreshTipsModeUI();
|
||||
if (this.pkLevelProgressNode) {
|
||||
this.pkLevelProgressNode.active = isPkMode;
|
||||
}
|
||||
@@ -1136,6 +1145,29 @@ export class PageLevel extends BaseView {
|
||||
this.updatePkLevelProgressLabel();
|
||||
}
|
||||
|
||||
private _refreshTipsModeUI(): void {
|
||||
if (this.tipsLayout) {
|
||||
this.tipsLayout.active = true;
|
||||
}
|
||||
|
||||
if (this._isShareMode) {
|
||||
this.showClue(1);
|
||||
this.hideClue(2);
|
||||
this.hideClue(3);
|
||||
if (this.unLockTipsBtn) {
|
||||
this.unLockTipsBtn.active = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.showClue(1);
|
||||
this.showClue(2);
|
||||
this.showClue(3);
|
||||
if (this.unLockTipsBtn) {
|
||||
this.unLockTipsBtn.active = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务端 level 使用 sortOrder,首关可能为 0;页面展示统一转成从 1 开始的关卡序号
|
||||
*/
|
||||
@@ -1833,8 +1865,10 @@ export class PageLevel extends BaseView {
|
||||
});
|
||||
passModal.setCallbacks({
|
||||
onNextLevel: () => {
|
||||
this._closePassModal();
|
||||
this.goToNextLevel();
|
||||
this._showShareNextConfirmModal(() => {
|
||||
this._closePassModal();
|
||||
void this.goToNextLevel();
|
||||
});
|
||||
},
|
||||
onShare: () => {
|
||||
// 分享后不关闭弹窗,用户可继续点击下一关
|
||||
@@ -2014,9 +2048,11 @@ export class PageLevel extends BaseView {
|
||||
});
|
||||
},
|
||||
onNext: () => {
|
||||
this._closeTimeoutModal();
|
||||
this._recordCurrentShareSubmission();
|
||||
void this.goToNextLevel();
|
||||
this._showShareNextConfirmModal(() => {
|
||||
this._closeTimeoutModal();
|
||||
this._recordCurrentShareSubmission();
|
||||
void this.goToNextLevel();
|
||||
});
|
||||
},
|
||||
onHome: () => {
|
||||
this._closeTimeoutModal();
|
||||
@@ -2046,6 +2082,47 @@ export class PageLevel extends BaseView {
|
||||
}
|
||||
}
|
||||
|
||||
private _closeCommonModal(): void {
|
||||
if (this._commonModalNode && this._commonModalNode.isValid) {
|
||||
this._commonModalNode.destroy();
|
||||
this._commonModalNode = null;
|
||||
console.log('[PageLevel] 关闭通用确认弹窗');
|
||||
}
|
||||
}
|
||||
|
||||
private _showShareNextConfirmModal(onConfirm: () => void): void {
|
||||
if (!this._isShareMode) {
|
||||
onConfirm();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._commonModalNode && this._commonModalNode.isValid) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.commonModalPrefab) {
|
||||
console.warn('[PageLevel] commonModalPrefab 未设置,直接进入下一题');
|
||||
onConfirm();
|
||||
return;
|
||||
}
|
||||
|
||||
const modal = CommonModal.show(this.commonModalPrefab, {
|
||||
title: '切换下一题',
|
||||
content: '确认进入下一题吗?',
|
||||
buttonHint: '确认',
|
||||
zIndex: CommonModal.MODAL_Z_INDEX + 1,
|
||||
onClose: () => {
|
||||
this._commonModalNode = null;
|
||||
},
|
||||
onConfirm: () => {
|
||||
this._commonModalNode = null;
|
||||
onConfirm();
|
||||
},
|
||||
}, this.node.parent ?? this.node);
|
||||
|
||||
this._commonModalNode = modal?.node ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示错误提示
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user