From 7f4f4cafea5a196ddf824adf7c4e65cec5d44d88 Mon Sep 17 00:00:00 2001
From: Tannin
Date: Tue, 17 Nov 2015 18:58:00 +0100
Subject: first work on interfacing with usvfs
---
src/spawn.cpp | 46 +++++++++++++++++++++++++++++-----------------
1 file changed, 29 insertions(+), 17 deletions(-)
(limited to 'src/spawn.cpp')
diff --git a/src/spawn.cpp b/src/spawn.cpp
index c79714bb..ad6707e3 100644
--- a/src/spawn.cpp
+++ b/src/spawn.cpp
@@ -24,6 +24,7 @@ along with Mod Organizer. If not, see .
#include
#include
#include
+#include
#include
#include
#include
@@ -37,7 +38,8 @@ using namespace MOShared;
static const int BUFSIZE = 4096;
-static bool spawn(LPCWSTR binary, LPCWSTR arguments, LPCWSTR currentDirectory, bool suspended,
+static bool spawn(LPCWSTR binary, LPCWSTR arguments, LPCWSTR currentDirectory,
+ bool suspended, bool hooked,
HANDLE stdOut, HANDLE stdErr,
HANDLE& processHandle, HANDLE& threadHandle)
{
@@ -85,15 +87,28 @@ static bool spawn(LPCWSTR binary, LPCWSTR arguments, LPCWSTR currentDirectory, b
}
PROCESS_INFORMATION pi;
- BOOL success = ::CreateProcess(nullptr,
- commandLine,
- nullptr, nullptr, // no special process or thread attributes
- inheritHandles, // inherit handles if we plan to use stdout or stderr reroute
- CREATE_BREAKAWAY_FROM_JOB | (suspended ? CREATE_SUSPENDED : 0), // create suspended so I have time to inject the DLL
- nullptr, // same environment as parent
- currentDirectory, // current directory
- &si, &pi // startup and process information
- );
+ BOOL success = FALSE;
+ if (hooked) {
+ success = ::CreateProcessHooked(nullptr,
+ commandLine,
+ nullptr, nullptr, // no special process or thread attributes
+ inheritHandles, // inherit handles if we plan to use stdout or stderr reroute
+ CREATE_BREAKAWAY_FROM_JOB,
+ nullptr, // same environment as parent
+ currentDirectory, // current directory
+ &si, &pi // startup and process information
+ );
+ } else {
+ success = ::CreateProcess(nullptr,
+ commandLine,
+ nullptr, nullptr, // no special process or thread attributes
+ inheritHandles, // inherit handles if we plan to use stdout or stderr reroute
+ CREATE_BREAKAWAY_FROM_JOB,
+ nullptr, // same environment as parent
+ currentDirectory, // current directory
+ &si, &pi // startup and process information
+ );
+ }
::SetEnvironmentVariable(TEXT("PATH"), oldPath.get());
@@ -136,8 +151,8 @@ HANDLE startBinary(const QFileInfo &binary,
std::wstring currentDirectoryName = ToWString(QDir::toNativeSeparators(currentDirectory.absolutePath()));
try {
- if (!spawn(binaryName.c_str(), ToWString(arguments).c_str(), currentDirectoryName.c_str(), true,
- stdOut, stdErr, processHandle, threadHandle)) {
+ if (!spawn(binaryName.c_str(), ToWString(arguments).c_str(), currentDirectoryName.c_str(),
+ true, hooked, stdOut, stdErr, processHandle, threadHandle)) {
reportError(QObject::tr("failed to spawn \"%1\"").arg(binary.fileName()));
return INVALID_HANDLE_VALUE;
}
@@ -165,7 +180,7 @@ HANDLE startBinary(const QFileInfo &binary,
return INVALID_HANDLE_VALUE;
}
}
-
+/*
if (hooked) {
try {
QFileInfo dllInfo(QApplication::applicationDirPath() + "/" + ToQString(AppConfig::hookDLLName()));
@@ -185,6 +200,7 @@ HANDLE startBinary(const QFileInfo &binary,
reportError("ready?");
#endif // DEBUG
}
+ */
if (::AssignProcessToJobObject(jobObject, processHandle) == 0) {
qWarning("failed to assign to job object: %lu", ::GetLastError());
@@ -194,10 +210,6 @@ HANDLE startBinary(const QFileInfo &binary,
::CloseHandle(processHandle);
}
- if (::ResumeThread(threadHandle) == (DWORD)-1) {
- reportError(QObject::tr("failed to run \"%1\"").arg(binary.fileName()));
- return INVALID_HANDLE_VALUE;
- }
::CloseHandle(threadHandle);
return jobObject;
}
--
cgit v1.3.1
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/spawn.cpp')
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
From 8d1dd6238f8d754aef1385409f4f97273a0d226f Mon Sep 17 00:00:00 2001
From: Tannin
Date: Tue, 9 Feb 2016 20:54:54 +0100
Subject: fixed display of process name in unlock-widget
---
src/organizercore.cpp | 63 +++++++++++++++++++++++++++++++++------------------
src/spawn.cpp | 44 +----------------------------------
2 files changed, 42 insertions(+), 65 deletions(-)
(limited to 'src/spawn.cpp')
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index d39235f5..ecadfb5d 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -978,40 +978,59 @@ void OrganizerCore::spawnBinary(const QFileInfo &binary,
QCoreApplication::processEvents();
DWORD processExitCode;
- DWORD retLen;
- JOBOBJECT_BASIC_PROCESS_ID_LIST info;
+
+ dialog->setProcessName(
+ QString::fromStdWString(getProcessName(::GetProcessId(processHandle))));
{
DWORD currentProcess = 0UL;
- bool isJobHandle = true;
-
- DWORD res = ::MsgWaitForMultipleObjects(1, &processHandle, false, 1000, QS_KEY | QS_MOUSE);
- while ((res != WAIT_FAILED) && (res != WAIT_OBJECT_0) && !dialog->unlockClicked()) {
- if (isJobHandle) {
- if (::QueryInformationJobObject(processHandle, JobObjectBasicProcessIdList, &info, sizeof(info), &retLen) > 0) {
- if (info.NumberOfProcessIdsInList == 0) {
- break;
- } else {
- if (info.ProcessIdList[0] != currentProcess) {
- currentProcess = info.ProcessIdList[0];
- dialog->setProcessName(ToQString(getProcessName(currentProcess)));
+
+ DWORD res = ::MsgWaitForMultipleObjects(1, &processHandle, false, 1000,
+ QS_KEY | QS_MOUSE);
+ bool tryAgain = true;
+ while ((res != WAIT_FAILED) && !dialog->unlockClicked()) {
+ if (res == WAIT_OBJECT_0) {
+ // process ended, is there another one in the group?
+ static const DWORD maxCount = 5;
+ size_t numProcesses = maxCount;
+ LPDWORD processes = new DWORD[maxCount];
+ if (::GetVFSProcessList(&numProcesses, processes)) {
+ bool found = false;
+ for (size_t i = 0; i < std::min(maxCount, numProcesses);
+ ++i) {
+ std::wstring processName = getProcessName(processes[i]);
+ if (!boost::starts_with(processName, L"ModOrganizer.exe")) {
+ currentProcess = processes[i];
+ dialog->setProcessName(QString::fromStdWString(processName));
+ processHandle
+ = ::OpenProcess(SYNCHRONIZE, FALSE, currentProcess);
+ found = true;
}
}
- } else {
- // the info-object I passed only provides space for 1 process id. but since this code only cares about whether there
- // is more than one that's good enough. ERROR_MORE_DATA simply signals there are at least two processes running.
- // any other error probably means the handle is a regular process handle, probably caused by running MO in a job without
- // the right to break out.
- if (::GetLastError() != ERROR_MORE_DATA) {
- isJobHandle = false;
+ if (!found) {
+ // it's possible the previous process has deregistered before
+ // the new one has registered, so we should try one more time
+ // with a little delay
+ if (tryAgain) {
+ tryAgain = false;
+ QThread::msleep(500);
+ continue;
+ } else {
+ break;
+ }
+ } else {
+ tryAgain = true;
}
+ } else {
+ break;
}
}
// keep processing events so the app doesn't appear dead
QCoreApplication::processEvents();
- res = ::MsgWaitForMultipleObjects(1, &processHandle, false, 1000, QS_KEY | QS_MOUSE);
+ res = ::MsgWaitForMultipleObjects(1, &processHandle, false, 1000,
+ QS_KEY | QS_MOUSE);
}
::GetExitCodeProcess(processHandle, &processExitCode);
diff --git a/src/spawn.cpp b/src/spawn.cpp
index 19cf304c..fc0b448a 100644
--- a/src/spawn.cpp
+++ b/src/spawn.cpp
@@ -134,19 +134,6 @@ HANDLE startBinary(const QFileInfo &binary,
HANDLE stdOut,
HANDLE stdErr)
{
- JOBOBJECT_EXTENDED_LIMIT_INFORMATION jobInfo;
-
- ::QueryInformationJobObject(nullptr, JobObjectExtendedLimitInformation, &jobInfo, sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION), nullptr);
- jobInfo.BasicLimitInformation.LimitFlags |= JOB_OBJECT_LIMIT_BREAKAWAY_OK;
-
- HANDLE jobObject = ::CreateJobObject(nullptr, nullptr);
-
- if (jobObject == nullptr) {
- qWarning("failed to create job object: %lu", ::GetLastError());
- } else {
- ::SetInformationJobObject(jobObject, JobObjectExtendedLimitInformation, &jobInfo, sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION));
- }
-
HANDLE processHandle, threadHandle;
std::wstring binaryName = ToWString(QDir::toNativeSeparators(binary.absoluteFilePath()));
std::wstring currentDirectoryName = ToWString(QDir::toNativeSeparators(currentDirectory.absolutePath()));
@@ -181,36 +168,7 @@ HANDLE startBinary(const QFileInfo &binary,
return INVALID_HANDLE_VALUE;
}
}
-/*
- if (hooked) {
- try {
- QFileInfo dllInfo(QApplication::applicationDirPath() + "/" + ToQString(AppConfig::hookDLLName()));
- if (!dllInfo.exists()) {
- reportError(QObject::tr("\"%1\" doesn't exist").arg(dllInfo.fileName()));
- return INVALID_HANDLE_VALUE;
- }
- injectDLL(processHandle, threadHandle,
- QDir::toNativeSeparators(dllInfo.canonicalFilePath()).toLocal8Bit().constData(),
- ToWString(profileName).c_str(), logLevel);
- } catch (const windows_error& e) {
- reportError(QObject::tr("failed to inject dll into \"%1\": %2").arg(binary.fileName()).arg(e.what()));
- ::TerminateProcess(processHandle, 1);
- return INVALID_HANDLE_VALUE;
- }
-#ifdef _DEBUG
- reportError("ready?");
-#endif // DEBUG
- }
- */
-
- if (::AssignProcessToJobObject(jobObject, processHandle) == 0) {
- qWarning("failed to assign to job object: %lu", ::GetLastError());
- ::CloseHandle(jobObject);
- jobObject = processHandle;
- } else {
- ::CloseHandle(processHandle);
- }
::CloseHandle(threadHandle);
- return jobObject;
+ return processHandle;
}
--
cgit v1.3.1
From fd68248698357591f99c3091d5b15a3084fc078d Mon Sep 17 00:00:00 2001
From: Tannin
Date: Tue, 9 Feb 2016 20:57:20 +0100
Subject: fixed browse-button for mod directory (in settings)
---
src/settingsdialog.cpp | 10 +++++++++-
src/settingsdialog.h | 3 +++
src/settingsdialog.ui | 2 +-
src/spawn.cpp | 2 +-
4 files changed, 14 insertions(+), 3 deletions(-)
(limited to 'src/spawn.cpp')
diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp
index 341fa19d..5b58c9da 100644
--- a/src/settingsdialog.cpp
+++ b/src/settingsdialog.cpp
@@ -110,7 +110,7 @@ void SettingsDialog::on_browseDownloadDirBtn_clicked()
void SettingsDialog::on_browseModDirBtn_clicked()
{
- QString temp = QFileDialog::getExistingDirectory(this, tr("Select mod directory"), ui->downloadDirEdit->text());
+ QString temp = QFileDialog::getExistingDirectory(this, tr("Select mod directory"), ui->modDirEdit->text());
if (!temp.isEmpty()) {
ui->modDirEdit->setText(temp);
}
@@ -124,6 +124,14 @@ void SettingsDialog::on_browseCacheDirBtn_clicked()
}
}
+void SettingsDialog::on_browseProfilesDirBtn_clicked()
+{
+ QString temp = QFileDialog::getExistingDirectory(this, tr("Select profiles directory"), ui->profilesDirEdit->text());
+ if (!temp.isEmpty()) {
+ ui->profilesDirEdit->setText(temp);
+ }
+}
+
void SettingsDialog::on_resetDialogsButton_clicked()
{
if (QMessageBox::question(this, tr("Confirm?"),
diff --git a/src/settingsdialog.h b/src/settingsdialog.h
index 8bd080ab..d1a566b1 100644
--- a/src/settingsdialog.h
+++ b/src/settingsdialog.h
@@ -52,6 +52,9 @@ signals:
void resetDialogs();
+private slots:
+ void on_browseProfilesDirBtn_clicked();
+
private slots:
void on_changeInstanceButton_clicked();
diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui
index 805a5060..f54ab895 100644
--- a/src/settingsdialog.ui
+++ b/src/settingsdialog.ui
@@ -660,7 +660,7 @@ p, li { white-space: pre-wrap; }
false
- 100
+ 170
diff --git a/src/spawn.cpp b/src/spawn.cpp
index fc0b448a..0ff64af0 100644
--- a/src/spawn.cpp
+++ b/src/spawn.cpp
@@ -60,7 +60,7 @@ static bool spawn(LPCWSTR binary, LPCWSTR arguments, LPCWSTR currentDirectory,
si.dwFlags |= STARTF_USESTDHANDLES;
}
si.cb = sizeof(si);
- int length = wcslen(binary) + wcslen(arguments) + 4;
+ size_t length = wcslen(binary) + wcslen(arguments) + 4;
wchar_t *commandLine = nullptr;
if (arguments[0] != L'\0') {
commandLine = new wchar_t[length];
--
cgit v1.3.1
From 986330a3bd8e0a4717a0a1aa26f4acd2c04de1ac Mon Sep 17 00:00:00 2001
From: Tannin
Date: Mon, 16 May 2016 16:03:36 +0200
Subject: removed obsolete stuff
---
src/main.cpp | 1 -
src/pluginlist.cpp | 1 -
src/shared/fallout3info.cpp | 71 ------------------
src/shared/fallout3info.h | 55 --------------
src/shared/fallout4info.cpp | 100 --------------------------
src/shared/fallout4info.h | 75 -------------------
src/shared/falloutnvinfo.cpp | 71 ------------------
src/shared/falloutnvinfo.h | 53 --------------
src/shared/gameinfo.cpp | 167 -------------------------------------------
src/shared/gameinfo.h | 89 -----------------------
src/shared/oblivioninfo.cpp | 71 ------------------
src/shared/oblivioninfo.h | 54 --------------
src/shared/skyriminfo.cpp | 81 ---------------------
src/shared/skyriminfo.h | 58 ---------------
src/spawn.cpp | 1 -
15 files changed, 948 deletions(-)
delete mode 100644 src/shared/fallout3info.cpp
delete mode 100644 src/shared/fallout3info.h
delete mode 100644 src/shared/fallout4info.cpp
delete mode 100644 src/shared/fallout4info.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/spawn.cpp')
diff --git a/src/main.cpp b/src/main.cpp
index 3cced2a1..6940e288 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -27,7 +27,6 @@ along with Mod Organizer. If not, see .
#include
#include
-#include
#include
#include
#include
diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp
index 5c21d0c8..8d37ab82 100644
--- a/src/pluginlist.cpp
+++ b/src/pluginlist.cpp
@@ -18,7 +18,6 @@ along with Mod Organizer. If not, see .
*/
#include "pluginlist.h"
-#include "inject.h"
#include "settings.h"
#include "scopeguard.h"
#include "modinfo.h"
diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp
deleted file mode 100644
index 446d4afe..00000000
--- a/src/shared/fallout3info.cpp
+++ /dev/null
@@ -1,71 +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");
-}
-
-} // namespace MOShared
diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h
deleted file mode 100644
index 601fc346..00000000
--- a/src/shared/fallout3info.h
+++ /dev/null
@@ -1,55 +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 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/fallout4info.cpp b/src/shared/fallout4info.cpp
deleted file mode 100644
index aab431ad..00000000
--- a/src/shared/fallout4info.cpp
+++ /dev/null
@@ -1,100 +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 "fallout4info.h"
-#include "util.h"
-#include
-#include
-#include
-#include "windows_error.h"
-#include "error_report.h"
-#define WIN32_LEAN_AND_MEAN
-#include
-#include
-
-namespace MOShared {
-
-Fallout4Info::Fallout4Info(const std::wstring &gameDirectory)
- : GameInfo(gameDirectory)
-{
- identifyMyGamesDirectory(L"fallout4");
-}
-
-bool Fallout4Info::identifyGame(const std::wstring &searchPath)
-{
- return FileExists(searchPath, L"Fallout4.exe") &&
- FileExists(searchPath, L"Fallout4Launcher.exe");
-}
-
-std::wstring Fallout4Info::getRegPathStatic()
-{
- HKEY key;
- LONG errorcode = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Bethesda Softworks\\Fallout4",
- 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 Fallout4Info::getDLCPlugins()
-{
- return std::vector();
-}
-
-std::vector Fallout4Info::getSavegameAttachmentExtensions()
-{
- return std::vector();
-}
-
-std::vector Fallout4Info::getIniFileNames() const
-{
- return boost::assign::list_of(L"fallout4.ini")(L"fallout4prefs.ini");
-}
-
-std::wstring Fallout4Info::getNexusPage(bool nmmScheme)
-{
- if (nmmScheme) {
- return L"http://nmm.nexusmods.com/fallout4";
- } else {
- return L"http://www.nexusmods.com/fallout4";
- }
-}
-
-std::wstring Fallout4Info::getNexusInfoUrlStatic()
-{
- return L"http://nmm.nexusmods.com/fallout4";
-}
-
-int Fallout4Info::getNexusModIDStatic()
-{
- return 377160;
-}
-
-} // namespace MOShared
diff --git a/src/shared/fallout4info.h b/src/shared/fallout4info.h
deleted file mode 100644
index 70c9b7d3..00000000
--- a/src/shared/fallout4info.h
+++ /dev/null
@@ -1,75 +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 FALLOUT4INFO_H
-#define FALLOUT4INFO_H
-
-
-#include "gameinfo.h"
-
-namespace MOShared {
-
-
-class Fallout4Info : public GameInfo
-{
-
- friend class GameInfo;
-
-public:
-
- virtual ~Fallout4Info() {}
-
- static std::wstring getRegPathStatic();
- virtual std::wstring getRegPath() const { return getRegPathStatic(); }
- virtual std::wstring getBinaryName() { return L"Fallout4.exe"; }
-
- virtual std::wstring getGameName() const { return L"Fallout 4"; }
- virtual std::wstring getGameShortName() const { return L"Fallout4"; }
-
- virtual std::vector getDLCPlugins();
- virtual std::vector getSavegameAttachmentExtensions();
-
- // file name of this games ini (no path)
- virtual std::vector getIniFileNames() const;
-
- virtual std::wstring getNexusPage(bool nmmScheme = true);
- static std::wstring getNexusInfoUrlStatic();
- virtual std::wstring getNexusInfoUrl() { return getNexusInfoUrlStatic(); }
- static int getNexusModIDStatic();
- virtual int getNexusModID() { return getNexusModIDStatic(); }
- virtual int getNexusGameID() { return 1151; }
-
- // 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();
-
- virtual std::wstring archiveListKey() { return L"SArchiveList"; }
-
-private:
-
- Fallout4Info(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 510dfa01..00000000
--- a/src/shared/falloutnvinfo.cpp
+++ /dev/null
@@ -1,71 +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");
-}
-
-} // namespace MOShared
diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h
deleted file mode 100644
index a9b3b9ec..00000000
--- a/src/shared/falloutnvinfo.h
+++ /dev/null
@@ -1,53 +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;
-
-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 9b097053..00000000
--- a/src/shared/gameinfo.cpp
+++ /dev/null
@@ -1,167 +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 "fallout4info.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);
- } else if (Fallout4Info::identifyGame(searchPath)) {
- s_Instance = new Fallout4Info(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 c99ebef7..00000000
--- a/src/shared/gameinfo.h
+++ /dev/null
@@ -1,89 +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;
-
-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 b290fb36..00000000
--- a/src/shared/oblivioninfo.cpp
+++ /dev/null
@@ -1,71 +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");
-}
-
-} // namespace MOShared
diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h
deleted file mode 100644
index 6609921a..00000000
--- a/src/shared/oblivioninfo.h
+++ /dev/null
@@ -1,54 +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 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/skyriminfo.cpp b/src/shared/skyriminfo.cpp
deleted file mode 100644
index fbe13ae0..00000000
--- a/src/shared/skyriminfo.cpp
+++ /dev/null
@@ -1,81 +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");
-}
-
-} // namespace MOShared
diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h
deleted file mode 100644
index a13b834e..00000000
--- a/src/shared/skyriminfo.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 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;
-
-private:
-
- SkyrimInfo(const std::wstring &gameDirectory);
-
- static bool identifyGame(const std::wstring &searchPath);
-
-private:
-
- std::wstring m_AppData;
-
-};
-
-} // namespace MOShared
-
-#endif // SKYRIMINFO_H
diff --git a/src/spawn.cpp b/src/spawn.cpp
index 0ff64af0..ac8ccf30 100644
--- a/src/spawn.cpp
+++ b/src/spawn.cpp
@@ -22,7 +22,6 @@ along with Mod Organizer. If not, see .
#include "report.h"
#include "utility.h"
#include
-#include
#include
#include
#include
--
cgit v1.3.1
From 5e5c9c07291f6b09623d31c92b1fb61c4ede576e Mon Sep 17 00:00:00 2001
From: Sandro Jäckel
Date: Thu, 22 Feb 2018 16:54:34 +0100
Subject: Applied clang-format on source
---
.clang-format | 11 +
src/aboutdialog.cpp | 95 +-
src/aboutdialog.h | 44 +-
src/activatemodsdialog.cpp | 99 +-
src/activatemodsdialog.h | 58 +-
src/bbcode.cpp | 415 +-
src/bbcode.h | 7 +-
src/browserdialog.cpp | 370 +-
src/browserdialog.h | 110 +-
src/browserview.cpp | 77 +-
src/browserview.h | 67 +-
src/categories.cpp | 516 ++-
src/categories.h | 306 +-
src/categoriesdialog.cpp | 320 +-
src/categoriesdialog.h | 46 +-
src/credentialsdialog.cpp | 32 +-
src/credentialsdialog.h | 21 +-
src/csvbuilder.cpp | 345 +-
src/csvbuilder.h | 99 +-
src/descriptionpage.h | 14 +-
src/directoryrefresher.cpp | 203 +-
src/directoryrefresher.h | 200 +-
src/downloadlist.cpp | 123 +-
src/downloadlist.h | 96 +-
src/downloadlistsortproxy.cpp | 71 +-
src/downloadlistsortproxy.h | 27 +-
src/downloadlistwidget.cpp | 482 +--
src/downloadlistwidget.h | 103 +-
src/downloadlistwidgetcompact.cpp | 455 +--
src/downloadlistwidgetcompact.h | 114 +-
src/downloadmanager.cpp | 2325 +++++------
src/downloadmanager.h | 837 ++--
src/editexecutablesdialog.cpp | 459 +--
src/editexecutablesdialog.h | 91 +-
src/eventfilter.cpp | 14 +-
src/eventfilter.h | 16 +-
src/executableslist.cpp | 253 +-
src/executableslist.h | 273 +-
src/filedialogmemory.cpp | 106 +-
src/filedialogmemory.h | 37 +-
src/gameinfoimpl.cpp | 49 +-
src/genericicondelegate.cpp | 44 +-
src/genericicondelegate.h | 45 +-
src/helper.cpp | 90 +-
src/helper.h | 13 +-
src/icondelegate.cpp | 71 +-
src/icondelegate.h | 22 +-
src/ilockedwaitingforprocess.h | 7 +-
src/installationmanager.cpp | 1334 +++---
src/installationmanager.h | 303 +-
src/instancemanager.cpp | 410 +-
src/instancemanager.h | 46 +-
src/iuserinterface.h | 35 +-
src/json.cpp | 823 ++--
src/json.h | 105 +-
src/loadmechanism.cpp | 454 +--
src/loadmechanism.h | 119 +-
src/lockeddialog.cpp | 64 +-
src/lockeddialog.h | 21 +-
src/lockeddialogbase.cpp | 65 +-
src/lockeddialogbase.h | 32 +-
src/logbuffer.cpp | 337 +-
src/logbuffer.h | 78 +-
src/loghighlighter.cpp | 47 +-
src/loghighlighter.h | 9 +-
src/main.cpp | 1052 +++--
src/mainwindow.cpp | 8136 ++++++++++++++++++-------------------
src/mainwindow.h | 691 ++--
src/messagedialog.cpp | 107 +-
src/messagedialog.h | 46 +-
src/moapplication.cpp | 175 +-
src/moapplication.h | 19 +-
src/modeltest.cpp | 496 ++-
src/modeltest.h | 62 +-
src/modflagicondelegate.cpp | 142 +-
src/modflagicondelegate.h | 17 +-
src/modinfo.cpp | 512 ++-
src/modinfo.h | 1111 +++--
src/modinfobackup.cpp | 22 +-
src/modinfobackup.h | 49 +-
src/modinfodialog.cpp | 1832 ++++-----
src/modinfodialog.h | 313 +-
src/modinfoforeign.cpp | 76 +-
src/modinfoforeign.h | 100 +-
src/modinfooverwrite.cpp | 75 +-
src/modinfooverwrite.h | 82 +-
src/modinforegular.cpp | 878 ++--
src/modinforegular.h | 622 ++-
src/modinfowithconflictinfo.cpp | 184 +-
src/modinfowithconflictinfo.h | 62 +-
src/modlist.cpp | 1891 +++++----
src/modlist.h | 432 +-
src/modlistsortproxy.cpp | 646 ++-
src/modlistsortproxy.h | 134 +-
src/modlistview.cpp | 67 +-
src/modlistview.h | 22 +-
src/moshortcut.cpp | 26 +-
src/moshortcut.h | 23 +-
src/motddialog.cpp | 27 +-
src/motddialog.h | 19 +-
src/nexusinterface.cpp | 943 ++---
src/nexusinterface.h | 700 ++--
src/noeditdelegate.cpp | 9 +-
src/noeditdelegate.h | 6 +-
src/nxmaccessmanager.cpp | 478 +--
src/nxmaccessmanager.h | 131 +-
src/organizercore.cpp | 3491 ++++++++--------
src/organizercore.h | 408 +-
src/organizerproxy.cpp | 187 +-
src/organizerproxy.h | 93 +-
src/overwriteinfodialog.cpp | 340 +-
src/overwriteinfodialog.h | 53 +-
src/persistentcookiejar.cpp | 96 +-
src/persistentcookiejar.h | 19 +-
src/plugincontainer.cpp | 502 ++-
src/plugincontainer.h | 115 +-
src/pluginlist.cpp | 1866 ++++-----
src/pluginlist.h | 501 ++-
src/pluginlistsortproxy.cpp | 137 +-
src/pluginlistsortproxy.h | 44 +-
src/pluginlistview.cpp | 66 +-
src/pluginlistview.h | 22 +-
src/previewdialog.cpp | 66 +-
src/previewdialog.h | 24 +-
src/previewgenerator.cpp | 40 +-
src/previewgenerator.h | 24 +-
src/problemsdialog.cpp | 104 +-
src/problemsdialog.h | 30 +-
src/profile.cpp | 1180 +++---
src/profile.h | 569 ++-
src/profileinputdialog.cpp | 28 +-
src/profileinputdialog.h | 19 +-
src/profilesdialog.cpp | 460 +--
src/profilesdialog.h | 81 +-
src/qtgroupingproxy.cpp | 1651 ++++----
src/qtgroupingproxy.h | 235 +-
src/queryoverwritedialog.cpp | 51 +-
src/queryoverwritedialog.h | 39 +-
src/savetextasdialog.cpp | 54 +-
src/savetextasdialog.h | 21 +-
src/selectiondialog.cpp | 107 +-
src/selectiondialog.h | 54 +-
src/selfupdater.cpp | 412 +-
src/selfupdater.h | 142 +-
src/serverinfo.h | 13 +-
src/settings.cpp | 1491 ++++---
src/settings.h | 846 ++--
src/settingsdialog.cpp | 319 +-
src/settingsdialog.h | 53 +-
src/shared/appconfig.cpp | 4 +-
src/shared/appconfig.h | 4 +-
src/shared/directoryentry.cpp | 1332 +++---
src/shared/directoryentry.h | 405 +-
src/shared/error_report.cpp | 98 +-
src/shared/leaktrace.cpp | 70 +-
src/shared/leaktrace.h | 7 +-
src/shared/stackdata.cpp | 219 +-
src/shared/stackdata.h | 43 +-
src/shared/util.cpp | 209 +-
src/shared/util.h | 23 +-
src/shared/windows_error.cpp | 43 +-
src/shared/windows_error.h | 14 +-
src/singleinstance.cpp | 125 +-
src/singleinstance.h | 79 +-
src/spawn.cpp | 244 +-
src/spawn.h | 12 +-
src/syncoverwritedialog.cpp | 215 +-
src/syncoverwritedialog.h | 31 +-
src/transfersavesdialog.cpp | 464 +--
src/transfersavesdialog.h | 81 +-
src/usvfsconnector.cpp | 251 +-
src/usvfsconnector.h | 50 +-
src/viewmarkingscrollbar.cpp | 54 +-
src/viewmarkingscrollbar.h | 20 +-
src/waitingonclosedialog.cpp | 61 +-
src/waitingonclosedialog.h | 23 +-
176 files changed, 26451 insertions(+), 30158 deletions(-)
create mode 100644 .clang-format
(limited to 'src/spawn.cpp')
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00000000..6e34f96b
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,11 @@
+---
+Language: Cpp
+BasedOnStyle: LLVM
+
+AccessModifierOffset: -4
+AlwaysBreakTemplateDeclarations: true
+ColumnLimit: 120
+DerivePointerAlignment: false
+IndentWidth: 4
+PointerAlignment: Left
+SortUsingDeclarations: true
\ No newline at end of file
diff --git a/src/aboutdialog.cpp b/src/aboutdialog.cpp
index ed57a217..e79109ad 100644
--- a/src/aboutdialog.cpp
+++ b/src/aboutdialog.cpp
@@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License
along with Mod Organizer. If not, see .
*/
-
#include "aboutdialog.h"
#include "ui_aboutdialog.h"
#include
@@ -30,65 +29,55 @@ along with Mod Organizer. If not, see .
#include
#include
-
-AboutDialog::AboutDialog(const QString &version, QWidget *parent)
- : QDialog(parent)
- , ui(new Ui::AboutDialog)
-{
- ui->setupUi(this);
-
- m_LicenseFiles[LICENSE_LGPL3] = "lgpl-3.0.txt";
- m_LicenseFiles[LICENSE_GPL3] = "gpl-3.0.txt";
- m_LicenseFiles[LICENSE_BSD3] = "bsd3.txt";
- m_LicenseFiles[LICENSE_BOOST] = "boost.txt";
- m_LicenseFiles[LICENSE_CCBY3] = "by-sa3.txt";
- m_LicenseFiles[LICENSE_ZLIB] = "zlib.txt";
- m_LicenseFiles[LICENSE_APACHE2] = "apache-license-2.0.txt";
-
- addLicense("Qt", LICENSE_LGPL3);
- addLicense("Qt Json", LICENSE_GPL3);
- addLicense("Boost Library", LICENSE_BOOST);
- addLicense("7-zip", LICENSE_LGPL3);
- addLicense("ZLib", LICENSE_ZLIB);
- addLicense("Tango Icon Theme", LICENSE_NONE);
- addLicense("RRZE Icon Set", LICENSE_CCBY3);
- addLicense("Icons by Lorc, Delapouite and sbed available on http://game-icons.net", LICENSE_CCBY3);
- addLicense("Castle Core", LICENSE_APACHE2);
- addLicense("LOOT", LICENSE_GPL3);
-
- ui->nameLabel->setText(QString("%1 %2").arg(ui->nameLabel->text()).arg(version));
+AboutDialog::AboutDialog(const QString& version, QWidget* parent) : QDialog(parent), ui(new Ui::AboutDialog) {
+ ui->setupUi(this);
+
+ m_LicenseFiles[LICENSE_LGPL3] = "lgpl-3.0.txt";
+ m_LicenseFiles[LICENSE_GPL3] = "gpl-3.0.txt";
+ m_LicenseFiles[LICENSE_BSD3] = "bsd3.txt";
+ m_LicenseFiles[LICENSE_BOOST] = "boost.txt";
+ m_LicenseFiles[LICENSE_CCBY3] = "by-sa3.txt";
+ m_LicenseFiles[LICENSE_ZLIB] = "zlib.txt";
+ m_LicenseFiles[LICENSE_APACHE2] = "apache-license-2.0.txt";
+
+ addLicense("Qt", LICENSE_LGPL3);
+ addLicense("Qt Json", LICENSE_GPL3);
+ addLicense("Boost Library", LICENSE_BOOST);
+ addLicense("7-zip", LICENSE_LGPL3);
+ addLicense("ZLib", LICENSE_ZLIB);
+ addLicense("Tango Icon Theme", LICENSE_NONE);
+ addLicense("RRZE Icon Set", LICENSE_CCBY3);
+ addLicense("Icons by Lorc, Delapouite and sbed available on http://game-icons.net", LICENSE_CCBY3);
+ addLicense("Castle Core", LICENSE_APACHE2);
+ addLicense("LOOT", LICENSE_GPL3);
+
+ ui->nameLabel->setText(QString("%1 %2")
+ .arg(ui->nameLabel->text())
+ .arg(version));
#if defined(HGID)
- ui->revisionLabel->setText(ui->revisionLabel->text() + " " + HGID);
+ ui->revisionLabel->setText(ui->revisionLabel->text() + " " + HGID);
#elif defined(GITID)
- ui->revisionLabel->setText(ui->revisionLabel->text() + " " + GITID);
+ ui->revisionLabel->setText(ui->revisionLabel->text() + " " + GITID);
#else
- ui->revisionLabel->setText(ui->revisionLabel->text() + " unknown");
+ ui->revisionLabel->setText(ui->revisionLabel->text() + " unknown");
#endif
}
+AboutDialog::~AboutDialog() { delete ui; }
-AboutDialog::~AboutDialog()
-{
- delete ui;
+void AboutDialog::addLicense(const QString& name, Licenses license) {
+ QListWidgetItem* item = new QListWidgetItem(name);
+ item->setData(Qt::UserRole, license);
+ ui->creditsList->addItem(item);
}
-
-void AboutDialog::addLicense(const QString &name, Licenses license)
-{
- QListWidgetItem *item = new QListWidgetItem(name);
- item->setData(Qt::UserRole, license);
- ui->creditsList->addItem(item);
-}
-
-
-void AboutDialog::on_creditsList_currentItemChanged(QListWidgetItem *current, QListWidgetItem*)
-{
- auto iter = m_LicenseFiles.find(current->data(Qt::UserRole).toInt());
- if (iter != m_LicenseFiles.end()) {
- QString filePath = qApp->applicationDirPath() + "/license/" + iter->second;
- QString text = MOBase::readFileText(filePath);
- ui->licenseText->setText(text);
- } else {
- ui->licenseText->setText(tr("No license"));
- }
+void AboutDialog::on_creditsList_currentItemChanged(QListWidgetItem* current, QListWidgetItem*) {
+ auto iter = m_LicenseFiles.find(current->data(Qt::UserRole).toInt());
+ if (iter != m_LicenseFiles.end()) {
+ QString filePath = qApp->applicationDirPath() + "/license/" + iter->second;
+ QString text = MOBase::readFileText(filePath);
+ ui->licenseText->setText(text);
+ } else {
+ ui->licenseText->setText(tr("No license"));
+ }
}
diff --git a/src/aboutdialog.h b/src/aboutdialog.h
index 103a0d2f..a5c93834 100644
--- a/src/aboutdialog.h
+++ b/src/aboutdialog.h
@@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License
along with Mod Organizer. If not, see .
*/
-
#define ABOUTDIALOG_H
#include
@@ -29,43 +28,38 @@ class QListWidgetItem;
#include
");
- m_TagMap["code"] = std::make_pair(QRegExp("\\[code\\](.*)\\[/code\\]"),
- "\\1
");
- m_TagMap["heading"]= std::make_pair(QRegExp("\\[heading\\](.*)\\[/heading\\]"),
- "\\1
");
- m_TagMap["line"] = std::make_pair(QRegExp("\\[line\\]"),
- "
");
-
- // lists
- m_TagMap["list"] = std::make_pair(QRegExp("\\[list\\](.*)\\[/list\\]"),
- "");
- m_TagMap["list="] = std::make_pair(QRegExp("\\[list.*\\](.*)\\[/list\\]"),
- "\\1
");
- m_TagMap["ul"] = std::make_pair(QRegExp("\\[ul\\](.*)\\[/ul\\]"),
- "");
- m_TagMap["ol"] = std::make_pair(QRegExp("\\[ol\\](.*)\\[/ol\\]"),
- "\\1
");
- m_TagMap["li"] = std::make_pair(QRegExp("\\[li\\](.*)\\[/li\\]"),
- "\\1");
-
- // tables
- m_TagMap["table"] = std::make_pair(QRegExp("\\[table\\](.*)\\[/table\\]"),
- "");
- m_TagMap["tr"] = std::make_pair(QRegExp("\\[tr\\](.*)\\[/tr\\]"),
- "\\1
");
- m_TagMap["th"] = std::make_pair(QRegExp("\\[th\\](.*)\\[/th\\]"),
- "\\1 | ");
- m_TagMap["td"] = std::make_pair(QRegExp("\\[td\\](.*)\\[/td\\]"),
- "\\1 | ");
-
- // web content
- m_TagMap["url"] = std::make_pair(QRegExp("\\[url\\](.*)\\[/url\\]"),
- "\\1");
- m_TagMap["url="] = std::make_pair(QRegExp("\\[url=([^\\]]*)\\](.*)\\[/url\\]"),
- "\\2");
- m_TagMap["img"] = std::make_pair(QRegExp("\\[img\\](.*)\\[/img\\]"),
- "
");
- m_TagMap["img="] = std::make_pair(QRegExp("\\[img=([^\\]]*)\\](.*)\\[/img\\]"),
- "
");
- m_TagMap["email="] = std::make_pair(QRegExp("\\[email=\"?([^\\]]*)\"?\\](.*)\\[/email\\]"),
- "\\2");
- m_TagMap["youtube"] = std::make_pair(QRegExp("\\[youtube\\](.*)\\[/youtube\\]"),
- "http://www.youtube.com/v/\\1");
-
+ BBCodeMap() : m_TagNameExp("^[a-zA-Z*]*=?") {
+ m_TagMap["b"] = std::make_pair(QRegExp("\\[b\\](.*)\\[/b\\]"), "\\1");
+ m_TagMap["i"] = std::make_pair(QRegExp("\\[i\\](.*)\\[/i\\]"), "\\1");
+ m_TagMap["u"] = std::make_pair(QRegExp("\\[u\\](.*)\\[/u\\]"), "\\1");
+ m_TagMap["s"] = std::make_pair(QRegExp("\\[s\\](.*)\\[/s\\]"), "\\1");
+ m_TagMap["sub"] = std::make_pair(QRegExp("\\[sub\\](.*)\\[/sub\\]"), "\\1");
+ m_TagMap["sup"] = std::make_pair(QRegExp("\\[sup\\](.*)\\[/sup\\]"), "\\1");
+ m_TagMap["size="] =
+ std::make_pair(QRegExp("\\[size=([^\\]]*)\\](.*)\\[/size\\]"), "\\2");
+ m_TagMap["color="] = std::make_pair(QRegExp("\\[color=([^\\]]*)\\](.*)\\[/color\\]"), "");
+ m_TagMap["font="] = std::make_pair(QRegExp("\\[font=([^\\]]*)\\](.*)\\[/font\\]"),
+ "\\2");
+ m_TagMap["center"] =
+ std::make_pair(QRegExp("\\[center\\](.*)\\[/center\\]"), "\\1
");
+ m_TagMap["quote"] = std::make_pair(QRegExp("\\[quote\\](.*)\\[/quote\\]"), "\"\\1\"
");
+ m_TagMap["quote="] = std::make_pair(QRegExp("\\[quote=([^\\]]*)\\](.*)\\[/quote\\]"),
+ "\"\\2\"
--\\1
");
+ m_TagMap["code"] = std::make_pair(QRegExp("\\[code\\](.*)\\[/code\\]"), "\\1
");
+ m_TagMap["heading"] =
+ std::make_pair(QRegExp("\\[heading\\](.*)\\[/heading\\]"), "\\1
");
+ m_TagMap["line"] = std::make_pair(QRegExp("\\[line\\]"), "
");
+
+ // lists
+ m_TagMap["list"] = std::make_pair(QRegExp("\\[list\\](.*)\\[/list\\]"), "");
+ m_TagMap["list="] = std::make_pair(QRegExp("\\[list.*\\](.*)\\[/list\\]"), "\\1
");
+ m_TagMap["ul"] = std::make_pair(QRegExp("\\[ul\\](.*)\\[/ul\\]"), "");
+ m_TagMap["ol"] = std::make_pair(QRegExp("\\[ol\\](.*)\\[/ol\\]"), "\\1
");
+ m_TagMap["li"] = std::make_pair(QRegExp("\\[li\\](.*)\\[/li\\]"), "\\1");
+
+ // tables
+ m_TagMap["table"] = std::make_pair(QRegExp("\\[table\\](.*)\\[/table\\]"), "");
+ m_TagMap["tr"] = std::make_pair(QRegExp("\\[tr\\](.*)\\[/tr\\]"), "\\1
");
+ m_TagMap["th"] = std::make_pair(QRegExp("\\[th\\](.*)\\[/th\\]"), "\\1 | ");
+ m_TagMap["td"] = std::make_pair(QRegExp("\\[td\\](.*)\\[/td\\]"), "\\1 | ");
+
+ // web content
+ m_TagMap["url"] = std::make_pair(QRegExp("\\[url\\](.*)\\[/url\\]"), "\\1");
+ m_TagMap["url="] = std::make_pair(QRegExp("\\[url=([^\\]]*)\\](.*)\\[/url\\]"), "\\2");
+ m_TagMap["img"] = std::make_pair(QRegExp("\\[img\\](.*)\\[/img\\]"), "
");
+ m_TagMap["img="] =
+ std::make_pair(QRegExp("\\[img=([^\\]]*)\\](.*)\\[/img\\]"), "
");
+ m_TagMap["email="] =
+ std::make_pair(QRegExp("\\[email=\"?([^\\]]*)\"?\\](.*)\\[/email\\]"), "\\2");
+ m_TagMap["youtube"] =
+ std::make_pair(QRegExp("\\[youtube\\](.*)\\[/youtube\\]"),
+ "http://www.youtube.com/v/\\1");
+
+ // make all patterns non-greedy and case-insensitive
+ for (TagMap::iterator iter = m_TagMap.begin(); iter != m_TagMap.end(); ++iter) {
+ iter->second.first.setCaseSensitivity(Qt::CaseInsensitive);
+ iter->second.first.setMinimal(true);
+ }
- // make all patterns non-greedy and case-insensitive
- for (TagMap::iterator iter = m_TagMap.begin(); iter != m_TagMap.end(); ++iter) {
- iter->second.first.setCaseSensitivity(Qt::CaseInsensitive);
- iter->second.first.setMinimal(true);
+ // this tag is in fact greedy
+ m_TagMap["*"] = std::make_pair(QRegExp("\\[\\*\\](.*)"), "\\1");
+
+ m_ColorMap.insert(std::make_pair("red", "FF0000"));
+ m_ColorMap.insert(std::make_pair("green", "00FF00"));
+ m_ColorMap.insert(std::make_pair("blue", "0000FF"));
+ m_ColorMap.insert(std::make_pair("black", "000000"));
+ m_ColorMap.insert(std::make_pair("gray", "7F7F7F"));
+ m_ColorMap.insert(std::make_pair("white", "FFFFFF"));
+ m_ColorMap.insert(std::make_pair("yellow", "FFFF00"));
+ m_ColorMap.insert(std::make_pair("cyan", "00FFFF"));
+ m_ColorMap.insert(std::make_pair("magenta", "FF00FF"));
+ m_ColorMap.insert(std::make_pair("brown", "A52A2A"));
+ m_ColorMap.insert(std::make_pair("orange", "FFA500"));
+ m_ColorMap.insert(std::make_pair("gold", "FFD700"));
+ m_ColorMap.insert(std::make_pair("deepskyblue", "00BFFF"));
+ m_ColorMap.insert(std::make_pair("salmon", "FA8072"));
+ m_ColorMap.insert(std::make_pair("dodgerblue", "1E90FF"));
+ m_ColorMap.insert(std::make_pair("greenyellow", "ADFF2F"));
+ m_ColorMap.insert(std::make_pair("peru", "CD853F"));
}
- // this tag is in fact greedy
- m_TagMap["*"] = std::make_pair(QRegExp("\\[\\*\\](.*)"),
- "\\1");
-
- m_ColorMap.insert(std::make_pair("red", "FF0000"));
- m_ColorMap.insert(std::make_pair("green", "00FF00"));
- m_ColorMap.insert(std::make_pair("blue", "0000FF"));
- m_ColorMap.insert(std::make_pair("black", "000000"));
- m_ColorMap.insert(std::make_pair("gray", "7F7F7F"));
- m_ColorMap.insert(std::make_pair("white", "FFFFFF"));
- m_ColorMap.insert(std::make_pair("yellow", "FFFF00"));
- m_ColorMap.insert(std::make_pair("cyan", "00FFFF"));
- m_ColorMap.insert(std::make_pair("magenta", "FF00FF"));
- m_ColorMap.insert(std::make_pair("brown", "A52A2A"));
- m_ColorMap.insert(std::make_pair("orange", "FFA500"));
- m_ColorMap.insert(std::make_pair("gold", "FFD700"));
- m_ColorMap.insert(std::make_pair("deepskyblue", "00BFFF"));
- m_ColorMap.insert(std::make_pair("salmon", "FA8072"));
- m_ColorMap.insert(std::make_pair("dodgerblue", "1E90FF"));
- m_ColorMap.insert(std::make_pair("greenyellow", "ADFF2F"));
- m_ColorMap.insert(std::make_pair("peru", "CD853F"));
- }
-
private:
-
- QRegExp m_TagNameExp;
- TagMap m_TagMap;
- std::map m_ColorMap;
+ QRegExp m_TagNameExp;
+ TagMap m_TagMap;
+ std::map m_ColorMap;
};
-
-QString convertToHTML(const QString &inputParam)
-{
- // this code goes over the input string once and replaces all bbtags
- // it encounters. This function is called recursively for every replaced
- // string to convert nested tags.
- //
- // This could be implemented simpler by applying a set of regular expressions
- // for each recognized bb-tag one after the other but that would probably be
- // very inefficient (O(n^2)).
-
- QString input = inputParam.mid(0).replace("\r\n", "
");
- input.replace("\\\"", "\"").replace("\\'", "'");
- QString result;
- int lastBlock = 0;
- int pos = 0;
-
- // iterate over the input buffer
- while ((pos = input.indexOf('[', lastBlock)) != -1) {
- // append everything between the previous tag-block and the current one
- result.append(input.midRef(lastBlock, pos - lastBlock));
-
- if ((pos < (input.size() - 1)) && (input.at(pos + 1) == '/')) {
- // skip invalid end tag
- int tagEnd = input.indexOf(']', pos) + 1;
- pos = tagEnd;
- } else {
- // convert the tag and content if necessary
- int length = -1;
- QString replacement = BBCodeMap::instance().convertTag(input.mid(pos), length);
- if (length != 0) {
- result.append(convertToHTML(replacement));
- // length contains the number of characters in the original tag
- pos += length;
- } else {
- // nothing replaced
- result.append('[');
- ++pos;
- }
+QString convertToHTML(const QString& inputParam) {
+ // this code goes over the input string once and replaces all bbtags
+ // it encounters. This function is called recursively for every replaced
+ // string to convert nested tags.
+ //
+ // This could be implemented simpler by applying a set of regular expressions
+ // for each recognized bb-tag one after the other but that would probably be
+ // very inefficient (O(n^2)).
+
+ QString input = inputParam.mid(0).replace("\r\n", "
");
+ input.replace("\\\"", "\"").replace("\\'", "'");
+ QString result;
+ int lastBlock = 0;
+ int pos = 0;
+
+ // iterate over the input buffer
+ while ((pos = input.indexOf('[', lastBlock)) != -1) {
+ // append everything between the previous tag-block and the current one
+ result.append(input.midRef(lastBlock, pos - lastBlock));
+
+ if ((pos < (input.size() - 1)) && (input.at(pos + 1) == '/')) {
+ // skip invalid end tag
+ int tagEnd = input.indexOf(']', pos) + 1;
+ pos = tagEnd;
+ } else {
+ // convert the tag and content if necessary
+ int length = -1;
+ QString replacement = BBCodeMap::instance().convertTag(input.mid(pos), length);
+ if (length != 0) {
+ result.append(convertToHTML(replacement));
+ // length contains the number of characters in the original tag
+ pos += length;
+ } else {
+ // nothing replaced
+ result.append('[');
+ ++pos;
+ }
+ }
+ lastBlock = pos;
}
- lastBlock = pos;
- }
- // append the remainder (everything after the last tag)
- result.append(input.midRef(lastBlock));
- return result;
+ // append the remainder (everything after the last tag)
+ result.append(input.midRef(lastBlock));
+ return result;
}
} // namespace BBCode
-
diff --git a/src/bbcode.h b/src/bbcode.h
index 708dfe71..d8a10337 100644
--- a/src/bbcode.h
+++ b/src/bbcode.h
@@ -20,10 +20,8 @@ along with Mod Organizer. If not, see .
#ifndef BBCODE_H
#define BBCODE_H
-
#include
-
namespace BBCode {
/**
@@ -32,9 +30,8 @@ namespace BBCode {
* @param replaceOccured if not nullptr, this parameter will be set to true if any bb tags were replaced
* @return the same string in html representation
**/
-QString convertToHTML(const QString &input);
-
-}
+QString convertToHTML(const QString& input);
+} // namespace BBCode
#endif // BBCODE_H
diff --git a/src/browserdialog.cpp b/src/browserdialog.cpp
index c2c65acc..d5a43332 100644
--- a/src/browserdialog.cpp
+++ b/src/browserdialog.cpp
@@ -19,276 +19,228 @@ along with Mod Organizer. If not, see .
#include "browserdialog.h"
-#include "ui_browserdialog.h"
#include "browserview.h"
#include "messagedialog.h"
-#include "report.h"
#include "persistentcookiejar.h"
+#include "report.h"
+#include "ui_browserdialog.h"
-#include
#include "settings.h"
+#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
#include
+#include
+#include
#include
+#include
+#include
+#include
+#include
+#include
+BrowserDialog::BrowserDialog(QWidget* parent)
+ : QDialog(parent), ui(new Ui::BrowserDialog), m_AccessManager(new QNetworkAccessManager(this)) {
+ ui->setupUi(this);
+ m_AccessManager->setCookieJar(
+ new PersistentCookieJar(QDir::fromNativeSeparators(Settings::instance().getCacheDirectory() + "/cookies.dat")));
-BrowserDialog::BrowserDialog(QWidget *parent)
- : QDialog(parent)
- , ui(new Ui::BrowserDialog)
- , m_AccessManager(new QNetworkAccessManager(this))
-{
- ui->setupUi(this);
-
- m_AccessManager->setCookieJar(new PersistentCookieJar(
- QDir::fromNativeSeparators(Settings::instance().getCacheDirectory() + "/cookies.dat")));
-
- Qt::WindowFlags flags = windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint;
- Qt::WindowFlags helpFlag = Qt::WindowContextHelpButtonHint;
- flags = flags & (~helpFlag);
- setWindowFlags(flags);
+ Qt::WindowFlags flags = windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint;
+ Qt::WindowFlags helpFlag = Qt::WindowContextHelpButtonHint;
+ flags = flags & (~helpFlag);
+ setWindowFlags(flags);
- m_Tabs = this->findChild("browserTabWidget");
+ m_Tabs = this->findChild("browserTabWidget");
- installEventFilter(this);
+ installEventFilter(this);
- connect(m_Tabs, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested(int)));
+ connect(m_Tabs, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested(int)));
- ui->urlEdit->setVisible(false);
+ ui->urlEdit->setVisible(false);
}
-BrowserDialog::~BrowserDialog()
-{
- delete ui;
-}
+BrowserDialog::~BrowserDialog() { delete ui; }
-void BrowserDialog::closeEvent(QCloseEvent *event)
-{
-// m_AccessManager->showCookies();
- QDialog::closeEvent(event);
+void BrowserDialog::closeEvent(QCloseEvent* event) {
+ // m_AccessManager->showCookies();
+ QDialog::closeEvent(event);
}
-void BrowserDialog::initTab(BrowserView *newView)
-{
- //newView->page()->setNetworkAccessManager(m_AccessManager);
- //newView->page()->setForwardUnsupportedContent(true);
-
- connect(newView, SIGNAL(loadProgress(int)), this, SLOT(progress(int)));
- connect(newView, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged(QString)));
- connect(newView, SIGNAL(initTab(BrowserView*)), this, SLOT(initTab(BrowserView*)));
- connect(newView, SIGNAL(startFind()), this, SLOT(startSearch()));
- connect(newView, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
- connect(newView, SIGNAL(openUrlInNewTab(QUrl)), this, SLOT(openInNewTab(QUrl)));
- connect(newView, SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadRequested(QNetworkRequest)));
- connect(newView, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(unsupportedContent(QNetworkReply*)));
-
- ui->backBtn->setEnabled(false);
- ui->fwdBtn->setEnabled(false);
- m_Tabs->addTab(newView, tr("new"));
- newView->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
- newView->settings()->setAttribute(QWebEngineSettings::AutoLoadImages, true);
-}
+void BrowserDialog::initTab(BrowserView* newView) {
+ // newView->page()->setNetworkAccessManager(m_AccessManager);
+ // newView->page()->setForwardUnsupportedContent(true);
+ connect(newView, SIGNAL(loadProgress(int)), this, SLOT(progress(int)));
+ connect(newView, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged(QString)));
+ connect(newView, SIGNAL(initTab(BrowserView*)), this, SLOT(initTab(BrowserView*)));
+ connect(newView, SIGNAL(startFind()), this, SLOT(startSearch()));
+ connect(newView, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
+ connect(newView, SIGNAL(openUrlInNewTab(QUrl)), this, SLOT(openInNewTab(QUrl)));
+ connect(newView, SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadRequested(QNetworkRequest)));
+ connect(newView, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(unsupportedContent(QNetworkReply*)));
-void BrowserDialog::openInNewTab(const QUrl &url)
-{
- BrowserView *newView = new BrowserView(this);
- initTab(newView);
- newView->setUrl(url);
+ ui->backBtn->setEnabled(false);
+ ui->fwdBtn->setEnabled(false);
+ m_Tabs->addTab(newView, tr("new"));
+ newView->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
+ newView->settings()->setAttribute(QWebEngineSettings::AutoLoadImages, true);
}
-
-BrowserView *BrowserDialog::getCurrentView()
-{
- return qobject_cast(m_Tabs->currentWidget());
+void BrowserDialog::openInNewTab(const QUrl& url) {
+ BrowserView* newView = new BrowserView(this);
+ initTab(newView);
+ newView->setUrl(url);
}
+BrowserView* BrowserDialog::getCurrentView() { return qobject_cast(m_Tabs->currentWidget()); }
-void BrowserDialog::urlChanged(const QUrl &url)
-{
- BrowserView *currentView = getCurrentView();
- if (currentView != nullptr) {
- ui->backBtn->setEnabled(currentView->history()->canGoBack());
- ui->fwdBtn->setEnabled(currentView->history()->canGoForward());
- }
- ui->urlEdit->setText(url.toString());
+void BrowserDialog::urlChanged(const QUrl& url) {
+ BrowserView* currentView = getCurrentView();
+ if (currentView != nullptr) {
+ ui->backBtn->setEnabled(currentView->history()->canGoBack());
+ ui->fwdBtn->setEnabled(currentView->history()->canGoForward());
+ }
+ ui->urlEdit->setText(url.toString());
}
-
-void BrowserDialog::openUrl(const QUrl &url)
-{
- if (isHidden()) {
- show();
- }
- openInNewTab(url);
+void BrowserDialog::openUrl(const QUrl& url) {
+ if (isHidden()) {
+ show();
+ }
+ openInNewTab(url);
}
+void BrowserDialog::maximizeWidth() {
+ int viewportWidth = getCurrentView()->page()->contentsSize().width();
+ int frameWidth = width() - viewportWidth;
-void BrowserDialog::maximizeWidth()
-{
- int viewportWidth = getCurrentView()->page()->contentsSize ().width();
- int frameWidth = width() - viewportWidth;
-
- int contentWidth = getCurrentView()->page()->contentsSize().width();
-
- QDesktopWidget screen;
- int currentScreen = screen.screenNumber(this);
- int screenWidth = screen.screenGeometry(currentScreen).size().width();
-
- int targetWidth = std::min(std::max(viewportWidth, contentWidth) + frameWidth, screenWidth);
- this->resize(targetWidth, height());
-}
+ int contentWidth = getCurrentView()->page()->contentsSize().width();
+ QDesktopWidget screen;
+ int currentScreen = screen.screenNumber(this);
+ int screenWidth = screen.screenGeometry(currentScreen).size().width();
-void BrowserDialog::progress(int value)
-{
- ui->loadProgress->setValue(value);
- if (value == 100) {
- maximizeWidth();
- ui->loadProgress->setVisible(false);
- } else {
- ui->loadProgress->setVisible(true);
- }
+ int targetWidth = std::min(std::max(viewportWidth, contentWidth) + frameWidth, screenWidth);
+ this->resize(targetWidth, height());
}
-
-void BrowserDialog::titleChanged(const QString &title)
-{
- BrowserView *view = qobject_cast(sender());
- for (int i = 0; i < m_Tabs->count(); ++i) {
- if (m_Tabs->widget(i) == view) {
- m_Tabs->setTabText(i, title.mid(0, 15));
- m_Tabs->setTabToolTip(i, title);
+void BrowserDialog::progress(int value) {
+ ui->loadProgress->setValue(value);
+ if (value == 100) {
+ maximizeWidth();
+ ui->loadProgress->setVisible(false);
+ } else {
+ ui->loadProgress->setVisible(true);
}
- }
}
-
-QString BrowserDialog::guessFileName(const QString &url)
-{
- QRegExp uploadsExp(QString("http://.+/uploads/([^/]+)$"));
- if (uploadsExp.indexIn(url) != -1) {
- // these seem to be premium downloads
- return uploadsExp.cap(1);
- }
-
- QRegExp filesExp(QString("http://.+\\?file=([^&]+)"));
- if (filesExp.indexIn(url) != -1) {
- // a regular manual download?
- return filesExp.cap(1);
- }
- return "unknown";
+void BrowserDialog::titleChanged(const QString& title) {
+ BrowserView* view = qobject_cast(sender());
+ for (int i = 0; i < m_Tabs->count(); ++i) {
+ if (m_Tabs->widget(i) == view) {
+ m_Tabs->setTabText(i, title.mid(0, 15));
+ m_Tabs->setTabToolTip(i, title);
+ }
+ }
}
-void BrowserDialog::unsupportedContent(QNetworkReply *reply)
-{
- try {
- QWebEnginePage *page = qobject_cast(sender());
- if (page == nullptr) {
- qCritical("sender not a page");
- return;
- }
- BrowserView *view = qobject_cast(page->view());
- if (view == nullptr) {
- qCritical("no view?");
- return;
+QString BrowserDialog::guessFileName(const QString& url) {
+ QRegExp uploadsExp(QString("http://.+/uploads/([^/]+)$"));
+ if (uploadsExp.indexIn(url) != -1) {
+ // these seem to be premium downloads
+ return uploadsExp.cap(1);
}
- emit requestDownload(view->url(), reply);
- } catch (const std::exception &e) {
- if (isVisible()) {
- MessageDialog::showMessage(tr("failed to start download"), this);
+ QRegExp filesExp(QString("http://.+\\?file=([^&]+)"));
+ if (filesExp.indexIn(url) != -1) {
+ // a regular manual download?
+ return filesExp.cap(1);
+ }
+ return "unknown";
+}
+
+void BrowserDialog::unsupportedContent(QNetworkReply* reply) {
+ try {
+ QWebEnginePage* page = qobject_cast(sender());
+ if (page == nullptr) {
+ qCritical("sender not a page");
+ return;
+ }
+ BrowserView* view = qobject_cast(page->view());
+ if (view == nullptr) {
+ qCritical("no view?");
+ return;
+ }
+
+ emit requestDownload(view->url(), reply);
+ } catch (const std::exception& e) {
+ if (isVisible()) {
+ MessageDialog::showMessage(tr("failed to start download"), this);
+ }
+ qCritical("exception downloading unsupported content: %s", e.what());
}
- qCritical("exception downloading unsupported content: %s", e.what());
- }
-}
-
-
-void BrowserDialog::downloadRequested(const QNetworkRequest &request)
-{
- qCritical("download request %s ignored", request.url().toString().toUtf8().constData());
}
-
-void BrowserDialog::tabCloseRequested(int index)
-{
- if (m_Tabs->count() == 1) {
- this->close();
- } else {
- m_Tabs->widget(index)->deleteLater();
- m_Tabs->removeTab(index);
- }
+void BrowserDialog::downloadRequested(const QNetworkRequest& request) {
+ qCritical("download request %s ignored", request.url().toString().toUtf8().constData());
}
-void BrowserDialog::on_backBtn_clicked()
-{
- BrowserView *currentView = getCurrentView();
- if (currentView != nullptr) {
- currentView->back();
- }
+void BrowserDialog::tabCloseRequested(int index) {
+ if (m_Tabs->count() == 1) {
+ this->close();
+ } else {
+ m_Tabs->widget(index)->deleteLater();
+ m_Tabs->removeTab(index);
+ }
}
-void BrowserDialog::on_fwdBtn_clicked()
-{
- BrowserView *currentView = getCurrentView();
- if (currentView != nullptr) {
- currentView->forward();
- }
+void BrowserDialog::on_backBtn_clicked() {
+ BrowserView* currentView = getCurrentView();
+ if (currentView != nullptr) {
+ currentView->back();
+ }
}
-
-void BrowserDialog::startSearch()
-{
- ui->searchEdit->setFocus();
+void BrowserDialog::on_fwdBtn_clicked() {
+ BrowserView* currentView = getCurrentView();
+ if (currentView != nullptr) {
+ currentView->forward();
+ }
}
+void BrowserDialog::startSearch() { ui->searchEdit->setFocus(); }
-void BrowserDialog::on_searchEdit_returnPressed()
-{
-// BrowserView *currentView = getCurrentView();
-// if (currentView != nullptr) {
-// currentView->findText(ui->searchEdit->text(), QWebEnginePage::FindWrapsAroundDocument);
-// }
+void BrowserDialog::on_searchEdit_returnPressed() {
+ // BrowserView *currentView = getCurrentView();
+ // if (currentView != nullptr) {
+ // currentView->findText(ui->searchEdit->text(), QWebEnginePage::FindWrapsAroundDocument);
+ // }
}
-void BrowserDialog::on_refreshBtn_clicked()
-{
- getCurrentView()->reload();
-}
+void BrowserDialog::on_refreshBtn_clicked() { getCurrentView()->reload(); }
-void BrowserDialog::on_browserTabWidget_currentChanged(int index)
-{
- BrowserView *currentView = qobject_cast(ui->browserTabWidget->widget(index));
- if (currentView != nullptr) {
- ui->backBtn->setEnabled(currentView->history()->canGoBack());
- ui->fwdBtn->setEnabled(currentView->history()->canGoForward());
- }
+void BrowserDialog::on_browserTabWidget_currentChanged(int index) {
+ BrowserView* currentView = qobject_cast(ui->browserTabWidget->widget(index));
+ if (currentView != nullptr) {
+ ui->backBtn->setEnabled(currentView->history()->canGoBack());
+ ui->fwdBtn->setEnabled(currentView->history()->canGoForward());
+ }
}
-void BrowserDialog::on_urlEdit_returnPressed()
-{
- QWebEngineView *currentView = getCurrentView();
- if (currentView != nullptr) {
- currentView->setUrl(QUrl(ui->urlEdit->text()));
- }
+void BrowserDialog::on_urlEdit_returnPressed() {
+ QWebEngineView* currentView = getCurrentView();
+ if (currentView != nullptr) {
+ currentView->setUrl(QUrl(ui->urlEdit->text()));
+ }
}
-bool BrowserDialog::eventFilter(QObject *object, QEvent *event)
-{
- if (event->type() == QEvent::KeyPress) {
- QKeyEvent *keyEvent = reinterpret_cast(event);
- if ((keyEvent->modifiers() & Qt::ControlModifier)
- && (keyEvent->key() == Qt::Key_U)) {
- ui->urlEdit->setVisible(!ui->urlEdit->isVisible());
- return true;
+bool BrowserDialog::eventFilter(QObject* object, QEvent* event) {
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent* keyEvent = reinterpret_cast(event);
+ if ((keyEvent->modifiers() & Qt::ControlModifier) && (keyEvent->key() == Qt::Key_U)) {
+ ui->urlEdit->setVisible(!ui->urlEdit->isVisible());
+ return true;
+ }
}
- }
- return QDialog::eventFilter(object, event);
+ return QDialog::eventFilter(object, event);
}
diff --git a/src/browserdialog.h b/src/browserdialog.h
index 354a377b..6947cc43 100644
--- a/src/browserdialog.h
+++ b/src/browserdialog.h
@@ -20,18 +20,17 @@ along with Mod Organizer. If not, see .
#ifndef BROWSERDIALOG_H
#define BROWSERDIALOG_H
+#include
#include
-#include
#include
-#include
-#include
+#include
#include
#include
-#include
-
+#include
+#include
namespace Ui {
- class BrowserDialog;
+class BrowserDialog;
}
class BrowserView;
@@ -39,88 +38,81 @@ class BrowserView;
/**
* @brief a dialog containing a webbrowser that is intended to browse the nexus network
**/
-class BrowserDialog : public QDialog
-{
+class BrowserDialog : public QDialog {
Q_OBJECT
public:
-
- /**
- * @brief constructor
- *
- * @param accessManager the access manager to use for network requests
- * @param parent parent widget
- **/
- explicit BrowserDialog(QWidget *parent = 0);
- ~BrowserDialog();
-
- /**
- * @brief set the url to open. If automatic login is enabled, the url is opened after login
- *
- * @param url the url to open
- **/
- void openUrl(const QUrl &url);
-
- virtual bool eventFilter(QObject *object, QEvent *event);
+ /**
+ * @brief constructor
+ *
+ * @param accessManager the access manager to use for network requests
+ * @param parent parent widget
+ **/
+ explicit BrowserDialog(QWidget* parent = 0);
+ ~BrowserDialog();
+
+ /**
+ * @brief set the url to open. If automatic login is enabled, the url is opened after login
+ *
+ * @param url the url to open
+ **/
+ void openUrl(const QUrl& url);
+
+ virtual bool eventFilter(QObject* object, QEvent* event);
signals:
- /**
- * @brief emitted when the user starts a download
- * @param pageUrl url of the current web site from which the download was started
- * @param reply network reply of the started download
- */
- void requestDownload(const QUrl &pageUrl, QNetworkReply *reply);
+ /**
+ * @brief emitted when the user starts a download
+ * @param pageUrl url of the current web site from which the download was started
+ * @param reply network reply of the started download
+ */
+ void requestDownload(const QUrl& pageUrl, QNetworkReply* reply);
protected:
-
- virtual void closeEvent(QCloseEvent *);
+ virtual void closeEvent(QCloseEvent*);
private slots:
- void initTab(BrowserView *newView);
- void openInNewTab(const QUrl &url);
+ void initTab(BrowserView* newView);
+ void openInNewTab(const QUrl& url);
- void progress(int value);
+ void progress(int value);
- void titleChanged(const QString &title);
- void unsupportedContent(QNetworkReply *reply);
- void downloadRequested(const QNetworkRequest &request);
+ void titleChanged(const QString& title);
+ void unsupportedContent(QNetworkReply* reply);
+ void downloadRequested(const QNetworkRequest& request);
- void tabCloseRequested(int index);
+ void tabCloseRequested(int index);
- void urlChanged(const QUrl &url);
+ void urlChanged(const QUrl& url);
- void on_backBtn_clicked();
+ void on_backBtn_clicked();
- void on_fwdBtn_clicked();
+ void on_fwdBtn_clicked();
- void on_searchEdit_returnPressed();
+ void on_searchEdit_returnPressed();
- void startSearch();
+ void startSearch();
- void on_refreshBtn_clicked();
+ void on_refreshBtn_clicked();
- void on_browserTabWidget_currentChanged(int index);
+ void on_browserTabWidget_currentChanged(int index);
- void on_urlEdit_returnPressed();
+ void on_urlEdit_returnPressed();
private:
+ QString guessFileName(const QString& url);
- QString guessFileName(const QString &url);
-
- BrowserView *getCurrentView();
+ BrowserView* getCurrentView();
- void maximizeWidth();
+ void maximizeWidth();
private:
+ Ui::BrowserDialog* ui;
- Ui::BrowserDialog *ui;
-
- QNetworkAccessManager *m_AccessManager;
-
- QTabWidget *m_Tabs;
-
+ QNetworkAccessManager* m_AccessManager;
+ QTabWidget* m_Tabs;
};
#endif // BROWSERDIALOG_H
diff --git a/src/browserview.cpp b/src/browserview.cpp
index 0b871e23..a44792b2 100644
--- a/src/browserview.cpp
+++ b/src/browserview.cpp
@@ -19,58 +19,53 @@ along with Mod Organizer. If not, see .
#include "browserview.h"
+#include "utility.h"
#include
#include
+#include
#include
#include
#include
-#include
#include
-#include "utility.h"
-
-BrowserView::BrowserView(QWidget *parent)
- : QWebEngineView(parent)
-{
- installEventFilter(this);
+BrowserView::BrowserView(QWidget* parent) : QWebEngineView(parent) {
+ installEventFilter(this);
- //page()->settings()->setMaximumPagesInCache(10);
+ // page()->settings()->setMaximumPagesInCache(10);
}
-QWebEngineView *BrowserView::createWindow(QWebEnginePage::WebWindowType)
-{
- BrowserView *newView = new BrowserView(parentWidget());
- emit initTab(newView);
- return newView;
+QWebEngineView* BrowserView::createWindow(QWebEnginePage::WebWindowType) {
+ BrowserView* newView = new BrowserView(parentWidget());
+ emit initTab(newView);
+ return newView;
}
-bool BrowserView::eventFilter(QObject *obj, QEvent *event)
-{
- if (event->type() == QEvent::ShortcutOverride) {
- QKeyEvent *keyEvent = static_cast(event);
- if (keyEvent->matches(QKeySequence::Find)) {
- emit startFind();
- } else if (keyEvent->matches(QKeySequence::FindNext)) {
- emit findAgain();
- }
- } else if (event->type() == QEvent::MouseButtonPress) {
- QMouseEvent *mouseEvent = static_cast(event);
- if (mouseEvent->button() == Qt::MidButton) {
- mouseEvent->ignore();
- return true;
+bool BrowserView::eventFilter(QObject* obj, QEvent* event) {
+ if (event->type() == QEvent::ShortcutOverride) {
+ QKeyEvent* keyEvent = static_cast(event);
+ if (keyEvent->matches(QKeySequence::Find)) {
+ emit startFind();
+ } else if (keyEvent->matches(QKeySequence::FindNext)) {
+ emit findAgain();
+ }
+ } else if (event->type() == QEvent::MouseButtonPress) {
+ QMouseEvent* mouseEvent = static_cast(event);
+ if (mouseEvent->button() == Qt::MidButton) {
+ mouseEvent->ignore();
+ return true;
+ }
+ // TODO This is due to that QTWebEnginePage doesn't support QWebFrame anymore
+ // } else if (event->type() == QEvent::MouseButtonRelease) {
+ // QMouseEvent *mouseEvent = static_cast(event);
+ // if (mouseEvent->button() == Qt::MidButton) {
+ // QWebEngineContextMenuData hitTest = page()->hitTestContent(mouseEvent->pos());
+ // if (hitTest.linkUrl().isValid()) {
+ // emit openUrlInNewTab(hitTest.linkUrl());
+ // }
+ // mouseEvent->ignore();
+ //
+ // return true;
+ // }
}
-// TODO This is due to that QTWebEnginePage doesn't support QWebFrame anymore
-// } else if (event->type() == QEvent::MouseButtonRelease) {
-// QMouseEvent *mouseEvent = static_cast(event);
-// if (mouseEvent->button() == Qt::MidButton) {
-// QWebEngineContextMenuData hitTest = page()->hitTestContent(mouseEvent->pos());
-// if (hitTest.linkUrl().isValid()) {
-// emit openUrlInNewTab(hitTest.linkUrl());
-// }
-// mouseEvent->ignore();
-//
-// return true;
-// }
- }
- return QWebEngineView::eventFilter(obj, event);
+ return QWebEngineView::eventFilter(obj, event);
}
diff --git a/src/browserview.h b/src/browserview.h
index 24be21c1..b390ed4e 100644
--- a/src/browserview.h
+++ b/src/browserview.h
@@ -20,62 +20,55 @@ along with Mod Organizer. If not, see .
#ifndef NEXUSVIEW_H
#define NEXUSVIEW_H
-
class QEvent;
class QUrl;
class QWidget;
-#include
#include
+#include
/**
* @brief web view used to display a nexus page
**/
-class BrowserView : public QWebEngineView
-{
+class BrowserView : public QWebEngineView {
Q_OBJECT
public:
-
- explicit BrowserView(QWidget *parent = 0);
+ explicit BrowserView(QWidget* parent = 0);
signals:
- /**
- * @brief emitted when the user opens a new window to be displayed in another tab
- *
- * @param newView the view for the newly opened window
- **/
- void initTab(BrowserView *newView);
-
- /**
- * @brief emitted when the user requests a link to be opened in a new tab by middle-clicking
- *
- * @param url the url to open
- */
- void openUrlInNewTab(const QUrl &url);
-
- /**
- * @brief Ctrl-f was clicked. The containing dialog should activate its find-facility
- */
- void startFind();
-
- /**
- * @brief F3 was pressed. The containing dialog should search again
- */
- void findAgain();
+ /**
+ * @brief emitted when the user opens a new window to be displayed in another tab
+ *
+ * @param newView the view for the newly opened window
+ **/
+ void initTab(BrowserView* newView);
+
+ /**
+ * @brief emitted when the user requests a link to be opened in a new tab by middle-clicking
+ *
+ * @param url the url to open
+ */
+ void openUrlInNewTab(const QUrl& url);
+
+ /**
+ * @brief Ctrl-f was clicked. The containing dialog should activate its find-facility
+ */
+ void startFind();
+
+ /**
+ * @brief F3 was pressed. The containing dialog should search again
+ */
+ void findAgain();
protected:
+ virtual QWebEngineView* createWindow(QWebEnginePage::WebWindowType type);
- virtual QWebEngineView *createWindow(QWebEnginePage::WebWindowType type);
-
- virtual bool eventFilter(QObject *obj, QEvent *event);
-
+ virtual bool eventFilter(QObject* obj, QEvent* event);
private:
-
- QString m_FindPattern;
- bool m_MiddleClick;
-
+ QString m_FindPattern;
+ bool m_MiddleClick;
};
#endif // NEXUSVIEW_H
diff --git a/src/categories.cpp b/src/categories.cpp
index d8cd49fb..c88227e6 100644
--- a/src/categories.cpp
+++ b/src/categories.cpp
@@ -19,350 +19,302 @@ along with Mod Organizer. If not, see .
#include "categories.h"
-#include
#include
+#include
-#include
-#include
+#include
#include
+#include
#include
-#include
-
+#include
using namespace MOBase;
-
CategoryFactory* CategoryFactory::s_Instance = nullptr;
+QString CategoryFactory::categoriesFilePath() { return qApp->property("dataPath").toString() + "/categories.dat"; }
-QString CategoryFactory::categoriesFilePath()
-{
- return qApp->property("dataPath").toString() + "/categories.dat";
-}
+CategoryFactory::CategoryFactory() { atexit(&cleanup); }
+void CategoryFactory::loadCategories() {
+ reset();
-CategoryFactory::CategoryFactory()
-{
- atexit(&cleanup);
-}
+ QFile categoryFile(categoriesFilePath());
-void CategoryFactory::loadCategories()
-{
- reset();
-
- QFile categoryFile(categoriesFilePath());
-
- if (!categoryFile.open(QIODevice::ReadOnly)) {
- loadDefaultCategories();
- } else {
- int lineNum = 0;
- while (!categoryFile.atEnd()) {
- QByteArray line = categoryFile.readLine();
- ++lineNum;
- QList cells = line.split('|');
- if (cells.count() != 4) {
- qCritical("invalid category line %d: %s (%d cells)",
- lineNum, line.constData(), cells.count());
- } else {
- std::vector nexusIDs;
- if (cells[2].length() > 0) {
- QList nexusIDStrings = cells[2].split(',');
- for (QList::iterator iter = nexusIDStrings.begin();
- iter != nexusIDStrings.end(); ++iter) {
- bool ok = false;
- int temp = iter->toInt(&ok);
- if (!ok) {
- qCritical("invalid id %s", iter->constData());
+ if (!categoryFile.open(QIODevice::ReadOnly)) {
+ loadDefaultCategories();
+ } else {
+ int lineNum = 0;
+ while (!categoryFile.atEnd()) {
+ QByteArray line = categoryFile.readLine();
+ ++lineNum;
+ QList cells = line.split('|');
+ if (cells.count() != 4) {
+ qCritical("invalid category line %d: %s (%d cells)", lineNum, line.constData(), cells.count());
+ } else {
+ std::vector nexusIDs;
+ if (cells[2].length() > 0) {
+ QList nexusIDStrings = cells[2].split(',');
+ for (QList::iterator iter = nexusIDStrings.begin(); iter != nexusIDStrings.end();
+ ++iter) {
+ bool ok = false;
+ int temp = iter->toInt(&ok);
+ if (!ok) {
+ qCritical("invalid id %s", iter->constData());
+ }
+ nexusIDs.push_back(temp);
+ }
+ }
+ bool cell0Ok = true;
+ bool cell3Ok = true;
+ int id = cells[0].toInt(&cell0Ok);
+ int parentID = cells[3].trimmed().toInt(&cell3Ok);
+ if (!cell0Ok || !cell3Ok) {
+ qCritical("invalid category line %d: %s", lineNum, line.constData());
+ }
+ addCategory(id, QString::fromUtf8(cells[1].constData()), nexusIDs, parentID);
}
- nexusIDs.push_back(temp);
- }
- }
- bool cell0Ok = true;
- bool cell3Ok = true;
- int id = cells[0].toInt(&cell0Ok);
- int parentID = cells[3].trimmed().toInt(&cell3Ok);
- if (!cell0Ok || !cell3Ok) {
- qCritical("invalid category line %d: %s",
- lineNum, line.constData());
}
- addCategory(id, QString::fromUtf8(cells[1].constData()), nexusIDs, parentID);
- }
+ categoryFile.close();
}
- categoryFile.close();
- }
- std::sort(m_Categories.begin(), m_Categories.end());
- setParents();
+ std::sort(m_Categories.begin(), m_Categories.end());
+ setParents();
}
-
-CategoryFactory &CategoryFactory::instance()
-{
- if (s_Instance == nullptr) {
- s_Instance = new CategoryFactory;
- }
- return *s_Instance;
+CategoryFactory& CategoryFactory::instance() {
+ if (s_Instance == nullptr) {
+ s_Instance = new CategoryFactory;
+ }
+ return *s_Instance;
}
-
-void CategoryFactory::reset()
-{
- m_Categories.clear();
- m_IDMap.clear();
- // 28 =
- // 43 = Savegames (makes no sense to install them through MO)
- // 45 = Videos and trailers
- // 87 = Miscelanous
- addCategory(0, "None", MakeVector(4, 28, 43, 45, 87), 0);
+void CategoryFactory::reset() {
+ m_Categories.clear();
+ m_IDMap.clear();
+ // 28 =
+ // 43 = Savegames (makes no sense to install them through MO)
+ // 45 = Videos and trailers
+ // 87 = Miscelanous
+ addCategory(0, "None", MakeVector(4, 28, 43, 45, 87), 0);
}
+void CategoryFactory::setParents() {
+ for (std::vector::iterator iter = m_Categories.begin(); iter != m_Categories.end(); ++iter) {
+ iter->m_HasChildren = false;
+ }
-void CategoryFactory::setParents()
-{
- for (std::vector::iterator iter = m_Categories.begin();
- iter != m_Categories.end(); ++iter) {
- iter->m_HasChildren = false;
- }
-
- for (std::vector::const_iterator categoryIter = m_Categories.begin();
- categoryIter != m_Categories.end(); ++categoryIter) {
- if (categoryIter->m_ParentID != 0) {
- std::map::const_iterator iter = m_IDMap.find(categoryIter->m_ParentID);
- if (iter != m_IDMap.end()) {
- m_Categories[iter->second].m_HasChildren = true;
- }
+ for (std::vector::const_iterator categoryIter = m_Categories.begin(); categoryIter != m_Categories.end();
+ ++categoryIter) {
+ if (categoryIter->m_ParentID != 0) {
+ std::map::const_iterator iter = m_IDMap.find(categoryIter->m_ParentID);
+ if (iter != m_IDMap.end()) {
+ m_Categories[iter->second].m_HasChildren = true;
+ }
+ }
}
- }
}
-void CategoryFactory::cleanup()
-{
- delete s_Instance;
- s_Instance = nullptr;
+void CategoryFactory::cleanup() {
+ delete s_Instance;
+ s_Instance = nullptr;
}
+void CategoryFactory::saveCategories() {
+ QFile categoryFile(categoriesFilePath());
-void CategoryFactory::saveCategories()
-{
- QFile categoryFile(categoriesFilePath());
-
- if (!categoryFile.open(QIODevice::WriteOnly)) {
- reportError(QObject::tr("Failed to save custom categories"));
- return;
- }
+ if (!categoryFile.open(QIODevice::WriteOnly)) {
+ reportError(QObject::tr("Failed to save custom categories"));
+ return;
+ }
- categoryFile.resize(0);
- for (std::vector::const_iterator iter = m_Categories.begin();
- iter != m_Categories.end(); ++iter) {
- if (iter->m_ID == 0) {
- continue;
+ categoryFile.resize(0);
+ for (std::vector::const_iterator iter = m_Categories.begin(); iter != m_Categories.end(); ++iter) {
+ if (iter->m_ID == 0) {
+ continue;
+ }
+ QByteArray line;
+ line.append(QByteArray::number(iter->m_ID))
+ .append("|")
+ .append(iter->m_Name.toUtf8())
+ .append("|")
+ .append(VectorJoin(iter->m_NexusIDs, ","))
+ .append("|")
+ .append(QByteArray::number(iter->m_ParentID))
+ .append("\n");
+ categoryFile.write(line);
}
- QByteArray line;
- line.append(QByteArray::number(iter->m_ID)).append("|")
- .append(iter->m_Name.toUtf8()).append("|")
- .append(VectorJoin(iter->m_NexusIDs, ",")).append("|")
- .append(QByteArray::number(iter->m_ParentID)).append("\n");
- categoryFile.write(line);
- }
- categoryFile.close();
+ categoryFile.close();
}
-
-unsigned int CategoryFactory::countCategories(std::tr1::function filter)
-{
- unsigned int result = 0;
- for (const Category &cat : m_Categories) {
- if (filter(cat)) {
- ++result;
+unsigned int CategoryFactory::countCategories(std::tr1::function filter) {
+ unsigned int result = 0;
+ for (const Category& cat : m_Categories) {
+ if (filter(cat)) {
+ ++result;
+ }
}
- }
- return result;
+ return result;
}
-int CategoryFactory::addCategory(const QString &name, const std::vector &nexusIDs, int parentID)
-{
- int id = 1;
- while (m_IDMap.find(id) != m_IDMap.end()) {
- ++id;
- }
- addCategory(id, name, nexusIDs, parentID);
-
- saveCategories();
- return id;
-}
+int CategoryFactory::addCategory(const QString& name, const std::vector& nexusIDs, int parentID) {
+ int id = 1;
+ while (m_IDMap.find(id) != m_IDMap.end()) {
+ ++id;
+ }
+ addCategory(id, name, nexusIDs, parentID);
-void CategoryFactory::addCategory(int id, const QString &name, const std::vector &nexusIDs, int parentID)
-{
- int index = static_cast(m_Categories.size());
- m_Categories.push_back(Category(index, id, name, nexusIDs, parentID));
- for (int nexusID : nexusIDs) {
- m_NexusMap[nexusID] = index;
- }
- m_IDMap[id] = index;
+ saveCategories();
+ return id;
}
-
-void CategoryFactory::loadDefaultCategories()
-{
- // the order here is relevant as it defines the order in which the
- // mods appear in the combo box
- addCategory(1, "Animations", MakeVector(2, 4, 51), 0);
- addCategory(52, "Poses", MakeVector(1, 29), 1);
- addCategory(2, "Armour", MakeVector(2, 5, 54), 0);
- addCategory(53, "Power Armor", MakeVector(1, 53), 2);
- addCategory(3, "Audio", MakeVector(3, 33, 35, 106), 0);
- addCategory(38, "Music", MakeVector(2, 34, 61), 0);
- addCategory(39, "Voice", MakeVector(2, 36, 107), 0);
- addCategory(5, "Clothing", MakeVector(2, 9, 60), 0);
- addCategory(41, "Jewelry", MakeVector(1, 102), 5);
- addCategory(42, "Backpacks", MakeVector(1, 49), 5);
- addCategory(6, "Collectables", MakeVector(2, 10, 92), 0);
- addCategory(28, "Companions", MakeVector(3, 11, 66, 96), 0);
- addCategory(7, "Creatures, Mounts, & Vehicles", MakeVector(4, 12, 65, 83, 101), 0);
- addCategory(8, "Factions", MakeVector(2, 16, 25), 0);
- addCategory(9, "Gameplay", MakeVector(2, 15, 24), 0);
- addCategory(27, "Combat", MakeVector(1, 77), 9);
- addCategory(43, "Crafting", MakeVector(2, 50, 100), 9);
- addCategory(48, "Overhauls", MakeVector(2, 24, 79), 9);
- addCategory(49, "Perks", MakeVector(1, 27), 9);
- addCategory(54, "Radio", MakeVector(1, 31), 9);
- addCategory(55, "Shouts", MakeVector(1, 104), 9);
- addCategory(22, "Skills & Levelling", MakeVector(2, 46, 73), 9);
- addCategory(58, "Weather & Lighting", MakeVector(1, 56), 9);
- addCategory(44, "Equipment", MakeVector(1, 44), 43);
- addCategory(45, "Home/Settlement", MakeVector(1, 45), 43);
- addCategory(10, "Body, Face, & Hair", MakeVector(2, 17, 26), 0);
- addCategory(39, "Tattoos", MakeVector(1, 57), 10);
- addCategory(40, "Character Presets", MakeVector(1, 58), 0);
- addCategory(11, "Items", MakeVector(2, 27, 85), 0);
- addCategory(32, "Mercantile", MakeVector(2, 23, 69), 0);
- addCategory(37, "Ammo", MakeVector(1, 3), 11);
- addCategory(19, "Weapons", MakeVector(2, 41, 55), 11);
- addCategory(36, "Weapon & Armour Sets", MakeVector(1, 42), 11);
- addCategory(23, "Player Homes", MakeVector(2, 28, 67), 0);
- addCategory(25, "Castles & Mansions", MakeVector(1, 68), 23);
- addCategory(51, "Settlements", MakeVector(1, 48), 23);
- addCategory(12, "Locations", MakeVector(10, 20, 21, 22, 30, 47, 70, 88, 89, 90, 91), 0);
- addCategory(4, "Cities", MakeVector(1, 53), 12);
- addCategory(31, "Landscape Changes", MakeVector(1, 58), 0);
- addCategory(29, "Environment", MakeVector(2, 14, 74), 0);
- addCategory(30, "Immersion", MakeVector(2, 51, 78), 0);
- addCategory(20, "Magic", MakeVector(3, 75, 93, 94), 0);
- addCategory(21, "Models & Textures", MakeVector(2, 19, 29), 0);
- addCategory(33, "Modders resources", MakeVector(2, 18, 82), 0);
- addCategory(13, "NPCs", MakeVector(3, 22, 33, 99), 0);
- addCategory(24, "Bugfixes", MakeVector(2, 6, 95), 0);
- addCategory(14, "Patches", MakeVector(2, 25, 84), 24);
- addCategory(35, "Utilities", MakeVector(2, 38, 39), 0);
- addCategory(26, "Cheats", MakeVector(1, 8), 0);
- addCategory(15, "Quests", MakeVector(2, 30, 35), 0);
- addCategory(16, "Races & Classes", MakeVector(1, 34), 0);
- addCategory(34, "Stealth", MakeVector(1, 76), 0);
- addCategory(17, "UI", MakeVector(2, 37, 42), 0);
- addCategory(18, "Visuals", MakeVector(2, 40, 62), 0);
- addCategory(50, "Pip-Boy", MakeVector(1, 52), 18);
- addCategory(46, "Shader Presets", MakeVector(3, 13, 97, 105), 0);
- addCategory(47, "Miscellaneous", MakeVector(2, 2, 28), 0);
+void CategoryFactory::addCategory(int id, const QString& name, const std::vector& nexusIDs, int parentID) {
+ int index = static_cast(m_Categories.size());
+ m_Categories.push_back(Category(index, id, name, nexusIDs, parentID));
+ for (int nexusID : nexusIDs) {
+ m_NexusMap[nexusID] = index;
+ }
+ m_IDMap[id] = index;
}
-
-int CategoryFactory::getParentID(unsigned int index) const
-{
- if (index >= m_Categories.size()) {
- throw MyException(QObject::tr("invalid index %1").arg(index));
- }
-
- return m_Categories[index].m_ParentID;
+void CategoryFactory::loadDefaultCategories() {
+ // the order here is relevant as it defines the order in which the
+ // mods appear in the combo box
+ addCategory(1, "Animations", MakeVector(2, 4, 51), 0);
+ addCategory(52, "Poses", MakeVector(1, 29), 1);
+ addCategory(2, "Armour", MakeVector(2, 5, 54), 0);
+ addCategory(53, "Power Armor", MakeVector(1, 53), 2);
+ addCategory(3, "Audio", MakeVector(3, 33, 35, 106), 0);
+ addCategory(38, "Music", MakeVector(2, 34, 61), 0);
+ addCategory(39, "Voice", MakeVector(2, 36, 107), 0);
+ addCategory(5, "Clothing", MakeVector(2, 9, 60), 0);
+ addCategory(41, "Jewelry", MakeVector(1, 102), 5);
+ addCategory(42, "Backpacks", MakeVector(1, 49), 5);
+ addCategory(6, "Collectables", MakeVector(2, 10, 92), 0);
+ addCategory(28, "Companions", MakeVector(3, 11, 66, 96), 0);
+ addCategory(7, "Creatures, Mounts, & Vehicles", MakeVector(4, 12, 65, 83, 101), 0);
+ addCategory(8, "Factions", MakeVector(2, 16, 25), 0);
+ addCategory(9, "Gameplay", MakeVector(2, 15, 24), 0);
+ addCategory(27, "Combat", MakeVector(1, 77), 9);
+ addCategory(43, "Crafting", MakeVector(2, 50, 100), 9);
+ addCategory(48, "Overhauls", MakeVector(2, 24, 79), 9);
+ addCategory(49, "Perks", MakeVector(1, 27), 9);
+ addCategory(54, "Radio", MakeVector(1, 31), 9);
+ addCategory(55, "Shouts", MakeVector(1, 104), 9);
+ addCategory(22, "Skills & Levelling", MakeVector(2, 46, 73), 9);
+ addCategory(58, "Weather & Lighting", MakeVector(1, 56), 9);
+ addCategory(44, "Equipment", MakeVector(1, 44), 43);
+ addCategory(45, "Home/Settlement", MakeVector(1, 45), 43);
+ addCategory(10, "Body, Face, & Hair", MakeVector(2, 17, 26), 0);
+ addCategory(39, "Tattoos", MakeVector(1, 57), 10);
+ addCategory(40, "Character Presets", MakeVector(1, 58), 0);
+ addCategory(11, "Items", MakeVector(2, 27, 85), 0);
+ addCategory(32, "Mercantile", MakeVector(2, 23, 69), 0);
+ addCategory(37, "Ammo", MakeVector(1, 3), 11);
+ addCategory(19, "Weapons", MakeVector(2, 41, 55), 11);
+ addCategory(36, "Weapon & Armour Sets", MakeVector(1, 42), 11);
+ addCategory(23, "Player Homes", MakeVector(2, 28, 67), 0);
+ addCategory(25, "Castles & Mansions", MakeVector(1, 68), 23);
+ addCategory(51, "Settlements", MakeVector(1, 48), 23);
+ addCategory(12, "Locations", MakeVector(10, 20, 21, 22, 30, 47, 70, 88, 89, 90, 91), 0);
+ addCategory(4, "Cities", MakeVector(1, 53), 12);
+ addCategory(31, "Landscape Changes", MakeVector(1, 58), 0);
+ addCategory(29, "Environment", MakeVector(2, 14, 74), 0);
+ addCategory(30, "Immersion", MakeVector(2, 51, 78), 0);
+ addCategory(20, "Magic", MakeVector(3, 75, 93, 94), 0);
+ addCategory(21, "Models & Textures", MakeVector(2, 19, 29), 0);
+ addCategory(33, "Modders resources", MakeVector(2, 18, 82), 0);
+ addCategory(13, "NPCs", MakeVector(3, 22, 33, 99), 0);
+ addCategory(24, "Bugfixes", MakeVector(2, 6, 95), 0);
+ addCategory(14, "Patches", MakeVector(2, 25, 84), 24);
+ addCategory(35, "Utilities", MakeVector(2, 38, 39), 0);
+ addCategory(26, "Cheats", MakeVector(1, 8), 0);
+ addCategory(15, "Quests", MakeVector(2, 30, 35), 0);
+ addCategory(16, "Races & Classes", MakeVector(1, 34), 0);
+ addCategory(34, "Stealth", MakeVector(1, 76), 0);
+ addCategory(17, "UI", MakeVector(2, 37, 42), 0);
+ addCategory(18, "Visuals", MakeVector(2, 40, 62), 0);
+ addCategory(50, "Pip-Boy", MakeVector(1, 52), 18);
+ addCategory(46, "Shader Presets", MakeVector(3, 13, 97, 105), 0);
+ addCategory(47, "Miscellaneous", MakeVector(2, 2, 28), 0);
}
+int CategoryFactory::getParentID(unsigned int index) const {
+ if (index >= m_Categories.size()) {
+ throw MyException(QObject::tr("invalid index %1").arg(index));
+ }
-bool CategoryFactory::categoryExists(int id) const
-{
- return m_IDMap.find(id) != m_IDMap.end();
+ return m_Categories[index].m_ParentID;
}
-
-bool CategoryFactory::isDecendantOf(int id, int parentID) const
-{
- std::map