Allow longer hostnames
This commit is contained in:
parent
6bcc45f227
commit
9e3cd77c6c
@ -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
|
||||
|
@ -258,20 +258,6 @@ namespace server_list
|
||||
return true;
|
||||
}
|
||||
|
||||
void resize_host_name(std::string& name)
|
||||
{
|
||||
name = utils::string::split(name, '\n').front();
|
||||
|
||||
game::Font_s* font = game::R_RegisterFont("fonts/default.otf", 18);
|
||||
auto text_size = game::UI_TextWidth(name.data(), 32, font, 1.0f);
|
||||
|
||||
while (text_size > 450)
|
||||
{
|
||||
text_size = game::UI_TextWidth(name.data(), 32, font, 1.0f);
|
||||
name.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
utils::hook::detour lui_open_menu_hook;
|
||||
|
||||
void lui_open_menu_stub(int controllerIndex, const char* menu, int a3, int a4, unsigned int a5)
|
||||
@ -364,8 +350,6 @@ namespace server_list
|
||||
|
||||
server.in_game = 1;
|
||||
|
||||
resize_host_name(server.host_name);
|
||||
|
||||
insert_server(std::move(server));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user