diff --git a/DataTables/Datas/global_config.xlsx b/DataTables/Datas/global_config.xlsx index f43d33c0..d5d40106 100644 Binary files a/DataTables/Datas/global_config.xlsx and b/DataTables/Datas/global_config.xlsx differ diff --git a/DataTables/output/tbglobalconfig.json b/DataTables/output/tbglobalconfig.json index 4a819c72..66b99a10 100644 --- a/DataTables/output/tbglobalconfig.json +++ b/DataTables/output/tbglobalconfig.json @@ -5,6 +5,7 @@ "Temperature": 0.7, "MaxTokens": 2048, "Timeout": 30000, - "FreeChatTimes": 20 + "FreeChatTimes": 20, + "GameName": "AIGirlChat" } ] \ No newline at end of file diff --git a/assets/Scenes/MainScene.scene b/assets/Scenes/MainScene.scene index a66d6ca7..381575da 100644 --- a/assets/Scenes/MainScene.scene +++ b/assets/Scenes/MainScene.scene @@ -18,15 +18,12 @@ "_children": [ { "__id__": 2 - }, - { - "__id__": 32 } ], "_active": true, "_components": [], "_prefab": { - "__id__": 34 + "__id__": 32 }, "_lpos": { "__type__": "cc.Vec3", @@ -57,7 +54,7 @@ }, "autoReleaseAssets": false, "_globals": { - "__id__": 35 + "__id__": 33 }, "_id": "1a23cd3e-e487-4fd1-a415-346c2087464d" }, @@ -1018,63 +1015,6 @@ }, "_id": "98EWBIubZPlZT+LFQb4IYI" }, - { - "__type__": "cc.Node", - "_name": "ConfigManager", - "_objFlags": 0, - "__editorExtras__": {}, - "_parent": { - "__id__": 1 - }, - "_children": [], - "_active": true, - "_components": [ - { - "__id__": 33 - } - ], - "_prefab": null, - "_lpos": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 0, - "y": 0, - "z": 0, - "w": 1 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 1, - "y": 1, - "z": 1 - }, - "_mobility": 0, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_id": "67ZXnZeExFXIu59phK6Xjz" - }, - { - "__type__": "fbd43WrI4tK6KXuGCPuxhSR", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 32 - }, - "_enabled": true, - "__prefab": null, - "_id": "57vDjH7bVD4JDeqZChrdP3" - }, { "__type__": "cc.PrefabInfo", "root": null, @@ -1086,28 +1026,28 @@ { "__type__": "cc.SceneGlobals", "ambient": { - "__id__": 36 + "__id__": 34 }, "shadows": { - "__id__": 37 + "__id__": 35 }, "_skybox": { - "__id__": 38 + "__id__": 36 }, "fog": { - "__id__": 39 + "__id__": 37 }, "octree": { - "__id__": 40 + "__id__": 38 }, "skin": { - "__id__": 41 + "__id__": 39 }, "lightProbeInfo": { - "__id__": 42 + "__id__": 40 }, "postSettings": { - "__id__": 43 + "__id__": 41 }, "bakedWithStationaryMainLight": false, "bakedWithHighpLightmap": false diff --git a/assets/Scripts/Main/Common/Utils.ts b/assets/Scripts/Main/Common/Utils.ts index 4558129a..ea0d1b03 100644 --- a/assets/Scripts/Main/Common/Utils.ts +++ b/assets/Scripts/Main/Common/Utils.ts @@ -1,328 +1,351 @@ -import { _decorator, Color, isValid, Label, Node, RichText, Size, Sprite, UITransform, Vec3, view } from "cc"; +import { + _decorator, + Color, + isValid, + Label, + Node, + RichText, + Size, + Sprite, + UITransform, + Vec3, + view, +} from "cc"; import li_EventManager from "./li_EventManager"; const { ccclass, property } = _decorator; @ccclass export default class Utils { - //log日志 - public static Log(msg: string | any, ...subst: any[]) { - let IsLocalCSChanel = true - if (IsLocalCSChanel) { - console.log(msg, subst) - } + //log日志 + public static Log(msg: string | any, ...subst: any[]) { + let IsLocalCSChanel = true; + if (IsLocalCSChanel) { + console.log(msg, subst); } - //警告日志 - public static Warning(msg: string | any, ...subst: any[]) { - let IsLocalCSChanel = true - if (IsLocalCSChanel) { - console.warn(msg, subst) - } + } + //警告日志 + public static Warning(msg: string | any, ...subst: any[]) { + let IsLocalCSChanel = true; + if (IsLocalCSChanel) { + console.warn(msg, subst); } - //错误日志 - public static Error(msg: string | any, ...subst: any[]) { - let IsLocalCSChanel = true - if (IsLocalCSChanel) { - console.error(msg, subst) - } + } + //错误日志 + public static Error(msg: string | any, ...subst: any[]) { + let IsLocalCSChanel = true; + if (IsLocalCSChanel) { + console.error(msg, subst); } + } + //解析节点 + public static parseNode = function (node: Node, oriObj?: any) { + if (!node || !node.children) return; + oriObj = oriObj || node; + let chs = node.children; + for (let i = 0; i < chs.length; i++) { + let ch = chs[i]; + let chName = ch.name; + if (chName && chName.length > 0) { + try { + oriObj[chName] = ch; + } catch (error) { + //hg_utils.hgLog("chName err:", chName); + } + } + Utils.parseNode(ch, oriObj); + } + }; - //解析节点 - public static parseNode = function (node: Node, oriObj?: any) { - if (!node || !node.children) return; - oriObj = oriObj || node; - let chs = node.children; - for (let i = 0; i < chs.length; i++) { - let ch = chs[i]; - let chName = ch.name; - if (chName && chName.length > 0) { - try { - oriObj[chName] = ch; - } catch (error) { - //hg_utils.hgLog("chName err:", chName); - } - } - Utils.parseNode(ch, oriObj); - } - } + //更换父节点,保留原有的坐标和旋转 + public static changeNodeParent(node: Node, parentNode: Node) { + let world_Q = node.getWorldRotation(); + let world_pos = node.getWorldPosition(); //原来的世界坐标 + node.setParent(parentNode); + node.setRotation(world_Q); + node.setWorldPosition(world_pos); + } - - //更换父节点,保留原有的坐标和旋转 - public static changeNodeParent(node:Node, parentNode:Node) { - let world_Q = node.getWorldRotation() - let world_pos = node.getWorldPosition()//原来的世界坐标 - node.setParent(parentNode) - node.setRotation(world_Q); - node.setWorldPosition(world_pos) + /** + * 封装setString方法 + */ + static setString(node: Node, str: string | number) { + if (!isValid(node)) return; + let lb: any = node.getComponent(Label); + if (!lb) return; + if (str == null) { + str = ""; } + str += ""; + lb.string = str; + } - - /** - * 封装setString方法 - */ - static setString(node: Node, str: string | number) { - if (!isValid(node)) return; - let lb:any = node.getComponent(Label); - if (!lb) return; - if(str == null) {str = ""} - str += "" - lb.string = str; + /** + * 添加富文本 + * @param node + * @param str + * @param outLine + * @param width + * @returns + */ + static addRichText( + node: Node, + str: string, + outLine: string | null = null, + width: number | null = 2, + max: number = 0 + ) { + if (!node) return; + let comp = node.getComponent(RichText); + if (!comp) return; + str = Utils.replaceAll(str, "", ""); + str = str.replace(/\<\/font\>/g, ""); + str = Utils.replaceAll(str, "'>", ">"); + str = Utils.replaceAll(str, "'); - str = Utils.replaceAll(str, "'>", ">"); - str = Utils.replaceAll(str, "(); public static jsonFileNames: string[] = []; - onLoad() { + private constructor() {} + + public init() { this.loadAllConfig(); } @@ -65,7 +71,7 @@ export default class ConfigManager extends Component { } Promise.all(promises).then((values) => { console.log("静态配置加载完成"); - ConfigManager.tables = new cfg.Tables(this.getFileData); + ConfigManager.tables = new cfg.Tables(ConfigManager.I.getFileData); for (let item of ConfigManager.tables.TbGirls.getDataList()) { console.log(item); } diff --git a/assets/Scripts/chat18x/ui/panels/ThemePanel.ts b/assets/Scripts/chat18x/ui/panels/ThemePanel.ts index 57c5a9c6..42eeab1d 100644 --- a/assets/Scripts/chat18x/ui/panels/ThemePanel.ts +++ b/assets/Scripts/chat18x/ui/panels/ThemePanel.ts @@ -71,14 +71,14 @@ export class ThemePanel extends li_BaseView { this.cache.push(item); this.content.addChild(newNode); } - const rectInfo = cfgs[0]; + const rectInfo = ConfigManager.tables.TbGirls.get(10001); this.recId = rectInfo.id; - this.rectNameKey = rectInfo.key; + this.rectNameKey = rectInfo.nameKey; //this.recName.string = LanguageUtils.getText(this.rectNameKey); ResManager.I.changeBundleSpriteFrame( this.recSprite, - rectInfo.path, + rectInfo.avatarPath, "Chat18x", () => { let sizeTran = this.recSprite.node.parent.getComponent(UITransform); diff --git a/assets/Scripts/schema/schema.ts b/assets/Scripts/schema/schema.ts index 30b4bf45..dfafa04c 100644 --- a/assets/Scripts/schema/schema.ts +++ b/assets/Scripts/schema/schema.ts @@ -194,6 +194,7 @@ export class GlobalConfig { this.MaxTokens = _buf_.readInt() this.Timeout = _buf_.readInt() this.FreeChatTimes = _buf_.readInt() + this.GameName = _buf_.readString() } /** @@ -217,6 +218,10 @@ export class GlobalConfig { * 单个角色免费聊天次数 */ readonly FreeChatTimes: number + /** + * 游戏名 + */ + readonly GameName: string resolve(tables:Tables) { @@ -225,6 +230,7 @@ export class GlobalConfig { + } } @@ -630,6 +636,10 @@ export class TbGlobalConfig { * 单个角色免费聊天次数 */ get FreeChatTimes(): number { return this._data.FreeChatTimes; } + /** + * 游戏名 + */ + get GameName(): string { return this._data.GameName; } resolve(tables:Tables) { this._data.resolve(tables) diff --git a/assets/bundles/DataTable/tbglobalconfig.bin b/assets/bundles/DataTable/tbglobalconfig.bin index fdf68ae7..74a319e7 100644 Binary files a/assets/bundles/DataTable/tbglobalconfig.bin and b/assets/bundles/DataTable/tbglobalconfig.bin differ