From a4dbe82be792a75091ac57500c56b565778bc62a Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sun, 27 Dec 2015 13:50:46 +0000 Subject: Removes the gameinfo + related files from shared to hookdll --- src/shared/fallout3info.cpp | 88 ----------------------- src/shared/fallout3info.h | 59 ---------------- src/shared/falloutnvinfo.cpp | 88 ----------------------- src/shared/falloutnvinfo.h | 59 ---------------- src/shared/gameinfo.cpp | 164 ------------------------------------------- src/shared/gameinfo.h | 95 ------------------------- src/shared/oblivioninfo.cpp | 88 ----------------------- src/shared/oblivioninfo.h | 58 --------------- src/shared/shared.pro | 10 --- src/shared/skyriminfo.cpp | 104 --------------------------- src/shared/skyriminfo.h | 62 ---------------- 11 files changed, 875 deletions(-) delete mode 100644 src/shared/fallout3info.cpp delete mode 100644 src/shared/fallout3info.h delete mode 100644 src/shared/falloutnvinfo.cpp delete mode 100644 src/shared/falloutnvinfo.h delete mode 100644 src/shared/gameinfo.cpp delete mode 100644 src/shared/gameinfo.h delete mode 100644 src/shared/oblivioninfo.cpp delete mode 100644 src/shared/oblivioninfo.h delete mode 100644 src/shared/skyriminfo.cpp delete mode 100644 src/shared/skyriminfo.h (limited to 'src/shared') diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp deleted file mode 100644 index 797d68ec..00000000 --- a/src/shared/fallout3info.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright (C) 2012 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer 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. - -Mod Organizer 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 Mod Organizer. If not, see . -*/ - -#include "fallout3info.h" -#include "util.h" -#include -#include -#include -#include "windows_error.h" -#include "error_report.h" -#define WIN32_LEAN_AND_MEAN -#include -#include - -namespace MOShared { - -Fallout3Info::Fallout3Info(const std::wstring &gameDirectory) - : GameInfo(gameDirectory) -{ - identifyMyGamesDirectory(L"fallout3"); -} - -bool Fallout3Info::identifyGame(const std::wstring &searchPath) -{ - return FileExists(searchPath, L"Fallout3.exe") && - FileExists(searchPath, L"FalloutLauncher.exe"); -} - -std::wstring Fallout3Info::getRegPathStatic() -{ - HKEY key; - LONG errorcode = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Bethesda Softworks\\Fallout3", - 0, KEY_QUERY_VALUE, &key); - - if (errorcode != ERROR_SUCCESS) { - return std::wstring(); - } - - WCHAR temp[MAX_PATH]; - DWORD bufferSize = MAX_PATH; - - if (::RegQueryValueExW(key, L"Installed Path", nullptr, nullptr, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) { - return std::wstring(temp); - } else { - return std::wstring(); - } -} - - -std::vector Fallout3Info::getIniFileNames() const -{ - return boost::assign::list_of(L"fallout.ini")(L"falloutprefs.ini"); -} - -std::wstring Fallout3Info::getReferenceDataFile() const -{ - return L"Fallout - Meshes.bsa"; -} - -bool Fallout3Info::rerouteToProfile(const wchar_t *fileName, const wchar_t*) const -{ - static LPCWSTR profileFiles[] = { L"fallout.ini", L"falloutprefs.ini", L"plugins.txt", nullptr }; - - for (int i = 0; profileFiles[i] != nullptr; ++i) { - if (_wcsicmp(fileName, profileFiles[i]) == 0) { - return true; - } - } - return false; -} - -} // namespace MOShared diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h deleted file mode 100644 index 5cf98e3b..00000000 --- a/src/shared/fallout3info.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -Copyright (C) 2012 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer 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. - -Mod Organizer 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 Mod Organizer. If not, see . -*/ - -#ifndef FALLOUT3INFO_H -#define FALLOUT3INFO_H - -#include "gameinfo.h" - -namespace MOShared { - - -class Fallout3Info : public GameInfo -{ - - friend class GameInfo; - -public: - - virtual ~Fallout3Info() {} - - static std::wstring getRegPathStatic(); - virtual std::wstring getRegPath() const { return getRegPathStatic(); } - - // file name of this games ini (no path) - virtual std::vector getIniFileNames() const; - - virtual std::wstring getReferenceDataFile() const; - - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) const; - - virtual std::wstring archiveListKey() const { return L"SArchiveList"; } - -private: - - Fallout3Info(const std::wstring &gameDirectory); - - static bool identifyGame(const std::wstring &searchPath); - -}; - -} // namespace MOShared - -#endif // FALLOUT3INFO_H diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp deleted file mode 100644 index 6347224d..00000000 --- a/src/shared/falloutnvinfo.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright (C) 2012 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer 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. - -Mod Organizer 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 Mod Organizer. If not, see . -*/ - -#include "falloutnvinfo.h" -#include "util.h" -#include -#include -#include -#include "windows_error.h" -#include "error_report.h" -#define WIN32_LEAN_AND_MEAN -#include -#include - -namespace MOShared { - - -FalloutNVInfo::FalloutNVInfo(const std::wstring &gameDirectory) - : GameInfo(gameDirectory) -{ - identifyMyGamesDirectory(L"falloutnv"); -} - -bool FalloutNVInfo::identifyGame(const std::wstring &searchPath) -{ - return FileExists(searchPath, L"FalloutNV.exe") && - FileExists(searchPath, L"FalloutNVLauncher.exe"); -} - -std::wstring FalloutNVInfo::getRegPathStatic() -{ - HKEY key; - LONG errorcode = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Bethesda Softworks\\FalloutNV", - 0, KEY_QUERY_VALUE, &key); - - if (errorcode != ERROR_SUCCESS) { - return std::wstring(); - } - - WCHAR temp[MAX_PATH]; - DWORD bufferSize = MAX_PATH; - - if (::RegQueryValueExW(key, L"Installed Path", nullptr, nullptr, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) { - return std::wstring(temp); - } else { - return std::wstring(); - } -} - -std::vector FalloutNVInfo::getIniFileNames() const -{ - return boost::assign::list_of(L"fallout.ini")(L"falloutprefs.ini"); -} - -std::wstring FalloutNVInfo::getReferenceDataFile() const -{ - return L"Fallout - Meshes.bsa"; -} - -bool FalloutNVInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t*) const -{ - static LPCWSTR profileFiles[] = { L"fallout.ini", L"falloutprefs.ini", L"plugins.txt", nullptr }; - - for (int i = 0; profileFiles[i] != nullptr; ++i) { - if (_wcsicmp(fileName, profileFiles[i]) == 0) { - return true; - } - } - return false; -} - -} // namespace MOShared diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h deleted file mode 100644 index 04c13c7d..00000000 --- a/src/shared/falloutnvinfo.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -Copyright (C) 2012 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer 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. - -Mod Organizer 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 Mod Organizer. If not, see . -*/ - -#ifndef FALLOUTNVINFO_H -#define FALLOUTNVINFO_H - - -#include "gameinfo.h" - -namespace MOShared { - - -class FalloutNVInfo : public GameInfo -{ - - friend class GameInfo; - -public: - - virtual ~FalloutNVInfo() {} - - static std::wstring getRegPathStatic(); - virtual std::wstring getRegPath() const { return getRegPathStatic(); } - - // file name of this games ini (no path) - virtual std::vector getIniFileNames() const; - - virtual std::wstring getReferenceDataFile() const; - - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) const; - - virtual std::wstring archiveListKey() const { return L"SArchiveList"; } - -private: - - FalloutNVInfo(const std::wstring &gameDirectory); - - static bool identifyGame(const std::wstring &searchPath); -}; - -} // namespace MOShared - -#endif // FALLOUTNVINFO_H diff --git a/src/shared/gameinfo.cpp b/src/shared/gameinfo.cpp deleted file mode 100644 index 5c13a520..00000000 --- a/src/shared/gameinfo.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* -Copyright (C) 2012 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer 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. - -Mod Organizer 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 Mod Organizer. If not, see . -*/ - -#include "gameinfo.h" - -#include "windows_error.h" - -#include "oblivioninfo.h" -#include "fallout3info.h" -#include "falloutnvinfo.h" -#include "skyriminfo.h" -#include "util.h" - -#include -#include - -#include -#include -#include - -namespace MOShared { - - -GameInfo* GameInfo::s_Instance = nullptr; - - -GameInfo::GameInfo(const std::wstring &gameDirectory) - : m_GameDirectory(gameDirectory) -{ - atexit(&cleanup); -} - - -void GameInfo::cleanup() { - delete GameInfo::s_Instance; - GameInfo::s_Instance = nullptr; -} - - -void GameInfo::identifyMyGamesDirectory(const std::wstring &file) -{ - // this function attempts 3 (three!) ways to determine the correct "My Games" folder. - wchar_t myDocuments[MAX_PATH]; - memset(myDocuments, '\0', MAX_PATH * sizeof(wchar_t)); - - m_MyGamesDirectory.clear(); - - // a) this is the way it should work. get the configured My Documents\My Games directory - if (::SHGetFolderPathW(nullptr, CSIDL_PERSONAL, nullptr, SHGFP_TYPE_CURRENT, myDocuments) == S_OK) { - m_MyGamesDirectory = std::wstring(myDocuments) + L"\\My Games"; - } - - // b) if there is no directory there, look in the default directory - if (m_MyGamesDirectory.empty() - || !FileExists(m_MyGamesDirectory + L"\\" + file)) { - if (::SHGetFolderPathW(nullptr, CSIDL_PERSONAL, nullptr, SHGFP_TYPE_DEFAULT, myDocuments) == S_OK) { - std::wstring fromDefault = std::wstring(myDocuments) + L"\\My Games"; - if (FileExists(fromDefault + L"\\" + file)) { - m_MyGamesDirectory = fromDefault; - } - } - } - // c) finally, look in the registry. This is discouraged - if (m_MyGamesDirectory.empty() - || !FileExists(m_MyGamesDirectory + L"\\" + file)) { - std::wstring fromRegistry = getSpecialPath(L"Personal") + L"\\My Games"; - if (FileExists(fromRegistry + L"\\" + file)) { - m_MyGamesDirectory = fromRegistry; - } - } -} - -bool GameInfo::identifyGame(const std::wstring &searchPath) -{ - if (OblivionInfo::identifyGame(searchPath)) { - s_Instance = new OblivionInfo(searchPath); - } else if (Fallout3Info::identifyGame(searchPath)) { - s_Instance = new Fallout3Info(searchPath); - } else if (FalloutNVInfo::identifyGame(searchPath)) { - s_Instance = new FalloutNVInfo(searchPath); - } else if (SkyrimInfo::identifyGame(searchPath)) { - s_Instance = new SkyrimInfo(searchPath); - } - - return s_Instance != nullptr; -} - - -bool GameInfo::init(const std::wstring &moDirectory, const std::wstring &gamePath) -{ - if (s_Instance == nullptr) { - if (gamePath.length() == 0) { - // search upward in the directory until a recognized game-binary is found - std::wstring searchPath(moDirectory); - while (!identifyGame(searchPath)) { - size_t lastSep = searchPath.find_last_of(L"/\\"); - if (lastSep == std::string::npos) { - return false; - } - searchPath.erase(lastSep); - } - } else if (!identifyGame(gamePath)) { - return false; - } - } - return true; -} - - -GameInfo &GameInfo::instance() -{ - assert(s_Instance != nullptr && "gameinfo not yet initialized"); - return *s_Instance; -} - -std::wstring GameInfo::getGameDirectory() const -{ - return m_GameDirectory; -} - -std::wstring GameInfo::getSpecialPath(LPCWSTR name) const -{ - HKEY key; - LONG errorcode = ::RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders", - 0, KEY_QUERY_VALUE, &key); - - if (errorcode != ERROR_SUCCESS) { - throw windows_error("failed to look up special folder (path)", errorcode); - } - - WCHAR temp[MAX_PATH]; - DWORD bufferSize = MAX_PATH; - - errorcode = ::RegQueryValueExW(key, name, nullptr, nullptr, (LPBYTE)temp, &bufferSize); - if (errorcode != ERROR_SUCCESS) { - throw windows_error((boost::format("failed to look up special folder (%1%)") % ToString(name, true)).str(), errorcode); - } - - WCHAR temp2[MAX_PATH]; - // try to expand variables in the path, if any - if (::ExpandEnvironmentStringsW(temp, temp2, MAX_PATH) != 0) { - return temp2; - } else { - return temp; - } -} - -} // namespace MOShared diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h deleted file mode 100644 index 7bc86d3a..00000000 --- a/src/shared/gameinfo.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -Copyright (C) 2012 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer 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. - -Mod Organizer 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 Mod Organizer. If not, see . -*/ - -#ifndef GAMEINFO_H -#define GAMEINFO_H - -#include -#include -#include - -#define WIN32_LEAN_AND_MEAN -#include - -namespace MOShared { - - -/** - Class to manage information that depends on the used game type. The intention is to keep - as much of the rest of omo is game-agnostic. It is mostly concerned with figuring out the - correct paths, filenames and data types. -*/ -class GameInfo -{ - -public: - - virtual ~GameInfo() {} - - //**USED IN HOOKDLL and at startup to set up for hookdll to work - // initialise with the path to the mo directory (needs to be where hook.dll is stored). This - // needs to be called before the instance can be retrieved - static bool init(const std::wstring &moDirectory, const std::wstring &gamePath = L""); - - //**USED ONLY IN HOOKDLL - static GameInfo& instance(); - - //**USED ONLY IN HOOKDLL - virtual std::wstring getGameDirectory() const; - - //**USED ONLY IN HOOKDLL - virtual std::wstring getRegPath() const = 0; - - //**USED ONLY IN HOOKDLL - // file name of this games ini file(s) - virtual std::vector getIniFileNames() const = 0; - - //**USED ONLY IN HOOKDLL - virtual std::wstring getReferenceDataFile() const = 0; - - //**USED ONLY IN HOOKDLL - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) const = 0; - -protected: - - GameInfo(const std::wstring &gameDirectory); - - void identifyMyGamesDirectory(const std::wstring &file); - -private: - - static bool identifyGame(const std::wstring &searchPath); - std::wstring getSpecialPath(LPCWSTR name) const; - - static void cleanup(); - -private: - - static GameInfo *s_Instance; - - std::wstring m_MyGamesDirectory; - - std::wstring m_GameDirectory; - -}; - - -} // namespace MOShared - -#endif // GAMEINFO_H diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp deleted file mode 100644 index b50f1daa..00000000 --- a/src/shared/oblivioninfo.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright (C) 2012 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer 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. - -Mod Organizer 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 Mod Organizer. If not, see . -*/ - -#include "oblivioninfo.h" -#include -#include -#include "util.h" -#include -#include "windows_error.h" -#include "error_report.h" -#define WIN32_LEAN_AND_MEAN -#include -#include - -namespace MOShared { - - -OblivionInfo::OblivionInfo(const std::wstring &gameDirectory) - : GameInfo(gameDirectory) -{ - identifyMyGamesDirectory(L"oblivion"); -} - -bool OblivionInfo::identifyGame(const std::wstring &searchPath) -{ - return FileExists(searchPath, L"Oblivion.exe") && - FileExists(searchPath, L"OblivionLauncher.exe"); -} - -std::wstring OblivionInfo::getRegPathStatic() -{ - HKEY key; - LONG errorcode = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Bethesda Softworks\\Oblivion", - 0, KEY_QUERY_VALUE, &key); - - if (errorcode != ERROR_SUCCESS) { - return std::wstring(); - } - - WCHAR temp[MAX_PATH]; - DWORD bufferSize = MAX_PATH; - - if (::RegQueryValueExW(key, L"Installed Path", nullptr, nullptr, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) { - return std::wstring(temp); - } else { - return std::wstring(); - } -} - -std::vector OblivionInfo::getIniFileNames() const -{ - return boost::assign::list_of(L"oblivion.ini")(L"oblivionprefs.ini"); -} - -bool OblivionInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t*) const -{ - static LPCWSTR profileFiles[] = { L"oblivion.ini", L"oblivionprefs.ini", L"plugins.txt", nullptr }; - - for (int i = 0; profileFiles[i] != nullptr; ++i) { - if (_wcsicmp(fileName, profileFiles[i]) == 0) { - return true; - } - } - return false; -} - -std::wstring OblivionInfo::getReferenceDataFile() const -{ - return L"Oblivion - Meshes.bsa"; -} - -} // namespace MOShared diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h deleted file mode 100644 index bf0b2707..00000000 --- a/src/shared/oblivioninfo.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -Copyright (C) 2012 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer 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. - -Mod Organizer 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 Mod Organizer. If not, see . -*/ - -#ifndef OBLIVIONINFO_H -#define OBLIVIONINFO_H - -#include "gameinfo.h" - -namespace MOShared { - -class OblivionInfo : public GameInfo -{ - - friend class GameInfo; - -public: - - virtual ~OblivionInfo() {} - - static std::wstring getRegPathStatic(); - virtual std::wstring getRegPath() const { return getRegPathStatic(); } - - // file name of this games ini (no path) - virtual std::vector getIniFileNames() const; - - virtual std::wstring getReferenceDataFile() const; - - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) const; - - virtual std::wstring archiveListKey() const { return L"SArchiveList"; } - -private: - - OblivionInfo(const std::wstring &gameDirectory); - - static bool identifyGame(const std::wstring &searchPath); - -}; - -} // namespace MOShared - -#endif // OBLIVIONINFO_H diff --git a/src/shared/shared.pro b/src/shared/shared.pro index a64e781d..517e1e86 100644 --- a/src/shared/shared.pro +++ b/src/shared/shared.pro @@ -21,12 +21,7 @@ SOURCES += \ windows_error.cpp \ error_report.cpp \ directoryentry.cpp \ - gameinfo.cpp \ - oblivioninfo.cpp \ - fallout3info.cpp \ - falloutnvinfo.cpp \ util.cpp \ - skyriminfo.cpp \ appconfig.cpp \ leaktrace.cpp \ stackdata.cpp @@ -36,12 +31,7 @@ HEADERS += \ windows_error.h \ error_report.h \ directoryentry.h \ - gameinfo.h \ - oblivioninfo.h \ - fallout3info.h \ - falloutnvinfo.h \ util.h \ - skyriminfo.h \ appconfig.h \ appconfig.inc \ leaktrace.h \ diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp deleted file mode 100644 index 9662e66d..00000000 --- a/src/shared/skyriminfo.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* -Copyright (C) 2012 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer 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. - -Mod Organizer 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 Mod Organizer. If not, see . -*/ - -#include "skyriminfo.h" - -#include "util.h" -#include -#include -#include -#include "windows_error.h" -#include "error_report.h" -#define WIN32_LEAN_AND_MEAN -#include -#include -#include - -namespace MOShared { - - -SkyrimInfo::SkyrimInfo(const std::wstring &gameDirectory) - : GameInfo(gameDirectory) -{ - identifyMyGamesDirectory(L"skyrim"); - - wchar_t appDataPath[MAX_PATH]; - if (SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, appDataPath))) { - m_AppData = appDataPath; - } -} - -bool SkyrimInfo::identifyGame(const std::wstring &searchPath) -{ - return FileExists(searchPath, L"TESV.exe") && - FileExists(searchPath, L"SkyrimLauncher.exe"); -} - - - - -std::wstring SkyrimInfo::getRegPathStatic() -{ - HKEY key; - LONG errorcode = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Bethesda Softworks\\Skyrim", - 0, KEY_QUERY_VALUE, &key); - - if (errorcode != ERROR_SUCCESS) { - return std::wstring(); - } - - WCHAR temp[MAX_PATH]; - DWORD bufferSize = MAX_PATH; - - if (::RegQueryValueExW(key, L"Installed Path", nullptr, nullptr, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) { - return std::wstring(temp); - } else { - return std::wstring(); - } -} - -std::vector SkyrimInfo::getIniFileNames() const -{ - return boost::assign::list_of(L"skyrim.ini")(L"skyrimprefs.ini"); -} - -std::wstring SkyrimInfo::getReferenceDataFile() const -{ - return L"Skyrim - Meshes.bsa"; -} - -bool SkyrimInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) const -{ - static LPCWSTR profileFiles[] = { L"skyrim.ini", L"skyrimprefs.ini", L"loadorder.txt", nullptr }; - - for (int i = 0; profileFiles[i] != nullptr; ++i) { - if (_wcsicmp(fileName, profileFiles[i]) == 0) { - return true; - } - } - - if ((_wcsicmp(fileName, L"plugins.txt") == 0) && - (m_AppData.empty() || (StrStrIW(fullPath, m_AppData.c_str()) != nullptr))) { - return true; - } - - return false; -} - -} // namespace MOShared diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h deleted file mode 100644 index bd329403..00000000 --- a/src/shared/skyriminfo.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright (C) 2012 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer 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. - -Mod Organizer 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 Mod Organizer. If not, see . -*/ - -#ifndef SKYRIMINFO_H -#define SKYRIMINFO_H - - -#include "gameinfo.h" - -namespace MOShared { - - -class SkyrimInfo : public GameInfo -{ - - friend class GameInfo; - -public: - - virtual ~SkyrimInfo() {} - - static std::wstring getRegPathStatic(); - virtual std::wstring getRegPath() const { return getRegPathStatic(); } - - // file name of this games ini (no path) - virtual std::vector getIniFileNames() const; - - virtual std::wstring getReferenceDataFile() const; - - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) const; - -private: - - SkyrimInfo(const std::wstring &gameDirectory); - - static bool identifyGame(const std::wstring &searchPath); - -private: - - std::wstring m_AppData; - -}; - -} // namespace MOShared - -#endif // SKYRIMINFO_H -- cgit v1.3.1