Skip to content

Commit

Permalink
added 'please wait for connection to broker' loading screen if broker…
Browse files Browse the repository at this point in the history
… server is being slow
  • Loading branch information
mattieFM committed Nov 18, 2023
1 parent 57ab8bf commit d740f17
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 15 additions & 3 deletions www/mods/_multiplayer/hostMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ MATTIE.scenes.multiplayer.host.prototype.create = function () {
MATTIE.multiplayer.hostController.open();
this.addPlayerListWindow();
this.addOptionsBtns();
this.addPeerDisplayWindow();
const loadingAnimInterval = setInterval(() => {
this.animateTick();
}, 500);

MATTIE.multiplayer.hostController.self.on('open', () => {
this.addPeerDisplayWindow();
this.initListController();
clearInterval(loadingAnimInterval);
this.showHideCode(true);
});
};

Expand Down Expand Up @@ -67,11 +73,17 @@ MATTIE.scenes.multiplayer.host.prototype.showHideCode = function (hidden) {
if (this._peerWindow) this._peerWindow.updateText(text);
};

MATTIE.scenes.multiplayer.host.prototype.animateTick = function () {
const text = this._peerWindow.text;
text[1] = text[1].endsWith('...') ? text[1].replace('...', '') : `${text[1]}.`;

if (this._peerWindow) this._peerWindow.updateText(text);
};

MATTIE.scenes.multiplayer.host.prototype.addPeerDisplayWindow = function () {
const text = [
'People can join using this number:',
'*'.repeat(MATTIE.multiplayer.hostController.peerId.length),

'Please wait for connection to broker',
];
this._peerWindow = new MATTIE.windows.TextDisplay((Graphics.boxWidth - 600) / 2 + 100, 0, 600, 100, text);
this.addWindow(this._peerWindow);
Expand Down
2 changes: 2 additions & 0 deletions www/mods/commonLibs/_common/menus/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ MATTIE.windows.TextDisplay.prototype = Object.create(Window_Base.prototype);
MATTIE.windows.TextDisplay.prototype.constructor = MATTIE.windows.TextDisplay;

MATTIE.windows.TextDisplay.prototype.initialize = function (x, y, width, height, text) {
this.text = text;
Window_Base.prototype.initialize.call(this, x, y, width, height);
this.mattieWidth = width;
this.resetTextColor();
Expand All @@ -90,6 +91,7 @@ MATTIE.windows.TextDisplay.prototype.updatePlacement = function (xOffset = 0, yO

MATTIE.windows.TextDisplay.prototype.updateText = function (text) {
this.contents.clear();
this.text = text;
if (typeof text === typeof 'string') {
text += '\n';
text = text.split('\n');
Expand Down

0 comments on commit d740f17

Please sign in to comment.