engineplugin.h
1 //------------------------------------------------------------------------------
2 // engineplugin.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library 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 GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; 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 Braden "Blzut3" Obrzut <admin@maniacsvault.net>
22 //------------------------------------------------------------------------------
23 
24 #ifndef __ENGINEPLUGIN_H__
25 #define __ENGINEPLUGIN_H__
26 
27 #include <QtContainerFwd>
28 #include <QString>
29 #include <QStringList>
30 #include <QVector>
31 #include "global.h"
33 #include "serverapi/serverptr.h"
34 #include "serverapi/textprovider.h"
35 
36 // Bump whenever the ABI changes in order to reject old plugins
37 #define DOOMSEEKER_ABI_VERSION 2
38 
39 #define DECLARE_PLUGIN(XEnginePlugin) \
40  friend PLUGIN_EXPORT EnginePlugin *doomSeekerInit(); \
41  public: \
42  static EnginePlugin *staticInstance() { return __Static_Instance; } \
43  private: \
44  static XEnginePlugin *__Static_Instance;
45 
46 #define INSTALL_PLUGIN(XEnginePlugin) \
47  XEnginePlugin *XEnginePlugin::__Static_Instance; \
48  extern "C" PLUGIN_EXPORT unsigned int doomSeekerABI() { return DOOMSEEKER_ABI_VERSION; } \
49  extern "C" PLUGIN_EXPORT EnginePlugin *doomSeekerInit() \
50  { \
51  XEnginePlugin::__Static_Instance = new XEnginePlugin(); \
52  return XEnginePlugin::staticInstance(); \
53  }
54 
55 class Broadcast;
56 class ConfigPage;
57 class CreateServerDialog;
59 class GameCVarProvider;
60 class GameCVar;
61 class GameExeFactory;
62 class GameHost;
63 class GameMode;
64 class IniSection;
65 class IRCNetworkEntity;
66 class MasterClient;
67 class Server;
68 class QHostAddress;
69 class QPixmap;
70 class QWidget;
71 class TextProvider;
72 
76 class MAIN_EXPORT EnginePlugin
77 {
78  protected:
85  {
87 
90 
105 
116 
249  EP_CanonicalName
250  };
251 
253  virtual void setupConfig(IniSection &config);
254 
255  public:
260  class Data
261  {
262  public:
263  unsigned int abiVersion;
264  bool allowsConnectPassword;
265  bool allowsEmail;
266  bool allowsJoinPassword;
267  bool allowsMOTD;
268  bool allowsRConPassword;
269  bool allowsURL;
270  QString author;
272  QString defaultMaster;
273  quint16 defaultServerPort;
275  QPixmap *icon;
276  bool inGameFileDownloads;
277  QVector<IRCNetworkEntity> ircChannels;
278  MasterClient *masterClient;
279  QString name;
280  IniSection *pConfig;
281  quint8 refreshThreshold;
282  QString scheme;
283  bool supportsRandomMapRotation;
284  bool valid;
285  unsigned int version;
286  bool demoExtensionAutomatic;
287  QString demoExtension;
292  QScopedPointer<TextProvider> aboutProvider;
304  bool clientOnly;
315  QSharedPointer<GameExeFactory> gameExeFactory;
316  Broadcast *broadcast;
317 
318  QString clientExeName;
319  QString serverExeName;
320  QStringList gameFileSearchSuffixes;
321 
327  QSharedPointer<GameCVarProvider> difficulty;
328  bool hasMapList;
329  bool hasIwad;
330  bool allowsClientSlots;
331  bool allowsPlayerSlots;
332  bool allowsUpnp;
333  bool allowsUpnpPort;
334  QString canonicalName;
335 
336  Data();
337 
338  bool hasBroadcast() const
339  {
340  return broadcast != NULL;
341  }
342 
343  bool hasMasterClient() const
344  {
345  return masterClient != NULL;
346  }
347  };
348 
349  EnginePlugin();
350  virtual ~EnginePlugin();
351 
361  void init(const char* name, const char* const icon[], ...);
362 
366  virtual ConfigPage* configuration(QWidget *parent);
367 
385  virtual QList<CreateServerDialogPage*> createServerDialogPages(
386  CreateServerDialog* pDialog)
387  {
388  return QList<CreateServerDialogPage*>();
389  }
390 
391  const Data *data() const { return d; }
392  const QPixmap &icon() const { return *d->icon; }
393  void setConfig(IniSection &cfg);
394 
398  virtual QList<DMFlagsSection> dmFlags() const;
399 
400  GameExeFactory *gameExe();
401 
409  virtual GameHost* gameHost();
410 
418  virtual QList<GameMode> gameModes() const;
422  virtual QList<GameCVar> gameModifiers() const;
423 
428  virtual QList<GameCVar> limits(const GameMode& mode) const { return QList<GameCVar>(); }
429 
433  void masterHost(QString &host, unsigned short &port) const;
434 
448  QString nameCanonical() const;
449 
457  virtual ServerPtr server(const QHostAddress &address, unsigned short port) const;
458 
475  virtual void start();
476 
477  protected:
482  virtual ServerPtr mkServer(const QHostAddress &address, unsigned short port) const = 0;
483  void initDefaultGameFiles();
484  void setGameExeFactory(QSharedPointer<GameExeFactory> factory);
485 
486  private:
487  Data *d;
488 
489  QStringList collectKnownPaths(const IniSection &ini) const;
490  void findGameFiles(IniSection &ini);
491 };
492 
493 extern "C" PLUGIN_EXPORT EnginePlugin *doomSeekerInit();
494 
495 #endif
Disables specifying amount of player slots in create game box.
Definition: engineplugin.h:197
bool createDMFlagsPagesAutomatic
Controls behavior of "Create Game" dialog.
Definition: engineplugin.h:303
Creates GameCVar set.
Informs that the game has no notion of an IWAD.
Definition: engineplugin.h:179
QPixmap * icon
icon of the engine
Definition: engineplugin.h:275
(const char*) Author of the plugin.
Definition: engineplugin.h:88
QScopedPointer< TextProvider > aboutProvider
Description of the plugin, intended to be displayed in the "About" dialog.
Definition: engineplugin.h:292
QSharedPointer< GameExeFactory > gameExeFactory
Factory of executable retrievers ExeFile objects.
Definition: engineplugin.h:315
Allows the player to join a server without downloading files through Wadseeker.
Definition: engineplugin.h:99
Tells the create game box that this game allows UPnP.
Definition: engineplugin.h:204
MasterClient object.
Definition: engineplugin.h:123
Signifies that servers can be created with a join password.
Definition: engineplugin.h:94
Signifies that a server can be created with a random map rotation.
Definition: engineplugin.h:101
File name for game&#39;s server executable if game has any.
Definition: engineplugin.h:143
LAN Broadcast object.
Definition: engineplugin.h:119
Returns executable file retrievers from plugins to Doomseeker.
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:97
(bool)auto, (const char*)extension Sets the extension taht will be used for demos (default is true an...
Definition: engineplugin.h:104
virtual QList< CreateServerDialogPage * > createServerDialogPages(CreateServerDialog *pDialog)
Creates a list of custom Create Game dialog pages.
Definition: engineplugin.h:385
GameCVarProvider that returns difficulty levels ordered from easiest to hardest.
Definition: engineplugin.h:168
QSharedPointer< GameCVarProvider > difficulty
Difficulty levels provider for this game.
Definition: engineplugin.h:327
Signifies that servers can be created for remote console access.
Definition: engineplugin.h:95
Provides a description to be shown in the "About" menu.
Definition: engineplugin.h:222
Dialog window allowing user to create a game.
File name for game&#39;s client (main) executable.
Definition: engineplugin.h:132
Tells the create game box that this game allows to modify UPnP port.
Definition: engineplugin.h:218
Signifies that servers can have a message of the day.
Definition: engineplugin.h:96
Game mode representation.
Signifies that servers can provide a URL for potential wad downloads.
Definition: engineplugin.h:93
Signals the end of init parameters.
Definition: engineplugin.h:86
(quint8) The amount of time (in seconds) that must pass before a server can be requeried.
Definition: engineplugin.h:102
Base class to be used by plugins to define custom pages in Create Game dialog.
Signifies that servers can be created with a connection password.
Definition: engineplugin.h:91
Disables map list in create game box.
Definition: engineplugin.h:172
Signifies that servers can have an administrative contact email attached.
Definition: engineplugin.h:92
Data structure that describes and defines a connection to an IRC network or server.
INI section representation.
Definition: inisection.h:40
Indicates that client binary serves the purpose of the client and server.
Definition: engineplugin.h:115
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:428
(unsigned int) Single version number for plugin.
Definition: engineplugin.h:89
(quint16) Default port for custom server creation.
Definition: engineplugin.h:98
Abstract base for all MasterClients.
Definition: masterclient.h:49
Default search suffixes used to automatically find game files.
Definition: engineplugin.h:160
(const char*)server, (const char*)channel - Can be repeated. Default IRC channels.
Definition: engineplugin.h:100
(const char*) Overrides the URL scheme which Doomseeker sets for this plugin. By default it is the po...
Definition: engineplugin.h:103
A general game setting or variable (like fraglimit).
QString defaultMaster
Default port on which servers for given engine are hosted.
Definition: engineplugin.h:272
Base class for configuration pages.
Definition: configpage.h:44
Disables specifying amount of client slots in create game box.
Definition: engineplugin.h:188