feat: 添加分享模式按钮文案支持,优化通关弹窗功能

This commit is contained in:
richarjiang
2026-05-13 08:28:58 +08:00
parent ef7d1ad0f7
commit b8da554530
3 changed files with 130 additions and 4 deletions

View File

@@ -21,6 +21,8 @@ export interface PassModalTitleInfo {
interface PassModalParams {
levelIndex?: number;
/** 下一步按钮文案,不传时使用 prefab 默认文案 */
nextButtonText?: string;
titleInfo?: PassModalTitleInfo;
/**
* 通关前的称号信息。传入后,本次显示会把进度条从该起点动画到 titleInfo 的终点;
@@ -93,6 +95,9 @@ export class PassModal extends BaseModal {
/** 进度动画所绑定的对象,用于 Tween.stopAllByTarget */
private readonly _progressTweenTarget: { progress: number } = { progress: 0 };
/** 下一步按钮文案,为 null 时保留 prefab 默认值 */
private _nextButtonText: string | null = null;
/** 进度游标 0% 时的本地 X 坐标,使用 prefab 当前摆放位置作为起点 */
private _progressAnchorStartX: number | null = null;
@@ -107,6 +112,11 @@ export class PassModal extends BaseModal {
if (params?.titleInfo) {
this.setTitleInfo(params.titleInfo);
}
if (params && 'nextButtonText' in params) {
this._nextButtonText = params.nextButtonText ?? null;
this._applyNextButtonText();
}
}
/**
@@ -144,6 +154,7 @@ export class PassModal extends BaseModal {
super.onViewShow();
this._updateWidget();
this._refreshTitleView();
this._applyNextButtonText();
this._playSuccessSound();
this._playProgressAnimation();
}
@@ -234,6 +245,17 @@ export class PassModal extends BaseModal {
}
}
private _applyNextButtonText(): void {
if (!this.nextLevelButton || this._nextButtonText === null) {
return;
}
const label = this.nextLevelButton.getChildByName('Label')?.getComponent(Label);
if (label) {
label.string = this._nextButtonText;
}
}
private _applyProgressText(text: string | undefined): void {
if (this.progressLabel && text !== undefined) {
this.progressLabel.string = text;