Move data files

This commit is contained in:
Federico Cecchetto
2022-08-22 02:27:20 +02:00
parent 8685504588
commit 2f563a501f
33 changed files with 1 additions and 1 deletions

View File

@ -0,0 +1,92 @@
local spacing = 10
local topoffset = 15
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_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
})
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
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 decobox = LUI.MenuBuilder.BuildRegisteredType("h1_box_deco", {
decoTopOffset = topoffset2 - topoffset + 15,
decoBottomOffset = -f6_local7,
decoRightOffset = -665 + extrawidth
})
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 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
})
element.id = "systemInfoList_id"
menu.vlist = element
menu:addElement(element)
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_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)
luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth
menu:AddBackButton()
menu:registerEventHandler("menu_close", LUI.SystemInfo.LeaveMenu)
return menu
end

View File

@ -0,0 +1 @@
require("loading")

View File

@ -0,0 +1,122 @@
function createdivider(menu, text)
local element = LUI.UIElement.new( {
leftAnchor = true,
rightAnchor = true,
left = 0,
right = 0,
topAnchor = true,
bottomAnchor = false,
top = 0,
bottom = 33.33
})
element.scrollingToNext = true
element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", {
title_bar_text = Engine.ToUpperCase(text)
}))
element.text = element:getFirstChild():getFirstChild():getNextSibling()
menu.list:addElement(element)
return element
end
function string:truncate(length)
if (#self <= length) then
return self
end
return self:sub(1, length - 3) .. "..."
end
LUI.addmenubutton("main_campaign", {
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
game:addlocalizedstring(name, name)
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))
game:addlocalizedstring(data.description, data.description)
game:addlocalizedstring(data.author, data.author)
game:addlocalizedstring(data.version, data.version)
desc = Engine.Localize("@LUA_MENU_MOD_DESC",
data.description, data.author, data.version)
name = data.name
end)
end
return name, desc
end
LUI.MenuBuilder.registerType("mods_menu", function(a1)
local menu = LUI.MenuTemplate.new(a1, {
menu_title = "@MENU_MODS",
exclusiveController = 0,
menu_width = 400,
menu_top_indent = LUI.MenuTemplate.spMenuOffset,
showTopRightSmallBar = true,
uppercase_title = true
})
menu:AddButton("@LUA_MENU_WORKSHOP", function()
if (LUI.MenuBuilder.m_types_build["mods_workshop_menu"]) then
LUI.FlowManager.RequestAddMenu(nil, "mods_workshop_menu")
end
end, nil, true, nil, {
desc_text = Engine.Localize("@LUA_MENU_WORKSHOP_DESC")
})
local modfolder = game:getloadedmod()
if (modfolder ~= "") then
local name = getmodname(modfolder)
createdivider(menu, Engine.Localize("@LUA_MENU_LOADED_MOD", name:truncate(24)))
menu:AddButton("@LUA_MENU_UNLOAD", function()
Engine.Exec("unloadmod")
end, nil, true, nil, {
desc_text = Engine.Localize("@LUA_MENU_UNLOAD_DESC")
})
end
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 (mods[i] ~= modfolder) then
game:addlocalizedstring(name, name)
menu:AddButton(name, function()
Engine.Exec("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)
return menu
end)

View File

View File

@ -0,0 +1,154 @@
require("language")
function createdivider(menu, text)
local element = LUI.UIElement.new({
leftAnchor = true,
rightAnchor = true,
left = 0,
right = 0,
topAnchor = true,
bottomAnchor = false,
top = 0,
bottom = 33.33
})
element.scrollingToNext = true
element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", {
title_bar_text = Engine.ToUpperCase(Engine.Localize(text))
}))
menu.list:addElement(element)
end
LUI.addmenubutton("pc_controls", {
index = 4,
text = "@MENU_GENERAL",
description = Engine.Localize("@MENU_GENERAL_DESC"),
callback = function()
LUI.FlowManager.RequestAddMenu(nil, "settings_menu")
end
})
LUI.MenuBuilder.m_types_build["settings_menu"] = function(a1)
local menu = LUI.MenuTemplate.new(a1, {
menu_title = "@MENU_GENERAL",
menu_list_divider_top_offset = -(LUI.H1MenuTab.tabChangeHoldingElementHeight + H1MenuDims.spacing),
menu_width = GenericMenuDims.OptionMenuWidth
})
createdivider(menu, "@LUA_MENU_UPDATES")
LUI.Options.CreateOptionButton(
menu,
"cg_auto_update",
"@LUA_MENU_AUTO_UPDATE",
"@LUA_MENU_AUTO_UPDATE_DESC",
{
{
text = "@LUA_MENU_ENABLED",
value = true
},
{
text = "@LUA_MENU_DISABLED",
value = false
}
}
)
menu:AddButton("@LUA_MENU_CHECK_UPDATES", function()
LUI.tryupdating(false)
end, nil, true, nil, {
desc_text = Engine.Localize("@LUA_MENU_CHECK_UPDATES_DESC")
})
createdivider(menu, "@LUA_MENU_DRAWING")
LUI.Options.CreateOptionButton(
menu,
"cg_drawFps",
"@LUA_MENU_DRAW_FPS",
"@LUA_MENU_DRAW_FPS_DESC",
{
{
text = "@LUA_MENU_DISABLED",
value = 0
},
{
text = "@LUA_MENU_FPS_ONLY",
value = 1
},
{
text = "@LUA_MENU_FPS_AND_VIEWPOS",
value = 2
}
}
)
LUI.Options.CreateOptionButton(
menu,
"cg_drawSpeed",
"@LUA_MENU_DRAW_SPEED",
"@LUA_MENU_DRAW_SPEED_DESC",
{
{
text = "@LUA_MENU_ENABLED",
value = true
},
{
text = "@LUA_MENU_DISABLED",
value = false
}
}
)
LUI.Options.CreateOptionButton(
menu,
"cg_speedGraph",
"@LUA_MENU_DRAW_SPEEDGRAPH",
"@LUA_MENU_DRAW_SPEEDGRAPH_DESC",
{
{
text = "@LUA_MENU_ENABLED",
value = true
},
{
text = "@LUA_MENU_DISABLED",
value = false
}
}
)
createdivider(menu, "@LUA_MENU_RENDERING")
LUI.Options.CreateOptionButton(
menu,
"r_fullbright",
"@LUA_MENU_R_FULLBRIGHT",
"@LUA_MENU_R_FULLBRIGHT_DESC",
{
{
text = "@LUA_MENU_DISABLED",
value = 0
},
{
text = "@LUA_MENU_ENABLED",
value = 1
},
{
text = "@LUA_MENU_MODE2",
value = 2
},
{
text = "@LUA_MENU_MODE3",
value = 3
}
}
)
LUI.Options.InitScrollingList(menu.list, nil)
LUI.Options.AddOptionTextInfo(menu)
menu:AddBackButton()
return menu
end

View File

@ -0,0 +1,214 @@
game:addlocalizedstring("MENU_english", "English")
game:addlocalizedstring("MENU_french", "Français")
game:addlocalizedstring("MENU_german", "Deutsch")
game:addlocalizedstring("MENU_italian", "Italiano")
game:addlocalizedstring("MENU_spanish", "Español")
game:addlocalizedstring("MENU_russian", "Русский")
game:addlocalizedstring("MENU_polish", "Polski")
game:addlocalizedstring("MENU_portuguese", "Português")
game:addlocalizedstring("MENU_japanese_full", "日本語")
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_korean", "한국어")
game:addlocalizedstring("MENU_english_safe", "English (Safe)")
game:addlocalizedstring("MENU_russian_partial", "Русский (Только текст)") -- text only (English dubbing)
LUI.addmenubutton("pc_controls", {
index = 4,
text = "@LUA_MENU_CHOOSE_LANGUAGE",
description = Engine.Localize("@LUA_MENU_CHOOSE_LANGUAGE_DESC"),
callback = function()
LUI.FlowManager.RequestAddMenu(nil, "choose_language_menu")
end
})
local factory = LUI.UIGenericButton.ButtonLabelFactory
local overrideyoffset = nil
LUI.UIGenericButton.ButtonLabelFactory = function(data, ...)
if (overrideyoffset) then
data.yOffset = overrideyoffset
overrideyoffset = nil
end
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
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,
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
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)
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
})
menu:AddBackButton()
return menu
end)
-- rus/pol patches
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 res = weaponinfodef(...)
CoD.Language.Russian = rus
return res
end
else
local levelselectmenu = LUI.sp_menus.LevelSelectMenu
local setupinfobox = levelselectmenu.SetupInfoBoxLeftForArcadeMode
levelselectmenu.SetupInfoBoxLeftForArcadeMode = function(...)
local rus = CoD.Language.Russian
CoD.Language.Russian = 1337
local res = setupinfobox(...)
CoD.Language.Russian = rus
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
local lang = Engine.GetCurrentLanguage()
if (lang == 5 or lang == 6 or lang == 17) then
local scale = function (size)
return size * 720 / 1080
end
CoD.TextSettings.SP_HudAmmoStatusText = {
Font = RegisterFont("fonts/bank.ttf", 16),
Height = 16
}
CoD.TextSettings.SP_HudAmmoCounterFont = {
Font = RegisterFont("fonts/bank.ttf", 34),
Height = 34
}
CoD.TextSettings.HudAmmoCounterFont = {
Font = RegisterFont("fonts/bank.ttf", 105),
Height = 64
}
CoD.TextSettings.H2TitleFont = {
Font = RegisterFont("fonts/bank.ttf", 56),
Height = scale(56)
}
end