Compare commits
2 Commits
e89d93b95f
...
c1132daeab
Author | SHA1 | Date | |
---|---|---|---|
c1132daeab | |||
f2e260a251 |
@ -19,7 +19,7 @@ class ColorMixer
|
||||
this.setup(color);
|
||||
}
|
||||
|
||||
setup(color)
|
||||
async setup(color)
|
||||
{
|
||||
Engine.GetGUIObjectByName("titleBar").caption = translate("Color");
|
||||
Engine.GetGUIObjectByName("infoLabel").caption = translate("Move the sliders to change the Red, Green and Blue components of the Color");
|
||||
@ -31,7 +31,8 @@ class ColorMixer
|
||||
this.panel.size = "50%-" + lRDiff + " 50%-" + uDDiff + " 50%+" + lRDiff + " 50%+" + uDDiff;
|
||||
|
||||
const button = [];
|
||||
setButtonCaptionsAndVisibitily(button, this.captions, cancelHotkey, "cmButton");
|
||||
const closePromise =
|
||||
setButtonCaptionsAndVisibility(button, this.captions, cancelHotkey, "cmButton");
|
||||
distributeButtonsHorizontally(button, this.captions);
|
||||
|
||||
const c = color.split(" ");
|
||||
@ -67,9 +68,11 @@ class ColorMixer
|
||||
// Update return color on cancel to prevent malformed values from initial input.
|
||||
color = this.color.join(" ");
|
||||
|
||||
cancelHotkey.onPress = () => { Engine.PopGuiPage(color); };
|
||||
button[0].onPress = () => { Engine.PopGuiPage(color); };
|
||||
button[1].onPress = () => { Engine.PopGuiPage(this.color.join(" ")); };
|
||||
const buttonIndex = await closePromise;
|
||||
if (buttonIndex === 0)
|
||||
Engine.PopGuiPage(color);
|
||||
else
|
||||
Engine.PopGuiPage(this.color.join(" "));
|
||||
}
|
||||
|
||||
updateFromSlider(index)
|
||||
|
@ -19,17 +19,17 @@ function distributeButtonsHorizontally(button, captions)
|
||||
}
|
||||
}
|
||||
|
||||
function setButtonCaptionsAndVisibitily(button, captions, cancelHotkey, name)
|
||||
function setButtonCaptionsAndVisibility(button, captions, cancelHotkey, name)
|
||||
{
|
||||
captions.forEach((caption, i) => {
|
||||
button[i] = Engine.GetGUIObjectByName(name + (i + 1));
|
||||
button[i].caption = caption;
|
||||
button[i].hidden = false;
|
||||
button[i].onPress = () => {
|
||||
Engine.PopGuiPage(i);
|
||||
};
|
||||
return new Promise(resolve => {
|
||||
captions.forEach((caption, i) => {
|
||||
button[i] = Engine.GetGUIObjectByName(name + (i + 1));
|
||||
button[i].caption = caption;
|
||||
button[i].hidden = false;
|
||||
button[i].onPress = resolve.bind(null, i);
|
||||
|
||||
if (i == 0)
|
||||
cancelHotkey.onPress = button[i].onPress;
|
||||
if (i == 0)
|
||||
cancelHotkey.onPress = button[i].onPress;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -131,17 +131,19 @@ var g_ModIOState = {
|
||||
}
|
||||
};
|
||||
|
||||
function init(data)
|
||||
async function init(data)
|
||||
{
|
||||
progressDialog(
|
||||
const promise = progressDialog(
|
||||
translate("Initializing mod.io interface."),
|
||||
translate("Initializing"),
|
||||
false,
|
||||
translate("Cancel"),
|
||||
closePage);
|
||||
translate("Cancel"));
|
||||
|
||||
g_Failure = false;
|
||||
Engine.ModIoStartGetGameId();
|
||||
|
||||
await promise;
|
||||
closePage();
|
||||
}
|
||||
|
||||
function onTick()
|
||||
@ -242,44 +244,48 @@ function cancelModListUpdate()
|
||||
Engine.GetGUIObjectByName('refreshButton').enabled = true;
|
||||
}
|
||||
|
||||
function updateModList()
|
||||
async function updateModList()
|
||||
{
|
||||
clearModList();
|
||||
Engine.GetGUIObjectByName("refreshButton").enabled = false;
|
||||
|
||||
progressDialog(
|
||||
const promise = progressDialog(
|
||||
translate("Fetching and updating list of available mods."),
|
||||
translate("Updating"),
|
||||
false,
|
||||
translate("Cancel Update"),
|
||||
cancelModListUpdate);
|
||||
translate("Cancel Update"));
|
||||
|
||||
g_Failure = false;
|
||||
g_RequestCancelled = false;
|
||||
Engine.ModIoStartListMods();
|
||||
|
||||
await promise;
|
||||
cancelModListUpdate();
|
||||
}
|
||||
|
||||
function downloadMod()
|
||||
async function downloadMod()
|
||||
{
|
||||
let selected = selectedModIndex();
|
||||
|
||||
if (isSelectedModInvalid(selected))
|
||||
return;
|
||||
|
||||
progressDialog(
|
||||
const promise = progressDialog(
|
||||
sprintf(translate("Downloading “%(modname)s”"), {
|
||||
"modname": g_ModsAvailableOnline[selected].name
|
||||
}),
|
||||
translate("Downloading"),
|
||||
true,
|
||||
translate("Cancel Download"),
|
||||
() => { Engine.GetGUIObjectByName("downloadButton").enabled = true; });
|
||||
translate("Cancel Download"));
|
||||
|
||||
Engine.GetGUIObjectByName("downloadButton").enabled = false;
|
||||
|
||||
g_Failure = false;
|
||||
g_RequestCancelled = false;
|
||||
Engine.ModIoStartDownloadMod(selected);
|
||||
|
||||
await promise;
|
||||
Engine.GetGUIObjectByName("downloadButton").enabled = true;
|
||||
}
|
||||
|
||||
function cancelRequest()
|
||||
@ -304,7 +310,7 @@ function showErrorMessageBox(caption, title, buttonCaptions)
|
||||
return messageBox(500, 250, caption, title, buttonCaptions);
|
||||
}
|
||||
|
||||
function progressDialog(dialogCaption, dialogTitle, showProgressBar, buttonCaption, buttonAction)
|
||||
async function progressDialog(dialogCaption, dialogTitle, showProgressBar, buttonCaption)
|
||||
{
|
||||
Engine.GetGUIObjectByName("downloadDialog_title").caption = dialogTitle;
|
||||
|
||||
@ -318,13 +324,14 @@ function progressDialog(dialogCaption, dialogTitle, showProgressBar, buttonCapti
|
||||
Engine.GetGUIObjectByName("downloadDialog_progress").hidden = !showProgressBar;
|
||||
Engine.GetGUIObjectByName("downloadDialog_status").hidden = !showProgressBar;
|
||||
|
||||
let downloadDialog_button = Engine.GetGUIObjectByName("downloadDialog_button");
|
||||
downloadDialog_button.caption = buttonCaption;
|
||||
downloadDialog_button.onPress = () => { cancelRequest(); buttonAction(); };
|
||||
|
||||
Engine.GetGUIObjectByName("downloadDialog").hidden = false;
|
||||
|
||||
g_RequestStartTime = Date.now();
|
||||
|
||||
const downloadDialog_button = Engine.GetGUIObjectByName("downloadDialog_button");
|
||||
downloadDialog_button.caption = buttonCaption;
|
||||
await new Promise(resolve => {downloadDialog_button.onPress = resolve;});
|
||||
cancelRequest();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Currently limited to at most 3 buttons per message box.
|
||||
* The convention is to have "cancel" appear first.
|
||||
*/
|
||||
function init(data)
|
||||
async function init(data)
|
||||
{
|
||||
// Set title
|
||||
Engine.GetGUIObjectByName("mbTitleBar").caption = data.title;
|
||||
@ -25,6 +25,8 @@ function init(data)
|
||||
let captions = data.buttonCaptions || [translate("OK")];
|
||||
|
||||
let mbButton = [];
|
||||
setButtonCaptionsAndVisibitily(mbButton, captions, mbCancelHotkey, "mbButton");
|
||||
const closePromise = setButtonCaptionsAndVisibility(mbButton, captions, mbCancelHotkey, "mbButton");
|
||||
distributeButtonsHorizontally(mbButton, captions);
|
||||
|
||||
Engine.PopGuiPage(await closePromise);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class TimedConfirmation
|
||||
this.setup(data);
|
||||
}
|
||||
|
||||
setup(data)
|
||||
async setup(data)
|
||||
{
|
||||
Engine.GetGUIObjectByName("tmcTitleBar").caption = data.title;
|
||||
|
||||
@ -46,8 +46,11 @@ class TimedConfirmation
|
||||
const captions = data.buttonCaptions || [translate("OK")];
|
||||
|
||||
const button = [];
|
||||
setButtonCaptionsAndVisibitily(button, captions, cancelHotkey, "tmcButton");
|
||||
const closePromise =
|
||||
setButtonCaptionsAndVisibility(button, captions, cancelHotkey, "tmcButton");
|
||||
distributeButtonsHorizontally(button, captions);
|
||||
|
||||
Engine.PopGuiPage(await closePromise);
|
||||
}
|
||||
|
||||
onTick()
|
||||
|
Loading…
Reference in New Issue
Block a user