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

@@ -26,10 +26,13 @@
"_components": [ "_components": [
{ {
"__id__": 30 "__id__": 30
},
{
"__id__": 32
} }
], ],
"_prefab": { "_prefab": {
"__id__": 32 "__id__": 34
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -187,8 +190,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 300, "width": 399.6,
"height": 140 "height": 159.6
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@@ -322,7 +325,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": -35.2, "y": -40.1,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@@ -534,7 +537,7 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 84, "width": 149.9,
"height": 54.4 "height": 54.4
}, },
"_anchorPoint": { "_anchorPoint": {
@@ -570,14 +573,14 @@
"b": 255, "b": 255,
"a": 255 "a": 255
}, },
"_string": "卡成升级", "_string": "卡成升级........................",
"_horizontalAlign": 1, "_horizontalAlign": 1,
"_verticalAlign": 1, "_verticalAlign": 1,
"_actualFontSize": 20, "_actualFontSize": 21,
"_fontSize": 20, "_fontSize": 20,
"_fontFamily": "Arial", "_fontFamily": "Arial",
"_lineHeight": 40, "_lineHeight": 23,
"_overflow": 0, "_overflow": 2,
"_enableWrapText": true, "_enableWrapText": true,
"_font": null, "_font": null,
"_isSystemFontUsed": true, "_isSystemFontUsed": true,
@@ -643,8 +646,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 150, "width": 199.8,
"height": 70 "height": 79.8
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@@ -743,6 +746,24 @@
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "1ctkO0TStCjK1FILIEJzwK" "fileId": "1ctkO0TStCjK1FILIEJzwK"
}, },
{
"__type__": "366cayIQXtAzJLimznQOpMz",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 33
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "ffW/hlSrtP1I4iporD0DuU"
},
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {

File diff suppressed because it is too large Load Diff

View File

@@ -146,7 +146,7 @@ export class HerosListComp extends CCComp {
// 确保 smalltip 气泡初始隐藏,避免遮挡按钮触摸(组件缺失时兜底补挂) // 确保 smalltip 气泡初始隐藏,避免遮挡按钮触摸(组件缺失时兜底补挂)
const tipNode = this.upgrade_btn.getChildByName("smalltip") const tipNode = this.upgrade_btn.getChildByName("smalltip")
if (tipNode) { if (tipNode) {
const tip = tipNode.getComponent(SmallTipComp) ?? tipNode.addComponent(SmallTipComp) tipNode.getComponent(SmallTipComp) ?? tipNode.addComponent(SmallTipComp)
tipNode.active = false tipNode.active = false
} }

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "366cac88-417b-40cc-92e2-9b39d03a9333",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -23,6 +23,7 @@ import {
} from "../common/config/TalentSet"; } from "../common/config/TalentSet";
import { GameEvent } from "../common/config/GameEvent"; import { GameEvent } from "../common/config/GameEvent";
import { UIID } from "../common/config/GameUIConfig"; import { UIID } from "../common/config/GameUIConfig";
import { SmallTipComp } from "./SmallTipComp";
import { TalentItemComp } from "./TalentItemComp"; import { TalentItemComp } from "./TalentItemComp";
import { smc } from "../common/SingletonModuleComp"; import { smc } from "../common/SingletonModuleComp";
import { oops } from "db://oops-framework/core/Oops"; import { oops } from "db://oops-framework/core/Oops";
@@ -45,6 +46,9 @@ const TAB_LOCKED_CHILD = "locked";
/** 阶位页签未选中态子节点名(可选;非当前选中页签时显示) */ /** 阶位页签未选中态子节点名(可选;非当前选中页签时显示) */
const TAB_INACTIVE_CHILD = "noactive"; const TAB_INACTIVE_CHILD = "noactive";
/** 页签/卡片上的 smalltip 气泡节点名 */
const SMALL_TIP_CHILD = "smalltip";
/** TalentsComp —— 天赋加点页组件(阶位 Tab 单屏聚焦) */ /** TalentsComp —— 天赋加点页组件(阶位 Tab 单屏聚焦) */
@ccclass('TalentsComp') @ccclass('TalentsComp')
@ecs.register('Talents', false) @ecs.register('Talents', false)
@@ -92,13 +96,13 @@ export class TalentsComp extends CCComp {
/** 是否已完成首次默认阶位选择 */ /** 是否已完成首次默认阶位选择 */
private inited: boolean = false; private inited: boolean = false;
/** 阶位 → 页签节点/文案 映射(onLoad 时装配) */ /** 阶位 → 页签节点/文案/气泡 映射(onLoad 时装配) */
private tabNodes: Map<TalentTier, { node: Node | null; label: Label | null }> = new Map(); private tabNodes: Map<TalentTier, { node: Node | null; label: Label | null; tip: SmallTipComp | null }> = new Map();
protected onLoad(): void { protected onLoad(): void {
this.tabNodes.set(TalentTier.Basic, { node: this.tab_basic, label: this.lbl_tab_basic }); 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 }); 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 }); 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) { for (const [tier, tab] of this.tabNodes) {
tab.node?.on(NodeEventType.TOUCH_END, () => this.selectTier(tier), this); 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 { private onTalentTap(uuid: number): void {
const cfg = TalentSet[uuid]; const cfg = TalentSet[uuid];
if (!cfg) return; if (!cfg) return;
const levels = smc.getTalentLevels(); const levels = smc.getTalentLevels();
const tab = this.tabNodes.get(cfg.tier);
if (!isTalentTierUnlocked(levels, cfg.tier)) { if (!isTalentTierUnlocked(levels, cfg.tier)) {
const invested = getTalentTierInvestedPoints(levels, (cfg.tier - 1) as TalentTier); 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; return;
} }
const lv = smc.getTalentLv(uuid); const lv = smc.getTalentLv(uuid);
if (lv >= cfg.max_lv) { if (lv >= cfg.max_lv) {
oops.gui.toast("该天赋已满级"); this.showSmallTip(tab?.node ?? null, "该天赋已满级");
return; return;
} }
const cost = getTalentUpgradeCost(lv); const cost = getTalentUpgradeCost(lv);
if (cost <= 0) return; if (cost <= 0) return;
if (smc.getTalentPoints() < cost) { if (smc.getTalentPoints() < cost) {
oops.gui.toast("天赋点不足"); this.showSmallTip(tab?.node ?? null, "天赋点不足");
return; return;
} }
@@ -249,7 +273,7 @@ export class TalentsComp extends CCComp {
maskClose: true, maskClose: true,
okFunc: () => { okFunc: () => {
if (!smc.upgradeTalent(uuid)) { if (!smc.upgradeTalent(uuid)) {
oops.gui.toast("天赋点不足"); this.showSmallTip(this.tabNodes.get(cfg.tier)?.node ?? null, "天赋点不足");
} }
}, },
}); });