Allow longer hostnames

This commit is contained in:
Federico Cecchetto
2022-03-09 22:27:12 +01:00
parent 6bcc45f227
commit 9e3cd77c6c
3 changed files with 119 additions and 121 deletions

View File

@ -24,6 +24,19 @@ local columns = {
"@MENU_PING",
}
function textlength(text, font, height)
local _, _, width = luiglobals.GetTextDimensions(text, font, height)
return width
end
function trimtext(text, font, height, maxwidth)
while (textlength(text, font, height) > maxwidth) do
text = text:sub(1, #text - 1)
end
return text
end
SystemLinkJoinMenu.AddHeaderButton = function(menu, f12_arg1, width)
local state = CoD.CreateState(0, f12_arg1, nil, nil, CoD.AnchorTypes.TopLeft)
state.width = width
@ -53,7 +66,8 @@ SystemLinkJoinMenu.AddServerButton = function(menu, controller, index)
button:addEventHandler("button_action", SystemLinkJoinMenu.OnJoinGame)
local gettext = function(i)
return Lobby.GetServerData(controller, index, i - 1)
local text = Lobby.GetServerData(controller, index, i - 1)
return trimtext(text, CoD.TextSettings.TitleFontSmall.Font, 14, 400)
end
for i = 1, #offsets do