gameexefactory.cpp
1 //------------------------------------------------------------------------------
2 // gameexefactory.cpp
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) 2013 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #include "gameexefactory.h"
24 
25 #include "plugins/engineplugin.h"
26 #include "serverapi/exefile.h"
27 #include "serverapi/gamefile.h"
28 
29 DClass<GameExeFactory>
30 {
31 public:
32  EnginePlugin* plugin;
33 
34  QList<ExeFilePath> (GameExeFactory::*additionalExecutables)(int) const;
35  GameFileList (GameExeFactory::*gameFiles)() const;
36 };
37 
38 DPointered(GameExeFactory)
39 
41 {
42  d->plugin = plugin;
43 
44  set_additionalExecutables(&GameExeFactory::additionalExecutables_default);
45  set_gameFiles(&GameExeFactory::gameFiles_default);
46 }
47 
48 GameExeFactory::~GameExeFactory()
49 {
50 }
51 
52 POLYMORPHIC_DEFINE_CONST(QList<ExeFilePath>, GameExeFactory, additionalExecutables, (int execType), (execType));
53 POLYMORPHIC_DEFINE_CONST(GameFileList, GameExeFactory, gameFiles, (), ());
54 
56 {
57  return d->plugin;
58 }
59 
60 QList<ExeFilePath> GameExeFactory::additionalExecutables_default(int execType) const
61 {
62  return QList<ExeFilePath>();
63 }
64 
65 GameFileList GameExeFactory::gameFiles_default() const
66 {
67  GameFile tmplate = GameFile().setSearchSuffixes(d->plugin->data()->gameFileSearchSuffixes);
68  GameFileList list;
69  if (d->plugin->data()->clientOnly)
70  {
71  list << GameFile(tmplate).setConfigName("BinaryPath").setNiceName(tr("game"))
72  .setFileName(d->plugin->data()->clientExeName)
73  .setExecutable(GameFile::Cso);
74  }
75  else
76  {
77  list << GameFile(tmplate).setConfigName("BinaryPath").setNiceName(tr("client"))
78  .setFileName(d->plugin->data()->clientExeName)
79  .setExecutable(GameFile::Offline | GameFile::Client);
80  list << GameFile(tmplate).setConfigName("ServerBinaryPath").setNiceName(tr("server"))
81  .setFileName(d->plugin->data()->serverExeName).setExecutable(GameFile::Server);
82  }
83  return list;
84 }
GameFile collection.
Definition: gamefile.h:145
QList< ExeFilePath > additionalExecutables(int execType) const
[Virtual] Additional paths to any executable that matches the bit mask.
Returns executable file retrievers from plugins to Doomseeker.
Game file definition allows to browse this file in configuration box.
Definition: gamefile.h:72
GameFileList gameFiles() const
[Virtual] List of all game files associated with this game.
EnginePlugin * plugin() const
Gets EnginePlugin associated with this object.