refactor(ui): 调整UI页面管理方式,改为节点显隐控制

1. 注释并禁用了Ranks、Heros、Talents三个UIID的全局弹窗配置
2. 将三个页面改为通过MissionHomeComp控制节点显隐切换
3. 移除了原有的gui.open/remove弹窗调用逻辑,改为设置active状态
4. 调整了组件生命周期,改用onEnable替代onAdded处理显示逻辑
5. 更新了对应组件的注释和文档说明
This commit is contained in:
panw
2026-05-27 16:18:26 +08:00
parent 3c78acde78
commit ad0539d238
5 changed files with 52 additions and 48 deletions

View File

@@ -17,9 +17,9 @@ export enum UIID {
Victory,
IBox,
Notity,
Ranks,
Heros,
Talents,
// Ranks,
// Heros,
// Talents,
Mission,
HInfo,
}
@@ -32,9 +32,9 @@ export var UIConfigData: { [key: number]: UIConfig } = {
[UIID.Victory]: { layer: LayerType.UI, prefab: "gui/element/victory" },
[UIID.IBox]: { layer: LayerType.UI, prefab: "gui/element/ibox" },
[UIID.Notity]: { layer: LayerType.UI, prefab: "gui/element/notity" },
[UIID.Ranks]: { layer: LayerType.UI, prefab: "gui/element/ranks" },
[UIID.Heros]: { layer: LayerType.UI, prefab: "gui/element/heros" },
[UIID.Talents]: { layer: LayerType.UI, prefab: "gui/element/talents" },
// [UIID.Ranks]: { layer: LayerType.UI, prefab: "gui/element/ranks" },
// [UIID.Heros]: { layer: LayerType.UI, prefab: "gui/element/heros" },
// [UIID.Talents]: { layer: LayerType.UI, prefab: "gui/element/talents" },
[UIID.Mission]: { layer: LayerType.UI, prefab: "gui/element/mission" },
[UIID.HInfo]: { layer: LayerType.UI, prefab: "gui/element/hnode" },
}

View File

@@ -22,7 +22,6 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { oops } from "db://oops-framework/core/Oops";
import { mLogger } from "../common/Logger";
import { UIID } from "../common/config/GameUIConfig";
import { HeroInfo, HeroList } from "../common/config/heroSet";
import { buildSkillDesc } from "../common/config/HeroSkillDesc";
import { CardLiteComp } from "./CardLiteComp";
@@ -71,10 +70,6 @@ export class HerosListComp extends CCComp {
private selectNode: Node | null = null
debugMode: boolean = false
onAdded(args: any) {
}
start() {
this.initCardList()
if (HeroList.length > 0) {
@@ -82,8 +77,14 @@ export class HerosListComp extends CCComp {
}
}
protected onEnable(): void {
if (this.cards_node && this.cards_node.children.length > 0) {
this.onCardSelect(this.huuid || HeroList[0])
}
}
closeHeros() {
oops.gui.remove(UIID.Heros)
this.node.active = false
}
// ======================== 卡片列表 ========================

View File

@@ -15,7 +15,7 @@
*
* 依赖:
* - GameEvent.MissionStart / MissionEnd —— 游戏生命周期事件
* - UIID.Ranks —— 排行榜弹窗 ID
* - UIID.Mission —— 战斗界面 ID
*/
import { _decorator, instantiate, Prefab, resources, Sprite, SpriteAtlas, UITransform ,Node} from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
@@ -92,15 +92,26 @@ export class MissionHomeComp extends CCComp {
}
/** 打开排行榜弹窗 */
openRanks(){
oops.gui.open(UIID.Ranks)
private showPage(page: Node) {
this.heros_page.active = (page === this.heros_page)
this.talents_page.active = (page === this.talents_page)
this.ranks_page.active = (page === this.ranks_page)
}
openHero(){
oops.gui.open(UIID.Heros)
private hideAllPages() {
this.heros_page.active = false
this.talents_page.active = false
this.ranks_page.active = false
}
openTalents(){
oops.gui.open(UIID.Talents)
openRanks() {
this.showPage(this.ranks_page)
}
openHero() {
this.showPage(this.heros_page)
}
openTalents() {
this.showPage(this.talents_page)
}
/** 任务结束回调:重新显示主页 */
mission_end(){
@@ -111,8 +122,8 @@ export class MissionHomeComp extends CCComp {
/** 激活主页显示:刷新数据并显示节点 */
home_active(){
this.uodate_data()
this.hideAllPages()
this.node.active=true
}
/** 更新主页显示数据(预留) */

View File

@@ -1,19 +1,18 @@
/**
* @file RanksComp.ts
* @description 排行榜弹窗组件UI 视图层)
* @description 排行榜页面组件UI 视图层)
*
* 职责:
* 1. 展示排行榜界面,包含 Top1~Top3 特殊位和通用列表区域。
* 2. 提供关闭排行榜弹窗的按钮回调。
* 2. 提供关闭排行榜页面的按钮回调。
*
* 关键设计:
* - top1_node / top2_node / top3_node 用于展示前三名玩家的特殊样式。
* - lists_node 为滚动列表的容器节点。
* - list_prefab / melist_prefab 分别为普通排名项和"我的排名"项的预制体。
* - 当前 onLoad / onAdded 未实现具体逻辑,预留后期接入排行数据。
*
* 依赖:
* - UIID.Ranks —— 在 oops.gui 系统中注册的弹窗 ID
* - MissionHomeComp —— 通过节点 active 显隐控制页面切换
*/
import { _decorator, Animation, AnimationClip, Button, Event, Label, Node, NodeEventType, Sprite, resources, Prefab } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
@@ -21,8 +20,6 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
import { HeroInfo } from "../common/config/heroSet";
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { Hero } from "../hero/Hero";
import { oops } from "db://oops-framework/core/Oops";
import { UIID } from "../common/config/GameUIConfig";
import { mLogger } from "../common/Logger";
const {property, ccclass } = _decorator;
@@ -30,7 +27,7 @@ const {property, ccclass } = _decorator;
/**
* RanksComp —— 排行榜视图组件
*
* 通过 oops.gui.open(UIID.Ranks) 打开
* 通过 MissionHomeComp 页面切换显示
* 展示 Top3 + 通用列表 + 我的排名。
*/
@ccclass('RanksComp')
@@ -55,13 +52,11 @@ export class RanksComp extends CCComp {
@property(Prefab)
melist_prefab=null!
/** 预留:加载排行数据 */
onLoad() {
}
/** 预留:弹窗打开时接收参数 */
onAdded(args: any) {
protected onEnable(): void {
}
@@ -69,9 +64,9 @@ export class RanksComp extends CCComp {
super.onDestroy();
}
/** 关闭排行榜弹窗 */
/** 关闭排行榜页面 */
closeRanks(){
oops.gui.remove(UIID.Ranks)
this.node.active = false
}
/** ECS 组件移除时销毁节点 */

View File

@@ -1,22 +1,21 @@
/**
* @file TalentsComp.ts
* @description 战斗结算弹窗组件UI 视图层)
* @description 天赋系统页面组件UI 视图层)
*
* 职责:
* 1. 在战斗结束时弹出,展示结算信息(得分、奖励)
* 2. 根据传入参数判断是否可复活,切换"下一步"或"复活"按钮
* 3. 计算单局总分并存储到 smc.vmdata.scores.score
* 4. 提供"重新开始"和"退出"两个操作入口
* 1. 展示玩家等级、当前经验、进度条、金币
* 2. 展示天赋列表及每个天赋的当前等级
* 3. 处理天赋升级点击事件,扣除金币并保存
* 4. 处理重置天赋(看广告)功能
*
* 关键设计:
* - onAdded(args) 接收战斗结果参数Talents / rewards / game_data / can_revive
* - calculateTotalScore() 根据 ScoreWeights 配置加权计算各项得分
* - restart() 和 Talents_end() 通过分发 MissionEnd / MissionStart 事件驱动游戏状态切换。
* - 通过 MissionHomeComp 页面切换显示,节点 active 控制显隐
* - onAdded(args) 接收参数时刷新界面
*
* 依赖:
* - smc.vmdata.scores —— 全局战斗统计数据
* - ScoreWeightsScoreSet—— 得分权重配置
* - GameEvent.MissionEnd / MissionStart —— 游戏生命周期事件
* - MissionHomeComp —— 通过节点 active 显隐控制页面切换
* - smc.collection —— 玩家数据
* - TalentConfigTalentSet—— 天赋配置
*/
import { _decorator, Node, Label, Button, ProgressBar, instantiate, Prefab } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
@@ -78,7 +77,6 @@ export class TalentsComp extends CCComp {
private readonly MAX_PLAYER_LEVEL = 30;
protected onLoad(): void {
// 绑定按钮事件
if (this.btn_reset && this.btn_reset.node) {
this.btn_reset.node.on(Button.EventType.CLICK, this.onResetClicked, this);
}
@@ -87,8 +85,7 @@ export class TalentsComp extends CCComp {
}
}
onAdded(args: any) {
// 直接刷新界面,因为图集已经在游戏启动时被 smc 预加载并缓存
protected onEnable(): void {
this.refreshUI();
}
@@ -250,7 +247,7 @@ export class TalentsComp extends CCComp {
/** 点击返回按钮 */
private onCloseClicked() {
oops.gui.removeByNode(this.node); //
this.node.active = false
}
protected onDestroy(): void {