From 30a8ee8d9f31613d125c200fd0aa77a91d214155 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Thu, 21 Apr 2022 00:06:10 +0200 Subject: [PATCH] Fix main menu freezing --- data/ui_scripts/mods/loading.lua | 10 ++++++++-- data/ui_scripts/patches/__init__.lua | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 data/ui_scripts/patches/__init__.lua diff --git a/data/ui_scripts/mods/loading.lua b/data/ui_scripts/mods/loading.lua index c83ea272..2dfe9081 100644 --- a/data/ui_scripts/mods/loading.lua +++ b/data/ui_scripts/mods/loading.lua @@ -48,11 +48,16 @@ LUI.addmenubutton("main_campaign", { function getmodname(path) local name = path - local desc = Engine.Localize("@LUA_MENU_MOD_DESC_DEFAULT", name) + game:addlocalizedstring(name, name) + game:addlocalizedstring("LUA_MENU_MOD_DESC_DEFAULT", "Load &&1.") + local desc = Engine.Localize("LUA_MENU_MOD_DESC_DEFAULT", name) local infofile = path .. "/info.json" if (io.fileexists(infofile)) then pcall(function() + game:addlocalizedstring(data.description) + game:addlocalizedstring(data.author) + game:addlocalizedstring(data.version) local data = json.decode(io.readfile(infofile)) desc = Engine.Localize("@LUA_MENU_MOD_DESC", data.description, data.author, data.version) @@ -82,7 +87,8 @@ LUI.MenuBuilder.m_types_build["mods_menu"] = function(a1) local modfolder = game:getloadedmod() if (modfolder ~= "") then - createdivider(menu, Engine.Localize("@LUA_MENU_LOADED_MOD", getmodname(modfolder):truncate(24))) + local name = getmodname(modfolder) + createdivider(menu, Engine.Localize("@LUA_MENU_LOADED_MOD", name:truncate(24))) menu:AddButton("@LUA_MENU_UNLOAD", function() game:executecommand("unloadmod") diff --git a/data/ui_scripts/patches/__init__.lua b/data/ui_scripts/patches/__init__.lua new file mode 100644 index 00000000..9002be83 --- /dev/null +++ b/data/ui_scripts/patches/__init__.lua @@ -0,0 +1,27 @@ +local maps = { + "af_caves", + "af_chase", + "airport", + "arcadia", + "boneyard", + "cliffhanger", + "contingency", + "dc_whitehouse", + "dcburning", + "dcemp", + "ending", + "estate", + "favela", + "favela_escape", + "gulag", + "invasion", + "oilrig", + "roadkill", + "trainer", + "museum", +} + +for i = 1, #maps do + local string = "LUA_MENU_SP_LOCATION_" .. maps[i]:upper() + game:addlocalizedstring(string, string) +end