This commit is contained in:
2025-07-17 17:18:21 +08:00
commit 1ffc1b5cf0
5309 changed files with 1150310 additions and 0 deletions
@@ -0,0 +1,207 @@
import { _decorator, AssetManager, AudioClip, Button, Component, ImageAsset, JsonAsset, Label, Material, Node, Prefab, ProgressBar, Sprite, SpriteFrame } from 'cc';
import { GButton } from '../../Main/Common/GButton';
import ResManager from '../../Main/Manager/ResManager';
import Resource from '../../Main/Config/Resource';
import { SDKManager } from '../../Main/Channel/SDKManager';
import HttpUnit from '../../Main/Common/HttpUnit';
import GlobalValue from '../../Main/Common/GlobalValue';
import Utils from '../../Main/Common/Utils';
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
import { promptItem } from '../Item/promptItem';
const { ccclass, property } = _decorator;
@ccclass('PreloadUI')
export class PreloadUI extends Component {
private checkFinish = true; //检查完成
private preloadFinish = false; //资源加载完成
private loginFinish = false; //登录完成
private jinduBar: Node = null;
private jinduFilled: Sprite = null;
private LabProgress: Label = null;
private btnLogin: Sprite = null; //登录按钮
start() {
Utils.addInnerEL(InnerMsgCode.UI_ShowPrompt, this, this.resiveShowPrompt)
this.jinduBar = this.node.getChildByName("jinduBar");
this.jinduFilled = this.jinduBar.getChildByName("jinduFilled").getComponent(Sprite);
this.LabProgress = this.node.getChildByName("LabProgress").getComponent(Label);
this.btnLogin = this.node.getChildByName("btnLogin").getComponent(Sprite);
//适配背景图
let BG = this.node.getChildByName("BG");
Utils.adjustBgPixelRatio(BG, 1)
this.jinduFilled.fillRange = 0;
this.btnLogin.node.active = false;
this.preloadFiles()
}
protected onDestroy(): void {
Utils.removeInnerEL(InnerMsgCode.UI_ShowPrompt, this, this.resiveShowPrompt)
}
update(deltaTime: number) {
if (this.checkFinish) {
if (this.preloadFinish && this.loginFinish) {
this.checkFinish = false
this.enterGame()
}
}
}
/**收到飘字消息 */
resiveShowPrompt(data: any) {
let msg = data.text
let self = this
ResManager.I.loadSubpackagePrefab("item/promptItem", (n_node: Node)=>{
self.node.addChild(n_node)
let pItem = n_node.getComponent(promptItem)
pItem.setLabel(msg)
})
}
//预加载文件
preloadFiles() {
let preloadTab = [
{path:"Music/music_interface", bundleName: "Audio", ftype: AudioClip},
{path:"bg/mengli_stage_bg", bundleName: "Raw", ftype: ImageAsset},
{path:"cg0/mengli_0_cg", bundleName: "Raw", ftype: ImageAsset},
{path:"cg1/mengli_1_cg", bundleName: "Raw", ftype: ImageAsset},
{path:"cg2/mengli_2_cg", bundleName: "Raw", ftype: ImageAsset},
{path:"cg3/mengli_3_cg", bundleName: "Raw", ftype: ImageAsset},
{path:"emo_1/mengli_shy", bundleName: "Raw", ftype: ImageAsset},
{path:"emo_2/mengli_laugh", bundleName: "Raw", ftype: ImageAsset},
{path:"emo_3/mengli_disgust", bundleName: "Raw", ftype: ImageAsset},
{path:"role/mengli_default", bundleName: "Raw", ftype: ImageAsset},
{path:"Zjm/raw1", bundleName: "Raw", ftype: ImageAsset},
{path:"touming", bundleName: "common", ftype: ImageAsset},
// {path:"chanpin_1_0", bundleName: "daoju", ftype: ImageAsset}, //有合图加载失败
{path:"zjm_1", bundleName: "Zhujiemian", ftype: ImageAsset},
{path:"mohu", bundleName: "Materials", ftype: Material},
{path:"UI/Cross/Cross_UI", bundleName: "PB", ftype: Prefab},
{path:"UI/StartUI/Start_UI", bundleName: "PB", ftype: Prefab},
{path:"commonGlobal", bundleName: "DataTable", ftype: JsonAsset},
];
let num_prefab = 0; //已加载数量
let num_succeed = 0;//加载成功数量
let preloadFunc = () => {
if (num_prefab < preloadTab.length) {
let cfg = preloadTab[num_prefab]
ResManager.I.preLoadSubpackageFile(cfg.path, cfg.bundleName, cfg.ftype, (ret) => {
num_prefab++;
num_succeed++;
let percent = 0.45 * (num_prefab / preloadTab.length)
this.showLoadProgress(0.55 + percent);
console.log("加载成功:", cfg.path);
preloadFunc();
}, (err)=>{
num_prefab++;
console.log("加载失败:", err);
});
} else {
if (num_succeed >= num_prefab) {
this.loadDataTable();
}
}
}
preloadFunc();
}
//加载配置表
loadDataTable(){
let dataArr = [
"commonGlobal",
// "levelHole",
"Music",
"Sound",
]
//配置表使用方法: let cfgs = Resource.getConfig("Sound")
let num_prefab = 0;
let preloadFunc = () => {
if (num_prefab < dataArr.length) {
let cfgname = dataArr[num_prefab]
ResManager.I.loadSubpackageDataTable(cfgname, (ret: JsonAsset) => {
num_prefab++;
Resource.addSubJsonConfig(cfgname, ret.json)
preloadFunc();
});
} else {
this.preloadFinish = true;
this.onLogin();
}
}
preloadFunc();
}
//显示加载进度
showLoadProgress(percent) {
this.jinduFilled.fillRange = percent;
}
//登录
onLogin() {
//初始化SDK信息
SDKManager.init(() => {
//检测是否有授权,有授权直接登录,没有授权就先进主界面,到主界面获取权限
SDKManager.checkAutoSetting("userInfo", (ishave) => {
if (ishave) {
console.log("有授权,直接登录")
HttpUnit.ins.login((loginData) => {
if (loginData == null) {
//登录失败,这里处理重复登录的逻辑
} else {
this.loginFinish = true
}
})
} else {
console.log("没有授权,等待授权后登录")
// this.loginFinish = true
this.jinduBar.active = false
this.LabProgress.node.active = false
//登录按钮
this.btnLogin.node.active = true
let loginPath = ""
if (SDKManager.isWenxin()) {
loginPath = "login1"
} else if (SDKManager.isByteDance()) {
loginPath = "login2"
} else if (SDKManager.isKuaishou()) {
loginPath = "login3"
}
ResManager.I.changeResourceSpriteFrame(this.btnLogin, loginPath)
HttpUnit.ins.login((loginData) => {
if (loginData == null) {
//登录失败,这里处理重复登录的逻辑
} else {
this.loginFinish = true
}
})
}
})
})
}
enterGame() {
let islogin = HttpUnit.IsLogin();
console.log("进入游戏,登录状态:", islogin);
this.jinduBar.active = false
this.LabProgress.node.active = false
this.btnLogin.node.active = false
if (islogin) {
} else {
//没登录成功,先进主界面,在主界面里进行登录
}
ResManager.I.goMainScene(); //进入下一个场景
// ResManager.I.goCustomScene("Test2DScene"); //进入自定义场景
}
}
@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "5053c32c-96a6-4ca8-be98-f312605af709",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "5053c32c-96a6-4ca8-be98-f312605af709@6c48a",
"displayName": "danyu_disgust",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "5053c32c-96a6-4ca8-be98-f312605af709",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "5053c32c-96a6-4ca8-be98-f312605af709@f9941",
"displayName": "danyu_disgust",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -9,
"trimX": 159,
"trimY": 18,
"width": 607,
"height": 1171,
"rawWidth": 925,
"rawHeight": 1189,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-303.5,
-585.5,
0,
303.5,
-585.5,
0,
-303.5,
585.5,
0,
303.5,
585.5,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
159,
1171,
766,
1171,
159,
0,
766,
0
],
"nuv": [
0.17189189189189188,
0,
0.8281081081081081,
0,
0.17189189189189188,
0.9848612279226241,
0.8281081081081081,
0.9848612279226241
],
"minPos": [
-303.5,
-585.5,
0
],
"maxPos": [
303.5,
585.5,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "5053c32c-96a6-4ca8-be98-f312605af709@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "5053c32c-96a6-4ca8-be98-f312605af709@6c48a"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 406 KiB

@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "71b537dc-c128-4c2b-a101-9661041ae592",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "71b537dc-c128-4c2b-a101-9661041ae592@6c48a",
"displayName": "diduoduo_disgust",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "71b537dc-c128-4c2b-a101-9661041ae592",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "71b537dc-c128-4c2b-a101-9661041ae592@f9941",
"displayName": "diduoduo_disgust",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -53.5,
"trimX": 0,
"trimY": 107,
"width": 925,
"height": 1082,
"rawWidth": 925,
"rawHeight": 1189,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-462.5,
-541,
0,
462.5,
-541,
0,
-462.5,
541,
0,
462.5,
541,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
1082,
925,
1082,
0,
0,
925,
0
],
"nuv": [
0,
0,
1,
0,
0,
0.9100084104289319,
1,
0.9100084104289319
],
"minPos": [
-462.5,
-541,
0
],
"maxPos": [
462.5,
541,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "71b537dc-c128-4c2b-a101-9661041ae592@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "71b537dc-c128-4c2b-a101-9661041ae592@6c48a"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

@@ -0,0 +1,23 @@
{
"__version__": "3.0.7",
"game": {
"name": "未知游戏",
"app_id": "UNKNOW",
"c_id": "0"
},
"appConfigMaps": [
{
"app_id": "UNKNOW",
"config_id": "97f237"
}
],
"configs": [
{
"app_id": "UNKNOW",
"config_id": "97f237",
"config_name": "Default",
"config_remarks": "",
"services": []
}
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 419 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "3eb356aa-b44e-4b76-a09b-d4300332ae4a",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "3eb356aa-b44e-4b76-a09b-d4300332ae4a@6c48a",
"displayName": "nanamiya_rie_laugh",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "3eb356aa-b44e-4b76-a09b-d4300332ae4a",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "3eb356aa-b44e-4b76-a09b-d4300332ae4a@f9941",
"displayName": "nanamiya_rie_laugh",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "none",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 925,
"height": 1189,
"rawWidth": 925,
"rawHeight": 1189,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-462.5,
-594.5,
0,
462.5,
-594.5,
0,
-462.5,
594.5,
0,
462.5,
594.5,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
1189,
925,
1189,
0,
0,
925,
0
],
"nuv": [
0,
0,
1,
0,
0,
1,
1,
1
],
"minPos": [
-462.5,
-594.5,
0
],
"maxPos": [
462.5,
594.5,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "3eb356aa-b44e-4b76-a09b-d4300332ae4a@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "3eb356aa-b44e-4b76-a09b-d4300332ae4a@6c48a"
}
}
@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "f265e4bc-49bd-4277-90f2-353f37a6f070",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "f265e4bc-49bd-4277-90f2-353f37a6f070@6c48a",
"displayName": "maki_anna_laugh",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "f265e4bc-49bd-4277-90f2-353f37a6f070",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "f265e4bc-49bd-4277-90f2-353f37a6f070@f9941",
"displayName": "maki_anna_laugh",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -10,
"offsetY": -9,
"trimX": 73,
"trimY": 18,
"width": 759,
"height": 1171,
"rawWidth": 925,
"rawHeight": 1189,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-379.5,
-585.5,
0,
379.5,
-585.5,
0,
-379.5,
585.5,
0,
379.5,
585.5,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
73,
1171,
832,
1171,
73,
0,
832,
0
],
"nuv": [
0.07891891891891892,
0,
0.8994594594594595,
0,
0.07891891891891892,
0.9848612279226241,
0.8994594594594595,
0.9848612279226241
],
"minPos": [
-379.5,
-585.5,
0
],
"maxPos": [
379.5,
585.5,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "f265e4bc-49bd-4277-90f2-353f37a6f070@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "f265e4bc-49bd-4277-90f2-353f37a6f070@6c48a"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 813 KiB