mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-03-25 08:34:16 +08:00
add uiManager auto scan and load skin resource
This commit is contained in:
@@ -42,7 +42,7 @@
|
|||||||
{
|
{
|
||||||
"x":15,
|
"x":15,
|
||||||
"type":"Button",
|
"type":"Button",
|
||||||
"props":{"y":200,"var":"btnBack","skin":"images/button/button_back@3x.png","left":30},
|
"props":{"y":200,"var":"btnBack","skin":"images/button/button_back@3x.png","name":"btnBack","left":30},
|
||||||
"nodeParent":1,
|
"nodeParent":1,
|
||||||
"label":"Button(btnBack)",
|
"label":"Button(btnBack)",
|
||||||
"isDirectory":false,
|
"isDirectory":false,
|
||||||
|
|||||||
19
src/app.js
19
src/app.js
@@ -40,7 +40,9 @@ class App{
|
|||||||
Laya.Text.langPacks = (await import(`./i18n/${this.#language}.js`)).default;
|
Laya.Text.langPacks = (await import(`./i18n/${this.#language}.js`)).default;
|
||||||
}
|
}
|
||||||
|
|
||||||
async start(language = App.languages['zh-cn']) {
|
async start({
|
||||||
|
language = App.languages['zh-cn']
|
||||||
|
}) {
|
||||||
this.#initLaya();
|
this.#initLaya();
|
||||||
const uiManager = UIManager.getInstance();
|
const uiManager = UIManager.getInstance();
|
||||||
uiManager.themes = ViewTypes.themes.default;
|
uiManager.themes = ViewTypes.themes.default;
|
||||||
@@ -55,21 +57,6 @@ class App{
|
|||||||
"images/atlas/images/button.atlas",
|
"images/atlas/images/button.atlas",
|
||||||
"images/atlas/images/icons.atlas",
|
"images/atlas/images/icons.atlas",
|
||||||
"images/atlas/images/progress.atlas",
|
"images/atlas/images/progress.atlas",
|
||||||
"images/background/background_1@3x.png",
|
|
||||||
"images/background/background_2@3x.png",
|
|
||||||
"images/accessories/insert_coin@3x.png",
|
|
||||||
"images/accessories/title@3x.png",
|
|
||||||
"images/accessories/titlebar@3x.png",
|
|
||||||
"images/border/achievement_complete@3x.png",
|
|
||||||
"images/border/border_1@3x.png",
|
|
||||||
"images/border/border_2@3x.png",
|
|
||||||
"images/border/card@3x.png",
|
|
||||||
"images/border/talent_item@3x.png",
|
|
||||||
"images/border/talent_item_selected@3x.png",
|
|
||||||
"images/border/up@3x.png",
|
|
||||||
"images/button/button_main@3x.png",
|
|
||||||
"images/slider/vslider_1@3x$bar.png",
|
|
||||||
"images/slider/vslider_1@3x.png",
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,4 +12,4 @@ location.search.substr(1).split('&').forEach(item => {
|
|||||||
query[parts[0]] = parts[1];
|
query[parts[0]] = parts[1];
|
||||||
});
|
});
|
||||||
|
|
||||||
game.start(query.lang);
|
game.start(query);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -72,6 +72,12 @@ class UIManager {
|
|||||||
// load view
|
// load view
|
||||||
const ViewClass = await this.loadView(viewName);
|
const ViewClass = await this.loadView(viewName);
|
||||||
const resourceList = await ViewClass.load?.(args);
|
const resourceList = await ViewClass.load?.(args);
|
||||||
|
const scanedResourceList = this.#loading? this.scanResource(ViewClass.uiView): [];
|
||||||
|
if(preload) {
|
||||||
|
preload = [].concat(preload).concat(scanedResourceList);
|
||||||
|
} else {
|
||||||
|
preload = scanedResourceList;
|
||||||
|
}
|
||||||
await this.loadRes(resourceList, preload, onProgress);
|
await this.loadRes(resourceList, preload, onProgress);
|
||||||
|
|
||||||
// create view
|
// create view
|
||||||
@@ -127,4 +133,17 @@ class UIManager {
|
|||||||
clearAllDialog() {
|
clearAllDialog() {
|
||||||
this.#dialogLayer.removeChildren();
|
this.#dialogLayer.removeChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scanResource(uiView) {
|
||||||
|
if(!uiView) return [];
|
||||||
|
const resourceList = [];
|
||||||
|
if(uiView.props?.skin) {
|
||||||
|
resourceList.push(uiView.props.skin);
|
||||||
|
}
|
||||||
|
uiView.child?.forEach(child => {
|
||||||
|
resourceList.push(...this.scanResource(child));
|
||||||
|
});
|
||||||
|
|
||||||
|
return resourceList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user