diff --git a/data/ui_scripts/branding/__init__.lua b/data/ui_scripts/branding/__init__.lua index f0338fbc..89368f2d 100644 --- a/data/ui_scripts/branding/__init__.lua +++ b/data/ui_scripts/branding/__init__.lua @@ -5,88 +5,88 @@ local extrawidth = 50 local extraheight = 40 LUI.MenuBuilder.m_types_build["SystemInfo"] = function (f6_arg0, f6_arg1) - local f6_local0 = LUI.MenuTemplate.spMenuOffset - local title = "LUA_MENU_SYSTEM_INFO_CAPS" + local f6_local0 = LUI.MenuTemplate.spMenuOffset + local title = "LUA_MENU_SYSTEM_INFO_CAPS" - local f6_local2 = false - local f6_local3 = 0 + local f6_local2 = false + local f6_local3 = 0 - local menu = LUI.MenuTemplate.new(f6_arg0, { - menu_title = title, - menu_top_indent = f6_local0 + f6_local3, - showSelectButton = false, - skipAnim = f6_local2 - }) + local menu = LUI.MenuTemplate.new(f6_arg0, { + menu_title = title, + menu_top_indent = f6_local0 + f6_local3, + showSelectButton = false, + skipAnim = f6_local2 + }) - menu:setClass(LUI.SystemInfo) - menu:PopulateMissingProps(f6_arg1) - menu:ValidateProps(f6_arg1) - menu.id = "systemInfo_id" + menu:setClass(LUI.SystemInfo) + menu:PopulateMissingProps(f6_arg1) + menu:ValidateProps(f6_arg1) + menu.id = "systemInfo_id" - local f6_local5 = 300 - local f6_local6 = LUI.MenuTemplate.ListTop + f6_local0 - local f6_local7 = f6_arg1.menu_height - if not f6_local7 then - f6_local7 = f6_local5 - end + local f6_local5 = 300 + local f6_local6 = LUI.MenuTemplate.ListTop + f6_local0 + local f6_local7 = f6_arg1.menu_height + if not f6_local7 then + f6_local7 = f6_local5 + end - f6_local7 = f6_local7 + f6_local6 - extraheight + f6_local7 = f6_local7 + f6_local6 - extraheight - local f6_local9 = luiglobals.GenericMenuDims.OptionMenuWidth + 100 - local f6_local10 = menu.properties - local topoffset2 = LUI.MenuTemplate.ListTop + LUI.MenuTemplate.spMenuOffset + local f6_local9 = luiglobals.GenericMenuDims.OptionMenuWidth + 100 + local f6_local10 = menu.properties + local topoffset2 = LUI.MenuTemplate.ListTop + LUI.MenuTemplate.spMenuOffset - local decobox = LUI.MenuBuilder.BuildRegisteredType("h1_box_deco", { - decoTopOffset = topoffset2 - topoffset + 15, - decoBottomOffset = -f6_local7, - decoRightOffset = -665 + extrawidth - }) + local decobox = LUI.MenuBuilder.BuildRegisteredType("h1_box_deco", { + decoTopOffset = topoffset2 - topoffset + 15, + decoBottomOffset = -f6_local7, + decoRightOffset = -665 + extrawidth + }) - menu:addElement(decobox) + menu:addElement(decobox) - local decoleft = CoD.CreateState(0, 0.5, 8, 0.5, CoD.AnchorTypes.TopLeft) - decoleft.color = luiglobals.Colors.h1.light_grey - decobox:addElement(LUI.UILine.new(decoleft)) + local decoleft = CoD.CreateState(0, 0.5, 8, 0.5, CoD.AnchorTypes.TopLeft) + decoleft.color = luiglobals.Colors.h1.light_grey + decobox:addElement(LUI.UILine.new(decoleft)) - local decoright = CoD.CreateState(0, 0.5, -8, 0.5, CoD.AnchorTypes.TopRight) - decoright.color = luiglobals.Colors.h1.light_grey - decobox:addElement(LUI.UILine.new(decoright)) + local decoright = CoD.CreateState(0, 0.5, -8, 0.5, CoD.AnchorTypes.TopRight) + decoright.color = luiglobals.Colors.h1.light_grey + decobox:addElement(LUI.UILine.new(decoright)) - local element = LUI.UIVerticalList.new({ - leftAnchor = true, - rightAnchor = true, - topAnchor = true, - bottomAnchor = true, - left = spacing, - right = 100, - top = topoffset2 + 15, - bottom = 0, - spacing = spacing * 0.8 - }) + local element = LUI.UIVerticalList.new({ + leftAnchor = true, + rightAnchor = true, + topAnchor = true, + bottomAnchor = true, + left = spacing, + right = 100, + top = topoffset2 + 15, + bottom = 0, + spacing = spacing * 0.8 + }) - element.id = "systemInfoList_id" - menu.vlist = element - menu:addElement(element) + element.id = "systemInfoList_id" + menu.vlist = element + menu:addElement(element) - local optionmenuwidth = luiglobals.GenericMenuDims.OptionMenuWidth - luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth + extrawidth + local optionmenuwidth = luiglobals.GenericMenuDims.OptionMenuWidth + luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth + extrawidth - menu:AddInfo(Engine.Localize("MENU_SYSINFO_VERSION"), function() - return Engine.GetBuildNumber() - end) + menu:AddInfo(Engine.Localize("MENU_SYSINFO_VERSION"), function() + return Engine.GetBuildNumber() + end) - menu:AddInfo(Engine.Localize("MENU_SYSINFO_CUSTOMER_SUPPORT_LINK"), function() - return Engine.Localize("MENU_SYSINFO_CUSTOMER_SUPPORT_URL") - end) + menu:AddInfo(Engine.Localize("MENU_SYSINFO_CUSTOMER_SUPPORT_LINK"), function() + return Engine.Localize("MENU_SYSINFO_CUSTOMER_SUPPORT_URL") + end) - menu:AddInfo(Engine.Localize("MENU_SYSINFO_DONATION_LINK"), function() - return Engine.Localize("MENU_SYSINFO_DONATION_URL") - end) + menu:AddInfo(Engine.Localize("MENU_SYSINFO_DONATION_LINK"), function() + return Engine.Localize("MENU_SYSINFO_DONATION_URL") + end) - luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth + luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth - menu:AddBackButton() - menu:registerEventHandler("menu_close", LUI.SystemInfo.LeaveMenu) + menu:AddBackButton() + menu:registerEventHandler("menu_close", LUI.SystemInfo.LeaveMenu) - return menu + return menu end \ No newline at end of file diff --git a/data/ui_scripts/mods/__init__.lua b/data/ui_scripts/mods/__init__.lua index e591a736..ca2d3da9 100644 --- a/data/ui_scripts/mods/__init__.lua +++ b/data/ui_scripts/mods/__init__.lua @@ -1 +1 @@ -require("loading") \ No newline at end of file +require("loading") diff --git a/data/ui_scripts/mods/loading.lua b/data/ui_scripts/mods/loading.lua index 18fab2c8..c83ea272 100644 --- a/data/ui_scripts/mods/loading.lua +++ b/data/ui_scripts/mods/loading.lua @@ -1,3 +1,14 @@ +game:addlocalizedstring("MENU_MODS", "MODS") +game:addlocalizedstring("MENU_MODS_DESC", "Load installed mods.") +game:addlocalizedstring("LUA_MENU_MOD_DESC_DEFAULT", "Load &&1.") +game:addlocalizedstring("LUA_MENU_MOD_DESC", "&&1\nAuthor: &&2\nVersion: &&3") +game:addlocalizedstring("LUA_MENU_OPEN_STORE", "Open store") +game:addlocalizedstring("LUA_MENU_OPEN_STORE_DESC", "Download and install mods.") +game:addlocalizedstring("LUA_MENU_LOADED_MOD", "Loaded mod: ^3&&1") +game:addlocalizedstring("LUA_MENU_AVAILABLE_MODS", "Available mods") +game:addlocalizedstring("LUA_MENU_UNLOAD", "Unload") +game:addlocalizedstring("LUA_MENU_UNLOAD_DESC", "Unload the currently loaded mod.") + function createdivider(menu, text) local element = LUI.UIElement.new( { leftAnchor = true, @@ -12,112 +23,102 @@ function createdivider(menu, text) element.scrollingToNext = true element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", { - title_bar_text = Engine.ToUpperCase(Engine.Localize(text)) + title_bar_text = Engine.ToUpperCase(text) })) menu.list:addElement(element) end function string:truncate(length) - if (#self <= length) then - return self - end + if (#self <= length) then + return self + end - return self:sub(1, length - 3) .. "..." + return self:sub(1, length - 3) .. "..." end LUI.addmenubutton("main_campaign", { - index = 6, - text = "$_MODS", - description = "Load installed mods.", - callback = function() - LUI.FlowManager.RequestAddMenu(nil, "mods_menu") - end + index = 6, + text = "@MENU_MODS", + description = Engine.Localize("@MENU_MODS_DESC"), + callback = function() + LUI.FlowManager.RequestAddMenu(nil, "mods_menu") + end }) function getmodname(path) - local name = path - local desc = "Load " .. name - local infofile = path .. "/info.json" + local name = path + local desc = Engine.Localize("@LUA_MENU_MOD_DESC_DEFAULT", name) + local infofile = path .. "/info.json" - if (io.fileexists(infofile)) then - pcall(function() - local data = json.decode(io.readfile(infofile)) - desc = string.format("%s\nAuthor: %s\nVersion: %s", - data.description, data.author, data.version) - name = data.name - end) - end + if (io.fileexists(infofile)) then + pcall(function() + local data = json.decode(io.readfile(infofile)) + desc = Engine.Localize("@LUA_MENU_MOD_DESC", + data.description, data.author, data.version) + name = data.name + end) + end - return name, desc + return name, desc end LUI.MenuBuilder.m_types_build["mods_menu"] = function(a1) - local menu = LUI.MenuTemplate.new(a1, { - menu_title = "$_MODS", - exclusiveController = 0, - menu_width = 400, - menu_top_indent = LUI.MenuTemplate.spMenuOffset, - showTopRightSmallBar = true - }) + local menu = LUI.MenuTemplate.new(a1, { + menu_title = "@MENU_MODS", + exclusiveController = 0, + menu_width = 400, + menu_top_indent = LUI.MenuTemplate.spMenuOffset, + showTopRightSmallBar = true + }) - menu:AddButton("$_OPEN STORE", function() - if (LUI.MenuBuilder.m_types_build["mod_store_menu"]) then - LUI.FlowManager.RequestAddMenu(nil, "mod_store_menu") - end - end, nil, true, nil, { - desc_text = "Download and install mods." - }) + menu:AddButton("@LUA_MENU_OPEN_STORE", function() + if (LUI.MenuBuilder.m_types_build["mod_store_menu"]) then + LUI.FlowManager.RequestAddMenu(nil, "mod_store_menu") + end + end, nil, true, nil, { + desc_text = Engine.Localize("@LUA_MENU_OPEN_STORE_DESC") + }) - local modfolder = game:getloadedmod() - if (modfolder ~= "") then - createdivider(menu, "$_Loaded mod: ^3" .. getmodname(modfolder):truncate(20)) + local modfolder = game:getloadedmod() + if (modfolder ~= "") then + createdivider(menu, Engine.Localize("@LUA_MENU_LOADED_MOD", getmodname(modfolder):truncate(24))) - menu:AddButton("$_UNLOAD", function() - game:executecommand("unloadmod") - end, nil, true, nil, { - desc_text = "Unload the currently loaded mod." - }) - end + menu:AddButton("@LUA_MENU_UNLOAD", function() + game:executecommand("unloadmod") + end, nil, true, nil, { + desc_text = Engine.Localize("@LUA_MENU_UNLOAD_DESC") + }) + end - createdivider(menu, "$_Available mods") + createdivider(menu, Engine.Localize("@LUA_MENU_AVAILABLE_MODS")) - if (io.directoryexists("mods")) then - local mods = io.listfiles("mods/") - for i = 1, #mods do - if (io.directoryexists(mods[i]) and not io.directoryisempty(mods[i])) then - local name, desc = getmodname(mods[i]) + if (io.directoryexists("mods")) then + local mods = io.listfiles("mods/") + for i = 1, #mods do + if (io.directoryexists(mods[i]) and not io.directoryisempty(mods[i])) then + local name, desc = getmodname(mods[i]) - if (mods[i] ~= modfolder) then - menu:AddButton("$_" .. name, function() - game:executecommand("loadmod " .. mods[i]) - end, nil, true, nil, { - desc_text = desc - }) - end - end - end - end - - menu:AddBackButton(function(a1) - Engine.PlaySound(CoD.SFX.MenuBack) - LUI.FlowManager.RequestLeaveMenu(a1) - end) + if (mods[i] ~= modfolder) then + game:addlocalizedstring(name, name) + menu:AddButton(name, function() + game:executecommand("loadmod " .. mods[i]) + end, nil, true, nil, { + desc_text = desc + }) + end + end + end + end + + menu:AddBackButton(function(a1) + Engine.PlaySound(CoD.SFX.MenuBack) + LUI.FlowManager.RequestLeaveMenu(a1) + end) - LUI.Options.InitScrollingList(menu.list, nil) - menu:CreateBottomDivider() - menu.optionTextInfo = LUI.Options.AddOptionTextInfo(menu) + LUI.Options.InitScrollingList(menu.list, nil) + menu:CreateBottomDivider() + menu.optionTextInfo = LUI.Options.AddOptionTextInfo(menu) - return menu + return menu end - -local localize = Engine.Localize -Engine.Localize = function(...) - local args = {...} - - if (type(args[1]) == "string" and args[1]:sub(1, 2) == "$_") then - return args[1]:sub(3, -1) - end - - return localize(table.unpack(args)) -end \ No newline at end of file diff --git a/data/ui_scripts/settings/__init__.lua b/data/ui_scripts/settings/__init__.lua index 4bd4beab..0facce7f 100644 --- a/data/ui_scripts/settings/__init__.lua +++ b/data/ui_scripts/settings/__init__.lua @@ -1,4 +1,4 @@ -game:addlocalizedstring("MENU_GENERAL", "General") +game:addlocalizedstring("MENU_GENERAL", "GENERAL") game:addlocalizedstring("MENU_GENERAL_DESC", "Set the client's settings.") game:addlocalizedstring("LUA_MENU_AUTO_UPDATE", "Automatic updates") game:addlocalizedstring("LUA_MENU_CHECK_UPDATES", "Check for updates") @@ -46,7 +46,7 @@ end LUI.addmenubutton("pc_controls", { index = 4, text = "@MENU_GENERAL", - description = "@MENU_GENERAL_DESC", + description = Engine.Localize("@MENU_GENERAL_DESC"), callback = function() LUI.FlowManager.RequestAddMenu(nil, "settings_menu") end @@ -174,4 +174,4 @@ LUI.MenuBuilder.m_types_build["settings_menu"] = function(a1) menu:AddBackButton() return menu -end \ No newline at end of file +end diff --git a/src/client/resources/ui_scripts/updater.lua b/src/client/resources/ui_scripts/updater.lua index 7b32b7f8..329f83ef 100644 --- a/src/client/resources/ui_scripts/updater.lua +++ b/src/client/resources/ui_scripts/updater.lua @@ -4,157 +4,157 @@ taskinterval = 100 updater.cancelupdate() function startupdatecheck(popup, autoclose) - updatecancelled = false + updatecancelled = false - local callback = function() - if (not updater.getupdatecheckstatus()) then - if (autoclose) then - LUI.FlowManager.RequestLeaveMenu(popup) - return - end + local callback = function() + if (not updater.getupdatecheckstatus()) then + if (autoclose) then + LUI.FlowManager.RequestLeaveMenu(popup) + return + end - popup.text:setText("Error: " .. updater.getlasterror()) - return - end + popup.text:setText("Error: " .. updater.getlasterror()) + return + end - if (not updater.isupdateavailable()) then - if (autoclose) then - LUI.FlowManager.RequestLeaveMenu(popup) - return - end + if (not updater.isupdateavailable()) then + if (autoclose) then + LUI.FlowManager.RequestLeaveMenu(popup) + return + end - popup.text:setText("No updates available") - return - end + popup.text:setText("No updates available") + return + end - LUI.yesnopopup({ - title = "NOTICE", - text = "An update is available, proceed with installation?", - callback = function(result) - if (result) then - startupdatedownload(popup, autoclose) - else - LUI.FlowManager.RequestLeaveMenu(popup) - end - end - }) - end + LUI.yesnopopup({ + title = "NOTICE", + text = "An update is available, proceed with installation?", + callback = function(result) + if (result) then + startupdatedownload(popup, autoclose) + else + LUI.FlowManager.RequestLeaveMenu(popup) + end + end + }) + end - updater.startupdatecheck() - createtask({ - done = updater.isupdatecheckdone, - cancelled = isupdatecancelled, - callback = callback, - interval = taskinterval - }) + updater.startupdatecheck() + createtask({ + done = updater.isupdatecheckdone, + cancelled = isupdatecancelled, + callback = callback, + interval = taskinterval + }) end function startupdatedownload(popup, autoclose) - updater.startupdatedownload() + updater.startupdatedownload() - local textupdate = nil - local previousfile = nil - textupdate = game:oninterval(function() - local file = updater.getcurrentfile() - if (file == previousfile) then - return - end + local textupdate = nil + local previousfile = nil + textupdate = game:oninterval(function() + local file = updater.getcurrentfile() + if (file == previousfile) then + return + end - file = previousfile - popup.text:setText("Downloading file " .. updater.getcurrentfile() .. "...") - end, 10) + file = previousfile + popup.text:setText("Downloading file " .. updater.getcurrentfile() .. "...") + end, 10) - local callback = function() - textupdate:clear() + local callback = function() + textupdate:clear() - if (not updater.getupdatedownloadstatus()) then - if (autoclose) then - LUI.FlowManager.RequestLeaveMenu(popup) - return - end + if (not updater.getupdatedownloadstatus()) then + if (autoclose) then + LUI.FlowManager.RequestLeaveMenu(popup) + return + end - popup.text:setText("Error: " .. updater.getlasterror()) - return - end + popup.text:setText("Error: " .. updater.getlasterror()) + return + end - popup.text:setText("Update successful") + popup.text:setText("Update successful") - if (updater.isrestartrequired()) then - LUI.confirmationpopup({ - title = "RESTART REQUIRED", - text = "Update requires restart", - buttontext = "RESTART", - callback = function() - updater.relaunch() - end - }) - else - Engine.Exec("lui_restart") - end + if (updater.isrestartrequired()) then + LUI.confirmationpopup({ + title = "RESTART REQUIRED", + text = "Update requires restart", + buttontext = "RESTART", + callback = function() + updater.relaunch() + end + }) + else + Engine.Exec("lui_restart") + end - if (autoclose) then - LUI.FlowManager.RequestLeaveMenu(popup) - end - end + if (autoclose) then + LUI.FlowManager.RequestLeaveMenu(popup) + end + end - createtask({ - done = updater.isupdatedownloaddone, - cancelled = isupdatecancelled, - callback = callback, - interval = taskinterval - }) + createtask({ + done = updater.isupdatedownloaddone, + cancelled = isupdatecancelled, + callback = callback, + interval = taskinterval + }) end function updaterpopup(oncancel) - return LUI.openpopupmenu("generic_waiting_popup_", { - oncancel = oncancel, - withcancel = true, - text = "Checking for updates..." - }) + return LUI.openpopupmenu("generic_waiting_popup_", { + oncancel = oncancel, + withcancel = true, + text = "Checking for updates..." + }) end function createtask(data) - local interval = nil - interval = game:oninterval(function() - if (data.cancelled()) then - interval:clear() - return - end + local interval = nil + interval = game:oninterval(function() + if (data.cancelled()) then + interval:clear() + return + end - if (data.done()) then - interval:clear() - data.callback() - end - end, data.interval) - return interval + if (data.done()) then + interval:clear() + data.callback() + end + end, data.interval) + return interval end function isupdatecancelled() - return updatecancelled + return updatecancelled end function tryupdate(autoclose) - updatecancelled = false - local popup = updaterpopup(function() - updater.cancelupdate() - updatecancelled = true - end) + updatecancelled = false + local popup = updaterpopup(function() + updater.cancelupdate() + updatecancelled = true + end) - startupdatecheck(popup, autoclose) + startupdatecheck(popup, autoclose) end function tryautoupdate() - if (not updater.autoupdatesenabled()) then - return - end + if (not updater.autoupdatesenabled()) then + return + end - if (not updater.gethastriedupdate()) then - game:ontimeout(function() - updater.sethastriedupdate(true) - tryupdate(true) - end, 100) - end + if (not updater.gethastriedupdate()) then + game:ontimeout(function() + updater.sethastriedupdate(true) + tryupdate(true) + end, 100) + end end LUI.tryupdating = tryupdate -LUI.onmenuopen("main_lockout", tryautoupdate) \ No newline at end of file +LUI.onmenuopen("main_lockout", tryautoupdate)