mirror of
https://github.com/ModOrganizer2/modorganizer.git
synced 2026-07-27 13:58:24 -07:00
Compare commits
32
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3cb50057b | ||
|
|
5518309300 | ||
|
|
f22bb9d6a6 | ||
|
|
382226bb46 | ||
|
|
bdf04f516c | ||
|
|
54c7131a5e | ||
|
|
15e256ef44 | ||
|
|
b23a4885e0 | ||
|
|
823dfd410b | ||
|
|
ba09054e6b | ||
|
|
694e3ed279 | ||
|
|
cffd9eb4e2 | ||
|
|
640b14ef25 | ||
|
|
47293827bb | ||
|
|
0a3169b808 | ||
|
|
f4528c7aaa | ||
|
|
4f0a6e8b88 | ||
|
|
c57b172204 | ||
|
|
dfca8be71b | ||
|
|
08037bf876 | ||
|
|
500ab7f706 | ||
|
|
08309b71ba | ||
|
|
dce78b62b8 | ||
|
|
af6e1c3ab4 | ||
|
|
50325c8fc2 | ||
|
|
7a382eab75 | ||
|
|
8e6868bf88 | ||
|
|
a891146446 | ||
|
|
72f14df8a7 | ||
|
|
0fa7155eb8 | ||
|
|
c6c61ce792 | ||
|
|
ef801879ab |
@@ -12,7 +12,9 @@ SUBDIRS = bsatk \
|
||||
plugins \
|
||||
proxydll \
|
||||
nxmhandler \
|
||||
BossDummy
|
||||
BossDummy \
|
||||
pythonRunner \
|
||||
esptk
|
||||
|
||||
hookdll.depends = shared
|
||||
organizer.depends = shared, uibase, plugins
|
||||
|
||||
@@ -65,11 +65,6 @@ ActivateModsDialog::~ActivateModsDialog()
|
||||
}
|
||||
|
||||
|
||||
void ActivateModsDialog::on_buttonBox_accepted()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
std::set<QString> ActivateModsDialog::getModsToActivate()
|
||||
{
|
||||
std::set<QString> result;
|
||||
|
||||
@@ -62,7 +62,6 @@ public:
|
||||
std::set<QString> getESPsToActivate();
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
|
||||
private:
|
||||
Ui::ActivateModsDialog *ui;
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2012 Sebastian Herbord. All rights reserved.
|
||||
|
||||
This file is part of Mod Organizer.
|
||||
|
||||
Mod Organizer is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Mod Organizer is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "archivetree.h"
|
||||
#include <QDragMoveEvent>
|
||||
|
||||
ArchiveTree::ArchiveTree(QWidget *parent) :
|
||||
QTreeWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool ArchiveTree::testMovePossible(QTreeWidgetItem *source, QTreeWidgetItem *target)
|
||||
{
|
||||
if ((target == NULL) ||
|
||||
(source == NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((source == target) ||
|
||||
(source->parent() == target)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ArchiveTree::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
QTreeWidgetItem *source = this->currentItem();
|
||||
if ((source == NULL) || (source->parent() == NULL)) {
|
||||
// can't change top level
|
||||
event->ignore();
|
||||
return;
|
||||
} else {
|
||||
QTreeWidget::dragEnterEvent(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ArchiveTree::dragMoveEvent(QDragMoveEvent *event)
|
||||
{
|
||||
if (!testMovePossible(this->currentItem(), itemAt(event->pos()))) {
|
||||
event->ignore();
|
||||
} else {
|
||||
QTreeWidget::dragMoveEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ArchiveTree::dropEvent(QDropEvent *event)
|
||||
{
|
||||
event->ignore();
|
||||
|
||||
QTreeWidgetItem *target = itemAt(event->pos());
|
||||
|
||||
QList<QTreeWidgetItem*> sourceItems = this->selectedItems();
|
||||
for (QList<QTreeWidgetItem*>::iterator iter = sourceItems.begin();
|
||||
iter != sourceItems.end(); ++iter) {
|
||||
QTreeWidgetItem *source = *iter;
|
||||
if ((source->parent() != NULL) &&
|
||||
testMovePossible(source, target)) {
|
||||
source->parent()->removeChild(source);
|
||||
if (target->data(0, Qt::UserRole).toInt() != 0) {
|
||||
// target is a file
|
||||
if (target->parent() == NULL) {
|
||||
// this should really not happen, how should a
|
||||
// file get to the top level?
|
||||
return;
|
||||
}
|
||||
int index = target->parent()->indexOfChild(target);
|
||||
target->parent()->insertChild(index, source);
|
||||
emit changed();
|
||||
} else {
|
||||
// target is a directory
|
||||
target->insertChild(target->childCount(), source);
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2012 Sebastian Herbord. All rights reserved.
|
||||
|
||||
This file is part of Mod Organizer.
|
||||
|
||||
Mod Organizer is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Mod Organizer is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ARCHIVETREE_H
|
||||
#define ARCHIVETREE_H
|
||||
|
||||
#include <QTreeWidget>
|
||||
|
||||
/**
|
||||
* @brief QT tree widget used to display the content of an archive in the manual installation dialog
|
||||
**/
|
||||
class ArchiveTree : public QTreeWidget
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit ArchiveTree(QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
void changed();
|
||||
|
||||
public slots:
|
||||
|
||||
protected:
|
||||
|
||||
virtual void dragEnterEvent(QDragEnterEvent *event);
|
||||
virtual void dragMoveEvent(QDragMoveEvent *event);
|
||||
virtual void dropEvent(QDropEvent *event);
|
||||
|
||||
private:
|
||||
|
||||
bool testMovePossible(QTreeWidgetItem *source, QTreeWidgetItem *target);
|
||||
|
||||
};
|
||||
|
||||
#endif // ARCHIVETREE_H
|
||||
@@ -43,6 +43,7 @@ QString CategoryFactory::categoriesFilePath()
|
||||
|
||||
CategoryFactory::CategoryFactory()
|
||||
{
|
||||
atexit(&cleanup);
|
||||
reset();
|
||||
|
||||
QFile categoryFile(categoriesFilePath());
|
||||
@@ -124,6 +125,12 @@ void CategoryFactory::setParents()
|
||||
}
|
||||
}
|
||||
|
||||
void CategoryFactory::cleanup()
|
||||
{
|
||||
delete s_Instance;
|
||||
s_Instance = NULL;
|
||||
}
|
||||
|
||||
|
||||
void CategoryFactory::saveCategories()
|
||||
{
|
||||
|
||||
@@ -180,6 +180,8 @@ private:
|
||||
|
||||
void setParents();
|
||||
|
||||
static void cleanup();
|
||||
|
||||
private:
|
||||
|
||||
static CategoryFactory *s_Instance;
|
||||
@@ -188,6 +190,8 @@ private:
|
||||
std::map<int, unsigned int> m_IDMap;
|
||||
std::map<int, unsigned int> m_NexusMap;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ void DownloadListWidgetDelegate::paint(QPainter *painter, const QStyleOptionView
|
||||
}
|
||||
m_InstallLabel->setPalette(labelPalette);
|
||||
if (m_Manager->isInfoIncomplete(downloadIndex)) {
|
||||
m_NameLabel->setText("<img src=\":/MO/gui/resources/dialog-warning_16.png\" /> " + m_NameLabel->text());
|
||||
m_NameLabel->setText("<img src=\":/MO/gui/warning_16\" /> " + m_NameLabel->text());
|
||||
}
|
||||
} else {
|
||||
m_InstallLabel->setVisible(false);
|
||||
@@ -208,6 +208,11 @@ void DownloadListWidgetDelegate::issueRemoveFromView()
|
||||
emit removeDownload(m_ContextRow, false);
|
||||
}
|
||||
|
||||
void DownloadListWidgetDelegate::issueRestoreToView()
|
||||
{
|
||||
emit restoreDownload(m_ContextRow);
|
||||
}
|
||||
|
||||
void DownloadListWidgetDelegate::issueCancel()
|
||||
{
|
||||
emit cancelDownload(m_ContextRow);
|
||||
@@ -277,13 +282,18 @@ bool DownloadListWidgetDelegate::editorEvent(QEvent *event, QAbstractItemModel *
|
||||
QMenu menu(m_View);
|
||||
m_ContextRow = qobject_cast<QSortFilterProxyModel*>(model)->mapToSource(index).row();
|
||||
DownloadManager::DownloadState state = m_Manager->getState(m_ContextRow);
|
||||
bool hidden = m_Manager->isHidden(m_ContextRow);
|
||||
if (state >= DownloadManager::STATE_READY) {
|
||||
menu.addAction(tr("Install"), this, SLOT(issueInstall()));
|
||||
if (m_Manager->isInfoIncomplete(m_ContextRow)) {
|
||||
menu.addAction(tr("Query Info"), this, SLOT(issueQueryInfo()));
|
||||
}
|
||||
menu.addAction(tr("Delete"), this, SLOT(issueDelete()));
|
||||
menu.addAction(tr("Remove from View"), this, SLOT(issueRemoveFromView()));
|
||||
if (hidden) {
|
||||
menu.addAction(tr("Un-Hide"), this, SLOT(issueRestoreToView()));
|
||||
} else {
|
||||
menu.addAction(tr("Remove from View"), this, SLOT(issueRemoveFromView()));
|
||||
}
|
||||
} else if (state == DownloadManager::STATE_DOWNLOADING){
|
||||
menu.addAction(tr("Cancel"), this, SLOT(issueCancel()));
|
||||
menu.addAction(tr("Pause"), this, SLOT(issuePause()));
|
||||
@@ -295,9 +305,11 @@ bool DownloadListWidgetDelegate::editorEvent(QEvent *event, QAbstractItemModel *
|
||||
menu.addSeparator();
|
||||
menu.addAction(tr("Delete Installed..."), this, SLOT(issueDeleteCompleted()));
|
||||
menu.addAction(tr("Delete All..."), this, SLOT(issueDeleteAll()));
|
||||
menu.addSeparator();
|
||||
menu.addAction(tr("Remove Installed..."), this, SLOT(issueRemoveFromViewCompleted()));
|
||||
menu.addAction(tr("Remove All..."), this, SLOT(issueRemoveFromViewAll()));
|
||||
if (!hidden) {
|
||||
menu.addSeparator();
|
||||
menu.addAction(tr("Remove Installed..."), this, SLOT(issueRemoveFromViewCompleted()));
|
||||
menu.addAction(tr("Remove All..."), this, SLOT(issueRemoveFromViewAll()));
|
||||
}
|
||||
menu.exec(mouseEvent->globalPos());
|
||||
|
||||
event->accept();
|
||||
|
||||
@@ -65,6 +65,7 @@ signals:
|
||||
void installDownload(int index);
|
||||
void queryInfo(int index);
|
||||
void removeDownload(int index, bool deleteFile);
|
||||
void restoreDownload(int index);
|
||||
void cancelDownload(int index);
|
||||
void pauseDownload(int index);
|
||||
void resumeDownload(int index);
|
||||
@@ -83,6 +84,7 @@ private slots:
|
||||
void issueInstall();
|
||||
void issueDelete();
|
||||
void issueRemoveFromView();
|
||||
void issueRestoreToView();
|
||||
void issueCancel();
|
||||
void issuePause();
|
||||
void issueResume();
|
||||
|
||||
@@ -137,7 +137,7 @@ void DownloadListWidgetCompactDelegate::paint(QPainter *painter, const QStyleOpt
|
||||
m_DoneLabel->setForegroundRole(QPalette::WindowText);
|
||||
}
|
||||
if (m_Manager->isInfoIncomplete(downloadIndex)) {
|
||||
m_NameLabel->setText("<img src=\":/MO/gui/resources/dialog-warning_16.png\"/> " + m_NameLabel->text());
|
||||
m_NameLabel->setText("<img src=\":/MO/gui/warning_16\"/> " + m_NameLabel->text());
|
||||
}
|
||||
} else {
|
||||
m_DoneLabel->setVisible(false);
|
||||
@@ -195,6 +195,11 @@ void DownloadListWidgetCompactDelegate::issueRemoveFromView()
|
||||
emit removeDownload(m_ContextIndex.row(), false);
|
||||
}
|
||||
|
||||
void DownloadListWidgetCompactDelegate::issueRestoreToView()
|
||||
{
|
||||
emit restoreDownload(m_ContextIndex.row());
|
||||
}
|
||||
|
||||
void DownloadListWidgetCompactDelegate::issueCancel()
|
||||
{
|
||||
emit cancelDownload(m_ContextIndex.row());
|
||||
@@ -265,13 +270,18 @@ bool DownloadListWidgetCompactDelegate::editorEvent(QEvent *event, QAbstractItem
|
||||
QMenu menu;
|
||||
m_ContextIndex = qobject_cast<QSortFilterProxyModel*>(model)->mapToSource(index);
|
||||
DownloadManager::DownloadState state = m_Manager->getState(m_ContextIndex.row());
|
||||
bool hidden = m_Manager->isHidden(m_ContextIndex.row());
|
||||
if (state >= DownloadManager::STATE_READY) {
|
||||
menu.addAction(tr("Install"), this, SLOT(issueInstall()));
|
||||
if (m_Manager->isInfoIncomplete(m_ContextIndex.row())) {
|
||||
menu.addAction(tr("Query Info"), this, SLOT(issueQueryInfo()));
|
||||
}
|
||||
menu.addAction(tr("Delete"), this, SLOT(issueDelete()));
|
||||
menu.addAction(tr("Remove from View"), this, SLOT(issueRemoveFromView()));
|
||||
if (hidden) {
|
||||
menu.addAction(tr("Un-Hide"), this, SLOT(issueRestoreToView()));
|
||||
} else {
|
||||
menu.addAction(tr("Remove from View"), this, SLOT(issueRemoveFromView()));
|
||||
}
|
||||
} else if (state == DownloadManager::STATE_DOWNLOADING){
|
||||
menu.addAction(tr("Cancel"), this, SLOT(issueCancel()));
|
||||
menu.addAction(tr("Pause"), this, SLOT(issuePause()));
|
||||
@@ -283,9 +293,11 @@ bool DownloadListWidgetCompactDelegate::editorEvent(QEvent *event, QAbstractItem
|
||||
menu.addSeparator();
|
||||
menu.addAction(tr("Delete Installed..."), this, SLOT(issueDeleteCompleted()));
|
||||
menu.addAction(tr("Delete All..."), this, SLOT(issueDeleteAll()));
|
||||
menu.addSeparator();
|
||||
menu.addAction(tr("Remove Installed..."), this, SLOT(issueRemoveFromViewCompleted()));
|
||||
menu.addAction(tr("Remove All..."), this, SLOT(issueRemoveFromViewAll()));
|
||||
if (!hidden) {
|
||||
menu.addSeparator();
|
||||
menu.addAction(tr("Remove Installed..."), this, SLOT(issueRemoveFromViewCompleted()));
|
||||
menu.addAction(tr("Remove All..."), this, SLOT(issueRemoveFromViewAll()));
|
||||
}
|
||||
menu.exec(mouseEvent->globalPos());
|
||||
|
||||
event->accept();
|
||||
|
||||
@@ -65,6 +65,7 @@ signals:
|
||||
void installDownload(int index);
|
||||
void queryInfo(int index);
|
||||
void removeDownload(int index, bool deleteFile);
|
||||
void restoreDownload(int index);
|
||||
void cancelDownload(int index);
|
||||
void pauseDownload(int index);
|
||||
void resumeDownload(int index);
|
||||
@@ -83,6 +84,7 @@ private slots:
|
||||
void issueInstall();
|
||||
void issueDelete();
|
||||
void issueRemoveFromView();
|
||||
void issueRestoreToView();
|
||||
void issueCancel();
|
||||
void issuePause();
|
||||
void issueResume();
|
||||
|
||||
+72
-12
@@ -22,6 +22,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "nxmurl.h"
|
||||
#include <gameinfo.h>
|
||||
#include <nxmurl.h>
|
||||
#include <taskprogressmanager.h>
|
||||
#include "utility.h"
|
||||
#include "json.h"
|
||||
#include "selectiondialog.h"
|
||||
@@ -63,18 +64,21 @@ DownloadManager::DownloadInfo *DownloadManager::DownloadInfo::createNew(const Ne
|
||||
info->m_CurrentUrl = 0;
|
||||
info->m_Tries = AUTOMATIC_RETRIES;
|
||||
info->m_State = STATE_STARTED;
|
||||
info->m_TaskProgressId = TaskProgressManager::instance().getId();
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
DownloadManager::DownloadInfo *DownloadManager::DownloadInfo::createFromMeta(const QString &filePath)
|
||||
DownloadManager::DownloadInfo *DownloadManager::DownloadInfo::createFromMeta(const QString &filePath, bool showHidden)
|
||||
{
|
||||
DownloadInfo *info = new DownloadInfo;
|
||||
|
||||
QString metaFileName = filePath + ".meta";
|
||||
QSettings metaFile(metaFileName, QSettings::IniFormat);
|
||||
if (metaFile.value("removed", false).toBool()) {
|
||||
if (!showHidden && metaFile.value("removed", false).toBool()) {
|
||||
return NULL;
|
||||
} else {
|
||||
info->m_Hidden = metaFile.value("removed", false).toBool();
|
||||
}
|
||||
|
||||
QString fileName = QFileInfo(filePath).fileName();
|
||||
@@ -105,6 +109,7 @@ DownloadManager::DownloadInfo *DownloadManager::DownloadInfo::createFromMeta(con
|
||||
info->m_CurrentUrl = 0;
|
||||
info->m_Urls = metaFile.value("url", "").toString().split(";");
|
||||
info->m_Tries = 0;
|
||||
info->m_TaskProgressId = TaskProgressManager::instance().getId();
|
||||
info->m_NexusInfo.m_Name = metaFile.value("name", 0).toString();
|
||||
info->m_NexusInfo.m_ModName = metaFile.value("modName", "").toString();
|
||||
info->m_NexusInfo.m_Version = metaFile.value("version", 0).toString();
|
||||
@@ -148,7 +153,7 @@ QString DownloadManager::DownloadInfo::currentURL()
|
||||
|
||||
|
||||
DownloadManager::DownloadManager(NexusInterface *nexusInterface, QObject *parent)
|
||||
: IDownloadManager(parent), m_NexusInterface(nexusInterface), m_DirWatcher()
|
||||
: IDownloadManager(parent), m_NexusInterface(nexusInterface), m_DirWatcher(), m_ShowHidden(false)
|
||||
{
|
||||
connect(&m_DirWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(directoryChanged(QString)));
|
||||
}
|
||||
@@ -159,6 +164,7 @@ DownloadManager::~DownloadManager()
|
||||
for (QVector<DownloadInfo*>::iterator iter = m_ActiveDownloads.begin(); iter != m_ActiveDownloads.end(); ++iter) {
|
||||
delete *iter;
|
||||
}
|
||||
m_ActiveDownloads.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -184,13 +190,15 @@ void DownloadManager::pauseAll()
|
||||
::Sleep(100);
|
||||
|
||||
bool done = false;
|
||||
QTime startTime = QTime::currentTime();
|
||||
// further loops: busy waiting for all downloads to complete. This could be neater...
|
||||
while (!done) {
|
||||
while (!done && (startTime.secsTo(QTime::currentTime()) < 5)) {
|
||||
QCoreApplication::processEvents();
|
||||
done = true;
|
||||
foreach (DownloadInfo *info, m_ActiveDownloads) {
|
||||
if ((info->m_State < STATE_CANCELED) ||
|
||||
(info->m_State != STATE_FETCHINGFILEINFO) || (info->m_State != STATE_FETCHINGMODINFO)) {
|
||||
(info->m_State == STATE_FETCHINGFILEINFO) ||
|
||||
(info->m_State == STATE_FETCHINGMODINFO)) {
|
||||
done = false;
|
||||
break;
|
||||
}
|
||||
@@ -226,6 +234,12 @@ void DownloadManager::setSupportedExtensions(const QStringList &extensions)
|
||||
refreshList();
|
||||
}
|
||||
|
||||
void DownloadManager::setShowHidden(bool showHidden)
|
||||
{
|
||||
m_ShowHidden = showHidden;
|
||||
refreshList();
|
||||
}
|
||||
|
||||
void DownloadManager::refreshList()
|
||||
{
|
||||
// remove finished downloads
|
||||
@@ -263,7 +277,7 @@ void DownloadManager::refreshList()
|
||||
|
||||
QString fileName = QDir::fromNativeSeparators(m_OutputDirectory) + "/" + file;
|
||||
|
||||
DownloadInfo *info = DownloadInfo::createFromMeta(fileName);
|
||||
DownloadInfo *info = DownloadInfo::createFromMeta(fileName, m_ShowHidden);
|
||||
if (info != NULL) {
|
||||
m_ActiveDownloads.push_front(info);
|
||||
}
|
||||
@@ -362,6 +376,15 @@ void DownloadManager::startDownload(QNetworkReply *reply, DownloadInfo *newDownl
|
||||
void DownloadManager::addNXMDownload(const QString &url)
|
||||
{
|
||||
NXMUrl nxmInfo(url);
|
||||
|
||||
QString managedGame = ToQString(MOShared::GameInfo::instance().getGameShortName());
|
||||
|
||||
if (nxmInfo.game().compare(managedGame, Qt::CaseInsensitive) != 0) {
|
||||
QMessageBox::information(NULL, tr("Wrong Game"), tr("The download link is for a mod for \"%1\" but this instance of MO "
|
||||
"has been set up for \"%2\".").arg(nxmInfo.game()).arg(managedGame), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
m_RequestIDs.insert(m_NexusInterface->requestFileInfo(nxmInfo.getModId(), nxmInfo.getFileId(), this, QVariant()));
|
||||
}
|
||||
|
||||
@@ -433,6 +456,22 @@ void DownloadManager::refreshAlphabeticalTranslation()
|
||||
}
|
||||
|
||||
|
||||
void DownloadManager::restoreDownload(int index)
|
||||
{
|
||||
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
|
||||
throw MyException(tr("invalid index"));
|
||||
}
|
||||
|
||||
DownloadInfo *download = m_ActiveDownloads.at(index);
|
||||
download->m_Hidden = false;
|
||||
|
||||
QString filePath = m_OutputDirectory + "/" + download->m_FileName;
|
||||
|
||||
QSettings metaSettings(filePath.append(".meta"), QSettings::IniFormat);
|
||||
metaSettings.setValue("removed", false);
|
||||
}
|
||||
|
||||
|
||||
void DownloadManager::removeDownload(int index, bool deleteFile)
|
||||
{
|
||||
try {
|
||||
@@ -488,9 +527,13 @@ void DownloadManager::pauseDownload(int index)
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_ActiveDownloads.at(index)->m_State == STATE_DOWNLOADING) {
|
||||
setState(m_ActiveDownloads.at(index), STATE_PAUSING);
|
||||
qDebug("pausing %d - %s", index, m_ActiveDownloads[index]->m_FileName.toUtf8().constData());
|
||||
DownloadInfo *info = m_ActiveDownloads.at(index);
|
||||
|
||||
if (info->m_State == STATE_DOWNLOADING) {
|
||||
setState(info, STATE_PAUSING);
|
||||
qDebug("pausing %d - %s", index, info->m_FileName.toUtf8().constData());
|
||||
} else if ((info->m_State == STATE_FETCHINGMODINFO) || (info->m_State == STATE_FETCHINGFILEINFO)) {
|
||||
setState(info, STATE_READY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,6 +710,14 @@ int DownloadManager::getModID(int index) const
|
||||
return m_ActiveDownloads.at(index)->m_ModID;
|
||||
}
|
||||
|
||||
bool DownloadManager::isHidden(int index) const
|
||||
{
|
||||
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
|
||||
throw MyException(tr("invalid index"));
|
||||
}
|
||||
return m_ActiveDownloads.at(index)->m_Hidden;
|
||||
}
|
||||
|
||||
|
||||
NexusInfo DownloadManager::getNexusInfo(int index) const
|
||||
{
|
||||
@@ -805,6 +856,7 @@ void DownloadManager::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
|
||||
}
|
||||
int oldProgress = info->m_Progress;
|
||||
info->m_Progress = ((info->m_ResumePos + bytesReceived) * 100) / (info->m_ResumePos + bytesTotal);
|
||||
TaskProgressManager::instance().updateProgress(info->m_TaskProgressId, bytesReceived, bytesTotal);
|
||||
if (oldProgress != info->m_Progress) {
|
||||
emit update(index);
|
||||
}
|
||||
@@ -838,6 +890,7 @@ void DownloadManager::createMetaFile(DownloadInfo *info)
|
||||
metaFile.setValue("uninstalled", info->m_State == DownloadManager::STATE_UNINSTALLED);
|
||||
metaFile.setValue("paused", (info->m_State == DownloadManager::STATE_PAUSED) ||
|
||||
(info->m_State == DownloadManager::STATE_ERROR));
|
||||
metaFile.setValue("removed", info->m_Hidden);
|
||||
|
||||
// slightly hackish...
|
||||
for (int i = 0; i < m_ActiveDownloads.size(); ++i) {
|
||||
@@ -946,7 +999,7 @@ void DownloadManager::nxmFilesAvailable(int, QVariant userData, QVariant resultD
|
||||
}
|
||||
|
||||
|
||||
void DownloadManager::nxmFileInfoAvailable(int modID, int fileID, QVariant, QVariant resultData, int requestID)
|
||||
void DownloadManager::nxmFileInfoAvailable(int modID, int fileID, QVariant userData, QVariant resultData, int requestID)
|
||||
{
|
||||
std::set<int>::iterator idIter = m_RequestIDs.find(requestID);
|
||||
if (idIter == m_RequestIDs.end()) {
|
||||
@@ -963,7 +1016,11 @@ void DownloadManager::nxmFileInfoAvailable(int modID, int fileID, QVariant, QVar
|
||||
info.m_Version = result["version"].toString();
|
||||
info.m_FileName = result["uri"].toString();
|
||||
|
||||
m_RequestIDs.insert(m_NexusInterface->requestDownloadURL(modID, fileID, this, qVariantFromValue(info)));
|
||||
if (userData.isValid()) {
|
||||
m_RequestIDs.insert(m_NexusInterface->requestDownloadURL(modID, fileID, this, qVariantFromValue(info), userData.toString()));
|
||||
} else {
|
||||
m_RequestIDs.insert(m_NexusInterface->requestDownloadURL(modID, fileID, this, qVariantFromValue(info)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1105,6 +1162,7 @@ void DownloadManager::downloadFinished()
|
||||
QByteArray data = info->m_Reply->readAll();
|
||||
info->m_Output.write(data);
|
||||
info->m_Output.close();
|
||||
TaskProgressManager::instance().forgetMe(info->m_TaskProgressId);
|
||||
|
||||
bool error = false;
|
||||
|
||||
@@ -1150,7 +1208,9 @@ void DownloadManager::downloadFinished()
|
||||
QVariantMap serverMap = server.toMap();
|
||||
if (serverMap["URI"].toString() == url) {
|
||||
int deltaTime = info->m_StartTime.secsTo(QTime::currentTime());
|
||||
emit downloadSpeed(serverMap["Name"].toString(), (info->m_TotalSize - info->m_PreResumeSize) / deltaTime);
|
||||
if (deltaTime > 5) {
|
||||
emit downloadSpeed(serverMap["Name"].toString(), (info->m_TotalSize - info->m_PreResumeSize) / deltaTime);
|
||||
} // no division by zero please! Also, if the download is shorter than a few seconds, the result is way to inprecise
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+26
-2
@@ -98,10 +98,14 @@ private:
|
||||
int m_Tries;
|
||||
bool m_ReQueried;
|
||||
|
||||
quint32 m_TaskProgressId;
|
||||
|
||||
NexusInfo m_NexusInfo;
|
||||
|
||||
bool m_Hidden;
|
||||
|
||||
static DownloadInfo *createNew(const NexusInfo &nexusInfo, int modID, int fileID, const QStringList &URLs);
|
||||
static DownloadInfo *createFromMeta(const QString &filePath);
|
||||
static DownloadInfo *createFromMeta(const QString &filePath, bool showHidden);
|
||||
|
||||
/**
|
||||
* @brief rename the file
|
||||
@@ -121,7 +125,7 @@ private:
|
||||
private:
|
||||
static unsigned int s_NextDownloadID;
|
||||
private:
|
||||
DownloadInfo() : m_TotalSize(0), m_ReQueried(false) {}
|
||||
DownloadInfo() : m_TotalSize(0), m_ReQueried(false), m_Hidden(false) {}
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -166,6 +170,11 @@ public:
|
||||
*/
|
||||
void setSupportedExtensions(const QStringList &extensions);
|
||||
|
||||
/**
|
||||
* @brief sets whether hidden files are to be shown after all
|
||||
*/
|
||||
void setShowHidden(bool showHidden);
|
||||
|
||||
/**
|
||||
* @brief download from an already open network connection
|
||||
*
|
||||
@@ -261,6 +270,13 @@ public:
|
||||
**/
|
||||
int getModID(int index) const;
|
||||
|
||||
/**
|
||||
* @brief determine if the specified file is supposed to be hidden
|
||||
* @param index index of the file to look up
|
||||
* @return true if the specified file is supposed to be hidden
|
||||
*/
|
||||
bool isHidden(int index) const;
|
||||
|
||||
/**
|
||||
* @brief retrieve all nexus info of the download specified by index
|
||||
*
|
||||
@@ -350,6 +366,12 @@ public slots:
|
||||
**/
|
||||
void removeDownload(int index, bool deleteFile);
|
||||
|
||||
/**
|
||||
* @brief restores the specified download to view (which was previously hidden
|
||||
* @param index index of the download to restore
|
||||
*/
|
||||
void restoreDownload(int index);
|
||||
|
||||
/**
|
||||
* @brief cancel the specified download. This will lead to the corresponding file to be deleted
|
||||
*
|
||||
@@ -434,6 +456,8 @@ private:
|
||||
|
||||
std::map<QString, int> m_DownloadFails;
|
||||
|
||||
bool m_ShowHidden;
|
||||
|
||||
};
|
||||
|
||||
#endif // DOWNLOADMANAGER_H
|
||||
|
||||
@@ -172,16 +172,6 @@ void ExecutablesList::addExecutable(const QString &title, const QString &executa
|
||||
}
|
||||
}
|
||||
|
||||
/*void ExecutablesList::remove(const QString &executableName)
|
||||
{
|
||||
for (std::vector<Executable>::iterator iter = m_Executables.begin(); iter != m_Executables.end(); ++iter) {
|
||||
if (iter->m_Custom && (iter->m_BinaryInfo.absoluteFilePath() == executableName)) {
|
||||
m_Executables.erase(iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
void ExecutablesList::remove(const QString &title)
|
||||
{
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2012 Sebastian Herbord. All rights reserved.
|
||||
|
||||
This file is part of Mod Organizer.
|
||||
|
||||
Mod Organizer is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Mod Organizer is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "finddialog.h"
|
||||
#include "ui_finddialog.h"
|
||||
|
||||
FindDialog::FindDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::FindDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
FindDialog::~FindDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FindDialog::on_nextBtn_clicked()
|
||||
{
|
||||
emit findNext();
|
||||
}
|
||||
|
||||
void FindDialog::on_patternEdit_textChanged(const QString &pattern)
|
||||
{
|
||||
emit patternChanged(pattern);
|
||||
}
|
||||
|
||||
void FindDialog::on_closeBtn_clicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2012 Sebastian Herbord. All rights reserved.
|
||||
|
||||
This file is part of Mod Organizer.
|
||||
|
||||
Mod Organizer is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Mod Organizer is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FINDDIALOG_H
|
||||
#define FINDDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class FindDialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Find dialog used in the TextView dialog
|
||||
**/
|
||||
class FindDialog : public QDialog
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief constructor
|
||||
*
|
||||
* @param parent parent widget
|
||||
**/
|
||||
explicit FindDialog(QWidget *parent = 0);
|
||||
|
||||
~FindDialog();
|
||||
|
||||
signals:
|
||||
|
||||
/**
|
||||
* @brief emitted when the user wants to jump to the next location matching the pattern
|
||||
**/
|
||||
void findNext();
|
||||
|
||||
/**
|
||||
* @brief emitted when the user changes the pattern to search for
|
||||
*
|
||||
* @param pattern the new search pattern
|
||||
**/
|
||||
void patternChanged(const QString &pattern);
|
||||
|
||||
private slots:
|
||||
void on_nextBtn_clicked();
|
||||
|
||||
void on_patternEdit_textChanged(const QString &arg1);
|
||||
|
||||
void on_closeBtn_clicked();
|
||||
|
||||
private:
|
||||
Ui::FindDialog *ui;
|
||||
};
|
||||
|
||||
#endif // FINDDIALOG_H
|
||||
+38
-55
@@ -46,6 +46,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include <QDateTime>
|
||||
#include <QDirIterator>
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
|
||||
using namespace MOBase;
|
||||
@@ -152,7 +153,6 @@ bool InstallationManager::unpackSingleFile(const QString &fileName)
|
||||
if (_wcsicmp(data[i]->getFileName(), ToWString(fileName).c_str()) == 0) {
|
||||
available = true;
|
||||
data[i]->setSkip(false);
|
||||
qDebug("usf %ls -> %s", data[i]->getFileName(), qPrintable(baseName));
|
||||
data[i]->setOutputFileName(ToWString(baseName).c_str());
|
||||
m_TempFilesToDelete.insert(baseName);
|
||||
} else {
|
||||
@@ -184,11 +184,7 @@ qDebug("usf %ls -> %s", data[i]->getFileName(), qPrintable(baseName));
|
||||
QString InstallationManager::extractFile(const QString &fileName)
|
||||
{
|
||||
if (unpackSingleFile(fileName)) {
|
||||
QString tempFileName = QDir::tempPath().append("/").append(QFileInfo(fileName).fileName());
|
||||
|
||||
m_FilesToDelete.insert(tempFileName);
|
||||
|
||||
return tempFileName;
|
||||
return QDir::tempPath().append("/").append(QFileInfo(fileName).fileName());
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
@@ -432,7 +428,7 @@ QString InstallationManager::generateBackupName(const QString &directoryName) co
|
||||
|
||||
bool InstallationManager::testOverwrite(GuessedValue<QString> &modName) const
|
||||
{
|
||||
QString targetDirectory = QDir::fromNativeSeparators(m_ModsDirectory.mid(0).append("\\").append(modName));
|
||||
QString targetDirectory = QDir::fromNativeSeparators(m_ModsDirectory + "\\" + modName);
|
||||
|
||||
while (QDir(targetDirectory).exists()) {
|
||||
QueryOverwriteDialog overwriteDialog(m_ParentWidget);
|
||||
@@ -571,52 +567,39 @@ bool InstallationManager::doInstall(GuessedValue<QString> &modName, int modID,
|
||||
}
|
||||
|
||||
|
||||
void InstallationManager::openFile(const QString &fileName)
|
||||
{
|
||||
unpackSingleFile(fileName);
|
||||
|
||||
QString tempFileName = QDir::tempPath().append("/").append(QFileInfo(fileName).fileName());
|
||||
|
||||
SHELLEXECUTEINFOW execInfo;
|
||||
memset(&execInfo, 0, sizeof(SHELLEXECUTEINFOW));
|
||||
execInfo.cbSize = sizeof(SHELLEXECUTEINFOW);
|
||||
execInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
|
||||
execInfo.lpVerb = L"open";
|
||||
std::wstring fileNameW = ToWString(tempFileName);
|
||||
execInfo.lpFile = fileNameW.c_str();
|
||||
execInfo.nShow = SW_SHOWNORMAL;
|
||||
if (!::ShellExecuteExW(&execInfo)) {
|
||||
qCritical("failed to spawn %s: %d", tempFileName.toUtf8().constData(), ::GetLastError());
|
||||
}
|
||||
|
||||
m_FilesToDelete.insert(tempFileName);
|
||||
}
|
||||
|
||||
|
||||
// copy and pasted from mo_dll
|
||||
bool EndsWith(LPCWSTR string, LPCWSTR subString)
|
||||
{
|
||||
size_t slen = wcslen(string);
|
||||
size_t len = wcslen(subString);
|
||||
if (slen < len) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
if (towlower(string[slen - len + i]) != towlower(subString[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InstallationManager::wasCancelled()
|
||||
{
|
||||
return m_CurrentArchive->getLastError() == Archive::ERROR_EXTRACT_CANCELLED;
|
||||
}
|
||||
|
||||
|
||||
void InstallationManager::postInstallCleanup() const
|
||||
{
|
||||
m_CurrentArchive->close();
|
||||
|
||||
// directories we may want to remove. sorted from longest to shortest to ensure we remove subdirectories first.
|
||||
auto longestFirst = [](const QString &LHS, const QString &RHS) -> bool {
|
||||
if (LHS.size() != RHS.size()) return LHS.size() > RHS.size();
|
||||
else return LHS < RHS;
|
||||
};
|
||||
|
||||
std::set<QString, std::function<bool(const QString&, const QString&)>> directoriesToRemove(longestFirst);
|
||||
|
||||
// clean up temp files
|
||||
// TODO: this doesn't yet remove directories. Also, the files may be left there if this point isn't reached
|
||||
foreach (const QString &tempFile, m_TempFilesToDelete) {
|
||||
QFileInfo fileInfo(QDir::tempPath() + "/" + tempFile);
|
||||
QFile::remove(fileInfo.absoluteFilePath());
|
||||
directoriesToRemove.insert(fileInfo.absolutePath());
|
||||
}
|
||||
|
||||
// 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) {
|
||||
QDir().rmdir(dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool InstallationManager::install(const QString &fileName, GuessedValue<QString> &modName, bool &hasIniTweaks)
|
||||
{
|
||||
QFileInfo fileInfo(fileName);
|
||||
@@ -665,19 +648,19 @@ bool InstallationManager::install(const QString &fileName, GuessedValue<QString>
|
||||
modName.update(guessedModName, GUESS_GOOD);
|
||||
}
|
||||
|
||||
qDebug("using mod name \"%s\" (id %d)", modName->toUtf8().constData(), modID);
|
||||
m_CurrentFile = fileInfo.fileName();
|
||||
m_CurrentFile = fileInfo.absoluteFilePath();
|
||||
if (fileInfo.dir() == QDir(ToQString(GameInfo::instance().getDownloadDir()))) {
|
||||
m_CurrentFile = fileInfo.fileName();
|
||||
}
|
||||
qDebug("using mod name \"%s\" (id %d) -> %s", modName->toUtf8().constData(), modID, qPrintable(m_CurrentFile));
|
||||
|
||||
// open the archive and construct the directory tree the installers work on
|
||||
bool archiveOpen = m_CurrentArchive->open(ToWString(QDir::toNativeSeparators(fileName)).c_str(),
|
||||
new MethodCallback<InstallationManager, void, LPSTR>(this, &InstallationManager::queryPassword));
|
||||
|
||||
ON_BLOCK_EXIT([this] {
|
||||
this->m_CurrentArchive->close();
|
||||
});
|
||||
|
||||
DirectoryTree *filesTree = archiveOpen ? createFilesTree() : NULL;
|
||||
ON_BLOCK_EXIT(std::bind(&InstallationManager::postInstallCleanup, this));
|
||||
|
||||
QScopedPointer<DirectoryTree> filesTree(archiveOpen ? createFilesTree() : NULL);
|
||||
IPluginInstaller::EInstallResult installResult = IPluginInstaller::RESULT_NOTATTEMPTED;
|
||||
|
||||
std::sort(m_Installers.begin(), m_Installers.end(), [] (IPluginInstaller *LHS, IPluginInstaller *RHS) {
|
||||
@@ -702,7 +685,7 @@ bool InstallationManager::install(const QString &fileName, GuessedValue<QString>
|
||||
(filesTree != NULL) && (installer->isArchiveSupported(*filesTree))) {
|
||||
installResult = installerSimple->install(modName, *filesTree, version, modID);
|
||||
if (installResult == IPluginInstaller::RESULT_SUCCESS) {
|
||||
mapToArchive(filesTree);
|
||||
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)) {
|
||||
installResult = IPluginInstaller::RESULT_FAILED;
|
||||
|
||||
@@ -57,6 +57,11 @@ public:
|
||||
|
||||
~InstallationManager();
|
||||
|
||||
/**
|
||||
* @brief update the directory where mods are to be installed
|
||||
* @param modsDirectory the mod directory
|
||||
* @note this is called a lot, probably redundantly
|
||||
*/
|
||||
void setModsDirectory(const QString &modsDirectory) { m_ModsDirectory = modsDirectory; }
|
||||
|
||||
/**
|
||||
@@ -163,9 +168,7 @@ private:
|
||||
|
||||
bool ensureValidModName(MOBase::GuessedValue<QString> &name) const;
|
||||
|
||||
private slots:
|
||||
|
||||
void openFile(const QString &fileName);
|
||||
void postInstallCleanup() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -197,7 +200,6 @@ private:
|
||||
|
||||
QProgressDialog m_InstallationProgress;
|
||||
|
||||
std::set<QString> m_FilesToDelete;
|
||||
std::set<QString> m_TempFilesToDelete;
|
||||
|
||||
};
|
||||
|
||||
+58
-55
@@ -18,6 +18,11 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef LEAK_CHECK_WITH_VLD
|
||||
#include <wchar.h>
|
||||
#include <vld.h>
|
||||
#endif // LEAK_CHECK_WITH_VLD
|
||||
|
||||
#include <QApplication>
|
||||
#include <QPushButton>
|
||||
#include <QListWidget>
|
||||
@@ -182,16 +187,7 @@ void cleanupDir()
|
||||
"QtXml4.dll",
|
||||
"QtWebKit4.dll",
|
||||
"qjpeg4.dll",
|
||||
/* "dlls/phonon4.dll",
|
||||
"dlls/QtCore4.dll",
|
||||
"dlls/QtGui4.dll",
|
||||
"dlls/QtNetwork4.dll",
|
||||
"dlls/QtXml4.dll",
|
||||
"dlls/QtXmlPatterns4.dll",
|
||||
"dlls/QtWebKit4.dll",
|
||||
"dlls/QtDeclarative4.dll",
|
||||
"dlls/QtScript4.dll",
|
||||
"dlls/QtSql4.dll"*/
|
||||
"NCC/GamebryoBase.dll"
|
||||
};
|
||||
|
||||
static const int NUM_FILES = sizeof(fileNames) / sizeof(QString);
|
||||
@@ -352,7 +348,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
bool done = false;
|
||||
while (!done) {
|
||||
if (!GameInfo::init(moPath, ToWString(gamePath))) {
|
||||
if (!GameInfo::init(moPath, ToWString(QDir::toNativeSeparators(gamePath)))) {
|
||||
if (!gamePath.isEmpty()) {
|
||||
reportError(QObject::tr("No game identified in \"%1\". The directory is required to contain "
|
||||
"the game binary and its launcher.").arg(gamePath));
|
||||
@@ -437,63 +433,70 @@ int main(int argc, char *argv[])
|
||||
qDebug("initializing tutorials");
|
||||
TutorialManager::init(QDir::fromNativeSeparators(ToQString(GameInfo::instance().getTutorialDir())).append("/"));
|
||||
|
||||
application.setStyleFile(settings.value("Settings/style", "").toString());
|
||||
if (!application.setStyleFile(settings.value("Settings/style", "").toString())) {
|
||||
// disable invalid stylesheet
|
||||
settings.setValue("Settings/style", "");
|
||||
}
|
||||
|
||||
// set up main window and its data structures
|
||||
MainWindow mainWindow(argv[0], settings);
|
||||
QObject::connect(&mainWindow, SIGNAL(styleChanged(QString)), &application, SLOT(setStyleFile(QString)));
|
||||
QObject::connect(&instance, SIGNAL(messageSent(QString)), &mainWindow, SLOT(externalMessage(QString)));
|
||||
int res = 1;
|
||||
{ // scope to control lifetime of mainwindow
|
||||
// set up main window and its data structures
|
||||
MainWindow mainWindow(argv[0], settings);
|
||||
QObject::connect(&mainWindow, SIGNAL(styleChanged(QString)), &application, SLOT(setStyleFile(QString)));
|
||||
QObject::connect(&instance, SIGNAL(messageSent(QString)), &mainWindow, SLOT(externalMessage(QString)));
|
||||
|
||||
mainWindow.setExecutablesList(executablesList);
|
||||
mainWindow.readSettings();
|
||||
mainWindow.setExecutablesList(executablesList);
|
||||
mainWindow.readSettings();
|
||||
|
||||
QString selectedProfileName = QString::fromUtf8(settings.value("selected_profile", "").toByteArray());
|
||||
QString selectedProfileName = QString::fromUtf8(settings.value("selected_profile", "").toByteArray());
|
||||
|
||||
{ // see if there is a profile on the command line
|
||||
int profileIndex = arguments.indexOf("-p", 1);
|
||||
if ((profileIndex != -1) && (profileIndex < arguments.size() - 1)) {
|
||||
qDebug("profile overwritten on command line");
|
||||
selectedProfileName = arguments.at(profileIndex + 1);
|
||||
{ // see if there is a profile on the command line
|
||||
int profileIndex = arguments.indexOf("-p", 1);
|
||||
if ((profileIndex != -1) && (profileIndex < arguments.size() - 1)) {
|
||||
qDebug("profile overwritten on command line");
|
||||
selectedProfileName = arguments.at(profileIndex + 1);
|
||||
}
|
||||
arguments.removeAt(profileIndex);
|
||||
arguments.removeAt(profileIndex);
|
||||
}
|
||||
arguments.removeAt(profileIndex);
|
||||
arguments.removeAt(profileIndex);
|
||||
}
|
||||
qDebug("configured profile: %s", qPrintable(selectedProfileName));
|
||||
qDebug("configured profile: %s", qPrintable(selectedProfileName));
|
||||
|
||||
// if we have a command line parameter, it is either a nxm link or
|
||||
// a binary to start
|
||||
if ((arguments.size() > 1) && (!isNxmLink(arguments.at(1)))) {
|
||||
QString exeName = arguments.at(1);
|
||||
qDebug("starting %s from command line", qPrintable(exeName));
|
||||
arguments.removeFirst(); // remove application name (ModOrganizer.exe)
|
||||
arguments.removeFirst(); // remove binary name
|
||||
// pass the remaining parameters to the binary
|
||||
mainWindow.spawnProgram(exeName, arguments.join(" "), selectedProfileName, QDir());
|
||||
return 0;
|
||||
}
|
||||
// if we have a command line parameter, it is either a nxm link or
|
||||
// a binary to start
|
||||
if ((arguments.size() > 1) && (!isNxmLink(arguments.at(1)))) {
|
||||
QString exeName = arguments.at(1);
|
||||
qDebug("starting %s from command line", qPrintable(exeName));
|
||||
arguments.removeFirst(); // remove application name (ModOrganizer.exe)
|
||||
arguments.removeFirst(); // remove binary name
|
||||
// pass the remaining parameters to the binary
|
||||
mainWindow.startApplication(exeName, arguments, QString(), selectedProfileName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
mainWindow.createFirstProfile();
|
||||
mainWindow.createFirstProfile();
|
||||
|
||||
if (selectedProfileName.length() != 0) {
|
||||
if (!mainWindow.setCurrentProfile(selectedProfileName)) {
|
||||
if (selectedProfileName.length() != 0) {
|
||||
if (!mainWindow.setCurrentProfile(selectedProfileName)) {
|
||||
mainWindow.setCurrentProfile(1);
|
||||
qWarning("failed to set profile: %s",
|
||||
selectedProfileName.toUtf8().constData());
|
||||
}
|
||||
} else {
|
||||
mainWindow.setCurrentProfile(1);
|
||||
qWarning("failed to set profile: %s",
|
||||
selectedProfileName.toUtf8().constData());
|
||||
}
|
||||
} else {
|
||||
mainWindow.setCurrentProfile(1);
|
||||
}
|
||||
|
||||
qDebug("displaying main window");
|
||||
mainWindow.show();
|
||||
qDebug("displaying main window");
|
||||
mainWindow.show();
|
||||
|
||||
if ((arguments.size() > 1) &&
|
||||
(isNxmLink(arguments.at(1)))) {
|
||||
qDebug("starting download from command line: %s", qPrintable(arguments.at(1)));
|
||||
mainWindow.externalMessage(arguments.at(1));
|
||||
if ((arguments.size() > 1) &&
|
||||
(isNxmLink(arguments.at(1)))) {
|
||||
qDebug("starting download from command line: %s", qPrintable(arguments.at(1)));
|
||||
mainWindow.externalMessage(arguments.at(1));
|
||||
}
|
||||
splash.finish(&mainWindow);
|
||||
res = application.exec();
|
||||
}
|
||||
splash.finish(&mainWindow);
|
||||
return application.exec();
|
||||
return res;
|
||||
} catch (const std::exception &e) {
|
||||
reportError(e.what());
|
||||
return 1;
|
||||
|
||||
+318
-61
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user