Browse Source

bug #1897: Ui's are now only built on initial zone-in

tags/v0.10.6^2
Shaun 2 years ago
parent
commit
727fa7d1d7
2 changed files with 36 additions and 23 deletions
  1. +33
    -18
      src/client/ui/factory.js
  2. +3
    -5
      src/client/ui/templates/mainMenu/mainMenu.js

+ 33
- 18
src/client/ui/factory.js View File

@@ -14,6 +14,7 @@ define([
return {
uis: [],
root: '',
ingameUisBuilt: false,

init: function (root) {
if (root)
@@ -32,30 +33,34 @@ define([
},

onBuildIngameUis: async function () {
events.clearQueue();
if (!this.ingameUisBuilt) {
events.clearQueue();

await Promise.all(
globals.clientConfig.uiList.map(u => {
const uiType = u.path ? u.path.split('/').pop() : u;
await Promise.all(
globals.clientConfig.uiList.map(u => {
const uiType = u.path ? u.path.split('/').pop() : u;

return new Promise(res => {
const doneCheck = () => {
const isDone = this.uis.some(ui => ui.type === uiType);
if (isDone) {
res();
return new Promise(res => {
const doneCheck = () => {
const isDone = this.uis.some(ui => ui.type === uiType);
if (isDone) {
res();

return;
}
return;
}

setTimeout(doneCheck, 100);
};
setTimeout(doneCheck, 100);
};

this.build(uiType, { path: u.path });
this.build(uiType, { path: u.path });

doneCheck();
});
})
);
doneCheck();
});
})
);

this.ingameUisBuilt = true;
}

client.request({
threadModule: 'instancer',
@@ -166,6 +171,16 @@ define([
}
},

exitGame: function () {
$('[class^="ui"]:not(.ui-container)').toArray().forEach(el => {
let ui = $(el).data('ui');
if (ui && ui.destroy)
ui.destroy();
});

this.ingameUisBuilt = false;
},

getUi: function (type) {
return this.uis.find(u => u.type === type);
}


+ 3
- 5
src/client/ui/templates/mainMenu/mainMenu.js View File

@@ -66,11 +66,9 @@ define([
sound.unload();

events.emit('onShowCharacterSelect');
$('[class^="ui"]:not(.ui-container)').toArray().forEach(el => {
let ui = $(el).data('ui');
if (ui && ui.destroy)
ui.destroy();
});

factory.exitGame();

factory.build('characters', {});
},



Loading…
Cancel
Save