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.ui | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'src/editexecutablesdialog.ui') 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 -- 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/editexecutablesdialog.ui') 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/editexecutablesdialog.ui') 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 836e550dd0bc2b20d99f222865cfe1a0cb069187 Mon Sep 17 00:00:00 2001 From: Helidoc65 Date: Tue, 7 Nov 2017 10:42:43 -0700 Subject: Add files via upload Fixed to get rid of WindowsWindow::setGeometry: Unable to set geometry bug. --- src/editexecutablesdialog.ui | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/editexecutablesdialog.ui') diff --git a/src/editexecutablesdialog.ui b/src/editexecutablesdialog.ui index b3543c95..bdbb8bd1 100644 --- a/src/editexecutablesdialog.ui +++ b/src/editexecutablesdialog.ui @@ -10,6 +10,12 @@ 460 + + + 200 + 200 + + Modify Executables -- cgit v1.3.1