@shimotsuki/core 1.0.6 → 1.0.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/dist/index.d.ts +15 -11
- package/dist/index.js +29 -22
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -970,18 +970,17 @@ type UIComponentType<T> = T extends UILayer<infer U> ? U : void;
|
|
|
970
970
|
type SceneComponentType<T> = T extends SceneLayer<infer U> ? U : void;
|
|
971
971
|
/**预制体路径 */
|
|
972
972
|
declare enum BasePrefab {
|
|
973
|
-
Root = "
|
|
974
|
-
Toast = "
|
|
975
|
-
BlackMask = "
|
|
976
|
-
Loading = "
|
|
977
|
-
Notice = "
|
|
978
|
-
Reconnection = "
|
|
973
|
+
Root = "root",
|
|
974
|
+
Toast = "toast",
|
|
975
|
+
BlackMask = "black-mask",
|
|
976
|
+
Loading = "loading",
|
|
977
|
+
Notice = "notice",
|
|
978
|
+
Reconnection = "reconnection"
|
|
979
979
|
}
|
|
980
980
|
declare class GuiManager extends BaseManager {
|
|
981
|
+
#private;
|
|
981
982
|
/**常驻顶层UI节点层级 */
|
|
982
|
-
|
|
983
|
-
get gui(): Gui;
|
|
984
|
-
set gui(v: Gui);
|
|
983
|
+
gui: Gui;
|
|
985
984
|
/**
|
|
986
985
|
* 获取预制体
|
|
987
986
|
* @param type 类型
|
|
@@ -989,7 +988,7 @@ declare class GuiManager extends BaseManager {
|
|
|
989
988
|
*/
|
|
990
989
|
private getGuiPrefabByType;
|
|
991
990
|
/**初始化 */
|
|
992
|
-
init(): Promise<this>;
|
|
991
|
+
init(path?: string, bundleName?: string): Promise<this>;
|
|
993
992
|
}
|
|
994
993
|
|
|
995
994
|
/**
|
|
@@ -998,7 +997,7 @@ declare class GuiManager extends BaseManager {
|
|
|
998
997
|
* @date 2024-09-12 11:49:44
|
|
999
998
|
*/
|
|
1000
999
|
declare class Manager {
|
|
1001
|
-
|
|
1000
|
+
#private;
|
|
1002
1001
|
static get instance(): Manager;
|
|
1003
1002
|
readonly onAppInitDelegate: AsyncDelegate<() => (Promise<void> | void)>;
|
|
1004
1003
|
/**音频 */
|
|
@@ -1013,6 +1012,11 @@ declare class Manager {
|
|
|
1013
1012
|
res: ResLoader;
|
|
1014
1013
|
/**工具类 */
|
|
1015
1014
|
util: CoreUtil;
|
|
1015
|
+
/**GUI资源配置 */
|
|
1016
|
+
setGuiConfig: ({ path, bundleName }?: {
|
|
1017
|
+
path?: string;
|
|
1018
|
+
bundleName?: string;
|
|
1019
|
+
}) => this;
|
|
1016
1020
|
/**启动 */
|
|
1017
1021
|
boot(): Promise<void>;
|
|
1018
1022
|
}
|
package/dist/index.js
CHANGED
|
@@ -1709,30 +1709,26 @@ CoreBlackMask = __decorate([
|
|
|
1709
1709
|
/**预制体路径 */
|
|
1710
1710
|
var BasePrefab;
|
|
1711
1711
|
(function (BasePrefab) {
|
|
1712
|
-
BasePrefab["Root"] = "
|
|
1713
|
-
BasePrefab["Toast"] = "
|
|
1714
|
-
BasePrefab["BlackMask"] = "
|
|
1715
|
-
BasePrefab["Loading"] = "
|
|
1716
|
-
BasePrefab["Notice"] = "
|
|
1717
|
-
BasePrefab["Reconnection"] = "
|
|
1712
|
+
BasePrefab["Root"] = "root";
|
|
1713
|
+
BasePrefab["Toast"] = "toast";
|
|
1714
|
+
BasePrefab["BlackMask"] = "black-mask";
|
|
1715
|
+
BasePrefab["Loading"] = "loading";
|
|
1716
|
+
BasePrefab["Notice"] = "notice";
|
|
1717
|
+
BasePrefab["Reconnection"] = "reconnection";
|
|
1718
1718
|
})(BasePrefab || (BasePrefab = {}));
|
|
1719
1719
|
class GuiManager extends BaseManager {
|
|
1720
1720
|
/**常驻顶层UI节点层级 */
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
}
|
|
1725
|
-
set gui(v) {
|
|
1726
|
-
this._gui = v;
|
|
1727
|
-
}
|
|
1721
|
+
gui;
|
|
1722
|
+
#path = 'core';
|
|
1723
|
+
#bundleName = 'resources';
|
|
1728
1724
|
/**
|
|
1729
1725
|
* 获取预制体
|
|
1730
1726
|
* @param type 类型
|
|
1731
1727
|
* @returns
|
|
1732
1728
|
*/
|
|
1733
|
-
getGuiPrefabByType = (type) => {
|
|
1729
|
+
getGuiPrefabByType = (bundleName, type) => {
|
|
1734
1730
|
return new Promise((resolve, reject) => {
|
|
1735
|
-
this.cat.res.load(
|
|
1731
|
+
this.cat.res.load(bundleName, `${this.#path}/${type}`, (err, prefab) => {
|
|
1736
1732
|
if (err) {
|
|
1737
1733
|
reject(err);
|
|
1738
1734
|
}
|
|
@@ -1743,9 +1739,11 @@ class GuiManager extends BaseManager {
|
|
|
1743
1739
|
});
|
|
1744
1740
|
};
|
|
1745
1741
|
/**初始化 */
|
|
1746
|
-
async init() {
|
|
1742
|
+
async init(path = 'core', bundleName = 'resources') {
|
|
1743
|
+
this.#bundleName = bundleName;
|
|
1744
|
+
this.#path = path;
|
|
1747
1745
|
// 初始化常驻节点
|
|
1748
|
-
const root_prefab = await this.getGuiPrefabByType(BasePrefab.Root);
|
|
1746
|
+
const root_prefab = await this.getGuiPrefabByType(this.#bundleName, BasePrefab.Root);
|
|
1749
1747
|
const root = instantiate(root_prefab);
|
|
1750
1748
|
this.gui = root.getComponent(Gui).init(this.cat);
|
|
1751
1749
|
director.addPersistRootNode(root);
|
|
@@ -2529,12 +2527,12 @@ CoreUIModal = __decorate([
|
|
|
2529
2527
|
* @date 2024-09-12 11:49:44
|
|
2530
2528
|
*/
|
|
2531
2529
|
class Manager {
|
|
2532
|
-
static ins;
|
|
2530
|
+
static #ins;
|
|
2533
2531
|
static get instance() {
|
|
2534
|
-
if (!this
|
|
2535
|
-
this
|
|
2532
|
+
if (!this.#ins) {
|
|
2533
|
+
this.#ins = new Manager();
|
|
2536
2534
|
}
|
|
2537
|
-
return this
|
|
2535
|
+
return this.#ins;
|
|
2538
2536
|
}
|
|
2539
2537
|
onAppInitDelegate = new AsyncDelegate();
|
|
2540
2538
|
/**音频 */
|
|
@@ -2549,6 +2547,15 @@ class Manager {
|
|
|
2549
2547
|
res;
|
|
2550
2548
|
/**工具类 */
|
|
2551
2549
|
util;
|
|
2550
|
+
#path = 'core';
|
|
2551
|
+
#bundleName = 'resources';
|
|
2552
|
+
/**GUI资源配置 */
|
|
2553
|
+
setGuiConfig = ({ path = 'core', bundleName = 'resources' } = {}) => {
|
|
2554
|
+
this.#path = path;
|
|
2555
|
+
this.#bundleName = bundleName;
|
|
2556
|
+
console.log('GUI资源配置', this.#path, this.#bundleName);
|
|
2557
|
+
return this;
|
|
2558
|
+
};
|
|
2552
2559
|
/**启动 */
|
|
2553
2560
|
async boot() {
|
|
2554
2561
|
this.res = new ResLoader();
|
|
@@ -2556,7 +2563,7 @@ class Manager {
|
|
|
2556
2563
|
this.storage = new StorageManager(this);
|
|
2557
2564
|
this.event = new MessageManager();
|
|
2558
2565
|
this.audio = new AudioManager(this);
|
|
2559
|
-
this.gui = (await (new GuiManager(this)).init()).gui;
|
|
2566
|
+
this.gui = (await (new GuiManager(this)).init(this.#bundleName, this.#path)).gui;
|
|
2560
2567
|
}
|
|
2561
2568
|
}
|
|
2562
2569
|
const cat = Manager.instance;
|