2010-05-09 23:23:13 +02:00
|
|
|
|
// ==============================================================
|
|
|
|
|
// This file is part of Glest (www.glest.org)
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2001-2005 Marti<74>o Figueroa
|
|
|
|
|
//
|
2010-12-23 01:00:30 +01:00
|
|
|
|
// You can redistribute this code 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
|
2010-05-09 23:23:13 +02:00
|
|
|
|
// License, or (at your option) any later version
|
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
|
|
#ifndef _GLEST_GAME_MENUSTATEMASTERSERVER_H_
|
|
|
|
|
#define _GLEST_GAME_MENUSTATEMASTERSERVER_H_
|
|
|
|
|
|
|
|
|
|
#include "main_menu.h"
|
|
|
|
|
#include "masterserver_info.h"
|
2010-05-13 08:43:56 +02:00
|
|
|
|
#include "simple_threads.h"
|
2010-05-16 05:31:12 +02:00
|
|
|
|
#include "network_interface.h"
|
2010-12-23 01:00:30 +01:00
|
|
|
|
#include "ircclient.h"
|
|
|
|
|
#include "chat_manager.h"
|
2010-09-07 07:25:40 +02:00
|
|
|
|
#include "leak_dumper.h"
|
2010-05-09 23:23:13 +02:00
|
|
|
|
|
|
|
|
|
namespace Glest{ namespace Game{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// ServerLine
|
|
|
|
|
// ===============================
|
|
|
|
|
|
|
|
|
|
class ServerLine {
|
|
|
|
|
private:
|
|
|
|
|
|
2010-10-23 11:06:47 +02:00
|
|
|
|
MasterServerInfo masterServerInfo;
|
2010-05-09 23:23:13 +02:00
|
|
|
|
int index;
|
|
|
|
|
GraphicButton selectButton;
|
2010-10-23 11:06:47 +02:00
|
|
|
|
GraphicLabel gameFull;
|
2010-05-09 23:23:13 +02:00
|
|
|
|
|
|
|
|
|
//general info:
|
|
|
|
|
GraphicLabel glestVersionLabel;
|
|
|
|
|
GraphicLabel platformLabel;
|
2010-12-17 22:36:34 +01:00
|
|
|
|
//GraphicLabel binaryCompileDateLabel;
|
2010-12-23 01:00:30 +01:00
|
|
|
|
|
2010-05-09 23:23:13 +02:00
|
|
|
|
//game info:
|
|
|
|
|
GraphicLabel serverTitleLabel;
|
|
|
|
|
GraphicLabel ipAddressLabel;
|
2010-12-23 01:00:30 +01:00
|
|
|
|
|
2010-05-09 23:23:13 +02:00
|
|
|
|
//game setup info:
|
|
|
|
|
GraphicLabel techLabel;
|
2010-12-23 01:00:30 +01:00
|
|
|
|
GraphicLabel mapLabel;
|
2010-05-09 23:23:13 +02:00
|
|
|
|
GraphicLabel tilesetLabel;
|
|
|
|
|
GraphicLabel activeSlotsLabel;
|
|
|
|
|
|
2010-07-03 12:06:31 +02:00
|
|
|
|
GraphicLabel externalConnectPort;
|
|
|
|
|
|
2010-10-10 08:35:50 +02:00
|
|
|
|
const char * containerName;
|
|
|
|
|
std::vector<std::string> registeredObjNameList;
|
|
|
|
|
|
2010-05-09 23:23:13 +02:00
|
|
|
|
public:
|
2010-09-09 23:07:39 +02:00
|
|
|
|
ServerLine( MasterServerInfo *mServerInfo, int lineIndex, const char *containerName);
|
2010-05-09 23:23:13 +02:00
|
|
|
|
virtual ~ServerLine();
|
2010-10-23 11:06:47 +02:00
|
|
|
|
MasterServerInfo *getMasterServerInfo() {return &masterServerInfo;}
|
2010-05-09 23:23:13 +02:00
|
|
|
|
const int getIndex() const {return index;}
|
|
|
|
|
bool buttonMouseClick(int x, int y);
|
|
|
|
|
bool buttonMouseMove(int x, int y);
|
|
|
|
|
//void setIndex(int value);
|
|
|
|
|
void render();
|
2010-12-23 01:00:30 +01:00
|
|
|
|
|
2010-05-09 23:23:13 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ===============================
|
2010-12-23 01:00:30 +01:00
|
|
|
|
// class MenuStateMasterserver
|
2010-05-09 23:23:13 +02:00
|
|
|
|
// ===============================
|
|
|
|
|
typedef vector<ServerLine*> ServerLines;
|
|
|
|
|
typedef vector<MasterServerInfo*> MasterServerInfos;
|
|
|
|
|
|
2010-12-23 01:00:30 +01:00
|
|
|
|
class MenuStateMasterserver : public MenuState, public SimpleTaskCallbackInterface, public IRCCallbackInterface {
|
2010-09-09 08:42:39 +02:00
|
|
|
|
|
2010-05-09 23:23:13 +02:00
|
|
|
|
private:
|
2010-09-09 08:42:39 +02:00
|
|
|
|
|
2010-05-09 23:23:13 +02:00
|
|
|
|
GraphicButton buttonRefresh;
|
|
|
|
|
GraphicButton buttonReturn;
|
2010-05-15 20:40:58 +02:00
|
|
|
|
GraphicButton buttonCreateGame;
|
|
|
|
|
GraphicLabel labelAutoRefresh;
|
|
|
|
|
GraphicListBox listBoxAutoRefresh;
|
2010-05-09 23:23:13 +02:00
|
|
|
|
GraphicLabel labelTitle;
|
|
|
|
|
ServerLines serverLines;
|
2010-06-25 01:29:30 +02:00
|
|
|
|
GraphicLabel labelChatUrl;
|
2010-12-23 01:00:30 +01:00
|
|
|
|
|
2010-10-06 22:54:08 +02:00
|
|
|
|
GraphicLabel announcementLabel;
|
2010-10-13 21:16:04 +02:00
|
|
|
|
GraphicLabel versionInfoLabel;
|
2010-12-23 01:00:30 +01:00
|
|
|
|
|
2010-10-23 11:06:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GraphicLabel glestVersionLabel;
|
|
|
|
|
GraphicLabel platformLabel;
|
2010-12-18 00:23:45 +01:00
|
|
|
|
//GraphicLabel binaryCompileDateLabel;
|
2010-10-23 11:06:47 +02:00
|
|
|
|
|
|
|
|
|
//game info:
|
|
|
|
|
GraphicLabel serverTitleLabel;
|
|
|
|
|
GraphicLabel ipAddressLabel;
|
|
|
|
|
|
|
|
|
|
//game setup info:
|
|
|
|
|
GraphicLabel techLabel;
|
|
|
|
|
GraphicLabel mapLabel;
|
|
|
|
|
GraphicLabel tilesetLabel;
|
|
|
|
|
GraphicLabel activeSlotsLabel;
|
|
|
|
|
|
|
|
|
|
GraphicLabel externalConnectPort;
|
|
|
|
|
|
|
|
|
|
GraphicLabel selectButton;
|
2010-12-23 01:00:30 +01:00
|
|
|
|
|
2010-05-09 23:23:13 +02:00
|
|
|
|
GraphicMessageBox mainMessageBox;
|
|
|
|
|
int mainMessageBoxState;
|
2010-12-23 01:00:30 +01:00
|
|
|
|
|
|
|
|
|
GraphicLabel ircOnlinePeopleLabel;
|
|
|
|
|
GraphicLabel ircOnlinePeopleListLabel;
|
|
|
|
|
|
2010-10-06 22:54:08 +02:00
|
|
|
|
bool announcementLoaded;
|
2010-05-13 08:43:56 +02:00
|
|
|
|
bool needUpdateFromServer;
|
2010-05-15 20:40:58 +02:00
|
|
|
|
int autoRefreshTime;
|
|
|
|
|
time_t lastRefreshTimer;
|
2010-05-13 08:43:56 +02:00
|
|
|
|
SimpleTaskThread *updateFromMasterserverThread;
|
2010-05-16 18:40:21 +02:00
|
|
|
|
bool playServerFoundSound;
|
2010-12-23 01:00:30 +01:00
|
|
|
|
|
2010-12-23 08:42:15 +01:00
|
|
|
|
//Console console;
|
2010-05-09 23:23:13 +02:00
|
|
|
|
|
2010-05-16 05:31:12 +02:00
|
|
|
|
static DisplayMessageFunction pCB_DisplayMessage;
|
|
|
|
|
std::string threadedErrorMsg;
|
2010-06-11 05:17:38 +02:00
|
|
|
|
Mutex masterServerThreadAccessor;
|
2010-10-30 19:31:57 +02:00
|
|
|
|
Mutex masterServerThreadPtrChangeAccessor;
|
|
|
|
|
bool masterServerThreadInDeletion;
|
2010-05-16 05:31:12 +02:00
|
|
|
|
|
2010-12-23 01:00:30 +01:00
|
|
|
|
std::vector<string> ircArgs;
|
|
|
|
|
IRCThread *ircClient;
|
|
|
|
|
|
|
|
|
|
Console consoleIRC;
|
|
|
|
|
ChatManager chatManager;
|
|
|
|
|
|
2010-05-09 23:23:13 +02:00
|
|
|
|
public:
|
|
|
|
|
MenuStateMasterserver(Program *program, MainMenu *mainMenu);
|
2010-12-23 01:00:30 +01:00
|
|
|
|
~MenuStateMasterserver();
|
|
|
|
|
|
2010-05-09 23:23:13 +02:00
|
|
|
|
void mouseClick(int x, int y, MouseButton mouseButton);
|
|
|
|
|
void mouseMove(int x, int y, const MouseState *mouseState);
|
|
|
|
|
void update();
|
|
|
|
|
void render();
|
2010-12-23 01:00:30 +01:00
|
|
|
|
|
2010-09-04 01:54:11 +02:00
|
|
|
|
virtual void keyDown(char key);
|
2010-12-23 01:00:30 +01:00
|
|
|
|
virtual void keyPress(char c);
|
|
|
|
|
virtual void keyUp(char key);
|
|
|
|
|
|
2010-05-13 08:43:56 +02:00
|
|
|
|
virtual void simpleTask();
|
|
|
|
|
|
2010-05-16 05:31:12 +02:00
|
|
|
|
static void setDisplayMessageFunction(DisplayMessageFunction pDisplayMessage) { pCB_DisplayMessage = pDisplayMessage; }
|
|
|
|
|
|
2010-12-23 01:00:30 +01:00
|
|
|
|
virtual void IRC_CallbackEvent(const char* origin, const char **params, unsigned int count);
|
|
|
|
|
|
2010-05-09 23:23:13 +02:00
|
|
|
|
private:
|
|
|
|
|
void showMessageBox(const string &text, const string &header, bool toggle);
|
2010-07-03 12:06:31 +02:00
|
|
|
|
bool connectToServer(string ipString, int port);
|
2010-05-09 23:23:13 +02:00
|
|
|
|
void clearServerLines();
|
|
|
|
|
void updateServerInfo();
|
2010-12-23 01:00:30 +01:00
|
|
|
|
void cleanup();
|
|
|
|
|
|
2010-05-09 23:23:13 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}}//end namespace
|
|
|
|
|
|
|
|
|
|
#endif
|