update
This commit is contained in:
@@ -5,6 +5,7 @@ import { Node } from "cc";
|
||||
import li_EventManager from "../../Main/Common/li_EventManager";
|
||||
import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
|
||||
import { ThemePanel } from "../ui/panels/ThemePanel";
|
||||
import { GirlListPanel } from "../ui/panels/GirlListPanel";
|
||||
|
||||
/**
|
||||
* 页面过渡动画类型枚举
|
||||
@@ -57,6 +58,9 @@ export class NavigationManager {
|
||||
private selectedGirlId: number = 1; // 当前选中的角色ID
|
||||
private selectedThemeId: number = 1; // 当前选中的主题ID
|
||||
|
||||
private themePanel: ThemePanel = null;
|
||||
private girlListPanel: GirlListPanel = null;
|
||||
|
||||
/**
|
||||
* 获取NavigationManager的单例实例
|
||||
*
|
||||
@@ -229,6 +233,11 @@ export class NavigationManager {
|
||||
ViewManager.I.openBundlesView(panelName, openData, (panel: Node) => {
|
||||
if (panel && panel.isValid) {
|
||||
this.panelCache.set(panelType, panel);
|
||||
|
||||
if (panelName === "ThemePanel") {
|
||||
this.themePanel = panel.getComponent(ThemePanel);
|
||||
}
|
||||
|
||||
callback(panel);
|
||||
}
|
||||
});
|
||||
@@ -259,18 +268,15 @@ export class NavigationManager {
|
||||
* 隐藏ThemePanel的子页面
|
||||
*/
|
||||
private hideThemePanelChildren(direction: "left" | "right") {
|
||||
const themePanelNode = this.findThemePanelNode();
|
||||
if (themePanelNode) {
|
||||
const themePanelComponent = themePanelNode.getComponent("ThemePanel");
|
||||
if (themePanelComponent) {
|
||||
// 获取子页面节点
|
||||
const childPanel = this.getThemePanelChildNode(themePanelComponent);
|
||||
if (childPanel && childPanel.active) {
|
||||
console.log(
|
||||
"[NavigationManager] Hiding ThemePanel child with animation"
|
||||
);
|
||||
this.hidePanelWithAnimation(childPanel, direction);
|
||||
}
|
||||
const themePanel = this.findThemePanelNode();
|
||||
if (themePanel) {
|
||||
// 获取子页面节点
|
||||
const childPanel = this.getThemePanelChildNode(themePanel);
|
||||
if (childPanel && childPanel.active) {
|
||||
console.log(
|
||||
"[NavigationManager] Hiding ThemePanel child with animation"
|
||||
);
|
||||
this.hidePanelWithAnimation(childPanel, direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -278,31 +284,11 @@ export class NavigationManager {
|
||||
/**
|
||||
* 获取ThemePanel的子页面节点
|
||||
*/
|
||||
private getThemePanelChildNode(themePanelComponent: any): Node | null {
|
||||
private getThemePanelChildNode(themePanel: ThemePanel): Node | null {
|
||||
try {
|
||||
// ThemePanel存储子页面在currentChildPanel属性中
|
||||
if (
|
||||
themePanelComponent.currentChildPanel &&
|
||||
themePanelComponent.currentChildPanel.node
|
||||
) {
|
||||
return themePanelComponent.currentChildPanel.node;
|
||||
}
|
||||
|
||||
// 如果没有直接的引用,尝试通过ViewManager查找GirlListPanel
|
||||
const viewList = (ViewManager.I as any).m_viewList;
|
||||
if (viewList) {
|
||||
for (let i = 0; i < viewList.length; i++) {
|
||||
const view = viewList[i];
|
||||
if (
|
||||
view &&
|
||||
view.isValid &&
|
||||
view.name === "GirlListPanel" &&
|
||||
view.active
|
||||
) {
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
const childPanel = themePanel.getChildPanel();
|
||||
if (childPanel) return childPanel.node;
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error(
|
||||
@@ -354,6 +340,10 @@ export class NavigationManager {
|
||||
|
||||
panel.active = true;
|
||||
|
||||
if (panel.name === "ThemePanel" && this.girlListPanel) {
|
||||
this.showPanelWithAnimation(this.girlListPanel.node, direction, callback);
|
||||
}
|
||||
|
||||
if (direction === "right") {
|
||||
UITransitionHelper.slideInFromRight(panel, 0.3, () => {
|
||||
callback && callback();
|
||||
@@ -402,7 +392,7 @@ export class NavigationManager {
|
||||
* 设置选中的主题ID
|
||||
* @param themeId 主题ID
|
||||
*/
|
||||
public setSelectedThemeId(themeId: number): void {
|
||||
public setSelectedCategoryId(themeId: number): void {
|
||||
this.selectedThemeId = themeId;
|
||||
console.log("[NavigationManager] Selected theme ID set to:", themeId);
|
||||
}
|
||||
@@ -415,198 +405,6 @@ export class NavigationManager {
|
||||
return this.selectedThemeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用页面导航方法,支持过渡动画
|
||||
*
|
||||
* @param {string} targetPanel - 目标面板名称
|
||||
* @param {any} navigationData - 导航数据
|
||||
* @param {PageTransitionConfig} transitionConfig - 过渡动画配置
|
||||
* @param {any} currentPanel - 当前面板实例(可选)
|
||||
* @param {Function} onComplete - 完成回调(可选)
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* NavigationManager.Instance.navigateWithTransition(
|
||||
* "ChatPanel",
|
||||
* { roleId: 10001 },
|
||||
* { incomingTransition: PageTransitionType.SLIDE_RIGHT, outgoingTransition: PageTransitionType.SLIDE_LEFT },
|
||||
* currentPanel
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
public navigateWithTransition(
|
||||
targetPanel: string,
|
||||
navigationData: any,
|
||||
transitionConfig: PageTransitionConfig,
|
||||
currentPanel?: any,
|
||||
onComplete?: Function
|
||||
): void {
|
||||
if (!targetPanel) {
|
||||
console.warn("NavigationManager: Target panel name is required");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(
|
||||
`Navigating to ${targetPanel} with transition:`,
|
||||
transitionConfig
|
||||
);
|
||||
//const correntPos = currentPanel.node.position;
|
||||
const duration = transitionConfig.duration || 0.1;
|
||||
const useTransition =
|
||||
transitionConfig.incomingTransition !== PageTransitionType.NONE ||
|
||||
transitionConfig.outgoingTransition !== PageTransitionType.NONE;
|
||||
|
||||
if (!useTransition) {
|
||||
// 在没有过渡动画的情况下,也需要处理子页面逻辑
|
||||
if (targetPanel && targetPanel !== "GirlListPanel") {
|
||||
this.handleThemePanelChildPanelsOnNavigation();
|
||||
}
|
||||
|
||||
ViewManager.I.openBundlesView(targetPanel, navigationData, onComplete);
|
||||
if (
|
||||
currentPanel &&
|
||||
currentPanel.onClose &&
|
||||
typeof currentPanel.onClose === "function"
|
||||
) {
|
||||
currentPanel.onClose();
|
||||
//currentPanel.node.position = correntPos;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ViewManager.I.openBundlesView(targetPanel, navigationData, (targetNode) => {
|
||||
this._executeTransition(
|
||||
targetNode,
|
||||
currentPanel,
|
||||
transitionConfig,
|
||||
duration,
|
||||
onComplete
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行页面过渡动画的私有方法
|
||||
*
|
||||
* @private
|
||||
* @param {any} targetNode - 目标节点
|
||||
* @param {any} currentPanel - 当前面板
|
||||
* @param {PageTransitionConfig} config - 动画配置
|
||||
* @param {number} duration - 动画时长
|
||||
* @param {Function} onComplete - 完成回调
|
||||
*/
|
||||
private _executeTransition(
|
||||
targetNode: any,
|
||||
currentPanel: any,
|
||||
config: PageTransitionConfig,
|
||||
duration: number,
|
||||
onComplete?: Function
|
||||
): void {
|
||||
const targetPanelName = targetNode ? targetNode.name : null;
|
||||
const executeIncomingAnimation = (callback?: Function) => {
|
||||
if (
|
||||
config.incomingTransition === PageTransitionType.NONE ||
|
||||
!targetNode
|
||||
) {
|
||||
callback && callback();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (config.incomingTransition) {
|
||||
case PageTransitionType.SLIDE_RIGHT:
|
||||
UITransitionHelper.slideInFromRight(targetNode, duration, callback);
|
||||
break;
|
||||
case PageTransitionType.SLIDE_LEFT:
|
||||
UITransitionHelper.slideInFromLeft(targetNode, duration, callback);
|
||||
break;
|
||||
|
||||
default:
|
||||
callback && callback();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
const executeOutgoingAnimation = (callback?: Function) => {
|
||||
if (
|
||||
config.outgoingTransition === PageTransitionType.NONE ||
|
||||
!currentPanel ||
|
||||
!currentPanel.node ||
|
||||
!currentPanel.node.isValid
|
||||
) {
|
||||
callback && callback();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (config.outgoingTransition) {
|
||||
case PageTransitionType.SLIDE_LEFT:
|
||||
UITransitionHelper.slideOutToLeft(
|
||||
currentPanel.node,
|
||||
duration,
|
||||
callback
|
||||
);
|
||||
break;
|
||||
case PageTransitionType.SLIDE_RIGHT:
|
||||
UITransitionHelper.slideOutToRight(
|
||||
currentPanel.node,
|
||||
duration,
|
||||
callback
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
callback && callback();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
const closeCurrentPanel = () => {
|
||||
if (
|
||||
currentPanel &&
|
||||
currentPanel.onClose &&
|
||||
typeof currentPanel.onClose === "function"
|
||||
) {
|
||||
if (currentPanel.node.name !== "ThemePanel") {
|
||||
currentPanel.onClose();
|
||||
} else {
|
||||
// 如果当前面板是 ThemePanel,检查是否需要关闭子页面
|
||||
console.log(
|
||||
"[NavigationManager] ThemePanel detected, checking for child panels"
|
||||
);
|
||||
if (
|
||||
currentPanel.closeChildPanel &&
|
||||
typeof currentPanel.closeChildPanel === "function"
|
||||
) {
|
||||
currentPanel.closeChildPanel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查目标面板是否会导致需要隐藏 ThemePanel 的子页面
|
||||
if (targetPanelName && targetPanelName !== "GirlListPanel") {
|
||||
this.handleThemePanelChildPanelsOnNavigation();
|
||||
}
|
||||
|
||||
onComplete && onComplete();
|
||||
};
|
||||
|
||||
if (config.simultaneous) {
|
||||
let completedAnimations = 0;
|
||||
const animationComplete = () => {
|
||||
completedAnimations++;
|
||||
if (completedAnimations >= 2) {
|
||||
closeCurrentPanel();
|
||||
}
|
||||
};
|
||||
|
||||
executeIncomingAnimation(animationComplete);
|
||||
executeOutgoingAnimation(animationComplete);
|
||||
} else {
|
||||
executeOutgoingAnimation(() => {
|
||||
executeIncomingAnimation(closeCurrentPanel);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入角色列表页面(作为 ThemePanel 的子页面)
|
||||
*
|
||||
@@ -624,7 +422,7 @@ export class NavigationManager {
|
||||
}
|
||||
|
||||
// 更新选中的主题ID
|
||||
this.setSelectedThemeId(themeId);
|
||||
this.setSelectedCategoryId(themeId);
|
||||
|
||||
console.log(
|
||||
`[NavigationManager] Navigating to girl list with theme ID: ${themeId}`
|
||||
@@ -647,6 +445,7 @@ export class NavigationManager {
|
||||
parentPanel: "ThemePanel", // 标记父页面
|
||||
},
|
||||
(girlListPanelNode) => {
|
||||
this.girlListPanel = girlListPanelNode.getComponent(GirlListPanel);
|
||||
// 获取 ThemePanel 实例并设置子页面关系
|
||||
console.log(
|
||||
"[NavigationManager] GirlListPanel opened, setting up parent-child relationship"
|
||||
@@ -660,44 +459,24 @@ export class NavigationManager {
|
||||
/**
|
||||
* 查找已存在的GirlListPanel
|
||||
*/
|
||||
private findExistingGirlListPanel(): any {
|
||||
try {
|
||||
const viewList = (ViewManager.I as any).m_viewList;
|
||||
if (viewList) {
|
||||
for (let i = 0; i < viewList.length; i++) {
|
||||
const view = viewList[i];
|
||||
if (view && view.isValid && view.name === "GirlListPanel") {
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"[NavigationManager] Error finding existing GirlListPanel:",
|
||||
error
|
||||
);
|
||||
return null;
|
||||
}
|
||||
private findExistingGirlListPanel(): GirlListPanel {
|
||||
if (this.girlListPanel) return this.girlListPanel;
|
||||
else return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新激活已存在的GirlListPanel
|
||||
*/
|
||||
private reactivateGirlListPanel(panelNode: any, themeId: number): void {
|
||||
private reactivateGirlListPanel(panel: GirlListPanel, themeId: number): void {
|
||||
try {
|
||||
// 重新激活面板
|
||||
panelNode.active = true;
|
||||
panel.node.active = true;
|
||||
|
||||
// 获取面板组件并刷新数据
|
||||
const girlListComponent = panelNode.getComponent("GirlListPanel");
|
||||
if (girlListComponent) {
|
||||
//const girlListComponent = panelNode.getComponent("GirlListPanel");
|
||||
if (panel) {
|
||||
// 如果有刷新方法,调用它来更新主题数据
|
||||
if (typeof girlListComponent.refreshWithTheme === "function") {
|
||||
girlListComponent.refreshWithTheme(themeId);
|
||||
} else if (typeof girlListComponent.Show === "function") {
|
||||
girlListComponent.Show(themeId);
|
||||
}
|
||||
panel.refresh(themeId);
|
||||
console.log(
|
||||
"[NavigationManager] GirlListPanel reactivated with theme:",
|
||||
themeId
|
||||
@@ -705,7 +484,7 @@ export class NavigationManager {
|
||||
}
|
||||
|
||||
// 重新建立父子关系
|
||||
this.setupParentChildRelationship(panelNode);
|
||||
this.setupParentChildRelationship(panel);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"[NavigationManager] Error reactivating GirlListPanel:",
|
||||
@@ -722,17 +501,16 @@ export class NavigationManager {
|
||||
private setupParentChildRelationship(girlListPanelNode: any): void {
|
||||
try {
|
||||
// 查找 ThemePanel 实例
|
||||
const themePanelNode = this.findThemePanelNode();
|
||||
if (themePanelNode) {
|
||||
const themePanelComponent = themePanelNode.getComponent("ThemePanel");
|
||||
const themePanel = this.findThemePanelNode();
|
||||
if (themePanel) {
|
||||
const girlListPanelComponent =
|
||||
girlListPanelNode.getComponent("GirlListPanel");
|
||||
girlListPanelNode.getComponent(GirlListPanel);
|
||||
|
||||
if (themePanelComponent && girlListPanelComponent) {
|
||||
if (themePanel && girlListPanelComponent) {
|
||||
console.log(
|
||||
"[NavigationManager] Setting up parent-child relationship"
|
||||
);
|
||||
themePanelComponent.setChildPanel(girlListPanelComponent);
|
||||
this.themePanel.setChildPanel(girlListPanelComponent);
|
||||
} else {
|
||||
console.warn("[NavigationManager] Failed to get panel components");
|
||||
}
|
||||
@@ -752,27 +530,9 @@ export class NavigationManager {
|
||||
* @private
|
||||
* @returns ThemePanel 节点或 null
|
||||
*/
|
||||
private findThemePanelNode(): any {
|
||||
console.log("[NavigationManager] Finding ThemePanel node...");
|
||||
try {
|
||||
// 通过 ViewManager 的视图列表查找 ThemePanel
|
||||
const viewList = (ViewManager.I as any).m_viewList;
|
||||
if (viewList) {
|
||||
for (let i = 0; i < viewList.length; i++) {
|
||||
const view = viewList[i];
|
||||
if (view && view.isValid && view.name === "ThemePanel") {
|
||||
console.log("[NavigationManager] Found ThemePanel node");
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log("[NavigationManager] ThemePanel not found in view list");
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error("[NavigationManager] Error finding ThemePanel:", error);
|
||||
return null;
|
||||
}
|
||||
private findThemePanelNode(): ThemePanel {
|
||||
if (this.themePanel) return this.themePanel;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -786,259 +546,10 @@ export class NavigationManager {
|
||||
|
||||
const themePanelNode = this.findThemePanelNode();
|
||||
if (themePanelNode) {
|
||||
const themePanelComponent = themePanelNode.getComponent("ThemePanel");
|
||||
if (themePanelComponent && themePanelComponent.closeChildPanel) {
|
||||
if (themePanelNode && themePanelNode.hideChildPanel) {
|
||||
console.log("[NavigationManager] Closing ThemePanel child panels");
|
||||
themePanelComponent.closeChildPanel();
|
||||
themePanelNode.hideChildPanel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入聊天页面
|
||||
*
|
||||
* @param {number} roleId - 角色ID
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* NavigationManager.Instance.navigateToChat(10001);
|
||||
* ```
|
||||
*/
|
||||
public navigateToChat(roleId: number): void;
|
||||
/**
|
||||
* 进入聊天页面(带过渡动画)
|
||||
*
|
||||
* @param {number} roleId - 角色ID
|
||||
* @param {PageTransitionConfig} transitionConfig - 过渡动画配置
|
||||
* @param {any} currentPanel - 当前面板实例(可选)
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* NavigationManager.Instance.navigateToChat(10001,
|
||||
* { incomingTransition: PageTransitionType.FADE, outgoingTransition: PageTransitionType.SLIDE_LEFT },
|
||||
* this
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
public navigateToChat(
|
||||
roleId: number,
|
||||
transitionConfig?: PageTransitionConfig,
|
||||
currentPanel?: any
|
||||
): void;
|
||||
public navigateToChat(
|
||||
roleId: number,
|
||||
transitionConfig?: PageTransitionConfig,
|
||||
currentPanel?: any
|
||||
): void {
|
||||
if (roleId == null || roleId <= 0) {
|
||||
console.warn("Invalid role ID for chat navigation:", roleId);
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新选中的角色ID
|
||||
this.setSelectedGirlId(roleId);
|
||||
|
||||
// NavigationPanel 始终显示,不需要隐藏 DefaultView
|
||||
console.log(`Navigating to chat with role ID: ${roleId}`);
|
||||
|
||||
if (transitionConfig) {
|
||||
this.navigateWithTransition(
|
||||
"ChatPanel",
|
||||
roleId,
|
||||
transitionConfig,
|
||||
currentPanel
|
||||
);
|
||||
} else {
|
||||
ViewManager.I.openBundlesView("ChatPanel", roleId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 带过渡动画进入聊天页面
|
||||
* 从GirlDetailPanel平滑过渡到ChatPanel
|
||||
*
|
||||
* @param {string} categoryId - 类别ID
|
||||
* @param {number} roleId - 角色ID
|
||||
* @param {any} currentPanel - 当前面板实例(GirlDetailPanel)
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* NavigationManager.Instance.navigateToChatWithTransition("1", 10001, this);
|
||||
* ```
|
||||
*/
|
||||
public navigateToChatWithTransition(
|
||||
categoryId: string,
|
||||
roleId: number,
|
||||
currentPanel?: any
|
||||
): void {
|
||||
if (roleId == null || roleId <= 0) {
|
||||
console.warn(
|
||||
"Invalid role ID for chat navigation with transition:",
|
||||
roleId
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新选中的角色ID和主题ID
|
||||
this.setSelectedGirlId(roleId);
|
||||
if (categoryId != null) {
|
||||
this.setSelectedThemeId(parseInt(categoryId));
|
||||
}
|
||||
|
||||
const navigationData = {
|
||||
categoryId: categoryId,
|
||||
roleId: roleId,
|
||||
};
|
||||
|
||||
const transitionConfig: PageTransitionConfig = {
|
||||
incomingTransition: PageTransitionType.SLIDE_RIGHT,
|
||||
outgoingTransition: PageTransitionType.SLIDE_LEFT,
|
||||
duration: 0.3,
|
||||
simultaneous: true,
|
||||
};
|
||||
|
||||
this.navigateWithTransition(
|
||||
"ChatPanel",
|
||||
navigationData,
|
||||
transitionConfig,
|
||||
currentPanel
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入角色详情页面
|
||||
*
|
||||
* @param {number} roleId - 角色ID
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* NavigationManager.Instance.navigateToGirlDetail(10001);
|
||||
* ```
|
||||
*/
|
||||
public navigateToGirlDetail(roleId: number): void;
|
||||
/**
|
||||
* 进入角色详情页面(带过渡动画)
|
||||
*
|
||||
* @param {number} roleId - 角色ID
|
||||
* @param {PageTransitionConfig} transitionConfig - 过渡动画配置
|
||||
* @param {any} currentPanel - 当前面板实例(可选)
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* NavigationManager.Instance.navigateToGirlDetail(10001,
|
||||
* { incomingTransition: PageTransitionType.SLIDE_RIGHT, outgoingTransition: PageTransitionType.SLIDE_LEFT },
|
||||
* this
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
public navigateToGirlDetail(
|
||||
roleId: number,
|
||||
transitionConfig?: PageTransitionConfig,
|
||||
currentPanel?: any
|
||||
): void;
|
||||
public navigateToGirlDetail(
|
||||
roleId: number,
|
||||
transitionConfig?: PageTransitionConfig,
|
||||
currentPanel?: any
|
||||
): void {
|
||||
if (roleId == null || roleId <= 0) {
|
||||
console.warn("Invalid role ID for detail navigation:", roleId);
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新选中的角色ID
|
||||
this.setSelectedGirlId(roleId);
|
||||
|
||||
console.log(`Navigating to girl detail with role ID: ${roleId}`);
|
||||
|
||||
if (transitionConfig) {
|
||||
this.navigateWithTransition(
|
||||
"GirlDetailPanel",
|
||||
roleId,
|
||||
transitionConfig,
|
||||
currentPanel
|
||||
);
|
||||
} else {
|
||||
ViewManager.I.openBundlesView("GirlDetailPanel", roleId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回主界面
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* NavigationManager.Instance.navigateToMainMenu();
|
||||
* ```
|
||||
*/
|
||||
public navigateToMainMenu(): void {
|
||||
console.log("Navigating to main menu");
|
||||
// TODO: 实现返回主界面的逻辑
|
||||
// ViewManager.I.openBundlesView("MainMenu");
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否可以导航到指定页面
|
||||
*
|
||||
* @param {string} pageName - 页面名称
|
||||
* @returns {boolean} 是否可以导航
|
||||
*/
|
||||
public canNavigateTo(pageName: string): boolean {
|
||||
const allowedPages = ["GirlListPanel", "ChatPanel", "GirlDetailPanel"];
|
||||
return allowedPages.indexOf(pageName) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前页面的导航历史(预留功能)
|
||||
*
|
||||
* @returns {string[]} 导航历史数组
|
||||
*/
|
||||
public getNavigationHistory(): string[] {
|
||||
// TODO: 实现导航历史记录功能
|
||||
console.log("Navigation history feature not implemented yet");
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回上一页(预留功能)
|
||||
*/
|
||||
public goBack(): void {
|
||||
// TODO: 实现返回上一页功能
|
||||
console.log("Go back feature not implemented yet");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预设的过渡动画配置
|
||||
*/
|
||||
public static getTransitionPresets() {
|
||||
return {
|
||||
SLIDE_LEFT_TO_RIGHT: {
|
||||
incomingTransition: PageTransitionType.SLIDE_RIGHT,
|
||||
outgoingTransition: PageTransitionType.SLIDE_LEFT,
|
||||
duration: 0.1,
|
||||
simultaneous: true,
|
||||
} as PageTransitionConfig,
|
||||
|
||||
SLIDE_RIGHT_TO_LEFT: {
|
||||
incomingTransition: PageTransitionType.SLIDE_LEFT,
|
||||
outgoingTransition: PageTransitionType.SLIDE_RIGHT,
|
||||
duration: 0.1,
|
||||
simultaneous: true,
|
||||
} as PageTransitionConfig,
|
||||
|
||||
SLIDE_OVER: {
|
||||
incomingTransition: PageTransitionType.SLIDE_RIGHT,
|
||||
outgoingTransition: PageTransitionType.NONE,
|
||||
duration: 0.1,
|
||||
simultaneous: true,
|
||||
} as PageTransitionConfig,
|
||||
|
||||
SLIDE_UNDER: {
|
||||
incomingTransition: PageTransitionType.NONE,
|
||||
outgoingTransition: PageTransitionType.SLIDE_LEFT,
|
||||
duration: 0.1,
|
||||
simultaneous: true,
|
||||
} as PageTransitionConfig,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,10 +47,15 @@ export class GirlListPanel extends li_BaseView {
|
||||
this.refresh(this.category);
|
||||
}
|
||||
|
||||
cacheCategory: number = -1;
|
||||
|
||||
async refresh(category: number) {
|
||||
if (category == this.cacheCategory) return;
|
||||
this.cacheCategory = category;
|
||||
if (this.cache) {
|
||||
for (let i = this.cache.length - 1; i >= 0; i--) {
|
||||
this.cache[i].node.destroy();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +83,10 @@ export class GirlListPanel extends li_BaseView {
|
||||
}
|
||||
}
|
||||
|
||||
hide() {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
private registerListener() {
|
||||
GButton.BandClick(this._nodeTab.ReturnBtn, this.Return, this);
|
||||
}
|
||||
|
||||
@@ -2,16 +2,11 @@ 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";
|
||||
import { ViewManager } from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||
import {
|
||||
NavigationManager,
|
||||
PageTransitionType,
|
||||
PanelType,
|
||||
} from "../../manager/NavigationManager";
|
||||
import { InnerMsgCode } from "../../../Main/Config/InnerMsgCode";
|
||||
import GameRootUI from "../../../Main/Common/GameRootUI";
|
||||
import { UITransitionHelper } from "../../utils/UITransitionHelper";
|
||||
import { ThemePanel } from "./ThemePanel";
|
||||
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import { ShopData } from "../../data/ShopData";
|
||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
import GameRootUI from "../../../Main/Common/GameRootUI";
|
||||
import { MainController } from "../../core/MainController";
|
||||
import { GirlListPanel } from "./GirlListPanel";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -53,7 +54,7 @@ export class ThemePanel extends li_BaseView {
|
||||
cache: ThemeItem[] = [];
|
||||
|
||||
// 子页面管理
|
||||
private currentChildPanel: any = null;
|
||||
private listPanel: GirlListPanel = null;
|
||||
|
||||
// 加载状态保护
|
||||
private isLoading: boolean = false;
|
||||
@@ -316,7 +317,7 @@ export class ThemePanel extends li_BaseView {
|
||||
) == 0;
|
||||
if (isRelease || isFree) {
|
||||
NavigationManager.Instance.setSelectedGirlId(this.recId);
|
||||
NavigationManager.Instance.setSelectedThemeId(
|
||||
NavigationManager.Instance.setSelectedCategoryId(
|
||||
girlData.getGrilCategoryById(this.recId)
|
||||
);
|
||||
NavigationManager.Instance.switchToPanel(PanelType.GIRL_DETAIL);
|
||||
@@ -384,29 +385,34 @@ export class ThemePanel extends li_BaseView {
|
||||
}
|
||||
}
|
||||
|
||||
public getChildPanel(): GirlListPanel {
|
||||
if (this.listPanel) return this.listPanel;
|
||||
return null;
|
||||
}
|
||||
public setChildPanel(panel: GirlListPanel) {
|
||||
this.listPanel = panel;
|
||||
}
|
||||
/**
|
||||
* 设置子页面
|
||||
* @param panel 子页面实例
|
||||
* 隐藏子页面
|
||||
*/
|
||||
public setChildPanel(panel: any): void {
|
||||
console.log("[ThemePanel] Setting child panel:", panel);
|
||||
// 先关闭旧的子页面
|
||||
this.closeChildPanel();
|
||||
this.currentChildPanel = panel;
|
||||
public hideChildPanel(): void {
|
||||
if (this.listPanel) {
|
||||
console.log("[ThemePanel] Closing child panel");
|
||||
if (this.listPanel.hide) {
|
||||
this.listPanel.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭子页面
|
||||
*/
|
||||
public closeChildPanel(): void {
|
||||
if (this.currentChildPanel) {
|
||||
public clostChildPanel(): void {
|
||||
if (this.listPanel) {
|
||||
console.log("[ThemePanel] Closing child panel");
|
||||
if (this.currentChildPanel.onClose) {
|
||||
this.currentChildPanel.onClose();
|
||||
} else if (this.currentChildPanel.destroy) {
|
||||
this.currentChildPanel.destroy();
|
||||
if (this.listPanel.close) {
|
||||
this.listPanel.close();
|
||||
}
|
||||
this.currentChildPanel = null;
|
||||
this.listPanel = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,7 +421,7 @@ export class ThemePanel extends li_BaseView {
|
||||
*/
|
||||
public onHide(): void {
|
||||
console.log("[ThemePanel] onHide called");
|
||||
this.closeChildPanel();
|
||||
this.hideChildPanel();
|
||||
this.cancelCurrentOperation();
|
||||
}
|
||||
|
||||
@@ -437,7 +443,7 @@ export class ThemePanel extends li_BaseView {
|
||||
this.cancelCurrentOperation();
|
||||
|
||||
// 关闭子页面
|
||||
this.closeChildPanel();
|
||||
this.clostChildPanel();
|
||||
|
||||
// 清理缓存
|
||||
this.clearCache();
|
||||
|
||||
Reference in New Issue
Block a user