xoreos  0.0.5
probes.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/ustring.h"
26 #include "src/common/filelist.h"
27 #include "src/common/filepath.h"
28 
30 
33 
34 namespace Engines {
35 
36 namespace KotOR {
37 
39 private:
40  static const Common::UString kGameName;
41 
42 public:
45 
47  return Aurora::kGameIDKotOR;
48  }
49 
50  const Common::UString &getGameName() const {
51  return kGameName;
52  }
53 
54  bool probe(Common::SeekableReadStream &UNUSED(stream)) const {
55  return false;
56  }
57 
59  return new KotOREngine;
60  }
61 };
62 
63 const Common::UString EngineProbe::kGameName = "Star Wars: Knights of the Old Republic";
64 
65 
67 public:
70 
72 
73  bool probe(const Common::UString &UNUSED(directory), const Common::FileList &rootFiles) const {
74 
75  // If swkotor.exe exists, this should be a valid path for the Windows port
76  return rootFiles.contains("/swkotor.exe", true);
77  }
78 
79 };
80 
81 class EngineProbeMac : public EngineProbe {
82 public:
85 
87 
88  bool probe(const Common::UString &directory, const Common::FileList &UNUSED(rootFiles)) const {
89 
90  // If the "Knights of the Old Republic.app" directory exists,
91  // this should be a valid path for the Mac OS X port
92  const Common::UString appDirectory1 =
93  Common::FilePath::findSubDirectory(directory, "Knights of the Old Republic.app", true);
94  // Alternatively, the app directory might just be called "KOTOR"
95  const Common::UString appDirectory2 =
96  Common::FilePath::findSubDirectory(directory, "KOTOR.app", true);
97 
98  return !appDirectory1.empty() || !appDirectory2.empty();
99  }
100 
101 };
102 
103 class EngineProbeXbox : public EngineProbe {
104 public:
107 
109 
110  bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const {
111 
112  // If the "dataxbox" directory exists and "players.erf" exists,
113  // this should be a valid path for the Xbox port
114  const Common::UString appDirectory = Common::FilePath::findSubDirectory(directory, "dataxbox");
115 
116  return !appDirectory.empty() && rootFiles.contains("/players.erf", true);
117  }
118 
119 };
120 
122 public:
125 
127 
128  bool probe(const Common::UString &directory, const Common::FileList &UNUSED(rootFiles)) const {
129  // TODO: Detect the unextracted OBBs? Doesn't work with how we index directories, though.
130 
131  const Common::FileList dataFiles(Common::FilePath::findSubDirectory(directory, "data", true));
132  if (dataFiles.contains("/2da.bzf", true))
133  return true;
134 
135  return false;
136  }
137 
138 };
139 
140 
141 void createEngineProbes(std::list<const ::Engines::EngineProbe *> &probes) {
142  probes.push_back(new EngineProbeWindows);
143  probes.push_back(new EngineProbeMac);
144  probes.push_back(new EngineProbeXbox);
145  probes.push_back(new EngineProbeAndroid);
146 }
147 
148 } // End of namespace KotOR
149 
150 } // End of namespace Engines
GameID
Definition: types.h:393
A class holding an UTF-8 string.
Definition: ustring.h:48
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const
Check for the game in that directory, containing these files.
Definition: probes.cpp:110
Aurora::Platform getPlatform() const
Get the Platform that the probe is able to detect.
Definition: probes.cpp:108
const Common::UString & getGameName() const
Return a string of the full game name.
Definition: probes.cpp:50
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const
Check for the game in that directory, containing these files.
Definition: probes.cpp:88
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const
Check for the game in that directory, containing these files.
Definition: probes.cpp:128
Aurora::Platform getPlatform() const
Get the Platform that the probe is able to detect.
Definition: probes.cpp:71
A probe that checks if an engine can handle game data found in a specific directory and creates an in...
bool probe(Common::SeekableReadStream &stream) const
Check for the game in that file.
Definition: probes.cpp:54
Android mobile phones and tablets.
Definition: types.h:437
static const Common::UString kGameName
Definition: probes.cpp:40
Aurora::Platform getPlatform() const
Get the Platform that the probe is able to detect.
Definition: probes.cpp:126
#define UNUSED(x)
Definition: system.h:170
Star Wars: Knights of the Old Republic.
Definition: types.h:397
Engine class handling Star Wars: Knights of the Old Republic.
Microsoft Xbox.
Definition: types.h:433
void createEngineProbes(std::list< const ::Engines::EngineProbe *> &probes)
Definition: probes.cpp:141
bool empty() const
Is the string empty?
Definition: ustring.cpp:245
Aurora::Platform getPlatform() const
Get the Platform that the probe is able to detect.
Definition: probes.cpp:86
Unicode string handling.
The base class for an engine within BioWare&#39;s Aurora family.
Definition: engine.h:49
A probe able to detect one specific game.
Definition: engineprobe.h:44
Engines::Engine * createEngine() const
Create the respective engine for the GameID.
Definition: probes.cpp:58
A list of files.
Definition: filelist.h:35
Aurora::GameID getGameID() const
Get the GameID that the probe is able to detect.
Definition: probes.cpp:46
Microsoft Windows.
Definition: types.h:430
A list of files.
Probing for an installation of Star Wars: Knights of the Old Republic.
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const
Check for the game in that directory, containing these files.
Definition: probes.cpp:73
Interface for a seekable & readable data stream.
Definition: readstream.h:265
Platform
Definition: types.h:429
Utility class for manipulating file paths.
static UString findSubDirectory(const UString &directory, const UString &subDirectory, bool caseInsensitive=false)
Find a directory&#39;s subdirectory.
Definition: filepath.cpp:318
bool contains(const UString &str, bool caseInsensitive) const
Does the list contain at least one file ending with the given string?
Definition: filelist.cpp:185