feat(map): 新增小提示组件并替换全局toast为气泡提示

1. 新增SmallTipComp小提示组件与对应预制体
2. 重构天赋页逻辑,将toast提示替换为锚定气泡提示
3. 优化升级按钮的气泡初始化逻辑
4. 调整小提示预制体的尺寸与文案样式
This commit is contained in:
pan
2026-09-01 16:36:12 +08:00
parent 8e1c81adb0
commit 38cc214bd4
5 changed files with 432 additions and 316 deletions

View File

@@ -23,6 +23,7 @@ import {
} from "../common/config/TalentSet";
import { GameEvent } from "../common/config/GameEvent";
import { UIID } from "../common/config/GameUIConfig";
import { SmallTipComp } from "./SmallTipComp";
import { TalentItemComp } from "./TalentItemComp";
import { smc } from "../common/SingletonModuleComp";
import { oops } from "db://oops-framework/core/Oops";
@@ -45,6 +46,9 @@ const TAB_LOCKED_CHILD = "locked";
/** 阶位页签未选中态子节点名(可选;非当前选中页签时显示) */
const TAB_INACTIVE_CHILD = "noactive";
/** 页签/卡片上的 smalltip 气泡节点名 */
const SMALL_TIP_CHILD = "smalltip";
/** TalentsComp —— 天赋加点页组件(阶位 Tab 单屏聚焦) */
@ccclass('TalentsComp')
@ecs.register('Talents', false)
@@ -92,13 +96,13 @@ export class TalentsComp extends CCComp {
/** 是否已完成首次默认阶位选择 */
private inited: boolean = false;
/** 阶位 → 页签节点/文案 映射(onLoad 时装配) */
private tabNodes: Map<TalentTier, { node: Node | null; label: Label | null }> = new Map();
/** 阶位 → 页签节点/文案/气泡 映射(onLoad 时装配) */
private tabNodes: Map<TalentTier, { node: Node | null; label: Label | null; tip: SmallTipComp | null }> = new Map();
protected onLoad(): void {
this.tabNodes.set(TalentTier.Basic, { node: this.tab_basic, label: this.lbl_tab_basic });
this.tabNodes.set(TalentTier.Specialized, { node: this.tab_special, label: this.lbl_tab_special });
this.tabNodes.set(TalentTier.Super, { node: this.tab_super, label: this.lbl_tab_super });
this.tabNodes.set(TalentTier.Basic, { node: this.tab_basic, label: this.lbl_tab_basic, tip: this.getSmallTip(this.tab_basic) });
this.tabNodes.set(TalentTier.Specialized, { node: this.tab_special, label: this.lbl_tab_special, tip: this.getSmallTip(this.tab_special) });
this.tabNodes.set(TalentTier.Super, { node: this.tab_super, label: this.lbl_tab_super, tip: this.getSmallTip(this.tab_super) });
for (const [tier, tab] of this.tabNodes) {
tab.node?.on(NodeEventType.TOUCH_END, () => this.selectTier(tier), this);
@@ -216,26 +220,46 @@ export class TalentsComp extends CCComp {
}
}
/** 卡片点击统一入口:未解锁/已满级直接 toast;其余弹出 CommonPrompt 确认加点,成功后事件驱动刷新 */
/**
* 获取挂载点下的 smalltip 气泡组件(节点缺失或组件未挂时返回 null 并静默跳过提示)
* @param parent 气泡挂载的父节点
*/
private getSmallTip(parent: Node | null): SmallTipComp | null {
const tipNode = parent?.getChildByName(SMALL_TIP_CHILD);
return tipNode ? (tipNode.getComponent(SmallTipComp) ?? tipNode.addComponent(SmallTipComp)) : null;
}
/**
* 在指定节点下弹出 smalltip 气泡提示
* @param anchor 气泡挂载的父节点(优先页签,卡片点击时传卡片节点)
* @param text 提示文案
*/
private showSmallTip(anchor: Node | null, text: string): void {
const tip = this.getSmallTip(anchor);
tip?.show(text);
}
/** 卡片点击统一入口:未解锁/已满级/点数不足走 smalltip 气泡;其余弹出 CommonPrompt 确认加点,成功后事件驱动刷新 */
private onTalentTap(uuid: number): void {
const cfg = TalentSet[uuid];
if (!cfg) return;
const levels = smc.getTalentLevels();
const tab = this.tabNodes.get(cfg.tier);
if (!isTalentTierUnlocked(levels, cfg.tier)) {
const invested = getTalentTierInvestedPoints(levels, (cfg.tier - 1) as TalentTier);
oops.gui.toast(`${TIER_TAB_TEXT[cfg.tier].lockName}投入 ${invested}/${TALENT_TIER_UNLOCK_THRESHOLD} 点解锁本阶`);
this.showSmallTip(tab?.node ?? null, `${TIER_TAB_TEXT[cfg.tier].lockName}投入 ${invested}/${TALENT_TIER_UNLOCK_THRESHOLD} 点解锁本阶`);
return;
}
const lv = smc.getTalentLv(uuid);
if (lv >= cfg.max_lv) {
oops.gui.toast("该天赋已满级");
this.showSmallTip(tab?.node ?? null, "该天赋已满级");
return;
}
const cost = getTalentUpgradeCost(lv);
if (cost <= 0) return;
if (smc.getTalentPoints() < cost) {
oops.gui.toast("天赋点不足");
this.showSmallTip(tab?.node ?? null, "天赋点不足");
return;
}
@@ -249,7 +273,7 @@ export class TalentsComp extends CCComp {
maskClose: true,
okFunc: () => {
if (!smc.upgradeTalent(uuid)) {
oops.gui.toast("天赋点不足");
this.showSmallTip(this.tabNodes.get(cfg.tier)?.node ?? null, "天赋点不足");
}
},
});