summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTannin <sherb@gmx.net>2015-12-28 14:34:44 +0100
committerTannin <sherb@gmx.net>2015-12-28 14:34:44 +0100
commitddf841400ef4da235f11e9b67177a78bb3d519d4 (patch)
tree1ae407dbb626ff600e8560996680edb594f89667 /src
parent1bfc91046badb609261c78b4b5e03bba4dcb61bd (diff)
parentd417229e6bbaaf393d9172b3c46ee36d285f2196 (diff)
Merge branch 'new_vfs_library' of https://github.com/TanninOne/modorganizer into new_vfs_library
Diffstat (limited to 'src')
-rw-r--r--src/downloadmanager.cpp5
-rw-r--r--src/downloadmanager.h4
-rw-r--r--src/main.cpp4
-rw-r--r--src/nxmaccessmanager.cpp1
-rw-r--r--src/organizercore.cpp31
-rw-r--r--src/profile.h4
-rw-r--r--src/profilesdialog.h1
-rw-r--r--src/settings.cpp1
-rw-r--r--src/transfersavesdialog.cpp13
9 files changed, 39 insertions, 25 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index 9d891475..648276ce 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -1244,14 +1244,13 @@ int DownloadManager::startDownloadURLs(const QStringList &urls)
return m_ActiveDownloads.size() - 1;
}
-/* This doesn't appear to be used by anything
int DownloadManager::startDownloadNexusFile(int modID, int fileID)
{
int newID = m_ActiveDownloads.size();
- addNXMDownload(QString("nxm://%1/mods/%2/files/%3").arg(ToQString(MOShared::GameInfo::instance().getGameName())).arg(modID).arg(fileID));
+ addNXMDownload(QString("nxm://%1/mods/%2/files/%3").arg(m_ManagedGame->getGameShortName()).arg(modID).arg(fileID));
return newID;
}
-*/
+
QString DownloadManager::downloadPath(int id)
{
return getFilePath(id);
diff --git a/src/downloadmanager.h b/src/downloadmanager.h
index 54db4648..e63a0113 100644
--- a/src/downloadmanager.h
+++ b/src/downloadmanager.h
@@ -329,9 +329,9 @@ public:
virtual int startDownloadURLs(const QStringList &urls);
- /* This doesn't appear to be used anywhere
+
virtual int startDownloadNexusFile(int modID, int fileID);
- */
+
virtual QString downloadPath(int id);
/**
diff --git a/src/main.cpp b/src/main.cpp
index 0258910c..30938485 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -35,7 +35,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <report.h>
#include "modlist.h"
#include "profile.h"
-#include "gameinfo.h"
#include "spawn.h"
#include "executableslist.h"
#include "singleinstance.h"
@@ -556,9 +555,6 @@ int main(int argc, char *argv[])
organizer.setManagedGame(game);
- //*sigh just for making it work
- GameInfo::init(application.applicationDirPath().toStdWString(), game->gameDirectory().absolutePath().toStdWString());
-
organizer.createDefaultProfile();
//See the pragma - we apparently don't use this so not sure why we check it
diff --git a/src/nxmaccessmanager.cpp b/src/nxmaccessmanager.cpp
index cdf50fd8..a7dd6eef 100644
--- a/src/nxmaccessmanager.cpp
+++ b/src/nxmaccessmanager.cpp
@@ -26,7 +26,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "selfupdater.h"
#include "persistentcookiejar.h"
#include "settings.h"
-#include <gameinfo.h>
#include <QMessageBox>
#include <QPushButton>
#include <QNetworkProxy>
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index c1044c9d..c84b603d 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -997,7 +997,31 @@ 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, currentDirectory, true);
+ QString modsPath(qApp->property("dataPath").toString() + "/" + QString::fromStdWString(AppConfig::modsPath()));
+
+ 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
+
+ QString cwdPath = currentDirectory.absolutePath();
+
+ int binOffset = binPath.indexOf('/', modsPath.length() + 1);
+ int cwdOffset = cwdPath.indexOf('/', cwdPath.length() + 1);
+ QString binPath = m_GamePlugin->dataDirectory().absolutePath() + "/" + binPath.mid(binOffset);
+ QString cwd = m_GamePlugin->dataDirectory().absolutePath() + "/" + cwdPath.mid(cwdOffset);
+ QString cmdline = QString("launch \"%1\" \"%2\" %3")
+ .arg(QDir::toNativeSeparators(cwd),
+ QDir::toNativeSeparators(binPath),
+ arguments);
+
+ return startBinary(QFileInfo(QCoreApplication::applicationDirPath() + "/helper.exe"),
+ cmdline,
+ QCoreApplication::applicationDirPath(), true);
+ } else {
+ return startBinary(binary, arguments, currentDirectory, true);
+ }
} else {
qDebug("start of \"%s\" canceled by plugin", qPrintable(binary.absoluteFilePath()));
return INVALID_HANDLE_VALUE;
@@ -1576,7 +1600,7 @@ std::vector<Mapping> OrganizerCore::fileMapping()
int overwriteId = m_DirectoryStructure->getOriginByName(L"Overwrite").getID();
- IPluginGame *game = qApp->property("managed_game").value<IPluginGame *>();
+ const IPluginGame *game = qApp->property("managed_game").value<const IPluginGame *>();
MappingType result = fileMapping(
QDir::toNativeSeparators(game->dataDirectory().absolutePath()),
"\\",
@@ -1585,11 +1609,12 @@ std::vector<Mapping> OrganizerCore::fileMapping()
if (m_CurrentProfile->localSavesEnabled()) {
LocalSavegames *localSaves = game->feature<LocalSavegames>();
-
if (localSaves != nullptr) {
MappingType saveMap = localSaves->mappings(currentProfile()->absolutePath() + "/saves");
result.reserve(result.size() + saveMap.size());
result.insert(result.end(), saveMap.begin(), saveMap.end());
+ } else {
+ qWarning("local save games not supported by this game plugin");
}
}
diff --git a/src/profile.h b/src/profile.h
index 5d5a3bc5..a7d71251 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -102,10 +102,6 @@ public:
/**
* @brief activate archive invalidation
- *
- * @param dataDirectory data directory of the game
- * @todo passing the data directory as a parameter is useless, the function should
- * be able to query it from GameInfo
**/
void activateInvalidation();
diff --git a/src/profilesdialog.h b/src/profilesdialog.h
index 26476883..073d92b7 100644
--- a/src/profilesdialog.h
+++ b/src/profilesdialog.h
@@ -48,7 +48,6 @@ public:
*
* @param profileName currently enabled profile
* @param parent parent widget
- * @todo the game path could be retrieved from GameInfo just as easily
**/
explicit ProfilesDialog(const QString &profileName, MOBase::IPluginGame const *game, QWidget *parent = 0);
~ProfilesDialog();
diff --git a/src/settings.cpp b/src/settings.cpp
index 25b58df7..7b812759 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -22,7 +22,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "settingsdialog.h"
#include "utility.h"
#include "helper.h"
-#include <gameinfo.h>
#include <appconfig.h>
#include <utility.h>
#include <iplugingame.h>
diff --git a/src/transfersavesdialog.cpp b/src/transfersavesdialog.cpp
index f6ca27cd..838d12ce 100644
--- a/src/transfersavesdialog.cpp
+++ b/src/transfersavesdialog.cpp
@@ -157,7 +157,7 @@ void TransferSavesDialog::on_moveToLocalBtn_clicked()
{
QString selectedCharacter = ui->globalCharacterList->currentItem()->text();
if (QMessageBox::question(this, tr("Confirm"),
- tr("Copy all save games of character \"%1\" to the profile?").arg(selectedCharacter),
+ tr("Move all save games of character \"%1\" to the profile?").arg(selectedCharacter),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
QString destination = m_Profile.absolutePath() + "/saves";
OverwriteMode overwriteMode = OVERWRITE_ASK;
@@ -176,10 +176,11 @@ void TransferSavesDialog::on_moveToLocalBtn_clicked()
continue;
}
}
- if (!QFile::rename(fileInfo.absoluteFilePath(), destinationFile)) {
- qCritical("failed to move %s to %s",
+ if (!shellMove(fileInfo.absoluteFilePath(), destinationFile)) {
+ qCritical("failed to move %s to %s: %lu",
fileInfo.absoluteFilePath().toUtf8().constData(),
- destinationFile.toUtf8().constData());
+ destinationFile.toUtf8().constData(),
+ ::GetLastError());
}
}
}
@@ -240,7 +241,7 @@ void TransferSavesDialog::on_moveToGlobalBtn_clicked()
continue;
}
}
- if (!QFile::rename(fileInfo.absoluteFilePath(), destinationFile)) {
+ if (!shellMove(fileInfo.absoluteFilePath(), destinationFile)) {
qCritical("failed to move %s to %s",
fileInfo.absoluteFilePath().toUtf8().constData(),
destinationFile.toUtf8().constData());
@@ -279,7 +280,7 @@ void TransferSavesDialog::on_copyToGlobalBtn_clicked()
continue;
}
}
- if (!QFile::copy(fileInfo.absoluteFilePath(), destinationFile)) {
+ if (!shellCopy(fileInfo.absoluteFilePath(), destinationFile)) {
qCritical("failed to copy %s to %s",
fileInfo.absoluteFilePath().toUtf8().constData(),
destinationFile.toUtf8().constData());