This commit is contained in:
2025-09-15 16:11:15 +08:00
parent eb0163b3fc
commit 5a5014b024
26 changed files with 2400 additions and 754 deletions
@@ -1,7 +1,7 @@
import { ViewManager } from "db://assets/Scripts/Main/Manager/ViewManager";
import { UITransitionHelper } from "../utils/UITransitionHelper";
import GameRootUI from "../../Main/Common/GameRootUI";
import { Node } from "cc";
import { Node, sys } from "cc";
import li_EventManager from "../../Main/Common/li_EventManager";
import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
import { ThemePanel } from "../ui/panels/ThemePanel";
@@ -55,12 +55,14 @@ export class NavigationManager {
private currentVisiblePanel: Node = null;
// 选中的角色相关信息
private selectedGirlId: number = 1; // 当前选中的角色ID
private selectedThemeId: number = 1; // 当前选中的主题ID
private selectedGirlId: number = 10002; // 当前选中的角色ID
private selectedCategoryId: number = -1; // 当前选中的主题ID
private themePanel: ThemePanel = null;
private girlListPanel: GirlListPanel = null;
private static LastSelectGirlID = "LastSelectGirlID";
/**
* 获取NavigationManager的单例实例
*
@@ -70,6 +72,21 @@ export class NavigationManager {
public static get Instance(): NavigationManager {
if (!this._instance) {
this._instance = new NavigationManager();
//初始化默认选的girl
let cacheGirlId = sys.localStorage.getItem(this.LastSelectGirlID);
if (!cacheGirlId) {
cacheGirlId = 10002;
sys.localStorage.setItem(this.LastSelectGirlID, cacheGirlId);
}
this._instance.selectedGirlId = Number(cacheGirlId);
let cacheCategoryId = sys.localStorage.getItem("LastSelectCategoryId");
if (!cacheCategoryId) {
cacheCategoryId = 0;
sys.localStorage.setItem("LastSelectCategoryId", cacheCategoryId);
}
this._instance.selectedCategoryId = cacheCategoryId;
}
return this._instance;
}
@@ -101,6 +118,10 @@ export class NavigationManager {
*/
public switchToPanel(panelType: PanelType, force: boolean = false): void {
if (this.currentActivePanel === panelType && !force) {
if (panelType === PanelType.THEME) {
this.girlListPanel.hide();
}
return;
}
@@ -361,6 +382,7 @@ export class NavigationManager {
*/
public setSelectedGirlId(girlId: number): void {
this.selectedGirlId = girlId;
sys.localStorage.setItem(NavigationManager.LastSelectGirlID, girlId);
console.log("[NavigationManager] Selected girl ID set to:", girlId);
}
@@ -377,7 +399,7 @@ export class NavigationManager {
* @param themeId 主题ID
*/
public setSelectedCategoryId(themeId: number): void {
this.selectedThemeId = themeId;
this.selectedCategoryId = themeId;
console.log("[NavigationManager] Selected theme ID set to:", themeId);
}
@@ -385,8 +407,8 @@ export class NavigationManager {
* 获取当前选中的主题ID
* @returns 当前选中的主题ID
*/
public getSelectedThemeId(): number {
return this.selectedThemeId;
public getSelectedCategoryId(): number {
return this.selectedCategoryId;
}
/**
@@ -418,7 +440,7 @@ export class NavigationManager {
if (existingGirlListPanel) {
// 如果面板已存在,重新显示并刷新数据
console.log("[NavigationManager] Reactivating existing GirlListPanel");
this.reactivateGirlListPanel(existingGirlListPanel, themeId);
this.reactivateGirlListPanel(existingGirlListPanel);
} else {
// 如果面板不存在,创建新的
console.log("[NavigationManager] Creating new GirlListPanel");
@@ -451,7 +473,7 @@ export class NavigationManager {
/**
* 重新激活已存在的GirlListPanel
*/
private reactivateGirlListPanel(panel: GirlListPanel, themeId: number): void {
private reactivateGirlListPanel(panel: GirlListPanel): void {
try {
// 重新激活面板
panel.node.active = true;
@@ -460,10 +482,10 @@ export class NavigationManager {
//const girlListComponent = panelNode.getComponent("GirlListPanel");
if (panel) {
// 如果有刷新方法,调用它来更新主题数据
panel.refresh(themeId);
panel.refresh();
console.log(
"[NavigationManager] GirlListPanel reactivated with theme:",
themeId
this.selectedCategoryId
);
}