mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-20 23:33:59 -07:00
When calling `Engine.PushGuiPage` a promise is returned. The promise is
settled when the "child" page is closed. That allows to `await` it
inside `async` functions.
Previously the callback was run right inside the call to
`Engine.PopGuiPage`. Now the continuation of the promise is called at
the end of the "tick".
This won't help performance. It will more likely make things worse.
Since gui pages aren't opened or closed that frequently, it doesn't
matter that much.
Refs: 86c151ebaa
For the engine side:
The promise is stored in the `CGUIManager::SGUIPage` (like previously
the callback). When the promise is fulfilled it enqueues a callback in
the `JobQueue` of the `JSContext`.
Original patch by: @wraitii
Comments by: @wraitii, @Stan, @Polakrity, @lyv, @elexis, @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D3807
This was SVN commit r28145.
33 lines
600 B
JavaScript
33 lines
600 B
JavaScript
function downloadModsButton()
|
|
{
|
|
initTerms({
|
|
"Disclaimer": {
|
|
"title": translate("Disclaimer"),
|
|
"file": "gui/modio/Disclaimer.txt",
|
|
"config": "modio.disclaimer",
|
|
"accepted": false,
|
|
"callback": openModIo,
|
|
"urlButtons": [
|
|
{
|
|
"caption": translate("mod.io Terms"),
|
|
"url": "https://mod.io/terms"
|
|
},
|
|
{
|
|
"caption": translate("mod.io Privacy Policy"),
|
|
"url": "https://mod.io/privacy"
|
|
}
|
|
]
|
|
}
|
|
});
|
|
|
|
openTerms("Disclaimer");
|
|
}
|
|
|
|
async function openModIo(data)
|
|
{
|
|
if (!data.accepted)
|
|
return;
|
|
|
|
await Engine.PushGuiPage("page_modio.xml");
|
|
initMods();
|
|
}
|