Skip to content

Commit

Permalink
Merge 'remotes/trunk'
Browse files Browse the repository at this point in the history
  • Loading branch information
na-Itms committed Apr 23, 2018
2 parents a4ef6b6 + f05ad7f commit 031d790
Show file tree
Hide file tree
Showing 39 changed files with 2,167 additions and 118 deletions.
8 changes: 8 additions & 0 deletions binaries/data/config/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,14 @@ delay = 200 ; Duration in milliseconds that is waited b
[mod]
enabledmods = "mod public"

[modio]
public_key = "RWQBhIRg+dOifTWlwgYHe8RfD8bqoDh1cCvygboAl3GOUKiCo0NlF4fw" ; Public key corresponding to the private key valid mods are signed with

[modio.v1]
baseurl = "https://api.mod.io/v1"
api_key = "23df258a71711ea6e4b50893acc1ba55"
name_id = "0ad"

[network]
duplicateplayernames = false ; Rename joining player to "User (2)" if "User" is already connected, otherwise prohibit join.
lateobservers = everyone ; Allow observers to join the game after it started. Possible values: everyone, buddies, disabled.
Expand Down
48 changes: 48 additions & 0 deletions binaries/data/mods/mod/gui/common/functions_msgbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// We want to pass callback functions for the different buttons in a convenient way.
// Because passing functions accross compartment boundaries is a pain, we just store them here together with some optional arguments.
// The messageBox page will return the code of the pressed button and the according function will be called.
var g_MessageBoxBtnFunctions = [];
var g_MessageBoxCallbackArgs = [];

function messageBoxCallbackFunction(btnCode)
{
if (btnCode !== undefined && g_MessageBoxBtnFunctions[btnCode])
{
// Cache the variables to make it possible to call a messageBox from a callback function.
let callbackFunction = g_MessageBoxBtnFunctions[btnCode];
let callbackArgs = g_MessageBoxCallbackArgs[btnCode];

g_MessageBoxBtnFunctions = [];
g_MessageBoxCallbackArgs = [];

if (callbackArgs !== undefined)
callbackFunction(callbackArgs);
else
callbackFunction();
return;
}

g_MessageBoxBtnFunctions = [];
g_MessageBoxCallbackArgs = [];
};

function messageBox(mbWidth, mbHeight, mbMessage, mbTitle, mbButtonCaptions, mbBtnCode, mbCallbackArgs)
{
if (g_MessageBoxBtnFunctions && g_MessageBoxBtnFunctions.length)
{
warn("A messagebox was called when a previous callback function is still set, aborting!");
return;
}

g_MessageBoxBtnFunctions = mbBtnCode;
g_MessageBoxCallbackArgs = mbCallbackArgs || g_MessageBoxCallbackArgs;

Engine.PushGuiPage("page_msgbox.xml", {
"width": mbWidth,
"height": mbHeight,
"message": mbMessage,
"title": mbTitle,
"buttonCaptions": mbButtonCaptions,
"callback": mbBtnCode && "messageBoxCallbackFunction"
});
}
50 changes: 49 additions & 1 deletion binaries/data/mods/mod/gui/common/l10n.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
/**
* @param filesize - In bytes.
* @return Object with quantized filesize and suitable unit of size.
*/
function filesizeToObj(filesize)
{
// We are unlikely to download files measured in units greater than GiB.
let units = [
translateWithContext("filesize unit", "B"),
translateWithContext("filesize unit", "KiB"),
translateWithContext("filesize unit", "MiB"),
translateWithContext("filesize unit", "GiB")
];

let i = 0;
while (i < units.length - 1)
{
if (filesize < 1024)
break;
filesize /= 1024;
++i;
}

return {
"filesize": filesize.toFixed(i == 0 ? 0 : 1),
"unit": units[i]
};
}

function filesizeToString(filesize)
{
// Translation: For example: 123.4 KiB
return sprintf(translate("%(filesize)s %(unit)s"), filesizeToObj(filesize));
}

/**
* Convert time in milliseconds to [HH:]mm:ss string representation.
*
* @param time Time period in milliseconds (integer)
* @return String representing time period
*/
function timeToString(time)
{
return Engine.FormatMillisecondsIntoDateStringGMT(time, time < 1000 * 60 * 60 ?
// Translation: Time-format string. See http://userguide.icu-project.org/formatparse/datetime for a guide to the meaning of the letters.
translate("mm:ss") : translate("HH:mm:ss"));
}

/**
* These functions rely on the JS cache where possible and
* should be prefered over the Engine.Translate ones to optimize the performance.
Expand Down Expand Up @@ -44,7 +92,7 @@ function translatePlural(singularMessage, pluralMessage, number)
function translateWithContext(context, message)
{
if (!g_TranslationsWithContext[context])
g_TranslationsWithContext[context] = {}
g_TranslationsWithContext[context] = {};

if (!g_TranslationsWithContext[context][message])
g_TranslationsWithContext[context][message] = Engine.TranslateWithContext(context, message);
Expand Down
Loading

0 comments on commit 031d790

Please sign in to comment.