Show player/server count in server list
This commit is contained in:
parent
b12a763367
commit
1b6442fc9e
@ -7,6 +7,8 @@ end
|
||||
|
||||
game:addlocalizedstring("MENU_NUMPLAYERS", "Players")
|
||||
game:addlocalizedstring("MENU_PING", "Ping")
|
||||
game:addlocalizedstring("SERVERLIST_PLAYER_COUNT", "&&1 Players")
|
||||
game:addlocalizedstring("SERVERLIST_SERVER_COUNT", "&&1 Servers")
|
||||
|
||||
local columns = {
|
||||
{
|
||||
@ -195,8 +197,33 @@ function menu_systemlink_join(f19_arg0, f19_arg1)
|
||||
SystemLinkJoinMenu.UpdateCounterText(menu, nil)
|
||||
Lobby.BuildServerList(Engine.GetFirstActiveController())
|
||||
|
||||
local playercount = LUI.UIText.new({
|
||||
rightAnchor = true,
|
||||
topAnchor = true,
|
||||
height = 18,
|
||||
bottom = 58,
|
||||
font = CoD.TextSettings.BodyFont.Font,
|
||||
width = 300,
|
||||
alignment = LUI.Alignment.Right,
|
||||
})
|
||||
menu:addElement(playercount)
|
||||
|
||||
local servercount = LUI.UIText.new({
|
||||
rightAnchor = true,
|
||||
topAnchor = true,
|
||||
height = 18,
|
||||
bottom = 58 - 25,
|
||||
font = CoD.TextSettings.BodyFont.Font,
|
||||
width = 300,
|
||||
alignment = LUI.Alignment.Right,
|
||||
})
|
||||
menu:addElement(servercount)
|
||||
|
||||
menu.list:registerEventHandler(LUI.UIScrollIndicator.UpdateEvent, function(element, event)
|
||||
SystemLinkJoinMenu.UpdateCounterText(menu, event)
|
||||
|
||||
playercount:setText(Engine.Localize("@SERVERLIST_PLAYER_COUNT", serverlist:getplayercount()))
|
||||
servercount:setText(Engine.Localize("@SERVERLIST_SERVER_COUNT", serverlist:getservercount()))
|
||||
end)
|
||||
|
||||
SystemLinkJoinMenu.UpdateGameList(menu)
|
||||
|
@ -9,4 +9,7 @@ namespace server_list
|
||||
void handle_info_response(const game::netadr_s& address, const utils::info_string& info);
|
||||
|
||||
bool sl_key_event(int key, int down);
|
||||
|
||||
int get_player_count();
|
||||
int get_server_count();
|
||||
}
|
@ -17,6 +17,7 @@
|
||||
#include "fastfiles.hpp"
|
||||
#include "scripting.hpp"
|
||||
#include "updater.hpp"
|
||||
#include "server_list.hpp"
|
||||
|
||||
#include "game/ui_scripting/execution.hpp"
|
||||
#include "game/scripting/execution.hpp"
|
||||
@ -342,6 +343,12 @@ namespace ui_scripting
|
||||
::game::Dvar_SetFromStringByNameFromSource("virtualLobbyPresentable", "1", ::game::DvarSetSource::DVAR_SOURCE_INTERNAL);
|
||||
};
|
||||
|
||||
auto server_list_table = table();
|
||||
lua["serverlist"] = server_list_table;
|
||||
|
||||
server_list_table["getplayercount"] = server_list::get_player_count;
|
||||
server_list_table["getservercount"] = server_list::get_server_count;
|
||||
|
||||
auto updater_table = table();
|
||||
lua["updater"] = updater_table;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user