From 495846534d560f825819b7ee391e8c461ce76e4f Mon Sep 17 00:00:00 2001 From: Tannin Date: Mon, 7 Dec 2015 20:09:34 +0100 Subject: - no longer displaying "not logged in". This was too confusing for some - fixed files missing from vfs if parent directory exists in real destination dir - implemented plugin api to access current profile - steam game detection now also works for 64-bit games - removed reference to archive tab from tutorial - usvfs log level is now taken from config - some cleanup --- src/CMakeLists.txt | 3 --- src/categories.cpp | 4 +++- src/mainwindow.cpp | 9 +++---- src/organizercore.cpp | 40 ++++++++++++++++++++++++++----- src/organizercore.h | 2 ++ src/organizerproxy.cpp | 5 ++++ src/organizerproxy.h | 3 +-- src/profile.h | 2 +- src/savegamegamebyro.h | 2 +- src/selfupdater.h | 2 ++ src/shared/fallout3info.cpp | 12 ---------- src/shared/fallout3info.h | 2 -- src/shared/fallout4info.cpp | 12 ---------- src/shared/fallout4info.h | 2 -- src/shared/falloutnvinfo.cpp | 13 ---------- src/shared/falloutnvinfo.h | 2 -- src/shared/gameinfo.cpp | 3 ++- src/shared/gameinfo.h | 2 -- src/shared/oblivioninfo.cpp | 12 ---------- src/shared/oblivioninfo.h | 2 -- src/shared/skyriminfo.cpp | 18 -------------- src/shared/skyriminfo.h | 2 -- src/spawn.cpp | 2 -- src/spawn.h | 2 +- src/tutorials/tutorial_firststeps_main.js | 36 ---------------------------- src/usvfsconnector.cpp | 12 +++++++++- 26 files changed, 66 insertions(+), 140 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 030c0f18..313f7506 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -279,9 +279,6 @@ SET(project_path "${default_project_path}" CACHE PATH "path to the other mo proj SET(lib_path "${project_path}/../../install/libs") -MESSAGE(STATUS ${lib_path}) -MESSAGE(STATUS ${project_path}) - INCLUDE_DIRECTORIES(${project_path}/uibase/src ${project_path}/bsatk/src ${project_path}/esptk/src diff --git a/src/categories.cpp b/src/categories.cpp index 400cc74b..f096a902 100644 --- a/src/categories.cpp +++ b/src/categories.cpp @@ -317,9 +317,11 @@ int CategoryFactory::getCategoryIndex(int ID) const int CategoryFactory::getCategoryID(const QString &name) const { - auto iter = std::find_if(m_Categories.begin(), m_Categories.end(), [name] (const Category &cat) -> bool { + auto iter = std::find_if(m_Categories.begin(), m_Categories.end(), + [name] (const Category &cat) -> bool { return cat.m_Name == name; }); + if (iter != m_Categories.end()) { return iter->m_ID; } else { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 71013c3c..a3a5bf38 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -355,9 +355,7 @@ void MainWindow::updateWindowTitle(const QString &accountName, bool premium) ToQString(GameInfo::instance().getGameName()), m_OrganizerCore.getVersion().displayString()); - if (accountName.isEmpty()) { - title.append(" (not logged in)"); - } else { + if (!accountName.isEmpty()) { title.append(QString(" (%1%2)").arg(accountName, premium ? "*" : "")); } @@ -582,7 +580,7 @@ bool MainWindow::errorReported(QString &logFile) int MainWindow::checkForProblems() { - int numProblems = 0; + size_t numProblems = 0; for (IPluginDiagnose *diagnose : m_PluginContainer.plugins()) { numProblems += diagnose->activeProblems().size(); } @@ -4184,10 +4182,9 @@ void MainWindow::on_bossButton_clicked() HANDLE stdOutWrite = INVALID_HANDLE_VALUE; HANDLE stdOutRead = INVALID_HANDLE_VALUE; createStdoutPipe(&stdOutRead, &stdOutWrite); + m_OrganizerCore.prepareVFS(); HANDLE loot = startBinary(QFileInfo(qApp->applicationDirPath() + "/loot/lootcli.exe"), parameters.join(" "), - m_OrganizerCore.currentProfile()->name(), - m_OrganizerCore.settings().logLevel(), qApp->applicationDirPath() + "/loot", true, stdOutWrite); diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 83d468ef..89cdd4e6 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -13,6 +13,7 @@ #include "nxmaccessmanager.h" #include #include +#include #include #include #include @@ -279,7 +280,9 @@ bool OrganizerCore::testForSteam() bool success = false; while (!success) { processIDs.reset(new DWORD[currentSize]); - if (!::EnumProcesses(processIDs.get(), currentSize * sizeof(DWORD), &bytesReturned)) { + if (!::EnumProcesses(processIDs.get(), + static_cast(currentSize) * sizeof(DWORD), + &bytesReturned)) { qWarning("failed to determine if steam is running"); return true; } @@ -532,6 +535,11 @@ void OrganizerCore::createDefaultProfile() } } +void OrganizerCore::prepareVFS() +{ + m_USVFS.updateMapping(fileMapping()); +} + void OrganizerCore::setCurrentProfile(const QString &profileName) { if ((m_CurrentProfile != nullptr) && @@ -991,7 +999,7 @@ HANDLE OrganizerCore::spawnBinaryDirect(const QFileInfo &binary, const QString & // TODO: should also pass arguments if (m_AboutToRun(binary.absoluteFilePath())) { m_USVFS.updateMapping(fileMapping()); - return startBinary(binary, arguments, profileName, m_Settings.logLevel(), currentDirectory, true); + return startBinary(binary, arguments, currentDirectory, true); } else { qDebug("start of \"%s\" canceled by plugin", qPrintable(binary.absoluteFilePath())); return INVALID_HANDLE_VALUE; @@ -1562,16 +1570,35 @@ void OrganizerCore::prepareStart() { std::vector OrganizerCore::fileMapping() { + // need to wait until directory structure + while (m_DirectoryUpdate) { + ::Sleep(100); + QCoreApplication::processEvents(); + } + IPluginGame *game = qApp->property("managed_game").value(); MappingType result = fileMapping( QDir::toNativeSeparators(game->dataDirectory().absolutePath()), "\\", directoryStructure(), directoryStructure()); + if (m_CurrentProfile->localSavesEnabled()) { + LocalSavegames *localSaves = game->feature(); + + if (localSaves != nullptr) { + MappingType saveMap = localSaves->mappings(currentProfile()->absolutePath() + "/saves"); + result.reserve(result.size() + saveMap.size()); + result.insert(result.end(), saveMap.begin(), saveMap.end()); + } + } + for (MOBase::IPluginFileMapper *mapper : m_PluginContainer->plugins()) { - MappingType pluginMap = mapper->mappings(); - result.reserve(result.size() + pluginMap.size()); - result.insert(result.end(), pluginMap.begin(), pluginMap.end()); + IPlugin *plugin = dynamic_cast(mapper); + if (plugin->isActive()) { + MappingType pluginMap = mapper->mappings(); + result.reserve(result.size() + pluginMap.size()); + result.insert(result.end(), pluginMap.begin(), pluginMap.end()); + } } return result; @@ -1607,9 +1634,10 @@ std::vector OrganizerCore::fileMapping( directoryEntry->getSubDirectories(current, end); for (; current != end; ++current) { int origin = (*current)->anyOrigin(); + /* if (origin == 0) { continue; - } + }*/ QString originPath = QString::fromStdWString(base->getOriginByID(origin).getPath()); diff --git a/src/organizercore.h b/src/organizercore.h index 1de1dfe8..74814461 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -126,6 +126,8 @@ public: MOBase::DelayedFileWriter &pluginsWriter() { return m_PluginListsWriter; } + void prepareVFS(); + public: MOBase::IGameInfo &gameInfo() const; MOBase::IModRepositoryBridge *createNexusBridge() const; diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index 095cb0bb..665b15d1 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -155,6 +155,11 @@ QList OrganizerProxy::findFileInfos(const QString return m_Proxied->findFileInfos(path, filter); } +MOBase::IProfile *OrganizerProxy::profile() +{ + return m_Proxied->currentProfile(); +} + MOBase::IDownloadManager *OrganizerProxy::downloadManager() { return m_Proxied->downloadManager(); diff --git a/src/organizerproxy.h b/src/organizerproxy.h index fb502a7f..029abcaf 100644 --- a/src/organizerproxy.h +++ b/src/organizerproxy.h @@ -34,6 +34,7 @@ public: virtual QStringList findFiles(const QString &path, const std::function &filter) const; virtual QStringList getFileOrigins(const QString &fileName) const; virtual QList findFileInfos(const QString &path, const std::function &filter) const; + virtual MOBase::IProfile *profile(); virtual MOBase::IDownloadManager *downloadManager(); virtual MOBase::IPluginList *pluginList(); @@ -46,7 +47,6 @@ public: virtual bool onFinishedRun(const std::function &func); virtual bool onModInstalled(const std::function &func); - private: OrganizerCore *m_Proxied; @@ -55,5 +55,4 @@ private: }; - #endif // ORGANIZERPROXY_H diff --git a/src/profile.h b/src/profile.h index 342b6fa0..249ef618 100644 --- a/src/profile.h +++ b/src/profile.h @@ -210,7 +210,7 @@ public: * * @return number of mods for which the profile has status information **/ - unsigned int numMods() const { return m_ModStatus.size(); } + size_t numMods() const { return m_ModStatus.size(); } /** * @return the number of mods that can be enabled and where the priority can be modified diff --git a/src/savegamegamebyro.h b/src/savegamegamebyro.h index 029d478f..af866666 100644 --- a/src/savegamegamebyro.h +++ b/src/savegamegamebyro.h @@ -70,7 +70,7 @@ public: /** * @return number of plugins that were enabled when the save game was created **/ - int numPlugins() const { return m_Plugins.size(); } + size_t numPlugins() const { return m_Plugins.size(); } /** * retrieve the name of one of the plugins that were enabled when the save game diff --git a/src/selfupdater.h b/src/selfupdater.h index 143b05cb..bb9804e8 100644 --- a/src/selfupdater.h +++ b/src/selfupdater.h @@ -29,6 +29,8 @@ along with Mod Organizer. If not, see . #include #include +#include + class NexusInterface; diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp index 0b369b50..a4b60410 100644 --- a/src/shared/fallout3info.cpp +++ b/src/shared/fallout3info.cpp @@ -107,16 +107,4 @@ int Fallout3Info::getNexusModIDStatic() return 16348; } -bool Fallout3Info::rerouteToProfile(const wchar_t *fileName, const wchar_t*) -{ - 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 index 0045581d..878adc2b 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -59,8 +59,6 @@ public: virtual int getNexusModID() { return getNexusModIDStatic(); } virtual int getNexusGameID() { return 120; } - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath); - // get a list of executables (game binary and known-to-work 3rd party tools). All of these are relative to // the game directory //virtual std::vector getExecutables(); diff --git a/src/shared/fallout4info.cpp b/src/shared/fallout4info.cpp index 81143731..c9229793 100644 --- a/src/shared/fallout4info.cpp +++ b/src/shared/fallout4info.cpp @@ -102,16 +102,4 @@ int Fallout4Info::getNexusModIDStatic() return 377160; } -bool Fallout4Info::rerouteToProfile(const wchar_t *fileName, const wchar_t*) -{ - static LPCWSTR profileFiles[] = { L"fallout4.ini", L"fallout4prefs.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/fallout4info.h b/src/shared/fallout4info.h index 98ce4092..4a28e867 100644 --- a/src/shared/fallout4info.h +++ b/src/shared/fallout4info.h @@ -59,8 +59,6 @@ public: virtual int getNexusModID() { return getNexusModIDStatic(); } virtual int getNexusGameID() { return 1151; } - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath); - // get a list of executables (game binary and known-to-work 3rd party tools). All of these are relative to // the game directory //virtual std::vector getExecutables(); diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp index 1203bd25..81a75af3 100644 --- a/src/shared/falloutnvinfo.cpp +++ b/src/shared/falloutnvinfo.cpp @@ -113,17 +113,4 @@ int FalloutNVInfo::getNexusModIDStatic() return 42572; } - -bool FalloutNVInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t*) -{ - 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 index e1a614d2..5712c2ba 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -92,8 +92,6 @@ public: virtual int getNexusModID() { return getNexusModIDStatic(); } virtual int getNexusGameID() { return 130; } - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath); - // get a list of executables (game binary and known-to-work 3rd party tools). All of these are relative to // the game directory //virtual std::vector getExecutables(); diff --git a/src/shared/gameinfo.cpp b/src/shared/gameinfo.cpp index db72653e..d9dd9bb1 100644 --- a/src/shared/gameinfo.cpp +++ b/src/shared/gameinfo.cpp @@ -140,7 +140,8 @@ std::wstring GameInfo::getGameDirectory() const bool GameInfo::requiresSteam() const { - return FileExists(getGameDirectory() + L"\\steam_api.dll"); + return FileExists(getGameDirectory() + L"\\steam_api.dll") + || FileExists(getGameDirectory() + L"\\steam_api64.dll"); } std::wstring GameInfo::getLocalAppFolder() const diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index 8ee8a8de..0e0052d7 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -91,8 +91,6 @@ public: virtual int getNexusModID() = 0; virtual int getNexusGameID() = 0; - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) = 0; - public: // initialise with the path to the mo directory (needs to be where hook.dll is stored). This diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp index 16748f58..c60f8911 100644 --- a/src/shared/oblivioninfo.cpp +++ b/src/shared/oblivioninfo.cpp @@ -125,18 +125,6 @@ int OblivionInfo::getNexusModIDStatic() return 38277; } -bool OblivionInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t*) -{ - 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() { return L"Oblivion - Meshes.bsa"; diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index 87ba26ff..1ef5b48e 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -90,8 +90,6 @@ public: virtual int getNexusModID() { return getNexusModIDStatic(); } virtual int getNexusGameID() { return 101; } - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath); - // get a list of executables (game binary and known-to-work 3rd party tools). All of these are relative to // the game directory //virtual std::vector getExecutables(); diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp index f66fcef4..acd72a3f 100644 --- a/src/shared/skyriminfo.cpp +++ b/src/shared/skyriminfo.cpp @@ -139,23 +139,5 @@ int SkyrimInfo::getNexusModIDStatic() return 1334; } -bool SkyrimInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) -{ - 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 index 5951f910..732b9261 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -64,8 +64,6 @@ public: static int getNexusGameIDStatic() { return 110; } virtual int getNexusGameID() { return getNexusGameIDStatic(); } - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath); - private: SkyrimInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory); diff --git a/src/spawn.cpp b/src/spawn.cpp index ad6707e3..14cdb4d4 100644 --- a/src/spawn.cpp +++ b/src/spawn.cpp @@ -126,8 +126,6 @@ static bool spawn(LPCWSTR binary, LPCWSTR arguments, LPCWSTR currentDirectory, HANDLE startBinary(const QFileInfo &binary, const QString &arguments, - const QString& profileName, - int logLevel, const QDir ¤tDirectory, bool hooked, HANDLE stdOut, diff --git a/src/spawn.h b/src/spawn.h index 63eda18d..c2d99bdb 100644 --- a/src/spawn.h +++ b/src/spawn.h @@ -60,7 +60,7 @@ private: * @todo is the profile name even used any more? * @todo is the hooked parameter used? **/ -HANDLE startBinary(const QFileInfo &binary, const QString &arguments, const QString &profileName, int logLevel, +HANDLE startBinary(const QFileInfo &binary, const QString &arguments, const QDir ¤tDirectory, bool hooked, HANDLE stdOut = INVALID_HANDLE_VALUE, HANDLE stdErr = INVALID_HANDLE_VALUE); diff --git a/src/tutorials/tutorial_firststeps_main.js b/src/tutorials/tutorial_firststeps_main.js index 2bc270d7..c47b5c0d 100644 --- a/src/tutorials/tutorial_firststeps_main.js +++ b/src/tutorials/tutorial_firststeps_main.js @@ -144,42 +144,6 @@ function getTutorialSteps() applicationWindow.modInfoDisplayed.connect(nextStep) }, - function() { - tutorial.text = qsTr("Another special type of files are BSAs. These are bundles of game resources. " - + "Please open the \"Archives\"-tab.") - if (tutorialControl.waitForTabOpen("tabWidget", 1)) { - highlightItem("tabWidget", true) - } else { - waitForClick() - } - }, - - function() { - tutorial.text = qsTr("These archives can be a real headache because the way bsas interact " - + "with non-bundled resources is complicated. The game can even crash if required " - + "archives are not loaded or ordered incorrectly.") - waitForClick() - }, - - function() { - tutorial.text = qsTr("MO applies some \"magic\" to make all BSAs that are checked in this list load in " - + "the correct order interleaved with the non-bundled resources.") - waitForClick() - }, - - function() { - tutorial.text = qsTr("You can disable this magic to make MO behave more like other tools. In this case " - + "their load order follows that of the corresponding plugin (.esp).") - highlightItem("managedArchiveLabel", false) - waitForClick() - }, - - function() { - tutorial.text = qsTr("Many BSAs will appear grayed out and enabled. These mods are loaded by the game engine " - + "automatically so they can't be disabled here.") - waitForClick() - }, - function() { tutorial.text = qsTr("Now you know how to download, install and enable mods.\n" + "It's important you always start the game from inside MO, otherwise " diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp index a29d806e..23a51891 100644 --- a/src/usvfsconnector.cpp +++ b/src/usvfsconnector.cpp @@ -19,6 +19,7 @@ along with Mod Organizer. If not, see . #include "usvfsconnector.h" +#include "settings.h" #include #include #include @@ -84,12 +85,21 @@ void LogWorker::process() void LogWorker::exit() { m_QuitRequested = true; +} +LogLevel logLevel(int level) +{ + switch (level) { + case LogLevel::Info: return LogLevel::Info; + case LogLevel::Warning: return LogLevel::Warning; + case LogLevel::Error: return LogLevel::Error; + default: return LogLevel::Debug; + } } UsvfsConnector::UsvfsConnector() { - usvfs::Parameters params(SHMID, false, LogLevel::Debug); + usvfs::Parameters params(SHMID, false, logLevel(Settings::instance().logLevel())); InitLogging(false); ConnectVFS(¶ms); -- cgit v1.3.1