gameexefactory.cpp
1 //------------------------------------------------------------------------------
2 // gameexefactory.cpp
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) 2013 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #include "gameexefactory.h"
24 
25 #include "plugins/engineplugin.h"
26 #include "serverapi/exefile.h"
27 
28 DClass<GameExeFactory>
29 {
30 public:
31  EnginePlugin* plugin;
32 
33  ExeFile* (GameExeFactory::*offline)();
34  ExeFile* (GameExeFactory::*server)();
35 };
36 
37 DPointered(GameExeFactory)
38 
40 {
41  d->plugin = plugin;
42 
43  set_offline(&GameExeFactory::offline_default);
44  set_server(&GameExeFactory::server_default);
45 }
46 
47 GameExeFactory::~GameExeFactory()
48 {
49 }
50 
51 POLYMORPHIC_DEFINE(ExeFile*, GameExeFactory, offline, (), ());
52 POLYMORPHIC_DEFINE(ExeFile*, GameExeFactory, server, (), ());
53 
55 {
56  return d->plugin;
57 }
58 
59 ExeFile* GameExeFactory::offline_default()
60 {
61  ExeFile *f = new ExeFile();
62  f->setProgramName(d->plugin->data()->name);
63  f->setExeTypeName(tr("offline"));
64  f->setConfigKey("BinaryPath");
65  return f;
66 }
67 
68 ExeFile* GameExeFactory::server_default()
69 {
70  ExeFile *f = new ExeFile();
71  f->setProgramName(d->plugin->data()->name);
72  f->setExeTypeName(tr("server"));
73  if (d->plugin->data()->clientOnly)
74  {
75  f->setConfigKey("BinaryPath");
76  }
77  else
78  {
79  f->setConfigKey("ServerBinaryPath");
80  }
81  return f;
82 }
void setProgramName(const QString &name)
Plugin setter for programName().
Definition: exefile.cpp:113
void setExeTypeName(const QString &name)
Plugin setter for exeTypeName().
Definition: exefile.cpp:108
EnginePlugin * plugin()
Gets EnginePlugin associated with this object.
Returns executable file retrievers from plugins to Doomseeker.
void setConfigKey(const QString &keyName)
Plugin setter for configKey().
Definition: exefile.cpp:103
Access to external program executables (game clients, servers, and so on).
Definition: exefile.h:48