Remove localized_strings component

This commit is contained in:
fed
2023-02-28 19:07:57 +01:00
parent f4ee252daa
commit 33a18ca486
15 changed files with 337 additions and 562 deletions

View File

@ -1,298 +1,2 @@
local spacing = 10
local topoffset = 15
local extrawidth = 50
local extraheight1 = 0
local function makelink(element, link)
element:setHandleMouseMove(true)
element:setHandleMouseButton(true)
element:registerAnimationState("focused", {
color = {
r = 1,
g = 1,
b = 1
}
})
local entered = false
element:registerEventHandler("mouseenter", function()
if (not entered) then
Engine.PlaySound(CoD.SFX.MouseOver)
entered = true
end
element:animateToState("focused")
end)
element:registerEventHandler("mouseleave", function()
entered = false
element:animateToState("default")
end)
element:registerEventHandler("leftmousedown", function()
Engine.PlaySound(CoD.SFX.MouseClick)
game:openlink(link)
end)
end
local addlinkinfo = function(menu, key, value, link)
local text = Engine.Localize(value)
local element = menu:AddInfo(Engine.Localize(key), function()
return text
end)
local linkelement = element:getFirstChild():getNextSibling()
makelink(linkelement, link)
end
local function getnumcredits()
local csv = "credits.csv"
local rowcount = Engine.TableGetRowCount(csv)
return rowcount
end
local extraheight2 = getnumcredits() * 25 / 2
local function addcredits(menu)
local cols = {
name = 0,
link = 1
}
local csv = "credits.csv"
local rowcount = Engine.TableGetRowCount(csv)
local num = 0
local creditselement = LUI.UIElement.new({
topAnchor = true,
leftAnchor = true,
left = 500,
width = 30,
top = 255
})
menu:addElement(creditselement)
menu:AddInfo(Engine.Localize("MENU_CREDITS"), function()
return ""
end)
local num = 0
local addcredit = function(name, link)
local row = num % 4
local col = num >= 4 and 0 or 1
local text = Engine.Localize(name)
local element = LUI.UIText.new({
rightAnchor = true,
topAnchor = true,
right = -10 + (col * -100),
top = 25 * row,
width = 90,
height = LUI.MenuGenericButtons.ButtonLabelFont.Height * 0.8,
font = LUI.MenuGenericButtons.ButtonLabelFont.Font,
color = Colors.h1.light_grey,
alignment = Engine.IsRightToLeftLanguage() and LUI.Alignment.None or LUI.Alignment.Right
})
element.id = "credits_" .. num
element:setText(text)
creditselement:addElement(element)
makelink(element, link)
num = num + 1
end
for i = 0, rowcount - 1 do
local name = Engine.TableLookupByRow(csv, i, cols.name)
local link = Engine.TableLookupByRow(csv, i, cols.link)
addcredit(name, link)
end
end
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 - extraheight1
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)
addlinkinfo(menu, "MENU_SYSINFO_CUSTOMER_SUPPORT_LINK", "MENU_SYSINFO_CUSTOMER_SUPPORT_URL", "github")
luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth
menu:AddBackButton()
menu:registerEventHandler("menu_close", LUI.SystemInfo.LeaveMenu)
return menu
end
local startmap = Engine.StreamingInstallMap
Engine.StreamingInstallMap = function(map, args, ...)
if (args == "set ui_play_credits 1; devmap ending;") then
LUI.FlowManager.RequestAddMenu(nil, "credits_menu")
else
startmap(map, args, ...)
end
end
local creditsmap = function()
LUI.FlowManager.PushMenuStackToDVar()
if LUI.LevelSelect.IsAllLevelCompleted() then
Engine.SetDvarString("ui_char_museum_mode", "credits_2", true)
else
Engine.SetDvarString("ui_char_museum_mode", "credits_black", true)
end
startmap("ending", "set ui_play_credits 1; devmap ending;")
end
LUI.MenuBuilder.registerType("credits_menu", function(f6_arg0, f6_arg1)
local f6_local0 = LUI.MenuTemplate.spMenuOffset
local title = "MENU_SP_CREDITS_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:AddButton("MENU_SP_CREDITS_CAPS", creditsmap, nil, true, nil, {
desc_text = Engine.Localize("@LUA_MENU_CREDITS_DESC")
})
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 - extraheight2
local f6_local9 = luiglobals.GenericMenuDims.OptionMenuWidth + 100
local f6_local10 = menu.properties
local topoffset2 = LUI.MenuTemplate.ListTop + LUI.MenuTemplate.spMenuOffset + 50
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
addlinkinfo(menu, "MENU_SYSINFO_CUSTOMER_SUPPORT_LINK", "MENU_SYSINFO_CUSTOMER_SUPPORT_URL", "github")
addlinkinfo(menu, "MENU_SYSINFO_DONATION_LINK", "MENU_SYSINFO_DONATION_URL", "donate")
addcredits(menu)
luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth
menu:AddBackButton()
menu:registerEventHandler("menu_close", LUI.SystemInfo.LeaveMenu)
return menu
end)
require("credits")
require("mainmenu")

View File

@ -0,0 +1,298 @@
local spacing = 10
local topoffset = 15
local extrawidth = 50
local extraheight1 = 0
local function makelink(element, link)
element:setHandleMouseMove(true)
element:setHandleMouseButton(true)
element:registerAnimationState("focused", {
color = {
r = 1,
g = 1,
b = 1
}
})
local entered = false
element:registerEventHandler("mouseenter", function()
if (not entered) then
Engine.PlaySound(CoD.SFX.MouseOver)
entered = true
end
element:animateToState("focused")
end)
element:registerEventHandler("mouseleave", function()
entered = false
element:animateToState("default")
end)
element:registerEventHandler("leftmousedown", function()
Engine.PlaySound(CoD.SFX.MouseClick)
game:openlink(link)
end)
end
local addlinkinfo = function(menu, key, value, link)
local text = Engine.Localize(value)
local element = menu:AddInfo(Engine.Localize(key), function()
return text
end)
local linkelement = element:getFirstChild():getNextSibling()
makelink(linkelement, link)
end
local function getnumcredits()
local csv = "credits.csv"
local rowcount = Engine.TableGetRowCount(csv)
return rowcount
end
local extraheight2 = getnumcredits() * 25 / 2
local function addcredits(menu)
local cols = {
name = 0,
link = 1
}
local csv = "credits.csv"
local rowcount = Engine.TableGetRowCount(csv)
local num = 0
local creditselement = LUI.UIElement.new({
topAnchor = true,
leftAnchor = true,
left = 500,
width = 30,
top = 255
})
menu:addElement(creditselement)
menu:AddInfo(Engine.Localize("MENU_CREDITS"), function()
return ""
end)
local num = 0
local addcredit = function(name, link)
local row = num % 4
local col = num >= 4 and 0 or 1
local text = Engine.Localize(name)
local element = LUI.UIText.new({
rightAnchor = true,
topAnchor = true,
right = -10 + (col * -100),
top = 25 * row,
width = 90,
height = LUI.MenuGenericButtons.ButtonLabelFont.Height * 0.8,
font = LUI.MenuGenericButtons.ButtonLabelFont.Font,
color = Colors.h1.light_grey,
alignment = Engine.IsRightToLeftLanguage() and LUI.Alignment.None or LUI.Alignment.Right
})
element.id = "credits_" .. num
element:setText(text)
creditselement:addElement(element)
makelink(element, link)
num = num + 1
end
for i = 0, rowcount - 1 do
local name = Engine.TableLookupByRow(csv, i, cols.name)
local link = Engine.TableLookupByRow(csv, i, cols.link)
addcredit(name, link)
end
end
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 - extraheight1
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)
addlinkinfo(menu, "MENU_SYSINFO_CUSTOMER_SUPPORT_LINK", "MENU_SYSINFO_CUSTOMER_SUPPORT_URL", "github")
luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth
menu:AddBackButton()
menu:registerEventHandler("menu_close", LUI.SystemInfo.LeaveMenu)
return menu
end
local startmap = Engine.StreamingInstallMap
Engine.StreamingInstallMap = function(map, args, ...)
if (args == "set ui_play_credits 1; devmap ending;") then
LUI.FlowManager.RequestAddMenu(nil, "credits_menu")
else
startmap(map, args, ...)
end
end
local creditsmap = function()
LUI.FlowManager.PushMenuStackToDVar()
if LUI.LevelSelect.IsAllLevelCompleted() then
Engine.SetDvarString("ui_char_museum_mode", "credits_2", true)
else
Engine.SetDvarString("ui_char_museum_mode", "credits_black", true)
end
startmap("ending", "set ui_play_credits 1; devmap ending;")
end
LUI.MenuBuilder.registerType("credits_menu", function(f6_arg0, f6_arg1)
local f6_local0 = LUI.MenuTemplate.spMenuOffset
local title = "MENU_SP_CREDITS_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:AddButton("MENU_SP_CREDITS_CAPS", creditsmap, nil, true, nil, {
desc_text = Engine.Localize("@LUA_MENU_CREDITS_DESC")
})
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 - extraheight2
local f6_local9 = luiglobals.GenericMenuDims.OptionMenuWidth + 100
local f6_local10 = menu.properties
local topoffset2 = LUI.MenuTemplate.ListTop + LUI.MenuTemplate.spMenuOffset + 50
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
addlinkinfo(menu, "MENU_SYSINFO_CUSTOMER_SUPPORT_LINK", "MENU_SYSINFO_CUSTOMER_SUPPORT_URL", "github")
addlinkinfo(menu, "MENU_SYSINFO_DONATION_LINK", "MENU_SYSINFO_DONATION_URL", "donate")
addcredits(menu)
luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth
menu:AddBackButton()
menu:registerEventHandler("menu_close", LUI.SystemInfo.LeaveMenu)
return menu
end)

View File

@ -0,0 +1,4 @@
LUI.onmenuopen("main_campaign", function(menu)
local headertext = menu:getFirstDescendentById("header_text")
headertext:setText("H2-MOD")
end)

View File

@ -42,17 +42,10 @@ function getmodname(path)
local modinfo = mods.getinfo(path)
if (not modinfo.isvalid) then
game:addlocalizedstring(path, path)
local desc = Engine.Localize("LUA_MENU_MOD_DESC_DEFAULT", path)
local desc = Engine.Localize("LUA_MENU_MOD_DESC_DEFAULT", string.el(path))
return path, desc
else
game:addlocalizedstring(modinfo.name, modinfo.name)
game:addlocalizedstring(modinfo.description, modinfo.description)
game:addlocalizedstring(modinfo.author, modinfo.author)
game:addlocalizedstring(modinfo.version, modinfo.version)
local desc = Engine.Localize("@LUA_MENU_MOD_DESC",
modinfo.description, modinfo.author, modinfo.version)
local desc = Engine.Localize("@LUA_MENU_MOD_DESC", string.el(modinfo.description), string.el(modinfo.author), string.el(modinfo.version))
return modinfo.name, desc
end
end
@ -67,18 +60,10 @@ LUI.MenuBuilder.registerType("mods_menu", function(a1)
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)))
createdivider(menu, Engine.Localize("@LUA_MENU_LOADED_MOD", string.el(name:truncate(24))))
menu:AddButton("@LUA_MENU_UNLOAD", function()
Engine.Exec("unloadmod")
@ -98,8 +83,7 @@ LUI.MenuBuilder.registerType("mods_menu", function(a1)
local name, desc = getmodname(mods[i])
if (mods[i] ~= modfolder) then
game:addlocalizedstring(name, name)
menu:AddButton(name, function()
menu:AddButton(string.el(name), function()
Engine.Exec("loadmod " .. mods[i])
end, nil, true, nil, {
desc_text = desc

View File

@ -95,5 +95,26 @@
"MENU_CREDITS_5": "netadr",
"MENU_CREDITS_6": "quaK",
"MENU_CREDITS_7": "xensik",
"MENU_CREDITS_8": "ZoneTool"
"MENU_CREDITS_8": "ZoneTool",
"LUA_MENU_SP_LOCATION_AF_CAVES": "LUA_MENU_SP_LOCATION_AF_CAVES",
"LUA_MENU_SP_LOCATION_AF_CHASE": "LUA_MENU_SP_LOCATION_AF_CHASE",
"LUA_MENU_SP_LOCATION_AIRPORT": "LUA_MENU_SP_LOCATION_AIRPORT",
"LUA_MENU_SP_LOCATION_ARCADIA": "LUA_MENU_SP_LOCATION_ARCADIA",
"LUA_MENU_SP_LOCATION_BONEYARD": "LUA_MENU_SP_LOCATION_BONEYARD",
"LUA_MENU_SP_LOCATION_CLIFFHANGER": "LUA_MENU_SP_LOCATION_CLIFFHANGER",
"LUA_MENU_SP_LOCATION_CONTINGENCY": "LUA_MENU_SP_LOCATION_CONTINGENCY",
"LUA_MENU_SP_LOCATION_DC_WHITEHOUSE": "LUA_MENU_SP_LOCATION_DC_WHITEHOUSE",
"LUA_MENU_SP_LOCATION_DCBURNING": "LUA_MENU_SP_LOCATION_DCBURNING",
"LUA_MENU_SP_LOCATION_DCEMP": "LUA_MENU_SP_LOCATION_DCEMP",
"LUA_MENU_SP_LOCATION_ENDING": "LUA_MENU_SP_LOCATION_ENDING",
"LUA_MENU_SP_LOCATION_ESTATE": "LUA_MENU_SP_LOCATION_ESTATE",
"LUA_MENU_SP_LOCATION_FAVELA": "LUA_MENU_SP_LOCATION_FAVELA",
"LUA_MENU_SP_LOCATION_FAVELA_ESCAPE": "LUA_MENU_SP_LOCATION_FAVELA_ESCAPE",
"LUA_MENU_SP_LOCATION_GULAG": "LUA_MENU_SP_LOCATION_GULAG",
"LUA_MENU_SP_LOCATION_INVASION": "LUA_MENU_SP_LOCATION_INVASION",
"LUA_MENU_SP_LOCATION_OILRIG": "LUA_MENU_SP_LOCATION_OILRIG",
"LUA_MENU_SP_LOCATION_ROADKILL": "LUA_MENU_SP_LOCATION_ROADKILL",
"LUA_MENU_SP_LOCATION_TRAINER": "LUA_MENU_SP_LOCATION_TRAINER",
"LUA_MENU_SP_LOCATION_MUSEUM": "LUA_MENU_SP_LOCATION_MUSEUM"
}