gamedemo.h
1 //------------------------------------------------------------------------------
2 // gamedemo.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) 2014 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef ida153f497_2308_468a_8825_d9e06386db7a
24 #define ida153f497_2308_468a_8825_d9e06386db7a
25 
26 #include "dptr.h"
27 
28 #include <QDateTime>
29 #include <QDir>
30 #include <QList>
31 #include <QString>
32 #include <QWidget>
33 
34 class EnginePlugin;
35 class PWad;
36 
44 struct GameDemo
45 {
46  static const unsigned MAX_AUTHOR_FILENAME_LEN = 32;
47 
49  QString demopath;
51  QString author;
53  QString game;
55  QString gameVersion;
57  QDateTime time;
59  QString iwad;
61  QList<PWad> wads;
62 
71  QString exportedName() const;
72 
76  QString exportedNameNoExtension() const;
77 
87  QString managedName() const;
88 
92  QString managedNameNoExtension() const;
93 
97  bool hasDemoFile() const
98  {
99  return !demopath.isEmpty();
100  }
101 
118  void imprintPath(const QString &path);
119 };
120 
125 {
126 public:
127  enum Control
128  {
135  };
136 
137  DemoRecord();
138  DemoRecord(Control control);
139 
140  operator Control() const;
141 
142 private:
143  class PrivData
144  {
145  public:
146  DemoRecord::Control control;
147  };
148  PrivData d;
149 };
150 
155 {
156 public:
160  DemoStore();
161 
165  DemoStore(QDir root);
166 
170  static QStringList demoFileFilters();
171 
181  bool ensureStorageExists(QWidget *parent);
182 
197  bool importDemo(const GameDemo &demo);
198 
204  static QString metafile(const QString &path);
205 
225  QString mkDemoFullPath(DemoRecord::Control control, const EnginePlugin &plugin,
226  const bool isMultiplayer);
227 
238  QStringList listManagedDemos();
239 
251  bool removeManagedDemo(const QString &name);
252 
256  const QDir &root() const;
257 
276  void saveDemoMetaData(const QString &demoName, const EnginePlugin &plugin,
277  const QString &iwad, const QList<PWad> &pwads, const bool isMultiplayer,
278  const QString &gameVersion = QString());
279 
301  static GameDemo loadGameDemo(const QString &path);
302 
315  GameDemo loadManagedGameDemo(const QString &name);
316 
317 private:
318  DPtr<DemoStore> d;
319 
323  static QStringList listDemoExtensions();
324 
325  void saveDemoMetaData(const GameDemo &demo, const QString &path);
326 };
327 
328 #endif