engineplugin.h
1 //------------------------------------------------------------------------------
2 // engineplugin.h
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301, USA.
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2011 "Blzut3" <admin@maniacsvault.net>
22 //------------------------------------------------------------------------------
23 
24 #ifndef __ENGINEPLUGIN_H__
25 #define __ENGINEPLUGIN_H__
26 
27 #include <QtContainerFwd>
28 #include <QString>
29 #include <QVector>
30 #include "global.h"
32 #include "serverapi/serverptr.h"
33 
34 // Bump whenever the ABI changes in order to reject old plugins
35 #define DOOMSEEKER_ABI_VERSION 2
36 
37 #define DECLARE_PLUGIN(XEnginePlugin) \
38  public: \
39  static EnginePlugin *staticInstance() { return &__Static_Instance; } \
40  protected: \
41  static XEnginePlugin __Static_Instance;
42 
43 #define INSTALL_PLUGIN(XEnginePlugin) \
44  XEnginePlugin XEnginePlugin::__Static_Instance; \
45  extern "C" PLUGIN_EXPORT unsigned int doomSeekerABI() { return DOOMSEEKER_ABI_VERSION; } \
46  extern "C" PLUGIN_EXPORT EnginePlugin *doomSeekerInit() \
47  { \
48  return XEnginePlugin::staticInstance(); \
49  }
50 
52 class CreateServerDialog;
54 class GameCVar;
55 class GameExeFactory;
56 class GameHost;
57 class GameMode;
58 class IniSection;
59 class IRCNetworkEntity;
60 class MasterClient;
61 class Server;
62 class QHostAddress;
63 class QPixmap;
64 class QWidget;
65 
69 class MAIN_EXPORT EnginePlugin
70 {
71  protected:
78  {
80 
83 
99 
109  EP_ClientOnly
110  };
111 
113  virtual void setupConfig(IniSection &config) const {}
114 
115  public:
120  class Data
121  {
122  public:
123  unsigned int abiVersion;
125  QList<DMFlagsSection> allDMFlags;
126  bool allowsConnectPassword;
127  bool allowsEmail;
128  bool allowsJoinPassword;
129  bool allowsMOTD;
130  bool allowsRConPassword;
131  bool allowsURL;
132  QString author;
134  QString defaultMaster;
135  quint16 defaultServerPort;
137  QList<GameMode> gameModes;
145  QList<GameCVar> gameModifiers;
146  bool hasMasterServer;
148  QPixmap *icon;
149  bool inGameFileDownloads;
150  QVector<IRCNetworkEntity> ircChannels;
151  QString name;
152  IniSection *pConfig;
153  quint8 refreshThreshold;
154  QString scheme;
155  bool supportsRandomMapRotation;
156  bool valid;
157  unsigned int version;
158  bool demoExtensionAutomatic;
159  QString demoExtension;
171  bool clientOnly;
182 
183  Data();
184  };
185 
186  EnginePlugin();
187  virtual ~EnginePlugin();
188 
198  void init(const char* name, const char* const icon[], ...);
199 
203  virtual ConfigurationBaseBox* configuration(QWidget *parent) const;
204 
222  virtual QList<CreateServerDialogPage*> createServerDialogPages(
223  CreateServerDialog* pDialog)
224  {
225  return QList<CreateServerDialogPage*>();
226  }
227 
228  const Data *data() const { return d; }
229  const QPixmap &icon() const { return *d->icon; }
230  void setConfig(IniSection &cfg) const;
231 
232  GameExeFactory *gameExe()
233  {
234  return data()->gameExeFactory;
235  }
236 
244  virtual GameHost* gameHost();
245 
250  virtual QList<GameCVar> limits(const GameMode& mode) const { return QList<GameCVar>(); }
251 
255  virtual MasterClient* masterClient() const { return NULL; }
259  void masterHost(QString &host, unsigned short &port) const;
260 
271  QString nameCanonical() const;
272 
280  virtual ServerPtr server(const QHostAddress &address, unsigned short port) const;
281 
282  protected:
287  virtual ServerPtr mkServer(const QHostAddress &address, unsigned short port) const = 0;
288 
289  void setDMFlags(const QList<DMFlagsSection> &dmFlags);
290  void setGameModes(const QList<GameMode> &gameModes);
291  void setGameModifiers(const QList<GameCVar> &gameModifiers);
292 
293  private:
294  Data *d;
295 };
296 
297 #endif
GameExeFactory * gameExeFactory
Factory of executable retrievers objects.
Definition: engineplugin.h:181
bool createDMFlagsPagesAutomatic
Controls behavior of "Create Game" dialog.
Definition: engineplugin.h:170
QPixmap * icon
icon of the engine
Definition: engineplugin.h:148
(const char*) Author of the plugin.
Definition: engineplugin.h:81
Allows the player to join a server without downloading files through Wadseeker.
Definition: engineplugin.h:93
Signifies that servers can be created with a join password.
Definition: engineplugin.h:87
Signifies that a server can be created with a random map rotation.
Definition: engineplugin.h:95
QList< GameMode > gameModes
All available game modes for the engine or NULL if none.
Definition: engineplugin.h:137
Returns executable file retrievers from plugins to Doomseeker.
QList< GameCVar > gameModifiers
Returns a list of modifiers.
Definition: engineplugin.h:145
A representation of a server for a given game.
Definition: server.h:93
(const char*) Default ip address and port ("address:port") for master server. Requires EP_HasMasterSe...
Definition: engineplugin.h:90
(bool)auto, (const char*)extension Sets the extension taht will be used for demos (default is true an...
Definition: engineplugin.h:98
virtual QList< CreateServerDialogPage * > createServerDialogPages(CreateServerDialog *pDialog)
Creates a list of custom Create Game dialog pages.
Definition: engineplugin.h:222
virtual MasterClient * masterClient() const
Definition: engineplugin.h:255
Signifies that servers can be created for remote console access.
Definition: engineplugin.h:88
Dialog window allowing user to host a game.
Signifies that servers can have a message of the day.
Definition: engineplugin.h:89
Game mode representation.
Signifies that servers can provide a URL for potential wad downloads.
Definition: engineplugin.h:86
virtual void setupConfig(IniSection &config) const
Reimplement if you want to perform some ini initialization manually.
Definition: engineplugin.h:113
Signals the end of init parameters.
Definition: engineplugin.h:79
(quint8) The amount of time (in seconds) that must pass before a server can be requeried.
Definition: engineplugin.h:96
Base class to be used by plugins to define custom pages in Create Server dialog.
Signifies that servers can be created with a connection password.
Definition: engineplugin.h:84
Signifies that servers can have an administrative contact email attached.
Definition: engineplugin.h:85
Data structure that describes and defines a connection to an IRC network or server.
INI section representation.
Definition: inisection.h:40
Creates game servers, offline games or demo playbacks.
Definition: gamehost.h:69
virtual QList< GameCVar > limits(const GameMode &mode) const
Returns a list of limits (like fraglimit) supported by passed gamemode.
Definition: engineplugin.h:250
(unsigned int) Single version number for plugin.
Definition: engineplugin.h:82
Signifies that the plugin implements a master server protocol.
Definition: engineplugin.h:92
(quint16) Default port for custom server creation.
Definition: engineplugin.h:91
Abstract base for all MasterClients.
Definition: masterclient.h:49
Base class for configuration pages.
(const char*)server, (const char*)channel - Can be repeated. Default IRC channels.
Definition: engineplugin.h:94
(const char*) Overrides the URL scheme which Doomseeker sets for this plugin. By default it is the po...
Definition: engineplugin.h:97
A general game setting or variable (like fraglimit).
QString defaultMaster
Default port on which servers for given engine are hosted.
Definition: engineplugin.h:134
QList< DMFlagsSection > allDMFlags
List of all engine's DM flags or NULL if none.
Definition: engineplugin.h:125