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 
55 EnginePlugin *GameExeFactory::plugin() const
56 {
57  return d->plugin;
58 }
59 
60 QList<ExeFilePath> GameExeFactory::additionalExecutables_default(int execType) const
61 {
62  Q_UNUSED(execType);
63  return QList<ExeFilePath>();
64 }
65 
66 GameFileList GameExeFactory::gameFiles_default() const
67 {
68  GameFile tmplate = GameFile().setSearchSuffixes(d->plugin->data()->gameFileSearchSuffixes);
69  GameFileList list;
70  if (d->plugin->data()->clientOnly)
71  {
72  list << GameFile(tmplate).setConfigName("BinaryPath").setNiceName(tr("game"))
73  .setFileName(d->plugin->data()->clientExeName)
74  .setExecutable(GameFile::Cso);
75  }
76  else
77  {
78  list << GameFile(tmplate).setConfigName("BinaryPath").setNiceName(tr("client"))
79  .setFileName(d->plugin->data()->clientExeName)
80  .setExecutable(GameFile::Offline | GameFile::Client);
81  list << GameFile(tmplate).setConfigName("ServerBinaryPath").setNiceName(tr("server"))
82  .setFileName(d->plugin->data()->serverExeName).setExecutable(GameFile::Server);
83  }
84  return list;
85 }