Localization and UI patches

This commit is contained in:
Vlad Loktionov
2022-08-22 10:15:45 +03:00
parent c0013157b2
commit 89b20d82cb
37 changed files with 7445 additions and 123 deletions

View File

@ -65,7 +65,7 @@ LUI.MenuBuilder.m_types_build["settings_menu"] = function(a1)
LUI.Options.CreateOptionButton(
menu,
"cg_drawFps",
"cg_drawFPS",
"@LUA_MENU_DRAW_FPS",
"@LUA_MENU_DRAW_FPS_DESC",
{
@ -145,6 +145,44 @@ LUI.MenuBuilder.m_types_build["settings_menu"] = function(a1)
}
)
createdivider(menu, "@LUA_MENU_AUDIO_OPTIONS")
LUI.Options.CreateOptionButton(
menu,
"snd_musicDisabledForCustomSoundtrack",
"@LUA_MENU_MUSIC",
"@LUA_MENU_MUSIC_DESC",
{
{
text = "@LUA_MENU_DISABLED",
value = true
},
{
text = "@LUA_MENU_ENABLED",
value = false
},
}
)
createdivider(menu, "@MENU_GAME_BEGINNING")
LUI.Options.CreateOptionButton(
menu,
"intro",
"@LUA_MENU_INTRO",
"@LUA_MENU_INTRO_DESC",
{
{
text = "@LUA_MENU_DISABLED",
value = false
},
{
text = "@LUA_MENU_ENABLED",
value = true
},
}
)
LUI.Options.InitScrollingList(menu.list, nil)
LUI.Options.AddOptionTextInfo(menu)

View File

@ -11,11 +11,11 @@ game:addlocalizedstring("MENU_japanese_partial", "日本語(一部)")
game:addlocalizedstring("MENU_traditional_chinese", "繁體中文")
game:addlocalizedstring("MENU_simplified_chinese", "简体中文")
game:addlocalizedstring("MENU_arabic", "العربية")
game:addlocalizedstring("MENU_czech", "České") -- ??
game:addlocalizedstring("MENU_spanishna", "Español (México)") -- text only (English dubbing)
game:addlocalizedstring("MENU_czech", "České")
game:addlocalizedstring("MENU_spanishna", "Español (América Latina)") -- text only (English dubbing)
game:addlocalizedstring("MENU_korean", "한국어")
game:addlocalizedstring("MENU_english_safe", "English (Safe)")
game:addlocalizedstring("MENU_russian_partial", "Русский (Только текст)") -- text only (English dubbing)
game:addlocalizedstring("MENU_russian_partial", "Русский (Англ. озвучка)") -- text only (English dubbing)
LUI.addmenubutton("pc_controls", {
index = 4,
@ -26,142 +26,70 @@ LUI.addmenubutton("pc_controls", {
end
})
local factory = LUI.UIGenericButton.ButtonLabelFactory
local overrideyoffset = nil
LUI.UIGenericButton.ButtonLabelFactory = function(data, ...)
if (overrideyoffset) then
data.yOffset = overrideyoffset
overrideyoffset = nil
end
local universalfont = RegisterFont("fallback/fonts/default.otf", 30)
return factory(data, ...)
end
local arabicfont = RegisterFont("fonts/arabic.ttf", 30)
local koreanfont = RegisterFont("fonts/korean.ttf", 30)
local polrusfont = RegisterFont("polrus/fonts/default.otf", 30)
local japanesefont = RegisterFont("fonts/japanese.ttf", 30)
local chinesefont = RegisterFont("fonts/chinese.ttf", 30)
local function setchinesefont(lang)
if (lang ~= CoD.Language.Traditional_chinese and lang ~= CoD.Language.Simplified_chinese) then
return
end
LUI.MenuGenericButtons.ButtonLabelFont.Font = chinesefont
LUI.MenuGenericButtons.ButtonLabelFont.Height = 22
overrideyoffset = 1
end
local function setjapanesefont(lang)
if (lang ~= CoD.Language.Japanese_full and lang ~= CoD.Language.Japanese_partial) then
return
end
LUI.MenuGenericButtons.ButtonLabelFont.Font = japanesefont
LUI.MenuGenericButtons.ButtonLabelFont.Height = 18
overrideyoffset = 1
end
local function setkoreanfont(lang)
if (lang ~= CoD.Language.Korean) then
return
end
LUI.MenuGenericButtons.ButtonLabelFont.Font = koreanfont
LUI.MenuGenericButtons.ButtonLabelFont.Height = 25
overrideyoffset = 1
end
local function setarabicfont(lang)
if (lang ~= CoD.Language.Arabic) then
return
end
LUI.MenuGenericButtons.ButtonLabelFont.Font = arabicfont
LUI.MenuGenericButtons.ButtonLabelFont.Height = 28
overrideyoffset = 0
end
local function setpolrusfont(lang)
if (lang ~= CoD.Language.Russian and lang ~= CoD.Language.Russian_partial and lang ~= CoD.Language.Polish) then
return
end
LUI.MenuGenericButtons.ButtonLabelFont.Font = polrusfont
overrideyoffset = 2.5
local function setuniversalfont(lang)
LUI.MenuGenericButtons.ButtonLabelFont.Font = universalfont
end
LUI.MenuBuilder.registerType("choose_language_menu", function(a1)
local menu = LUI.MenuTemplate.new(a1, {
menu_title = "@LUA_MENU_CHOOSE_LANGUAGE",
menu_list_divider_top_offset = -(LUI.H1MenuTab.tabChangeHoldingElementHeight + H1MenuDims.spacing),
menu_width = 300,
menu_width = 240,
uppercase_title = true
})
local languages = Engine.GetSupportedLanguages()
for i = 1, #languages do
local prevfont = LUI.MenuGenericButtons.ButtonLabelFont.Font
local prevheight = LUI.MenuGenericButtons.ButtonLabelFont.Height
local id = languages[i].id
local lang = Engine.GetCurrentLanguage()
if (lang == CoD.Language.Traditional_chinese or lang == CoD.Language.Simplified_chinese) then
setjapanesefont(id)
setkoreanfont(id)
setarabicfont(id)
elseif (lang == CoD.Language.Japanese_full or lang == CoD.Language.Japanese_partial) then
setchinesefont(id)
setkoreanfont(id)
setarabicfont(id)
elseif (lang ~= CoD.Language.Arabic and lang ~= CoD.Language.Korean) then
setpolrusfont(id)
setchinesefont(id)
setjapanesefont(id)
setkoreanfont(id)
setarabicfont(id)
end
setuniversalfont(id)
local button = menu:AddButton("", function()
if (languages[i].id == Engine.GetCurrentLanguage()) then
LUI.FlowManager.RequestLeaveMenu(nil, "choose_language_menu")
return
end
LUI.FlowManager.RequestAddMenu(nil, "choose_language_confirm_popup", false, nil, true, {
language = languages[i].id
})
end)
end, languages[i].id == Engine.GetCurrentLanguage(), true, nil, {
desc_text = Engine.Localize("LOCALE_" .. (languages[i].id))
})
overrideyoffset = nil
LUI.MenuGenericButtons.ButtonLabelFont.Font = prevfont
LUI.MenuGenericButtons.ButtonLabelFont.Height = prevheight
local label = button:getFirstDescendentById("text_label")
label:setText(Engine.ToUpperCase(languages[i].name))
end
LUI.Options.InitScrollingList(menu.list, nil, {
rows = 11
rows = 10
})
LUI.Options.AddOptionTextInfo(menu)
menu:AddBackButton()
return menu
end)
-- rus/pol patches
-- global patch
LUI.UIButtonText.IsOffsetedLanguage = function()
return false
end
-- pol/rus patch
if (not Engine.InFrontend()) then
local weaponinfodef = LUI.MenuBuilder.m_definitions["WeaponInfoHudDef"]
LUI.MenuBuilder.m_definitions["WeaponInfoHudDef"] = function(...)
local rus = CoD.Language.Russian
CoD.Language.Russian = 1337
local pol = CoD.Language.Polish
CoD.Language.Polish = 1338
local res = weaponinfodef(...)
CoD.Language.Russian = rus
CoD.Language.Polish = pol
return res
end
else
@ -170,24 +98,19 @@ else
levelselectmenu.SetupInfoBoxLeftForArcadeMode = function(...)
local rus = CoD.Language.Russian
CoD.Language.Russian = 1337
local pol = CoD.Language.Polish
CoD.Language.Polish = 1338
local res = setupinfobox(...)
CoD.Language.Russian = rus
CoD.Language.Polish = pol
return res
end
end
LUI.UIButtonText.IsOffsetedLanguage = function()
if Engine.IsRightToLeftLanguage() then
return true
elseif Engine.IsAsianLanguage() then
return true
else
return false
end
end
-- ara/ces/pol/rus patch
local lang = Engine.GetCurrentLanguage()
if (lang == 5 or lang == 6 or lang == 17) then
if (lang == 5 or lang == 6 or lang == 12 or lang == 13 or lang == 17) then
local scale = function (size)
return size * 720 / 1080
end