Index: binaries/data/config/default.cfg =================================================================== --- binaries/data/config/default.cfg +++ binaries/data/config/default.cfg @@ -433,6 +433,14 @@ [mod] enabledmods = "mod public" +[modio] +public_key = "RWTYeOHDj5pYF08pXRcDErxhi4D3iQFirR8O6teEPYet51LQuy2aYFGw" ; Public key corresponding to the private key valid mods are signed with + +[modio.v1] +baseurl = "https://api.test.mod.io/v1" +api_key = "acf8fc07e3a8e9228ef4d5704c1659a1" +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. Index: binaries/data/mods/mod/gui/common/functions_msgbox.js =================================================================== --- /dev/null +++ binaries/data/mods/mod/gui/common/functions_msgbox.js @@ -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 = []; + +var g_MessageBoxCallbackFunction = function(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 && "g_MessageBoxCallbackFunction" + }); +} Index: binaries/data/mods/mod/gui/common/l10n.js =================================================================== --- binaries/data/mods/mod/gui/common/l10n.js +++ binaries/data/mods/mod/gui/common/l10n.js @@ -1,3 +1,57 @@ +function filesizeToString(filesize) +{ + 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; + } + + // Translation: For example: 123.4 KiB + return sprintf(translate("%(filesize)s %(unit)s"), { + "filesize": filesize.toFixed(i == 0 ? 0 : 1), + "unit": units[i] + }); +} + +/** + * @param time - In milliseconds. + */ +function timeToString(time) +{ + time /= 1000; + let units = [ + [translateWithContext("time unit", "seconds"), 60], + [translateWithContext("time unit", "minutes"), 60], + [translateWithContext("time unit", "hours"), 24], + [translateWithContext("time unit", "days"), 7] + ]; + + let i = 0; + while (i < units.length - 1) + { + if (time < units[i][1]) + break; + time /= units[i][1]; + ++i; + } + + // Translation: For example: 12 minutes + return sprintf(translate("%(time)s %(unit)s"), { + "time": time.toFixed(0), + "unit": units[i][0] + }); +} + /** * These functions rely on the JS cache where possible and * should be prefered over the Engine.Translate ones to optimize the performance. Index: binaries/data/mods/mod/gui/help/help.js =================================================================== --- /dev/null +++ binaries/data/mods/mod/gui/help/help.js @@ -0,0 +1,4 @@ +function init(data) +{ + Engine.GetGUIObjectByName("mainText").caption = Engine.TranslateLines(Engine.ReadFile("gui/help/help.txt")); +} Index: binaries/data/mods/mod/gui/help/help.txt =================================================================== --- /dev/null +++ binaries/data/mods/mod/gui/help/help.txt @@ -0,0 +1,5 @@ +0 A.D. is designed to be easily modded. Mods are distributed in the form of .pyromod files, which can be opened like .zip files. + +In order to install mods, just open the file with 0 A.D.: it will then be available in the mod selector. You can enable it and disable it at will. You can delete the mod manually using your file browser if needed (see https://trac.wildfiregames.com/wiki/GameDataPaths). + +mod.io is a service developed by DBolical that allows us to list and download all the mods that were verified by the team. Click "Download Mods" to try it out and install some! Index: binaries/data/mods/mod/gui/help/help.xml =================================================================== --- /dev/null +++ binaries/data/mods/mod/gui/help/help.xml @@ -0,0 +1,30 @@ + + + + +