mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Remove Engine.SwitchGuiPage from locale
This commit is contained in:
parent
340a4d64ca
commit
3126a249d2
3 changed files with 26 additions and 13 deletions
|
|
@ -19,22 +19,31 @@ function init()
|
|||
var localeText = Engine.GetGUIObjectByName("localeText");
|
||||
localeText.caption = currentLocale;
|
||||
|
||||
return new Promise(closePageCallback =>
|
||||
const cancel = new Promise(closePageCallback =>
|
||||
{
|
||||
Engine.GetGUIObjectByName("cancelButton").onPress = closePageCallback;
|
||||
Engine.GetGUIObjectByName("cancelButton").onPress = closePageCallback.bind(undefined, false);
|
||||
});
|
||||
|
||||
return Promise.race([ cancel, applySelectedLocale() ]);
|
||||
}
|
||||
|
||||
function applySelectedLocale()
|
||||
{
|
||||
var localeText = Engine.GetGUIObjectByName("localeText");
|
||||
if (!Engine.SaveLocale(localeText.caption))
|
||||
return new Promise(closePageCallback =>
|
||||
{
|
||||
warn("Selected locale could not be saved in the configuration!");
|
||||
return;
|
||||
}
|
||||
Engine.ReevaluateCurrentLocaleAndReload();
|
||||
Engine.SwitchGuiPage("page_pregame.xml");
|
||||
Engine.GetGUIObjectByName("apply").onPress = () =>
|
||||
{
|
||||
var localeText = Engine.GetGUIObjectByName("localeText");
|
||||
if (!Engine.SaveLocale(localeText.caption))
|
||||
{
|
||||
warn("Selected locale could not be saved in the configuration!");
|
||||
return;
|
||||
}
|
||||
|
||||
Engine.ReevaluateCurrentLocaleAndReload();
|
||||
closePageCallback(true);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function languageSelectionChanged()
|
||||
|
|
|
|||
|
|
@ -41,9 +41,8 @@
|
|||
<action on="Press">openAdvancedMenu();</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="ModernButtonRed" size="66%+5 100%-60 100% 100%-32">
|
||||
<object name="apply" type="button" style="ModernButtonRed" size="66%+5 100%-60 100% 100%-32">
|
||||
<translatableAttribute id="caption">Accept</translatableAttribute>
|
||||
<action on="Press">applySelectedLocale();</action>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
|
|
|
|||
|
|
@ -312,9 +312,14 @@ export const mainMenuItems = [
|
|||
{
|
||||
"caption": translate("Language"),
|
||||
"tooltip": translate("Choose the language of the game."),
|
||||
"onPress": () =>
|
||||
"onPress": async(closePageCallback) =>
|
||||
{
|
||||
Engine.OpenChildPage("page_locale.xml");
|
||||
if (!await Engine.OpenChildPage("page_locale.xml"))
|
||||
return;
|
||||
|
||||
closePageCallback({ [Engine.openRequest]: {
|
||||
"page": "page_pregame.xml"
|
||||
} });
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue