Skip to content

Commit d7fcb71

Browse files
committed
NeoUI - Table headers + main table API + section X-axis scrolling
NeoUI table headers and main table API implemented, now have Begin/EndTable and NextTableRow implementation replacing the previous custom paint + button. Now can just layout the table cells with widgets, although at the moment only NeoUI::Label are properly utilized and dealt with. Other widgets are not refactored up for tables yet. The table headers now have dragable resizing and the server browser now have tags column. There's also right-click on the header to show/hide columns. Sections now have X-axis scrolling, mainly used for table and header scrolling support. Re-done NeoUI::Tabs scrolling, now it's held externally and its own thing. OTHERS: * Fix SDR/Steam networking server bot vs player number count * Fix border in smaller resolutions TODOs: * Section X-scrollbar controls options/flags * Modes: * No X-scrollbar * Indicator/thin X-scrollbar * Dragable/thick X-scrollbar * Using BeginTable will automatically put the section into Dragable/thick X-scrollbar mode * Some TODOs in source code * Change from only header to any sections to reference other section's scrolls * More columns parity to legacy browser FUTURE TODOs: * Refactor painting of widgets to utilize vgui viewports * Possible split of painting (and colors) from NeoUI internals * Vertical layouting that expands horizontally as oppose to the default horizontal layouting that expands vertically * fixes #1566 * fixes #994 * fixes #1815
1 parent b7e6a66 commit d7fcb71

9 files changed

Lines changed: 1500 additions & 508 deletions

File tree

src/game/client/neo/ui/neo_root.cpp

Lines changed: 457 additions & 312 deletions
Large diffs are not rendered by default.

src/game/client/neo/ui/neo_root.h

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ class CNeoRoot : public vgui::EditablePanel, public CGameEventListener
172172
int m_iServerBrowserTab = 0;
173173
CNeoServerList m_serverBrowser[GS__TOTAL];
174174
CNeoServerPlayers m_serverPlayers;
175-
ServerBrowserFilters m_sbFilters;
176-
bool m_bSBFiltModified = false;
175+
ServerBrowserFilters m_sbFilters = {};
176+
NeoUI::TableHeaderModFlags m_headerModFlagsServerBrowser = 0;
177177
bool m_bShowFilterPanel = false;
178-
bool m_bSPlayersSortModified = false;
178+
NeoUI::TableHeaderModFlags m_headerModFlagsPlayers = 0;
179179
GameServerSortContext m_sortCtx = {};
180180

181181
wchar_t m_wszBindingText[128];
@@ -231,6 +231,26 @@ class CNeoRoot : public vgui::EditablePanel, public CGameEventListener
231231
servernetadr_t m_favCacheNetAdr = {};
232232
bool m_bFavCacheIsFav = false;
233233
bool m_bAutoRefreshFav = false;
234+
235+
// server browser headers - current view
236+
const wchar_t *m_wszServerBrowserHeaders[GSIW__TOTAL] = {};
237+
int m_iTotalColsSBrowser = 0;
238+
int m_iColsWideServerBrowser[GSIW__TOTAL] = {};
239+
bool m_bSBHInit = false;
240+
241+
// server browser headers - all headers infos
242+
bool m_bColsHideSBrowser[GSIW__TOTAL] = {};
243+
int m_iColsWideAllServerBrowser[GSIW__TOTAL] = {};
244+
245+
int m_iColsWideServerBlacklist[SBLIST_COL__TOTAL] = {};
246+
int m_iColsWideDetailedPlayerList[GSPS__TOTAL] = {};
247+
248+
int m_iUpDownInitialServer = -1;
249+
int m_iUpDownDirection = 0;
250+
251+
NeoUI::TabsState m_tabsStateSettings = {};
252+
NeoUI::TabsState m_tabsStateServerBrowser = {};
253+
NeoUI::TabsState m_tabsStateIFF = {};
234254
};
235255

236256
extern CNeoRoot *g_pNeoRoot;

src/game/client/neo/ui/neo_root_serverbrowser.cpp

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,14 @@ void CNeoServerList::UpdateFilteredList()
205205
}
206206

207207
gameserveritem_t curGsi;
208-
if (IN_BETWEEN_AR(0, g_pNeoRoot->m_iSelectedServer, m_filteredServers.Count()))
208+
if (IN_BETWEEN_AR(0, g_pNeoRoot->m_iSelectedServer, m_filteredServers.size()))
209209
{
210210
V_memcpy(&curGsi, &m_filteredServers[g_pNeoRoot->m_iSelectedServer], sizeof(gameserveritem_t));
211211
}
212212

213213
m_filteredServers = m_servers;
214-
if (m_filteredServers.IsEmpty())
214+
215+
if (m_filteredServers.empty())
215216
{
216217
g_pNeoRoot->m_iSelectedServer = -1;
217218
return;
@@ -280,10 +281,10 @@ void CNeoServerList::UpdateFilteredList()
280281
return (m_pSortCtx->bDescending) ? (V_strcmp(szRight, szLeft) > 0) : (V_strcmp(szLeft, szRight) > 0);
281282
});
282283

283-
if (IN_BETWEEN_AR(0, g_pNeoRoot->m_iSelectedServer, m_filteredServers.Count()))
284+
if (IN_BETWEEN_AR(0, g_pNeoRoot->m_iSelectedServer, m_filteredServers.size()))
284285
{
285286
g_pNeoRoot->m_iSelectedServer = -1;
286-
for (int i = 0; i < m_filteredServers.Count(); ++i)
287+
for (int i = 0; i < m_filteredServers.size(); ++i)
287288
{
288289
if (V_memcmp(&curGsi, &m_filteredServers[i], sizeof(gameserveritem_t)) == 0)
289290
{
@@ -301,6 +302,8 @@ void CNeoServerList::RequestList()
301302
return;
302303
}
303304

305+
m_servers.clear();
306+
304307
static MatchMakingKeyValuePair_t mmFilters[] = {
305308
{"gamedir", "neo"},
306309
};
@@ -331,9 +334,26 @@ void CNeoServerList::ServerResponded(HServerListRequest hRequest, int iServer)
331334

332335
ISteamMatchmakingServers *steamMM = steamapicontext->SteamMatchmakingServers();
333336
gameserveritem_t *pServerDetails = steamMM->GetServerDetails(hRequest, iServer);
334-
if (pServerDetails)
337+
if (pServerDetails && m_servers.size() < 1024)
335338
{
336-
m_servers.AddToTail(*pServerDetails);
339+
wchar_t wszServerName[k_cbMaxGameServerName] = {};
340+
g_pVGuiLocalize->ConvertANSIToUnicode(
341+
pServerDetails->GetName(), wszServerName, sizeof(wszServerName));
342+
const int iWszLen = V_wcslen(wszServerName);
343+
// NEO TODO (nullsystem): Need to implement fallback fonts in NeoUI or otherwise
344+
// without fallback unicode fonts can corrupt the memory on drawing the text somehow
345+
for (int i = 0; i < iWszLen; ++i)
346+
{
347+
if (wszServerName[i] >= 256)
348+
{
349+
wszServerName[i] = L'?';
350+
}
351+
}
352+
char szServerName[k_cbMaxGameServerName] = {};
353+
g_pVGuiLocalize->ConvertUnicodeToANSI(wszServerName, szServerName, sizeof(szServerName));
354+
Q_UnicodeRepair(szServerName);
355+
pServerDetails->SetName(szServerName);
356+
m_servers.push_back(*pServerDetails);
337357
m_bModified = true;
338358
}
339359
}
@@ -350,7 +370,7 @@ void CNeoServerList::RefreshComplete(HServerListRequest hRequest, EMatchMakingSe
350370
if (m_iType == GS_BLACKLIST || hRequest != m_hdlRequest) return;
351371

352372
m_bSearching = false;
353-
if (response == eNoServersListedOnMasterServer && m_servers.IsEmpty())
373+
if (response == eNoServersListedOnMasterServer && m_servers.empty())
354374
{
355375
m_bModified = true;
356376
}

src/game/client/neo/ui/neo_root_serverbrowser.h

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <tier1/netadr.h>
44
#include <steam/isteammatchmaking.h>
55
#include <utlvector.h>
6+
#include <vector>
67

78
enum EServerBlacklistType
89
{
@@ -67,6 +68,7 @@ enum GameServerInfoW
6768
GSIW_MAP,
6869
GSIW_PLAYERS,
6970
GSIW_PING,
71+
GSIW_TAGS,
7072

7173
GSIW__TOTAL,
7274
};
@@ -80,6 +82,14 @@ enum AntiCheatMode
8082
ANTICHEAT__TOTAL,
8183
};
8284

85+
enum ETagsFilterMode
86+
{
87+
TAGSFILTER_INCLUDE = 0,
88+
TAGSFILTER_EXCLUDE,
89+
90+
TAGSFILTER__TOTAL,
91+
};
92+
8393
enum GameServerPlayerSort
8494
{
8595
GSPS_SCORE = 0,
@@ -101,16 +111,19 @@ struct GameServerSortContext
101111

102112
struct GameServerPlayerSortContext
103113
{
104-
GameServerPlayerSort col = GSPS_SCORE;
114+
int col = GSPS_SCORE;
105115
bool bDescending = true;
106116
};
107117

108118
class CNeoServerList : public ISteamMatchmakingServerListResponse
109119
{
110120
public:
111121
GameServerType m_iType;
112-
CUtlVector<gameserveritem_t> m_servers;
113-
CUtlVector<gameserveritem_t> m_filteredServers;
122+
123+
// NEO JANK (nullsystem): CUtlVector easily corrupts memory with
124+
// gameserveritem_t results, so using std::vector instead
125+
std::vector<gameserveritem_t> m_servers;
126+
std::vector<gameserveritem_t> m_filteredServers;
114127

115128
void UpdateFilteredList();
116129
void RequestList();
@@ -155,4 +168,9 @@ struct ServerBrowserFilters
155168
bool bIsNotPasswordProtected = false;
156169
int iAntiCheat = 0;
157170
int iMaxPing = 0;
171+
wchar_t wszMapFilter[k_cbMaxGameServerMapName] = {};
172+
int iMaxPlayerCount = 0;
173+
int iTagsFilterType = 0;
174+
wchar_t wszTagsFilter[k_cbMaxGameServerTags] = {};
158175
};
176+

src/game/client/neo/ui/neo_root_settings.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,8 @@ void NeoSettings_HUD(NeoSettings *ns)
14891489

14901490
NeoUI::SetPerRowLayout(1);
14911491
NeoUI::Tabs(IFF_LABELS, iIFFLabelsSize, &optionChosen,
1492-
NeoUI::TABFLAG_NOSIDEKEYS | NeoUI::TABFLAG_NOSTATERESETS);
1492+
NeoUI::TABFLAG_NOSIDEKEYS | NeoUI::TABFLAG_NOSTATERESETS,
1493+
&g_pNeoRoot->m_tabsStateIFF);
14931494
NeoUI::SetPerRowLayout(2, NeoUI::ROWLAYOUT_TWOSPLIT);
14941495

14951496
// NEO TODO (Adam) Show what the marker looks like somewhere here

src/game/client/neo/ui/neo_theme.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@ void SetupNTRETheme(NeoUI::Context *pNeoUICtx)
2727
pColors->sliderHotBg = COLOR_GREY;
2828
pColors->sliderActiveBg = COLOR_BLACK;
2929
pColors->tabHintsFg = COLOR_WHITE;
30+
pColors->tableHeaderSortIndicatorBg = COLOR_WHITE;
31+
pColors->headerDragNormalBg = COLOR_FADED_WHITE;
32+
pColors->headerDragActiveBg = COLOR_DARK_RED;
3033
}
3134

0 commit comments

Comments
 (0)