summaryrefslogtreecommitdiff
path: root/tracker/AdminServer/DialogGameInfo.h
blob: ef232233d2e177eee4f618aa0f3a0fccd845c371 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================

#ifndef DIALOGGAMEINFO_H
#define DIALOGGAMEINFO_H
#ifdef _WIN32
#pragma once
#endif

#include <VGUI_Frame.h>
#include "ServerList.h"
#include "IServerRefreshResponse.h"

class KeyValues;

namespace vgui
{
class Button;
class ToggleButton;
class RadioButton;
class Label;
class TextEntry;
}

//-----------------------------------------------------------------------------
// Purpose: Dialog for displaying information about a game server
//-----------------------------------------------------------------------------
class CDialogGameInfo : public vgui::Frame, public IServerRefreshResponse
{
public:
	CDialogGameInfo(class IGameList *gameList, unsigned int serverID, int serverIP = 0, int serverPort = 0);
	~CDialogGameInfo();

	void Run(const char *titleName);
	void ChangeGame(int serverIP, int serverPort);

	// forces the dialog to attempt to connect to the server
	void Connect();

	// implementation of IServerRefreshResponse interface
	// called when the server has successfully responded
	virtual void ServerResponded(serveritem_t &server);

	// called when a server response has timed out
	virtual void ServerFailedToRespond(serveritem_t &server);

	// called when the current refresh list is complete
	virtual void RefreshComplete();

protected:
	// message handlers
	void OnConnect();
	void OnRefresh();
	void OnButtonToggled(vgui::Panel *toggleButton);

	// response from the get password dialog
	void OnJoinServerWithPassword(const char *password);

	DECLARE_PANELMAP();

	// vgui overrides
	void OnTick();
	virtual void OnClose();
	virtual void PerformLayout();
	virtual void ApplySchemeSettings(vgui::IScheme *pScheme);

private:
	long m_iRequestRetry;	// time at which to retry the request

	// methods
	void RequestInfo();
	void ConnectToServer();
	void ShowAutoRetryOptions(bool state);

	void SetControlText(const char *textEntryName, const char *text);

	vgui::Button *m_pConnectButton;
	vgui::Button *m_pCloseButton;
	vgui::Button *m_pRefreshButton;
	vgui::Label *m_pInfoLabel;
	vgui::ToggleButton *m_pAutoRetry;
	vgui::RadioButton *m_pAutoRetryAlert;
	vgui::RadioButton *m_pAutoRetryJoin;

	// the ID of the server we're watching
	unsigned int m_iServerID;

	// server refreshing object
	CServerList	m_Servers;

	// true if we should try connect to the server when it refreshes
	bool m_bConnecting;

	// password, if entered
	char m_szPassword[64];

	// state
	bool m_bServerNotResponding;
	bool m_bServerFull;
	bool m_bShowAutoRetryToggle;
	bool m_bShowingExtendedOptions;

	typedef vgui::Frame BaseClass;
};

#endif // DIALOGGAMEINFO_H