2025-09-12 18:20:41 +08:00
|
|
|
import { _decorator, Component, Label, Node } from "cc";
|
|
|
|
|
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
|
|
|
|
|
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
|
|
|
|
import { GButton } from "db://assets/Scripts/Main/Common/GButton";
|
2025-09-15 16:11:15 +08:00
|
|
|
import { NavigationManager, PanelType } from "../../manager/NavigationManager";
|
|
|
|
|
import { NavigationBtn } from "../items/NavigationBtn";
|
2025-09-17 16:12:54 +08:00
|
|
|
import { ChatHistoryManager } from "../../manager/ChatHistoryManager";
|
2025-09-21 14:39:01 +08:00
|
|
|
import { PastGirlListPanel } from "./PastGirlListPanel";
|
2025-09-21 20:18:24 +08:00
|
|
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
2025-09-12 18:20:41 +08:00
|
|
|
|
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
|
|
|
|
@ccclass("NavigationPanel")
|
|
|
|
|
export class NavigationPanel extends li_BaseView {
|
|
|
|
|
private _nodeTab: any = {};
|
|
|
|
|
private currentActivePanel: PanelType = PanelType.THEME;
|
|
|
|
|
|
2025-09-15 16:11:15 +08:00
|
|
|
private themeBtn: NavigationBtn;
|
|
|
|
|
private girlDetailBtn: NavigationBtn;
|
2025-09-21 12:05:34 +08:00
|
|
|
private pastGirlListBtn: NavigationBtn;
|
2025-09-15 16:11:15 +08:00
|
|
|
private settingBtn: NavigationBtn;
|
2025-09-12 18:20:41 +08:00
|
|
|
|
|
|
|
|
private loadingView: Node;
|
|
|
|
|
|
|
|
|
|
onLoadCT() {
|
|
|
|
|
Utils.parseNode(this.node, this._nodeTab);
|
|
|
|
|
|
2025-09-15 16:11:15 +08:00
|
|
|
this.themeBtn = this._nodeTab.themeBtn.getComponent(NavigationBtn);
|
|
|
|
|
this.girlDetailBtn =
|
|
|
|
|
this._nodeTab.girlDetailBtn.getComponent(NavigationBtn);
|
2025-09-21 12:05:34 +08:00
|
|
|
this.pastGirlListBtn = this._nodeTab.chatBtn.getComponent(NavigationBtn);
|
2025-09-15 16:11:15 +08:00
|
|
|
this.settingBtn = this._nodeTab.settingBtn.getComponent(NavigationBtn);
|
2025-09-12 18:20:41 +08:00
|
|
|
this.loadingView = this._nodeTab.loadingView;
|
|
|
|
|
|
|
|
|
|
this.hideLoading();
|
|
|
|
|
|
|
|
|
|
// 注册到NavigationManager
|
|
|
|
|
NavigationManager.Instance.registerNavigationPanel(this);
|
|
|
|
|
|
|
|
|
|
this.registerListener();
|
2025-09-21 14:28:17 +08:00
|
|
|
this.updateButtonStates(PanelType.THEME);
|
2025-09-12 18:20:41 +08:00
|
|
|
|
|
|
|
|
// 初次打开时通过NavigationManager切换到主题面板
|
|
|
|
|
this.initializeFirstPanel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private registerListener() {
|
|
|
|
|
// 所有按钮点击都通过NavigationManager处理
|
|
|
|
|
GButton.BandClick(
|
2025-09-15 16:11:15 +08:00
|
|
|
this.themeBtn.node,
|
|
|
|
|
() => {
|
|
|
|
|
NavigationManager.Instance.switchToPanel(PanelType.THEME);
|
|
|
|
|
},
|
2025-09-12 18:20:41 +08:00
|
|
|
this
|
|
|
|
|
);
|
|
|
|
|
GButton.BandClick(
|
2025-09-15 16:11:15 +08:00
|
|
|
this.girlDetailBtn.node,
|
2025-09-12 18:20:41 +08:00
|
|
|
() => NavigationManager.Instance.switchToPanel(PanelType.GIRL_DETAIL),
|
|
|
|
|
this
|
|
|
|
|
);
|
|
|
|
|
GButton.BandClick(
|
2025-09-21 12:05:34 +08:00
|
|
|
this.pastGirlListBtn.node,
|
2025-09-21 14:39:01 +08:00
|
|
|
() => {
|
|
|
|
|
NavigationManager.Instance.switchToPanel(
|
|
|
|
|
PanelType.PAST_GIRL_LIST,
|
|
|
|
|
false,
|
|
|
|
|
(panel) => {
|
|
|
|
|
panel.getComponent(PastGirlListPanel).refresh();
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
},
|
2025-09-12 18:20:41 +08:00
|
|
|
this
|
|
|
|
|
);
|
|
|
|
|
GButton.BandClick(
|
2025-09-15 16:11:15 +08:00
|
|
|
this.settingBtn.node,
|
2025-09-16 11:58:15 +08:00
|
|
|
() => NavigationManager.Instance.switchToPanel(PanelType.PERSONAL),
|
2025-09-12 18:20:41 +08:00
|
|
|
this
|
|
|
|
|
);
|
2025-09-17 16:12:54 +08:00
|
|
|
|
|
|
|
|
GButton.BandClick(
|
|
|
|
|
this._nodeTab.CleanHistoryBtn,
|
|
|
|
|
() => {
|
|
|
|
|
ChatHistoryManager.Instance.clearAllHistory();
|
|
|
|
|
},
|
|
|
|
|
this
|
|
|
|
|
);
|
2025-09-12 18:20:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 更新按钮状态(公开方法,供NavigationManager调用)
|
|
|
|
|
* @param activePanel 当前激活的面板类型
|
|
|
|
|
*/
|
|
|
|
|
public updateButtonStates(activePanel: PanelType) {
|
|
|
|
|
this.currentActivePanel = activePanel;
|
2025-09-15 16:11:15 +08:00
|
|
|
|
2025-09-12 18:20:41 +08:00
|
|
|
this.refreshButtonVisuals();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 刷新按钮的视觉状态
|
|
|
|
|
*/
|
|
|
|
|
private refreshButtonVisuals() {
|
|
|
|
|
// TODO: 实现按钮状态更新的视觉效果
|
|
|
|
|
// 根据 currentActivePanel 更新按钮的选中状态
|
2025-09-21 20:18:24 +08:00
|
|
|
logger.log(
|
2025-09-12 18:20:41 +08:00
|
|
|
"[NavigationPanel] Button states updated for:",
|
|
|
|
|
this.currentActivePanel
|
|
|
|
|
);
|
2025-09-15 16:11:15 +08:00
|
|
|
|
|
|
|
|
this.themeBtn.setFocus(this.currentActivePanel === PanelType.THEME);
|
|
|
|
|
this.girlDetailBtn.setFocus(
|
|
|
|
|
this.currentActivePanel === PanelType.GIRL_DETAIL
|
|
|
|
|
);
|
2025-09-21 14:28:17 +08:00
|
|
|
this.pastGirlListBtn.setFocus(
|
|
|
|
|
this.currentActivePanel === PanelType.PAST_GIRL_LIST
|
|
|
|
|
);
|
2025-09-16 11:58:15 +08:00
|
|
|
this.settingBtn.setFocus(this.currentActivePanel === PanelType.PERSONAL);
|
2025-09-12 18:20:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private initializeFirstPanel() {
|
2025-09-21 12:05:34 +08:00
|
|
|
// 初次打开时通过NavigationManager切换到历史女孩列表面板
|
2025-09-21 14:28:17 +08:00
|
|
|
NavigationManager.Instance.switchToPanel(PanelType.THEME, true);
|
2025-09-12 18:20:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public showPanel() {
|
|
|
|
|
this.node.active = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public hidePanel() {
|
|
|
|
|
this.node.active = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 显示加载状态(公开方法,供NavigationManager调用)
|
|
|
|
|
*/
|
|
|
|
|
public showLoading() {
|
|
|
|
|
if (this.loadingView) {
|
|
|
|
|
this.loadingView.active = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 隐藏加载状态(公开方法,供NavigationManager调用)
|
|
|
|
|
*/
|
|
|
|
|
public hideLoading() {
|
|
|
|
|
if (this.loadingView) {
|
|
|
|
|
this.loadingView.active = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onDestroy(): void {}
|
|
|
|
|
}
|