@cc-component/cc-core 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cc-ex-component.md +12 -0
- package/assets/core/config/CommonEnum.ts +94 -0
- package/assets/core/config/CommonEnum.ts.meta +9 -0
- package/assets/core/config/IConfig.ts +89 -0
- package/assets/core/config/IConfig.ts.meta +9 -0
- package/assets/core/config/LayerType.ts +44 -0
- package/assets/core/config/LayerType.ts.meta +9 -0
- package/assets/core/config/LayerUI.ts +113 -0
- package/assets/core/config/LayerUI.ts.meta +9 -0
- package/assets/core/config.meta +9 -0
- package/assets/core/editor/LanguageManager.ts +323 -0
- package/assets/core/editor/LanguageManager.ts.meta +9 -0
- package/assets/core/editor/SpineRunner.ts +39 -0
- package/assets/core/editor/SpineRunner.ts.meta +9 -0
- package/assets/core/editor/i18nEditorComponent.ts +137 -0
- package/assets/core/editor/i18nEditorComponent.ts.meta +9 -0
- package/assets/core/editor.meta +9 -0
- package/assets/core/home/AudioUtil.ts +164 -0
- package/assets/core/home/AudioUtil.ts.meta +9 -0
- package/assets/core/home/BaseBoxView.ts +60 -0
- package/assets/core/home/BaseBoxView.ts.meta +9 -0
- package/assets/core/home/BaseLaunchComponent.ts +9 -0
- package/assets/core/home/BaseLaunchComponent.ts.meta +9 -0
- package/assets/core/home/BaseLoading.ts +136 -0
- package/assets/core/home/BaseLoading.ts.meta +9 -0
- package/assets/core/home/BaseSkeleton.ts +39 -0
- package/assets/core/home/BaseSkeleton.ts.meta +9 -0
- package/assets/core/home/CameraAngel.ts +326 -0
- package/assets/core/home/CameraAngel.ts.meta +9 -0
- package/assets/core/home/DouYinShow.ts +27 -0
- package/assets/core/home/DouYinShow.ts.meta +9 -0
- package/assets/core/home/EventManager.ts +39 -0
- package/assets/core/home/EventManager.ts.meta +9 -0
- package/assets/core/home/ExView.ts +9 -0
- package/assets/core/home/ExView.ts.meta +9 -0
- package/assets/core/home/FollowCamera.ts +205 -0
- package/assets/core/home/FollowCamera.ts.meta +9 -0
- package/assets/core/home/InViewCenter.ts +52 -0
- package/assets/core/home/InViewCenter.ts.meta +9 -0
- package/assets/core/home/JsonUtil.ts +102 -0
- package/assets/core/home/JsonUtil.ts.meta +9 -0
- package/assets/core/home/LoadingWindow.ts +44 -0
- package/assets/core/home/LoadingWindow.ts.meta +9 -0
- package/assets/core/home/ParabolaTween.ts +110 -0
- package/assets/core/home/ParabolaTween.ts.meta +9 -0
- package/assets/core/home/ProgessView.ts +96 -0
- package/assets/core/home/ProgessView.ts.meta +9 -0
- package/assets/core/home/Quaternion.ts +237 -0
- package/assets/core/home/Quaternion.ts.meta +9 -0
- package/assets/core/home/ResUtil.ts +132 -0
- package/assets/core/home/ResUtil.ts.meta +9 -0
- package/assets/core/home/ResourceManager.ts +430 -0
- package/assets/core/home/ResourceManager.ts.meta +9 -0
- package/assets/core/home/StateMachine.ts +93 -0
- package/assets/core/home/StateMachine.ts.meta +9 -0
- package/assets/core/home/StorageManager.ts +161 -0
- package/assets/core/home/StorageManager.ts.meta +9 -0
- package/assets/core/home/ThirdFreeLookCamera.ts +201 -0
- package/assets/core/home/ThirdFreeLookCamera.ts.meta +9 -0
- package/assets/core/home/TimeManager.ts +486 -0
- package/assets/core/home/TimeManager.ts.meta +9 -0
- package/assets/core/home/Tools.ts +103 -0
- package/assets/core/home/Tools.ts.meta +9 -0
- package/assets/core/home/prefabs.meta +12 -0
- package/assets/core/home/util/EncryptUtil.ts +60 -0
- package/assets/core/home/util/EncryptUtil.ts.meta +11 -0
- package/assets/core/home/util/MathUtil.ts +22 -0
- package/assets/core/home/util/MathUtil.ts.meta +9 -0
- package/assets/core/home/util/Md5.ts +202 -0
- package/assets/core/home/util/Md5.ts.meta +11 -0
- package/assets/core/home/util/RandomUtil.ts +61 -0
- package/assets/core/home/util/RandomUtil.ts.meta +9 -0
- package/assets/core/home/util/ResUtil.ts +129 -0
- package/assets/core/home/util/ResUtil.ts.meta +9 -0
- package/assets/core/home/util/crypto-js.d.ts +30 -0
- package/assets/core/home/util/crypto-js.d.ts.meta +11 -0
- package/assets/core/home/util/crypto-js.js +6030 -0
- package/assets/core/home/util/crypto-js.js.meta +9 -0
- package/assets/core/home/util.meta +12 -0
- package/assets/core/home.meta +12 -0
- package/assets/core/interface/ISceneParam.ts +11 -0
- package/assets/core/interface/ISceneParam.ts.meta +9 -0
- package/assets/core/interface/Interface.ts +160 -0
- package/assets/core/interface/Interface.ts.meta +1 -0
- package/assets/core/interface/MainModule.ts +1019 -0
- package/assets/core/interface/MainModule.ts.meta +9 -0
- package/assets/core/interface.meta +9 -0
- package/assets/core/lib/Logger.ts +286 -0
- package/assets/core/lib/Logger.ts.meta +9 -0
- package/assets/core/lib/language/.language.md +1 -0
- package/assets/core/lib/language/Language.ts +133 -0
- package/assets/core/lib/language/Language.ts.meta +13 -0
- package/assets/core/lib/language/LanguageData.ts +114 -0
- package/assets/core/lib/language/LanguageData.ts.meta +9 -0
- package/assets/core/lib/language/LanguageLabel.ts +172 -0
- package/assets/core/lib/language/LanguageLabel.ts.meta +13 -0
- package/assets/core/lib/language/LanguagePack.ts +126 -0
- package/assets/core/lib/language/LanguagePack.ts.meta +13 -0
- package/assets/core/lib/language/LanguagePointLabel.ts.meta +16 -0
- package/assets/core/lib/language/LanguageSpine.ts +60 -0
- package/assets/core/lib/language/LanguageSpine.ts.meta +9 -0
- package/assets/core/lib/language/LanguageSprite.ts +138 -0
- package/assets/core/lib/language/LanguageSprite.ts.meta +13 -0
- package/assets/core/lib/language.meta +9 -0
- package/assets/core/lib/logger/ELoggerLevel.ts +16 -0
- package/assets/core/lib/logger/ELoggerLevel.ts.meta +9 -0
- package/assets/core/lib/logger/MLogger.ts +118 -0
- package/assets/core/lib/logger/MLogger.ts.meta +9 -0
- package/assets/core/lib/logger.meta +9 -0
- package/assets/core/lib/net/libs/proto/output/protobuf.d.ts +2729 -0
- package/assets/core/lib/net/libs/proto/output/protobuf.d.ts.meta +9 -0
- package/assets/core/lib/net/libs/proto/output/protobuf.min.js +8 -0
- package/assets/core/lib/net/libs/proto/output/protobuf.min.js.meta +9 -0
- package/assets/core/lib/net/libs/proto/output/protobuf_custom.d.ts +102 -0
- package/assets/core/lib/net/libs/proto/output/protobuf_custom.d.ts.meta +9 -0
- package/assets/core/lib/net/libs/proto/output/protobuf_custom.js +222 -0
- package/assets/core/lib/net/libs/proto/output/protobuf_custom.js.meta +9 -0
- package/assets/core/lib/net/libs/proto/output.meta +9 -0
- package/assets/core/lib/net/libs/proto/source/Cmd.proto +6 -0
- package/assets/core/lib/net/libs/proto/source/Cmd.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/UserLogin.proto +12 -0
- package/assets/core/lib/net/libs/proto/source/UserLogin.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/base.proto +24 -0
- package/assets/core/lib/net/libs/proto/source/base.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/command.proto +31 -0
- package/assets/core/lib/net/libs/proto/source/command.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/domain/boos_battle_info.proto +13 -0
- package/assets/core/lib/net/libs/proto/source/domain/boos_battle_info.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/domain/player_auth.proto +26 -0
- package/assets/core/lib/net/libs/proto/source/domain/player_auth.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/domain.meta +9 -0
- package/assets/core/lib/net/libs/proto/source/message/game_push.proto +23 -0
- package/assets/core/lib/net/libs/proto/source/message/game_push.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/message/game_request.proto +24 -0
- package/assets/core/lib/net/libs/proto/source/message/game_request.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/message/game_response.proto +24 -0
- package/assets/core/lib/net/libs/proto/source/message/game_response.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/message.meta +9 -0
- package/assets/core/lib/net/libs/proto/source/push/boss_battle_events.proto +43 -0
- package/assets/core/lib/net/libs/proto/source/push/boss_battle_events.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/push.meta +9 -0
- package/assets/core/lib/net/libs/proto/source.meta +12 -0
- package/assets/core/lib/net/libs/proto.meta +9 -0
- package/assets/core/lib/net/libs.meta +9 -0
- package/assets/core/lib/net/net/HttpManager.ts +307 -0
- package/assets/core/lib/net/net/HttpManager.ts.meta +9 -0
- package/assets/core/lib/net/net/NetInterface.ts +114 -0
- package/assets/core/lib/net/net/NetInterface.ts.meta +9 -0
- package/assets/core/lib/net/net/NetManager.ts +77 -0
- package/assets/core/lib/net/net/NetManager.ts.meta +9 -0
- package/assets/core/lib/net/net/NetNode.ts +471 -0
- package/assets/core/lib/net/net/NetNode.ts.meta +9 -0
- package/assets/core/lib/net/net/WebSock.ts +81 -0
- package/assets/core/lib/net/net/WebSock.ts.meta +9 -0
- package/assets/core/lib/net/net/custom/NetChannelManager.ts +41 -0
- package/assets/core/lib/net/net/custom/NetChannelManager.ts.meta +9 -0
- package/assets/core/lib/net/net/custom/NetConfig.ts +11 -0
- package/assets/core/lib/net/net/custom/NetConfig.ts.meta +9 -0
- package/assets/core/lib/net/net/custom/NetErrorCode.ts +4 -0
- package/assets/core/lib/net/net/custom/NetErrorCode.ts.meta +9 -0
- package/assets/core/lib/net/net/custom/NetGameTips.ts +53 -0
- package/assets/core/lib/net/net/custom/NetGameTips.ts.meta +9 -0
- package/assets/core/lib/net/net/custom/NetNodeGame.ts +105 -0
- package/assets/core/lib/net/net/custom/NetNodeGame.ts.meta +9 -0
- package/assets/core/lib/net/net/custom.meta +9 -0
- package/assets/core/lib/net/net/protocol/NetProtocolJson.ts +39 -0
- package/assets/core/lib/net/net/protocol/NetProtocolJson.ts.meta +9 -0
- package/assets/core/lib/net/net/protocol/NetProtocolProtobuf.ts +85 -0
- package/assets/core/lib/net/net/protocol/NetProtocolProtobuf.ts.meta +9 -0
- package/assets/core/lib/net/net/protocol.meta +9 -0
- package/assets/core/lib/net/net.meta +9 -0
- package/assets/core/lib/net/prompt.meta +9 -0
- package/assets/core/lib/net.meta +9 -0
- package/assets/core/lib/old/VM2.ts +619 -0
- package/assets/core/lib/old/VM2.ts.meta +9 -0
- package/assets/core/lib/old/ViewModel.ts +905 -0
- package/assets/core/lib/old/ViewModel.ts.meta +9 -0
- package/assets/core/lib/old/ViewSearch.ts +125 -0
- package/assets/core/lib/old/ViewSearch.ts.meta +9 -0
- package/assets/core/lib/old.meta +9 -0
- package/assets/core/lib/tabbar/TabBarComponent.ts +113 -0
- package/assets/core/lib/tabbar/TabBarComponent.ts.meta +9 -0
- package/assets/core/lib/tabbar/TabBarController.ts +86 -0
- package/assets/core/lib/tabbar/TabBarController.ts.meta +9 -0
- package/assets/core/lib/tabbar/TabBarItem.ts +52 -0
- package/assets/core/lib/tabbar/TabBarItem.ts.meta +9 -0
- package/assets/core/lib/tabbar.meta +9 -0
- package/assets/core/lib.meta +12 -0
- package/assets/core.meta +9 -0
- package/assets.meta +9 -0
- package/index.ts +3 -0
- package/index.ts.meta +9 -0
- package/package.json +19 -0
- package/package.json.meta +11 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { CCString, Component, Label, RichText, TTFFont, _decorator, warn } from "cc";
|
|
2
|
+
import { EDITOR } from "cc/env";
|
|
3
|
+
import { LanguageData, LanguageDataType } from "./LanguageData";
|
|
4
|
+
import { assetManager } from "cc";
|
|
5
|
+
import { JsonAsset } from "cc";
|
|
6
|
+
import { IConfig } from "../../config/IConfig";
|
|
7
|
+
|
|
8
|
+
const { ccclass, property, executeInEditMode, disallowMultiple, requireComponent, menu } = _decorator;
|
|
9
|
+
@ccclass("LangLabelParamsItem")
|
|
10
|
+
export class LangLabelParamsItem {
|
|
11
|
+
@property
|
|
12
|
+
key: string = "";
|
|
13
|
+
@property
|
|
14
|
+
value: string = "";
|
|
15
|
+
}
|
|
16
|
+
@ccclass("LanguageLabel")
|
|
17
|
+
//@ccclass
|
|
18
|
+
@executeInEditMode
|
|
19
|
+
//@disallowMultiple
|
|
20
|
+
/** 文本多语言 */
|
|
21
|
+
@menu('OopsFramework/Language/LanguageLabel (文本多语言)')
|
|
22
|
+
export class LanguageLabel extends Component {
|
|
23
|
+
@property({
|
|
24
|
+
type: LangLabelParamsItem,
|
|
25
|
+
displayName: "params"
|
|
26
|
+
})
|
|
27
|
+
private _params: Array<LangLabelParamsItem> = [];
|
|
28
|
+
|
|
29
|
+
@property({
|
|
30
|
+
type: LangLabelParamsItem,
|
|
31
|
+
displayName: "params"
|
|
32
|
+
})
|
|
33
|
+
set params(value: Array<LangLabelParamsItem>) {
|
|
34
|
+
this._params = value;
|
|
35
|
+
if (!EDITOR) {
|
|
36
|
+
this._needUpdate = true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
get params(): Array<LangLabelParamsItem> {
|
|
40
|
+
return this._params || [];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@property({ serializable: true })
|
|
44
|
+
private _dataID: string = "";
|
|
45
|
+
@property({ type: CCString, serializable: true })
|
|
46
|
+
get dataID(): string {
|
|
47
|
+
return this._dataID || "";
|
|
48
|
+
}
|
|
49
|
+
set dataID(value: string) {
|
|
50
|
+
this._dataID = value;
|
|
51
|
+
if (EDITOR) {
|
|
52
|
+
// this._needUpdate = true;
|
|
53
|
+
this.changeLabelEditor()
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get string(): string {
|
|
58
|
+
let _string = LanguageData.getLangByID(this._dataID);
|
|
59
|
+
if (_string && this._params.length > 0) {
|
|
60
|
+
this._params.forEach((item: LangLabelParamsItem) => {
|
|
61
|
+
_string = _string.replace(`%{${item.key}}`, item.value)
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
if (!_string) {
|
|
65
|
+
warn("[LanguageLabel] 未找到语言标识,使用dataID替换");
|
|
66
|
+
_string = this._dataID;
|
|
67
|
+
}
|
|
68
|
+
return _string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** 更新语言 */
|
|
72
|
+
language() {
|
|
73
|
+
this._needUpdate = true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** 初始字体尺寸 */
|
|
77
|
+
initFontSize: number = 0;
|
|
78
|
+
|
|
79
|
+
onLoad() {
|
|
80
|
+
this._needUpdate = true;
|
|
81
|
+
this.addEditor()
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 修改多语言参数,采用惰性求值策略
|
|
87
|
+
* @param key 对于i18n表里面的key值
|
|
88
|
+
* @param value 替换的文本
|
|
89
|
+
*/
|
|
90
|
+
setVars(key: string, value: string) {
|
|
91
|
+
let haskey = false;
|
|
92
|
+
for (let i = 0; i < this._params.length; i++) {
|
|
93
|
+
let element: LangLabelParamsItem = this._params[i];
|
|
94
|
+
if (element.key === key) {
|
|
95
|
+
element.value = value;
|
|
96
|
+
haskey = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (!haskey) {
|
|
100
|
+
let ii = new LangLabelParamsItem();
|
|
101
|
+
ii.key = key;
|
|
102
|
+
ii.value = value;
|
|
103
|
+
this._params.push(ii);
|
|
104
|
+
}
|
|
105
|
+
this._needUpdate = true;
|
|
106
|
+
}
|
|
107
|
+
private _needUpdate: boolean = false;
|
|
108
|
+
|
|
109
|
+
update() {
|
|
110
|
+
if (this._needUpdate) {
|
|
111
|
+
this.updateContent();
|
|
112
|
+
this._needUpdate = false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
updateContent() {
|
|
117
|
+
const label = this.getComponent(Label);
|
|
118
|
+
const richtext = this.getComponent(RichText);
|
|
119
|
+
const font: TTFFont | null = LanguageData.font;
|
|
120
|
+
|
|
121
|
+
// console.log('过呢更新', this.node.name, this.string, LanguageData.current)
|
|
122
|
+
if (label) {
|
|
123
|
+
if (font) {
|
|
124
|
+
label.font = font;
|
|
125
|
+
}
|
|
126
|
+
label.string = this.string;
|
|
127
|
+
this.initFontSize = label.fontSize;
|
|
128
|
+
}
|
|
129
|
+
else if (richtext) {
|
|
130
|
+
if (font) {
|
|
131
|
+
richtext.font = font;
|
|
132
|
+
}
|
|
133
|
+
richtext.string = this.string;
|
|
134
|
+
this.initFontSize = richtext.fontSize;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
warn("[LanguageLabel], 该节点没有cc.Label || cc.RichText组件");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async addEditor() {
|
|
142
|
+
if (EDITOR) {
|
|
143
|
+
await MainModule.InitGameConfig()
|
|
144
|
+
MainModule.language.addEditorLabel(this);
|
|
145
|
+
this.changeLabelEditor()
|
|
146
|
+
} else {
|
|
147
|
+
LanguageData.updateLanguage();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**编辑器环境下改变多语言 */
|
|
152
|
+
public async changeLabelEditor() {
|
|
153
|
+
const dbUrl = await LanguageData.loadDBEditor(this.node)
|
|
154
|
+
await LanguageData.loadConfig()
|
|
155
|
+
const db_json = dbUrl + `/${MainModule.gui.config.language.path.json}/${LanguageData.current}.json`
|
|
156
|
+
|
|
157
|
+
let uuid = await Editor.Message.request("asset-db", "query-uuid", db_json);
|
|
158
|
+
assetManager.loadAny(uuid, (err, jsonAsset: JsonAsset) => {
|
|
159
|
+
// console.log("加载表格", jsonAsset, err);
|
|
160
|
+
if (!jsonAsset) return;
|
|
161
|
+
let labelData = jsonAsset.json;
|
|
162
|
+
LanguageData.language.set(LanguageDataType.Json, jsonAsset.json);
|
|
163
|
+
MainModule.language.labelArr.forEach((com) => {
|
|
164
|
+
com.updateContent()
|
|
165
|
+
})
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
}
|
|
172
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ver": "4.0.24",
|
|
3
|
+
"importer": "typescript",
|
|
4
|
+
"imported": true,
|
|
5
|
+
"uuid": "110c8bc4-7793-443c-bfcd-f66786427697",
|
|
6
|
+
"files": [],
|
|
7
|
+
"subMetas": {},
|
|
8
|
+
"userData": {
|
|
9
|
+
"moduleId": "project:///assets/script/core/gui/language/LanguageLabel.js",
|
|
10
|
+
"importerSettings": 4,
|
|
11
|
+
"simulateGlobals": []
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: dgflash
|
|
3
|
+
* @Date: 2021-07-03 16:13:17
|
|
4
|
+
* @LastEditors: dgflash
|
|
5
|
+
* @LastEditTime: 2023-08-22 16:34:28
|
|
6
|
+
*/
|
|
7
|
+
import { director, error, JsonAsset, TTFFont } from "cc";
|
|
8
|
+
//import { resLoader } from "../../../core/common/loader/ResLoader";
|
|
9
|
+
|
|
10
|
+
import { LanguageData, LanguageDataType, LanguageType } from "./LanguageData";
|
|
11
|
+
import { ResourceManager } from "../../home/ResourceManager";
|
|
12
|
+
import { SpriteFrame } from "cc";
|
|
13
|
+
import { sp } from "cc";
|
|
14
|
+
import { JsonUtil } from "../../home/JsonUtil";
|
|
15
|
+
import { Logger } from "../Logger";
|
|
16
|
+
|
|
17
|
+
export class LanguagePack {
|
|
18
|
+
/**
|
|
19
|
+
* 刷新语言文字
|
|
20
|
+
* @param lang
|
|
21
|
+
*/
|
|
22
|
+
updateLanguage(lang: string) {
|
|
23
|
+
let rootNodes = director.getScene()!.children;
|
|
24
|
+
for (let i = 0; i < rootNodes.length; ++i) {
|
|
25
|
+
LanguageType.forEach(type => {
|
|
26
|
+
let comps: any[] = rootNodes[i].getComponentsInChildren(type);
|
|
27
|
+
for (let j = 0; j < comps.length; j++) {
|
|
28
|
+
comps[j].language();
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 下载对应语言包资源
|
|
36
|
+
* @param lang 语言标识
|
|
37
|
+
* @param callback 下载完成回调
|
|
38
|
+
*/
|
|
39
|
+
async loadLanguageAssets(bundleName: string, lang: string, callback: Function) {
|
|
40
|
+
await this.loadTexture(bundleName, lang);
|
|
41
|
+
await this.loadSpine(bundleName, lang);
|
|
42
|
+
await this.loadJson(bundleName, lang);
|
|
43
|
+
//await this.loadTable(bundleName, lang);
|
|
44
|
+
|
|
45
|
+
callback(lang);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** 多语言Excel配置表数据 */
|
|
49
|
+
// private loadTable(bundleName: string, lang: string): Promise<void> {
|
|
50
|
+
// return new Promise(async (resolve, reject) => {
|
|
51
|
+
// let json = await JsonUtil.load("Language");
|
|
52
|
+
// if (json) {
|
|
53
|
+
// LanguageData.language.set(LanguageDataType.Excel, json);
|
|
54
|
+
// Logger.logConfig("config/game/Language", "下载语言包 table 资源");
|
|
55
|
+
// }
|
|
56
|
+
// resolve();
|
|
57
|
+
// });
|
|
58
|
+
// }
|
|
59
|
+
|
|
60
|
+
/** 纹理多语言资源 */
|
|
61
|
+
private loadTexture(bundleName: string, lang: string): Promise<void> {
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
const path = `${LanguageData.path_texture}/${lang}`;
|
|
64
|
+
MainModule.loadDir(bundleName, path, SpriteFrame, () => { }).then(() => {
|
|
65
|
+
Logger.logConfig(path, "下载语言包 textures 资源");
|
|
66
|
+
resolve();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Json格式多语言资源 */
|
|
72
|
+
private loadJson(bundleName: string, lang: string): Promise<void> {
|
|
73
|
+
return new Promise(async (resolve, reject) => {
|
|
74
|
+
const path = `${LanguageData.path_json}/${lang}`;
|
|
75
|
+
const jsonAsset = await MainModule.loadAsset(bundleName, path, JsonAsset);
|
|
76
|
+
if (jsonAsset) {
|
|
77
|
+
LanguageData.language.set(LanguageDataType.Json, jsonAsset.json);
|
|
78
|
+
Logger.logConfig(path, "下载语言包 json 资源");
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
resolve();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
MainModule.loadAsset(bundleName, path, TTFFont).then((font: TTFFont) => {
|
|
86
|
+
Logger.logConfig(path, "下载语言包 ttf 资源");
|
|
87
|
+
LanguageData.font = font;
|
|
88
|
+
resolve();
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** SPINE动画多语言资源 */
|
|
94
|
+
private loadSpine(bundleName: string, lang: string): Promise<void> {
|
|
95
|
+
return new Promise(async (resolve, reject) => {
|
|
96
|
+
const path = `${LanguageData.path_spine}/${lang}`;
|
|
97
|
+
MainModule.loadDir(bundleName, path, sp.Skeleton, () => { }).then(() => {
|
|
98
|
+
Logger.logConfig(path, "下载语言包 spine 资源");
|
|
99
|
+
resolve();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 释放某个语言的语言包资源包括json
|
|
106
|
+
* @param lang
|
|
107
|
+
*/
|
|
108
|
+
releaseLanguageAssets(lang: string) {
|
|
109
|
+
// let langTexture = `${LanguageData.path_texture}/${lang}`;
|
|
110
|
+
// resLoader.releaseDir(langTexture);
|
|
111
|
+
|
|
112
|
+
// let langJson = `${LanguageData.path_json}/${lang}`;
|
|
113
|
+
// let json = resLoader.get(langJson, JsonAsset);
|
|
114
|
+
// if (json) {
|
|
115
|
+
// json.decRef();
|
|
116
|
+
// }
|
|
117
|
+
|
|
118
|
+
// let font = resLoader.get(langJson, TTFFont);
|
|
119
|
+
// if (font) {
|
|
120
|
+
// font.decRef();
|
|
121
|
+
// }
|
|
122
|
+
|
|
123
|
+
// let langSpine = `${LanguageData.path_spine}/${lang}`;
|
|
124
|
+
// resLoader.release(langSpine);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ver": "4.0.24",
|
|
3
|
+
"importer": "typescript",
|
|
4
|
+
"imported": true,
|
|
5
|
+
"uuid": "2ffebca3-e7dc-4873-8bf8-059b72f120e6",
|
|
6
|
+
"files": [],
|
|
7
|
+
"subMetas": {},
|
|
8
|
+
"userData": {
|
|
9
|
+
"moduleId": "project:///assets/script/core/gui/language/LanguagePack.js",
|
|
10
|
+
"importerSettings": 4,
|
|
11
|
+
"simulateGlobals": []
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ver": "4.0.1",
|
|
3
|
+
"importer": "typescript",
|
|
4
|
+
"imported": true,
|
|
5
|
+
"uuid": "a1bd53a3-66a7-4477-8c18-9254dc5983bf",
|
|
6
|
+
"files": [
|
|
7
|
+
".js",
|
|
8
|
+
".trans"
|
|
9
|
+
],
|
|
10
|
+
"subMetas": {},
|
|
11
|
+
"userData": {
|
|
12
|
+
"importAsPlugin": false,
|
|
13
|
+
"moduleId": "project:///assets/script/core/gui/language/LanguagePointLabel.js",
|
|
14
|
+
"importerSettings": 3
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: dgflash
|
|
3
|
+
* @Date: 2023-07-25 10:44:38
|
|
4
|
+
* @LastEditors: dgflash
|
|
5
|
+
* @LastEditTime: 2023-07-25 11:48:52
|
|
6
|
+
*/
|
|
7
|
+
import { CCString, Component, _decorator, sp } from "cc";
|
|
8
|
+
import { EDITOR } from "cc/env";
|
|
9
|
+
import { LanguageData } from "./LanguageData";
|
|
10
|
+
|
|
11
|
+
const { ccclass, property, menu } = _decorator;
|
|
12
|
+
|
|
13
|
+
/** Spine 动画多语言 */
|
|
14
|
+
@ccclass("LanguageSpine")
|
|
15
|
+
@menu('OopsFramework/Language/LanguageSpine (Spine 动画多语言)')
|
|
16
|
+
export class LanguageSpine extends Component {
|
|
17
|
+
@property({ serializable: true })
|
|
18
|
+
private _dataID: string = "";
|
|
19
|
+
@property({ type: CCString, serializable: true })
|
|
20
|
+
get dataID(): string {
|
|
21
|
+
return this._dataID || "";
|
|
22
|
+
}
|
|
23
|
+
set dataID(value: string) {
|
|
24
|
+
this._dataID = value;
|
|
25
|
+
if (!EDITOR) {
|
|
26
|
+
this.updateSpine();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** 默认动画名 */
|
|
31
|
+
private _defaultAnimation: string = "";
|
|
32
|
+
|
|
33
|
+
onLoad() {
|
|
34
|
+
let spine: sp.Skeleton = this.getComponent(sp.Skeleton)!;
|
|
35
|
+
this._defaultAnimation = spine.animation;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
start() {
|
|
39
|
+
this.updateSpine();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** 更新语言 */
|
|
43
|
+
language() {
|
|
44
|
+
this.updateSpine();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private updateSpine() {
|
|
48
|
+
// 获取语言标记
|
|
49
|
+
let path = `language/spine/${LanguageData.current}/${this.dataID}`;
|
|
50
|
+
let res: sp.SkeletonData | null = MainModule.getAsset(MainModule.bundleName, path, sp.SkeletonData);
|
|
51
|
+
if (res) {
|
|
52
|
+
let spine: sp.Skeleton = this.getComponent(sp.Skeleton)!;
|
|
53
|
+
spine.skeletonData = res;
|
|
54
|
+
spine.setAnimation(0, this._defaultAnimation, true);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
console.error("[LanguageSpine] 资源不存在 " + path);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: dgflash
|
|
3
|
+
* @Date: 2021-11-24 15:51:01
|
|
4
|
+
* @LastEditors: dgflash
|
|
5
|
+
* @LastEditTime: 2022-09-02 10:04:57
|
|
6
|
+
*/
|
|
7
|
+
import { CCString, Component, Size, Sprite, SpriteFrame, UITransform, _decorator } from "cc";
|
|
8
|
+
import { EDITOR } from "cc/env";
|
|
9
|
+
import { LanguageData } from "./LanguageData";
|
|
10
|
+
import { sp } from "cc";
|
|
11
|
+
import { assetManager } from "cc";
|
|
12
|
+
import { ImageAsset } from "cc";
|
|
13
|
+
import { JsonAsset } from "cc";
|
|
14
|
+
import { IConfig } from "../../config/IConfig";
|
|
15
|
+
|
|
16
|
+
const { ccclass, property, executeInEditMode, disallowMultiple, requireComponent, menu } = _decorator;
|
|
17
|
+
|
|
18
|
+
/** 图片多语言 */
|
|
19
|
+
@ccclass("LanguageSprite")
|
|
20
|
+
@executeInEditMode
|
|
21
|
+
@menu('OopsFramework/Language/LanguageSprite (图片多语言)')
|
|
22
|
+
export class LanguageSprite extends Component {
|
|
23
|
+
@property({ serializable: true })
|
|
24
|
+
private _dataID: string = "";
|
|
25
|
+
@property({ type: CCString, serializable: true })
|
|
26
|
+
get dataID(): string {
|
|
27
|
+
return this._dataID || "";
|
|
28
|
+
}
|
|
29
|
+
set dataID(value: string) {
|
|
30
|
+
this._dataID = value;
|
|
31
|
+
if (!EDITOR) {
|
|
32
|
+
this.updateSprite();
|
|
33
|
+
}
|
|
34
|
+
if (EDITOR) {
|
|
35
|
+
this.changeSpriteEditor()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@property({
|
|
41
|
+
tooltip: "是否设置为图片原始资源大小"
|
|
42
|
+
})
|
|
43
|
+
private isRawSize: boolean = true;
|
|
44
|
+
|
|
45
|
+
protected onLoad(): void {
|
|
46
|
+
this.addEditor()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
start() {
|
|
51
|
+
this.updateSprite();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** 更新语言 */
|
|
55
|
+
language() {
|
|
56
|
+
this.updateSprite();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public async updateSprite() {
|
|
60
|
+
let path = `language/texture/${LanguageData.current}/${this.dataID}/spriteFrame`;
|
|
61
|
+
let res: SpriteFrame | null
|
|
62
|
+
// 获取语言标记
|
|
63
|
+
res = MainModule.getAsset(MainModule.bundleName, path, SpriteFrame);
|
|
64
|
+
if (!res) {
|
|
65
|
+
res = await MainModule.loadAsset(MainModule.bundleName, path, SpriteFrame)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (res) {
|
|
69
|
+
let spcomp: Sprite = this.getComponent(Sprite)!;
|
|
70
|
+
spcomp.spriteFrame = res;
|
|
71
|
+
|
|
72
|
+
/** 修改节点为原始图片资源大小 */
|
|
73
|
+
if (this.isRawSize) {
|
|
74
|
+
//@ts-ignore
|
|
75
|
+
let rawSize = res._originalSize as Size;
|
|
76
|
+
spcomp.getComponent(UITransform)?.setContentSize(rawSize);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
console.error("[LanguageSprite] 资源不存在 " + path);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
//#endregion编辑器
|
|
86
|
+
async addEditor() {
|
|
87
|
+
if (EDITOR) {
|
|
88
|
+
await MainModule.InitGameConfig()
|
|
89
|
+
MainModule.language.addEditorSprite(this);
|
|
90
|
+
this.changeSpriteEditor()
|
|
91
|
+
} else {
|
|
92
|
+
LanguageData.updateLanguage();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
public async changeSpriteEditor() {
|
|
98
|
+
const dbUrl = await LanguageData.loadDBEditor(this.node)
|
|
99
|
+
await LanguageData.loadConfig()
|
|
100
|
+
// console.error('-----', dbUrl)
|
|
101
|
+
const db_json = dbUrl + `/${MainModule.gui.config.language.path.texture}/${LanguageData.current}/`
|
|
102
|
+
MainModule.language.spriteArr.forEach(async (com) => {
|
|
103
|
+
const path_jpg = db_json + com.dataID + ".jpg"
|
|
104
|
+
const path_png = db_json + com.dataID + ".png"
|
|
105
|
+
const path_wep = db_json + com.dataID + ".webp"
|
|
106
|
+
let uuid = await Editor.Message.request("asset-db", "query-uuid", path_jpg);
|
|
107
|
+
if (!uuid) {
|
|
108
|
+
uuid = await Editor.Message.request("asset-db", "query-uuid", path_png);
|
|
109
|
+
}
|
|
110
|
+
if (!uuid) {
|
|
111
|
+
uuid = await Editor.Message.request("asset-db", "query-uuid", path_wep);
|
|
112
|
+
}
|
|
113
|
+
if (!uuid) {
|
|
114
|
+
console.error('没有找到多语言', db_json + com.dataID);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
assetManager.loadAny(uuid, (err, imageAsset: ImageAsset) => {
|
|
118
|
+
//console.log("加载图片", imageAsset, err);
|
|
119
|
+
if (!imageAsset) return;
|
|
120
|
+
let spriteFrame = SpriteFrame.createWithImage(imageAsset);
|
|
121
|
+
com.updateSpriteEditor(spriteFrame)
|
|
122
|
+
});
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
public async updateSpriteEditor(spr?: SpriteFrame) {
|
|
128
|
+
let spcomp: Sprite = this.getComponent(Sprite)!;
|
|
129
|
+
spcomp.spriteFrame = spr;
|
|
130
|
+
/** 修改节点为原始图片资源大小 */
|
|
131
|
+
if (this.isRawSize) {
|
|
132
|
+
//@ts-ignore
|
|
133
|
+
let rawSize = res._originalSize as Size;
|
|
134
|
+
spcomp.getComponent(UITransform)?.setContentSize(rawSize);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ver": "4.0.24",
|
|
3
|
+
"importer": "typescript",
|
|
4
|
+
"imported": true,
|
|
5
|
+
"uuid": "11b9693f-4486-45e7-b2e8-7a1c7297a1ec",
|
|
6
|
+
"files": [],
|
|
7
|
+
"subMetas": {},
|
|
8
|
+
"userData": {
|
|
9
|
+
"moduleId": "project:///assets/script/core/gui/language/LanguageSprite.js",
|
|
10
|
+
"importerSettings": 4,
|
|
11
|
+
"simulateGlobals": []
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export enum ELoggerLevel {
|
|
2
|
+
Debug = 1, Info, Warn, Error
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export enum EServerUrl {
|
|
6
|
+
Local = "http://192.168.6.17:8085",
|
|
7
|
+
OnLine = "https://sx-login.wyx.cn:10005",
|
|
8
|
+
Web = "http://49.232.130.221:10007",
|
|
9
|
+
/** 杨敏 */
|
|
10
|
+
Yang = "http://192.168.1.253:8081",
|
|
11
|
+
/** 付思佳 */
|
|
12
|
+
Fu = "http://192.168.1.34:8081",
|
|
13
|
+
TYF = "http://192.168.1.107:8081",
|
|
14
|
+
WYY = "http://192.168.1.46:8081",
|
|
15
|
+
HSJ = "http://192.168.1.78:8081",
|
|
16
|
+
}
|