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/usvfsconnector.cpp | 141 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 141 insertions(+)
create mode 100644 src/usvfsconnector.cpp
(limited to 'src/usvfsconnector.cpp')
diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp
new file mode 100644
index 00000000..6e1e5b31
--- /dev/null
+++ b/src/usvfsconnector.cpp
@@ -0,0 +1,141 @@
+/*
+Copyright (C) 2015 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 "usvfsconnector.h"
+#include
+#include
+#include
+#include
+
+
+static const char SHMID[] = "mod_organizer_instance";
+
+
+/*
+extern "C" DLLEXPORT BOOL WINAPI VirtualLinkFile(LPCWSTR source, LPCWSTR destination, BOOL failIfExists);
+extern "C" DLLEXPORT BOOL WINAPI VirtualLinkDirectoryStatic(LPCWSTR source, LPCWSTR destination, unsigned int flags);
+extern "C" DLLEXPORT BOOL WINAPI ConnectVFS(const usvfs::Parameters *parameters);
+extern "C" DLLEXPORT void WINAPI DisconnectVFS();
+extern "C" DLLEXPORT void WINAPI GetCurrentVFSName(char *buffer, size_t size);
+extern "C" DLLEXPORT BOOL WINAPI CreateProcessHooked(LPCWSTR lpApplicationName
+ , LPWSTR lpCommandLine
+ , LPSECURITY_ATTRIBUTES lpProcessAttributes
+ , LPSECURITY_ATTRIBUTES lpThreadAttributes
+ , BOOL bInheritHandles
+ , DWORD dwCreationFlags
+ , LPVOID lpEnvironment
+ , LPCWSTR lpCurrentDirectory
+ , LPSTARTUPINFOW lpStartupInfo
+ , LPPROCESS_INFORMATION lpProcessInformation
+ );
+extern "C" DLLEXPORT void __cdecl InitLogging(bool toLocal = false);
+extern "C" DLLEXPORT void __cdecl InitHooks(LPVOID userData, size_t userDataSize);
+*/
+
+
+LogWorker::LogWorker()
+ : m_Buffer(1024, '\0')
+ , m_QuitRequested(false)
+ , m_LogFile(new QTemporaryFile("usvfs-XXXXXX.log"))
+{
+ m_LogFile->open(QIODevice::WriteOnly);
+ qDebug("usvfs log messages are written to %s", qPrintable(m_LogFile->fileName()));
+}
+
+LogWorker::~LogWorker()
+{
+ delete m_LogFile;
+}
+
+void LogWorker::process()
+{
+ while (!m_QuitRequested) {
+ if (GetLogMessages(&m_Buffer[0], m_Buffer.size(), false)) {
+ m_LogFile->write(m_Buffer.c_str());
+ m_LogFile->write("\n");
+ m_LogFile->flush();
+
+ //emit outputLog(QString::fromStdString(m_Buffer));
+ } else {
+ QThread::sleep(1);
+ }
+ }
+ emit finished();
+}
+
+void LogWorker::exit()
+{
+ m_QuitRequested = true;
+
+}
+
+UsvfsConnector::UsvfsConnector()
+{
+ usvfs::Parameters params(SHMID, true, LogLevel::Debug);
+ InitLogging(false);
+ ConnectVFS(¶ms);
+
+ m_LogWorker.moveToThread(&m_WorkerThread);
+
+ connect(&m_WorkerThread, SIGNAL(started()), &m_LogWorker, SLOT(process()));
+ connect(&m_LogWorker, SIGNAL(finished()), &m_WorkerThread, SLOT(quit()));
+
+ m_WorkerThread.start(QThread::LowestPriority);
+}
+
+UsvfsConnector::~UsvfsConnector()
+{
+ DisconnectVFS();
+ m_LogWorker.exit();
+ m_WorkerThread.quit();
+ //m_WorkerThread.wait();
+}
+
+void UsvfsConnector::updateMapping(const MappingType &mapping)
+{
+ QProgressDialog progress;
+ progress.setLabelText(tr("Preparing vfs"));
+ progress.setMaximum(mapping.size());
+ progress.show();
+ int value = 0;
+ for (auto map : mapping) {
+ progress.setValue(value++);
+ if (value % 10 == 0) {
+ QCoreApplication::processEvents();
+ }
+ if (map.isDirectory) {
+ VirtualLinkDirectoryStatic(map.source.toStdWString().c_str()
+ , map.destination.toStdWString().c_str()
+ , 0);
+ } else {
+ VirtualLinkFile(map.source.toStdWString().c_str()
+ , map.destination.toStdWString().c_str()
+ , 0);
+ }
+ }
+/*
+ size_t dumpSize = 0;
+ CreateVFSDump(nullptr, &dumpSize);
+ std::unique_ptr buffer(new char[dumpSize]);
+ CreateVFSDump(buffer.get(), &dumpSize);
+ qDebug(buffer.get());
+*/
+}
+
--
cgit v1.3.1
From dbbd0c4eec8291fba7ce21670978255ec1ca2dbf Mon Sep 17 00:00:00 2001
From: Tannin
Date: Thu, 19 Nov 2015 19:10:18 +0100
Subject: usvfs log is now written to a persistent file (no log rotation yet
though)
---
src/usvfsconnector.cpp | 17 +++++++----------
src/usvfsconnector.h | 2 +-
2 files changed, 8 insertions(+), 11 deletions(-)
(limited to 'src/usvfsconnector.cpp')
diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp
index 6e1e5b31..62145475 100644
--- a/src/usvfsconnector.cpp
+++ b/src/usvfsconnector.cpp
@@ -53,26 +53,23 @@ extern "C" DLLEXPORT void __cdecl InitHooks(LPVOID userData, size_t userDataSize
LogWorker::LogWorker()
: m_Buffer(1024, '\0')
, m_QuitRequested(false)
- , m_LogFile(new QTemporaryFile("usvfs-XXXXXX.log"))
+ , m_LogFile(qApp->property("dataPath").toString() + "/logs/usvfs.log")
{
- m_LogFile->open(QIODevice::WriteOnly);
- qDebug("usvfs log messages are written to %s", qPrintable(m_LogFile->fileName()));
+ m_LogFile.open(QIODevice::WriteOnly);
+ qDebug("usvfs log messages are written to %s", qPrintable(m_LogFile.fileName()));
}
LogWorker::~LogWorker()
{
- delete m_LogFile;
}
void LogWorker::process()
{
while (!m_QuitRequested) {
if (GetLogMessages(&m_Buffer[0], m_Buffer.size(), false)) {
- m_LogFile->write(m_Buffer.c_str());
- m_LogFile->write("\n");
- m_LogFile->flush();
-
- //emit outputLog(QString::fromStdString(m_Buffer));
+ m_LogFile.write(m_Buffer.c_str());
+ m_LogFile.write("\n");
+ m_LogFile.flush();
} else {
QThread::sleep(1);
}
@@ -88,7 +85,7 @@ void LogWorker::exit()
UsvfsConnector::UsvfsConnector()
{
- usvfs::Parameters params(SHMID, true, LogLevel::Debug);
+ usvfs::Parameters params(SHMID, false, LogLevel::Debug);
InitLogging(false);
ConnectVFS(¶ms);
diff --git a/src/usvfsconnector.h b/src/usvfsconnector.h
index 464b932b..beec5acc 100644
--- a/src/usvfsconnector.h
+++ b/src/usvfsconnector.h
@@ -61,7 +61,7 @@ private:
std::string m_Buffer;
bool m_QuitRequested;
- QFile *m_LogFile;
+ QFile m_LogFile;
};
--
cgit v1.3.1
From fe8c3aaea58400425b9195bb670a1b4e8c9db10d Mon Sep 17 00:00:00 2001
From: Tannin
Date: Mon, 23 Nov 2015 21:44:47 +0100
Subject: some fixes and removed obsolete code
---
src/main.cpp | 2 +-
src/mainwindow.cpp | 184 ++-----------------------------------------------
src/mainwindow.h | 5 --
src/mainwindow.ui | 101 ---------------------------
src/usvfsconnector.cpp | 8 ++-
5 files changed, 12 insertions(+), 288 deletions(-)
(limited to 'src/usvfsconnector.cpp')
diff --git a/src/main.cpp b/src/main.cpp
index 07d6fa19..7061a6e3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -123,7 +123,7 @@ bool bootstrap()
// cycle logfile
removeOldFiles(qApp->property("dataPath").toString() + "/" + QString::fromStdWString(AppConfig::logPath()),
- "ModOrganizer*.log", 5, QDir::Name);
+ "usvfs*.log", 5, QDir::Name);
createAndMakeWritable(AppConfig::profilesPath());
createAndMakeWritable(AppConfig::modsPath());
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index e34d8b03..71013c3c 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -186,6 +186,7 @@ MainWindow::MainWindow(const QString &exeName
m_RefreshProgress->setVisible(false);
statusBar()->addWidget(m_RefreshProgress, 1000);
statusBar()->clearMessage();
+ statusBar()->hide();
ui->actionEndorseMO->setVisible(false);
@@ -233,8 +234,6 @@ MainWindow::MainWindow(const QString &exeName
}
ui->espList->installEventFilter(m_OrganizerCore.pluginList());
- ui->bsaList->setLocalMoveOnly(true);
-
ui->splitter->setStretchFactor(0, 3);
ui->splitter->setStretchFactor(1, 2);
@@ -302,9 +301,6 @@ MainWindow::MainWindow(const QString &exeName
connect(this, SIGNAL(styleChanged(QString)), this, SLOT(updateStyle(QString)));
- m_CheckBSATimer.setSingleShot(true);
- connect(&m_CheckBSATimer, SIGNAL(timeout()), this, SLOT(checkBSAList()));
-
m_UpdateProblemsTimer.setSingleShot(true);
connect(&m_UpdateProblemsTimer, SIGNAL(timeout()), this, SLOT(updateProblemsButton()));
@@ -1317,157 +1313,6 @@ static QStringList toStringList(InputIterator current, InputIterator end)
return result;
}
-void MainWindow::updateBSAList(const QStringList &defaultArchives, const QStringList &activeArchives)
-{
- m_DefaultArchives = defaultArchives;
- ui->bsaList->clear();
-#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
- ui->bsaList->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
-#else
- ui->bsaList->header()->setResizeMode(QHeaderView::ResizeToContents);
-#endif
-
- std::vector> items;
-
- IPluginGame *gamePlugin = qApp->property("managed_game").value();
- BSAInvalidation *invalidation = gamePlugin->feature();
- std::vector files = m_OrganizerCore.directoryStructure()->getFiles();
-
- QStringList plugins = m_OrganizerCore.findFiles("", [] (const QString &fileName) -> bool {
- return fileName.endsWith(".esp", Qt::CaseInsensitive)
- || fileName.endsWith(".esm", Qt::CaseInsensitive);
- });
-
- auto hasAssociatedPlugin = [&](const QString &bsaName) -> bool {
- for (const QString &pluginName : plugins) {
- QFileInfo pluginInfo(pluginName);
- if (bsaName.startsWith(QFileInfo(pluginName).baseName(), Qt::CaseInsensitive)
- && (m_OrganizerCore.pluginList()->state(pluginInfo.fileName()) == IPluginList::STATE_ACTIVE)) {
- return true;
- }
- }
- return false;
- };
-
- for (FileEntry::Ptr current : files) {
- QFileInfo fileInfo(ToQString(current->getName().c_str()));
-
- if (fileInfo.suffix().toLower() == "bsa") {
- int index = activeArchives.indexOf(fileInfo.fileName());
- if (index == -1) {
- index = 0xFFFF;
- } else {
- index += 2;
- }
-
- if ((invalidation != nullptr) && invalidation->isInvalidationBSA(fileInfo.fileName())) {
- index = 1;
- }
-
- int originId = current->getOrigin();
- FilesOrigin &origin = m_OrganizerCore.directoryStructure()->getOriginByID(originId);
-
- QTreeWidgetItem *newItem = new QTreeWidgetItem(QStringList()
- << fileInfo.fileName()
- << ToQString(origin.getName()));
- newItem->setData(0, Qt::UserRole, index);
- newItem->setData(1, Qt::UserRole, originId);
- newItem->setFlags(newItem->flags() & ~Qt::ItemIsDropEnabled | Qt::ItemIsUserCheckable);
- newItem->setCheckState(0, (index != -1) ? Qt::Checked : Qt::Unchecked);
- newItem->setData(0, Qt::UserRole, false);
- if (m_OrganizerCore.settings().forceEnableCoreFiles()
- && defaultArchives.contains(fileInfo.fileName())) {
- newItem->setCheckState(0, Qt::Checked);
- newItem->setDisabled(true);
- newItem->setData(0, Qt::UserRole, true);
- } else if (fileInfo.fileName().compare("update.bsa", Qt::CaseInsensitive) == 0) {
- newItem->setCheckState(0, Qt::Checked);
- newItem->setDisabled(true);
- } else if (hasAssociatedPlugin(fileInfo.fileName())) {
- newItem->setCheckState(0, Qt::Checked);
- newItem->setDisabled(true);
- }
-
- if (index < 0) index = 0;
-
- UINT32 sortValue = ((origin.getPriority() & 0xFFFF) << 16) | (index & 0xFFFF);
- items.push_back(std::make_pair(sortValue, newItem));
- }
- }
-
- std::sort(items.begin(), items.end(), BySortValue);
-
- for (auto iter = items.begin(); iter != items.end(); ++iter) {
- int originID = iter->second->data(1, Qt::UserRole).toInt();
-
- FilesOrigin origin = m_OrganizerCore.directoryStructure()->getOriginByID(originID);
- QString modName("data");
- unsigned int modIndex = ModInfo::getIndex(ToQString(origin.getName()));
- if (modIndex != UINT_MAX) {
- ModInfo::Ptr modInfo = ModInfo::getByIndex(modIndex);
- modName = modInfo->name();
- }
- QList items = ui->bsaList->findItems(modName, Qt::MatchFixedString);
- QTreeWidgetItem *subItem = nullptr;
- if (items.length() > 0) {
- subItem = items.at(0);
- } else {
- subItem = new QTreeWidgetItem(QStringList(modName));
- subItem->setFlags(subItem->flags() & ~Qt::ItemIsDragEnabled);
- ui->bsaList->addTopLevelItem(subItem);
- }
- subItem->addChild(iter->second);
- subItem->setExpanded(true);
- }
-
- checkBSAList();
-}
-
-
-void MainWindow::checkBSAList()
-{
- DataArchives *archives = m_OrganizerCore.managedGame()->feature();
-
- if (archives != nullptr) {
- ui->bsaList->blockSignals(true);
- ON_BLOCK_EXIT([&] () { ui->bsaList->blockSignals(false); });
-
- QStringList defaultArchives = archives->archives(m_OrganizerCore.currentProfile());
-
- bool warning = false;
-
- for (int i = 0; i < ui->bsaList->topLevelItemCount(); ++i) {
- bool modWarning = false;
- QTreeWidgetItem *tlItem = ui->bsaList->topLevelItem(i);
- for (int j = 0; j < tlItem->childCount(); ++j) {
- QTreeWidgetItem *item = tlItem->child(j);
- QString filename = item->text(0);
- item->setIcon(0, QIcon());
- item->setToolTip(0, QString());
-
- if (item->checkState(0) == Qt::Unchecked) {
- if (defaultArchives.contains(filename)) {
- item->setIcon(0, QIcon(":/MO/gui/warning"));
- item->setToolTip(0, tr("This bsa is enabled in the ini file so it may be required!"));
- modWarning = true;
- }
- }
- }
- if (modWarning) {
- ui->bsaList->expandItem(ui->bsaList->topLevelItem(i));
- warning = true;
- }
- }
-
- if (warning) {
- ui->tabWidget->setTabIcon(1, QIcon(":/MO/gui/warning"));
- } else {
- ui->tabWidget->setTabIcon(1, QIcon());
- }
- }
-}
-
-
void MainWindow::saveModMetas()
{
for (unsigned int i = 0; i < ModInfo::getNumMods(); ++i) {
@@ -1476,7 +1321,6 @@ void MainWindow::saveModMetas()
}
}
-
void MainWindow::fixCategories()
{
for (unsigned int i = 0; i < ModInfo::getNumMods(); ++i) {
@@ -1856,8 +1700,10 @@ void MainWindow::setESPListSorting(int index)
void MainWindow::refresher_progress(int percent)
{
if (percent == 100) {
-// m_RefreshProgress->setVisible(false);
+ m_RefreshProgress->setVisible(false);
+ statusBar()->hide();
} else if (!m_RefreshProgress->isVisible()) {
+ statusBar()->show();
m_RefreshProgress->setVisible(true);
m_RefreshProgress->setRange(0, 100);
m_RefreshProgress->setValue(percent);
@@ -3815,8 +3661,7 @@ void MainWindow::updateDownloadListDelegate()
void MainWindow::modDetailsUpdated(bool)
{
- --m_ModsToUpdate;
- if (m_ModsToUpdate == 0) {
+ if (--m_ModsToUpdate == 0) {
statusBar()->hide();
m_ModListSortProxy->setCategoryFilter(boost::assign::list_of(CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE));
for (int i = 0; i < ui->categoriesList->topLevelItemCount(); ++i) {
@@ -4022,19 +3867,6 @@ void MainWindow::displayColumnSelection(const QPoint &pos)
}
}
-
-void MainWindow::on_bsaList_customContextMenuRequested(const QPoint &pos)
-{
- m_ContextItem = ui->bsaList->itemAt(pos);
-
-// m_ContextRow = ui->bsaList->indexOfTopLevelItem(ui->bsaList->itemAt(pos));
-
- QMenu menu;
- menu.addAction(tr("Extract..."), this, SLOT(extractBSATriggered()));
-
- menu.exec(ui->bsaList->mapToGlobal(pos));
-}
-
void MainWindow::on_actionProblems_triggered()
{
ProblemsDialog problems(m_PluginContainer.plugins(), this);
@@ -4610,12 +4442,6 @@ void MainWindow::on_categoriesOrBtn_toggled(bool checked)
}
}
-void MainWindow::on_managedArchiveLabel_linkHovered(const QString&)
-{
- QToolTip::showText(QCursor::pos(),
- ui->managedArchiveLabel->toolTip());
-}
-
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
//Accept copy or move drags to the download window. Link drags are not
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 279c8922..44f46f4b 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -88,7 +88,6 @@ public:
virtual bool unlockClicked() override;
bool addProfile();
- void updateBSAList(const QStringList &defaultArchives, const QStringList &activeArchives);
void refreshDataTree();
void refreshSaveList();
@@ -439,8 +438,6 @@ private slots:
void startExeAction();
- void checkBSAList();
-
void updateProblemsButton();
void saveModMetas();
@@ -494,7 +491,6 @@ private slots: // ui slots
void on_actionUpdate_triggered();
void on_actionEndorseMO_triggered();
- void on_bsaList_customContextMenuRequested(const QPoint &pos);
void on_btnRefreshData_clicked();
void on_categoriesList_customContextMenuRequested(const QPoint &pos);
void on_conflictsCheckBox_toggled(bool checked);
@@ -522,7 +518,6 @@ private slots: // ui slots
void on_actionCopy_Log_to_Clipboard_triggered();
void on_categoriesAndBtn_toggled(bool checked);
void on_categoriesOrBtn_toggled(bool checked);
- void on_managedArchiveLabel_linkHovered(const QString &link);
};
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index 7d7eeca8..02319bee 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -884,102 +884,6 @@ p, li { white-space: pre-wrap; }
-
-
- Archives
-
-
-
- 6
-
-
- 6
-
-
- 6
-
-
- 6
-
- -
-
-
-
-
-
- <html><head/><body><p>BSAs are bundles of game assets (textures, scripts, ...). By default, the engine loads these bundles in a separate step from loose files. MO can manage those archives to align their load order with that of loose files:</p><p>If archives are <span style=" font-weight:600;">managed</span>, their load order is specified by the priority of the corresponding mod (left pane), the same as the loose files. You can manually enable any BSA that has no corresponding plugin active.<br/></p><p>If archives are <span style=" font-weight:600;">not managed</span> their load order is specified by the priority of the corresponding plugin (right pane, plugins tab). You can then not manually enable BSAs where the plugin isn't active.</p><p>In either case you can not disable archives if there is a matching plugin, the game will load them no matter what.</p></body></html>
-
-
- <html><head/><body><p>Archive order follows Plugin order.</p></body></html>
-
-
- true
-
-
-
-
-
- -
-
-
- Qt::CustomContextMenu
-
-
- List of available BS Archives. Archives not checked here are not managed by MO and ignore installation order.
-
-
- BSA files are archives (comparable to .zip files) that contain data assets (meshes, textures, ...) to be used by the game. As such they "compete" with loose files in your data directory over which is loaded.
-By default, BSAs that share their base name with an enabled ESP (i.e. plugin.esp and plugin.bsa) are automatically loaded and will have precedence over all loose files, the installation order you set up to the left is then ignored!
-
-BSAs checked here are loaded in such a way that your installation order is obeyed properly.
-
-
- QAbstractItemView::NoEditTriggers
-
-
- true
-
-
- false
-
-
- false
-
-
- QAbstractItemView::DragDrop
-
-
- Qt::MoveAction
-
-
- QAbstractItemView::SingleSelection
-
-
- QAbstractItemView::SelectRows
-
-
- 20
-
-
- true
-
-
- 1
-
-
- false
-
-
- 200
-
-
-
- File
-
-
-
-
-
-
Data
@@ -1477,11 +1381,6 @@ Right now this has very limited functionality
QTreeView
-
- MOBase::SortableTreeWidget
- QTreeWidget
-
-
diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp
index 62145475..a29d806e 100644
--- a/src/usvfsconnector.cpp
+++ b/src/usvfsconnector.cpp
@@ -22,6 +22,7 @@ along with Mod Organizer. If not, see .
#include
#include
#include
+#include
#include
@@ -53,10 +54,13 @@ extern "C" DLLEXPORT void __cdecl InitHooks(LPVOID userData, size_t userDataSize
LogWorker::LogWorker()
: m_Buffer(1024, '\0')
, m_QuitRequested(false)
- , m_LogFile(qApp->property("dataPath").toString() + "/logs/usvfs.log")
+ , m_LogFile(qApp->property("dataPath").toString()
+ + QString("/logs/usvfs-%1.log").arg(
+ QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd_hh-mm-ss")))
{
m_LogFile.open(QIODevice::WriteOnly);
- qDebug("usvfs log messages are written to %s", qPrintable(m_LogFile.fileName()));
+ qDebug("usvfs log messages are written to %s",
+ qPrintable(m_LogFile.fileName()));
}
LogWorker::~LogWorker()
--
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/usvfsconnector.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 568b2abc1244228670a0d0e1dea768d8a7d8727e Mon Sep 17 00:00:00 2001
From: Tannin
Date: Fri, 18 Dec 2015 20:16:28 +0100
Subject: removed close-mo feature
---
src/editexecutablesdialog.cpp | 13 ------
src/editexecutablesdialog.ui | 17 --------
src/executableslist.cpp | 7 +---
src/executableslist.h | 8 +---
src/mainwindow.cpp | 5 +--
src/mainwindow.h | 2 +-
src/organizercore.cpp | 92 +++++++++++++++++++------------------------
src/usvfsconnector.cpp | 3 +-
8 files changed, 46 insertions(+), 101 deletions(-)
(limited to 'src/usvfsconnector.cpp')
diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp
index b9d548a6..1b2d5a48 100644
--- a/src/editexecutablesdialog.cpp
+++ b/src/editexecutablesdialog.cpp
@@ -85,7 +85,6 @@ void EditExecutablesDialog::resetInput()
ui->argumentsEdit->setText("");
ui->appIDOverwriteEdit->clear();
ui->overwriteAppIDBox->setChecked(false);
- ui->closeCheckBox->setChecked(false);
ui->useAppIconCheckBox->setChecked(false);
m_CurrentItem = nullptr;
}
@@ -97,9 +96,6 @@ void EditExecutablesDialog::saveExecutable()
QDir::fromNativeSeparators(ui->binaryEdit->text()),
ui->argumentsEdit->text(),
QDir::fromNativeSeparators(ui->workingDirEdit->text()),
- (ui->closeCheckBox->checkState() == Qt::Checked) ?
- ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE
- : ExecutableInfo::CloseMOStyle::DEFAULT_STAY,
ui->overwriteAppIDBox->isChecked() ?
ui->appIDOverwriteEdit->text() : "",
Executable::UseApplicationIcon | Executable::CustomExecutable,
@@ -218,7 +214,6 @@ bool EditExecutablesDialog::executableChanged()
|| selectedExecutable.m_SteamAppID != ui->appIDOverwriteEdit->text()
|| selectedExecutable.m_WorkingDirectory != QDir::fromNativeSeparators(ui->workingDirEdit->text())
|| selectedExecutable.m_BinaryInfo.absoluteFilePath() != QDir::fromNativeSeparators(ui->binaryEdit->text())
- || (selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE) != ui->closeCheckBox->isChecked()
|| selectedExecutable.usesOwnIcon() != ui->useAppIconCheckBox->isChecked();
} else {
QFileInfo fileInfo(ui->binaryEdit->text());
@@ -291,14 +286,6 @@ void EditExecutablesDialog::on_executablesListBox_clicked(const QModelIndex &cur
ui->binaryEdit->setText(QDir::toNativeSeparators(selectedExecutable.m_BinaryInfo.absoluteFilePath()));
ui->argumentsEdit->setText(selectedExecutable.m_Arguments);
ui->workingDirEdit->setText(QDir::toNativeSeparators(selectedExecutable.m_WorkingDirectory));
- ui->closeCheckBox->setChecked(selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE);
- if (selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::NEVER_CLOSE) {
- ui->closeCheckBox->setEnabled(false);
- ui->closeCheckBox->setToolTip(tr("MO must be kept running or this application will not work correctly."));
- } else {
- ui->closeCheckBox->setEnabled(true);
- ui->closeCheckBox->setToolTip(tr("If checked, MO will be closed once the specified executable is run."));
- }
ui->removeButton->setEnabled(selectedExecutable.isCustom());
ui->overwriteAppIDBox->setChecked(!selectedExecutable.m_SteamAppID.isEmpty());
if (!selectedExecutable.m_SteamAppID.isEmpty()) {
diff --git a/src/editexecutablesdialog.ui b/src/editexecutablesdialog.ui
index abb6fe68..a2aad19a 100644
--- a/src/editexecutablesdialog.ui
+++ b/src/editexecutablesdialog.ui
@@ -164,19 +164,6 @@ Right now the only case I know of where this needs to be overwritten is for the
- -
-
-
- If checked, MO will be closed once the specified executable is run.
-
-
- If checked, MO will be closed once the specified executable is run.
-
-
- Close MO when started
-
-
-
-
@@ -247,10 +234,6 @@ Right now the only case I know of where this needs to be overwritten is for the
- executablesListBox
- closeButton
- closeCheckBox
- useAppIconCheckBox
diff --git a/src/executableslist.cpp b/src/executableslist.cpp
index a4511ade..9fe4596c 100644
--- a/src/executableslist.cpp
+++ b/src/executableslist.cpp
@@ -50,7 +50,6 @@ void ExecutablesList::init(IPluginGame const *game)
info.binary().absoluteFilePath(),
info.arguments().join(" "),
info.workingDirectory().absolutePath(),
- info.closeMO(),
info.steamAppID());
}
}
@@ -135,7 +134,6 @@ void ExecutablesList::updateExecutable(const QString &title,
const QString &executableName,
const QString &arguments,
const QString &workingDirectory,
- ExecutableInfo::CloseMOStyle closeMO,
const QString &steamAppID,
Executable::Flags mask,
Executable::Flags flags)
@@ -146,7 +144,6 @@ void ExecutablesList::updateExecutable(const QString &title,
if (existingExe != m_Executables.end()) {
existingExe->m_Title = title;
- existingExe->m_CloseMO = closeMO;
existingExe->m_Flags &= ~mask;
existingExe->m_Flags |= flags;
// for pre-configured executables don't overwrite settings we didn't store
@@ -162,7 +159,6 @@ void ExecutablesList::updateExecutable(const QString &title,
} else {
Executable newExe;
newExe.m_Title = title;
- newExe.m_CloseMO = closeMO;
newExe.m_BinaryInfo = file;
newExe.m_Arguments = arguments;
newExe.m_WorkingDirectory = workingDirectory;
@@ -186,12 +182,11 @@ void ExecutablesList::remove(const QString &title)
void ExecutablesList::addExecutableInternal(const QString &title, const QString &executableName,
const QString &arguments, const QString &workingDirectory,
- ExecutableInfo::CloseMOStyle closeMO, const QString &steamAppID)
+ const QString &steamAppID)
{
QFileInfo file(executableName);
if (file.exists()) {
Executable newExe;
- newExe.m_CloseMO = closeMO;
newExe.m_BinaryInfo = file;
newExe.m_Title = title;
newExe.m_Arguments = arguments;
diff --git a/src/executableslist.h b/src/executableslist.h
index 3d5ba0ed..eb7d2d6f 100644
--- a/src/executableslist.h
+++ b/src/executableslist.h
@@ -36,7 +36,6 @@ struct Executable {
QString m_Title;
QFileInfo m_BinaryInfo;
QString m_Arguments;
- MOBase::ExecutableInfo::CloseMOStyle m_CloseMO;
QString m_SteamAppID;
QString m_WorkingDirectory;
@@ -126,17 +125,15 @@ public:
* @param title name displayed in the UI
* @param executableName the actual filename to execute
* @param arguments arguments to pass to the executable
- * @param closeMO if true, MO will be closed when the binary is started
**/
void addExecutable(const QString &title,
const QString &executableName,
const QString &arguments,
const QString &workingDirectory,
- MOBase::ExecutableInfo::CloseMOStyle closeMO,
const QString &steamAppID,
Executable::Flags flags)
{
- updateExecutable(title, executableName, arguments, workingDirectory, closeMO, steamAppID, Executable::AllFlags, flags);
+ updateExecutable(title, executableName, arguments, workingDirectory, steamAppID, Executable::AllFlags, flags);
}
/**
@@ -151,7 +148,6 @@ public:
const QString &executableName,
const QString &arguments,
const QString &workingDirectory,
- MOBase::ExecutableInfo::CloseMOStyle closeMO,
const QString &steamAppID,
Executable::Flags mask,
Executable::Flags flags);
@@ -192,7 +188,7 @@ private:
std::vector::iterator findExe(const QString &title);
void addExecutableInternal(const QString &title, const QString &executableName, const QString &arguments,
- const QString &workingDirectory, MOBase::ExecutableInfo::CloseMOStyle closeMO,
+ const QString &workingDirectory,
const QString &steamAppID);
private:
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index edcfe223..1a7d1564 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -583,7 +583,7 @@ bool MainWindow::errorReported(QString &logFile)
}
-int MainWindow::checkForProblems()
+size_t MainWindow::checkForProblems()
{
size_t numProblems = 0;
for (IPluginDiagnose *diagnose : m_PluginContainer.plugins()) {
@@ -980,7 +980,6 @@ void MainWindow::startExeAction()
selectedExecutable.m_Arguments,
selectedExecutable.m_WorkingDirectory.length() != 0 ? selectedExecutable.m_WorkingDirectory
: selectedExecutable.m_BinaryInfo.absolutePath(),
- selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE,
selectedExecutable.m_SteamAppID);
} else {
qCritical("not an action?");
@@ -1497,7 +1496,6 @@ void MainWindow::on_startButton_clicked()
selectedExecutable.m_Arguments,
selectedExecutable.m_WorkingDirectory.length() != 0 ? selectedExecutable.m_WorkingDirectory
: selectedExecutable.m_BinaryInfo.absolutePath(),
- selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE,
selectedExecutable.m_SteamAppID);
}
@@ -3423,7 +3421,6 @@ void MainWindow::addAsExecutable()
binaryInfo.absoluteFilePath(),
arguments,
targetInfo.absolutePath(),
- ExecutableInfo::CloseMOStyle::DEFAULT_STAY,
QString(),
Executable::CustomExecutable);
refreshExecutablesList();
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 489f9145..49476bf3 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -209,7 +209,7 @@ private:
bool extractProgress(QProgressDialog &extractProgress, int percentage, std::string fileName);
- int checkForProblems();
+ size_t checkForProblems();
int getBinaryExecuteInfo(const QFileInfo &targetInfo, QFileInfo &binaryInfo, QString &arguments);
QTreeWidgetItem *addFilterItem(QTreeWidgetItem *root, const QString &name, int categoryID, ModListSortProxy::FilterType type);
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index fdc11c2a..59a58e48 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -236,7 +236,6 @@ QSettings::Status OrganizerCore::storeSettings(const QString &fileName)
settings.setValue("binary", item.m_BinaryInfo.absoluteFilePath());
settings.setValue("arguments", item.m_Arguments);
settings.setValue("workingDirectory", item.m_WorkingDirectory);
- settings.setValue("closeOnStart", item.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE);
settings.setValue("steamAppID", item.m_SteamAppID);
}
}
@@ -338,9 +337,6 @@ void OrganizerCore::updateExecutablesList(QSettings &settings)
int numCustomExecutables = settings.beginReadArray("customExecutables");
for (int i = 0; i < numCustomExecutables; ++i) {
settings.setArrayIndex(i);
- ExecutableInfo::CloseMOStyle closeMO =
- settings.value("closeOnStart").toBool() ? ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE
- : ExecutableInfo::CloseMOStyle::DEFAULT_STAY;
Executable::Flags flags;
if (settings.value("custom", true).toBool()) flags |= Executable::CustomExecutable;
@@ -351,7 +347,6 @@ void OrganizerCore::updateExecutablesList(QSettings &settings)
settings.value("binary").toString(),
settings.value("arguments").toString(),
settings.value("workingDirectory", "").toString(),
- closeMO,
settings.value("steamAppID", "").toString(),
flags);
}
@@ -875,7 +870,7 @@ ModList *OrganizerCore::modList()
return &m_ModList;
}
-void OrganizerCore::spawnBinary(const QFileInfo &binary, const QString &arguments, const QDir ¤tDirectory, bool closeAfterStart, const QString &steamAppID)
+void OrganizerCore::spawnBinary(const QFileInfo &binary, const QString &arguments, const QDir ¤tDirectory, const QString &steamAppID)
{
LockedDialog *dialog = new LockedDialog(qApp->activeWindow());
dialog->show();
@@ -883,55 +878,52 @@ void OrganizerCore::spawnBinary(const QFileInfo &binary, const QString &argument
HANDLE processHandle = spawnBinaryDirect(binary, arguments, m_CurrentProfile->name(), currentDirectory, steamAppID);
if (processHandle != INVALID_HANDLE_VALUE) {
- if (closeAfterStart && (m_UserInterface != nullptr)) {
- m_UserInterface->closeWindow();
- } else {
- if (m_UserInterface != nullptr) {
- m_UserInterface->setWindowEnabled(false);
- }
- // re-enable the locked dialog because what'd be the point otherwise?
- dialog->setEnabled(true);
-
- QCoreApplication::processEvents();
-
- DWORD processExitCode;
- DWORD retLen;
- JOBOBJECT_BASIC_PROCESS_ID_LIST info;
-
- {
- 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)));
- }
- }
+ if (m_UserInterface != nullptr) {
+ m_UserInterface->setWindowEnabled(false);
+ }
+ // re-enable the locked dialog because what'd be the point otherwise?
+ dialog->setEnabled(true);
+
+ QCoreApplication::processEvents();
+
+ DWORD processExitCode;
+ DWORD retLen;
+ JOBOBJECT_BASIC_PROCESS_ID_LIST info;
+
+ {
+ 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 {
- // 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 (info.ProcessIdList[0] != currentProcess) {
+ currentProcess = info.ProcessIdList[0];
+ dialog->setProcessName(ToQString(getProcessName(currentProcess)));
}
}
+ } 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;
+ }
}
+ }
- // keep processing events so the app doesn't appear dead
- QCoreApplication::processEvents();
+ // keep processing events so the app doesn't appear dead
+ QCoreApplication::processEvents();
- res = ::MsgWaitForMultipleObjects(1, &processHandle, false, 1000, QS_KEY | QS_MOUSE);
- }
- ::GetExitCodeProcess(processHandle, &processExitCode);
+ res = ::MsgWaitForMultipleObjects(1, &processHandle, false, 1000, QS_KEY | QS_MOUSE);
}
+ ::GetExitCodeProcess(processHandle, &processExitCode);
+
::CloseHandle(processHandle);
if (m_UserInterface != nullptr) {
@@ -1640,10 +1632,6 @@ 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/usvfsconnector.cpp b/src/usvfsconnector.cpp
index 23a51891..f3a45dfe 100644
--- a/src/usvfsconnector.cpp
+++ b/src/usvfsconnector.cpp
@@ -60,8 +60,7 @@ LogWorker::LogWorker()
QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd_hh-mm-ss")))
{
m_LogFile.open(QIODevice::WriteOnly);
- qDebug("usvfs log messages are written to %s",
- qPrintable(m_LogFile.fileName()));
+ qDebug("usvfs log messages are written to %s", qPrintable(m_LogFile.fileName()));
}
LogWorker::~LogWorker()
--
cgit v1.3.1
From 502e950cde5920e4184775c47621cb737696f512 Mon Sep 17 00:00:00 2001
From: Tannin
Date: Fri, 18 Dec 2015 20:32:29 +0100
Subject: support for adding directories to the vfs that will act as create
target for new files
---
src/organizercore.cpp | 18 +++++++++++++-----
src/organizercore.h | 5 +++--
src/usvfsconnector.cpp | 2 +-
3 files changed, 17 insertions(+), 8 deletions(-)
(limited to 'src/usvfsconnector.cpp')
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index 59a58e48..6a8e148f 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -1574,11 +1574,14 @@ std::vector OrganizerCore::fileMapping()
QCoreApplication::processEvents();
}
+ int overwriteId = m_DirectoryStructure->getOriginByName(L"Overwrite").getID();
+
IPluginGame *game = qApp->property("managed_game").value();
MappingType result = fileMapping(
QDir::toNativeSeparators(game->dataDirectory().absolutePath()),
"\\",
- directoryStructure(), directoryStructure());
+ directoryStructure(), directoryStructure(),
+ overwriteId);
if (m_CurrentProfile->localSavesEnabled()) {
LocalSavegames *localSaves = game->feature();
@@ -1606,7 +1609,8 @@ std::vector OrganizerCore::fileMapping(
const QString &dataPath,
const QString &relPath,
const DirectoryEntry *base,
- const DirectoryEntry *directoryEntry)
+ const DirectoryEntry *directoryEntry,
+ int createDestination)
{
std::vector result;
@@ -1623,7 +1627,7 @@ std::vector OrganizerCore::fileMapping(
QString source = originPath + relPath + fileName;
QString target = dataPath + relPath + fileName;
if (source != target) {
- result.push_back({source, target, false});
+ result.push_back({source, target, false, false});
}
}
@@ -1639,9 +1643,13 @@ std::vector OrganizerCore::fileMapping(
QString source = originPath + relPath + dirName;
QString target = dataPath + relPath + dirName;
- result.push_back({source, target, true});
+ bool writeDestination = (base == directoryEntry)
+ && (origin == createDestination);
+
+ result.push_back({source, target, true, writeDestination});
std::vector subRes
- = fileMapping(dataPath, relPath + dirName + "\\", base, *current);
+ = fileMapping(dataPath, relPath + dirName + "\\", base, *current,
+ createDestination);
result.insert(result.end(), subRes.begin(), subRes.end());
}
return result;
diff --git a/src/organizercore.h b/src/organizercore.h
index 86994f6d..ff730c2b 100644
--- a/src/organizercore.h
+++ b/src/organizercore.h
@@ -116,7 +116,7 @@ public:
void doAfterLogin(const std::function &function) { m_PostLoginTasks.append(function); }
- void spawnBinary(const QFileInfo &binary, const QString &arguments = "", const QDir ¤tDirectory = QDir(), bool closeAfterStart = true, const QString &steamAppID = "");
+ void spawnBinary(const QFileInfo &binary, const QString &arguments = "", const QDir ¤tDirectory = QDir(), const QString &steamAppID = "");
HANDLE spawnBinaryDirect(const QFileInfo &binary, const QString &arguments, const QString &profileName, const QDir ¤tDirectory, const QString &steamAppID);
void loginSuccessfulUpdate(bool necessary);
@@ -218,7 +218,8 @@ private:
std::vector
fileMapping(const QString &dataPath, const QString &relPath,
const MOShared::DirectoryEntry *base,
- const MOShared::DirectoryEntry *directoryEntry);
+ const MOShared::DirectoryEntry *directoryEntry,
+ int createDestination);
private slots:
diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp
index f3a45dfe..380abe01 100644
--- a/src/usvfsconnector.cpp
+++ b/src/usvfsconnector.cpp
@@ -133,7 +133,7 @@ void UsvfsConnector::updateMapping(const MappingType &mapping)
if (map.isDirectory) {
VirtualLinkDirectoryStatic(map.source.toStdWString().c_str()
, map.destination.toStdWString().c_str()
- , 0);
+ , (map.createTarget ? LINKFLAG_CREATETARGET : 0) | LINKFLAG_RECURSIVE);
} else {
VirtualLinkFile(map.source.toStdWString().c_str()
, map.destination.toStdWString().c_str()
--
cgit v1.3.1
From 8a9a1680b0b2ba1505636ab17f498d8ce6e02c2d Mon Sep 17 00:00:00 2001
From: Tannin
Date: Tue, 9 Feb 2016 20:02:58 +0100
Subject: code formatting (clang_format)
---
src/installationmanager.cpp | 66 +++--
src/logbuffer.cpp | 1 -
src/organizercore.cpp | 681 +++++++++++++++++++++++++++-----------------
src/usvfsconnector.cpp | 39 +--
4 files changed, 483 insertions(+), 304 deletions(-)
(limited to 'src/usvfsconnector.cpp')
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp
index 58565489..8ab27124 100644
--- a/src/installationmanager.cpp
+++ b/src/installationmanager.cpp
@@ -68,7 +68,10 @@ static T resolveFunction(QLibrary &lib, const char *name)
{
T temp = reinterpret_cast(lib.resolve(name));
if (temp == nullptr) {
- throw std::runtime_error(QObject::tr("invalid 7-zip32.dll: %1").arg(lib.errorString()).toLatin1().constData());
+ throw std::runtime_error(QObject::tr("invalid 7-zip32.dll: %1")
+ .arg(lib.errorString())
+ .toLatin1()
+ .constData());
}
return temp;
}
@@ -78,12 +81,15 @@ InstallationManager::InstallationManager()
: m_ParentWidget(nullptr)
, m_SupportedExtensions({ "zip", "rar", "7z", "fomod", "001" })
{
- QLibrary archiveLib(QCoreApplication::applicationDirPath() + "\\dlls\\archive.dll");
+ QLibrary archiveLib(QCoreApplication::applicationDirPath()
+ + "\\dlls\\archive.dll");
if (!archiveLib.load()) {
- throw MyException(tr("archive.dll not loaded: \"%1\"").arg(archiveLib.errorString()));
+ throw MyException(
+ tr("archive.dll not loaded: \"%1\"").arg(archiveLib.errorString()));
}
- CreateArchiveType CreateArchiveFunc = resolveFunction(archiveLib, "CreateArchive");
+ CreateArchiveType CreateArchiveFunc
+ = resolveFunction(archiveLib, "CreateArchive");
m_ArchiveHandler = CreateArchiveFunc();
if (!m_ArchiveHandler->isValid()) {
@@ -91,7 +97,6 @@ InstallationManager::InstallationManager()
}
}
-
InstallationManager::~InstallationManager()
{
delete m_ArchiveHandler;
@@ -111,10 +116,10 @@ void InstallationManager::setURL(QString const &url)
void InstallationManager::queryPassword(QString *password)
{
- *password = QInputDialog::getText(nullptr, tr("Password required"), tr("Password"), QLineEdit::Password);
+ *password = QInputDialog::getText(nullptr, tr("Password required"),
+ tr("Password"), QLineEdit::Password);
}
-
void InstallationManager::mapToArchive(const DirectoryTree::Node *node, QString path, FileData * const *data)
{
if (path.length() > 0) {
@@ -633,13 +638,14 @@ void InstallationManager::postInstallCleanup()
m_TempFilesToDelete.clear();
// try to delete each directory we had temporary files in. the call fails for non-empty directories which is ok
- foreach (const QString &dir, directoriesToRemove) {
+ for (const QString &dir : directoriesToRemove) {
QDir().rmdir(dir);
}
}
-
-bool InstallationManager::install(const QString &fileName, GuessedValue &modName, bool &hasIniTweaks)
+bool InstallationManager::install(const QString &fileName,
+ GuessedValue &modName,
+ bool &hasIniTweaks)
{
QFileInfo fileInfo(fileName);
if (m_SupportedExtensions.find(fileInfo.suffix()) == m_SupportedExtensions.end()) {
@@ -667,7 +673,8 @@ bool InstallationManager::install(const QString &fileName, GuessedValue
version = metaFile.value("version", "").toString();
newestVersion = metaFile.value("newestVersion", "").toString();
- unsigned int categoryIndex = CategoryFactory::instance().resolveNexusID(metaFile.value("category", 0).toInt());
+ unsigned int categoryIndex = CategoryFactory::instance().resolveNexusID(
+ metaFile.value("category", 0).toInt());
categoryID = CategoryFactory::instance().getCategoryID(categoryIndex);
repository = metaFile.value("repository", "").toString();
}
@@ -718,7 +725,7 @@ bool InstallationManager::install(const QString &fileName, GuessedValue
return LHS->priority() > RHS->priority();
});
- foreach (IPluginInstaller *installer, m_Installers) {
+ for (IPluginInstaller *installer : m_Installers) {
// don't use inactive installers (installer can't be null here but vc static code analysis thinks it could)
if ((installer == nullptr) || !installer->isActive()) {
continue;
@@ -735,14 +742,18 @@ bool InstallationManager::install(const QString &fileName, GuessedValue
try {
{ // simple case
- IPluginInstallerSimple *installerSimple = dynamic_cast(installer);
- if ((installerSimple != nullptr) &&
- (filesTree != nullptr) && (installer->isArchiveSupported(*filesTree))) {
- installResult = installerSimple->install(modName, *filesTree, version, modID);
+ IPluginInstallerSimple *installerSimple
+ = dynamic_cast(installer);
+ if ((installerSimple != nullptr) && (filesTree != nullptr)
+ && (installer->isArchiveSupported(*filesTree))) {
+ installResult
+ = installerSimple->install(modName, *filesTree, version, modID);
if (installResult == IPluginInstaller::RESULT_SUCCESS) {
mapToArchive(filesTree.data());
- // the simple installer only prepares the installation, the rest works the same for all installers
- if (!doInstall(modName, modID, version, newestVersion, categoryID, repository)) {
+ // the simple installer only prepares the installation, the rest
+ // works the same for all installers
+ if (!doInstall(modName, modID, version, newestVersion, categoryID,
+ repository)) {
installResult = IPluginInstaller::RESULT_FAILED;
}
}
@@ -750,13 +761,18 @@ bool InstallationManager::install(const QString &fileName, GuessedValue
}
{ // custom case
- IPluginInstallerCustom *installerCustom = dynamic_cast(installer);
- if ((installerCustom != nullptr) &&
- (((filesTree != nullptr) && installer->isArchiveSupported(*filesTree)) ||
- ((filesTree == nullptr) && installerCustom->isArchiveSupported(fileName)))) {
- std::set installerExtensions = installerCustom->supportedExtensions();
- if (installerExtensions.find(fileInfo.suffix()) != installerExtensions.end()) {
- installResult = installerCustom->install(modName, fileName, version, modID);
+ IPluginInstallerCustom *installerCustom
+ = dynamic_cast(installer);
+ if ((installerCustom != nullptr)
+ && (((filesTree != nullptr)
+ && installer->isArchiveSupported(*filesTree))
+ || ((filesTree == nullptr)
+ && installerCustom->isArchiveSupported(fileName)))) {
+ std::set installerExt
+ = installerCustom->supportedExtensions();
+ if (installerExt.find(fileInfo.suffix()) != installerExt.end()) {
+ installResult
+ = installerCustom->install(modName, fileName, version, modID);
unsigned int idx = ModInfo::getIndex(modName);
if (idx != UINT_MAX) {
ModInfo::Ptr info = ModInfo::getByIndex(idx);
diff --git a/src/logbuffer.cpp b/src/logbuffer.cpp
index 01ff2b87..8207dcbb 100644
--- a/src/logbuffer.cpp
+++ b/src/logbuffer.cpp
@@ -44,7 +44,6 @@ LogBuffer::LogBuffer(int messageCount, QtMsgType minMsgType,
LogBuffer::~LogBuffer()
{
- qDebug("closing log buffer");
qInstallMessageHandler(0);
write();
}
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index a73e6845..98144cad 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -30,21 +30,21 @@
#include
#include
-
+#include
using namespace MOShared;
using namespace MOBase;
-
static bool isOnline()
{
QList interfaces = QNetworkInterface::allInterfaces();
bool connected = false;
- for (auto iter = interfaces.begin(); iter != interfaces.end() && !connected; ++iter) {
- if ( (iter->flags() & QNetworkInterface::IsUp) &&
- (iter->flags() & QNetworkInterface::IsRunning) &&
- !(iter->flags() & QNetworkInterface::IsLoopBack)) {
+ for (auto iter = interfaces.begin(); iter != interfaces.end() && !connected;
+ ++iter) {
+ if ((iter->flags() & QNetworkInterface::IsUp)
+ && (iter->flags() & QNetworkInterface::IsRunning)
+ && !(iter->flags() & QNetworkInterface::IsLoopBack)) {
auto addresses = iter->addressEntries();
if (addresses.count() == 0) {
continue;
@@ -59,7 +59,8 @@ static bool isOnline()
return connected;
}
-static bool renameFile(const QString &oldName, const QString &newName, bool overwrite = true)
+static bool renameFile(const QString &oldName, const QString &newName,
+ bool overwrite = true)
{
if (overwrite && QFile::exists(newName)) {
QFile::remove(newName);
@@ -87,11 +88,12 @@ static std::wstring getProcessName(DWORD processId)
static void startSteam(QWidget *widget)
{
- QSettings steamSettings("HKEY_CURRENT_USER\\Software\\Valve\\Steam", QSettings::NativeFormat);
+ QSettings steamSettings("HKEY_CURRENT_USER\\Software\\Valve\\Steam",
+ QSettings::NativeFormat);
QString exe = steamSettings.value("SteamExe", "").toString();
if (!exe.isEmpty()) {
exe = QString("\"%1\"").arg(exe);
- //See if username and password supplied. If so, pass them into steam.
+ // See if username and password supplied. If so, pass them into steam.
QStringList args;
QString username;
QString password;
@@ -105,8 +107,9 @@ static void startSteam(QWidget *widget)
if (!QProcess::startDetached(exe, args)) {
reportError(QObject::tr("Failed to start \"%1\"").arg(exe));
} else {
- QMessageBox::information(widget, QObject::tr("Waiting"),
- QObject::tr("Please press OK once you're logged into steam."));
+ QMessageBox::information(
+ widget, QObject::tr("Waiting"),
+ QObject::tr("Please press OK once you're logged into steam."));
}
}
}
@@ -121,7 +124,6 @@ QStringList toStringList(InputIterator current, InputIterator end)
return result;
}
-
OrganizerCore::OrganizerCore(const QSettings &initSettings)
: m_UserInterface(nullptr)
, m_PluginContainer(nullptr)
@@ -155,21 +157,33 @@ OrganizerCore::OrganizerCore(const QSettings &initSettings)
m_InstallationManager.setModsDirectory(m_Settings.getModDirectory());
m_InstallationManager.setDownloadDirectory(m_Settings.getDownloadDirectory());
- connect(&m_DownloadManager, SIGNAL(downloadSpeed(QString,int)), this, SLOT(downloadSpeed(QString,int)));
- connect(&m_DirectoryRefresher, SIGNAL(refreshed()), this, SLOT(directory_refreshed()));
-
- connect(&m_ModList, SIGNAL(removeOrigin(QString)), this, SLOT(removeOrigin(QString)));
-
- connect(NexusInterface::instance()->getAccessManager(), SIGNAL(loginSuccessful(bool)), this, SLOT(loginSuccessful(bool)));
- connect(NexusInterface::instance()->getAccessManager(), SIGNAL(loginFailed(QString)), this, SLOT(loginFailed(QString)));
-
- //This seems awfully imperative
- connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame const *)), &m_Settings, SLOT(managedGameChanged(MOBase::IPluginGame const *)));
- connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame const *)), &m_DownloadManager, SLOT(managedGameChanged(MOBase::IPluginGame const *)));
- connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame const *)), &m_PluginList, SLOT(managedGameChanged(MOBase::IPluginGame const *)));
- connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame const *)), NexusInterface::instance(), SLOT(managedGameChanged(MOBase::IPluginGame const *)));
-
- connect(&m_PluginList, &PluginList::writePluginsList, &m_PluginListsWriter, &DelayedFileWriterBase::write);
+ connect(&m_DownloadManager, SIGNAL(downloadSpeed(QString, int)), this,
+ SLOT(downloadSpeed(QString, int)));
+ connect(&m_DirectoryRefresher, SIGNAL(refreshed()), this,
+ SLOT(directory_refreshed()));
+
+ connect(&m_ModList, SIGNAL(removeOrigin(QString)), this,
+ SLOT(removeOrigin(QString)));
+
+ connect(NexusInterface::instance()->getAccessManager(),
+ SIGNAL(loginSuccessful(bool)), this, SLOT(loginSuccessful(bool)));
+ connect(NexusInterface::instance()->getAccessManager(),
+ SIGNAL(loginFailed(QString)), this, SLOT(loginFailed(QString)));
+
+ // This seems awfully imperative
+ connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame const *)),
+ &m_Settings, SLOT(managedGameChanged(MOBase::IPluginGame const *)));
+ connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame const *)),
+ &m_DownloadManager,
+ SLOT(managedGameChanged(MOBase::IPluginGame const *)));
+ connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame const *)),
+ &m_PluginList, SLOT(managedGameChanged(MOBase::IPluginGame const *)));
+ connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame const *)),
+ NexusInterface::instance(),
+ SLOT(managedGameChanged(MOBase::IPluginGame const *)));
+
+ connect(&m_PluginList, &PluginList::writePluginsList, &m_PluginListsWriter,
+ &DelayedFileWriterBase::write);
// make directory refresher run in a separate thread
m_RefresherThread.start();
@@ -201,7 +215,8 @@ QString OrganizerCore::commitSettings(const QString &iniFile)
{
if (!shellRename(iniFile + ".new", iniFile, true, qApp->activeWindow())) {
DWORD err = ::GetLastError();
- // make a second attempt using qt functions but if that fails print the error from the first attempt
+ // make a second attempt using qt functions but if that fails print the
+ // error from the first attempt
if (!renameFile(iniFile + ".new", iniFile)) {
return windowsErrorString(err);
}
@@ -216,7 +231,8 @@ QSettings::Status OrganizerCore::storeSettings(const QString &fileName)
m_UserInterface->storeSettings(settings);
}
if (m_CurrentProfile != nullptr) {
- settings.setValue("selected_profile", m_CurrentProfile->name().toUtf8().constData());
+ settings.setValue("selected_profile",
+ m_CurrentProfile->name().toUtf8().constData());
}
settings.setValue("ask_for_nexuspw", m_AskForNexusPW);
@@ -249,31 +265,41 @@ QSettings::Status OrganizerCore::storeSettings(const QString &fileName)
void OrganizerCore::storeSettings()
{
- QString iniFile = qApp->property("dataPath").toString() + "/" + QString::fromStdWString(AppConfig::iniFileName());
+ QString iniFile = qApp->property("dataPath").toString() + "/"
+ + QString::fromStdWString(AppConfig::iniFileName());
if (QFileInfo(iniFile).exists()) {
if (!shellCopy(iniFile, iniFile + ".new", true, qApp->activeWindow())) {
- QMessageBox::critical(qApp->activeWindow(), tr("Failed to write settings"),
- tr("An error occured trying to update MO settings to %1: %2").arg(
- iniFile, windowsErrorString(::GetLastError())));
+ QMessageBox::critical(
+ qApp->activeWindow(), tr("Failed to write settings"),
+ tr("An error occured trying to update MO settings to %1: %2")
+ .arg(iniFile, windowsErrorString(::GetLastError())));
return;
}
}
- QSettings::Status result = storeSettings(iniFile + ".new");
+ QString writeTarget = iniFile + ".new";
+
+ QSettings::Status result = storeSettings(writeTarget);
if (result == QSettings::NoError) {
QString errMsg = commitSettings(iniFile);
if (!errMsg.isEmpty()) {
- qWarning("settings file not writable, may be locked by another application, trying direct write");
+ qWarning("settings file not writable, may be locked by another "
+ "application, trying direct write");
+ writeTarget = iniFile;
result = storeSettings(iniFile);
}
}
if (result != QSettings::NoError) {
- QString reason = result == QSettings::AccessError ? tr("File is write protected")
- : result == QSettings::FormatError ? tr("Invalid file format (probably a bug)")
- : tr("Unknown error %1").arg(result);
- QMessageBox::critical(qApp->activeWindow(), tr("Failed to write settings"),
- tr("An error occured trying to write back MO settings to %1: %2").arg(iniFile + ".new", reason));
+ QString reason = result == QSettings::AccessError
+ ? tr("File is write protected")
+ : result == QSettings::FormatError
+ ? tr("Invalid file format (probably a bug)")
+ : tr("Unknown error %1").arg(result);
+ QMessageBox::critical(
+ qApp->activeWindow(), tr("Failed to write settings"),
+ tr("An error occured trying to write back MO settings to %1: %2")
+ .arg(writeTarget, reason));
}
}
@@ -302,17 +328,19 @@ bool OrganizerCore::testForSteam()
for (unsigned int i = 0; i < bytesReturned / sizeof(DWORD); ++i) {
memset(processName, '\0', sizeof(TCHAR) * MAX_PATH);
if (processIDs[i] != 0) {
- HANDLE process = ::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processIDs[i]);
+ HANDLE process = ::OpenProcess(
+ PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processIDs[i]);
if (process != nullptr) {
HMODULE module;
DWORD ignore;
// first module in a process is always the binary
- if (EnumProcessModules(process, &module, sizeof(HMODULE) * 1, &ignore)) {
+ if (EnumProcessModules(process, &module, sizeof(HMODULE) * 1,
+ &ignore)) {
::GetModuleBaseName(process, module, processName, MAX_PATH);
- if ((_tcsicmp(processName, TEXT("steam.exe")) == 0) ||
- (_tcsicmp(processName, TEXT("steamservice.exe")) == 0)) {
+ if ((_tcsicmp(processName, TEXT("steam.exe")) == 0)
+ || (_tcsicmp(processName, TEXT("steamservice.exe")) == 0)) {
return true;
}
}
@@ -339,47 +367,62 @@ void OrganizerCore::updateExecutablesList(QSettings &settings)
settings.setArrayIndex(i);
Executable::Flags flags;
- if (settings.value("custom", true).toBool()) flags |= Executable::CustomExecutable;
- if (settings.value("toolbar", false).toBool()) flags |= Executable::ShowInToolbar;
- if (settings.value("ownicon", false).toBool()) flags |= Executable::UseApplicationIcon;
+ if (settings.value("custom", true).toBool())
+ flags |= Executable::CustomExecutable;
+ if (settings.value("toolbar", false).toBool())
+ flags |= Executable::ShowInToolbar;
+ if (settings.value("ownicon", false).toBool())
+ flags |= Executable::UseApplicationIcon;
- m_ExecutablesList.addExecutable(settings.value("title").toString(),
- settings.value("binary").toString(),
- settings.value("arguments").toString(),
- settings.value("workingDirectory", "").toString(),
- settings.value("steamAppID", "").toString(),
- flags);
+ m_ExecutablesList.addExecutable(
+ settings.value("title").toString(), settings.value("binary").toString(),
+ settings.value("arguments").toString(),
+ settings.value("workingDirectory", "").toString(),
+ settings.value("steamAppID", "").toString(), flags);
}
settings.endArray();
- // TODO this has nothing to do with executables list move to an appropriate function!
- ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure, m_Settings.displayForeign(), managedGame());
+ // TODO this has nothing to do with executables list move to an appropriate
+ // function!
+ ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure,
+ m_Settings.displayForeign(), managedGame());
}
-void OrganizerCore::setUserInterface(IUserInterface *userInterface, QWidget *widget)
+void OrganizerCore::setUserInterface(IUserInterface *userInterface,
+ QWidget *widget)
{
storeSettings();
m_UserInterface = userInterface;
if (widget != nullptr) {
- connect(&m_ModList, SIGNAL(modlist_changed(QModelIndex, int)), widget, SLOT(modlistChanged(QModelIndex, int)));
- connect(&m_ModList, SIGNAL(showMessage(QString)), widget, SLOT(showMessage(QString)));
- connect(&m_ModList, SIGNAL(modRenamed(QString,QString)), widget, SLOT(modRenamed(QString,QString)));
- connect(&m_ModList, SIGNAL(modUninstalled(QString)), widget, SLOT(modRemoved(QString)));
- connect(&m_ModList, SIGNAL(removeSelectedMods()), widget, SLOT(removeMod_clicked()));
- connect(&m_ModList, SIGNAL(requestColumnSelect(QPoint)), widget, SLOT(displayColumnSelection(QPoint)));
- connect(&m_ModList, SIGNAL(fileMoved(QString, QString, QString)), widget, SLOT(fileMoved(QString, QString, QString)));
- connect(&m_ModList, SIGNAL(modorder_changed()), widget, SLOT(modorder_changed()));
- connect(&m_DownloadManager, SIGNAL(showMessage(QString)), widget, SLOT(showMessage(QString)));
+ connect(&m_ModList, SIGNAL(modlist_changed(QModelIndex, int)), widget,
+ SLOT(modlistChanged(QModelIndex, int)));
+ connect(&m_ModList, SIGNAL(showMessage(QString)), widget,
+ SLOT(showMessage(QString)));
+ connect(&m_ModList, SIGNAL(modRenamed(QString, QString)), widget,
+ SLOT(modRenamed(QString, QString)));
+ connect(&m_ModList, SIGNAL(modUninstalled(QString)), widget,
+ SLOT(modRemoved(QString)));
+ connect(&m_ModList, SIGNAL(removeSelectedMods()), widget,
+ SLOT(removeMod_clicked()));
+ connect(&m_ModList, SIGNAL(requestColumnSelect(QPoint)), widget,
+ SLOT(displayColumnSelection(QPoint)));
+ connect(&m_ModList, SIGNAL(fileMoved(QString, QString, QString)), widget,
+ SLOT(fileMoved(QString, QString, QString)));
+ connect(&m_ModList, SIGNAL(modorder_changed()), widget,
+ SLOT(modorder_changed()));
+ connect(&m_DownloadManager, SIGNAL(showMessage(QString)), widget,
+ SLOT(showMessage(QString)));
}
m_InstallationManager.setParentWidget(widget);
m_Updater.setUserInterface(widget);
if (userInterface != nullptr) {
- // this currently wouldn't work reliably if the ui isn't initialized yet to display the result
+ // this currently wouldn't work reliably if the ui isn't initialized yet to
+ // display the result
if (isOnline() && !m_Settings.offlineMode()) {
m_Updater.testForUpdate();
} else {
@@ -390,15 +433,16 @@ void OrganizerCore::setUserInterface(IUserInterface *userInterface, QWidget *wid
void OrganizerCore::connectPlugins(PluginContainer *container)
{
- m_DownloadManager.setSupportedExtensions(m_InstallationManager.getSupportedExtensions());
+ m_DownloadManager.setSupportedExtensions(
+ m_InstallationManager.getSupportedExtensions());
m_PluginContainer = container;
if (!m_GameName.isEmpty()) {
m_GamePlugin = m_PluginContainer->managedGame(m_GameName);
emit managedGameChanged(m_GamePlugin);
}
- //Do this the hard way
- for (const IPluginGame * const game : container->plugins()) {
+ // Do this the hard way
+ for (const IPluginGame *const game : container->plugins()) {
QString n = game->gameShortName();
if (game->gameShortName() == "Skyrim") {
m_Updater.setNexusDownload(game);
@@ -416,13 +460,13 @@ void OrganizerCore::disconnectPlugins()
m_PluginList.disconnectSlots();
m_Settings.clearPlugins();
- m_GamePlugin = nullptr;
+ m_GamePlugin = nullptr;
m_PluginContainer = nullptr;
}
void OrganizerCore::setManagedGame(MOBase::IPluginGame *game)
{
- m_GameName = game->gameName();
+ m_GameName = game->gameName();
m_GamePlugin = game;
qApp->setProperty("managed_game", QVariant::fromValue(m_GamePlugin));
emit managedGameChanged(m_GamePlugin);
@@ -435,10 +479,10 @@ Settings &OrganizerCore::settings()
bool OrganizerCore::nexusLogin(bool retry)
{
- NXMAccessManager *accessManager = NexusInterface::instance()->getAccessManager();
+ NXMAccessManager *accessManager
+ = NexusInterface::instance()->getAccessManager();
- if ((accessManager->loginAttempted()
- || accessManager->loggedIn())
+ if ((accessManager->loginAttempted() || accessManager->loggedIn())
&& !retry) {
// previous attempt, maybe even successful
return false;
@@ -504,10 +548,12 @@ void OrganizerCore::externalMessage(const QString &message)
}
}
-void OrganizerCore::downloadRequested(QNetworkReply *reply, int modID, const QString &fileName)
+void OrganizerCore::downloadRequested(QNetworkReply *reply, int modID,
+ const QString &fileName)
{
try {
- if (m_DownloadManager.addDownload(reply, QStringList(), fileName, modID, 0, new ModRepositoryFileInfo(modID))) {
+ if (m_DownloadManager.addDownload(reply, QStringList(), fileName, modID, 0,
+ new ModRepositoryFileInfo(modID))) {
MessageDialog::showMessage(tr("Download started"), qApp->activeWindow());
}
} catch (const std::exception &e) {
@@ -536,7 +582,8 @@ InstallationManager *OrganizerCore::installationManager()
void OrganizerCore::createDefaultProfile()
{
QString profilesPath = settings().getProfileDirectory();
- if (QDir(profilesPath).entryList(QDir::AllDirs | QDir::NoDotAndDotDot).size() == 0) {
+ if (QDir(profilesPath).entryList(QDir::AllDirs | QDir::NoDotAndDotDot).size()
+ == 0) {
Profile newProf("Default", managedGame(), false);
}
}
@@ -548,11 +595,11 @@ void OrganizerCore::prepareVFS()
void OrganizerCore::setCurrentProfile(const QString &profileName)
{
- if ((m_CurrentProfile != nullptr) &&
- (profileName == m_CurrentProfile->name())) {
+ if ((m_CurrentProfile != nullptr)
+ && (profileName == m_CurrentProfile->name())) {
return;
}
- QString profileDir = settings().getProfileDirectory() + "/" + profileName;
+ QString profileDir = settings().getProfileDirectory() + "/" + profileName;
Profile *newProfile = new Profile(QDir(profileDir), managedGame());
delete m_CurrentProfile;
@@ -565,7 +612,8 @@ void OrganizerCore::setCurrentProfile(const QString &profileName)
m_CurrentProfile->deactivateInvalidation();
}
- connect(m_CurrentProfile, SIGNAL(modStatusChanged(uint)), this, SLOT(modStatusChanged(uint)));
+ connect(m_CurrentProfile, SIGNAL(modStatusChanged(uint)), this,
+ SLOT(modStatusChanged(uint)));
refreshDirectoryStructure();
}
@@ -617,7 +665,10 @@ MOBase::IModInterface *OrganizerCore::createMod(GuessedValue &name)
m_InstallationManager.setModsDirectory(m_Settings.getModDirectory());
- QString targetDirectory = QDir::fromNativeSeparators(m_Settings.getModDirectory()).append("/").append(name);
+ QString targetDirectory
+ = QDir::fromNativeSeparators(m_Settings.getModDirectory())
+ .append("/")
+ .append(name);
QSettings settingsFile(targetDirectory + "/meta.ini", QSettings::IniFormat);
@@ -632,7 +683,8 @@ MOBase::IModInterface *OrganizerCore::createMod(GuessedValue &name)
settingsFile.endArray();
}
- return ModInfo::createFrom(QDir(targetDirectory), &m_DirectoryStructure).data();
+ return ModInfo::createFrom(QDir(targetDirectory), &m_DirectoryStructure)
+ .data();
}
bool OrganizerCore::removeMod(MOBase::IModInterface *mod)
@@ -645,37 +697,44 @@ bool OrganizerCore::removeMod(MOBase::IModInterface *mod)
}
}
-void OrganizerCore::modDataChanged(MOBase::IModInterface*)
+void OrganizerCore::modDataChanged(MOBase::IModInterface *)
{
refreshModList(false);
}
-QVariant OrganizerCore::pluginSetting(const QString &pluginName, const QString &key) const
+QVariant OrganizerCore::pluginSetting(const QString &pluginName,
+ const QString &key) const
{
return m_Settings.pluginSetting(pluginName, key);
}
-void OrganizerCore::setPluginSetting(const QString &pluginName, const QString &key, const QVariant &value)
+void OrganizerCore::setPluginSetting(const QString &pluginName,
+ const QString &key, const QVariant &value)
{
m_Settings.setPluginSetting(pluginName, key, value);
}
-QVariant OrganizerCore::persistent(const QString &pluginName, const QString &key, const QVariant &def) const
+QVariant OrganizerCore::persistent(const QString &pluginName,
+ const QString &key,
+ const QVariant &def) const
{
return m_Settings.pluginPersistent(pluginName, key, def);
}
-void OrganizerCore::setPersistent(const QString &pluginName, const QString &key, const QVariant &value, bool sync)
+void OrganizerCore::setPersistent(const QString &pluginName, const QString &key,
+ const QVariant &value, bool sync)
{
m_Settings.setPluginPersistent(pluginName, key, value, sync);
}
QString OrganizerCore::pluginDataPath() const
{
- return qApp->applicationDirPath() + "/" + ToQString(AppConfig::pluginPath()) + "/data";
+ return qApp->applicationDirPath() + "/" + ToQString(AppConfig::pluginPath())
+ + "/data";
}
-MOBase::IModInterface *OrganizerCore::installMod(const QString &fileName, const QString &initModName)
+MOBase::IModInterface *OrganizerCore::installMod(const QString &fileName,
+ const QString &initModName)
{
if (m_CurrentProfile == nullptr) {
return nullptr;
@@ -689,18 +748,21 @@ MOBase::IModInterface *OrganizerCore::installMod(const QString &fileName, const
m_CurrentProfile->writeModlistNow();
m_InstallationManager.setModsDirectory(m_Settings.getModDirectory());
if (m_InstallationManager.install(fileName, modName, hasIniTweaks)) {
- MessageDialog::showMessage(tr("Installation successful"), qApp->activeWindow());
+ MessageDialog::showMessage(tr("Installation successful"),
+ qApp->activeWindow());
refreshModList();
int modIndex = ModInfo::getIndex(modName);
if (modIndex != UINT_MAX) {
ModInfo::Ptr modInfo = ModInfo::getByIndex(modIndex);
- if (hasIniTweaks
- && (m_UserInterface != nullptr)
+ if (hasIniTweaks && (m_UserInterface != nullptr)
&& (QMessageBox::question(qApp->activeWindow(), tr("Configure Mod"),
- tr("This mod contains ini tweaks. Do you want to configure them now?"),
- QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)) {
- m_UserInterface->displayModInformation(modInfo, modIndex, ModInfoDialog::TAB_INIFILES);
+ tr("This mod contains ini tweaks. Do you "
+ "want to configure them now?"),
+ QMessageBox::Yes | QMessageBox::No)
+ == QMessageBox::Yes)) {
+ m_UserInterface->displayModInformation(modInfo, modIndex,
+ ModInfoDialog::TAB_INIFILES);
}
m_ModInstalled(modName);
return modInfo.data();
@@ -709,7 +771,8 @@ MOBase::IModInterface *OrganizerCore::installMod(const QString &fileName, const
}
} else if (m_InstallationManager.wasCancelled()) {
QMessageBox::information(qApp->activeWindow(), tr("Installation cancelled"),
- tr("The mod was not installed completely."), QMessageBox::Ok);
+ tr("The mod was not installed completely."),
+ QMessageBox::Ok);
}
return nullptr;
}
@@ -718,8 +781,8 @@ void OrganizerCore::installDownload(int index)
{
try {
QString fileName = m_DownloadManager.getFilePath(index);
- int modID = m_DownloadManager.getModID(index);
- int fileID = m_DownloadManager.getFileInfo(index)->fileID;
+ int modID = m_DownloadManager.getModID(index);
+ int fileID = m_DownloadManager.getFileInfo(index)->fileID;
GuessedValue modName;
// see if there already are mods with the specified mod id
@@ -727,7 +790,8 @@ void OrganizerCore::installDownload(int index)
std::vector modInfo = ModInfo::getByModID(modID);
for (auto iter = modInfo.begin(); iter != modInfo.end(); ++iter) {
std::vector flags = (*iter)->getFlags();
- if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_BACKUP) == flags.end()) {
+ if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_BACKUP)
+ == flags.end()) {
modName.update((*iter)->name(), GUESS_PRESET);
(*iter)->saveMeta();
}
@@ -739,7 +803,8 @@ void OrganizerCore::installDownload(int index)
bool hasIniTweaks = false;
m_InstallationManager.setModsDirectory(m_Settings.getModDirectory());
if (m_InstallationManager.install(fileName, modName, hasIniTweaks)) {
- MessageDialog::showMessage(tr("Installation successful"), qApp->activeWindow());
+ MessageDialog::showMessage(tr("Installation successful"),
+ qApp->activeWindow());
refreshModList();
int modIndex = ModInfo::getIndex(modName);
@@ -747,12 +812,14 @@ void OrganizerCore::installDownload(int index)
ModInfo::Ptr modInfo = ModInfo::getByIndex(modIndex);
modInfo->addInstalledFile(modID, fileID);
- if (hasIniTweaks
- && m_UserInterface != nullptr
+ if (hasIniTweaks && m_UserInterface != nullptr
&& (QMessageBox::question(qApp->activeWindow(), tr("Configure Mod"),
- tr("This mod contains ini tweaks. Do you want to configure them now?"),
- QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)) {
- m_UserInterface->displayModInformation(modInfo, modIndex, ModInfoDialog::TAB_INIFILES);
+ tr("This mod contains ini tweaks. Do you "
+ "want to configure them now?"),
+ QMessageBox::Yes | QMessageBox::No)
+ == QMessageBox::Yes)) {
+ m_UserInterface->displayModInformation(modInfo, modIndex,
+ ModInfoDialog::TAB_INIFILES);
}
m_ModInstalled(modName);
@@ -763,8 +830,9 @@ void OrganizerCore::installDownload(int index)
emit modInstalled(modName);
} else if (m_InstallationManager.wasCancelled()) {
- QMessageBox::information(qApp->activeWindow(), tr("Installation cancelled"),
- tr("The mod was not installed completely."), QMessageBox::Ok);
+ QMessageBox::information(
+ qApp->activeWindow(), tr("Installation cancelled"),
+ tr("The mod was not installed completely."), QMessageBox::Ok);
}
} catch (const std::exception &e) {
reportError(e.what());
@@ -776,7 +844,8 @@ QString OrganizerCore::resolvePath(const QString &fileName) const
if (m_DirectoryStructure == nullptr) {
return QString();
}
- const FileEntry::Ptr file = m_DirectoryStructure->searchFile(ToWString(fileName), nullptr);
+ const FileEntry::Ptr file
+ = m_DirectoryStructure->searchFile(ToWString(fileName), nullptr);
if (file.get() != nullptr) {
return ToQString(file->getFullPath());
} else {
@@ -787,9 +856,10 @@ QString OrganizerCore::resolvePath(const QString &fileName) const
QStringList OrganizerCore::listDirectories(const QString &directoryName) const
{
QStringList result;
- DirectoryEntry *dir = m_DirectoryStructure->findSubDirectoryRecursive(ToWString(directoryName));
+ DirectoryEntry *dir = m_DirectoryStructure->findSubDirectoryRecursive(
+ ToWString(directoryName));
if (dir != nullptr) {
- std::vector::iterator current, end;
+ std::vector::iterator current, end;
dir->getSubDirectories(current, end);
for (; current != end; ++current) {
result.append(ToQString((*current)->getName()));
@@ -798,10 +868,13 @@ QStringList OrganizerCore::listDirectories(const QString &directoryName) const
return result;
}
-QStringList OrganizerCore::findFiles(const QString &path, const std::function &filter) const
+QStringList OrganizerCore::findFiles(
+ const QString &path,
+ const std::function &filter) const
{
QStringList result;
- DirectoryEntry *dir = m_DirectoryStructure->findSubDirectoryRecursive(ToWString(path));
+ DirectoryEntry *dir
+ = m_DirectoryStructure->findSubDirectoryRecursive(ToWString(path));
if (dir != nullptr) {
std::vector files = dir->getFiles();
foreach (FileEntry::Ptr file, files) {
@@ -818,12 +891,15 @@ QStringList OrganizerCore::findFiles(const QString &path, const std::functionsearchFile(ToWString(QFileInfo(fileName).fileName()), nullptr);
+ const FileEntry::Ptr file = m_DirectoryStructure->searchFile(
+ ToWString(QFileInfo(fileName).fileName()), nullptr);
if (file.get() != nullptr) {
- result.append(ToQString(m_DirectoryStructure->getOriginByID(file->getOrigin()).getName()));
+ result.append(ToQString(
+ m_DirectoryStructure->getOriginByID(file->getOrigin()).getName()));
foreach (int i, file->getAlternatives()) {
- result.append(ToQString(m_DirectoryStructure->getOriginByID(i).getName()));
+ result.append(
+ ToQString(m_DirectoryStructure->getOriginByID(i).getName()));
}
} else {
qDebug("%s not found", qPrintable(fileName));
@@ -831,20 +907,27 @@ QStringList OrganizerCore::getFileOrigins(const QString &fileName) const
return result;
}
-QList OrganizerCore::findFileInfos(const QString &path, const std::function &filter) const
+QList OrganizerCore::findFileInfos(
+ const QString &path,
+ const std::function &filter)
+ const
{
QList result;
- DirectoryEntry *dir = m_DirectoryStructure->findSubDirectoryRecursive(ToWString(path));
+ DirectoryEntry *dir
+ = m_DirectoryStructure->findSubDirectoryRecursive(ToWString(path));
if (dir != nullptr) {
std::vector files = dir->getFiles();
foreach (FileEntry::Ptr file, files) {
IOrganizer::FileInfo info;
- info.filePath = ToQString(file->getFullPath());
+ info.filePath = ToQString(file->getFullPath());
bool fromArchive = false;
- info.origins.append(ToQString(m_DirectoryStructure->getOriginByID(file->getOrigin(fromArchive)).getName()));
+ info.origins.append(ToQString(
+ m_DirectoryStructure->getOriginByID(file->getOrigin(fromArchive))
+ .getName()));
info.archive = fromArchive ? ToQString(file->getArchive()) : "";
foreach (int idx, file->getAlternatives()) {
- info.origins.append(ToQString(m_DirectoryStructure->getOriginByID(idx).getName()));
+ info.origins.append(
+ ToQString(m_DirectoryStructure->getOriginByID(idx).getName()));
}
if (filter(info)) {
@@ -870,13 +953,21 @@ ModList *OrganizerCore::modList()
return &m_ModList;
}
-void OrganizerCore::spawnBinary(const QFileInfo &binary, const QString &arguments, const QDir ¤tDirectory, const QString &steamAppID)
+void OrganizerCore::spawnBinary(const QFileInfo &binary,
+ const QString &arguments,
+ const QDir ¤tDirectory,
+ const QString &steamAppID)
{
LockedDialog *dialog = new LockedDialog(qApp->activeWindow());
dialog->show();
- ON_BLOCK_EXIT([&] () { dialog->hide(); dialog->deleteLater(); });
-
- HANDLE processHandle = spawnBinaryDirect(binary, arguments, m_CurrentProfile->name(), currentDirectory, steamAppID);
+ ON_BLOCK_EXIT([&]() {
+ dialog->hide();
+ dialog->deleteLater();
+ });
+
+ HANDLE processHandle
+ = spawnBinaryDirect(binary, arguments, m_CurrentProfile->name(),
+ currentDirectory, steamAppID);
if (processHandle != INVALID_HANDLE_VALUE) {
if (m_UserInterface != nullptr) {
m_UserInterface->setWindowEnabled(false);
@@ -930,15 +1021,20 @@ void OrganizerCore::spawnBinary(const QFileInfo &binary, const QString &argument
m_UserInterface->setWindowEnabled(true);
}
refreshDirectoryStructure();
- // need to remove our stored load order because it may be outdated if a foreign tool changed the
- // file time. After removing that file, refreshESPList will use the file time as the order
- if (managedGame()->loadOrderMechanism() == IPluginGame::LoadOrderMechanism::FileTime) {
+ // need to remove our stored load order because it may be outdated if a
+ // foreign tool changed the
+ // file time. After removing that file, refreshESPList will use the file
+ // time as the order
+ if (managedGame()->loadOrderMechanism()
+ == IPluginGame::LoadOrderMechanism::FileTime) {
qDebug("removing loadorder.txt");
QFile::remove(m_CurrentProfile->getLoadOrderFileName());
}
refreshESPList();
- if (managedGame()->loadOrderMechanism() == IPluginGame::LoadOrderMechanism::FileTime) {
- // the load order should have been retrieved from file time, now save it to our own format
+ if (managedGame()->loadOrderMechanism()
+ == IPluginGame::LoadOrderMechanism::FileTime) {
+ // the load order should have been retrieved from file time, now save it
+ // to our own format
savePluginList();
}
@@ -947,38 +1043,47 @@ void OrganizerCore::spawnBinary(const QFileInfo &binary, const QString &argument
}
}
-HANDLE OrganizerCore::spawnBinaryDirect(const QFileInfo &binary, const QString &arguments, const QString &profileName,
- const QDir ¤tDirectory, const QString &steamAppID)
+HANDLE OrganizerCore::spawnBinaryDirect(const QFileInfo &binary,
+ const QString &arguments,
+ const QString &profileName,
+ const QDir ¤tDirectory,
+ const QString &steamAppID)
{
prepareStart();
if (!binary.exists()) {
- reportError(tr("Executable \"%1\" not found").arg(binary.absoluteFilePath()));
+ reportError(
+ tr("Executable \"%1\" not found").arg(binary.absoluteFilePath()));
return INVALID_HANDLE_VALUE;
}
if (!steamAppID.isEmpty()) {
::SetEnvironmentVariableW(L"SteamAPPId", ToWString(steamAppID).c_str());
} else {
- ::SetEnvironmentVariableW(L"SteamAPPId", ToWString(m_Settings.getSteamAppID()).c_str());
- }
-
-
- //This could possibly be extracted somewhere else but it's probably for when
- //we have more than one provider of game registration.
- if ((QFileInfo(managedGame()->gameDirectory().absoluteFilePath("steam_api.dll")).exists()
- || QFileInfo(managedGame()->gameDirectory().absoluteFilePath("steam_api64.dll")).exists())
+ ::SetEnvironmentVariableW(L"SteamAPPId",
+ ToWString(m_Settings.getSteamAppID()).c_str());
+ }
+
+ // This could possibly be extracted somewhere else but it's probably for when
+ // we have more than one provider of game registration.
+ if ((QFileInfo(
+ managedGame()->gameDirectory().absoluteFilePath("steam_api.dll"))
+ .exists()
+ || QFileInfo(managedGame()->gameDirectory().absoluteFilePath(
+ "steam_api64.dll"))
+ .exists())
&& (m_Settings.getLoadMechanism() == LoadMechanism::LOAD_MODORGANIZER)) {
if (!testForSteam()) {
QWidget *window = qApp->activeWindow();
if ((window != nullptr) && (!window->isVisible())) {
window = nullptr;
}
- if (QuestionBoxMemory::query(window, "steamQuery",
- tr("Start Steam?"),
- tr("Steam is required to be running already to correctly start the game. "
- "Should MO try to start steam now?"),
- QDialogButtonBox::Yes | QDialogButtonBox::No) == QDialogButtonBox::Yes) {
+ if (QuestionBoxMemory::query(window, "steamQuery", tr("Start Steam?"),
+ tr("Steam is required to be running already "
+ "to correctly start the game. "
+ "Should MO try to start steam now?"),
+ QDialogButtonBox::Yes | QDialogButtonBox::No)
+ == QDialogButtonBox::Yes) {
startSteam(qApp->activeWindow());
}
}
@@ -1006,30 +1111,35 @@ HANDLE OrganizerCore::spawnBinaryDirect(const QFileInfo &binary, const QString &
QString cwdPath = currentDirectory.absolutePath();
- int binOffset = binPath.indexOf('/', modsPath.length() + 1);
- int cwdOffset = cwdPath.indexOf('/', modsPath.length() + 1);
- QString dataBinPath = m_GamePlugin->dataDirectory().absolutePath() + binPath.mid(binOffset, -1);
- QString dataCwd = m_GamePlugin->dataDirectory().absolutePath() + cwdPath.mid(cwdOffset, -1);
- QString cmdline = QString("launch \"%1\" \"%2\" %3")
- .arg(QDir::toNativeSeparators(dataCwd),
- QDir::toNativeSeparators(dataBinPath),
- arguments);
+ int binOffset = binPath.indexOf('/', modsPath.length() + 1);
+ int cwdOffset = cwdPath.indexOf('/', modsPath.length() + 1);
+ QString dataBinPath = m_GamePlugin->dataDirectory().absolutePath()
+ + binPath.mid(binOffset, -1);
+ QString dataCwd = m_GamePlugin->dataDirectory().absolutePath()
+ + cwdPath.mid(cwdOffset, -1);
+ QString cmdline
+ = QString("launch \"%1\" \"%2\" %3")
+ .arg(QDir::toNativeSeparators(dataCwd),
+ QDir::toNativeSeparators(dataBinPath), arguments);
return startBinary(QFileInfo(QCoreApplication::applicationFilePath()),
- cmdline,
- QCoreApplication::applicationDirPath(), true);
+ cmdline, QCoreApplication::applicationDirPath(), true);
} else {
return startBinary(binary, arguments, currentDirectory, true);
}
} else {
- qDebug("start of \"%s\" canceled by plugin", qPrintable(binary.absoluteFilePath()));
+ qDebug("start of \"%s\" canceled by plugin",
+ qPrintable(binary.absoluteFilePath()));
return INVALID_HANDLE_VALUE;
}
}
-HANDLE OrganizerCore::startApplication(const QString &executable, const QStringList &args, const QString &cwd, const QString &profile)
+HANDLE OrganizerCore::startApplication(const QString &executable,
+ const QStringList &args,
+ const QString &cwd,
+ const QString &profile)
{
QFileInfo binary;
- QString arguments = args.join(" ");
+ QString arguments = args.join(" ");
QString currentDirectory = cwd;
QString profileName = profile;
if (profile.length() == 0) {
@@ -1046,7 +1156,8 @@ HANDLE OrganizerCore::startApplication(const QString &executable, const QStringL
binary = QFileInfo(executable);
if (binary.isRelative()) {
// relative path, should be relative to game directory
- binary = QFileInfo(managedGame()->gameDirectory().absoluteFilePath(executable));
+ binary = QFileInfo(
+ managedGame()->gameDirectory().absoluteFilePath(executable));
}
if (cwd.length() == 0) {
currentDirectory = binary.absolutePath();
@@ -1054,7 +1165,7 @@ HANDLE OrganizerCore::startApplication(const QString &executable, const QStringL
try {
const Executable &exe = m_ExecutablesList.findByBinary(binary);
steamAppID = exe.m_SteamAppID;
- } catch (const std::runtime_error&) {
+ } catch (const std::runtime_error &) {
// nop
}
} else {
@@ -1069,20 +1180,22 @@ HANDLE OrganizerCore::startApplication(const QString &executable, const QStringL
if (cwd.length() == 0) {
currentDirectory = exe.m_WorkingDirectory;
}
- } catch (const std::runtime_error&) {
- qWarning("\"%s\" not set up as executable", executable.toUtf8().constData());
+ } catch (const std::runtime_error &) {
+ qWarning("\"%s\" not set up as executable",
+ executable.toUtf8().constData());
binary = QFileInfo(executable);
}
}
- return spawnBinaryDirect(binary, arguments, profileName, currentDirectory, steamAppID);
+ return spawnBinaryDirect(binary, arguments, profileName, currentDirectory,
+ steamAppID);
}
bool OrganizerCore::waitForApplication(HANDLE handle, LPDWORD exitCode)
{
if (m_UserInterface != nullptr) {
m_UserInterface->lock();
- ON_BLOCK_EXIT([&] () { m_UserInterface->unlock(); });
+ ON_BLOCK_EXIT([&]() { m_UserInterface->unlock(); });
}
DWORD retLen;
@@ -1090,33 +1203,41 @@ bool OrganizerCore::waitForApplication(HANDLE handle, LPDWORD exitCode)
bool isJobHandle = true;
- ULONG lastProcessID = ULONG_MAX;
+ ULONG lastProcessID = ULONG_MAX;
HANDLE processHandle = handle;
- DWORD res = ::MsgWaitForMultipleObjects(1, &handle, false, 500, QS_KEY | QS_MOUSE);
- while ((res != WAIT_FAILED)
- && (res != WAIT_OBJECT_0)
- && ((m_UserInterface == nullptr) || !m_UserInterface->unlockClicked())) {
+ DWORD res
+ = ::MsgWaitForMultipleObjects(1, &handle, false, 500, QS_KEY | QS_MOUSE);
+ while (
+ (res != WAIT_FAILED) && (res != WAIT_OBJECT_0)
+ && ((m_UserInterface == nullptr) || !m_UserInterface->unlockClicked())) {
if (isJobHandle) {
- if (::QueryInformationJobObject(handle, JobObjectBasicProcessIdList, &info, sizeof(info), &retLen) > 0) {
+ if (::QueryInformationJobObject(handle, JobObjectBasicProcessIdList,
+ &info, sizeof(info), &retLen)
+ > 0) {
if (info.NumberOfProcessIdsInList == 0) {
// fake signaled state
res = WAIT_OBJECT_0;
break;
} else {
- // this is indeed a job handle. Figure out one of the process handles as well.
+ // this is indeed a job handle. Figure out one of the process handles
+ // as well.
if (lastProcessID != info.ProcessIdList[0]) {
lastProcessID = info.ProcessIdList[0];
if (processHandle != handle) {
::CloseHandle(processHandle);
}
- processHandle = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, lastProcessID);
+ processHandle = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE,
+ lastProcessID);
}
}
} 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 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;
@@ -1127,7 +1248,8 @@ bool OrganizerCore::waitForApplication(HANDLE handle, LPDWORD exitCode)
// keep processing events so the app doesn't appear dead
QCoreApplication::processEvents();
- res = ::MsgWaitForMultipleObjects(1, &handle, false, 500, QS_KEY | QS_MOUSE);
+ res = ::MsgWaitForMultipleObjects(1, &handle, false, 500,
+ QS_KEY | QS_MOUSE);
}
if (exitCode != nullptr) {
@@ -1138,19 +1260,22 @@ bool OrganizerCore::waitForApplication(HANDLE handle, LPDWORD exitCode)
return res == WAIT_OBJECT_0;
}
-bool OrganizerCore::onAboutToRun(const std::function &func)
+bool OrganizerCore::onAboutToRun(
+ const std::function &func)
{
auto conn = m_AboutToRun.connect(func);
return conn.connected();
}
-bool OrganizerCore::onFinishedRun(const std::function &func)
+bool OrganizerCore::onFinishedRun(
+ const std::function &func)
{
auto conn = m_FinishedRun.connect(func);
return conn.connected();
}
-bool OrganizerCore::onModInstalled(const std::function &func)
+bool OrganizerCore::onModInstalled(
+ const std::function &func)
{
auto conn = m_ModInstalled.connect(func);
return conn.connected();
@@ -1162,7 +1287,8 @@ void OrganizerCore::refreshModList(bool saveChanges)
if (saveChanges) {
m_CurrentProfile->modlistWriter().writeImmediately(true);
}
- ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure, m_Settings.displayForeign(), managedGame());
+ ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure,
+ m_Settings.displayForeign(), managedGame());
m_CurrentProfile->refreshModStatus();
@@ -1174,16 +1300,16 @@ void OrganizerCore::refreshModList(bool saveChanges)
void OrganizerCore::refreshESPList()
{
if (m_DirectoryUpdate) {
- // don't mess up the esp list if we're currently updating the directory structure
- m_PostRefreshTasks.append([this] () { this->refreshESPList(); });
+ // don't mess up the esp list if we're currently updating the directory
+ // structure
+ m_PostRefreshTasks.append([this]() { this->refreshESPList(); });
return;
}
m_CurrentProfile->modlistWriter().write();
// clear list
try {
- m_PluginList.refresh(m_CurrentProfile->name(),
- *m_DirectoryStructure,
+ m_PluginList.refresh(m_CurrentProfile->name(), *m_DirectoryStructure,
m_CurrentProfile->getPluginsFileName(),
m_CurrentProfile->getLoadOrderFileName(),
m_CurrentProfile->getLockedOrderFileName());
@@ -1199,8 +1325,10 @@ void OrganizerCore::refreshBSAList()
if (archives != nullptr) {
m_ArchivesInit = false;
- // default archives are the ones enabled outside MO. if the list can't be found (which might
- // happen if ini files are missing) use hard-coded defaults (preferrably the same the game would use)
+ // default archives are the ones enabled outside MO. if the list can't be
+ // found (which might
+ // happen if ini files are missing) use hard-coded defaults (preferrably the
+ // same the game would use)
m_DefaultArchives = archives->archives(m_CurrentProfile);
if (m_DefaultArchives.length() == 0) {
m_DefaultArchives = archives->vanillaArchives();
@@ -1208,7 +1336,7 @@ void OrganizerCore::refreshBSAList()
m_ActiveArchives.clear();
- auto iter = enabledArchives();
+ auto iter = enabledArchives();
m_ActiveArchives = toStringList(iter.begin(), iter.end());
if (m_ActiveArchives.isEmpty()) {
m_ActiveArchives = m_DefaultArchives;
@@ -1223,17 +1351,19 @@ void OrganizerCore::refreshLists()
if ((m_CurrentProfile != nullptr) && m_DirectoryStructure->isPopulated()) {
refreshESPList();
refreshBSAList();
- } // no point in refreshing lists if no files have been added to the directory tree
+ } // no point in refreshing lists if no files have been added to the directory
+ // tree
}
void OrganizerCore::updateModActiveState(int index, bool active)
{
ModInfo::Ptr modInfo = ModInfo::getByIndex(index);
QDir dir(modInfo->absolutePath());
- for (const QString &esm : dir.entryList(QStringList() << "*.esm", QDir::Files)) {
+ for (const QString &esm :
+ dir.entryList(QStringList() << "*.esm", QDir::Files)) {
m_PluginList.enableESP(esm, active);
}
- int enabled = 0;
+ int enabled = 0;
QStringList esps = dir.entryList(QStringList() << "*.esp", QDir::Files);
for (const QString &esp : esps) {
const FileEntry::Ptr file = m_DirectoryStructure->findFile(ToWString(esp));
@@ -1249,47 +1379,50 @@ void OrganizerCore::updateModActiveState(int index, bool active)
}
}
if (active && (enabled > 1)) {
- MessageDialog::showMessage(tr("Multiple esps activated, please check that they don't conflict."), qApp->activeWindow());
+ MessageDialog::showMessage(
+ tr("Multiple esps activated, please check that they don't conflict."),
+ qApp->activeWindow());
}
m_PluginList.refreshLoadOrder();
// immediately save affected lists
m_PluginListsWriter.writeImmediately(false);
}
-void OrganizerCore::updateModInDirectoryStructure(unsigned int index, ModInfo::Ptr modInfo)
+void OrganizerCore::updateModInDirectoryStructure(unsigned int index,
+ ModInfo::Ptr modInfo)
{
// add files of the bsa to the directory structure
- m_DirectoryRefresher.addModFilesToStructure(m_DirectoryStructure
- , modInfo->name()
- , m_CurrentProfile->getModPriority(index)
- , modInfo->absolutePath()
- , modInfo->stealFiles()
- );
+ m_DirectoryRefresher.addModFilesToStructure(
+ m_DirectoryStructure, modInfo->name(),
+ m_CurrentProfile->getModPriority(index), modInfo->absolutePath(),
+ modInfo->stealFiles());
DirectoryRefresher::cleanStructure(m_DirectoryStructure);
// need to refresh plugin list now so we can activate esps
refreshESPList();
- // activate all esps of the specified mod so the bsas get activated along with it
+ // activate all esps of the specified mod so the bsas get activated along with
+ // it
updateModActiveState(index, true);
- // now we need to refresh the bsa list and save it so there is no confusion about what archives are avaiable and active
+ // now we need to refresh the bsa list and save it so there is no confusion
+ // about what archives are avaiable and active
refreshBSAList();
std::vector archives = enabledArchives();
- m_DirectoryRefresher.setMods(m_CurrentProfile->getActiveMods(),
- std::set(archives.begin(), archives.end()));
+ m_DirectoryRefresher.setMods(
+ m_CurrentProfile->getActiveMods(),
+ std::set(archives.begin(), archives.end()));
// finally also add files from bsas to the directory structure
- m_DirectoryRefresher.addModBSAToStructure(m_DirectoryStructure
- , modInfo->name()
- , m_CurrentProfile->getModPriority(index)
- , modInfo->absolutePath()
- , modInfo->archives()
- );
+ m_DirectoryRefresher.addModBSAToStructure(
+ m_DirectoryStructure, modInfo->name(),
+ m_CurrentProfile->getModPriority(index), modInfo->absolutePath(),
+ modInfo->archives());
}
void OrganizerCore::requestDownload(const QUrl &url, QNetworkReply *reply)
{
if (m_PluginContainer != nullptr) {
- for (IPluginModPage *modPage : m_PluginContainer->plugins()) {
+ for (IPluginModPage *modPage :
+ m_PluginContainer->plugins()) {
ModRepositoryFileInfo *fileInfo = new ModRepositoryFileInfo();
if (modPage->handlesDownload(url, reply->url(), *fileInfo)) {
fileInfo->repository = modPage->name();
@@ -1301,7 +1434,7 @@ void OrganizerCore::requestDownload(const QUrl &url, QNetworkReply *reply)
// no mod found that could handle the download. Is it a nexus mod?
if (url.host() == "www.nexusmods.com") {
- int modID = 0;
+ int modID = 0;
int fileID = 0;
QRegExp modExp("mods/(\\d+)");
if (modExp.indexIn(url.toString()) != -1) {
@@ -1311,13 +1444,18 @@ void OrganizerCore::requestDownload(const QUrl &url, QNetworkReply *reply)
if (fileExp.indexIn(reply->url().toString()) != -1) {
fileID = fileExp.cap(1).toInt();
}
- m_DownloadManager.addDownload(reply, new ModRepositoryFileInfo(modID, fileID));
+ m_DownloadManager.addDownload(reply,
+ new ModRepositoryFileInfo(modID, fileID));
} else {
if (QMessageBox::question(qApp->activeWindow(), tr("Download?"),
- tr("A download has been started but no installed page plugin recognizes it.\n"
- "If you download anyway no information (i.e. version) will be associated with the download.\n"
- "Continue?"),
- QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ tr("A download has been started but no installed "
+ "page plugin recognizes it.\n"
+ "If you download anyway no information (i.e. "
+ "version) will be associated with the "
+ "download.\n"
+ "Continue?"),
+ QMessageBox::Yes | QMessageBox::No)
+ == QMessageBox::Yes) {
m_DownloadManager.addDownload(reply, new ModRepositoryFileInfo());
}
}
@@ -1361,10 +1499,11 @@ void OrganizerCore::refreshDirectoryStructure()
m_CurrentProfile->modlistWriter().writeImmediately(true);
m_DirectoryUpdate = true;
- std::vector > activeModList = m_CurrentProfile->getActiveMods();
+ std::vector> activeModList
+ = m_CurrentProfile->getActiveMods();
auto archives = enabledArchives();
- m_DirectoryRefresher.setMods(activeModList,
- std::set(archives.begin(), archives.end()));
+ m_DirectoryRefresher.setMods(
+ activeModList, std::set(archives.begin(), archives.end()));
QTimer::singleShot(0, &m_DirectoryRefresher, SLOT(refresh()));
}
@@ -1378,7 +1517,8 @@ void OrganizerCore::directory_refreshed()
std::swap(m_DirectoryStructure, newStructure);
delete newStructure;
} else {
- // TODO: don't know why this happens, this slot seems to get called twice with only one emit
+ // TODO: don't know why this happens, this slot seems to get called twice
+ // with only one emit
return;
}
m_DirectoryUpdate = false;
@@ -1397,8 +1537,10 @@ void OrganizerCore::directory_refreshed()
void OrganizerCore::profileRefresh()
{
- // have to refresh mods twice (again in refreshModList), otherwise the refresh isn't complete. Not sure why
- ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure, m_Settings.displayForeign(), managedGame());
+ // have to refresh mods twice (again in refreshModList), otherwise the refresh
+ // isn't complete. Not sure why
+ ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure,
+ m_Settings.displayForeign(), managedGame());
m_CurrentProfile->refreshModStatus();
refreshModList();
@@ -1414,7 +1556,8 @@ void OrganizerCore::modStatusChanged(unsigned int index)
updateModActiveState(index, false);
refreshESPList();
if (m_DirectoryStructure->originExists(ToWString(modInfo->name()))) {
- FilesOrigin &origin = m_DirectoryStructure->getOriginByName(ToWString(modInfo->name()));
+ FilesOrigin &origin
+ = m_DirectoryStructure->getOriginByName(ToWString(modInfo->name()));
origin.enable(false);
}
}
@@ -1424,14 +1567,16 @@ void OrganizerCore::modStatusChanged(unsigned int index)
ModInfo::Ptr modInfo = ModInfo::getByIndex(i);
int priority = m_CurrentProfile->getModPriority(i);
if (m_DirectoryStructure->originExists(ToWString(modInfo->name()))) {
- // priorities in the directory structure are one higher because data is 0
- m_DirectoryStructure->getOriginByName(ToWString(modInfo->name())).setPriority(priority + 1);
+ // priorities in the directory structure are one higher because data is
+ // 0
+ m_DirectoryStructure->getOriginByName(ToWString(modInfo->name()))
+ .setPriority(priority + 1);
}
}
m_DirectoryStructure->getFileRegister()->sortOrigins();
refreshLists();
- } catch (const std::exception& e) {
+ } catch (const std::exception &e) {
reportError(tr("failed to update mod list: %1").arg(e.what()));
}
}
@@ -1463,39 +1608,50 @@ void OrganizerCore::loginSuccessfulUpdate(bool necessary)
void OrganizerCore::loginFailed(const QString &message)
{
- if (QMessageBox::question(qApp->activeWindow(), tr("Login failed"), tr("Login failed, try again?")) == QMessageBox::Yes) {
+ if (QMessageBox::question(qApp->activeWindow(), tr("Login failed"),
+ tr("Login failed, try again?"))
+ == QMessageBox::Yes) {
if (nexusLogin(true)) {
return;
}
}
if (!m_PendingDownloads.isEmpty()) {
- MessageDialog::showMessage(tr("login failed: %1. Download will not be associated with an account").arg(message), qApp->activeWindow());
+ MessageDialog::showMessage(
+ tr("login failed: %1. Download will not be associated with an account")
+ .arg(message),
+ qApp->activeWindow());
for (QString url : m_PendingDownloads) {
downloadRequestedNXM(url);
}
m_PendingDownloads.clear();
} else {
- MessageDialog::showMessage(tr("login failed: %1").arg(message), qApp->activeWindow());
+ MessageDialog::showMessage(tr("login failed: %1").arg(message),
+ qApp->activeWindow());
m_PostLoginTasks.clear();
}
NexusInterface::instance()->loginCompleted();
}
-
void OrganizerCore::loginFailedUpdate(const QString &message)
{
- MessageDialog::showMessage(tr("login failed: %1. You need to log-in with Nexus to update MO.").arg(message), qApp->activeWindow());
+ MessageDialog::showMessage(
+ tr("login failed: %1. You need to log-in with Nexus to update MO.")
+ .arg(message),
+ qApp->activeWindow());
}
void OrganizerCore::syncOverwrite()
{
- unsigned int overwriteIndex = ModInfo::findMod([](ModInfo::Ptr mod) -> bool {
+ unsigned int overwriteIndex = ModInfo::findMod([](ModInfo::Ptr mod) -> bool {
std::vector flags = mod->getFlags();
- return std::find(flags.begin(), flags.end(), ModInfo::FLAG_OVERWRITE) != flags.end(); });
+ return std::find(flags.begin(), flags.end(), ModInfo::FLAG_OVERWRITE)
+ != flags.end();
+ });
ModInfo::Ptr modInfo = ModInfo::getByIndex(overwriteIndex);
- SyncOverwriteDialog syncDialog(modInfo->absolutePath(), m_DirectoryStructure, qApp->activeWindow());
+ SyncOverwriteDialog syncDialog(modInfo->absolutePath(), m_DirectoryStructure,
+ qApp->activeWindow());
if (syncDialog.exec() == QDialog::Accepted) {
syncDialog.apply(QDir::fromNativeSeparators(m_Settings.getModDirectory()));
modInfo->testValid();
@@ -1528,8 +1684,13 @@ QString OrganizerCore::fullDescription(unsigned int key) const
{
switch (key) {
case PROBLEM_TOOMANYPLUGINS: {
- return tr("The game doesn't allow more than 255 active plugins (including the official ones) to be loaded. You have to disable some unused plugins or "
- "merge some plugins into one. You can find a guide here: http://wiki.step-project.com/Guide:Merging_Plugins");
+ return tr("The game doesn't allow more than 255 active plugins "
+ "(including the official ones) to be loaded. You have to "
+ "disable some unused plugins or "
+ "merge some plugins into one. You can find a guide here: http://wiki.step-project.com/"
+ "Guide:Merging_Plugins");
} break;
default: {
return tr("Description missing");
@@ -1566,7 +1727,7 @@ void OrganizerCore::savePluginList()
{
if (m_DirectoryUpdate) {
// delay save till after directory update
- m_PostRefreshTasks.append([&] () { this->savePluginList(); });
+ m_PostRefreshTasks.append([&]() { this->savePluginList(); });
return;
}
m_PluginList.saveTo(m_CurrentProfile->getPluginsFileName(),
@@ -1577,7 +1738,8 @@ void OrganizerCore::savePluginList()
m_PluginList.saveLoadOrder(*m_DirectoryStructure);
}
-void OrganizerCore::prepareStart() {
+void OrganizerCore::prepareStart()
+{
if (m_CurrentProfile == nullptr) {
return;
}
@@ -1598,17 +1760,16 @@ std::vector OrganizerCore::fileMapping()
int overwriteId = m_DirectoryStructure->getOriginByName(L"Overwrite").getID();
- IPluginGame *game = qApp->property("managed_game").value();
+ IPluginGame *game = qApp->property("managed_game").value();
MappingType result = fileMapping(
- QDir::toNativeSeparators(game->dataDirectory().absolutePath()),
- "\\",
- directoryStructure(), directoryStructure(),
- overwriteId);
+ QDir::toNativeSeparators(game->dataDirectory().absolutePath()), "\\",
+ directoryStructure(), directoryStructure(), overwriteId);
if (m_CurrentProfile->localSavesEnabled()) {
LocalSavegames *localSaves = game->feature();
if (localSaves != nullptr) {
- MappingType saveMap = localSaves->mappings(currentProfile()->absolutePath() + "/saves");
+ MappingType saveMap
+ = localSaves->mappings(currentProfile()->absolutePath() + "/saves");
result.reserve(result.size() + saveMap.size());
result.insert(result.end(), saveMap.begin(), saveMap.end());
} else {
@@ -1616,8 +1777,9 @@ std::vector OrganizerCore::fileMapping()
}
}
- for (MOBase::IPluginFileMapper *mapper : m_PluginContainer->plugins()) {
- IPlugin *plugin = dynamic_cast(mapper);
+ for (MOBase::IPluginFileMapper *mapper :
+ m_PluginContainer->plugins()) {
+ IPlugin *plugin = dynamic_cast(mapper);
if (plugin->isActive()) {
MappingType pluginMap = mapper->mappings();
result.reserve(result.size() + pluginMap.size());
@@ -1629,11 +1791,8 @@ std::vector OrganizerCore::fileMapping()
}
std::vector OrganizerCore::fileMapping(
- const QString &dataPath,
- const QString &relPath,
- const DirectoryEntry *base,
- const DirectoryEntry *directoryEntry,
- int createDestination)
+ const QString &dataPath, const QString &relPath, const DirectoryEntry *base,
+ const DirectoryEntry *directoryEntry, int createDestination)
{
std::vector result;
@@ -1647,15 +1806,15 @@ std::vector OrganizerCore::fileMapping(
QString originPath
= QString::fromStdWString(base->getOriginByID(origin).getPath());
QString fileName = QString::fromStdWString(current->getName());
- QString source = originPath + relPath + fileName;
- QString target = dataPath + relPath + fileName;
+ QString source = originPath + relPath + fileName;
+ QString target = dataPath + relPath + fileName;
if (source != target) {
result.push_back({source, target, false, false});
}
}
// recurse into subdirectories
- std::vector::const_iterator current, end;
+ std::vector::const_iterator current, end;
directoryEntry->getSubDirectories(current, end);
for (; current != end; ++current) {
int origin = (*current)->anyOrigin();
@@ -1663,18 +1822,16 @@ std::vector OrganizerCore::fileMapping(
QString originPath
= QString::fromStdWString(base->getOriginByID(origin).getPath());
QString dirName = QString::fromStdWString((*current)->getName());
- QString source = originPath + relPath + dirName;
- QString target = dataPath + relPath + dirName;
+ QString source = originPath + relPath + dirName;
+ QString target = dataPath + relPath + dirName;
- bool writeDestination = (base == directoryEntry)
- && (origin == createDestination);
+ bool writeDestination
+ = (base == directoryEntry) && (origin == createDestination);
result.push_back({source, target, true, writeDestination});
- std::vector subRes
- = fileMapping(dataPath, relPath + dirName + "\\", base, *current,
- createDestination);
+ std::vector subRes = fileMapping(
+ dataPath, relPath + dirName + "\\", base, *current, createDestination);
result.insert(result.end(), subRes.begin(), subRes.end());
}
return result;
}
-
diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp
index 380abe01..c56482f4 100644
--- a/src/usvfsconnector.cpp
+++ b/src/usvfsconnector.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 "usvfsconnector.h"
#include "settings.h"
#include
@@ -26,41 +25,49 @@ along with Mod Organizer. If not, see .
#include
#include
-
static const char SHMID[] = "mod_organizer_instance";
-
/*
-extern "C" DLLEXPORT BOOL WINAPI VirtualLinkFile(LPCWSTR source, LPCWSTR destination, BOOL failIfExists);
-extern "C" DLLEXPORT BOOL WINAPI VirtualLinkDirectoryStatic(LPCWSTR source, LPCWSTR destination, unsigned int flags);
-extern "C" DLLEXPORT BOOL WINAPI ConnectVFS(const usvfs::Parameters *parameters);
+extern "C" DLLEXPORT BOOL WINAPI VirtualLinkFile(LPCWSTR source, LPCWSTR
+destination, BOOL failIfExists);
+extern "C" DLLEXPORT BOOL WINAPI VirtualLinkDirectoryStatic(LPCWSTR source,
+LPCWSTR destination, unsigned int flags);
+extern "C" DLLEXPORT BOOL WINAPI ConnectVFS(const usvfs::Parameters
+*parameters);
extern "C" DLLEXPORT void WINAPI DisconnectVFS();
extern "C" DLLEXPORT void WINAPI GetCurrentVFSName(char *buffer, size_t size);
extern "C" DLLEXPORT BOOL WINAPI CreateProcessHooked(LPCWSTR lpApplicationName
, LPWSTR lpCommandLine
- , LPSECURITY_ATTRIBUTES lpProcessAttributes
- , LPSECURITY_ATTRIBUTES lpThreadAttributes
+ , LPSECURITY_ATTRIBUTES
+lpProcessAttributes
+ , LPSECURITY_ATTRIBUTES
+lpThreadAttributes
, BOOL bInheritHandles
, DWORD dwCreationFlags
, LPVOID lpEnvironment
- , LPCWSTR lpCurrentDirectory
- , LPSTARTUPINFOW lpStartupInfo
- , LPPROCESS_INFORMATION lpProcessInformation
+ , LPCWSTR
+lpCurrentDirectory
+ , LPSTARTUPINFOW
+lpStartupInfo
+ , LPPROCESS_INFORMATION
+lpProcessInformation
);
extern "C" DLLEXPORT void __cdecl InitLogging(bool toLocal = false);
-extern "C" DLLEXPORT void __cdecl InitHooks(LPVOID userData, size_t userDataSize);
+extern "C" DLLEXPORT void __cdecl InitHooks(LPVOID userData, size_t
+userDataSize);
*/
-
LogWorker::LogWorker()
: m_Buffer(1024, '\0')
, m_QuitRequested(false)
, m_LogFile(qApp->property("dataPath").toString()
- + QString("/logs/usvfs-%1.log").arg(
- QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd_hh-mm-ss")))
+ + QString("/logs/usvfs-%1.log")
+ .arg(QDateTime::currentDateTimeUtc().toString(
+ "yyyy-MM-dd_hh-mm-ss")))
{
m_LogFile.open(QIODevice::WriteOnly);
- qDebug("usvfs log messages are written to %s", qPrintable(m_LogFile.fileName()));
+ qDebug("usvfs log messages are written to %s",
+ qPrintable(m_LogFile.fileName()));
}
LogWorker::~LogWorker()
--
cgit v1.3.1
From 3202713cffed47611d96845562a0aaad86d5ad33 Mon Sep 17 00:00:00 2001
From: Tannin
Date: Tue, 9 Feb 2016 20:46:46 +0100
Subject: updated to match current usvfs api
---
src/usvfsconnector.cpp | 52 ++++++++++++++++++++++++++++++--------------------
1 file changed, 31 insertions(+), 21 deletions(-)
(limited to 'src/usvfsconnector.cpp')
diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp
index c56482f4..db20a54f 100644
--- a/src/usvfsconnector.cpp
+++ b/src/usvfsconnector.cpp
@@ -96,19 +96,27 @@ void LogWorker::exit()
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;
+ 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(Settings::instance().logLevel()));
+ USVFSParameters params;
+ USVFSInitParameters(¶ms, SHMID, false,
+ logLevel(Settings::instance().logLevel()));
InitLogging(false);
ConnectVFS(¶ms);
+ BlacklistExecutable(L"TSVNCache.exe");
+
m_LogWorker.moveToThread(&m_WorkerThread);
connect(&m_WorkerThread, SIGNAL(started()), &m_LogWorker, SLOT(process()));
@@ -122,37 +130,39 @@ UsvfsConnector::~UsvfsConnector()
DisconnectVFS();
m_LogWorker.exit();
m_WorkerThread.quit();
- //m_WorkerThread.wait();
+ m_WorkerThread.wait();
}
void UsvfsConnector::updateMapping(const MappingType &mapping)
{
QProgressDialog progress;
progress.setLabelText(tr("Preparing vfs"));
- progress.setMaximum(mapping.size());
+ progress.setMaximum(static_cast(mapping.size()));
progress.show();
int value = 0;
+
+ ClearVirtualMappings();
+
for (auto map : mapping) {
progress.setValue(value++);
if (value % 10 == 0) {
QCoreApplication::processEvents();
}
if (map.isDirectory) {
- VirtualLinkDirectoryStatic(map.source.toStdWString().c_str()
- , map.destination.toStdWString().c_str()
- , (map.createTarget ? LINKFLAG_CREATETARGET : 0) | LINKFLAG_RECURSIVE);
+ VirtualLinkDirectoryStatic(map.source.toStdWString().c_str(),
+ map.destination.toStdWString().c_str(),
+ (map.createTarget ? LINKFLAG_CREATETARGET : 0)
+ | LINKFLAG_RECURSIVE);
} else {
- VirtualLinkFile(map.source.toStdWString().c_str()
- , map.destination.toStdWString().c_str()
- , 0);
+ VirtualLinkFile(map.source.toStdWString().c_str(),
+ map.destination.toStdWString().c_str(), 0);
}
}
-/*
- size_t dumpSize = 0;
- CreateVFSDump(nullptr, &dumpSize);
- std::unique_ptr buffer(new char[dumpSize]);
- CreateVFSDump(buffer.get(), &dumpSize);
- qDebug(buffer.get());
-*/
+ /*
+ size_t dumpSize = 0;
+ CreateVFSDump(nullptr, &dumpSize);
+ std::unique_ptr buffer(new char[dumpSize]);
+ CreateVFSDump(buffer.get(), &dumpSize);
+ qDebug(buffer.get());
+ */
}
-
--
cgit v1.3.1
From eb97c46ed68a965d6ddf44fa6741fa929fd7d278 Mon Sep 17 00:00:00 2001
From: Tannin
Date: Sat, 7 May 2016 00:03:38 +0200
Subject: cleanup
---
src/CMakeLists.txt | 12 ++++-
src/aboutdialog.cpp | 5 ++-
src/aboutdialog.ui | 50 +++++++++++++++++++--
src/categories.cpp | 2 +-
src/directoryrefresher.cpp | 2 +-
src/downloadmanager.cpp | 47 +++++++++----------
src/editexecutablesdialog.cpp | 8 ++--
src/editexecutablesdialog.ui | 4 +-
src/executableslist.h | 3 +-
src/installationmanager.cpp | 3 +-
src/logbuffer.cpp | 22 +++++----
src/main.cpp | 6 +--
src/mainwindow.cpp | 14 +++---
src/mainwindow.ui | 40 +++++++++++------
src/modflagicondelegate.cpp | 6 +--
src/modinfo.cpp | 6 +--
src/modinfodialog.cpp | 10 +++--
src/nexusinterface.cpp | 11 ++---
src/organizercore.cpp | 12 +++--
src/persistentcookiejar.cpp | 2 +-
src/plugincontainer.cpp | 4 +-
src/profile.cpp | 17 +++----
src/profile.h | 2 +-
src/profilesdialog.cpp | 102 ++++++++++++++++++++----------------------
src/profilesdialog.ui | 4 +-
src/shared/util.cpp | 8 +++-
src/usvfsconnector.cpp | 9 +++-
src/version.rc | 4 +-
28 files changed, 248 insertions(+), 167 deletions(-)
(limited to 'src/usvfsconnector.cpp')
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 02c63ad2..a8b43c59 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -272,14 +272,22 @@ INCLUDE_DIRECTORIES(${project_path}/uibase/src
${project_path}/archive/src
${project_path}/../usvfs/usvfs
${project_path}/game_gamebryo/src
- ${project_path}/game_features/src)
+ ${project_path}/game_features/src
+ ${project_path}/githubpp/src)
INCLUDE_DIRECTORIES(shared ${ZLIB_INCLUDE_DIRS})
LINK_DIRECTORIES(${lib_path}
${project_path}/../zlib/lib)
-ADD_DEFINITIONS(-D_UNICODE -DUNICODE -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS)
+EXECUTE_PROCESS(
+ COMMAND git log -1 --format=%h
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ OUTPUT_VARIABLE GIT_COMMIT_HASH
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+ADD_DEFINITIONS(-D_UNICODE -DUNICODE -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -DGITID="${GIT_COMMIT_HASH}")
IF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
SET(usvfs_name usvfs_x64)
diff --git a/src/aboutdialog.cpp b/src/aboutdialog.cpp
index 3657a10d..ed57a217 100644
--- a/src/aboutdialog.cpp
+++ b/src/aboutdialog.cpp
@@ -54,10 +54,13 @@ AboutDialog::AboutDialog(const QString &version, QWidget *parent)
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));
-#ifdef HGID
+#if defined(HGID)
ui->revisionLabel->setText(ui->revisionLabel->text() + " " + HGID);
+#elif defined(GITID)
+ ui->revisionLabel->setText(ui->revisionLabel->text() + " " + GITID);
#else
ui->revisionLabel->setText(ui->revisionLabel->text() + " unknown");
#endif
diff --git a/src/aboutdialog.ui b/src/aboutdialog.ui
index ea5d2141..8d560f2b 100644
--- a/src/aboutdialog.ui
+++ b/src/aboutdialog.ui
@@ -6,8 +6,8 @@
0
0
- 508
- 335
+ 746
+ 369
@@ -18,13 +18,50 @@
-
+
-
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
-
+
+
+ 0
+ 0
+
+
+
+
+ 250
+ 250
+
+
+
+
+ 250
+ 250
+
+
- :/MO/gui/mo_icon.ico
+ :/MO/gui/splash
+
+
+ true
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
@@ -83,7 +120,7 @@
-
- Copyright 2011-2015 Sebastian Herbord
+ Copyright 2011-2016 Sebastian Herbord
@@ -265,6 +302,11 @@
thosrtanner
+ -
+
+ ogrotten
+
+
diff --git a/src/categories.cpp b/src/categories.cpp
index 7539d3fd..50ba5271 100644
--- a/src/categories.cpp
+++ b/src/categories.cpp
@@ -188,7 +188,7 @@ int CategoryFactory::addCategory(const QString &name, const std::vector &ne
void CategoryFactory::addCategory(int id, const QString &name, const std::vector &nexusIDs, int parentID)
{
- int index = m_Categories.size();
+ 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;
diff --git a/src/directoryrefresher.cpp b/src/directoryrefresher.cpp
index 4eac4103..0a8b82be 100644
--- a/src/directoryrefresher.cpp
+++ b/src/directoryrefresher.cpp
@@ -159,7 +159,7 @@ void DirectoryRefresher::refresh()
} catch (const std::exception &e) {
emit error(tr("failed to read mod (%1): %2").arg(iter->modName, e.what()));
}
- emit progress((i * 100) / m_Mods.size() + 1);
+ emit progress((i * 100) / static_cast(m_Mods.size()) + 1);
}
emit progress(100);
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index 6b4628cc..b92e171e 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -88,7 +88,8 @@ DownloadManager::DownloadInfo *DownloadManager::DownloadInfo::createFromMeta(con
QString fileName = QFileInfo(filePath).fileName();
if (fileName.endsWith(UNFINISHED)) {
- info->m_FileName = fileName.mid(0, fileName.length() - strlen(UNFINISHED));
+ info->m_FileName = fileName.mid(
+ 0, fileName.length() - static_cast(strlen(UNFINISHED)));
info->m_State = STATE_PAUSED;
} else {
info->m_FileName = fileName;
@@ -471,7 +472,7 @@ void DownloadManager::addNXMDownload(const QString &url)
void DownloadManager::removeFile(int index, bool deleteFile)
{
if (index >= m_ActiveDownloads.size()) {
- throw MyException(tr("invalid index"));
+ throw MyException(tr("remove: invalid download index %1").arg(index));
}
DownloadInfo *download = m_ActiveDownloads.at(index);
@@ -538,7 +539,7 @@ void DownloadManager::refreshAlphabeticalTranslation()
void DownloadManager::restoreDownload(int index)
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- throw MyException(tr("invalid index"));
+ throw MyException(tr("restore: invalid download index: %1").arg(index));
}
DownloadInfo *download = m_ActiveDownloads.at(index);
@@ -571,7 +572,7 @@ void DownloadManager::removeDownload(int index, bool deleteFile)
}
} else {
if (index >= m_ActiveDownloads.size()) {
- reportError(tr("invalid index %1").arg(index));
+ reportError(tr("remove: invalid download index %1").arg(index));
return;
}
@@ -589,7 +590,7 @@ void DownloadManager::removeDownload(int index, bool deleteFile)
void DownloadManager::cancelDownload(int index)
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- reportError(tr("invalid index %1").arg(index));
+ reportError(tr("cancel: invalid download index %1").arg(index));
return;
}
@@ -602,7 +603,7 @@ void DownloadManager::cancelDownload(int index)
void DownloadManager::pauseDownload(int index)
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- reportError(tr("invalid index %1").arg(index));
+ reportError(tr("pause: invalid download index %1").arg(index));
return;
}
@@ -622,7 +623,7 @@ void DownloadManager::pauseDownload(int index)
void DownloadManager::resumeDownload(int index)
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- reportError(tr("invalid index %1").arg(index));
+ reportError(tr("resume: invalid download index %1").arg(index));
return;
}
DownloadInfo *info = m_ActiveDownloads[index];
@@ -633,7 +634,7 @@ void DownloadManager::resumeDownload(int index)
void DownloadManager::resumeDownloadInt(int index)
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- reportError(tr("invalid index %1").arg(index));
+ reportError(tr("resume (int): invalid download index %1").arg(index));
return;
}
DownloadInfo *info = m_ActiveDownloads[index];
@@ -673,7 +674,7 @@ DownloadManager::DownloadInfo *DownloadManager::downloadInfoByID(unsigned int id
void DownloadManager::queryInfo(int index)
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- reportError(tr("invalid index %1").arg(index));
+ reportError(tr("query: invalid download index %1").arg(index));
return;
}
DownloadInfo *info = m_ActiveDownloads[index];
@@ -721,7 +722,7 @@ int DownloadManager::numPendingDownloads() const
std::pair DownloadManager::getPendingDownload(int index)
{
if ((index < 0) || (index >= m_PendingDownloads.size())) {
- throw MyException(tr("invalid index"));
+ throw MyException(tr("get pending: invalid download index %1").arg(index));
}
return m_PendingDownloads.at(index);
@@ -730,7 +731,7 @@ std::pair DownloadManager::getPendingDownload(int index)
QString DownloadManager::getFilePath(int index) const
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- throw MyException(tr("invalid index"));
+ throw MyException(tr("get path: invalid download index %1").arg(index));
}
return m_OutputDirectory + "/" + m_ActiveDownloads.at(index)->m_FileName;
@@ -751,7 +752,7 @@ QString DownloadManager::getFileTypeString(int fileType)
QString DownloadManager::getDisplayName(int index) const
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- throw MyException(tr("invalid index"));
+ throw MyException(tr("display name: invalid download index %1").arg(index));
}
DownloadInfo *info = m_ActiveDownloads.at(index);
@@ -768,7 +769,7 @@ QString DownloadManager::getDisplayName(int index) const
QString DownloadManager::getFileName(int index) const
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- throw MyException(tr("invalid index"));
+ throw MyException(tr("file name: invalid download index %1").arg(index));
}
return m_ActiveDownloads.at(index)->m_FileName;
@@ -777,7 +778,7 @@ QString DownloadManager::getFileName(int index) const
QDateTime DownloadManager::getFileTime(int index) const
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- throw MyException(tr("invalid index"));
+ throw MyException(tr("file time: invalid download index %1").arg(index));
}
DownloadInfo *info = m_ActiveDownloads.at(index);
@@ -791,7 +792,7 @@ QDateTime DownloadManager::getFileTime(int index) const
qint64 DownloadManager::getFileSize(int index) const
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- throw MyException(tr("invalid index"));
+ throw MyException(tr("file size: invalid download index %1").arg(index));
}
return m_ActiveDownloads.at(index)->m_TotalSize;
@@ -801,7 +802,7 @@ qint64 DownloadManager::getFileSize(int index) const
int DownloadManager::getProgress(int index) const
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- throw MyException(tr("invalid index"));
+ throw MyException(tr("progress: invalid download index %1").arg(index));
}
return m_ActiveDownloads.at(index)->m_Progress;
@@ -811,7 +812,7 @@ int DownloadManager::getProgress(int index) const
DownloadManager::DownloadState DownloadManager::getState(int index) const
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- throw MyException(tr("invalid index"));
+ throw MyException(tr("state: invalid download index %1").arg(index));
}
return m_ActiveDownloads.at(index)->m_State;
@@ -821,7 +822,7 @@ DownloadManager::DownloadState DownloadManager::getState(int index) const
bool DownloadManager::isInfoIncomplete(int index) const
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- throw MyException(tr("invalid index"));
+ throw MyException(tr("infocomplete: invalid download index %1").arg(index));
}
DownloadInfo *info = m_ActiveDownloads.at(index);
@@ -836,7 +837,7 @@ bool DownloadManager::isInfoIncomplete(int index) const
int DownloadManager::getModID(int index) const
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- throw MyException(tr("invalid index"));
+ throw MyException(tr("mod id: invalid download index %1").arg(index));
}
return m_ActiveDownloads.at(index)->m_FileInfo->modID;
}
@@ -844,7 +845,7 @@ int DownloadManager::getModID(int index) const
bool DownloadManager::isHidden(int index) const
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- throw MyException(tr("invalid index"));
+ throw MyException(tr("ishidden: invalid download index %1").arg(index));
}
return m_ActiveDownloads.at(index)->m_Hidden;
}
@@ -853,7 +854,7 @@ bool DownloadManager::isHidden(int index) const
const ModRepositoryFileInfo *DownloadManager::getFileInfo(int index) const
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- throw MyException(tr("invalid index"));
+ throw MyException(tr("file info: invalid download index %1").arg(index));
}
return m_ActiveDownloads.at(index)->m_FileInfo;
@@ -863,7 +864,7 @@ const ModRepositoryFileInfo *DownloadManager::getFileInfo(int index) const
void DownloadManager::markInstalled(int index)
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- throw MyException(tr("invalid index"));
+ throw MyException(tr("mark installed: invalid download index %1").arg(index));
}
DownloadInfo *info = m_ActiveDownloads.at(index);
@@ -878,7 +879,7 @@ void DownloadManager::markInstalled(int index)
void DownloadManager::markUninstalled(int index)
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- throw MyException(tr("invalid index"));
+ throw MyException(tr("mark uninstalled: invalid download index %1").arg(index));
}
DownloadInfo *info = m_ActiveDownloads.at(index);
diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp
index 1b2d5a48..05a7603d 100644
--- a/src/editexecutablesdialog.cpp
+++ b/src/editexecutablesdialog.cpp
@@ -126,15 +126,17 @@ void EditExecutablesDialog::on_addButton_clicked()
void EditExecutablesDialog::on_browseButton_clicked()
{
- QString binaryName = FileDialogMemory::getOpenFileName("editExecutableBinary", this,
- tr("Select a binary"), QString(), tr("Executable (%1)").arg("*.exe *.bat *.jar"));
+ QString binaryName = FileDialogMemory::getOpenFileName(
+ "editExecutableBinary", this, tr("Select a binary"), QString(),
+ tr("Executable (%1)").arg("*.exe *.bat *.jar"));
if (binaryName.endsWith(".jar", Qt::CaseInsensitive)) {
QString binaryPath;
{ // try to find java automatically
std::wstring binaryNameW = ToWString(binaryName);
WCHAR buffer[MAX_PATH];
- if (::FindExecutableW(binaryNameW.c_str(), nullptr, buffer) > (HINSTANCE)32) {
+ if (::FindExecutableW(binaryNameW.c_str(), nullptr, buffer)
+ > reinterpret_cast(32)) {
DWORD binaryType = 0UL;
if (!::GetBinaryTypeW(binaryNameW.c_str(), &binaryType)) {
qDebug("failed to determine binary type of \"%ls\": %lu", binaryNameW.c_str(), ::GetLastError());
diff --git a/src/editexecutablesdialog.ui b/src/editexecutablesdialog.ui
index a2aad19a..2640bb15 100644
--- a/src/editexecutablesdialog.ui
+++ b/src/editexecutablesdialog.ui
@@ -6,8 +6,8 @@
0
0
- 384
- 446
+ 426
+ 460
diff --git a/src/executableslist.h b/src/executableslist.h
index eb7d2d6f..0534c09e 100644
--- a/src/executableslist.h
+++ b/src/executableslist.h
@@ -133,7 +133,8 @@ public:
const QString &steamAppID,
Executable::Flags flags)
{
- updateExecutable(title, executableName, arguments, workingDirectory, steamAppID, Executable::AllFlags, flags);
+ updateExecutable(title, executableName, arguments, workingDirectory,
+ steamAppID, Executable::AllFlags, flags);
}
/**
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp
index 8ab27124..bf5ee91a 100644
--- a/src/installationmanager.cpp
+++ b/src/installationmanager.cpp
@@ -346,7 +346,8 @@ DirectoryTree *InstallationManager::createFilesTree()
// to uncheck all files in a directory while keeping the dir checked. Those directories are
// currently not installed.
DirectoryTree::Node *newNode = new DirectoryTree::Node;
- newNode->setData(DirectoryTreeInformation(*componentIter, i));
+ newNode->setData(
+ DirectoryTreeInformation(*componentIter, static_cast(i)));
currentNode->addNode(newNode, false);
currentNode = newNode;
} else {
diff --git a/src/logbuffer.cpp b/src/logbuffer.cpp
index 8207dcbb..522ce3c8 100644
--- a/src/logbuffer.cpp
+++ b/src/logbuffer.cpp
@@ -53,13 +53,15 @@ void LogBuffer::logMessage(QtMsgType type, const QString &message)
if (type >= m_MinMsgType) {
Message msg = {type, QTime::currentTime(), message};
if (m_NumMessages < m_Messages.size()) {
- beginInsertRows(QModelIndex(), m_NumMessages, m_NumMessages + 1);
+ beginInsertRows(QModelIndex(), static_cast(m_NumMessages),
+ static_cast(m_NumMessages) + 1);
}
m_Messages.at(m_NumMessages % m_Messages.size()) = msg;
if (m_NumMessages < m_Messages.size()) {
endInsertRows();
} else {
- emit dataChanged(createIndex(0, 0), createIndex(m_Messages.size(), 0));
+ emit dataChanged(createIndex(0, 0),
+ createIndex(static_cast(m_Messages.size()), 0));
}
++m_NumMessages;
if (type >= QtCriticalMsg) {
@@ -84,9 +86,10 @@ void LogBuffer::write() const
return;
}
- unsigned int i = (m_NumMessages > m_Messages.size())
- ? m_NumMessages - m_Messages.size()
- : 0U;
+ unsigned int i
+ = (m_NumMessages > m_Messages.size())
+ ? static_cast(m_NumMessages - m_Messages.size())
+ : 0U;
for (; i < m_NumMessages; ++i) {
file.write(m_Messages.at(i % m_Messages.size()).toString().toUtf8());
file.write("\r\n");
@@ -165,7 +168,7 @@ int LogBuffer::rowCount(const QModelIndex &parent) const
if (parent.isValid())
return 0;
else
- return std::min(m_NumMessages, m_Messages.size());
+ return static_cast(std::min(m_NumMessages, m_Messages.size()));
}
int LogBuffer::columnCount(const QModelIndex &) const
@@ -175,9 +178,10 @@ int LogBuffer::columnCount(const QModelIndex &) const
QVariant LogBuffer::data(const QModelIndex &index, int role) const
{
- unsigned offset = m_NumMessages < m_Messages.size()
- ? 0
- : m_NumMessages - m_Messages.size();
+ unsigned int offset
+ = m_NumMessages < m_Messages.size()
+ ? 0
+ : static_cast(m_NumMessages - m_Messages.size());
unsigned int msgIndex = (offset + index.row() + 1) % m_Messages.size();
switch (role) {
case Qt::DisplayRole: {
diff --git a/src/main.cpp b/src/main.cpp
index eb3a7248..6db5a50e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -161,9 +161,9 @@ static LONG WINAPI MyUnhandledExceptionFilter(struct _EXCEPTION_POINTERS *except
if (dbgDLL) {
FuncMiniDumpWriteDump funcDump = (FuncMiniDumpWriteDump)::GetProcAddress(dbgDLL, "MiniDumpWriteDump");
if (funcDump) {
- wchar_t exeNameBuffer[MAX_PATH];
- ::GetModuleFileNameW(nullptr, exeNameBuffer, MAX_PATH);
- QString dumpName = QString::fromWCharArray(exeNameBuffer) + ".dmp";
+ QString dataPath = qApp->property("dataPath").toString();
+ QString exeName = QFileInfo(qApp->applicationFilePath()).fileName();
+ QString dumpName = dataPath + "/" + exeName + ".dmp";
if (QMessageBox::question(nullptr, QObject::tr("Woops"),
QObject::tr("ModOrganizer has crashed! "
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 24391999..e174a17c 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -144,15 +144,10 @@ along with Mod Organizer. If not, see .
#include
#include
-#include
+#include
#include
-
-#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
#include
-#else
-#include
-#endif
#ifndef Q_MOC_RUN
#include
@@ -4198,7 +4193,12 @@ void MainWindow::on_bossButton_clicked()
HANDLE stdOutWrite = INVALID_HANDLE_VALUE;
HANDLE stdOutRead = INVALID_HANDLE_VALUE;
createStdoutPipe(&stdOutRead, &stdOutWrite);
- m_OrganizerCore.prepareVFS();
+ try {
+ m_OrganizerCore.prepareVFS();
+ } catch (const std::exception &e) {
+ QMessageBox::warning(qApp->activeWindow(), tr("Error"), e.what());
+ return;
+ }
HANDLE loot = startBinary(QFileInfo(qApp->applicationDirPath() + "/loot/lootcli.exe"),
parameters.join(" "),
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index 7d23cde5..f504994a 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -45,7 +45,10 @@
Categories
-
+
+
+ 0
+
3
@@ -92,25 +95,34 @@
-
-
-
- false
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 25
+
- Click blank area to deselect
+ Clear
+
+
+ true
-
-
-
-
-
-
- false
-
-
- false
+
+
+
+ 0
+ 0
+
-
diff --git a/src/modflagicondelegate.cpp b/src/modflagicondelegate.cpp
index d66c3ac5..5c4167ad 100644
--- a/src/modflagicondelegate.cpp
+++ b/src/modflagicondelegate.cpp
@@ -58,7 +58,7 @@ size_t ModFlagIconDelegate::getNumIcons(const QModelIndex &index) const
if (modIdx < ModInfo::getNumMods()) {
ModInfo::Ptr info = ModInfo::getByIndex(modIdx);
std::vector flags = info->getFlags();
- int count = flags.size();
+ size_t count = flags.size();
if (std::find_first_of(flags.begin(), flags.end(), m_ConflictFlags, m_ConflictFlags + 4) == flags.end()) {
++count;
}
@@ -71,11 +71,11 @@ size_t ModFlagIconDelegate::getNumIcons(const QModelIndex &index) const
QSize ModFlagIconDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &modelIndex) const
{
- int count = getNumIcons(modelIndex);
+ size_t count = getNumIcons(modelIndex);
unsigned int index = modelIndex.data(Qt::UserRole + 1).toInt();
QSize result;
if (index < ModInfo::getNumMods()) {
- result = QSize(count * 40, 20);
+ result = QSize(static_cast(count) * 40, 20);
} else {
result = QSize(1, 20);
}
diff --git a/src/modinfo.cpp b/src/modinfo.cpp
index 5593b0f0..3c97ca85 100644
--- a/src/modinfo.cpp
+++ b/src/modinfo.cpp
@@ -112,7 +112,7 @@ void ModInfo::createFromOverwrite()
unsigned int ModInfo::getNumMods()
{
QMutexLocker locker(&s_Mutex);
- return s_Collection.size();
+ return static_cast(s_Collection.size());
}
@@ -121,7 +121,7 @@ ModInfo::Ptr ModInfo::getByIndex(unsigned int index)
QMutexLocker locker(&s_Mutex);
if (index >= s_Collection.size()) {
- throw MyException(tr("invalid index %1").arg(index));
+ throw MyException(tr("invalid mod index %1").arg(index));
}
return s_Collection[index];
}
@@ -150,7 +150,7 @@ bool ModInfo::removeMod(unsigned int index)
QMutexLocker locker(&s_Mutex);
if (index >= s_Collection.size()) {
- throw MyException(tr("invalid index %1").arg(index));
+ throw MyException(tr("remove: invalid mod index %1").arg(index));
}
// update the indices first
ModInfo::Ptr modInfo = s_Collection[index];
diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp
index feaac2d4..e1a2183c 100644
--- a/src/modinfodialog.cpp
+++ b/src/modinfodialog.cpp
@@ -351,14 +351,18 @@ void ModInfoDialog::refreshLists()
void ModInfoDialog::addCategories(const CategoryFactory &factory, const std::set &enabledCategories, QTreeWidgetItem *root, int rootLevel)
{
- for (size_t i = 0; i < factory.numCategories(); ++i) {
+ for (int i = 0; i < static_cast(factory.numCategories()); ++i) {
if (factory.getParentID(i) != rootLevel) {
continue;
}
int categoryID = factory.getCategoryID(i);
- QTreeWidgetItem *newItem = new QTreeWidgetItem(QStringList(factory.getCategoryName(i)));
+ QTreeWidgetItem *newItem
+ = new QTreeWidgetItem(QStringList(factory.getCategoryName(i)));
newItem->setFlags(newItem->flags() | Qt::ItemIsUserCheckable);
- newItem->setCheckState(0, enabledCategories.find(categoryID) != enabledCategories.end() ? Qt::Checked : Qt::Unchecked);
+ newItem->setCheckState(0, enabledCategories.find(categoryID)
+ != enabledCategories.end()
+ ? Qt::Checked
+ : Qt::Unchecked);
newItem->setData(0, Qt::UserRole, categoryID);
if (factory.hasChildren(i)) {
addCategories(factory, enabledCategories, newItem, categoryID);
diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp
index c689501f..4a44c067 100644
--- a/src/nexusinterface.cpp
+++ b/src/nexusinterface.cpp
@@ -206,11 +206,12 @@ void NexusInterface::interpretNexusFileName(const QString &fileName, QString &mo
std::string candidate2 = result[2].str();
if (candidate2.length() != 0 && (candidate2.find_last_of("VvRr") == std::string::npos)) {
// well, that second match might be an id too...
- unsigned offset = strspn(candidate2.c_str(), "-_ ");
+ size_t offset = strspn(candidate2.c_str(), "-_ ");
if (offset < candidate2.length() && query) {
SelectionDialog selection(tr("Failed to guess mod id for \"%1\", please pick the correct one").arg(fileName));
QString r2Highlight(fileName);
- r2Highlight.insert(result.position(2) + result.length(2), "* ").insert(result.position(2) + offset, " *");
+ r2Highlight.insert(result.position(2) + result.length(2), "* ")
+ .insert(result.position(2) + static_cast(offset), " *");
QString r3Highlight(fileName);
r3Highlight.insert(result.position(3) + result.length(3), "* ").insert(result.position(3), " *");
@@ -264,14 +265,14 @@ QString NexusInterface::getModURL(int modID) const
return QString("%1/mods/%2").arg(getGameURL()).arg(modID);
}
-bool NexusInterface::isModURL(int modID, QString const &url) const
+bool NexusInterface::isModURL(int modID, const QString &url) const
{
- if (url == getModURL(modID)) {
+ if (QUrl(url) == QUrl(getModURL(modID))) {
return true;
}
//Try the alternate (old style) mod name
QString alt = QString("%1/%2").arg(getOldModsURL()).arg(modID);
- return alt == url;
+ return QUrl(alt) == QUrl(url);
}
int NexusInterface::requestDescription(int modID, QObject *receiver, QVariant userData,
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index f6196aa7..b1eaaef3 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -1345,8 +1345,6 @@ void OrganizerCore::refreshESPList()
// clear list
try {
m_PluginList.refresh(m_CurrentProfile->name(), *m_DirectoryStructure,
- m_CurrentProfile->getPluginsFileName(),
- m_CurrentProfile->getLoadOrderFileName(),
m_CurrentProfile->getLockedOrderFileName());
} catch (const std::exception &e) {
reportError(tr("Failed to refresh list of esps: %1").arg(e.what()));
@@ -1621,7 +1619,7 @@ void OrganizerCore::loginSuccessful(bool necessary)
if (necessary) {
MessageDialog::showMessage(tr("login successful"), qApp->activeWindow());
}
- foreach (QString url, m_PendingDownloads) {
+ for (QString url : m_PendingDownloads) {
downloadRequestedNXM(url);
}
m_PendingDownloads.clear();
@@ -1765,9 +1763,7 @@ void OrganizerCore::savePluginList()
m_PostRefreshTasks.append([&]() { this->savePluginList(); });
return;
}
- m_PluginList.saveTo(m_CurrentProfile->getPluginsFileName(),
- m_CurrentProfile->getLoadOrderFileName(),
- m_CurrentProfile->getLockedOrderFileName(),
+ m_PluginList.saveTo(m_CurrentProfile->getLockedOrderFileName(),
m_CurrentProfile->getDeleterFileName(),
m_Settings.hideUncheckedPlugins());
m_PluginList.saveLoadOrder(*m_DirectoryStructure);
@@ -1825,6 +1821,7 @@ std::vector OrganizerCore::fileMapping()
return result;
}
+
std::vector OrganizerCore::fileMapping(
const QString &dataPath, const QString &relPath, const DirectoryEntry *base,
const DirectoryEntry *directoryEntry, int createDestination)
@@ -1841,8 +1838,9 @@ std::vector OrganizerCore::fileMapping(
QString originPath
= QString::fromStdWString(base->getOriginByID(origin).getPath());
QString fileName = QString::fromStdWString(current->getName());
+// QString fileName = ToQString(current->getName());
QString source = originPath + relPath + fileName;
- QString target = dataPath + relPath + fileName;
+ QString target = dataPath + relPath + fileName;
if (source != target) {
result.push_back({source, target, false, false});
}
diff --git a/src/persistentcookiejar.cpp b/src/persistentcookiejar.cpp
index 6ca0de39..44537491 100644
--- a/src/persistentcookiejar.cpp
+++ b/src/persistentcookiejar.cpp
@@ -26,7 +26,7 @@ void PersistentCookieJar::save() {
QList cookies = allCookies();
data << static_cast(cookies.size());
- foreach (const QNetworkCookie &cookie, allCookies()) {
+ for (const QNetworkCookie &cookie : allCookies()) {
data << cookie.toRawForm();
}
diff --git a/src/plugincontainer.cpp b/src/plugincontainer.cpp
index a594f703..c4976d2c 100644
--- a/src/plugincontainer.cpp
+++ b/src/plugincontainer.cpp
@@ -200,7 +200,7 @@ void PluginContainer::unloadPlugins()
bf::for_each(m_Plugins, clearPlugins());
- foreach (const boost::signals2::connection &connection, m_DiagnosisConnections) {
+ for (const boost::signals2::connection &connection : m_DiagnosisConnections) {
connection.disconnect();
}
m_DiagnosisConnections.clear();
@@ -283,7 +283,7 @@ void PluginContainer::loadPlugins()
m_PluginLoaders.push_back(pluginLoader.release());
} else {
m_FailedPlugins.push_back(pluginName);
- qWarning("plugin \"%s\" failed to load", qPrintable(pluginName));
+ qWarning("plugin \"%s\" failed to load (may be outdated)", qPrintable(pluginName));
}
}
}
diff --git a/src/profile.cpp b/src/profile.cpp
index 8cc60cc0..d71b5a0f 100644
--- a/src/profile.cpp
+++ b/src/profile.cpp
@@ -163,7 +163,7 @@ void Profile::writeModlistNow()
return;
}
- for (int i = m_ModStatus.size() - 1; i >= 0; --i) {
+ for (int i = static_cast(m_ModStatus.size()) - 1; i >= 0; --i) {
// the priority order was inverted on load so it has to be inverted again
unsigned int index = m_ModIndexByPriority[i];
if (index != UINT_MAX) {
@@ -311,7 +311,7 @@ void Profile::refreshModStatus()
// invert priority order to match that of the pluginlist. Also
// give priorities to mods not referenced in the profile
for (size_t i = 0; i < m_ModStatus.size(); ++i) {
- ModInfo::Ptr modInfo = ModInfo::getByIndex(i);
+ ModInfo::Ptr modInfo = ModInfo::getByIndex(static_cast(i));
if (modInfo->alwaysEnabled()) {
m_ModStatus[i].m_Enabled = true;
}
@@ -340,7 +340,7 @@ void Profile::refreshModStatus()
if (topInsert < 0) {
int offset = topInsert * -1;
for (size_t i = 0; i < m_ModStatus.size(); ++i) {
- ModInfo::Ptr modInfo = ModInfo::getByIndex(i);
+ ModInfo::Ptr modInfo = ModInfo::getByIndex(static_cast(i));
if (modInfo->getFixedPriority() == INT_MAX) {
continue;
}
@@ -636,11 +636,12 @@ bool Profile::enableLocalSaves(bool enable)
m_Directory.mkdir("saves");
}
} else {
- QMessageBox::StandardButton res = QMessageBox::question(QApplication::activeModalWidget(), tr("Delete savegames?"),
- tr("Do you want to delete local savegames? (If you select \"No\", the save games "
- "will show up again if you re-enable local savegames)"),
- QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
- QMessageBox::Cancel);
+ QMessageBox::StandardButton res = QMessageBox::question(
+ QApplication::activeModalWidget(), tr("Delete savegames?"),
+ tr("Do you want to delete local savegames? (If you select \"No\", the "
+ "save games will show up again if you re-enable local savegames)"),
+ QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
+ QMessageBox::Cancel);
if (res == QMessageBox::Yes) {
shellDelete(QStringList(m_Directory.absoluteFilePath("saves")));
} else if (res == QMessageBox::No) {
diff --git a/src/profile.h b/src/profile.h
index ece23ef9..87dd91a5 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -174,7 +174,7 @@ public:
/**
* @return path to this profile
**/
- QString absolutePath() const;
+ virtual QString absolutePath() const override;
/**
* @return path to this profile's save games
diff --git a/src/profilesdialog.cpp b/src/profilesdialog.cpp
index 1a47cf74..40f01f0e 100644
--- a/src/profilesdialog.cpp
+++ b/src/profilesdialog.cpp
@@ -66,17 +66,15 @@ ProfilesDialog::ProfilesDialog(const QString &profileName, MOBase::IPluginGame c
profileIter.next();
QListWidgetItem *item = addItem(profileIter.filePath());
if (profileName == profileIter.fileName()) {
- m_ProfilesList->setCurrentItem(item);
+ ui->profilesList->setCurrentItem(item);
}
}
- QCheckBox *invalidationBox = findChild("invalidationBox");
-
BSAInvalidation *invalidation = game->feature();
if (invalidation == nullptr) {
- invalidationBox->setToolTip(tr("Archive invalidation isn't required for this game."));
- invalidationBox->setEnabled(false);
+ ui->invalidationBox->setToolTip(tr("Archive invalidation isn't required for this game."));
+ ui->invalidationBox->setEnabled(false);
}
}
@@ -89,13 +87,13 @@ void ProfilesDialog::showEvent(QShowEvent *event)
{
TutorableDialog::showEvent(event);
- if (m_ProfilesList->count() == 0) {
- QPoint pos = m_ProfilesList->mapToGlobal(QPoint(0, 0));
- pos.rx() += m_ProfilesList->width() / 2;
- pos.ry() += (m_ProfilesList->height() / 2) - 20;
+ if (ui->profilesList->count() == 0) {
+ QPoint pos = ui->profilesList->mapToGlobal(QPoint(0, 0));
+ pos.rx() += ui->profilesList->width() / 2;
+ pos.ry() += (ui->profilesList->height() / 2) - 20;
QWhatsThis::showText(pos,
QObject::tr("Before you can use ModOrganizer, you need to create at least one profile. "
- "ATTENTION: Run the game at least once before creating a profile!"), m_ProfilesList);
+ "ATTENTION: Run the game at least once before creating a profile!"), ui->profilesList);
}
}
@@ -108,7 +106,7 @@ void ProfilesDialog::on_closeButton_clicked()
QListWidgetItem *ProfilesDialog::addItem(const QString &name)
{
QDir profileDir(name);
- QListWidgetItem *newItem = new QListWidgetItem(profileDir.dirName(), m_ProfilesList);
+ QListWidgetItem *newItem = new QListWidgetItem(profileDir.dirName(), ui->profilesList);
try {
newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(new Profile(profileDir, m_Game))));
m_FailState = false;
@@ -121,10 +119,9 @@ QListWidgetItem *ProfilesDialog::addItem(const QString &name)
void ProfilesDialog::createProfile(const QString &name, bool useDefaultSettings)
{
try {
- QListWidget *profilesList = findChild("profilesList");
- QListWidgetItem *newItem = new QListWidgetItem(name, profilesList);
+ QListWidgetItem *newItem = new QListWidgetItem(name, ui->profilesList);
newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(new Profile(name, m_Game, useDefaultSettings))));
- profilesList->addItem(newItem);
+ ui->profilesList->addItem(newItem);
m_FailState = false;
} catch (const std::exception&) {
m_FailState = true;
@@ -135,10 +132,9 @@ void ProfilesDialog::createProfile(const QString &name, bool useDefaultSettings)
void ProfilesDialog::createProfile(const QString &name, const Profile &reference)
{
try {
- QListWidget *profilesList = findChild("profilesList");
- QListWidgetItem *newItem = new QListWidgetItem(name, profilesList);
+ QListWidgetItem *newItem = new QListWidgetItem(name, ui->profilesList);
newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(Profile::createPtrFrom(name, reference, m_Game))));
- profilesList->addItem(newItem);
+ ui->profilesList->addItem(newItem);
m_FailState = false;
} catch (const std::exception&) {
m_FailState = true;
@@ -164,20 +160,23 @@ void ProfilesDialog::on_addProfileButton_clicked()
void ProfilesDialog::on_copyProfileButton_clicked()
{
bool okClicked;
- QString name = QInputDialog::getText(this, tr("Name"), tr("Please enter a name for the new profile"), QLineEdit::Normal, QString(), &okClicked);
+ QString name = QInputDialog::getText(
+ this, tr("Name"), tr("Please enter a name for the new profile"),
+ QLineEdit::Normal, QString(), &okClicked);
fixDirectoryName(name);
if (okClicked) {
if (name.size() > 0) {
- QListWidget *profilesList = findChild("profilesList");
-
try {
- const Profile::Ptr currentProfile = profilesList->currentItem()->data(Qt::UserRole).value();
+ const Profile::Ptr currentProfile = ui->profilesList->currentItem()
+ ->data(Qt::UserRole)
+ .value();
createProfile(name, *currentProfile);
} catch (const std::exception &e) {
reportError(tr("failed to copy profile: %1").arg(e.what()));
}
} else {
- QMessageBox::warning(this, tr("Invalid name"), tr("Invalid profile name"));
+ QMessageBox::warning(this, tr("Invalid name"),
+ tr("Invalid profile name"));
}
}
}
@@ -188,13 +187,11 @@ void ProfilesDialog::on_removeProfileButton_clicked()
QMessageBox::Yes | QMessageBox::No);
if (confirmBox.exec() == QMessageBox::Yes) {
- QListWidget *profilesList = findChild("profilesList");
-
- Profile::Ptr currentProfile = profilesList->currentItem()->data(Qt::UserRole).value();
+ Profile::Ptr currentProfile = ui->profilesList->currentItem()->data(Qt::UserRole).value();
QString profilePath;
if (currentProfile.get() == nullptr) {
profilePath = Settings::instance().getProfileDirectory()
- + "/" + profilesList->currentItem()->text();
+ + "/" + ui->profilesList->currentItem()->text();
if (QMessageBox::question(this, tr("Profile broken"),
tr("This profile you're about to delete seems to be broken or the path is invalid. "
"I'm about to delete the following folder: \"%1\". Proceed?").arg(profilePath), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
@@ -205,7 +202,7 @@ void ProfilesDialog::on_removeProfileButton_clicked()
// we have to get rid of the it before deleting the directory
profilePath = currentProfile->absolutePath();
}
- QListWidgetItem* item = profilesList->takeItem(profilesList->currentRow());
+ QListWidgetItem* item = ui->profilesList->takeItem(ui->profilesList->currentRow());
if (item != nullptr) {
delete item;
}
@@ -270,53 +267,50 @@ void ProfilesDialog::on_invalidationBox_stateChanged(int state)
void ProfilesDialog::on_profilesList_currentItemChanged(QListWidgetItem *current, QListWidgetItem*)
{
- QCheckBox *invalidationBox = findChild("invalidationBox");
- QCheckBox *localSavesBox = findChild("localSavesBox");
- QPushButton *copyButton = findChild("copyProfileButton");
- QPushButton *removeButton = findChild("removeProfileButton");
- QPushButton *transferButton = findChild("transferButton");
- QPushButton *renameButton = findChild("renameButton");
-
if (current != nullptr) {
if (!current->data(Qt::UserRole).isValid()) return;
const Profile::Ptr currentProfile = current->data(Qt::UserRole).value();
try {
bool invalidationSupported = false;
- invalidationBox->blockSignals(true);
- invalidationBox->setChecked(currentProfile->invalidationActive(&invalidationSupported));
- invalidationBox->setEnabled(invalidationSupported);
- invalidationBox->blockSignals(false);
+ ui->invalidationBox->blockSignals(true);
+ ui->invalidationBox->setChecked(currentProfile->invalidationActive(&invalidationSupported));
+ ui->invalidationBox->setEnabled(invalidationSupported);
+ ui->invalidationBox->blockSignals(false);
bool localSaves = currentProfile->localSavesEnabled();
- transferButton->setEnabled(localSaves);
+ ui->transferButton->setEnabled(localSaves);
// prevent the stateChanged-event for the saves-box from triggering, otherwise it may think local saves
// were disabled and delete the files/rename the dir
- localSavesBox->blockSignals(true);
- localSavesBox->setChecked(localSaves);
- localSavesBox->blockSignals(false);
+ ui->localSavesBox->blockSignals(true);
+ ui->localSavesBox->setChecked(localSaves);
+ ui->localSavesBox->blockSignals(false);
+
+ ui->copyProfileButton->setEnabled(true);
+ ui->removeProfileButton->setEnabled(true);
+ ui->renameButton->setEnabled(true);
- copyButton->setEnabled(true);
- removeButton->setEnabled(true);
- renameButton->setEnabled(true);
+ ui->localIniFilesBox->blockSignals(true);
+ ui->localIniFilesBox->setChecked(currentProfile->localSettingsEnabled());
+ ui->localIniFilesBox->blockSignals(false);
} catch (const std::exception& E) {
reportError(tr("failed to determine if invalidation is active: %1").arg(E.what()));
- copyButton->setEnabled(false);
- removeButton->setEnabled(false);
- renameButton->setEnabled(false);
- invalidationBox->setChecked(false);
+ ui->copyProfileButton->setEnabled(false);
+ ui->removeProfileButton->setEnabled(false);
+ ui->renameButton->setEnabled(false);
+ ui->invalidationBox->setChecked(false);
}
} else {
- invalidationBox->setChecked(false);
- copyButton->setEnabled(false);
- removeButton->setEnabled(false);
- renameButton->setEnabled(false);
+ ui->invalidationBox->setChecked(false);
+ ui->copyProfileButton->setEnabled(false);
+ ui->removeProfileButton->setEnabled(false);
+ ui->renameButton->setEnabled(false);
}
}
void ProfilesDialog::on_localSavesBox_stateChanged(int state)
{
- Profile::Ptr currentProfile = m_ProfilesList->currentItem()->data(Qt::UserRole).value();
+ Profile::Ptr currentProfile = ui->profilesList->currentItem()->data(Qt::UserRole).value();
if (currentProfile->enableLocalSaves(state == Qt::Checked)) {
ui->transferButton->setEnabled(state == Qt::Checked);
diff --git a/src/profilesdialog.ui b/src/profilesdialog.ui
index 0c952877..fe03f466 100644
--- a/src/profilesdialog.ui
+++ b/src/profilesdialog.ui
@@ -6,8 +6,8 @@
0
0
- 471
- 318
+ 482
+ 332
diff --git a/src/shared/util.cpp b/src/shared/util.cpp
index 3692aae1..5491a9e6 100644
--- a/src/shared/util.cpp
+++ b/src/shared/util.cpp
@@ -81,12 +81,16 @@ std::wstring ToWString(const std::string &source, bool utf8)
if (!utf8) {
codepage = AreFileApisANSI() ? GetACP() : GetOEMCP();
}
- int sizeRequired = ::MultiByteToWideChar(codepage, 0, source.c_str(), source.length(), nullptr, 0);
+ int sizeRequired
+ = ::MultiByteToWideChar(codepage, 0, source.c_str(),
+ static_cast(source.length()), nullptr, 0);
if (sizeRequired == 0) {
throw windows_error("failed to convert string to wide character");
}
result.resize(sizeRequired, L'\0');
- ::MultiByteToWideChar(codepage, 0, source.c_str(), source.length(), &result[0], sizeRequired);
+ ::MultiByteToWideChar(codepage, 0, source.c_str(),
+ static_cast(source.length()), &result[0],
+ sizeRequired);
}
return result;
diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp
index db20a54f..bc818685 100644
--- a/src/usvfsconnector.cpp
+++ b/src/usvfsconnector.cpp
@@ -76,13 +76,16 @@ LogWorker::~LogWorker()
void LogWorker::process()
{
+ int noLogCycles = 0;
while (!m_QuitRequested) {
if (GetLogMessages(&m_Buffer[0], m_Buffer.size(), false)) {
m_LogFile.write(m_Buffer.c_str());
m_LogFile.write("\n");
m_LogFile.flush();
+ noLogCycles = 0;
} else {
- QThread::sleep(1);
+ QThread::msleep(std::min(40, noLogCycles) * 5);
+ ++noLogCycles;
}
}
emit finished();
@@ -148,11 +151,13 @@ void UsvfsConnector::updateMapping(const MappingType &mapping)
if (value % 10 == 0) {
QCoreApplication::processEvents();
}
+
if (map.isDirectory) {
VirtualLinkDirectoryStatic(map.source.toStdWString().c_str(),
map.destination.toStdWString().c_str(),
(map.createTarget ? LINKFLAG_CREATETARGET : 0)
- | LINKFLAG_RECURSIVE);
+ | LINKFLAG_RECURSIVE
+ );
} else {
VirtualLinkFile(map.source.toStdWString().c_str(),
map.destination.toStdWString().c_str(), 0);
diff --git a/src/version.rc b/src/version.rc
index 028912d7..872c65d7 100644
--- a/src/version.rc
+++ b/src/version.rc
@@ -1,7 +1,7 @@
#include "Winver.h"
-#define VER_FILEVERSION 2,0,4
-#define VER_FILEVERSION_STR "2,0,4alpha\0"
+#define VER_FILEVERSION 2,0,5
+#define VER_FILEVERSION_STR "2.0.5beta\0"
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
--
cgit v1.3.1
From afe0d749c438b086a7efa08e4d443be94f56d101 Mon Sep 17 00:00:00 2001
From: Tannin
Date: Sat, 7 May 2016 00:18:23 +0200
Subject: added option to use a mod as the target to create now files instead
of "overwrite"
---
src/CMakeLists.txt | 2 +
src/editexecutablesdialog.cpp | 57 +++++++++++++++++++++++------
src/editexecutablesdialog.h | 21 +++++++++--
src/editexecutablesdialog.ui | 45 +++++++++++++++++++++++
src/mainwindow.cpp | 55 +++++++++++++++++++---------
src/mainwindow.h | 1 +
src/organizercore.cpp | 85 ++++++++++++++++++++++++++++++++++++-------
src/organizercore.h | 20 ++++++----
src/usvfsconnector.cpp | 1 +
9 files changed, 235 insertions(+), 52 deletions(-)
(limited to 'src/usvfsconnector.cpp')
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a8b43c59..c6c038e8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -84,6 +84,7 @@ SET(organizer_SRCS
organizercore.cpp
instancemanager.cpp
usvfsconnector.cpp
+ eventfilter.cpp
shared/inject.cpp
shared/windows_error.cpp
@@ -170,6 +171,7 @@ SET(organizer_HDRS
iuserinterface.h
instancemanager.h
usvfsconnector.h
+ eventfilter.h
shared/inject.h
shared/windows_error.h
diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp
index 05a7603d..42d6f58b 100644
--- a/src/editexecutablesdialog.cpp
+++ b/src/editexecutablesdialog.cpp
@@ -29,15 +29,20 @@ along with Mod Organizer. If not, see .
using namespace MOBase;
using namespace MOShared;
-EditExecutablesDialog::EditExecutablesDialog(const ExecutablesList &executablesList, QWidget *parent)
+EditExecutablesDialog::EditExecutablesDialog(
+ const ExecutablesList &executablesList, const ModList &modList,
+ Profile *profile, QWidget *parent)
: TutorableDialog("EditExecutables", parent)
, ui(new Ui::EditExecutablesDialog)
, m_CurrentItem(nullptr)
, m_ExecutablesList(executablesList)
+ , m_Profile(profile)
{
ui->setupUi(this);
refreshExecutablesWidget();
+
+ ui->newFilesModBox->addItems(modList.allMods());
}
EditExecutablesDialog::~EditExecutablesDialog()
@@ -86,23 +91,30 @@ void EditExecutablesDialog::resetInput()
ui->appIDOverwriteEdit->clear();
ui->overwriteAppIDBox->setChecked(false);
ui->useAppIconCheckBox->setChecked(false);
+ ui->newFilesModCheckBox->setChecked(false);
m_CurrentItem = nullptr;
}
void EditExecutablesDialog::saveExecutable()
{
- m_ExecutablesList.updateExecutable(ui->titleEdit->text(),
- QDir::fromNativeSeparators(ui->binaryEdit->text()),
- ui->argumentsEdit->text(),
- QDir::fromNativeSeparators(ui->workingDirEdit->text()),
- ui->overwriteAppIDBox->isChecked() ?
- ui->appIDOverwriteEdit->text() : "",
- Executable::UseApplicationIcon | Executable::CustomExecutable,
- (ui->useAppIconCheckBox->isChecked() ?
- Executable::UseApplicationIcon : Executable::Flags())
- | Executable::CustomExecutable);
+ m_ExecutablesList.updateExecutable(
+ ui->titleEdit->text(),
+ QDir::fromNativeSeparators(ui->binaryEdit->text()),
+ ui->argumentsEdit->text(),
+ QDir::fromNativeSeparators(ui->workingDirEdit->text()),
+ ui->overwriteAppIDBox->isChecked() ?
+ ui->appIDOverwriteEdit->text() : "",
+ Executable::UseApplicationIcon | Executable::CustomExecutable,
+ (ui->useAppIconCheckBox->isChecked() ?
+ Executable::UseApplicationIcon : Executable::Flags())
+ | Executable::CustomExecutable);
+
+ if (ui->newFilesModCheckBox->isChecked()) {
+ m_Profile->storeSetting("custom_overwrites", ui->titleEdit->text(),
+ ui->newFilesModBox->currentText());
}
+}
void EditExecutablesDialog::delayedRefresh()
@@ -212,8 +224,13 @@ bool EditExecutablesDialog::executableChanged()
{
if (m_CurrentItem != nullptr) {
Executable const &selectedExecutable(m_ExecutablesList.find(m_CurrentItem->text()));
+
+ QString storedCustomOverwrite = m_Profile->setting("custom_overwrites", selectedExecutable.m_Title).toString();
+
return selectedExecutable.m_Arguments != ui->argumentsEdit->text()
|| selectedExecutable.m_SteamAppID != ui->appIDOverwriteEdit->text()
+ || !storedCustomOverwrite.isEmpty() != ui->newFilesModCheckBox->isChecked()
+ || !storedCustomOverwrite.isEmpty() && (storedCustomOverwrite != ui->newFilesModBox->currentText())
|| selectedExecutable.m_WorkingDirectory != QDir::fromNativeSeparators(ui->workingDirEdit->text())
|| selectedExecutable.m_BinaryInfo.absoluteFilePath() != QDir::fromNativeSeparators(ui->binaryEdit->text())
|| selectedExecutable.usesOwnIcon() != ui->useAppIconCheckBox->isChecked();
@@ -296,5 +313,23 @@ void EditExecutablesDialog::on_executablesListBox_clicked(const QModelIndex &cur
ui->appIDOverwriteEdit->clear();
}
ui->useAppIconCheckBox->setChecked(selectedExecutable.usesOwnIcon());
+
+ int index = -1;
+
+ QString customOverwrite = m_Profile->setting("custom_overwrites", selectedExecutable.m_Title).toString();
+ if (!customOverwrite.isEmpty()) {
+ index = ui->newFilesModBox->findText(customOverwrite);
+ qDebug("find %s -> %d", qPrintable(customOverwrite), index);
+ }
+
+ ui->newFilesModCheckBox->setChecked(index != -1);
+ if (index != -1) {
+ ui->newFilesModBox->setCurrentIndex(index);
+ }
}
}
+
+void EditExecutablesDialog::on_newFilesModCheckBox_toggled(bool checked)
+{
+ ui->newFilesModBox->setEnabled(checked);
+}
diff --git a/src/editexecutablesdialog.h b/src/editexecutablesdialog.h
index 4f6c5315..0f3dbaff 100644
--- a/src/editexecutablesdialog.h
+++ b/src/editexecutablesdialog.h
@@ -24,11 +24,16 @@ along with Mod Organizer. If not, see .
#include
#include
#include "executableslist.h"
+#include "profile.h"
namespace Ui {
class EditExecutablesDialog;
}
+
+class ModList;
+
+
/**
* @brief Dialog to manage the list of executables
**/
@@ -44,7 +49,10 @@ public:
* @param executablesList current list of executables
* @param parent parent widget
**/
- explicit EditExecutablesDialog(const ExecutablesList &executablesList, QWidget *parent = 0);
+ explicit EditExecutablesDialog(const ExecutablesList &executablesList,
+ const ModList &modList,
+ Profile *profile,
+ QWidget *parent = 0);
~EditExecutablesDialog();
@@ -56,6 +64,10 @@ public:
ExecutablesList getExecutablesList() const;
void saveExecutable();
+
+private slots:
+ void on_newFilesModCheckBox_toggled(bool checked);
+
private slots:
void on_binaryEdit_textChanged(const QString &arg1);
@@ -89,12 +101,13 @@ private:
bool executableChanged();
private:
- Ui::EditExecutablesDialog *ui;
+ Ui::EditExecutablesDialog *ui;
- QListWidgetItem *m_CurrentItem;
+ QListWidgetItem *m_CurrentItem;
- ExecutablesList m_ExecutablesList;
+ ExecutablesList m_ExecutablesList;
+ Profile *m_Profile;
};
#endif // EDITEXECUTABLESDIALOG_H
diff --git a/src/editexecutablesdialog.ui b/src/editexecutablesdialog.ui
index 2640bb15..b3543c95 100644
--- a/src/editexecutablesdialog.ui
+++ b/src/editexecutablesdialog.ui
@@ -164,6 +164,27 @@ Right now the only case I know of where this needs to be overwritten is for the
+ -
+
+
-
+
+
+ If this is enabled, new files are created in the specified mod instead of the "Overwrite" mod.
+
+
+ Create Files in Mod instead of Overwrite (*)
+
+
+
+ -
+
+
+ false
+
+
+
+
+
-
@@ -171,6 +192,13 @@ Right now the only case I know of where this needs to be overwritten is for the
+ -
+
+
+ (*) This setting is profile-specific
+
+
+
-
-
@@ -235,6 +263,23 @@ Right now the only case I know of where this needs to be overwritten is for the
+
+ executablesListBox
+ titleEdit
+ binaryEdit
+ browseButton
+ workingDirEdit
+ browseDirButton
+ argumentsEdit
+ overwriteAppIDBox
+ appIDOverwriteEdit
+ newFilesModCheckBox
+ newFilesModBox
+ useAppIconCheckBox
+ addButton
+ removeButton
+ closeButton
+
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index e174a17c..7944acfc 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1004,13 +1004,8 @@ void MainWindow::startExeAction()
{
QAction *action = qobject_cast(sender());
if (action != nullptr) {
- const Executable &selectedExecutable(m_OrganizerCore.executablesList()->find(action->text()));
m_OrganizerCore.spawnBinary(
- selectedExecutable.m_BinaryInfo,
- selectedExecutable.m_Arguments,
- selectedExecutable.m_WorkingDirectory.length() != 0 ? selectedExecutable.m_WorkingDirectory
- : selectedExecutable.m_BinaryInfo.absolutePath(),
- selectedExecutable.m_SteamAppID);
+ m_OrganizerCore.executablesList()->find(action->text()));
} else {
qCritical("not an action?");
}
@@ -1516,14 +1511,7 @@ void MainWindow::installMod(QString fileName)
void MainWindow::on_startButton_clicked()
{
- const Executable &selectedExecutable(getSelectedExecutable());
-
- m_OrganizerCore.spawnBinary(
- selectedExecutable.m_BinaryInfo,
- selectedExecutable.m_Arguments,
- selectedExecutable.m_WorkingDirectory.length() != 0 ? selectedExecutable.m_WorkingDirectory
- : selectedExecutable.m_BinaryInfo.absolutePath(),
- selectedExecutable.m_SteamAppID);
+ m_OrganizerCore.spawnBinary(getSelectedExecutable());
}
@@ -1613,7 +1601,9 @@ bool MainWindow::modifyExecutablesDialog()
{
bool result = false;
try {
- EditExecutablesDialog dialog(*m_OrganizerCore.executablesList());
+ EditExecutablesDialog dialog(*m_OrganizerCore.executablesList(),
+ *m_OrganizerCore.modList(),
+ m_OrganizerCore.currentProfile());
if (dialog.exec() == QDialog::Accepted) {
m_OrganizerCore.setExecutablesList(dialog.getExecutablesList());
result = true;
@@ -2423,7 +2413,32 @@ void MainWindow::information_clicked()
}
}
+void MainWindow::createEmptyMod_clicked()
+{
+ GuessedValue name;
+ name.setFilter(&fixDirectoryName);
+
+ while (name->isEmpty()) {
+ bool ok;
+ name.update(QInputDialog::getText(this, tr("Create Mod..."),
+ tr("This will create an empty mod.\n"
+ "Please enter a name:"), QLineEdit::Normal, "", &ok),
+ GUESS_USER);
+ if (!ok) {
+ return;
+ }
+ }
+
+ if (m_OrganizerCore.getMod(name) != nullptr) {
+ reportError(tr("A mod with this name already exists"));
+ return;
+ }
+ IModInterface *newMod = m_OrganizerCore.createMod(name);
+ if (newMod == nullptr) {
+ return;
+ }
+}
void MainWindow::createModFromOverwrite()
{
@@ -2862,6 +2877,8 @@ QMenu *MainWindow::modListContextMenu()
QMenu *menu = new QMenu(this);
menu->addAction(tr("Install Mod..."), this, SLOT(installMod_clicked()));
+ menu->addAction(tr("Create empty mod"), this, SLOT(createEmptyMod_clicked()));
+
menu->addAction(tr("Enable all visible"), this, SLOT(enableVisibleMods()));
menu->addAction(tr("Disable all visible"), this, SLOT(disableVisibleMods()));
@@ -3529,10 +3546,14 @@ void MainWindow::openDataFile()
QString arguments;
switch (getBinaryExecuteInfo(targetInfo, binaryInfo, arguments)) {
case 1: {
- m_OrganizerCore.spawnBinaryDirect(binaryInfo, arguments, m_OrganizerCore.currentProfile()->name(), targetInfo.absolutePath(), "");
+ m_OrganizerCore.spawnBinaryDirect(
+ binaryInfo, arguments, m_OrganizerCore.currentProfile()->name(),
+ targetInfo.absolutePath(), "", "");
} break;
case 2: {
- ::ShellExecuteW(nullptr, L"open", ToWString(targetInfo.absoluteFilePath()).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+ ::ShellExecuteW(nullptr, L"open",
+ ToWString(targetInfo.absoluteFilePath()).c_str(),
+ nullptr, nullptr, SW_SHOWNORMAL);
} break;
default: {
// nop
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 4e2e8e21..d2f3fb47 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -369,6 +369,7 @@ private slots:
// modlist context menu
void installMod_clicked();
+ void createEmptyMod_clicked();
void restoreBackup_clicked();
void renameMod_clicked();
void removeMod_clicked();
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index b1eaaef3..8f308c88 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -596,7 +596,7 @@ void OrganizerCore::createDefaultProfile()
void OrganizerCore::prepareVFS()
{
- m_USVFS.updateMapping(fileMapping());
+ m_USVFS.updateMapping(fileMapping(m_CurrentProfile->name(), QString()));
}
void OrganizerCore::setCurrentProfile(const QString &profileName)
@@ -969,10 +969,21 @@ QStringList OrganizerCore::modsSortedByProfilePriority() const
return res;
}
+void OrganizerCore::spawnBinary(const Executable &exe)
+{
+ spawnBinary(
+ exe.m_BinaryInfo, exe.m_Arguments,
+ exe.m_WorkingDirectory.length() != 0 ? exe.m_WorkingDirectory
+ : exe.m_BinaryInfo.absolutePath(),
+ exe.m_SteamAppID,
+ m_CurrentProfile->setting("custom_overwrites", exe.m_Title).toString());
+}
+
void OrganizerCore::spawnBinary(const QFileInfo &binary,
const QString &arguments,
const QDir ¤tDirectory,
- const QString &steamAppID)
+ const QString &steamAppID,
+ const QString &customOverwrite)
{
LockedDialog *dialog = new LockedDialog(qApp->activeWindow());
dialog->show();
@@ -983,7 +994,7 @@ void OrganizerCore::spawnBinary(const QFileInfo &binary,
HANDLE processHandle
= spawnBinaryDirect(binary, arguments, m_CurrentProfile->name(),
- currentDirectory, steamAppID);
+ currentDirectory, steamAppID, customOverwrite);
if (processHandle != INVALID_HANDLE_VALUE) {
if (m_UserInterface != nullptr) {
m_UserInterface->setWindowEnabled(false);
@@ -1082,7 +1093,8 @@ HANDLE OrganizerCore::spawnBinaryDirect(const QFileInfo &binary,
const QString &arguments,
const QString &profileName,
const QDir ¤tDirectory,
- const QString &steamAppID)
+ const QString &steamAppID,
+ const QString &customOverwrite)
{
prepareStart();
@@ -1135,11 +1147,16 @@ HANDLE OrganizerCore::spawnBinaryDirect(const QFileInfo &binary,
}
if (m_AboutToRun(binary.absoluteFilePath())) {
- m_USVFS.updateMapping(fileMapping());
+ try {
+ m_USVFS.updateMapping(fileMapping(profileName, customOverwrite));
+ } catch (const std::exception &e) {
+ QMessageBox::warning(qApp->activeWindow(), tr("Error"), e.what());
+ return INVALID_HANDLE_VALUE;
+ }
+
QString modsPath = settings().getModDirectory();
QString binPath = binary.absoluteFilePath();
-
if (binPath.startsWith(modsPath, Qt::CaseInsensitive)) {
// binary was installed as a MO mod. Need to start it through a (hooked)
// proxy to ensure pathes are correct
@@ -1185,6 +1202,7 @@ HANDLE OrganizerCore::startApplication(const QString &executable,
}
}
QString steamAppID;
+ QString customOverwrite;
if (executable.contains('\\') || executable.contains('/')) {
// file path
@@ -1200,6 +1218,9 @@ HANDLE OrganizerCore::startApplication(const QString &executable,
try {
const Executable &exe = m_ExecutablesList.findByBinary(binary);
steamAppID = exe.m_SteamAppID;
+ customOverwrite
+ = m_CurrentProfile->setting("custom_overwrites", exe.m_Title)
+ .toString();
} catch (const std::runtime_error &) {
// nop
}
@@ -1208,6 +1229,9 @@ HANDLE OrganizerCore::startApplication(const QString &executable,
try {
const Executable &exe = m_ExecutablesList.find(executable);
steamAppID = exe.m_SteamAppID;
+ customOverwrite
+ = m_CurrentProfile->setting("custom_overwrites", exe.m_Title)
+ .toString();
if (arguments == "") {
arguments = exe.m_Arguments;
}
@@ -1223,7 +1247,7 @@ HANDLE OrganizerCore::startApplication(const QString &executable,
}
return spawnBinaryDirect(binary, arguments, profileName, currentDirectory,
- steamAppID);
+ steamAppID, customOverwrite);
}
bool OrganizerCore::waitForApplication(HANDLE handle, LPDWORD exitCode)
@@ -1781,7 +1805,8 @@ void OrganizerCore::prepareStart()
storeSettings();
}
-std::vector OrganizerCore::fileMapping()
+std::vector OrganizerCore::fileMapping(const QString &profileName,
+ const QString &customOverwrite)
{
// need to wait until directory structure
while (m_DirectoryUpdate) {
@@ -1789,12 +1814,39 @@ std::vector OrganizerCore::fileMapping()
QCoreApplication::processEvents();
}
- int overwriteId = m_DirectoryStructure->getOriginByName(L"Overwrite").getID();
-
IPluginGame *game = qApp->property("managed_game").value();
- MappingType result = fileMapping(
- QDir::toNativeSeparators(game->dataDirectory().absolutePath()), "\\",
- directoryStructure(), directoryStructure(), overwriteId);
+ Profile profile(QDir(m_Settings.getProfileDirectory() + "/" + profileName),
+ game);
+
+ MappingType result;
+
+ QString dataPath
+ = QDir::toNativeSeparators(game->dataDirectory().absolutePath());
+
+ bool overwriteActive = false;
+
+ for (auto mod : profile.getActiveMods()) {
+ if (std::get<0>(mod).compare("overwrite", Qt::CaseInsensitive) == 0) {
+ continue;
+ }
+
+ unsigned int modIndex = ModInfo::getIndex(std::get<0>(mod));
+ ModInfo::Ptr modPtr = ModInfo::getByIndex(modIndex);
+
+ bool createTarget = customOverwrite == std::get<0>(mod);
+
+ overwriteActive |= createTarget;
+
+ if (modPtr->isRegular()) {
+ result.insert(result.end(), {QDir::toNativeSeparators(std::get<1>(mod)),
+ dataPath, true, createTarget});
+ }
+ }
+
+ if (!overwriteActive && !customOverwrite.isEmpty()) {
+ throw MyException(tr("The designated write target \"%1\" is not enabled.")
+ .arg(customOverwrite));
+ }
if (m_CurrentProfile->localSavesEnabled()) {
LocalSavegames *localSaves = game->feature();
@@ -1808,6 +1860,13 @@ std::vector OrganizerCore::fileMapping()
}
}
+ result.insert(result.end(), {
+ QDir::toNativeSeparators(m_Settings.getOverwriteDirectory()),
+ QDir::toNativeSeparators(game->dataDirectory().absolutePath()),
+ true,
+ customOverwrite.isEmpty()
+ });
+
for (MOBase::IPluginFileMapper *mapper :
m_PluginContainer->plugins()) {
IPlugin *plugin = dynamic_cast(mapper);
diff --git a/src/organizercore.h b/src/organizercore.h
index ea37d72c..cd7af1b8 100644
--- a/src/organizercore.h
+++ b/src/organizercore.h
@@ -129,8 +129,8 @@ public:
void doAfterLogin(const std::function &function) { m_PostLoginTasks.append(function); }
- void spawnBinary(const QFileInfo &binary, const QString &arguments = "", const QDir ¤tDirectory = QDir(), const QString &steamAppID = "");
- HANDLE spawnBinaryDirect(const QFileInfo &binary, const QString &arguments, const QString &profileName, const QDir ¤tDirectory, const QString &steamAppID);
+ void spawnBinary(const Executable &exe);
+ HANDLE spawnBinaryDirect(const QFileInfo &binary, const QString &arguments, const QString &profileName, const QDir ¤tDirectory, const QString &steamAppID, const QString &customOverwrite);
void loginSuccessfulUpdate(bool necessary);
void loginFailedUpdate(const QString &message);
@@ -173,11 +173,6 @@ public:
void refreshModList(bool saveChanges = true);
QStringList modsSortedByProfilePriority() const;
- /**
- * @brief return a descriptor of the mappings real file->virtual file
- */
- std::vector fileMapping();
-
public: // IPluginDiagnose interface
virtual std::vector activeProblems() const;
@@ -231,12 +226,23 @@ private:
bool testForSteam();
+ /**
+ * @brief return a descriptor of the mappings real file->virtual file
+ */
+ std::vector fileMapping(const QString &profile,
+ const QString &customOverwrite);
+
std::vector
fileMapping(const QString &dataPath, const QString &relPath,
const MOShared::DirectoryEntry *base,
const MOShared::DirectoryEntry *directoryEntry,
int createDestination);
+ void spawnBinary(const QFileInfo &binary, const QString &arguments = "",
+ const QDir ¤tDirectory = QDir(),
+ const QString &steamAppID = "",
+ const QString &customOverwrite = "");
+
private slots:
void directory_refreshed();
diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp
index bc818685..2af28522 100644
--- a/src/usvfsconnector.cpp
+++ b/src/usvfsconnector.cpp
@@ -136,6 +136,7 @@ UsvfsConnector::~UsvfsConnector()
m_WorkerThread.wait();
}
+
void UsvfsConnector::updateMapping(const MappingType &mapping)
{
QProgressDialog progress;
--
cgit v1.3.1
From 32480f7a818facb096c423fbed625bb311b0c497 Mon Sep 17 00:00:00 2001
From: Tannin
Date: Sat, 7 May 2016 00:23:13 +0200
Subject: minor fixes
---
src/editexecutablesdialog.cpp | 1 +
src/mainwindow.cpp | 13 ++++++------
src/mainwindow.h | 3 +++
src/usvfsconnector.cpp | 48 +++++++++++++++++--------------------------
4 files changed, 30 insertions(+), 35 deletions(-)
(limited to 'src/usvfsconnector.cpp')
diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp
index 42d6f58b..f76323e8 100644
--- a/src/editexecutablesdialog.cpp
+++ b/src/editexecutablesdialog.cpp
@@ -21,6 +21,7 @@ along with Mod Organizer. If not, see .
#include "ui_editexecutablesdialog.h"
#include "filedialogmemory.h"
#include "stackdata.h"
+#include "modlist.h"
#include
#include
#include
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 7944acfc..f21698b0 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -2978,11 +2978,7 @@ void MainWindow::on_modList_customContextMenuRequested(const QPoint &pos)
if (info->getNexusID() > 0) {
menu->addAction(tr("Visit on Nexus"), this, SLOT(visitOnNexus_clicked()));
- }
-
- //If a URL is specified which is not the game's URL, pop up 'visit web page'
- if (info->getURL() != "" &&
- !NexusInterface::instance()->isModURL(info->getNexusID(), info->getURL())) {
+ } else if ((info->getURL() != "")) {
menu->addAction(tr("Visit web page"), this, SLOT(visitWebPage_clicked()));
}
@@ -3025,7 +3021,7 @@ void MainWindow::on_categoriesList_itemSelectionChanged()
m_ModListSortProxy->setCategoryFilter(categories);
m_ModListSortProxy->setContentFilter(content);
- ui->clickBlankLabel->setEnabled(categories.size() > 0);
+ ui->clickBlankButton->setEnabled(categories.size() > 0);
if (indices.count() == 0) {
ui->currentCategoryLabel->setText(QString("(%1)").arg(tr("")));
} else if (indices.count() > 1) {
@@ -4579,3 +4575,8 @@ void MainWindow::dropEvent(QDropEvent *event)
event->accept();
}
+
+void MainWindow::on_clickBlankButton_clicked()
+{
+ deselectFilters();
+}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index d2f3fb47..866f1ad6 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -183,6 +183,9 @@ protected:
virtual void dragEnterEvent(QDragEnterEvent *event);
virtual void dropEvent(QDropEvent *event);
+private slots:
+ void on_clickBlankButton_clicked();
+
private:
void cleanup();
diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp
index 2af28522..d8818a9a 100644
--- a/src/usvfsconnector.cpp
+++ b/src/usvfsconnector.cpp
@@ -20,6 +20,8 @@ along with Mod Organizer. If not, see .
#include "usvfsconnector.h"
#include "settings.h"
#include
+#include
+#include
#include
#include
#include
@@ -27,35 +29,23 @@ along with Mod Organizer. If not, see .
static const char SHMID[] = "mod_organizer_instance";
-/*
-extern "C" DLLEXPORT BOOL WINAPI VirtualLinkFile(LPCWSTR source, LPCWSTR
-destination, BOOL failIfExists);
-extern "C" DLLEXPORT BOOL WINAPI VirtualLinkDirectoryStatic(LPCWSTR source,
-LPCWSTR destination, unsigned int flags);
-extern "C" DLLEXPORT BOOL WINAPI ConnectVFS(const usvfs::Parameters
-*parameters);
-extern "C" DLLEXPORT void WINAPI DisconnectVFS();
-extern "C" DLLEXPORT void WINAPI GetCurrentVFSName(char *buffer, size_t size);
-extern "C" DLLEXPORT BOOL WINAPI CreateProcessHooked(LPCWSTR lpApplicationName
- , LPWSTR lpCommandLine
- , LPSECURITY_ATTRIBUTES
-lpProcessAttributes
- , LPSECURITY_ATTRIBUTES
-lpThreadAttributes
- , BOOL bInheritHandles
- , DWORD dwCreationFlags
- , LPVOID lpEnvironment
- , LPCWSTR
-lpCurrentDirectory
- , LPSTARTUPINFOW
-lpStartupInfo
- , LPPROCESS_INFORMATION
-lpProcessInformation
- );
-extern "C" DLLEXPORT void __cdecl InitLogging(bool toLocal = false);
-extern "C" DLLEXPORT void __cdecl InitHooks(LPVOID userData, size_t
-userDataSize);
-*/
+
+std::string to_hex(void *bufferIn, size_t bufferSize)
+{
+ unsigned char *buffer = static_cast(bufferIn);
+ std::ostringstream temp;
+ temp << std::hex;
+ for (size_t i = 0; i < bufferSize; ++i) {
+ temp << std::setfill('0') << std::setw(2) << (unsigned int)buffer[i];
+ if ((i % 16) == 15) {
+ temp << "\n";
+ } else {
+ temp << " ";
+ }
+ }
+ return temp.str();
+}
+
LogWorker::LogWorker()
: m_Buffer(1024, '\0')
--
cgit v1.3.1
From 3d642563cbdb33784165e4f7d29dbaa66b455492 Mon Sep 17 00:00:00 2001
From: Tannin
Date: Sun, 19 Jun 2016 15:59:50 +0200
Subject: usvfs log level can now be changed without a restart
---
src/mainwindow.cpp | 2 ++
src/organizercore.cpp | 5 +++++
src/organizercore.h | 2 ++
src/settingsdialog.ui | 5 +++++
src/usvfsconnector.cpp | 16 ++++++++++++++--
src/usvfsconnector.h | 2 +-
6 files changed, 29 insertions(+), 3 deletions(-)
(limited to 'src/usvfsconnector.cpp')
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 0668f012..c90448c2 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -3222,6 +3222,8 @@ void MainWindow::on_actionSettings_triggered()
NexusInterface::instance()->setNMMVersion(m_OrganizerCore.settings().getNMMVersion());
updateDownloadListDelegate();
+
+ m_OrganizerCore.setLogLevel(m_OrganizerCore.settings().logLevel());
}
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index 1bec27bc..6ceefb4b 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -22,6 +22,7 @@
#include
#include
#include
+#include
#include "appconfig.h"
#include
#include
@@ -599,6 +600,10 @@ void OrganizerCore::prepareVFS()
m_USVFS.updateMapping(fileMapping(m_CurrentProfile->name(), QString()));
}
+void OrganizerCore::setLogLevel(int logLevel) {
+ m_USVFS.setLogLevel(logLevel);
+}
+
void OrganizerCore::setCurrentProfile(const QString &profileName)
{
if ((m_CurrentProfile != nullptr)
diff --git a/src/organizercore.h b/src/organizercore.h
index cd7af1b8..ecb02d83 100644
--- a/src/organizercore.h
+++ b/src/organizercore.h
@@ -141,6 +141,8 @@ public:
void prepareVFS();
+ void setLogLevel(int logLevel);
+
public:
MOBase::IModRepositoryBridge *createNexusBridge() const;
QString profileName() const;
diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui
index 6ae415d1..082be8a1 100644
--- a/src/settingsdialog.ui
+++ b/src/settingsdialog.ui
@@ -98,6 +98,11 @@ p, li { white-space: pre-wrap; }
Info
+ -
+
+ Warning
+
+
-
Error
diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp
index d8818a9a..0fe3567c 100644
--- a/src/usvfsconnector.cpp
+++ b/src/usvfsconnector.cpp
@@ -22,6 +22,7 @@ along with Mod Organizer. If not, see .
#include
#include
#include
+#include
#include
#include
#include
@@ -103,10 +104,11 @@ LogLevel logLevel(int level)
UsvfsConnector::UsvfsConnector()
{
USVFSParameters params;
- USVFSInitParameters(¶ms, SHMID, false,
- logLevel(Settings::instance().logLevel()));
+ LogLevel level = logLevel(Settings::instance().logLevel());
+ USVFSInitParameters(¶ms, SHMID, false, level);
InitLogging(false);
ConnectVFS(¶ms);
+ SetLogLevel(level);
BlacklistExecutable(L"TSVNCache.exe");
@@ -162,3 +164,13 @@ void UsvfsConnector::updateMapping(const MappingType &mapping)
qDebug(buffer.get());
*/
}
+
+void UsvfsConnector::setLogLevel(int logLevel) {
+ switch (logLevel) {
+ case LogLevel::Debug: SetLogLevel(LogLevel::Debug); break;
+ case LogLevel::Info: SetLogLevel(LogLevel::Info); break;
+ case LogLevel::Warning: SetLogLevel(LogLevel::Warning); break;
+ case LogLevel::Error: SetLogLevel(LogLevel::Error); break;
+ default: SetLogLevel(LogLevel::Debug); break;
+ }
+}
diff --git a/src/usvfsconnector.h b/src/usvfsconnector.h
index 78bb7a49..8f723a01 100644
--- a/src/usvfsconnector.h
+++ b/src/usvfsconnector.h
@@ -22,7 +22,6 @@ along with Mod Organizer. If not, see .
#define USVFSCONNECTOR_H
-#include
#include
#include
#include
@@ -68,6 +67,7 @@ public:
~UsvfsConnector();
void updateMapping(const MappingType &mapping);
+ void setLogLevel(int logLevel);
private:
--
cgit v1.3.1
From a00cda607cd9115d06c1185f78bcdded28c8b09d Mon Sep 17 00:00:00 2001
From: Tannin
Date: Thu, 30 Jun 2016 18:56:41 +0200
Subject: updated to changed usvfs api
---
src/installationmanager.cpp | 14 +-
src/organizer_en.ts | 599 +++++++++++++++++++++++---------------------
src/usvfsconnector.cpp | 2 +-
3 files changed, 315 insertions(+), 300 deletions(-)
(limited to 'src/usvfsconnector.cpp')
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp
index 1c9d8a42..9be4cdd9 100644
--- a/src/installationmanager.cpp
+++ b/src/installationmanager.cpp
@@ -77,16 +77,14 @@ static T resolveFunction(QLibrary &lib, const char *name)
return temp;
}
-
InstallationManager::InstallationManager()
- : m_ParentWidget(nullptr)
- , m_SupportedExtensions({ "zip", "rar", "7z", "fomod", "001" })
-{
- QLibrary archiveLib(QCoreApplication::applicationDirPath()
- + "\\dlls\\archive.dll");
+ : m_ParentWidget(nullptr),
+ m_SupportedExtensions({"zip", "rar", "7z", "fomod", "001"}) {
+ QLibrary archiveLib(QCoreApplication::applicationDirPath() +
+ "\\dlls\\archive.dll");
if (!archiveLib.load()) {
- throw MyException(
- tr("archive.dll not loaded: \"%1\"").arg(archiveLib.errorString()));
+ throw MyException(QObject::tr("archive.dll not loaded: \"%1\"")
+ .arg(archiveLib.errorString()));
}
CreateArchiveType CreateArchiveFunc
diff --git a/src/organizer_en.ts b/src/organizer_en.ts
index 686e15db..c3e523c4 100644
--- a/src/organizer_en.ts
+++ b/src/organizer_en.ts
@@ -1120,98 +1120,98 @@ p, li { white-space: pre-wrap; }
InstallationManager
-
+
Password required
-
+
Password
-
-
+
+
Extracting files
-
+
failed to create backup
-
+
Mod Name
-
+
Name
-
+
Invalid name
-
+
The name you entered is invalid, please enter a different one.
-
+
File format "%1" not supported
-
+
None of the available installer plugins were able to handle that archive
-
+
no error
-
+
7z.dll not found
-
+
7z.dll isn't valid
-
+
archive not found
-
+
failed to open archive
-
+
unsupported archive type
-
+
internal library error
-
+
archive invalid
-
+
unknown archive error
@@ -1461,8 +1461,8 @@ p, li { white-space: pre-wrap; }
-
-
+
+
Refresh
@@ -1641,7 +1641,7 @@ p, li { white-space: pre-wrap; }
-
+
Update
@@ -1652,7 +1652,7 @@ p, li { white-space: pre-wrap; }
-
+
No Problems
@@ -1682,7 +1682,7 @@ Right now this has very limited functionality
-
+
Endorse Mod Organizer
@@ -1707,579 +1707,579 @@ Right now this has very limited functionality
-
+
Toolbar
-
+
Desktop
-
+
Start Menu
-
+
Problems
-
+
There are potential problems with your setup
-
+
Everything seems to be in order
-
+
Help on UI
-
+
Documentation Wiki
-
+
Report Issue
-
+
Tutorials
-
+
About
-
+
About Qt
-
+
Name
-
+
Please enter a name for the new profile
-
+
failed to create profile: %1
-
+
Show tutorial?
-
+
You are starting Mod Organizer for the first time. Do you want to show a tutorial of its basic features? If you choose no you can always start the tutorial from the "Help"-menu.
-
+
Downloads in progress
-
+
There are still downloads in progress, do you really want to quit?
-
+
Plugin "%1" failed: %2
-
+
Plugin "%1" failed
-
+
Browse Mod Page
-
+
Also in: <br>
-
+
No conflict
-
+
<Edit...>
-
+
Activating Network Proxy
-
+
Choose Mod
-
+
Mod Archive
-
+
Start Tutorial?
-
+
You're about to start a tutorial. For technical reasons it's not possible to end the tutorial early. Continue?
-
+
failed to spawn notepad.exe: %1
-
+
failed to open %1
-
+
failed to change origin name: %1
-
+
failed to move "%1" from mod "%2" to "%3": %4
-
+
<Contains %1>
-
+
<Checked>
-
+
<Unchecked>
-
+
<Update>
-
+
<Managed by MO>
-
+
<Managed outside MO>
-
+
<No category>
-
+
<Conflicted>
-
+
<Not Endorsed>
-
+
failed to rename mod: %1
-
+
Overwrite?
-
+
This will replace the existing mod "%1". Continue?
-
+
failed to remove mod "%1"
-
-
-
+
+
+
failed to rename "%1" to "%2"
-
-
-
-
+
+
+
+
Confirm
-
+
Remove the following mods?<br><ul>%1</ul>
-
+
failed to remove mod: %1
-
+
Failed
-
+
Installation file no longer exists
-
+
Mods installed with old versions of MO can't be reinstalled in this way.
-
+
You need to be logged in with Nexus to resume a download
-
-
+
+
You need to be logged in with Nexus to endorse
-
+
Failed to display overwrite dialog: %1
-
+
Nexus ID for this Mod is unknown
-
+
Web page for this mod is unknown
-
-
-
+
+
+
Create Mod...
-
+
This will create an empty mod.
Please enter a name:
-
-
+
+
A mod with this name already exists
-
+
This will move all files from overwrite into a new, regular mod.
Please enter a name:
-
+
Not logged in, endorsement information will be wrong
-
+
Continue?
-
+
The versioning scheme decides which version is considered newer than another.
This function will guess the versioning scheme under the assumption that the installed version is outdated.
-
-
+
+
Sorry
-
+
I don't know a versioning scheme where %1 is newer than %2.
-
+
Really enable all visible mods?
-
+
Really disable all visible mods?
-
+
Choose what to export
-
+
Everything
-
+
All installed mods are included in the list
-
+
Active Mods
-
+
Only active (checked) mods from your current profile are included
-
+
Visible
-
+
All mods visible in the mod list are included
-
+
export failed: %1
-
+
Install Mod...
-
+
Create empty mod
-
+
Enable all visible
-
+
Disable all visible
-
+
Check all for update
-
+
Export to csv...
-
+
All Mods
-
+
Sync to Mods...
-
+
Restore Backup
-
+
Remove Backup...
-
+
Add/Remove Categories
-
+
Replace Categories
-
+
Primary Category
-
+
Change versioning scheme
-
+
Un-ignore update
-
+
Ignore update
-
+
Rename Mod...
-
+
Remove Mod...
-
+
Reinstall Mod
-
+
Un-Endorse
-
-
+
+
Endorse
-
+
Won't endorse
-
+
Endorsement state unknown
-
+
Ignore missing data
-
+
Visit on Nexus
-
+
Visit web page
-
+
Open in explorer
-
+
Information...
-
-
+
+
Exception:
-
-
+
+
Unknown exception
-
+
<All>
-
+
<Multiple>
-
+
%1 more
-
+
Are you sure you want to remove the following %n save(s)?<br><ul>%1</ul><br>Removed saves will be sent to the Recycle Bin.
@@ -2287,12 +2287,12 @@ This function will guess the versioning scheme under the assumption that the ins
-
+
Enable Mods...
-
+
Delete %n save(s)
@@ -2300,319 +2300,319 @@ This function will guess the versioning scheme under the assumption that the ins
-
+
failed to remove %1
-
+
failed to create %1
-
+
Can't change download directory while downloads are in progress!
-
+
failed to write to file %1
-
+
%1 written
-
+
Select binary
-
+
Binary
-
+
Enter Name
-
+
Please enter a name for the executable
-
+
Not an executable
-
+
This is not a recognized executable.
-
-
+
+
Replace file?
-
+
There already is a hidden version of this file. Replace it?
-
-
+
+
File operation failed
-
-
+
+
Failed to remove "%1". Maybe you lack the required file permissions?
-
+
There already is a visible version of this file. Replace it?
-
+
file not found: %1
-
+
failed to generate preview for %1
-
+
Sorry, can't preview anything. This function currently does not support extracting from bsas.
-
+
Update available
-
+
Open/Execute
-
+
Add as Executable
-
+
Preview
-
+
Un-Hide
-
+
Hide
-
+
Write To File...
-
+
Do you want to endorse Mod Organizer on %1 now?
-
+
Thank you!
-
+
Thank you for your endorsement!
-
+
Request to Nexus failed: %1
-
-
+
+
failed to read %1: %2
-
-
+
+
Error
-
+
failed to extract %1 (errorcode %2)
-
+
Extract BSA
-
+
This archive contains invalid hashes. Some files may be broken.
-
+
Are you sure?
-
+
This will restart MO, continue?
-
+
Edit Categories...
-
+
Deselect filter
-
+
Remove
-
+
Enable all
-
+
Disable all
-
+
Unlock load order
-
+
Lock load order
-
+
depends on missing "%1"
-
+
incompatible with "%1"
-
+
Please wait while LOOT is running
-
+
loot failed. Exit code was: %1
-
+
failed to start loot
-
+
failed to run loot: %1
-
+
Errors occured
-
+
Backup of load order created
-
+
Choose backup to restore
-
+
No Backups
-
+
There are no backups to restore
-
-
+
+
Restore failed
-
-
+
+
Failed to restore the backup. Errorcode: %1
-
+
Backup of modlist created
-
+
A file with the same name has already been downloaded. What would you like to do?
-
+
Overwrite
-
+
Rename new file
-
+
Ignore file
@@ -3593,147 +3593,147 @@ p, li { white-space: pre-wrap; }
-
-
+
+
Installation successful
-
-
+
+
Configure Mod
-
-
+
+
This mod contains ini tweaks. Do you want to configure them now?
-
-
+
+
mod "%1" not found
-
-
+
+
Installation cancelled
-
-
+
+
The mod was not installed completely.
-
+
Executable "%1" not found
-
+
Start Steam?
-
+
Steam is required to be running already to correctly start the game. Should MO try to start steam now?
-
+
Error
-
+
No profile set
-
+
Failed to refresh list of esps: %1
-
+
Multiple esps activated, please check that they don't conflict.
-
+
Download?
-
+
A download has been started but no installed page plugin recognizes it.
If you download anyway no information (i.e. version) will be associated with the download.
Continue?
-
+
failed to update mod list: %1
-
-
+
+
login successful
-
+
Login failed
-
+
Login failed, try again?
-
+
login failed: %1. Download will not be associated with an account
-
+
login failed: %1
-
+
login failed: %1. You need to log-in with Nexus to update MO.
-
+
Too many esps and esms enabled
-
-
+
+
Description missing
-
+
The game doesn't allow more than 255 active plugins (including the official ones) to be loaded. You have to disable some unused plugins or merge some plugins into one. You can find a guide here: <a href="http://wiki.step-project.com/Guide:Merging_Plugins">http://wiki.step-project.com/Guide:Merging_Plugins</a>
-
+
failed to save load order: %1
-
+
The designated write target "%1" is not enabled.
@@ -4280,20 +4280,20 @@ p, li { white-space: pre-wrap; }
QObject
-
+
Failed to save custom categories
-
-
-
-
+
+
+
+
invalid index %1
-
+
invalid category id %1
@@ -4358,6 +4358,11 @@ p, li { white-space: pre-wrap; }
invalid 7-zip32.dll: %1
+
+
+ archive.dll not loaded: "%1"
+
+
Enter Instance Name
@@ -4485,91 +4490,93 @@ p, li { white-space: pre-wrap; }
-
- Permissions required
+
+
+ Error
-
- The current user account doesn't have the required access rights to run Mod Organizer. The neccessary changes can be made automatically (the MO directory will be made writable for the current user account). You will be asked to run "helper.exe" with administrative rights.
+
+
+ Failed to create "%1". Your user account probably lacks permission.
-
-
+
+
Woops
-
+
ModOrganizer has crashed! Should a diagnostic file be created? If you send me this file (%1) to sherb@gmx.net, the bug is a lot more likely to be fixed. Please include a short description of what you were doing when the crash happened
-
+
ModOrganizer has crashed! Unfortunately I was not able to write a diagnostic file: %1
-
+
Plugin to handle %1 no longer installed
-
+
Could not use configuration settings for game "%1", path "%2".
-
-
+
+
Please select the game to manage
-
+
No game identified in "%1". The directory is required to contain the game binary and its launcher.
-
+
Please select the game edition you have (MO can't start the game correctly if this is set incorrectly!)
-
+
failed to start application: %1
-
-
+
+
Mod Organizer
-
+
An instance of Mod Organizer is already running
-
+
Failed to set up instance
-
+
Please use "Help" from the toolbar to get usage instructions to all elements
-
-
+
+
<Manage...>
-
+
failed to parse profile %1: %2
@@ -4620,12 +4627,12 @@ p, li { white-space: pre-wrap; }
-
+
Script Extender
-
+
Proxy DLL
@@ -4810,21 +4817,31 @@ Start elevated anyway? (you will be asked if you want to allow ModOrganizer.exe
Settings
-
+
Failed
-
+
Sorry, failed to start the helper application
-
-
+
+
attempt to store setting for unknown plugin "%1"
+
+
+ Error
+
+
+
+
+ Failed to create "%1", you may not have the necessary permission. path remains unchanged.
+
+
SettingsDialog
diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp
index 0fe3567c..0420ddc2 100644
--- a/src/usvfsconnector.cpp
+++ b/src/usvfsconnector.cpp
@@ -107,7 +107,7 @@ UsvfsConnector::UsvfsConnector()
LogLevel level = logLevel(Settings::instance().logLevel());
USVFSInitParameters(¶ms, SHMID, false, level);
InitLogging(false);
- ConnectVFS(¶ms);
+ CreateVFS(¶ms);
SetLogLevel(level);
BlacklistExecutable(L"TSVNCache.exe");
--
cgit v1.3.1
From 4adb13c9435baade511d3ac78fb142dc73bd2e1f Mon Sep 17 00:00:00 2001
From: Eran Mizrahi
Date: Fri, 8 Dec 2017 18:24:06 +0200
Subject: generate dumps using new diagnostics settings
---
src/main.cpp | 79 ++++++++++----------------------------------------
src/mainwindow.cpp | 2 +-
src/organizercore.cpp | 23 +++++++++++++--
src/organizercore.h | 7 ++++-
src/settings.cpp | 2 +-
src/usvfsconnector.cpp | 36 ++++++++++++++++-------
src/usvfsconnector.h | 4 ++-
7 files changed, 73 insertions(+), 80 deletions(-)
(limited to 'src/usvfsconnector.cpp')
diff --git a/src/main.cpp b/src/main.cpp
index 526563a2..71fbc943 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -48,6 +48,7 @@ along with Mod Organizer. If not, see .
#include
#include
+#include
#include
#include
@@ -127,71 +128,17 @@ bool isNxmLink(const QString &link)
static LONG WINAPI MyUnhandledExceptionFilter(struct _EXCEPTION_POINTERS *exceptionPtrs)
{
- typedef BOOL (WINAPI *FuncMiniDumpWriteDump)(HANDLE process, DWORD pid, HANDLE file, MINIDUMP_TYPE dumpType,
- const PMINIDUMP_EXCEPTION_INFORMATION exceptionParam,
- const PMINIDUMP_USER_STREAM_INFORMATION userStreamParam,
- const PMINIDUMP_CALLBACK_INFORMATION callbackParam);
- LONG result = EXCEPTION_CONTINUE_SEARCH;
-
- HMODULE dbgDLL = ::LoadLibrary(L"dbghelp.dll");
-
- static const int errorLen = 200;
- char errorBuffer[errorLen + 1];
- memset(errorBuffer, '\0', errorLen + 1);
-
- if (dbgDLL) {
- FuncMiniDumpWriteDump funcDump = (FuncMiniDumpWriteDump)::GetProcAddress(dbgDLL, "MiniDumpWriteDump");
- if (funcDump) {
- QString dataPath = qApp->property("dataPath").toString();
- QString exeName = QFileInfo(qApp->applicationFilePath()).fileName();
- QString dumpName = dataPath + "/" + exeName + ".dmp";
-
- if (QMessageBox::question(nullptr, QObject::tr("Woops"),
- QObject::tr("ModOrganizer has crashed! "
- "Should a diagnostic file be created? "
- "If you send me this file (%1) to modorganizer@gmail.com, "
- "the bug is a lot more likely to be fixed. "
- "Please include a short description of what you were "
- "doing when the crash happened"
- ).arg(dumpName),
- QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
-
- HANDLE dumpFile = ::CreateFile(dumpName.toStdWString().c_str(),
- GENERIC_WRITE, FILE_SHARE_WRITE, nullptr,
- CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
- if (dumpFile != INVALID_HANDLE_VALUE) {
- _MINIDUMP_EXCEPTION_INFORMATION exceptionInfo;
- exceptionInfo.ThreadId = ::GetCurrentThreadId();
- exceptionInfo.ExceptionPointers = exceptionPtrs;
- exceptionInfo.ClientPointers = false;
-
- BOOL success = funcDump(::GetCurrentProcess(), ::GetCurrentProcessId(), dumpFile,
- MiniDumpNormal, &exceptionInfo, nullptr, nullptr);
-
- ::FlushFileBuffers(dumpFile);
- ::CloseHandle(dumpFile);
- if (success) {
- return EXCEPTION_EXECUTE_HANDLER;
- }
- _snprintf(errorBuffer, errorLen, "failed to save minidump to %ls (error %lu)",
- dumpName.toStdWString().c_str(), ::GetLastError());
- } else {
- _snprintf(errorBuffer, errorLen, "failed to create %ls (error %lu)",
- dumpName.toStdWString().c_str(), ::GetLastError());
- }
- } else {
- return result;
- }
- } else {
- _snprintf(errorBuffer, errorLen, "dbghelp.dll outdated");
- }
- } else {
- _snprintf(errorBuffer, errorLen, "dbghelp.dll not found");
+ const std::wstring& dumpPath = OrganizerCore::crashDumpsPath();
+ int dumpRes =
+ CreateMiniDump(exceptionPtrs, OrganizerCore::getGlobalCrashDumpsType(), dumpPath.c_str());
+ if (!dumpRes) {
+ qCritical("ModOrganizer has crashed, crash dump created.");
+ return EXCEPTION_EXECUTE_HANDLER;
+ }
+ else {
+ qCritical("ModOrganizer has crashed, CreateMiniDump failed (%d, error %lu).", dumpRes, GetLastError());
+ return EXCEPTION_CONTINUE_SEARCH;
}
-
- QMessageBox::critical(nullptr, QObject::tr("Woops"),
- QObject::tr("ModOrganizer has crashed! Unfortunately I was not able to write a diagnostic file: %1").arg(errorBuffer));
- return result;
}
static bool HaveWriteAccess(const std::wstring &path)
@@ -448,6 +395,10 @@ int runApplication(MOApplication &application, SingleInstance &instance,
QSettings settings(dataPath + "/"
+ QString::fromStdWString(AppConfig::iniFileName()),
QSettings::IniFormat);
+
+ // global crashDumpType sits in OrganizerCore to make a bit less ugly to update it when the settings are changed during runtime
+ OrganizerCore::setGlobalCrashDumpsType(settings.value("Settings/crash_dumps_type", static_cast(CrashDumpsType::Mini)).toInt());
+
qDebug("initializing core");
OrganizerCore organizer(settings);
if (!organizer.bootstrap()) {
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 48dfdfbd..cab4c41f 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -3296,7 +3296,7 @@ void MainWindow::on_actionSettings_triggered()
updateDownloadListDelegate();
- m_OrganizerCore.setLogLevel(settings.logLevel());
+ m_OrganizerCore.updateVFSParams(settings.logLevel(), settings.crashDumpsType());
}
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index f8a368c9..adb895ec 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -47,6 +47,7 @@
#include // for qPrintable, etc
#include
+#include
#include // for _tcsicmp
#include
@@ -66,6 +67,9 @@
using namespace MOShared;
using namespace MOBase;
+//static
+CrashDumpsType OrganizerCore::m_globalCrashDumpsType = CrashDumpsType::None;
+
static bool isOnline()
{
QList interfaces = QNetworkInterface::allInterfaces();
@@ -643,8 +647,23 @@ void OrganizerCore::prepareVFS()
m_USVFS.updateMapping(fileMapping(m_CurrentProfile->name(), QString()));
}
-void OrganizerCore::setLogLevel(int logLevel) {
- m_USVFS.setLogLevel(logLevel);
+void OrganizerCore::updateVFSParams(int logLevel, int crashDumpsType) {
+ setGlobalCrashDumpsType(crashDumpsType);
+ m_USVFS.updateParams(logLevel, crashDumpsType);
+}
+
+//static
+void OrganizerCore::setGlobalCrashDumpsType(int crashDumpsType) {
+ m_globalCrashDumpsType = ::crashDumpsType(crashDumpsType);
+}
+
+//static
+std::wstring OrganizerCore::crashDumpsPath() {
+ wchar_t appDataLocal[MAX_PATH]{ 0 };
+ ::SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, appDataLocal);
+ std::wstring dumpPath{ appDataLocal };
+ dumpPath += L"\\modorganizer";
+ return dumpPath;
}
void OrganizerCore::setCurrentProfile(const QString &profileName)
diff --git a/src/organizercore.h b/src/organizercore.h
index 297b94f6..7bb7faa7 100644
--- a/src/organizercore.h
+++ b/src/organizercore.h
@@ -158,7 +158,11 @@ public:
void prepareVFS();
- void setLogLevel(int logLevel);
+ void updateVFSParams(int logLevel, int crashDumpsType);
+
+ static CrashDumpsType getGlobalCrashDumpsType() { return m_globalCrashDumpsType; }
+ static void setGlobalCrashDumpsType(int crashDumpsType);
+ static std::wstring crashDumpsPath();
public:
MOBase::IModRepositoryBridge *createNexusBridge() const;
@@ -319,6 +323,7 @@ private:
MOBase::DelayedFileWriter m_PluginListsWriter;
UsvfsConnector m_USVFS;
+ static CrashDumpsType m_globalCrashDumpsType;
};
#endif // ORGANIZERCORE_H
diff --git a/src/settings.cpp b/src/settings.cpp
index 7d90d861..05a62591 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -28,7 +28,7 @@ along with Mod Organizer. If not, see .
#include
#include
#include
-#include
+#include
#include
#include
diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp
index 0420ddc2..b90784d9 100644
--- a/src/usvfsconnector.cpp
+++ b/src/usvfsconnector.cpp
@@ -19,6 +19,8 @@ along with Mod Organizer. If not, see .
#include "usvfsconnector.h"
#include "settings.h"
+#include "organizercore.h"
+#include "shared/util.h"
#include
#include
#include
@@ -27,6 +29,7 @@ along with Mod Organizer. If not, see .
#include
#include
#include
+#include
static const char SHMID[] = "mod_organizer_instance";
@@ -101,14 +104,33 @@ LogLevel logLevel(int level)
}
}
+CrashDumpsType crashDumpsType(int type)
+{
+ switch (type) {
+ case CrashDumpsType::Mini:
+ return CrashDumpsType::Mini;
+ case CrashDumpsType::Data:
+ return CrashDumpsType::Data;
+ case CrashDumpsType::Full:
+ return CrashDumpsType::Full;
+ default:
+ return CrashDumpsType::None;
+ }
+}
+
UsvfsConnector::UsvfsConnector()
{
USVFSParameters params;
LogLevel level = logLevel(Settings::instance().logLevel());
- USVFSInitParameters(¶ms, SHMID, false, level);
+ CrashDumpsType dumpType = crashDumpsType(Settings::instance().crashDumpsType());
+
+ std::string dumpPath = MOShared::ToString(OrganizerCore::crashDumpsPath(), true);
+ USVFSInitParameters(¶ms, SHMID, false, level, dumpType, dumpPath.c_str());
InitLogging(false);
+
+ qDebug("Initializing VFS <%s, %d, %d, %s>", params.instanceName, params.logLevel, params.crashDumpsType, params.crashDumpsPath);
+
CreateVFS(¶ms);
- SetLogLevel(level);
BlacklistExecutable(L"TSVNCache.exe");
@@ -165,12 +187,6 @@ void UsvfsConnector::updateMapping(const MappingType &mapping)
*/
}
-void UsvfsConnector::setLogLevel(int logLevel) {
- switch (logLevel) {
- case LogLevel::Debug: SetLogLevel(LogLevel::Debug); break;
- case LogLevel::Info: SetLogLevel(LogLevel::Info); break;
- case LogLevel::Warning: SetLogLevel(LogLevel::Warning); break;
- case LogLevel::Error: SetLogLevel(LogLevel::Error); break;
- default: SetLogLevel(LogLevel::Debug); break;
- }
+void UsvfsConnector::updateParams(int logLevel, int crashDumpsType) {
+ USVFSUpdateParams(::logLevel(logLevel), ::crashDumpsType(crashDumpsType));
}
diff --git a/src/usvfsconnector.h b/src/usvfsconnector.h
index 8f723a01..0935bac1 100644
--- a/src/usvfsconnector.h
+++ b/src/usvfsconnector.h
@@ -27,6 +27,7 @@ along with Mod Organizer. If not, see .
#include
#include
#include
+#include
class LogWorker : public QThread {
@@ -67,7 +68,7 @@ public:
~UsvfsConnector();
void updateMapping(const MappingType &mapping);
- void setLogLevel(int logLevel);
+ void updateParams(int logLevel, int crashDumpsType);
private:
@@ -76,5 +77,6 @@ private:
};
+CrashDumpsType crashDumpsType(int type);
#endif // USVFSCONNECTOR_H
--
cgit v1.3.1
From 89b1f1d48dd05b372abca64b311b1107f044a897 Mon Sep 17 00:00:00 2001
From: Eran Mizrahi
Date: Sat, 9 Dec 2017 01:26:50 +0200
Subject: add logging of process spawn
---
src/organizercore.cpp | 4 ++++
src/usvfsconnector.cpp | 8 ++++++++
2 files changed, 12 insertions(+)
(limited to 'src/usvfsconnector.cpp')
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index 7f86f2b4..54cfed54 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -1181,9 +1181,13 @@ HANDLE OrganizerCore::spawnBinaryDirect(const QFileInfo &binary,
= QString("launch \"%1\" \"%2\" %3")
.arg(QDir::toNativeSeparators(dataCwd),
QDir::toNativeSeparators(dataBinPath), arguments);
+
+ qDebug() << "Spawning proxyed process <" << cmdline << ">";
+
return startBinary(QFileInfo(QCoreApplication::applicationFilePath()),
cmdline, QCoreApplication::applicationDirPath(), true);
} else {
+ qDebug() << "Spawning direct process <" << binary.absoluteFilePath() << "," << arguments << "," << currentDirectory.absolutePath() << ">";
return startBinary(binary, arguments, currentDirectory, true);
}
} else {
diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp
index b90784d9..ffbdf3aa 100644
--- a/src/usvfsconnector.cpp
+++ b/src/usvfsconnector.cpp
@@ -158,6 +158,10 @@ void UsvfsConnector::updateMapping(const MappingType &mapping)
progress.setMaximum(static_cast(mapping.size()));
progress.show();
int value = 0;
+ int files = 0;
+ int dirs = 0;
+
+ qDebug("Updating VFS mappings...");
ClearVirtualMappings();
@@ -173,11 +177,15 @@ void UsvfsConnector::updateMapping(const MappingType &mapping)
(map.createTarget ? LINKFLAG_CREATETARGET : 0)
| LINKFLAG_RECURSIVE
);
+ ++dirs;
} else {
VirtualLinkFile(map.source.toStdWString().c_str(),
map.destination.toStdWString().c_str(), 0);
+ ++files;
}
}
+
+ qDebug("VFS mappings updated ", dirs, files);
/*
size_t dumpSize = 0;
CreateVFSDump(nullptr, &dumpSize);
--
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/usvfsconnector.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