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();
175  void addInGamePassword();
176  POLYMORPHIC_SETTER_DECLARE(void, GameClientRunner, addInGamePassword, ());
177  void addInGamePassword_default();
184  void addIwad();
185  POLYMORPHIC_SETTER_DECLARE(void, GameClientRunner, addIwad, ());
186  void addIwad_default();
187 
192  void addWads();
203  void addPwads();
213  void addPassword();
214  POLYMORPHIC_SETTER_DECLARE(void, GameClientRunner, addPassword, ());
215  void addPassword_default();
216 
223  QStringList& args();
224 
225  const QString& argForBexLoading() const;
226 
233  const QString& argForConnect() const;
234 
242  const QString& argForConnectPassword() const;
243 
249  const QString& argForDehLoading() const;
250 
258  const QString& argForInGamePassword() const;
259 
265  const QString& argForIwadLoading() const;
266 
273  const QString& argForPort() const;
274 
280  const QString& argForOptionalWadLoading() const;
281 
287  const QString& argForPwadLoading() const;
288 
294  const QString& argForDemoRecord() const;
295 
306  void createCommandLineArguments();
307  POLYMORPHIC_SETTER_DECLARE(void, GameClientRunner, createCommandLineArguments, ());
308  void createCommandLineArguments_default();
309 
313  const QString& connectPassword() const;
317  const QString& demoName() const;
318 
322  QString findWad(const QString &wad) const;
323 
327  const QString& inGamePassword() const;
328 
329  bool isIwadFound() const;
330  const QString& iwadPath() const;
331 
338  void markPwadAsMissing(const PWad& pwadName);
339 
345  PathFinder& pathFinder();
346 
350  QString pathToOfflineExe(Message &msg);
351 
356  ServerConnectParams& serverConnectParams();
357 
358  void setArgForBexLoading(const QString& arg);
359  void setArgForConnect(const QString& arg);
360  void setArgForConnectPassword(const QString& arg);
361  void setArgForDehLoading(const QString& arg);
362  void setArgForDemoRecord(const QString& arg);
363  void setArgForInGamePassword(const QString& arg);
364  void setArgForIwadLoading(const QString& arg);
365  void setArgForOptionalWadLoading(const QString& arg);
366  void setArgForPort(const QString& arg);
367  void setArgForPwadLoading(const QString& arg);
368 
373  void setJoinError(const JoinError& e);
374 
380  QString wadTargetDirectory() const;
381 
382  private:
383  class GamePaths
384  {
385  public:
386  QString clientExe;
387  QString offlineExe;
388  QString workingDir;
389 
390  bool isValid() const
391  {
392  return !clientExe.isEmpty();
393  }
394  };
395 
397 
398  bool canDownloadWadsInGame() const;
399  bool isFatalError() const;
400  QString findIwad() const;
401  GamePaths gamePaths();
402  const QString& pluginName() const;
403  void saveDemoMetaData();
404 
411  void setupPathFinder();
412 };
413 
414 #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's system.
Definition: message.h:62
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...