MegaGlest/source/glest_game/menu/menu_state_masterserver.h

171 lines
4.2 KiB
C
Raw Normal View History

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
//
// 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"
#include "simple_threads.h"
#include "network_interface.h"
#include "ircclient.h"
#include "chat_manager.h"
#include "leak_dumper.h"
2010-05-09 23:23:13 +02:00
namespace Glest{ namespace Game{
// ===============================
// ServerLine
// ===============================
class ServerLine {
private:
MasterServerInfo masterServerInfo;
2010-05-09 23:23:13 +02:00
int index;
GraphicButton selectButton;
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-05-09 23:23:13 +02:00
//game info:
GraphicLabel serverTitleLabel;
GraphicLabel ipAddressLabel;
2010-05-09 23:23:13 +02:00
//game setup info:
GraphicLabel techLabel;
GraphicLabel mapLabel;
2010-05-09 23:23:13 +02:00
GraphicLabel tilesetLabel;
GraphicLabel activeSlotsLabel;
GraphicLabel externalConnectPort;
const char * containerName;
std::vector<std::string> registeredObjNameList;
2010-05-09 23:23:13 +02:00
public:
ServerLine( MasterServerInfo *mServerInfo, int lineIndex, const char *containerName);
2010-05-09 23:23:13 +02:00
virtual ~ServerLine();
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-05-09 23:23:13 +02:00
};
// ===============================
// class MenuStateMasterserver
2010-05-09 23:23:13 +02:00
// ===============================
typedef vector<ServerLine*> ServerLines;
typedef vector<MasterServerInfo*> MasterServerInfos;
class MenuStateMasterserver : public MenuState, public SimpleTaskCallbackInterface, public IRCCallbackInterface {
2010-05-09 23:23:13 +02:00
private:
2010-05-09 23:23:13 +02:00
GraphicButton buttonRefresh;
GraphicButton buttonReturn;
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-10-06 22:54:08 +02:00
GraphicLabel announcementLabel;
GraphicLabel versionInfoLabel;
GraphicLabel glestVersionLabel;
GraphicLabel platformLabel;
2010-12-18 00:23:45 +01:00
//GraphicLabel binaryCompileDateLabel;
//game info:
GraphicLabel serverTitleLabel;
GraphicLabel ipAddressLabel;
//game setup info:
GraphicLabel techLabel;
GraphicLabel mapLabel;
GraphicLabel tilesetLabel;
GraphicLabel activeSlotsLabel;
GraphicLabel externalConnectPort;
GraphicLabel selectButton;
2010-05-09 23:23:13 +02:00
GraphicMessageBox mainMessageBox;
int mainMessageBoxState;
GraphicLabel ircOnlinePeopleLabel;
GraphicLabel ircOnlinePeopleListLabel;
2010-10-06 22:54:08 +02:00
bool announcementLoaded;
bool needUpdateFromServer;
int autoRefreshTime;
time_t lastRefreshTimer;
SimpleTaskThread *updateFromMasterserverThread;
bool playServerFoundSound;
//Console console;
2010-05-09 23:23:13 +02:00
static DisplayMessageFunction pCB_DisplayMessage;
std::string threadedErrorMsg;
2010-06-11 05:17:38 +02:00
Mutex masterServerThreadAccessor;
Mutex masterServerThreadPtrChangeAccessor;
bool masterServerThreadInDeletion;
std::vector<string> ircArgs;
IRCThread *ircClient;
Console consoleIRC;
ChatManager chatManager;
2010-05-09 23:23:13 +02:00
public:
MenuStateMasterserver(Program *program, MainMenu *mainMenu);
~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();
virtual void keyDown(char key);
virtual void keyPress(char c);
virtual void keyUp(char key);
virtual void simpleTask();
static void setDisplayMessageFunction(DisplayMessageFunction pDisplayMessage) { pCB_DisplayMessage = pDisplayMessage; }
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);
bool connectToServer(string ipString, int port);
2010-05-09 23:23:13 +02:00
void clearServerLines();
void updateServerInfo();
void cleanup();
2010-05-09 23:23:13 +02:00
};
}}//end namespace
#endif