Skip to content

Commit 94023ca

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 * Added IP Address (hidden by default) column 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 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 94023ca

9 files changed

Lines changed: 1481 additions & 508 deletions

File tree

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

Lines changed: 423 additions & 311 deletions
Large diffs are not rendered by default.

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

Lines changed: 14 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,17 @@ class CNeoRoot : public vgui::EditablePanel, public CGameEventListener
231231
servernetadr_t m_favCacheNetAdr = {};
232232
bool m_bFavCacheIsFav = false;
233233
bool m_bAutoRefreshFav = false;
234+
235+
int m_iColsWideServerBrowser[GSIW__TOTAL] = {};
236+
int m_iColsWideServerBlacklist[SBLIST_COL__TOTAL] = {};
237+
int m_iColsWideDetailedPlayerList[GSPS__TOTAL] = {};
238+
239+
int m_iUpDownInitialServer = -1;
240+
int m_iUpDownDirection = 0;
241+
242+
NeoUI::TabsState m_tabsStateSettings = {};
243+
NeoUI::TabsState m_tabsStateServerBrowser = {};
244+
NeoUI::TabsState m_tabsStateIFF = {};
234245
};
235246

236247
extern CNeoRoot *g_pNeoRoot;

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

Lines changed: 32 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;
@@ -258,6 +259,10 @@ void CNeoServerList::UpdateFilteredList()
258259
iLeft = gsiLeft.m_nPing;
259260
iRight = gsiRight.m_nPing;
260261
break;
262+
case GSIW_IP_ADDRESS:
263+
iLeft = gsiLeft.m_NetAdr.GetIP();
264+
iRight = gsiRight.m_NetAdr.GetIP();
265+
break;
261266
case GSIW_NAME:
262267
default:
263268
// no-op, already assigned (default)
@@ -272,6 +277,7 @@ void CNeoServerList::UpdateFilteredList()
272277
break;
273278
case GSIW_PLAYERS:
274279
case GSIW_PING:
280+
case GSIW_IP_ADDRESS:
275281
if (iLeft != iRight) return (m_pSortCtx->bDescending) ? iLeft < iRight : iLeft > iRight;
276282
break;
277283
default:
@@ -280,10 +286,10 @@ void CNeoServerList::UpdateFilteredList()
280286
return (m_pSortCtx->bDescending) ? (V_strcmp(szRight, szLeft) > 0) : (V_strcmp(szLeft, szRight) > 0);
281287
});
282288

283-
if (IN_BETWEEN_AR(0, g_pNeoRoot->m_iSelectedServer, m_filteredServers.Count()))
289+
if (IN_BETWEEN_AR(0, g_pNeoRoot->m_iSelectedServer, m_filteredServers.size()))
284290
{
285291
g_pNeoRoot->m_iSelectedServer = -1;
286-
for (int i = 0; i < m_filteredServers.Count(); ++i)
292+
for (int i = 0; i < m_filteredServers.size(); ++i)
287293
{
288294
if (V_memcmp(&curGsi, &m_filteredServers[i], sizeof(gameserveritem_t)) == 0)
289295
{
@@ -301,6 +307,8 @@ void CNeoServerList::RequestList()
301307
return;
302308
}
303309

310+
m_servers.clear();
311+
304312
static MatchMakingKeyValuePair_t mmFilters[] = {
305313
{"gamedir", "neo"},
306314
};
@@ -331,9 +339,26 @@ void CNeoServerList::ServerResponded(HServerListRequest hRequest, int iServer)
331339

332340
ISteamMatchmakingServers *steamMM = steamapicontext->SteamMatchmakingServers();
333341
gameserveritem_t *pServerDetails = steamMM->GetServerDetails(hRequest, iServer);
334-
if (pServerDetails)
342+
if (pServerDetails && m_servers.size() < 1024)
335343
{
336-
m_servers.AddToTail(*pServerDetails);
344+
wchar_t wszServerName[k_cbMaxGameServerName] = {};
345+
g_pVGuiLocalize->ConvertANSIToUnicode(
346+
pServerDetails->GetName(), wszServerName, sizeof(wszServerName));
347+
const int iWszLen = V_wcslen(wszServerName);
348+
// NEO TODO (nullsystem): Need to implement fallback fonts in NeoUI or otherwise
349+
// without fallback unicode fonts can corrupt the memory on drawing the text somehow
350+
for (int i = 0; i < iWszLen; ++i)
351+
{
352+
if (wszServerName[i] >= 256)
353+
{
354+
wszServerName[i] = L'?';
355+
}
356+
}
357+
char szServerName[k_cbMaxGameServerName] = {};
358+
g_pVGuiLocalize->ConvertUnicodeToANSI(wszServerName, szServerName, sizeof(szServerName));
359+
Q_UnicodeRepair(szServerName);
360+
pServerDetails->SetName(szServerName);
361+
m_servers.push_back(*pServerDetails);
337362
m_bModified = true;
338363
}
339364
}
@@ -350,7 +375,7 @@ void CNeoServerList::RefreshComplete(HServerListRequest hRequest, EMatchMakingSe
350375
if (m_iType == GS_BLACKLIST || hRequest != m_hdlRequest) return;
351376

352377
m_bSearching = false;
353-
if (response == eNoServersListedOnMasterServer && m_servers.IsEmpty())
378+
if (response == eNoServersListedOnMasterServer && m_servers.empty())
354379
{
355380
m_bModified = true;
356381
}

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

Lines changed: 22 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
{
@@ -64,9 +65,11 @@ enum GameServerInfoW
6465
GSIW_LOCKED = 0,
6566
GSIW_VAC,
6667
GSIW_NAME,
68+
GSIW_IP_ADDRESS,
6769
GSIW_MAP,
6870
GSIW_PLAYERS,
6971
GSIW_PING,
72+
GSIW_TAGS,
7073

7174
GSIW__TOTAL,
7275
};
@@ -80,6 +83,14 @@ enum AntiCheatMode
8083
ANTICHEAT__TOTAL,
8184
};
8285

86+
enum ETagsFilterMode
87+
{
88+
TAGSFILTER_INCLUDE = 0,
89+
TAGSFILTER_EXCLUDE,
90+
91+
TAGSFILTER__TOTAL,
92+
};
93+
8394
enum GameServerPlayerSort
8495
{
8596
GSPS_SCORE = 0,
@@ -101,16 +112,19 @@ struct GameServerSortContext
101112

102113
struct GameServerPlayerSortContext
103114
{
104-
GameServerPlayerSort col = GSPS_SCORE;
115+
int col = GSPS_SCORE;
105116
bool bDescending = true;
106117
};
107118

108119
class CNeoServerList : public ISteamMatchmakingServerListResponse
109120
{
110121
public:
111122
GameServerType m_iType;
112-
CUtlVector<gameserveritem_t> m_servers;
113-
CUtlVector<gameserveritem_t> m_filteredServers;
123+
124+
// NEO JANK (nullsystem): CUtlVector easily corrupts memory with
125+
// gameserveritem_t results, so using std::vector instead
126+
std::vector<gameserveritem_t> m_servers;
127+
std::vector<gameserveritem_t> m_filteredServers;
114128

115129
void UpdateFilteredList();
116130
void RequestList();
@@ -155,4 +169,9 @@ struct ServerBrowserFilters
155169
bool bIsNotPasswordProtected = false;
156170
int iAntiCheat = 0;
157171
int iMaxPing = 0;
172+
wchar_t wszMapFilter[k_cbMaxGameServerMapName] = {};
173+
int iMaxPlayerCount = 0;
174+
int iTagsFilterType = 0;
175+
wchar_t wszTagsFilter[k_cbMaxGameServerTags] = {};
158176
};
177+

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)