gameclientrunner.h
1 //------------------------------------------------------------------------------
2 // gameclientrunner.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) 2010 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef id50da6ce1_f633_485e_9e5f_e808731b1e2e
24 #define id50da6ce1_f633_485e_9e5f_e808731b1e2e
25 
26 #include "dptr.h"
27 #include "global.h"
28 #include "pathfinder/pathfinder.h"
29 #include "serverapi/joinerror.h"
30 #include "serverapi/polymorphism.h"
31 #include "serverapi/serverptr.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() override;
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 
402  void markPwadAsIncompatible(const PWad &pwadName);
403 
409  PathFinder &pathFinder();
410 
415  ServerConnectParams &serverConnectParams();
416 
417  void setArgForBexLoading(const QString &arg);
418  void setArgForConnect(const QString &arg);
419  void setArgForConnectPassword(const QString &arg);
420  void setArgForDehLoading(const QString &arg);
421  void setArgForDemoRecord(const QString &arg);
422  void setArgForInGamePassword(const QString &arg);
423  void setArgForIwadLoading(const QString &arg);
424  void setArgForOptionalWadLoading(const QString &arg);
425  void setArgForPort(const QString &arg);
426  void setArgForPwadLoading(const QString &arg);
427 
428  void setExecutable(const QString &path);
429  void setWorkingDir(const QString &path);
430 
435  void setJoinError(const JoinError &e);
436 
442  QString wadTargetDirectory() const;
443 
444 private:
445  class GamePaths
446  {
447  public:
448  QString clientExe;
449  QString workingDir;
450 
451  bool isValid() const
452  {
453  return !clientExe.isEmpty();
454  }
455  };
456 
458 
459  bool canDownloadWadsInGame() const;
460  bool isFatalError() const;
461  QString fileLoadingPrefix(const QString &file) const;
462  QString findIwad() const;
463  GamePaths gamePaths();
464  const QString &pluginName() const;
465  void saveDemoMetaData();
466 
473  void setupPathFinder();
474 };
475 
476 #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...