gamefile.h
1 //------------------------------------------------------------------------------
2 // gamefile.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) 2015 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef idc66bde0f_a415_4f5a_8dcb_34697293515c
24 #define idc66bde0f_a415_4f5a_8dcb_34697293515c
25 
26 #include "dptr.h"
27 #include "global.h"
28 #include <QList>
29 #include <QString>
30 
72 class MAIN_EXPORT GameFile
73 {
74 public:
79  enum ExecType
80  {
81  Client = 0x1,
82  Server = 0x2,
83  Offline = 0x4,
84  Cso = Client | Server | Offline,
85  CreateGame = Server | Offline,
86  };
87 
88  GameFile();
89  virtual ~GameFile();
90 
94  bool isSameFile(const QString &otherFileName);
95 
99  bool isValid() const;
100 
104  int executable() const;
105  GameFile &setExecutable(int flags);
106 
110  const QString &configName() const;
111  GameFile &setConfigName(const QString &name);
112 
118  const QString &fileName() const;
119  GameFile &setFileName(const QString &name);
120 
125  const QString &niceName() const;
126  GameFile &setNiceName(const QString &name);
127 
133  QStringList &searchSuffixes() const;
134  GameFile &setSearchSuffixes(const QStringList &suffixes);
135 
136 private:
137  DPtr<GameFile> d;
138 };
139 
140 
145 class MAIN_EXPORT GameFileList
146 {
147  friend MAIN_EXPORT GameFileList& operator<<(GameFileList &list, const GameFile &gameFile);
148  friend MAIN_EXPORT GameFileList& operator<<(GameFileList &list, const GameFileList &other);
149 
150 public:
151  GameFileList();
152  virtual ~GameFileList();
153 
154  GameFileList &append(const GameFile &gameFile);
155  GameFileList &append(const GameFileList &list);
156  QList<GameFile> asQList() const;
157  void clear();
158  GameFile findByConfigName(const QString &configName);
159  GameFile first() const;
160  bool isEmpty() const;
161  GameFileList &prepend(const GameFile &gameFile);
162 
163 private:
165 };
166 
167 namespace GameFiles
168 {
169  GameFileList allCreateGameExecutables(const GameFileList &list);
170  GameFileList allClientExecutables(const GameFileList &list);
171  GameFileList allServerExecutables(const GameFileList &list);
172 
177  GameFileList allFlagMatchExecutables(const GameFileList &list, int execs);
178 
179  GameFile defaultClientExecutable(const GameFileList &list);
180  GameFile defaultOfflineExecutable(const GameFileList &list);
181  GameFile defaultServerExecutable(const GameFileList &list);
182 
183  GameFile preferredOfflineExecutable(const GameFileList &list);
184 }
185 
186 #endif
GameFile collection.
Definition: gamefile.h:145
ExecType
Executable types recognised by Doomseeker.
Definition: gamefile.h:79
A representation of a server for a given game.
Definition: server.h:93
Game file definition allows to browse this file in configuration box.
Definition: gamefile.h:72