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,41 @@ +function filesizeToString(filesize) +{ + // We are unlikely to download files larger than a TiB. + 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] + }); +} + +/** + * 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 (HH is hours, mm minutes, and ss seconds). + 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. 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,7 @@ +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 a mod, just open the file with 0 A.D. (either double-click on the file and choose to open it with the game, or run "pyrogenesis file.pyromod" in a terminal). The mod 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). + +For more information about modding the game, see https://trac.wildfiregames.com/wiki/Modding_Guide. + +mod.io is a service developed by DBolical, the company behind IndieDB and ModDB. Those websites have spread the word about 0 A.D. and other indie projects for a long time! Today, mod.io 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 @@ + + + + +