createserverdialog.h
1 //------------------------------------------------------------------------------
2 // createserverdialog.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) 2009-2012 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef DOOMSEEKER_GUI_CREATESERVERDIALOG_H
24 #define DOOMSEEKER_GUI_CREATESERVERDIALOG_H
25 
26 #include "dptr.h"
27 #include "serverapi/gamecreateparams.h"
29 #include <QDialog>
30 
32 class EnginePlugin;
33 class GameCreateParams;
34 class MapListPanel;
35 class Message;
36 class Server;
37 
41 class CreateServerDialog : public QDialog
42 {
43  Q_OBJECT
44 
45 public:
46  enum class CommandLinePurpose
47  {
48  Show, Run
49  };
50 
51  CreateServerDialog(GameCreateParams::HostMode hostMode, QWidget *parent = nullptr);
52  virtual ~CreateServerDialog();
53 
54  bool commandLineArguments(QString &executable, QStringList &args,
55  bool offline, CommandLinePurpose purpose);
56  void makeRemoteGameSetupDialog(EnginePlugin *plugin);
57  MapListPanel *mapListPanel();
58  QString mapName() const;
59  void setIwadByName(const QString &iwad);
60  QStringList wadPaths() const;
61 
62 private slots:
63  void changeToHostMode();
64  void changeToOfflineMode();
65  void firstLoadConfigTimer();
66 
72  void initEngineSpecific(EnginePlugin *engineInfo);
73  void initGamemodeSpecific(const GameMode &gameMode);
74  void showConfiguration();
75  void showLoadConfig();
76  void showSaveConfig();
77  void showStartGameCommandLine();
78  void startGame();
79 
80 private:
81  static const QString TEMP_GAME_CONFIG_FILENAME;
82 
84 
90  void addIwad(const QString &path);
91  void applyModeToUi();
92 
98  bool createHostInfo(GameCreateParams &params, bool offline, CommandLinePurpose purpose);
99  bool createHostInfoDemoRecord(GameCreateParams &params, bool offline, CommandLinePurpose purpose);
100 
101  GameMode currentGameMode() const;
102 
103  bool fillInParamsFromPluginPages(GameCreateParams &params);
104  void initDMFlagsTabs();
105 
111  void initEngineSpecificPages(EnginePlugin *engineInfo);
112 
113  void initServerTab();
114 
115  void initRules();
116 
117  bool loadConfig(const QString &filename, bool loadingPrevious);
118  void runGame(bool offline);
119  bool saveConfig(const QString &filename);
120  void setupMenu();
121  void showCommandLine(bool offline);
122 };
123 
124 #endif