src/core/plugins/engineplugin.h
00001 //------------------------------------------------------------------------------
00002 // engineplugin.h
00003 //------------------------------------------------------------------------------
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018 // 02110-1301, USA.
00019 //
00020 //------------------------------------------------------------------------------
00021 // Copyright (C) 2011 "Blzut3" <admin@maniacsvault.net>
00022 //------------------------------------------------------------------------------
00023 
00024 #ifndef __ENGINEPLUGIN_H__
00025 #define __ENGINEPLUGIN_H__
00026 
00027 #include <QtContainerFwd>
00028 #include <QString>
00029 #include <QVector>
00030 #include "global.h"
00031 #include "serverapi/serverstructs.h"
00032 
00033 #define DECLARE_PLUGIN(XEnginePlugin) \
00034         public: \
00035                 static EnginePlugin *staticInstance() { return &__Static_Instance; } \
00036         protected: \
00037                 static XEnginePlugin __Static_Instance;
00038 
00039 #define INSTALL_PLUGIN(XEnginePlugin) \
00040         XEnginePlugin XEnginePlugin::__Static_Instance; \
00041         extern "C" PLUGIN_EXPORT EnginePlugin *doomSeekerInit() \
00042         { \
00043                 return XEnginePlugin::staticInstance(); \
00044         }
00045 
00046 class Binaries;
00047 class ConfigurationBaseBox;
00048 class GameCVar;
00049 class GameMode;
00050 class IniSection;
00051 class IRCNetworkEntity;
00052 class MasterClient;
00053 class Server;
00054 class QHostAddress;
00055 class QPixmap;
00056 class QWidget;
00057 
00058 class MAIN_EXPORT EnginePlugin
00059 {
00060         protected:
00066                 enum InitFeatures
00067                 {
00068                         EP_Done, 
00069 
00070                         EP_Author, 
00071                         EP_Version, 
00072 
00073                         EP_AllDMFlags, 
00074                         EP_AllowsConnectPassword, 
00075                         EP_AllowsEmail, 
00076                         EP_AllowsURL, 
00077                         EP_AllowsJoinPassword, 
00078                         EP_AllowsRConPassword, 
00079                         EP_AllowsMOTD, 
00080                         EP_DefaultMaster, 
00081                         EP_DefaultServerPort, 
00082                         EP_GameModes, 
00083                         EP_GameModifiers, 
00084                         EP_HasMasterServer, 
00085                         EP_InGameFileDownloads, 
00086                         EP_IRCChannel, 
00087                         EP_SupportsRandomMapRotation, 
00088                         EP_RefreshThreshold 
00089                 };
00090 
00092                 virtual void                                                    setupConfig(IniSection &config) const {}
00093 
00094         public:
00099                 class Data
00100                 {
00101                         public:
00103                                 const DMFlags*                  allDMFlags;
00104                                 bool                                    allowsConnectPassword;
00105                                 bool                                    allowsEmail;
00106                                 bool                                    allowsJoinPassword;
00107                                 bool                                    allowsMOTD;
00108                                 bool                                    allowsRConPassword;
00109                                 bool                                    allowsURL;
00110                                 QString                                 author;
00112                                 QString                                 defaultMaster;
00113                                 quint16                                 defaultServerPort;
00115                                 const QList<GameMode>*  gameModes;
00123                                 const QList<GameCVar>*  gameModifiers;
00124                                 bool                                    hasMasterServer;
00126                                 QPixmap                                 *icon;
00127                                 bool                                    inGameFileDownloads;
00128                                 QVector<IRCNetworkEntity> ircChannels;
00129                                 QString                                 name;
00130                                 IniSection                              *pConfig;
00131                                 quint8                                  refreshThreshold;
00132                                 bool                                    supportsRandomMapRotation;
00133                                 bool                                    valid;
00134                                 unsigned int                    version;
00135 
00136                                 Data();
00137                 };
00138 
00139                 EnginePlugin();
00140                 virtual ~EnginePlugin();
00141 
00151                 void init(const char* name, const char* const icon[], ...);
00152 
00156                 virtual ConfigurationBaseBox*   configuration(QWidget *parent) const;
00157 
00158                 const Data                                              *data() const { return d; }
00159                 const QPixmap                                   &icon() const { return *d->icon; }
00160                 void                                                    setConfig(IniSection &cfg) const;
00161 
00166                 virtual QList<GameCVar>                 limits(const GameMode& mode) const { return QList<GameCVar>(); }
00167 
00171                 virtual MasterClient*                   masterClient() const { return NULL; }
00175                 void                                                    masterHost(QString &host, unsigned short &port) const;
00176 
00182                 virtual Server*                                 server(const QHostAddress &address, unsigned short port) const = 0;
00183 
00184         private:
00185                 Data    *d;
00186 };
00187 
00188 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator