2021-12-25 22:36:38 +01:00
|
|
|
#pragma once
|
|
|
|
#ifndef DEDICATED
|
2022-04-26 20:24:51 +02:00
|
|
|
#include "common/sdkdefs.h"
|
|
|
|
#include "windows/resource.h"
|
2021-12-25 22:36:38 +01:00
|
|
|
#include "networksystem/serverlisting.h"
|
|
|
|
#include "networksystem/r5net.h"
|
|
|
|
|
2022-03-04 12:22:17 +01:00
|
|
|
enum class eSection
|
2022-01-15 17:57:18 +00:00
|
|
|
{
|
|
|
|
SERVER_BROWSER,
|
|
|
|
HOST_SERVER,
|
|
|
|
SETTINGS
|
|
|
|
};
|
|
|
|
|
2022-03-04 12:22:17 +01:00
|
|
|
enum class eHostStatus
|
2022-01-15 17:57:18 +00:00
|
|
|
{
|
|
|
|
NOT_HOSTING,
|
|
|
|
HOSTING
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class EServerVisibility
|
|
|
|
{
|
|
|
|
OFFLINE,
|
|
|
|
HIDDEN,
|
|
|
|
PUBLIC
|
|
|
|
};
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
class IBrowser
|
|
|
|
{
|
|
|
|
private:
|
2022-01-12 02:53:07 +01:00
|
|
|
bool m_bInitialized = false;
|
2022-01-28 12:56:51 +01:00
|
|
|
bool m_bDefaultTheme = false;
|
2021-12-25 22:36:38 +01:00
|
|
|
public:
|
2022-01-15 17:57:18 +00:00
|
|
|
////////////////////
|
|
|
|
// Enum Vars //
|
|
|
|
////////////////////
|
|
|
|
|
2022-03-04 12:22:17 +01:00
|
|
|
eSection eCurrentSection = eSection::SERVER_BROWSER;
|
|
|
|
eHostStatus eHostingStatus = eHostStatus::NOT_HOSTING;
|
2022-01-15 17:57:18 +00:00
|
|
|
EServerVisibility eServerVisibility = EServerVisibility::OFFLINE;
|
|
|
|
public:
|
|
|
|
////////////////////
|
|
|
|
// Funcs //
|
|
|
|
////////////////////
|
2022-03-04 12:22:17 +01:00
|
|
|
IBrowser(void);
|
|
|
|
~IBrowser(void);
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2022-03-04 12:22:17 +01:00
|
|
|
void Draw(const char* pszTitle, bool* bDraw);
|
|
|
|
void CompMenu(void);
|
2022-01-12 02:53:07 +01:00
|
|
|
|
2022-03-04 12:22:17 +01:00
|
|
|
void ServerBrowserSection(void);
|
|
|
|
void RefreshServerList(void);
|
|
|
|
void GetServerList(void);
|
2022-01-15 15:25:19 +01:00
|
|
|
|
2022-03-04 12:22:17 +01:00
|
|
|
void ConnectToServer(const std::string& svIp, const std::string& svPort, const std::string& svNetKey);
|
|
|
|
void ConnectToServer(const std::string& svServer, const std::string& svNetKey);
|
2022-01-12 02:53:07 +01:00
|
|
|
|
2022-03-04 12:22:17 +01:00
|
|
|
void HiddenServersModal(void);
|
|
|
|
void HostServerSection(void);
|
2022-01-12 02:53:07 +01:00
|
|
|
|
2022-03-04 12:22:17 +01:00
|
|
|
void UpdateHostingStatus(void);
|
|
|
|
void SendHostingPostRequest(void);
|
2022-01-12 02:53:07 +01:00
|
|
|
|
2022-03-04 12:22:17 +01:00
|
|
|
void ProcessCommand(const char* pszCommand);
|
|
|
|
void LaunchServer(void);
|
2022-01-12 02:53:07 +01:00
|
|
|
|
2022-03-04 12:22:17 +01:00
|
|
|
void SettingsSection(void);
|
|
|
|
void RegenerateEncryptionKey(void) const;
|
|
|
|
void ChangeEncryptionKeyTo(const std::string& svNetKey) const;
|
2022-01-12 02:53:07 +01:00
|
|
|
|
2022-03-04 12:22:17 +01:00
|
|
|
void SetStyleVar(void);
|
2022-01-12 02:53:07 +01:00
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
////////////////////
|
|
|
|
// Server Browser //
|
|
|
|
////////////////////
|
|
|
|
public:
|
2022-01-12 02:53:07 +01:00
|
|
|
bool m_bActivate = false;
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
std::vector<ServerListing> m_vServerList;
|
|
|
|
ImGuiTextFilter m_imServerBrowserFilter;
|
|
|
|
char m_chServerConnStringBuffer[256] = { 0 };
|
|
|
|
char m_chServerEncKeyBuffer[30] = { 0 };
|
|
|
|
std::string m_szServerListMessage = std::string();
|
|
|
|
|
|
|
|
////////////////////
|
|
|
|
// Settings //
|
|
|
|
////////////////////
|
|
|
|
std::string m_szMatchmakingHostName;
|
|
|
|
|
|
|
|
////////////////////
|
|
|
|
// Host Server //
|
|
|
|
////////////////////
|
|
|
|
ServerListing m_Server;
|
|
|
|
std::vector<std::string> m_vszMapsList;
|
2022-01-15 17:57:18 +00:00
|
|
|
std::vector<std::string> m_vszMapFileNameList;
|
2021-12-25 22:36:38 +01:00
|
|
|
std::string m_szHostRequestMessage = "";
|
|
|
|
std::string m_szHostToken = "";
|
|
|
|
ImVec4 m_iv4HostRequestMessageColor = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
|
|
|
|
|
|
|
////////////////////
|
|
|
|
// Private Server //
|
|
|
|
////////////////////
|
|
|
|
std::string m_szHiddenServerToken = "";
|
|
|
|
std::string m_szHiddenServerRequestMessage = "";
|
|
|
|
ImVec4 m_ivHiddenServerMessageColor = ImVec4(0.00f, 1.00f, 0.00f, 1.00f);
|
|
|
|
|
|
|
|
/* Texture */
|
|
|
|
ID3D11ShaderResourceView* m_idLockedIcon = nullptr;
|
2022-04-26 20:24:51 +02:00
|
|
|
MODULERESOURCE m_rLockedIconBlob;
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2022-03-04 12:22:17 +01:00
|
|
|
void SetSection(eSection section)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
|
|
|
eCurrentSection = section;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-01-12 02:53:07 +01:00
|
|
|
extern IBrowser* g_pIBrowser;
|
2022-01-15 15:25:19 +01:00
|
|
|
#endif
|