gameclientrunner.h
1 //------------------------------------------------------------------------------
2 // gameclientrunner.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) 2010 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef id50da6ce1_f633_485e_9e5f_e808731b1e2e
24 #define id50da6ce1_f633_485e_9e5f_e808731b1e2e
25 
26 #include "pathfinder/pathfinder.h"
27 #include "serverapi/joinerror.h"
28 #include "serverapi/polymorphism.h"
29 #include "serverapi/serverptr.h"
30 #include "dptr.h"
31 #include "global.h"
32 #include <QObject>
33 #include <QString>
34 
35 class CommandLineInfo;
36 class Message;
37 class Server;
38 
46 class MAIN_EXPORT ServerConnectParams
47 {
48  public:
51  ServerConnectParams& operator=(const ServerConnectParams& other);
52  virtual ~ServerConnectParams();
53 
57  const QString& connectPassword() const;
63  const QString& demoName() const;
67  const QString& inGamePassword() const;
68 
69  void setConnectPassword(const QString& val);
70  void setDemoName(const QString& val);
71  void setInGamePassword(const QString& val);
72 
73  private:
75 };
76 
93 class MAIN_EXPORT GameClientRunner : public QObject
94 {
95  Q_OBJECT
96 
97  public:
98  GameClientRunner(ServerPtr server);
99  virtual ~GameClientRunner();
100 
112  JoinError createJoinCommandLine(CommandLineInfo &cli,
113  const ServerConnectParams &params);
114 
118  JoinError joinError() const;
119 
120  protected:
126  void addConnectCommand();
127  POLYMORPHIC_SETTER_DECLARE(void, GameClientRunner, addConnectCommand, ());
128  void addConnectCommand_default();
129 
138  void addCustomParameters();
148  void addDemoRecordCommand();
149 
157  void addExtra();
158  POLYMORPHIC_SETTER_DECLARE(void, GameClientRunner, addExtra, ());
159  void addExtra_default();
160 
165  void addGamePaths();
166  POLYMORPHIC_SETTER_DECLARE(void, GameClientRunner, addGamePaths, ());
167  void addGamePaths_default();
177  void addInGamePassword();
178  POLYMORPHIC_SETTER_DECLARE(void, GameClientRunner, addInGamePassword, ());
179  void addInGamePassword_default();
186  void addIwad();
187  POLYMORPHIC_SETTER_DECLARE(void, GameClientRunner, addIwad, ());
188  void addIwad_default();
189 
194  void addWads();
210  void addPwads();
211 
230  void addModFiles(const QStringList &files);
231  POLYMORPHIC_SETTER_DECLARE(void, GameClientRunner, addModFiles, (const QStringList&));
232  void addModFiles_default(const QStringList &files);
258  void addModFiles_prefixOnce(const QStringList &files);
259 
269  void addPassword();
270  POLYMORPHIC_SETTER_DECLARE(void, GameClientRunner, addPassword, ());
271  void addPassword_default();
272 
279  QStringList& args();
280 
281  const QString& argForBexLoading() const;
282 
289  const QString& argForConnect() const;
290 
298  const QString& argForConnectPassword() const;
299 
305  const QString& argForDehLoading() const;
306 
314  const QString& argForInGamePassword() const;
315 
321  const QString& argForIwadLoading() const;
322 
329  const QString& argForPort() const;
330 
336  const QString& argForOptionalWadLoading() const;
337 
343  const QString& argForPwadLoading() const;
344 
350  const QString& argForDemoRecord() const;
351 
362  void createCommandLineArguments();
363  POLYMORPHIC_SETTER_DECLARE(void, GameClientRunner, createCommandLineArguments, ());
364  void createCommandLineArguments_default();
365 
369  const QString& connectPassword() const;
373  const QString& demoName() const;
374 
378  QString findWad(const QString &wad) const;
379 
383  const QString& inGamePassword() const;
384 
385  bool isIwadFound() const;
386  const QString& iwadPath() const;
387 
394  void markPwadAsMissing(const PWad& pwadName);
395 
401  PathFinder& pathFinder();
402 
407  ServerConnectParams& serverConnectParams();
408 
409  void setArgForBexLoading(const QString& arg);
410  void setArgForConnect(const QString& arg);
411  void setArgForConnectPassword(const QString& arg);
412  void setArgForDehLoading(const QString& arg);
413  void setArgForDemoRecord(const QString& arg);
414  void setArgForInGamePassword(const QString& arg);
415  void setArgForIwadLoading(const QString& arg);
416  void setArgForOptionalWadLoading(const QString& arg);
417  void setArgForPort(const QString& arg);
418  void setArgForPwadLoading(const QString& arg);
419 
420  void setExecutable(const QString &path);
421  void setWorkingDir(const QString &path);
422 
427  void setJoinError(const JoinError& e);
428 
434  QString wadTargetDirectory() const;
435 
436  private:
437  class GamePaths
438  {
439  public:
440  QString clientExe;
441  QString workingDir;
442 
443  bool isValid() const
444  {
445  return !clientExe.isEmpty();
446  }
447  };
448 
450 
451  bool canDownloadWadsInGame() const;
452  bool isFatalError() const;
453  QString fileLoadingPrefix(const QString &file) const;
454  QString findIwad() const;
455  GamePaths gamePaths();
456  const QString& pluginName() const;
457  void saveDemoMetaData();
458 
465  void setupPathFinder();
466 };
467 
468 #endif
Performs a case-insensitive (OS independent) file searches.
Definition: pathfinder.h:81
PWAD hosted on a server.
Structure holding parameters for application launch.
Definition: apprunner.h:37
Message object used to pass messages throughout the Doomseeker&#39;s system.
Definition: message.h:63
A DTO for GameClientRunner; exchanges information between main program and plugins, and allows future extensions.
A representation of a server for a given game.
Definition: server.h:93
Indicator of error for the server join process.
Definition: joinerror.h:41
Creates command line that launches the client executable of the game and connects it to a server...