From ec15ca6fee23bc359584bb612f0255e498ec5467 Mon Sep 17 00:00:00 2001 From: phosit Date: Tue, 9 Sep 2025 19:19:47 +0200 Subject: [PATCH] Split waitOnEvent from init in gamesetup_mp --- .../public/gui/gamesetup_mp/gamesetup_mp.js | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/binaries/data/mods/public/gui/gamesetup_mp/gamesetup_mp.js b/binaries/data/mods/public/gui/gamesetup_mp/gamesetup_mp.js index 1d62daadfb..d746817daa 100644 --- a/binaries/data/mods/public/gui/gamesetup_mp/gamesetup_mp.js +++ b/binaries/data/mods/public/gui/gamesetup_mp/gamesetup_mp.js @@ -38,6 +38,25 @@ function cancelOr(costumPromise) })]); } +async function waitOnEvent(loadSavedGame) +{ + while (true) + { + await cancelOr(new Promise(resolve => { + Engine.GetGUIObjectByName("multiplayerPages").onTick = async() => { + if (await onTick(loadSavedGame)) + resolve(); + }; + Engine.GetGUIObjectByName("continueButton").onPress = () => { + if (confirmSetup(loadSavedGame)) + resolve(); + }; + })); + if (cancelSetup()) + return; + } +} + async function init(attribs) { g_UserRating = attribs.rating; @@ -90,21 +109,7 @@ async function init(attribs) break; } - while (true) - { - await cancelOr(new Promise(resolve => { - Engine.GetGUIObjectByName("multiplayerPages").onTick = async() => { - if (await onTick(attribs.loadSavedGame)) - resolve(); - }; - Engine.GetGUIObjectByName("continueButton").onPress = () => { - if (confirmSetup(attribs.loadSavedGame)) - resolve(); - }; - })); - if (cancelSetup()) - return; - } + await waitOnEvent(attribs.loadSavedGame); } function cancelSetup()