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 #include <QList>
31 #include <QString>
32 
34 class EnginePlugin;
35 class GameCreateParams;
36 struct GameDemo;
37 class MapListPanel;
38 class Message;
39 struct PickedGameFile;
40 class Server;
41 
45 class CreateServerDialog : public QDialog
46 {
47  Q_OBJECT
48 
49 public:
50  enum class CommandLinePurpose
51  {
52  Show, Run
53  };
54 
55  CreateServerDialog(GameCreateParams::HostMode hostMode, QWidget *parent = nullptr);
56  virtual ~CreateServerDialog();
57 
58  bool commandLineArguments(QString &executable, QStringList &args,
59  CommandLinePurpose purpose);
60  void makeDemoPlaybackSetupDialog(EnginePlugin *plugin, const GameDemo &demo,
61  const QString &iwad, const QList<PickedGameFile> &wads);
62  void makeRemoteGameSetupDialog(EnginePlugin *plugin);
63  MapListPanel *mapListPanel();
64  QString mapName() const;
65  void setIwadByName(const QString &iwad);
66  QStringList wadPaths() const;
67 
68 private slots:
69  void changeToHostMode();
70  void changeToOfflineMode();
71  void firstLoadConfigTimer();
72 
78  void initEngineSpecific(EnginePlugin *engineInfo);
79  void initGamemodeSpecific(const GameMode &gameMode);
80  void showCommandLine();
81  void showConfiguration();
82  void showLoadConfig();
83  void showSaveConfig();
84  void startGame();
85 
86 private:
87  static const QString TEMP_GAME_CONFIG_FILENAME;
88 
90 
96  void addIwad(const QString &path);
97  void applyModeToUi();
98 
104  bool createHostInfo(GameCreateParams &params, CommandLinePurpose purpose);
105  bool createHostInfoDemoRecord(GameCreateParams &params, CommandLinePurpose purpose);
106 
107  GameMode currentGameMode() const;
108 
109  bool fillInParamsFromPluginPages(GameCreateParams &params);
110  void initDMFlagsTabs();
111 
117  void initEngineSpecificPages(EnginePlugin *engineInfo);
118 
119  void initServerTab();
120 
121  void initRules();
122 
123  bool loadConfig(const QString &filename, bool loadingPrevious);
124  void runGame();
125  bool saveConfig(const QString &filename);
126  void setupMenu();
127  void switchToMode(GameCreateParams::HostMode mode);
128 };
129 
130 #endif