forked from mirrors/0ad
Remove Engine.SwitchGuiPage from locale
This commit is contained in:
@@ -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"
|
||||
} });
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user