Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NWN: Move probes into their own file, probes.h/.cpp
- Loading branch information
Showing
6 changed files
with
191 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* xoreos - A reimplementation of BioWare's Aurora engine | ||
* | ||
* xoreos is the legal property of its developers, whose names | ||
* can be found in the AUTHORS file distributed with this source | ||
* distribution. | ||
* | ||
* xoreos is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 3 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* xoreos is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with xoreos. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** @file | ||
* Probing for an installation of Neverwinter Nights. | ||
*/ | ||
|
||
#include "src/common/filelist.h" | ||
#include "src/common/filepath.h" | ||
|
||
#include "src/engines/nwn/probes.h" | ||
#include "src/engines/nwn/nwn.h" | ||
|
||
namespace Engines { | ||
|
||
namespace NWN { | ||
|
||
const NWNEngineProbeWindows kNWNEngineProbeWin; | ||
const NWNEngineProbeMac kNWNEngineProbeMac; | ||
const NWNEngineProbeLinux kNWNEngineProbeLinux; | ||
const NWNEngineProbeFallback kNWNEngineProbeFallback; | ||
|
||
const Common::UString NWNEngineProbe::kGameName = "Neverwinter Nights"; | ||
|
||
Engines::Engine *NWNEngineProbe::createEngine() const { | ||
return new NWNEngine; | ||
} | ||
|
||
bool NWNEngineProbeWindows::probe(const Common::UString &UNUSED(directory), | ||
const Common::FileList &rootFiles) const { | ||
|
||
// Look for the Windows binary nwmain.exe | ||
return rootFiles.contains("/nwmain.exe", true); | ||
} | ||
|
||
bool NWNEngineProbeMac::probe(const Common::UString &directory, | ||
const Common::FileList &UNUSED(rootFiles)) const { | ||
|
||
// Look for the app directory containing the Mac OS X binary | ||
return !Common::FilePath::findSubDirectory(directory, "Neverwinter Nights.app", true).empty(); | ||
} | ||
|
||
bool NWNEngineProbeLinux::probe(const Common::UString &UNUSED(directory), | ||
const Common::FileList &rootFiles) const { | ||
|
||
// Look for the Linux binary nwmain | ||
return rootFiles.contains("/nwmain", true); | ||
} | ||
|
||
bool NWNEngineProbeFallback::probe(const Common::UString &UNUSED(directory), | ||
const Common::FileList &rootFiles) const { | ||
|
||
// Don't accidentally trigger on NWN2 | ||
if (rootFiles.contains("/nwn2.ini", true)) | ||
return false; | ||
if (rootFiles.contains("/nwn2main.exe", true)) | ||
return false; | ||
|
||
// As a fallback, look for the nwn.ini, nwnplayer.ini or nwncdkey.ini | ||
return rootFiles.contains("/nwn.ini", true) || | ||
rootFiles.contains("/nwnplayer.ini", true) || | ||
rootFiles.contains("/nwncdkey.ini", true); | ||
} | ||
|
||
} // End of namespace NWN | ||
|
||
} // End of namespace Engines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* xoreos - A reimplementation of BioWare's Aurora engine | ||
* | ||
* xoreos is the legal property of its developers, whose names | ||
* can be found in the AUTHORS file distributed with this source | ||
* distribution. | ||
* | ||
* xoreos is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 3 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* xoreos is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with xoreos. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** @file | ||
* Probing for an installation of Neverwinter Nights. | ||
*/ | ||
|
||
#ifndef ENGINES_NWN_PROBES_H | ||
#define ENGINES_NWN_PROBES_H | ||
|
||
#include "src/common/ustring.h" | ||
|
||
#include "src/engines/engineprobe.h" | ||
|
||
namespace Engines { | ||
|
||
namespace NWN { | ||
|
||
class NWNEngineProbe : public Engines::EngineProbe { | ||
private: | ||
static const Common::UString kGameName; | ||
|
||
public: | ||
NWNEngineProbe() {} | ||
~NWNEngineProbe() {} | ||
|
||
Aurora::GameID getGameID() const { | ||
return Aurora::kGameIDNWN; | ||
} | ||
|
||
const Common::UString &getGameName() const { | ||
return kGameName; | ||
} | ||
|
||
bool probe(Common::SeekableReadStream &UNUSED(stream)) const { | ||
return false; | ||
} | ||
|
||
Engines::Engine *createEngine() const; | ||
}; | ||
|
||
class NWNEngineProbeWindows : public NWNEngineProbe { | ||
public: | ||
NWNEngineProbeWindows() {} | ||
~NWNEngineProbeWindows() {} | ||
|
||
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const; | ||
Aurora::Platform getPlatform() const { return Aurora::kPlatformWindows; } | ||
}; | ||
|
||
class NWNEngineProbeMac : public NWNEngineProbe { | ||
public: | ||
NWNEngineProbeMac() {} | ||
~NWNEngineProbeMac() {} | ||
|
||
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const; | ||
Aurora::Platform getPlatform() const { return Aurora::kPlatformMacOSX; } | ||
}; | ||
|
||
class NWNEngineProbeLinux: public NWNEngineProbe { | ||
public: | ||
NWNEngineProbeLinux() {} | ||
~NWNEngineProbeLinux() {} | ||
|
||
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const; | ||
Aurora::Platform getPlatform() const { return Aurora::kPlatformLinux; } | ||
}; | ||
|
||
class NWNEngineProbeFallback : public NWNEngineProbe { | ||
public: | ||
NWNEngineProbeFallback() {} | ||
~NWNEngineProbeFallback() {} | ||
|
||
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const; | ||
Aurora::Platform getPlatform() const { return Aurora::kPlatformUnknown; } | ||
}; | ||
|
||
extern const NWNEngineProbeWindows kNWNEngineProbeWin; | ||
extern const NWNEngineProbeMac kNWNEngineProbeMac; | ||
extern const NWNEngineProbeLinux kNWNEngineProbeLinux; | ||
extern const NWNEngineProbeFallback kNWNEngineProbeFallback; | ||
|
||
} // End of namespace NWN | ||
|
||
} // End of namespace Engines | ||
|
||
#endif // ENGINES_NWN_PROBES_H |