summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAl <gabriel.cortesi@outlook.com>2019-01-24 08:14:51 -0500
committerGitHub <noreply@github.com>2019-01-24 08:14:51 -0500
commitae794dba3204251fb76d7478a6f003b50301b8c7 (patch)
treebb9249fe3471d7d57ff96d557b5c53cd66346f36 /src
parentc0c754728c29a7a920a6e3550ed9944966e0c96d (diff)
parenta349ec24df44eaac8c083b8d07c51cabb8f62995 (diff)
Merge pull request #631 from Thex-PiedDroit/OverwriteToMod
Added ability to move files from the overwrite folder to an existing mod
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp58
-rw-r--r--src/mainwindow.h8
2 files changed, 62 insertions, 4 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index a9dd3e51..8a4ed854 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -3491,18 +3491,67 @@ void MainWindow::createModFromOverwrite()
return;
}
- IModInterface *newMod = m_OrganizerCore.createMod(name);
+ const IModInterface *newMod = m_OrganizerCore.createMod(name);
if (newMod == nullptr) {
return;
}
+ doMoveOverwriteContentToMod(newMod->absolutePath());
+}
+
+void MainWindow::moveOverwriteContentToExistingMod()
+{
+ QStringList mods;
+ auto indexesByPriority = m_OrganizerCore.currentProfile()->getAllIndexesByPriority();
+ for (auto & iter : indexesByPriority) {
+ if ((iter.second != UINT_MAX)) {
+ ModInfo::Ptr modInfo = ModInfo::getByIndex(iter.second);
+ if (!modInfo->hasFlag(ModInfo::FLAG_SEPARATOR) && !modInfo->hasFlag(ModInfo::FLAG_FOREIGN) && !modInfo->hasFlag(ModInfo::FLAG_OVERWRITE)) {
+ mods << modInfo->name();
+ }
+ }
+ }
+
+ ListDialog dialog(this);
+ QSettings &settings = m_OrganizerCore.settings().directInterface();
+ QString key = QString("geometry/%1").arg(dialog.objectName());
+
+ dialog.setWindowTitle("Select a mod...");
+ dialog.setChoices(mods);
+ dialog.restoreGeometry(settings.value(key).toByteArray());
+ if (dialog.exec() == QDialog::Accepted) {
+ QString result = dialog.getChoice();
+ if (!result.isEmpty()) {
+
+ QString modAbsolutePath;
+
+ for (const auto& mod : m_OrganizerCore.modsSortedByProfilePriority()) {
+ if (result.compare(mod) == 0) {
+ ModInfo::Ptr modInfo = ModInfo::getByIndex(ModInfo::getIndex(mod));
+ modAbsolutePath = modInfo->absolutePath();
+ break;
+ }
+ }
+
+ if (modAbsolutePath.isNull()) {
+ qWarning("Mod %s has not been found, for some reason", qUtf8Printable(result));
+ return;
+ }
+
+ doMoveOverwriteContentToMod(modAbsolutePath);
+ }
+ }
+}
+
+void MainWindow::doMoveOverwriteContentToMod(const QString &modAbsolutePath)
+{
unsigned int overwriteIndex = ModInfo::findMod([](ModInfo::Ptr mod) -> bool {
std::vector<ModInfo::EFlag> flags = mod->getFlags();
return std::find(flags.begin(), flags.end(), ModInfo::FLAG_OVERWRITE) != flags.end(); });
ModInfo::Ptr overwriteInfo = ModInfo::getByIndex(overwriteIndex);
- shellMove(QStringList(QDir::toNativeSeparators(overwriteInfo->absolutePath()) + "\\*"),
- QStringList(QDir::toNativeSeparators(newMod->absolutePath())), this);
+ shellMove((QDir::toNativeSeparators(overwriteInfo->absolutePath()) + "\\*"),
+ (QDir::toNativeSeparators(modAbsolutePath)), true, this);
m_OrganizerCore.refreshModList();
}
@@ -4354,6 +4403,7 @@ void MainWindow::on_modList_customContextMenuRequested(const QPoint &pos)
if (QDir(info->absolutePath()).count() > 2) {
menu->addAction(tr("Sync to Mods..."), &m_OrganizerCore, SLOT(syncOverwrite()));
menu->addAction(tr("Create Mod..."), this, SLOT(createModFromOverwrite()));
+ menu->addAction(tr("Move content to Mod..."), this, SLOT(moveOverwriteContentToExistingMod()));
menu->addAction(tr("Clear Overwrite..."), this, SLOT(clearOverwrite()));
}
menu->addAction(tr("Open in Explorer"), this, SLOT(openExplorer_clicked()));
@@ -6346,7 +6396,7 @@ void MainWindow::sendSelectedModsToSeparator_clicked()
if ((iter->second != UINT_MAX)) {
ModInfo::Ptr modInfo = ModInfo::getByIndex(iter->second);
if (modInfo->hasFlag(ModInfo::FLAG_SEPARATOR)) {
- separators << modInfo->name().chopped(10);
+ separators << modInfo->name().chopped(10); // Chops the "_separator" away from the name
}
}
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index e0311046..f2b9bc88 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -469,6 +469,14 @@ private slots:
BSA::EErrorCode extractBSA(BSA::Archive &archive, BSA::Folder::Ptr folder, const QString &destination, QProgressDialog &extractProgress);
void createModFromOverwrite();
+ /**
+ * @brief sends the content of the overwrite folder to an already existing mod
+ */
+ void moveOverwriteContentToExistingMod();
+ /**
+ * @brief actually sends the content of the overwrite folder to specified mod
+ */
+ void doMoveOverwriteContentToMod(const QString &modAbsolutePath);
void clearOverwrite();
void procError(QProcess::ProcessError error);