MegaGlest/source/glest_game/menu/menu_state_masterserver.h
Mark Vejvoda 97ee61165a updates to irc use in mastermenu:
- shows local username
- bugfixes for detecting new/dropped users in the irc channel
- lots of cleanup to remove use of so many static variables
2010-12-24 02:10:31 +00:00

171 lines
4.2 KiB
C++
Raw Blame History

// ==============================================================
// 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
// 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"
namespace Glest{ namespace Game{
// ===============================
// ServerLine
// ===============================
class ServerLine {
private:
MasterServerInfo masterServerInfo;
int index;
GraphicButton selectButton;
GraphicLabel gameFull;
//general info:
GraphicLabel glestVersionLabel;
GraphicLabel platformLabel;
//GraphicLabel binaryCompileDateLabel;
//game info:
GraphicLabel serverTitleLabel;
GraphicLabel ipAddressLabel;
//game setup info:
GraphicLabel techLabel;
GraphicLabel mapLabel;
GraphicLabel tilesetLabel;
GraphicLabel activeSlotsLabel;
GraphicLabel externalConnectPort;
const char * containerName;
std::vector<std::string> registeredObjNameList;
public:
ServerLine( MasterServerInfo *mServerInfo, int lineIndex, const char *containerName);
virtual ~ServerLine();
MasterServerInfo *getMasterServerInfo() {return &masterServerInfo;}
const int getIndex() const {return index;}
bool buttonMouseClick(int x, int y);
bool buttonMouseMove(int x, int y);
//void setIndex(int value);
void render();
};
// ===============================
// class MenuStateMasterserver
// ===============================
typedef vector<ServerLine*> ServerLines;
typedef vector<MasterServerInfo*> MasterServerInfos;
class MenuStateMasterserver : public MenuState, public SimpleTaskCallbackInterface, public IRCCallbackInterface {
private:
GraphicButton buttonRefresh;
GraphicButton buttonReturn;
GraphicButton buttonCreateGame;
GraphicLabel labelAutoRefresh;
GraphicListBox listBoxAutoRefresh;
GraphicLabel labelTitle;
ServerLines serverLines;
GraphicLabel labelChatUrl;
GraphicLabel announcementLabel;
GraphicLabel versionInfoLabel;
GraphicLabel glestVersionLabel;
GraphicLabel platformLabel;
//GraphicLabel binaryCompileDateLabel;
//game info:
GraphicLabel serverTitleLabel;
GraphicLabel ipAddressLabel;
//game setup info:
GraphicLabel techLabel;
GraphicLabel mapLabel;
GraphicLabel tilesetLabel;
GraphicLabel activeSlotsLabel;
GraphicLabel externalConnectPort;
GraphicLabel selectButton;
GraphicMessageBox mainMessageBox;
int mainMessageBoxState;
GraphicLabel ircOnlinePeopleLabel;
GraphicLabel ircOnlinePeopleListLabel;
bool announcementLoaded;
bool needUpdateFromServer;
int autoRefreshTime;
time_t lastRefreshTimer;
SimpleTaskThread *updateFromMasterserverThread;
bool playServerFoundSound;
//Console console;
static DisplayMessageFunction pCB_DisplayMessage;
std::string threadedErrorMsg;
Mutex masterServerThreadAccessor;
Mutex masterServerThreadPtrChangeAccessor;
bool masterServerThreadInDeletion;
std::vector<string> ircArgs;
IRCThread *ircClient;
Console consoleIRC;
ChatManager chatManager;
public:
MenuStateMasterserver(Program *program, MainMenu *mainMenu);
~MenuStateMasterserver();
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);
private:
void showMessageBox(const string &text, const string &header, bool toggle);
bool connectToServer(string ipString, int port);
void clearServerLines();
void updateServerInfo();
void cleanup();
};
}}//end namespace
#endif