summaryrefslogtreecommitdiff
path: root/tracker/AdminServer/serverpage.h
blob: d12f5998beea12c8528895282ad050f49aa1a73f (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// Purpose: 
//
// $Workfile:     $
// $Date:         $
//
//-----------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================
#if !defined( VINTERNETDLG_H )
#define VINTERNETDLG_H
#ifdef _WIN32
#pragma once
#endif

#include <VGUI_Frame.h>
#include <VGUI_ListPanel.h>
#include <VGUI_PHandle.h>

#include "utlvector.h"
#include "netadr.h"
#include "Server.h"
//#include "serversession.h"
//#include "trackerdoc.h"

//#include "ITrackerUser.h"
#include "../TrackerNET/TrackerNET_Interface.h"
#include "../TrackerNET/NetAddress.h" // for CNetAddress
#include "../TrackerNET/BinaryBuffer.h" // for IBinaryBuffer

#include "IGameList.h"

//#include "ClickableTabbedPanel.h"

class CServerContextMenu;
namespace vgui
{
class Label;
class Font;
class ListPanel;
class Button;
class ComboBox;
class QueryBox;
class ToggleButton;
class TextEntry;
class CheckButton;
class PropertySheet;
}

extern class IRunGameEngine *g_pRunGameEngine;
extern void v_strncpy(char *dest, const char *src, int bufsize);

class CFavoriteGames;
class CGamePanelInfo;
class CDialogGameInfo;

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class VInternetDlg : public vgui::Frame
{

public:
	// Construction/destruction
						VInternetDlg( unsigned int userid );
	virtual				~VInternetDlg( void );

	virtual void		Initialize( void );

	// displays the dialog, moves it into focus, updates if it has to
	virtual void		Open( void );

	// gets server info
	serveritem_t &VInternetDlg::GetServer(unsigned int serverID);

	// setup
	virtual void		PerformLayout();

	// updates status text at bottom of window
	virtual void		UpdateStatusText(PRINTF_FORMAT_STRING const char *format, ...);

	// context menu access
	virtual CServerContextMenu *GetContextMenu();		

	// returns a pointer to a static instance of this dialog
	// valid for use only in sort functions
	static VInternetDlg *GetInstance();

	// begins the process of joining a server from a game list
	// the game info dialog it opens will also update the game list
	virtual CDialogGameInfo *JoinGame(IGameList *gameList, unsigned int serverIndex);

	// joins a game by a specified IP, not attached to any game list
	virtual CDialogGameInfo *JoinGame(int serverIP, int serverPort, const char *titleName);

	// opens a game info dialog from a game list
	virtual CDialogGameInfo *OpenGameInfoDialog(IGameList *gameList, unsigned int serverIndex);

	// opens a game info dialog by a specified IP, not attached to any game list
	virtual CDialogGameInfo *OpenGameInfoDialog(int serverIP, int serverPort, const char *titleName);

	virtual vgui::PropertySheet *GetTabPanel(); 

	// called by the config panel to setup some global config values
	virtual void SetConfig(bool autorefresh,bool savercon,int refreshtime,bool graphs,int graphrefreshtime,bool getlogs);

	// passes the server info to the favorites panel to update the rconPassword
	virtual void UpdateServer(serveritem_t &server);

	// opens up the config dialog with the current config settings
	virtual void ConfigPanel();

	virtual void OnTick();

	void SearchForFriend(unsigned int uid, const char *email, const char *username, const char *firstname, const char *lastname);
	ISendMessage *VInternetDlg::CreateServerMessage(int msgID);
	CNetAddress GetServerAddress();
	void SendInitialLogin();
	bool CheckMessageValidity(IReceiveMessage *dataBlock);



private:

	// menu handler for tabs
	void OnOpenContextMenu();
	// current game list change
	//virtual void		OnGameListChanged();
	

	// password entry dialog for new servers
	void OnPlayerDialog(vgui::KeyValues *data);
	void OnDeleteServer(int chosenPanel);

	// load/saves filter settings from disk
	virtual void		LoadFilters();
	virtual void		SaveFilters();

	// Load/saves position and window size of a dialog from disk
	virtual void		LoadDialogState(vgui::Panel *dialog, const char *dialogName);
	virtual void		SaveDialogState(vgui::Panel *dialog, const char *dialogName);

	// called when dialog is shut down
	virtual void		OnClose();

	// catches the "manage server" menu option
	void OnManageServer(int serverID);

	// actually creates the new tab
	void ManageServer(int serverID,const char *pass);



	// pointer to current game list
	IGameList *m_pGameList;

	// Status text
	vgui::Label	*m_pStatusLabel;

	// property sheet
	vgui::PropertySheet *m_pTabPanel;
	CFavoriteGames *m_pFavoriteGames;
	CGamePanelInfo *m_pGamePanelInfo;

	vgui::KeyValues *m_pSavedData;

	bool m_bAutoRefresh;
	bool m_bSaveRcon;
	int m_iRefreshTime;
	bool m_bGraphs;
	int m_iGraphsRefreshTime;
	bool m_bDoLogging; // whether to get server log messages

	ITrackerNET *m_pNet;
	unsigned int m_iSessionID; // the session ID from tracker
	unsigned int m_iUserID;
	int m_iRemoteUID;
	bool m_bLoggedIn;
	CNetAddress m_iServerAddr;

	// context menu
	CServerContextMenu *m_pContextMenu;

	typedef vgui::Frame BaseClass;

	DECLARE_PANELMAP();
};

#endif // VINTERNETDLG_H