fix
This commit is contained in:
@@ -1,4 +1,17 @@
|
||||
import { _decorator, Node, Camera, Component, director, game, instantiate, Prefab, RenderTexture, view, resources, macro } from "cc";
|
||||
import {
|
||||
_decorator,
|
||||
Node,
|
||||
Camera,
|
||||
Component,
|
||||
director,
|
||||
game,
|
||||
instantiate,
|
||||
Prefab,
|
||||
RenderTexture,
|
||||
view,
|
||||
resources,
|
||||
macro,
|
||||
} from "cc";
|
||||
import Utils from "../Common/Utils";
|
||||
import GameRootUI from "../Common/GameRootUI";
|
||||
import ResManager from "./ResManager";
|
||||
@@ -6,7 +19,7 @@ import { CommonConfig } from "../Config/CommonConfig";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('ViewManager')
|
||||
@ccclass("ViewManager")
|
||||
export class ViewManager extends Component {
|
||||
private static _I: ViewManager = null;
|
||||
public static get I(): ViewManager {
|
||||
@@ -19,19 +32,21 @@ export class ViewManager extends Component {
|
||||
private m_viewList = [];
|
||||
private m_viewListData = {};
|
||||
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
start() {}
|
||||
|
||||
update(deltaTime: number) {}
|
||||
|
||||
private openIdx = 0;
|
||||
private openViewByPrefab(err, i_prefab: Prefab | Node, i_openInfo, callBack = null, path, type: string = '') {
|
||||
private openViewByPrefab(
|
||||
err,
|
||||
i_prefab: Prefab | Node,
|
||||
i_openInfo,
|
||||
callBack = null,
|
||||
path,
|
||||
type: string = ""
|
||||
) {
|
||||
if (err) {
|
||||
Utils.Log('打开界面时加载资源出错:' + err, path);
|
||||
Utils.Log("打开界面时加载资源出错:" + err, path);
|
||||
return;
|
||||
}
|
||||
let t_node: any = instantiate(i_prefab);
|
||||
@@ -42,8 +57,8 @@ export class ViewManager extends Component {
|
||||
let t_view: Node = this.m_viewList[i];
|
||||
if (t_view) {
|
||||
if (t_view.isValid && t_node.name == t_view.name) {
|
||||
t_node.setSiblingIndex(999)
|
||||
Utils.Log('已经打开的相同的界面:' + t_node.name);
|
||||
t_node.setSiblingIndex(999);
|
||||
Utils.Log("已经打开的相同的界面:" + t_node.name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -51,13 +66,13 @@ export class ViewManager extends Component {
|
||||
|
||||
//截屏纹理
|
||||
if (i_openInfo && i_openInfo.blueBg === true) {
|
||||
i_openInfo.screenShotTex = this.getScreenShot()
|
||||
i_openInfo.screenShotTex = this.getScreenShot();
|
||||
}
|
||||
|
||||
let viewSP = t_node.getComponent(t_node.name);
|
||||
if (!viewSP) {
|
||||
for (let index = 0; index < t_node['_components'].length; index++) {
|
||||
const element = t_node['_components'][index];
|
||||
for (let index = 0; index < t_node["_components"].length; index++) {
|
||||
const element = t_node["_components"][index];
|
||||
if (element.isScriptComponent) {
|
||||
viewSP = element;
|
||||
break;
|
||||
@@ -66,18 +81,27 @@ export class ViewManager extends Component {
|
||||
}
|
||||
|
||||
this.m_viewList.push(t_node);
|
||||
this.m_viewListData[t_node.name] = { path: path, data: i_openInfo, sort: this.openIdx++, name: t_node.name, uuid: t_node["_prefab"]['asset']['_uuid'] };
|
||||
this.m_viewListData[t_node.name] = {
|
||||
path: path,
|
||||
data: i_openInfo,
|
||||
sort: this.openIdx++,
|
||||
name: t_node.name,
|
||||
uuid: t_node["_prefab"]["asset"]["_uuid"],
|
||||
};
|
||||
viewSP && viewSP.openUIData && viewSP.openUIData(i_openInfo);
|
||||
callBack && callBack(t_node, i_openInfo);
|
||||
if (type == '') {
|
||||
GameRootUI.I.AddUIToLayer(t_node, CommonConfig.UILayerGroup.Layer_ui1, this.m_viewList.length)
|
||||
} else if (type == 'top') {
|
||||
if (type == "") {
|
||||
GameRootUI.I.AddUIToLayer(
|
||||
t_node,
|
||||
CommonConfig.UILayerGroup.Layer_ui1,
|
||||
this.m_viewList.length
|
||||
);
|
||||
} else if (type == "top") {
|
||||
// t_node.sType = "top"
|
||||
GameRootUI.I.AddUIToLayer(t_node, CommonConfig.UILayerGroup.Layer_top)
|
||||
} else if (type == 'tips') {
|
||||
GameRootUI.I.AddUIToLayer(t_node, CommonConfig.UILayerGroup.Layer_tips)
|
||||
GameRootUI.I.AddUIToLayer(t_node, CommonConfig.UILayerGroup.Layer_top);
|
||||
} else if (type == "tips") {
|
||||
GameRootUI.I.AddUIToLayer(t_node, CommonConfig.UILayerGroup.Layer_tips);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//检查是否有相同的View
|
||||
@@ -119,7 +143,7 @@ export class ViewManager extends Component {
|
||||
// camera.targetTexture = oldTargetTexture
|
||||
|
||||
// return texture
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
|
||||
private getViewIndex(i_view: Node) {
|
||||
@@ -133,51 +157,114 @@ export class ViewManager extends Component {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**打开resources窗体 */
|
||||
openMainView(i_prefab: string | Prefab, i_openData?, callBack = null, type: string = '') {
|
||||
openMainView(
|
||||
i_prefab: string | Prefab,
|
||||
i_openData?,
|
||||
callBack = null,
|
||||
type: string = ""
|
||||
) {
|
||||
if (i_prefab instanceof Prefab) {
|
||||
this.openViewByPrefab(null, i_prefab, i_openData, callBack, i_prefab, type);
|
||||
this.openViewByPrefab(
|
||||
null,
|
||||
i_prefab,
|
||||
i_openData,
|
||||
callBack,
|
||||
i_prefab,
|
||||
type
|
||||
);
|
||||
} else {
|
||||
resources.load(i_prefab, (err, $prefab: Prefab) => {
|
||||
this.openViewByPrefab(err, $prefab, i_openData, callBack, i_prefab, type);
|
||||
this.openViewByPrefab(
|
||||
err,
|
||||
$prefab,
|
||||
i_openData,
|
||||
callBack,
|
||||
i_prefab,
|
||||
type
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
/**打开bundle窗体 */
|
||||
openBundlesView(i_prefab: string | Prefab, i_openData?, callBack = null, type: string = '') {
|
||||
openBundlesView(
|
||||
i_prefab: string | Prefab,
|
||||
i_openData?,
|
||||
callBack = null,
|
||||
type: string = ""
|
||||
) {
|
||||
if (i_prefab instanceof Prefab) {
|
||||
this.openViewByPrefab(null, i_prefab, i_openData, callBack, i_prefab, type);
|
||||
this.openViewByPrefab(
|
||||
null,
|
||||
i_prefab,
|
||||
i_openData,
|
||||
callBack,
|
||||
i_prefab,
|
||||
type
|
||||
);
|
||||
} else {
|
||||
console.log("打开界面:", i_prefab);
|
||||
ResManager.I.getPrefab(i_prefab, (pb: Node) => {
|
||||
ResManager.I.getPrefab(
|
||||
i_prefab,
|
||||
(pb: Node) => {
|
||||
this.openViewByPrefab(null, pb, i_openData, callBack, i_prefab, type);
|
||||
}, null);
|
||||
},
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
/**打开bundle弹窗 */
|
||||
openBundlesPopupView(
|
||||
i_prefab: string | Prefab,
|
||||
i_openData?,
|
||||
callBack = null
|
||||
) {
|
||||
if (i_prefab instanceof Prefab) {
|
||||
this.openViewByPrefab(
|
||||
null,
|
||||
i_prefab,
|
||||
i_openData,
|
||||
callBack,
|
||||
i_prefab,
|
||||
"tips"
|
||||
);
|
||||
} else {
|
||||
console.log("打开界面:", i_prefab);
|
||||
ResManager.I.getPrefab(
|
||||
i_prefab,
|
||||
(pb: Node) => {
|
||||
this.openViewByPrefab(
|
||||
null,
|
||||
pb,
|
||||
i_openData,
|
||||
callBack,
|
||||
i_prefab,
|
||||
"tips"
|
||||
);
|
||||
},
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**关闭窗体 */
|
||||
closeView(i_view: Node) {
|
||||
let closeUIName = null
|
||||
let closeUIName = null;
|
||||
let t_index = this.getViewIndex(i_view);
|
||||
if (t_index > -1) {
|
||||
let t_view = this.m_viewList[t_index];
|
||||
if (t_view) {
|
||||
closeUIName = t_view.name
|
||||
closeUIName = t_view.name;
|
||||
delete this.m_viewListData[t_view.name];
|
||||
t_view.destroy();
|
||||
t_view.removeFromParent();
|
||||
|
||||
}
|
||||
this.m_viewList.splice(t_index, 1); //删除列表元素 参数1是指定位置,参数2是删除元素个数
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!this.m_viewList.length) {
|
||||
i_view.destroy();
|
||||
}
|
||||
Utils.Log('试图关闭一个队列中不存在的界面:', i_view.name);
|
||||
Utils.Log("试图关闭一个队列中不存在的界面:", i_view.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,15 +282,13 @@ export class ViewManager extends Component {
|
||||
this.m_viewList = [];
|
||||
this.m_viewListData = {};
|
||||
this.openIdx = 0;
|
||||
|
||||
}
|
||||
|
||||
//是否在主界面,没有打开任何其他界面。主界面是在打开场景时直接创建的,不走这里的打开接口
|
||||
isNotOpenAnyUI() {
|
||||
if (this.m_viewList && this.m_viewList.length > 0) {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -335,17 +335,17 @@ export class GirlData extends BaseData {
|
||||
let price = oneData.getGrilPhotoPrice(id);
|
||||
if (price <= 0) {
|
||||
// 价格为0,代表免费
|
||||
displayIds.push({ id: id });
|
||||
displayIds.push(id);
|
||||
} else {
|
||||
// 价格大于0,代表付费
|
||||
let isUnlock = this.isImageUnlock(categoryId, girlId, id);
|
||||
if (isUnlock) {
|
||||
// 已经解锁
|
||||
displayIds.push({ id: id });
|
||||
displayIds.push(id);
|
||||
} else {
|
||||
// 总聊天次数 大于等于 触发次数
|
||||
if (chatTotalCount >= unlockCounts) {
|
||||
displayIds.push({ id: id });
|
||||
displayIds.push(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ export class GirlDetailData extends BaseData {
|
||||
if (!this.photoData) return null;
|
||||
// 遍历数组找到匹配的资源
|
||||
for (let oneData of this.photoData) {
|
||||
if (oneData.id === id) {
|
||||
if (oneData.id == id) {
|
||||
return oneData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ export class GirlListItem extends Component {
|
||||
ViewManager.I.closeView(this.baseNode);
|
||||
} else {
|
||||
//未解锁
|
||||
ViewManager.I.openBundlesView("GirlListPopupPanel", {
|
||||
ViewManager.I.openBundlesPopupView("GirlListPopupPanel", {
|
||||
base: this,
|
||||
category: this.category,
|
||||
id: this.id,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
Submodule proto_cs updated: 9ec1d4f077...f055100cf0
Reference in New Issue
Block a user