2016-03-27 11:49:47 +02:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
Copyright (C) 2015 the OpenMoHAA team
|
|
|
|
|
|
|
|
This file is part of OpenMoHAA source code.
|
|
|
|
|
|
|
|
OpenMoHAA source code is free software; you can redistribute it
|
|
|
|
and/or modify it under the terms of the GNU General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 of the License,
|
|
|
|
or (at your option) any later version.
|
|
|
|
|
|
|
|
OpenMoHAA source code is distributed in the hope that it will be
|
|
|
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OpenMoHAA source code; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "cl_ui.h"
|
2023-07-27 23:02:39 +02:00
|
|
|
#include "../gamespy/goaceng.h"
|
2023-07-28 21:51:37 +02:00
|
|
|
#include "../gamespy/sv_gamespy.h"
|
2023-07-27 23:02:39 +02:00
|
|
|
|
|
|
|
class FAKKServerListItem : public UIListCtrlItem {
|
|
|
|
str m_strings[6];
|
|
|
|
str m_sVersion;
|
|
|
|
bool m_bDifferentVersion;
|
|
|
|
bool m_bFavorite;
|
|
|
|
bool m_bQueryDone;
|
|
|
|
bool m_bQueryFailed;
|
|
|
|
int m_iNumPlayers;
|
|
|
|
|
|
|
|
public:
|
|
|
|
str m_sIP;
|
|
|
|
unsigned int m_uiRealIP;
|
|
|
|
int m_iPort;
|
|
|
|
int m_iGameSpyPort;
|
|
|
|
|
|
|
|
public:
|
|
|
|
FAKKServerListItem(str string1, str string2, str string3, str string4, str string5, str string6, str ver);
|
|
|
|
|
|
|
|
griditemtype_t getListItemType(int index) const override;
|
|
|
|
int getListItemValue(int i) const override;
|
|
|
|
str getListItemString(int i) const override;
|
|
|
|
void setListItemString(int i, str sNewString);
|
|
|
|
void DrawListItem(int iColumn, const UIRect2D& drawRect, bool bSelected, UIFont* pFont) override;
|
|
|
|
qboolean IsHeaderEntry() const override;
|
2023-07-28 21:51:37 +02:00
|
|
|
bool IsQueried() const;
|
2023-07-27 23:02:39 +02:00
|
|
|
void SetQueried(bool bIsQueried);
|
2023-07-28 21:51:37 +02:00
|
|
|
bool IfQueryFailed() const;
|
2023-07-27 23:02:39 +02:00
|
|
|
void SetQueryFailed(bool bFailed);
|
2023-07-28 21:51:37 +02:00
|
|
|
void SetNumPlayers(int iNum);
|
|
|
|
bool IsFavorite() const;
|
2023-07-27 23:02:39 +02:00
|
|
|
void SetFavorite(bool bIsFavorite);
|
2023-07-28 21:51:37 +02:00
|
|
|
str GetListItemVersion() const;
|
2023-07-27 23:02:39 +02:00
|
|
|
void SetListItemVersion(str sNewVer);
|
|
|
|
void SetDifferentVersion(bool bIsDifferentVersion);
|
2023-07-28 21:51:37 +02:00
|
|
|
bool IsDifferentVersion() const;
|
2023-07-27 23:02:39 +02:00
|
|
|
};
|
|
|
|
|
2023-07-28 21:51:37 +02:00
|
|
|
void UpdateServerListCallBack(GServerList serverlist, int msg, void* instance, void* param1, void* param2);
|
|
|
|
|
|
|
|
static int g_iTotalNumPlayers;
|
|
|
|
qboolean g_bNumericSort = qfalse;
|
|
|
|
qboolean g_bReverseSort = qfalse;
|
|
|
|
qboolean g_NeedAdditionalLANSearch = qfalse;
|
|
|
|
|
2023-07-27 23:02:39 +02:00
|
|
|
FAKKServerListItem::FAKKServerListItem(str string1, str string2, str string3, str string4, str string5, str string6, str ver)
|
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
m_bFavorite = false;
|
|
|
|
m_bQueryDone = false;
|
|
|
|
m_bQueryFailed = false;
|
|
|
|
m_iNumPlayers = 0;
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
griditemtype_t FAKKServerListItem::getListItemType(int index) const
|
|
|
|
{
|
|
|
|
return griditemtype_t::TYPE_STRING;
|
|
|
|
}
|
|
|
|
|
|
|
|
int FAKKServerListItem::getListItemValue(int i) const
|
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
return atoi(m_strings[i]);
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
str FAKKServerListItem::getListItemString(int i) const
|
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
return m_strings[i];
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FAKKServerListItem::setListItemString(int i, str sNewString)
|
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
m_strings[i] = sNewString;
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FAKKServerListItem::DrawListItem(int iColumn, const UIRect2D& drawRect, bool bSelected, UIFont* pFont)
|
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
static cvar_t *pColoringType = Cvar_Get("cl_browserdetailedcolors", "0", CVAR_ARCHIVE);
|
|
|
|
|
|
|
|
if (!pColoringType->integer) {
|
|
|
|
if (IfQueryFailed() || (IsDifferentVersion() && IsQueried())) {
|
|
|
|
if (bSelected) {
|
|
|
|
DrawBox(drawRect, UColor(0.2f, 0.0f, 0.0f), 1.0);
|
|
|
|
pFont->setColor(UColor(0.9f, 0.0f, 0.0f));
|
|
|
|
} else {
|
|
|
|
DrawBox(drawRect, UColor(0.1f, 0.0f, 0.0f), 1.0);
|
|
|
|
pFont->setColor(UColor(0.55f, 0.0f, 0.0f));
|
|
|
|
}
|
|
|
|
} else if (IsQueried()) {
|
|
|
|
if (bSelected) {
|
|
|
|
DrawBox(drawRect, UColor(0.2f, 0.18f, 0.015f), 1.0);
|
|
|
|
pFont->setColor(UColor(0.9f, 0.8f, 0.6f));
|
|
|
|
} else {
|
|
|
|
DrawBox(drawRect, UColor(0.02f, 0.07f, 0.004f), 1.0);
|
|
|
|
pFont->setColor(UHudColor);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (bSelected) {
|
|
|
|
DrawBox(drawRect, UColor(0.15f, 0.18f, 0.18f), 1.0);
|
|
|
|
pFont->setColor(UColor(0.6f, 0.7f, 0.8f));
|
|
|
|
} else {
|
|
|
|
DrawBox(drawRect, UColor(0.005f, 0.07f, 0.02f), 1.0);
|
|
|
|
pFont->setColor(UColor(0.05f, 0.5f, 0.6f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pFont->Print(
|
|
|
|
drawRect.pos.x + 1.0,
|
|
|
|
drawRect.pos.y,
|
|
|
|
getListItemString(iColumn).c_str(),
|
|
|
|
-1,
|
|
|
|
qfalse
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
if (IsDifferentVersion()) {
|
|
|
|
if (IsQueried()) {
|
|
|
|
if (bSelected) {
|
|
|
|
DrawBox(drawRect, UColor(0.25f, 0.0f, 0.0f), 1.0);
|
|
|
|
pFont->setColor(UColor(0.0f, 0.5f, 0.0f));
|
|
|
|
} else {
|
|
|
|
DrawBox(drawRect, UColor(0.005f, 0.07f, 0.02f), 1.0);
|
|
|
|
pFont->setColor(UColor(0.0f, 0.35f, 0.0f));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (bSelected) {
|
|
|
|
DrawBox(drawRect, UColor(0.25f, 0.0f, 0.0f), 1.0);
|
|
|
|
pFont->setColor(UColor(0.5f, 0.6f, 0.7f));
|
|
|
|
} else {
|
|
|
|
DrawBox(drawRect, UColor(0.15f, 0.0f, 0.0f), 1.0);
|
|
|
|
pFont->setColor(UColor(0.05f, 0.4f, 0.5f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (IsQueried()) {
|
|
|
|
if (bSelected) {
|
|
|
|
DrawBox(drawRect, UColor(0.2f, 0.18f, 0.015f), 1.0);
|
|
|
|
pFont->setColor(UColor(0.9f, 0.8f, 0.6f));
|
|
|
|
} else {
|
|
|
|
DrawBox(drawRect, UColor(0.02f, 0.07f, 0.005f), 1.0);
|
|
|
|
pFont->setColor(UHudColor);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (bSelected) {
|
|
|
|
DrawBox(drawRect, UColor(0.15f, 0.18f, 0.18f), 1.0);
|
|
|
|
pFont->setColor(UColor(0.6f, 0.7f, 0.8f));
|
|
|
|
} else {
|
|
|
|
DrawBox(drawRect, UColor(0.005f, 0.07f, 0.02f), 1.0);
|
|
|
|
pFont->setColor(UColor(0.05f, 0.5f, 0.6f));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IfQueryFailed()) {
|
|
|
|
DrawBox(
|
|
|
|
UIRect2D(
|
|
|
|
drawRect.pos.x,
|
|
|
|
drawRect.pos.y + drawRect.size.height * 0.5 - 1.0 + drawRect.pos.y,
|
|
|
|
drawRect.size.width,
|
|
|
|
drawRect.size.height * 0.5 - 1.0 + drawRect.pos.y
|
|
|
|
),
|
|
|
|
URed,
|
|
|
|
0.3f
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
pFont->Print(
|
|
|
|
drawRect.pos.x + 1.0,
|
|
|
|
drawRect.pos.y,
|
|
|
|
getListItemString(iColumn).c_str(),
|
|
|
|
-1,
|
|
|
|
qfalse
|
|
|
|
);
|
|
|
|
|
|
|
|
if (IsDifferentVersion()) {
|
|
|
|
DrawBox(
|
|
|
|
UIRect2D(
|
|
|
|
drawRect.pos.x,
|
|
|
|
drawRect.pos.y + drawRect.size.height * 0.5 - 1.0 + drawRect.pos.y,
|
|
|
|
drawRect.size.width,
|
|
|
|
1.0
|
|
|
|
),
|
|
|
|
URed,
|
|
|
|
0.3f
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
qboolean FAKKServerListItem::IsHeaderEntry() const
|
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
return m_bFavorite;
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
|
|
|
|
2023-07-28 21:51:37 +02:00
|
|
|
bool FAKKServerListItem::IsQueried() const
|
2023-07-27 23:02:39 +02:00
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
return m_bQueryDone;
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FAKKServerListItem::SetQueried(bool bIsQueried)
|
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
m_bQueryDone = bIsQueried;
|
|
|
|
if (m_bQueryDone) {
|
|
|
|
m_bQueryFailed = false;
|
|
|
|
} else {
|
|
|
|
SetNumPlayers(0);
|
|
|
|
}
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
|
|
|
|
2023-07-28 21:51:37 +02:00
|
|
|
bool FAKKServerListItem::IfQueryFailed() const
|
2023-07-27 23:02:39 +02:00
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
return m_bQueryFailed;
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FAKKServerListItem::SetQueryFailed(bool bFailed)
|
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
m_bQueryFailed = bFailed;
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
|
|
|
|
2023-07-28 21:51:37 +02:00
|
|
|
void FAKKServerListItem::SetNumPlayers(int iNum)
|
2023-07-27 23:02:39 +02:00
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
if (m_iNumPlayers) {
|
|
|
|
g_iTotalNumPlayers -= m_iNumPlayers;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_iNumPlayers = iNum;
|
|
|
|
g_iTotalNumPlayers += iNum;
|
|
|
|
Cvar_Set("dm_playercount", va("%d", g_iTotalNumPlayers));
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
|
|
|
|
2023-07-28 21:51:37 +02:00
|
|
|
bool FAKKServerListItem::IsFavorite() const
|
2023-07-27 23:02:39 +02:00
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
return m_bFavorite;
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FAKKServerListItem::SetFavorite(bool bIsFavorite)
|
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
m_bFavorite = bIsFavorite;
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
|
|
|
|
2023-07-28 21:51:37 +02:00
|
|
|
str FAKKServerListItem::GetListItemVersion() const
|
2023-07-27 23:02:39 +02:00
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
return m_sVersion;
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FAKKServerListItem::SetListItemVersion(str sNewVer)
|
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
m_sVersion = sNewVer;
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FAKKServerListItem::SetDifferentVersion(bool bIsDifferentVersion)
|
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
m_bDifferentVersion = bIsDifferentVersion;
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
|
|
|
|
2023-07-28 21:51:37 +02:00
|
|
|
bool FAKKServerListItem::IsDifferentVersion() const
|
2023-07-27 23:02:39 +02:00
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
return m_bDifferentVersion;
|
2023-07-27 23:02:39 +02:00
|
|
|
}
|
2016-03-27 11:49:47 +02:00
|
|
|
|
|
|
|
CLASS_DECLARATION( UIListCtrl, UIFAKKServerList, NULL )
|
|
|
|
{
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
UIFAKKServerList::UIFAKKServerList()
|
|
|
|
{
|
2023-07-27 22:43:41 +02:00
|
|
|
setBackgroundColor(UWhite, true);
|
|
|
|
Connect(this, EV_UIListBase_ItemDoubleClicked, EV_UIListBase_ItemDoubleClicked);
|
|
|
|
Connect(this, EV_UIListBase_ItemSelected, EV_UIListBase_ItemSelected);
|
|
|
|
|
|
|
|
AllowActivate(true);
|
|
|
|
setHeaderFont("facfont-20");
|
|
|
|
m_serverList = NULL;
|
|
|
|
m_bHasList = false;
|
|
|
|
m_bGettingList = false;
|
|
|
|
m_bUpdatingList = false;
|
|
|
|
m_bLANListing = false;
|
|
|
|
m_iLastSortColumn = 2;
|
2016-03-27 11:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIFAKKServerList::SelectServer( Event *ev )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIFAKKServerList::ConnectServer( Event *ev )
|
|
|
|
{
|
2023-07-27 23:02:39 +02:00
|
|
|
// FIXME: unimplemented
|
2016-03-27 11:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
qboolean UIFAKKServerList::KeyEvent( int key, unsigned int time )
|
|
|
|
{
|
2023-07-27 23:02:39 +02:00
|
|
|
// FIXME: unimplemented
|
2016-03-27 11:49:47 +02:00
|
|
|
return qfalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIFAKKServerList::UpdateUIElement( void )
|
|
|
|
{
|
2023-07-27 23:02:39 +02:00
|
|
|
// FIXME: unimplemented
|
2016-03-27 11:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIFAKKServerList::RefreshServerList( Event *ev )
|
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
int i;
|
|
|
|
FAKKServerListItem* pNewServerItem;
|
|
|
|
|
|
|
|
for (i = 1; i <= getNumItems(); i++) {
|
|
|
|
pNewServerItem = static_cast<FAKKServerListItem*>(GetItem(i));
|
|
|
|
pNewServerItem->SetQueried(false);
|
|
|
|
pNewServerItem->SetQueryFailed(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_serverList) {
|
|
|
|
ServerListClear(m_serverList);
|
|
|
|
} else {
|
|
|
|
NewServerList();
|
|
|
|
}
|
|
|
|
|
|
|
|
Cvar_Set("dm_playercount", "0");
|
|
|
|
ServerListUpdate(m_serverList, true);
|
|
|
|
m_bUpdatingList = true;
|
2016-03-27 11:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIFAKKServerList::RefreshLANServerList( Event *ev )
|
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
int i;
|
|
|
|
FAKKServerListItem* pNewServerItem;
|
|
|
|
|
|
|
|
for (i = 1; i <= getNumItems(); i++) {
|
|
|
|
pNewServerItem = static_cast<FAKKServerListItem*>(GetItem(i));
|
|
|
|
pNewServerItem->SetQueried(false);
|
|
|
|
pNewServerItem->SetQueryFailed(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_serverList) {
|
|
|
|
ServerListClear(m_serverList);
|
|
|
|
} else {
|
|
|
|
NewServerList();
|
|
|
|
}
|
|
|
|
|
|
|
|
g_NeedAdditionalLANSearch = true;
|
|
|
|
|
|
|
|
Cvar_Set("dm_playercount", "0");
|
|
|
|
// Search all LAN servers from port 12300 to 12316
|
|
|
|
ServerListLANUpdate(m_serverList, true, 12300, 12316, 1);
|
2016-03-27 11:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIFAKKServerList::CancelRefresh( Event *ev )
|
|
|
|
{
|
2023-07-27 23:02:39 +02:00
|
|
|
ServerListHalt(m_serverList);
|
2016-03-27 11:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIFAKKServerList::NewServerList( void )
|
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
int iNumConcurrent;
|
|
|
|
const char* secret_key;
|
|
|
|
const char* game_name;
|
|
|
|
cvar_t* pRateCvar = Cvar_Get("rate", "5000", CVAR_ARCHIVE | CVAR_USERINFO);
|
|
|
|
|
|
|
|
game_name = GS_GetCurrentGameName();
|
|
|
|
secret_key = GS_GetCurrentGameKey();
|
|
|
|
if (pRateCvar->integer <= 3000) {
|
|
|
|
iNumConcurrent = 4;
|
|
|
|
} else if (pRateCvar->integer <= 5000) {
|
|
|
|
iNumConcurrent = 6;
|
|
|
|
} else if (pRateCvar->integer <= 25000) {
|
|
|
|
iNumConcurrent = 10;
|
|
|
|
} else {
|
|
|
|
iNumConcurrent = 15;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_serverList = ServerListNew(
|
|
|
|
game_name,
|
|
|
|
game_name,
|
|
|
|
secret_key,
|
|
|
|
iNumConcurrent,
|
|
|
|
&UpdateServerListCallBack,
|
|
|
|
1,
|
|
|
|
(void*)this
|
|
|
|
);
|
2016-03-27 11:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIFAKKServerList::MakeLANListing( Event *ev )
|
|
|
|
{
|
2023-07-27 23:02:39 +02:00
|
|
|
m_bLANListing = true;
|
2016-03-27 11:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIFAKKServerList::UpdateServer( Event *ev )
|
|
|
|
{
|
2023-07-27 23:02:39 +02:00
|
|
|
if (m_currentItem <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FAKKServerListItem* item = (FAKKServerListItem*)GetItem(getCurrentItem());
|
|
|
|
ServerListAuxUpdate(m_serverList, item->m_sIP.c_str(), item->m_iGameSpyPort, true, GQueryType::qt_status);
|
2016-03-27 11:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int UIFAKKServerList::ServerCompareFunction( const UIListCtrlItem *i1, const UIListCtrlItem *i2, int columnname )
|
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
int iCompResult;
|
|
|
|
int val1, val2;
|
|
|
|
const FAKKServerListItem* fi1 = static_cast<const FAKKServerListItem*>(i1);
|
|
|
|
const FAKKServerListItem* fi2 = static_cast<const FAKKServerListItem*>(i2);
|
|
|
|
|
|
|
|
if (fi1->IsFavorite() != fi2->IsFavorite())
|
|
|
|
{
|
|
|
|
if (fi1->IsFavorite()) {
|
|
|
|
iCompResult = -1;
|
|
|
|
} else {
|
|
|
|
iCompResult = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_bReverseSort) {
|
|
|
|
iCompResult = -iCompResult;
|
|
|
|
}
|
|
|
|
} else if (fi1->IsQueried() != fi2->IsQueried()) {
|
|
|
|
if (fi1->IsQueried()) {
|
|
|
|
iCompResult = -1;
|
|
|
|
} else {
|
|
|
|
iCompResult = 1;
|
|
|
|
}
|
|
|
|
} else if (fi1->IsDifferentVersion() != fi2->IsDifferentVersion()) {
|
|
|
|
|
|
|
|
if (fi1->IsDifferentVersion()) {
|
|
|
|
iCompResult = 1;
|
|
|
|
} else {
|
|
|
|
iCompResult = -1;
|
|
|
|
}
|
|
|
|
} else if (fi1->IfQueryFailed() != fi2->IfQueryFailed()) {
|
|
|
|
if (fi1->IfQueryFailed()) {
|
|
|
|
iCompResult = 1;
|
|
|
|
} else {
|
|
|
|
iCompResult = -1;
|
|
|
|
}
|
|
|
|
} else if (g_bNumericSort) {
|
|
|
|
val1 = fi1->getListItemValue(columnname);
|
|
|
|
val2 = fi2->getListItemValue(columnname);
|
|
|
|
|
|
|
|
if (val1 < val2) {
|
|
|
|
iCompResult = -1;
|
|
|
|
} else if (val1 > val2) {
|
|
|
|
iCompResult = 1;
|
|
|
|
} else {
|
|
|
|
iCompResult = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
iCompResult = str::icmp(fi1->getListItemString(columnname), fi2->getListItemString(columnname));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!iCompResult)
|
|
|
|
{
|
|
|
|
if (columnname != -2) {
|
|
|
|
val1 = fi1->getListItemValue(2);
|
|
|
|
val2 = fi2->getListItemValue(2);
|
|
|
|
|
|
|
|
if (val1 < val2) {
|
|
|
|
iCompResult = -1;
|
|
|
|
} else if (val1 > val2) {
|
|
|
|
iCompResult = 1;
|
|
|
|
} else {
|
|
|
|
iCompResult = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!iCompResult) {
|
|
|
|
if (columnname != 4) {
|
|
|
|
iCompResult = str::icmp(fi1->getListItemString(4), fi2->getListItemString(4));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!iCompResult) {
|
|
|
|
if (columnname != 5) {
|
|
|
|
iCompResult = str::icmp(fi1->getListItemString(5), fi2->getListItemString(5));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!iCompResult) {
|
|
|
|
if (columnname != 3) {
|
|
|
|
val1 = fi1->getListItemValue(3);
|
|
|
|
val2 = fi2->getListItemValue(3);
|
|
|
|
|
|
|
|
if (val1 < val2) {
|
|
|
|
iCompResult = 1;
|
|
|
|
} else if (val1 > val2) {
|
|
|
|
iCompResult = -1;
|
|
|
|
} else {
|
|
|
|
iCompResult = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!iCompResult) {
|
|
|
|
if (columnname != 0) {
|
|
|
|
iCompResult = str::icmp(fi1->getListItemString(0), fi2->getListItemString(0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!iCompResult) {
|
|
|
|
if (columnname != -1) {
|
|
|
|
iCompResult = str::icmp(fi1->getListItemString(1), fi2->getListItemString(1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return g_bReverseSort ? -iCompResult : iCompResult;
|
2016-03-27 11:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIFAKKServerList::Draw( void )
|
|
|
|
{
|
2023-07-27 23:02:39 +02:00
|
|
|
// FIXME: unimplemented
|
2016-03-27 11:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIFAKKServerList::SortByColumn( int column )
|
|
|
|
{
|
2023-07-28 21:51:37 +02:00
|
|
|
int i;
|
|
|
|
bool exists = 0;
|
|
|
|
bool numeric = 0;
|
|
|
|
bool reverse = 0;
|
|
|
|
UIListCtrlItem* selected = NULL;
|
|
|
|
bool selvisible = false;
|
|
|
|
|
|
|
|
for (i = 1; i <= m_columnlist.NumObjects(); i++) {
|
|
|
|
const columndef_t& def = m_columnlist.ObjectAt(i);
|
|
|
|
if (def.name == column) {
|
|
|
|
// found one
|
|
|
|
numeric = def.numeric;
|
|
|
|
reverse = def.reverse_sort;
|
|
|
|
exists = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!exists) {
|
|
|
|
m_iLastSortColumn = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_iLastSortColumn = column;
|
|
|
|
s_qsortcolumn = column;
|
|
|
|
s_qsortobject = this;
|
|
|
|
s_qsortreverse = reverse;
|
|
|
|
g_bNumericSort = numeric;
|
|
|
|
g_bReverseSort = reverse;
|
|
|
|
|
|
|
|
if (getCurrentItem()) {
|
|
|
|
selected = m_itemlist.ObjectAt(getCurrentItem());
|
|
|
|
if (GetScrollBar()) {
|
|
|
|
selvisible = getCurrentItem() >= GetScrollBar()->getTopItem() + 1
|
|
|
|
&& getCurrentItem() <= GetScrollBar()->getPageHeight() + GetScrollBar()->getTopItem();
|
|
|
|
} else {
|
|
|
|
selvisible = getCurrentItem() > 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setCompareFunction(&UIFAKKServerList::ServerCompareFunction);
|
|
|
|
if (m_itemlist.NumObjects()) {
|
|
|
|
m_itemlist.Sort(&UIListCtrl::QsortCompare);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selected) {
|
|
|
|
if (selvisible) {
|
|
|
|
TrySelectItem(FindItem(selected));
|
|
|
|
} else {
|
|
|
|
m_currentItem = FindItem(selected);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateServerListCallBack(GServerList serverlist, int msg, void* instance, void* param1, void* param2)
|
|
|
|
{
|
|
|
|
// FIXME: unimplemented
|
|
|
|
}
|