diff --git a/src/engines/enginemanager.cpp b/src/engines/enginemanager.cpp index 20ad088820..b623139da2 100644 --- a/src/engines/enginemanager.cpp +++ b/src/engines/enginemanager.cpp @@ -56,7 +56,7 @@ #include "src/engines/aurora/model.h" // The engines -#include "src/engines/nwn/nwn.h" +#include "src/engines/nwn/probes.h" #include "src/engines/nwn2/nwn2.h" #include "src/engines/kotor/kotor.h" #include "src/engines/kotor2/kotor2.h" diff --git a/src/engines/nwn/Makefile.am b/src/engines/nwn/Makefile.am index 545af91415..957a5ee2d4 100644 --- a/src/engines/nwn/Makefile.am +++ b/src/engines/nwn/Makefile.am @@ -4,6 +4,7 @@ noinst_LTLIBRARIES = libnwn.la noinst_HEADERS = \ nwn.h \ + probes.h \ types.h \ modelloader.h \ version.h \ @@ -87,6 +88,7 @@ noinst_HEADERS = \ libnwn_la_SOURCES = \ nwn.cpp \ + probes.cpp \ types.cpp \ modelloader.cpp \ version.cpp \ diff --git a/src/engines/nwn/nwn.cpp b/src/engines/nwn/nwn.cpp index 4e7633f78a..bfefc5a264 100644 --- a/src/engines/nwn/nwn.cpp +++ b/src/engines/nwn/nwn.cpp @@ -66,54 +66,6 @@ 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); -} - - NWNEngine::NWNEngine() : _version(0), _language(Aurora::kLanguageInvalid), _hasXP1(false), _hasXP2(false), _hasXP3(false), _scriptFuncs(0), _module(0) { diff --git a/src/engines/nwn/nwn.h b/src/engines/nwn/nwn.h index afd0e4f2df..b6de177182 100644 --- a/src/engines/nwn/nwn.h +++ b/src/engines/nwn/nwn.h @@ -34,11 +34,6 @@ #include "src/sound/types.h" #include "src/engines/engine.h" -#include "src/engines/engineprobe.h" - -namespace Common { - class FileList; -} namespace Engines { @@ -52,70 +47,6 @@ class ScriptFunctions; class GUI; class Module; -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; - class NWNEngine : public Engines::Engine { public: NWNEngine(); diff --git a/src/engines/nwn/probes.cpp b/src/engines/nwn/probes.cpp new file mode 100644 index 0000000000..6ffd1e6a7b --- /dev/null +++ b/src/engines/nwn/probes.cpp @@ -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 . + */ + +/** @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 diff --git a/src/engines/nwn/probes.h b/src/engines/nwn/probes.h new file mode 100644 index 0000000000..d3e268c7b5 --- /dev/null +++ b/src/engines/nwn/probes.h @@ -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 . + */ + +/** @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