From ba176e5e9b639ac0770192987833a3b40e71409a Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sun, 13 Dec 2015 18:30:40 +0000 Subject: Remove dependency of TransferSave on SaveGameBryo, part of fix for #418 Added a method to Profile class to get location of save games for the profile. I haven't added this to IProfile as am in two minds. Aside from this have done cleanups of issues suggested by include-what-you-use, and some OCD sorting of #includes --- src/aboutdialog.cpp | 8 + src/aboutdialog.h | 7 +- src/iuserinterface.h | 1 + src/mainwindow.cpp | 2 +- src/profile.cpp | 36 ++-- src/profile.h | 19 +- src/profilesdialog.cpp | 24 ++- src/profilesdialog.h | 15 +- src/transfersavesdialog.cpp | 409 ++++++++++++++++++++++---------------------- src/transfersavesdialog.h | 34 +++- 10 files changed, 314 insertions(+), 241 deletions(-) (limited to 'src') diff --git a/src/aboutdialog.cpp b/src/aboutdialog.cpp index 6fce2acb..3657a10d 100644 --- a/src/aboutdialog.cpp +++ b/src/aboutdialog.cpp @@ -22,6 +22,14 @@ along with Mod Organizer. If not, see . #include "ui_aboutdialog.h" #include +#include +#include +#include +#include +#include +#include +#include + AboutDialog::AboutDialog(const QString &version, QWidget *parent) : QDialog(parent) diff --git a/src/aboutdialog.h b/src/aboutdialog.h index c3b38c10..103a0d2f 100644 --- a/src/aboutdialog.h +++ b/src/aboutdialog.h @@ -22,10 +22,11 @@ along with Mod Organizer. If not, see . #define ABOUTDIALOG_H #include -#include +class QListWidgetItem; +#include +#include + #include -#include -#include namespace Ui { class AboutDialog; diff --git a/src/iuserinterface.h b/src/iuserinterface.h index bcf800b7..e03bcde2 100644 --- a/src/iuserinterface.h +++ b/src/iuserinterface.h @@ -7,6 +7,7 @@ #include #include +class QSettings; class IUserInterface { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f30e46f1..a85a0fb3 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1262,7 +1262,7 @@ QDir MainWindow::currentSavesDir() const { QDir savesDir; if (m_OrganizerCore.currentProfile()->localSavesEnabled()) { - savesDir.setPath(m_OrganizerCore.currentProfile()->absolutePath() + "/saves"); + savesDir.setPath(m_OrganizerCore.currentProfile()->savePath()); } else { wchar_t path[MAX_PATH]; ::GetPrivateProfileStringW( diff --git a/src/profile.cpp b/src/profile.cpp index 77f6ebd1..b0b8db46 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -19,30 +19,40 @@ along with Mod Organizer. If not, see . #include "profile.h" -#include "windows_error.h" #include "modinfo.h" #include "safewritefile.h" #include -#include #include -#include +#include "appconfig.h" #include #include #include #include -#include #include -#include -#include +#include // for QFile +#include // for operator|, QFlags +#include // for QIODevice, etc +#include +#include +#include // for QStringList +#include // for qDebug, qWarning, etc +#include // for qPrintable + +#include +#include // for assert +#include // for UINT_MAX, INT_MAX, etc +#include // for size_t +#include // for wcslen + +#include // for max, min +#include // for exception #include +#include // for set +#include // for find #include -#define WIN32_LEAN_AND_MEAN -#include -#include - using namespace MOBase; using namespace MOShared; @@ -687,6 +697,12 @@ QString Profile::absolutePath() const return QDir::cleanPath(m_Directory.absolutePath()); } +QString Profile::savePath() const +{ + return QDir::cleanPath(m_Directory.absoluteFilePath("saves")); + +} + void Profile::rename(const QString &newName) { QDir profileDir(qApp->property("dataPath").toString() + "/" + QString::fromStdWString(AppConfig::profilesPath())); diff --git a/src/profile.h b/src/profile.h index e33ac674..39e8ff5f 100644 --- a/src/profile.h +++ b/src/profile.h @@ -25,12 +25,16 @@ along with Mod Organizer. If not, see . #include #include -#include +#include #include -#include +#include +#include -#include +#include + +#include #include +#include namespace MOBase { class IPluginGame; } @@ -172,6 +176,15 @@ public: **/ QString absolutePath() const; + /** + * @return path to this profile's save games + **/ + QString savePath() const; + + /** + * @brief rename profile + * @param newName new name of profile + */ void rename(const QString &newName); /** diff --git a/src/profilesdialog.cpp b/src/profilesdialog.cpp index b21aee53..4d0b3389 100644 --- a/src/profilesdialog.cpp +++ b/src/profilesdialog.cpp @@ -19,22 +19,28 @@ along with Mod Organizer. If not, see . #include "profilesdialog.h" #include "ui_profilesdialog.h" + +#include "appconfig.h" +#include "bsainvalidation.h" +#include "iplugingame.h" +#include "profile.h" +#include "profileinputdialog.h" #include "report.h" -#include "utility.h" #include "transfersavesdialog.h" -#include "profileinputdialog.h" -#include "mainwindow.h" -#include "aboutdialog.h" -#include -#include -#include -#include +#include "utility.h" + +#include +#include +#include #include #include -#include +#include #include #include +#include + +#include using namespace MOBase; using namespace MOShared; diff --git a/src/profilesdialog.h b/src/profilesdialog.h index 073d92b7..0e79b94b 100644 --- a/src/profilesdialog.h +++ b/src/profilesdialog.h @@ -21,17 +21,16 @@ along with Mod Organizer. If not, see . #define PROFILESDIALOG_H #include "tutorabledialog.h" -#include -#include "profile.h" +class Profile; +class QListWidget; +class QListWidgetItem; +#include +class QString; -namespace Ui { - class ProfilesDialog; -} +namespace Ui { class ProfilesDialog; } -namespace MOBase { - class IPluginGame; -} +namespace MOBase { class IPluginGame; } /** diff --git a/src/transfersavesdialog.cpp b/src/transfersavesdialog.cpp index 48fc4548..710a33b9 100644 --- a/src/transfersavesdialog.cpp +++ b/src/transfersavesdialog.cpp @@ -21,19 +21,70 @@ along with Mod Organizer. If not, see . #include "ui_transfersavesdialog.h" #include "iplugingame.h" -#include "savegamegamebyro.h" -#include "utility.h" +#include "isavegame.h" +#include "savegameinfo.h" +#include "scriptextender.h" +#include +#include #include +#include +#include +#include +#include +#include +#include #include +#include +#include -#include -#include - +class QWidget; //Do we /really/ need this? using namespace MOBase; using namespace MOShared; +//These two classes give the save-transfer box a smidgin of useful info even +//if save game isn't supported yet. +namespace { + +class DummySave : public ISaveGame +{ +public: + DummySave(QString const &filename) : + m_File(filename) + {} + + ~DummySave() {} + + virtual QString getFilename() const override + { + return m_File; + } + + virtual QDateTime getCreationTime() const override + { + return QFileInfo(m_File).created(); + } + + virtual QString getIdentifier() const override + { + return m_File; + } + +private: + QString m_File; +}; + +class DummyInfo : public SaveGameInfo +{ +public: + virtual MOBase::ISaveGame const *getSaveGameInfo(QString const &file) const override + { + return new DummySave(file); + } +}; + +} //end anonymous namespace TransferSavesDialog::TransferSavesDialog(const Profile &profile, IPluginGame const *gamePlugin, QWidget *parent) : TutorableDialog("TransferSaves", parent) @@ -42,6 +93,7 @@ TransferSavesDialog::TransferSavesDialog(const Profile &profile, IPluginGame con , m_GamePlugin(gamePlugin) { ui->setupUi(this); + ui->label_2->setText(tr("Characters for profile %1").arg(m_Profile.name())); refreshGlobalSaves(); refreshLocalSaves(); refreshGlobalCharacters(); @@ -53,84 +105,27 @@ TransferSavesDialog::~TransferSavesDialog() delete ui; } - void TransferSavesDialog::refreshGlobalSaves() { - m_GlobalSaves.clear(); - QDir savesDir(m_GamePlugin->savesDirectory()); - savesDir.setNameFilters(QStringList() << QString("*.%1").arg(m_GamePlugin->savegameExtension())); - - QStringList files = savesDir.entryList(QDir::Files, QDir::Time); - - for (const QString &filename : files) { - SaveGameGamebryo *save = new SaveGameGamebryo(this, savesDir.absoluteFilePath(filename), m_GamePlugin); - save->setParent(this); - m_GlobalSaves.push_back(save); - } + refreshSaves(m_GlobalSaves, m_GamePlugin->savesDirectory().absolutePath()); } void TransferSavesDialog::refreshLocalSaves() { - m_LocalSaves.clear(); - - QDir savesDir(m_Profile.absolutePath() + "/saves"); - - savesDir.setNameFilters(QStringList() << QString("*.%1").arg(m_GamePlugin->savegameExtension())); - - QStringList files = savesDir.entryList(QDir::Files, QDir::Time); - - foreach (const QString &filename, files) { - SaveGameGamebryo *save = new SaveGameGamebryo(this, savesDir.absoluteFilePath(filename), m_GamePlugin); - save->setParent(this); - m_LocalSaves.push_back(save); - } + refreshSaves(m_LocalSaves, m_Profile.savePath()); } void TransferSavesDialog::refreshGlobalCharacters() { - std::set characters; - for (std::vector::const_iterator iter = m_GlobalSaves.begin(); - iter != m_GlobalSaves.end(); ++iter) { - characters.insert((*iter)->pcName()); - } - ui->globalCharacterList->clear(); - for (std::set::const_iterator iter = characters.begin(); - iter != characters.end(); ++iter) { - ui->globalCharacterList->addItem(*iter); - } - if (ui->globalCharacterList->count() > 0) { - ui->globalCharacterList->setCurrentRow(0); - ui->copyToLocalBtn->setEnabled(true); - ui->moveToLocalBtn->setEnabled(true); - } else { - ui->copyToLocalBtn->setEnabled(false); - ui->moveToLocalBtn->setEnabled(false); - } + refreshCharacters(m_GlobalSaves, ui->globalCharacterList, ui->copyToLocalBtn, ui->moveToLocalBtn); } void TransferSavesDialog::refreshLocalCharacters() { - std::set characters; - for (std::vector::const_iterator iter = m_LocalSaves.begin(); - iter != m_LocalSaves.end(); ++iter) { - characters.insert((*iter)->pcName()); - } - ui->localCharacterList->clear(); - for (std::set::const_iterator iter = characters.begin(); - iter != characters.end(); ++iter) { - ui->localCharacterList->addItem(*iter); - } - if (ui->localCharacterList->count() > 0) { - ui->localCharacterList->setCurrentRow(0); - ui->copyToGlobalBtn->setEnabled(true); - ui->moveToGlobalBtn->setEnabled(true); - } else { - ui->copyToGlobalBtn->setEnabled(false); - ui->moveToGlobalBtn->setEnabled(false); - } + refreshCharacters(m_LocalSaves, ui->localCharacterList, ui->copyToGlobalBtn, ui->moveToGlobalBtn); } @@ -152,153 +147,71 @@ bool TransferSavesDialog::testOverwrite(OverwriteMode &overwriteMode, const QStr return res == QMessageBox::Yes; } +#define MOVE_SAVES "Move all save games of character \"%1\"" +#define COPY_SAVES "Copy all save games of character \"%1\"" + +#define TO_PROFILE "to the profile?" +#define TO_GLOBAL "to the global location? Please be aware that this will mess up the running number of save games." + 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), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { - QString destination = m_Profile.absolutePath() + "/saves"; - OverwriteMode overwriteMode = OVERWRITE_ASK; - - for (std::vector::const_iterator iter = m_GlobalSaves.begin(); - iter != m_GlobalSaves.end(); ++iter) { - if ((*iter)->pcName() == selectedCharacter) { - QStringList files = (*iter)->saveFiles(); - foreach (const QString &file, files) { - QFileInfo fileInfo(file); - QString destinationFile = destination + "/" + fileInfo.fileName(); - if (QFile::exists(destinationFile)) { - if (testOverwrite(overwriteMode, destinationFile)) { - QFile::remove(destinationFile); - } else { - continue; - } - } - if (!QFile::rename(fileInfo.absoluteFilePath(), destinationFile)) { - qCritical("failed to move %s to %s", - fileInfo.absoluteFilePath().toUtf8().constData(), - destinationFile.toUtf8().constData()); - } - } - } - } + QString character = ui->globalCharacterList->currentItem()->text(); + if (transferCharacters(character, + MOVE_SAVES TO_PROFILE, + m_GlobalSaves[character], + m_Profile.savePath(), + QFile::rename, + "Failed to move %s to %s")) + { + refreshGlobalSaves(); + refreshGlobalCharacters(); + refreshLocalSaves(); + refreshLocalCharacters(); } - refreshGlobalSaves(); - refreshGlobalCharacters(); - refreshLocalSaves(); - refreshLocalCharacters(); } void TransferSavesDialog::on_copyToLocalBtn_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), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { - QString destination = m_Profile.absolutePath() + "/saves"; - OverwriteMode overwriteMode = OVERWRITE_ASK; - for (std::vector::const_iterator iter = m_GlobalSaves.begin(); - iter != m_GlobalSaves.end(); ++iter) { - if ((*iter)->pcName() == selectedCharacter) { - QStringList files = (*iter)->saveFiles(); - foreach (const QString &file, files) { - QFileInfo fileInfo(file); - QString destinationFile = destination + "/" + fileInfo.fileName(); - if (QFile::exists(destinationFile)) { - if (testOverwrite(overwriteMode, destinationFile)) { - QFile::remove(destinationFile); - } else { - continue; - } - } - if (!QFile::copy(fileInfo.absoluteFilePath(), destinationFile)) { - qCritical("failed to copy %s to %s", - fileInfo.absoluteFilePath().toUtf8().constData(), - destinationFile.toUtf8().constData()); - } - } - } - } + QString character = ui->globalCharacterList->currentItem()->text(); + if (transferCharacters(character, + COPY_SAVES TO_PROFILE, + m_GlobalSaves[character], + m_Profile.savePath(), + QFile::copy, + "Failed to copy %s to %s")) { + refreshLocalSaves(); + refreshLocalCharacters(); } - refreshLocalSaves(); - refreshLocalCharacters(); } void TransferSavesDialog::on_moveToGlobalBtn_clicked() { - QString selectedCharacter = ui->localCharacterList->currentItem()->text(); - if (QMessageBox::question(this, tr("Confirm"), - tr("Move all save games of character \"%1\" to the global location? Please be aware " - "that this will mess up the running number of save games.").arg(selectedCharacter), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { - - QDir destination = m_GamePlugin->savesDirectory(); - OverwriteMode overwriteMode = OVERWRITE_ASK; - for (std::vector::const_iterator iter = m_LocalSaves.begin(); - iter != m_LocalSaves.end(); ++iter) { - if ((*iter)->pcName() == selectedCharacter) { - QStringList files = (*iter)->saveFiles(); - foreach (const QString &file, files) { - QFileInfo fileInfo(file); - QString destinationFile = destination.filePath(fileInfo.fileName()); - if (QFile::exists(destinationFile)) { - if (testOverwrite(overwriteMode, destinationFile)) { - QFile::remove(destinationFile); - } else { - continue; - } - } - if (!QFile::rename(fileInfo.absoluteFilePath(), destinationFile)) { - qCritical("failed to move %s to %s", - fileInfo.absoluteFilePath().toUtf8().constData(), - destinationFile.toUtf8().constData()); - } - } - } - } + QString character = ui->localCharacterList->currentItem()->text(); + if (transferCharacters(character, + MOVE_SAVES TO_GLOBAL, + m_LocalSaves[character], + m_GamePlugin->savesDirectory().absolutePath(), + QFile::rename, + "Failed to move %s to %s")) { + refreshGlobalSaves(); + refreshGlobalCharacters(); + refreshLocalSaves(); + refreshLocalCharacters(); } - refreshGlobalSaves(); - refreshGlobalCharacters(); - refreshLocalSaves(); - refreshLocalCharacters(); } void TransferSavesDialog::on_copyToGlobalBtn_clicked() { - QString selectedCharacter = ui->localCharacterList->currentItem()->text(); - if (QMessageBox::question(this, tr("Confirm"), - tr("Copy all save games of character \"%1\" to the global location? Please be aware " - "that this will mess up the running number of save games.").arg(selectedCharacter), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { - - QDir destination = m_GamePlugin->savesDirectory(); - OverwriteMode overwriteMode = OVERWRITE_ASK; - for (std::vector::const_iterator iter = m_LocalSaves.begin(); - iter != m_LocalSaves.end(); ++iter) { - if ((*iter)->pcName() == selectedCharacter) { - QStringList files = (*iter)->saveFiles(); - foreach (const QString &file, files) { - QFileInfo fileInfo(file); - QString destinationFile = destination.filePath(fileInfo.fileName()); - if (QFile::exists(destinationFile)) { - if (testOverwrite(overwriteMode, destinationFile)) { - QFile::remove(destinationFile); - } else { - continue; - } - } - if (!QFile::copy(fileInfo.absoluteFilePath(), destinationFile)) { - qCritical("failed to copy %s to %s", - fileInfo.absoluteFilePath().toUtf8().constData(), - destinationFile.toUtf8().constData()); - } - } - } - } + QString character = ui->localCharacterList->currentItem()->text(); + if (transferCharacters(character, + COPY_SAVES TO_GLOBAL, + m_LocalSaves[character], + m_GamePlugin->savesDirectory().absolutePath(), + QFile::copy, + "Failed to copy %s to %s")) { + refreshGlobalSaves(); + refreshGlobalCharacters(); } - refreshGlobalSaves(); - refreshGlobalCharacters(); } void TransferSavesDialog::on_doneButton_clicked() @@ -309,10 +222,12 @@ void TransferSavesDialog::on_doneButton_clicked() void TransferSavesDialog::on_globalCharacterList_currentTextChanged(const QString ¤tText) { ui->globalSavesList->clear(); - for (std::vector::const_iterator iter = m_GlobalSaves.begin(); - iter != m_GlobalSaves.end(); ++iter) { - if ((*iter)->pcName() == currentText) { - ui->globalSavesList->addItem(QFileInfo((*iter)->fileName()).fileName()); + //sadly this can get called while we're resetting the list, with an invalid + //name, so we have to check. + SaveCollection::const_iterator saveList = m_GlobalSaves.find(currentText); + if (saveList != m_GlobalSaves.end()) { + for (SaveListItem const &save : saveList->second) { + ui->globalSavesList->addItem(QFileInfo(save->getFilename()).fileName()); } } } @@ -320,10 +235,98 @@ void TransferSavesDialog::on_globalCharacterList_currentTextChanged(const QStrin void TransferSavesDialog::on_localCharacterList_currentTextChanged(const QString ¤tText) { ui->localSavesList->clear(); - for (std::vector::const_iterator iter = m_LocalSaves.begin(); - iter != m_LocalSaves.end(); ++iter) { - if ((*iter)->pcName() == currentText) { - ui->localSavesList->addItem(QFileInfo((*iter)->fileName()).fileName()); + //sadly this can get called while we're resetting the list, with an invalid + //name, so we have to check. + SaveCollection::const_iterator saveList = m_LocalSaves.find(currentText); + if (saveList != m_LocalSaves.end()) { + for (SaveListItem const &save : saveList->second) { + ui->localSavesList->addItem(QFileInfo(save->getFilename()).fileName()); + } + } +} + +void TransferSavesDialog::refreshSaves(SaveCollection &saveCollection, QString const &savedir) +{ + saveCollection.clear(); + QDir savesDir(savedir); + savesDir.setNameFilters(QStringList() << QString("*.%1").arg(m_GamePlugin->savegameExtension())); + + SaveGameInfo const *info = m_GamePlugin->feature(); + if (info == nullptr) { + static DummyInfo dummyInfo; + info = &dummyInfo; + } + + QStringList files = savesDir.entryList(QDir::Files, QDir::Time); + for (const QString &filename : files) { + QString file = savesDir.absoluteFilePath(filename); + MOBase::ISaveGame const *save = info->getSaveGameInfo(file); + saveCollection[save->getIdentifier()].push_back( + std::unique_ptr(save)); + } +} + +void TransferSavesDialog::refreshCharacters(const SaveCollection &saveCollection, + QListWidget *charList, QPushButton *copy, QPushButton *move) +{ + charList->clear(); + for (SaveCollection::value_type const &val : saveCollection) { + charList->addItem(val.first); + } + if (charList->count() > 0) { + charList->setCurrentRow(0); + copy->setEnabled(true); + move->setEnabled(true); + } else { + copy->setEnabled(false); + move->setEnabled(false); + } +} + +bool TransferSavesDialog::transferCharacters(QString const &character, + char const *message, + SaveList &saves, + QString const &dest, + bool (method)(QString const &, QString const &), + char const *errmsg) +{ + if (QMessageBox::question(this, tr("Confirm"), + tr(message).arg(character), + QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) { + return false; + } + + OverwriteMode overwriteMode = OVERWRITE_ASK; + + QStringList extensions = { m_GamePlugin->savegameExtension() }; + { + ScriptExtender *ext = m_GamePlugin->feature(); + if (ext != nullptr) { + extensions += ext->saveGameAttachmentExtensions(); + } + } + QDir destination(dest); + for (SaveListItem const &save : saves) { + QFileInfo const saveFile = save->getFilename(); + for (QString const &ext : extensions) { + QFileInfo sourceFile(saveFile.absoluteDir().absoluteFilePath(saveFile.completeBaseName() + "." + ext)); + QString destinationFile = destination.absoluteFilePath(sourceFile.fileName()); + + //If the file is already there, let them skip (or not). + if (QFile::exists(destinationFile)) { + if (! testOverwrite(overwriteMode, destinationFile)) { + continue; + } + //OK, they want to remove it. + QFile::remove(destinationFile); + } + + if (! method(sourceFile.absoluteFilePath(), destinationFile)) { + qCritical(errmsg, + sourceFile.absoluteFilePath().toUtf8().constData(), + destinationFile.toUtf8().constData()); + } } } + return true; } diff --git a/src/transfersavesdialog.h b/src/transfersavesdialog.h index e2c556b4..d3f079e3 100644 --- a/src/transfersavesdialog.h +++ b/src/transfersavesdialog.h @@ -23,10 +23,19 @@ along with Mod Organizer. If not, see . #include "tutorabledialog.h" #include "profile.h" +class QListWidget; +#include +class QPushButton; +#include +class QWidget; + +#include +#include +#include + namespace Ui { class TransferSavesDialog; } namespace MOBase { class IPluginGame; } - -class SaveGame; +namespace MOBase { class ISaveGame; } class TransferSavesDialog : public MOBase::TutorableDialog { @@ -76,8 +85,25 @@ private: MOBase::IPluginGame const *m_GamePlugin; - std::vector m_GlobalSaves; - std::vector m_LocalSaves; + typedef std::unique_ptr SaveListItem; + typedef std::vector SaveList; + typedef std::map SaveCollection; + SaveCollection m_GlobalSaves; + SaveCollection m_LocalSaves; + + void refreshSaves(SaveCollection &saveCollection, const QString &savedir); + void refreshCharacters(SaveCollection const &saveCollection, + QListWidget *charList, + QPushButton *copy, + QPushButton *move); + + bool transferCharacters(QString const &character, + char const *message, + SaveList &saves, + QString const &dest, + bool (method)(QString const &, QString const &), + char const *errmsg + ); }; -- cgit v1.3.1 From 967c2ae653b54bfc61c3854294f7b1cbff76809b Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Mon, 14 Dec 2015 22:25:57 +0000 Subject: Removes the SaveGame class from mainwindow. Using include what you use to add/remove #includes --- massage_messages.py | 14 ++++- src/mainwindow.cpp | 122 +++++++++++++++++++++++++------------ src/mainwindow.h | 101 +++++++++++++++++++----------- src/organizer.pro | 4 +- src/savegame.cpp | 38 ------------ src/savegame.h | 14 +---- src/savegamegamebryo.cpp | 2 +- src/savegamegamebryo.h | 78 ++++++++++++++++++++++++ src/savegamegamebyro.h | 77 ----------------------- src/savegameinfowidgetgamebryo.cpp | 2 +- 10 files changed, 243 insertions(+), 209 deletions(-) create mode 100644 src/savegamegamebryo.h delete mode 100644 src/savegamegamebyro.h (limited to 'src') diff --git a/massage_messages.py b/massage_messages.py index d79f4cea..0a3ee9ad 100644 --- a/massage_messages.py +++ b/massage_messages.py @@ -36,6 +36,7 @@ includes = dict() adding = None added = dict() +lcadded = dict() foundline = None @@ -70,6 +71,7 @@ def process_next_line(line, outfile): m = re.match(r'.*class (.*);', line) if m: added[m.group(1)] = (adding, line) + lcadded[m.group(1).lower() + '.h'] = m.group(1) else: added[line] = (adding, line) elif removing: @@ -79,12 +81,18 @@ def process_next_line(line, outfile): m = re.match(r'- #include [<"](.*)[">] +// lines (.*)-', line) if m: foundline = m.group(2) - if m.group(1) in added: + # Note: In this project at least we have a naming convention of + # lower case filename and upper case classname. + clname = m.group(1) + if clname not in added: + if clname in lcadded: + clname = lcadded[clname] + if clname in added: messages[removing].append( '%s(%s) : warning I0004: Replace include of %s with ' 'forward reference %s' % ( - removing, m.group(2), m.group(1), added[m.group(1)][1])) - del added[m.group(1)] + removing, m.group(2), m.group(1), added[clname][1])) + del added[clname] else: messages[removing].append( '%s(%s) : warning I0001: Unnecessary include of %s' % ( diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a85a0fb3..8c292f08 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -20,7 +20,20 @@ along with Mod Organizer. If not, see . #include "mainwindow.h" #include "ui_mainwindow.h" +#include "directoryentry.h" +#include "directoryrefresher.h" +#include "executableinfo.h" +#include "executableslist.h" +#include "guessedvalue.h" +#include "imodinterface.h" +#include "iplugingame.h" +#include "iplugindiagnose.h" +#include "nexusinterface.h" +#include "organizercore.h" +#include "previewgenerator.h" #include "spawn.h" +#include "versioninfo.h" + #include "report.h" #include "modlist.h" #include "modlistsortproxy.h" @@ -31,7 +44,6 @@ along with Mod Organizer. If not, see . #include "editexecutablesdialog.h" #include "categories.h" #include "categoriesdialog.h" -#include "utility.h" #include "modinfodialog.h" #include "overwriteinfodialog.h" #include "activatemodsdialog.h" @@ -41,16 +53,13 @@ along with Mod Organizer. If not, see . #include "messagedialog.h" #include "installationmanager.h" #include "lockeddialog.h" -#include "syncoverwritedialog.h" #include "logbuffer.h" #include "downloadlistsortproxy.h" #include "motddialog.h" #include "filedialogmemory.h" -#include "questionboxmemory.h" #include "tutorialmanager.h" #include "modflagicondelegate.h" #include "genericicondelegate.h" -#include "credentialsdialog.h" #include "selectiondialog.h" #include "csvbuilder.h" #include "savetextasdialog.h" @@ -59,59 +68,84 @@ along with Mod Organizer. If not, see . #include "browserdialog.h" #include "aboutdialog.h" #include "safewritefile.h" -//? -//#include "isavegame.h" -//#include "savegameinfo.h" -//? +#include "savegameinfowidget.h" +#include "savegameinfowidgetgamebryo.h" +#include "scriptextender.h" #include "nxmaccessmanager.h" -#include -#include +#include "appconfig.h" #include -#include #include #include -#include #include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include + #include #include #include #include #include #include -#include #include -#include #include #include #include +#include #include #include -#include #include #include -#include -#include #include #include -#include -#include #include -#include -#include #include #include #include -#include +#include #include + + #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include #else #include #endif + #include #include @@ -119,22 +153,19 @@ along with Mod Organizer. If not, see . #include #include #include -#include #include #endif -#include #include -#include -#include -#include -#include +#include +#include #include #include -#include -#include -#include +#include +#include +#include +#include #ifdef TEST_MODELS #include "modeltest.h" @@ -3191,29 +3222,42 @@ void MainWindow::deleteSavegame_clicked() { QModelIndexList selectedIndexes = ui->savegameList->selectionModel()->selectedIndexes(); + //This feels wrong and should be part of savegame interface + QStringList extensions; + { + ScriptExtender *extender = m_OrganizerCore.managedGame()->feature(); + if (extender != nullptr) { + extensions += extender->saveGameAttachmentExtensions(); + } + } + QString savesMsgLabel; QStringList deleteFiles; int count = 0; - foreach (const QModelIndex &idx, selectedIndexes) { - QString name = idx.data().toString(); - SaveGame *save = new SaveGame(this, idx.data(Qt::UserRole).toString(), m_OrganizerCore.managedGame()); + for (const QModelIndex &idx : selectedIndexes) { + //QString name = idx.data().toString(); + QFileInfo fileName(idx.data(Qt::UserRole).toString()); if (count < 10) { - savesMsgLabel += "
  • " + QFileInfo(name).completeBaseName() + "
  • "; + savesMsgLabel += "
  • " + fileName.completeBaseName() + "
  • "; } ++count; - deleteFiles << save->saveFiles(); + deleteFiles << fileName.absoluteFilePath(); + for (QString const &ext : extensions) { + deleteFiles << fileName.absoluteDir().absoluteFilePath(fileName.completeBaseName() + "." + ext); + } } if (count > 10) { savesMsgLabel += "
  • ... " + tr("%1 more").arg(count - 10) + "
  • "; } - if (QMessageBox::question(this, tr("Confirm"), tr("Are you sure you want to remove the following %n save(s)?
      %1

    Removed saves will be sent to the Recycle Bin.", "", selectedIndexes.count()) - .arg(savesMsgLabel), + if (QMessageBox::question(this, tr("Confirm"), + tr("Are you sure you want to remove the following %n save(s)?
      %1

    Removed saves will be sent to the Recycle Bin.", "", selectedIndexes.count()) + .arg(savesMsgLabel), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { shellDelete(deleteFiles, true); // recycle bin delete. } diff --git a/src/mainwindow.h b/src/mainwindow.h index 0cdea807..04e9f221 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -20,51 +20,82 @@ along with Mod Organizer. If not, see . #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "modlist.h" -#include "pluginlist.h" -#include "plugincontainer.h" -#define WIN32_LEAN_AND_MEAN -#include -#include -#include "directoryrefresher.h" -#include -#include "settings.h" -#include "downloadmanager.h" -#include "installationmanager.h" -#include "selfupdater.h" -#include "savegamegamebyro.h" -#include "modlistsortproxy.h" -#include "pluginlistsortproxy.h" -#include "tutorialcontrol.h" -#include "savegameinfowidgetgamebryo.h" -#include "previewgenerator.h" +#include "bsafolder.h" #include "browserdialog.h" +#include "delayedfilewriter.h" +#include "errorcodes.h" +#include "imoinfo.h" #include "iuserinterface.h" -#include -#include -#include +#include "modinfo.h" +#include "modlistsortproxy.h" +#include "tutorialcontrol.h" + +//Note the commented headers here can be replaced with forward references, +//when I get round to cleaning up main.cpp +struct Executable; +class CategoryFactory; +class LockedDialog; +class OrganizerCore; +#include "plugincontainer.h" //class PluginContainer; +class PluginListSortProxy; +#include "savegamegamebryo.h" //class SaveGameGamebryo; +class SaveGameInfoWidget; +namespace BSA { class Archive; } +#include "iplugingame.h" //namespace MOBase { class IPluginGame; } +namespace MOBase { class IPluginModPage; } +namespace MOBase { class IPluginTool; } +namespace MOShared { class DirectoryEntry; } + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class QAction; +class QAbstractItemModel; +class QDateTime; +class QEvent; +class QFile; +class QListWidgetItem; +class QMenu; +class QModelIndex; +class QPoint; +class QProgressBar; +class QProgressDialog; +class QTranslator; +class QTreeWidgetItem; +class QUrl; +class QSettings; +class QWidget; + #ifndef Q_MOC_RUN #include #endif +//Sigh - just for HANDLE +#define WIN32_LEAN_AND_MEAN +#include + +#include +#include +#include +#include + namespace Ui { class MainWindow; } -class LockedDialog; -class QToolButton; -class ModListSortProxy; -class ModListGroupCategoriesProxy; class MainWindow : public QMainWindow, public IUserInterface diff --git a/src/organizer.pro b/src/organizer.pro index 1284aa40..eed4190d 100644 --- a/src/organizer.pro +++ b/src/organizer.pro @@ -109,7 +109,6 @@ HEADERS += \ selectiondialog.h \ savegameinfowidgetgamebryo.h \ savegameinfowidget.h \ - savegamegamebyro.h \ savegame.h \ queryoverwritedialog.h \ profilesdialog.h \ @@ -175,7 +174,8 @@ HEADERS += \ modinforegular.h \ modinfobackup.h \ modinfooverwrite.h \ - modinfoforeign.h + modinfoforeign.h \ + savegamegamebryo.h FORMS += \ transfersavesdialog.ui \ diff --git a/src/savegame.cpp b/src/savegame.cpp index 2b125575..41120a88 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -19,20 +19,6 @@ along with Mod Organizer. If not, see . #include "savegame.h" -#include "iplugingame.h" -#include "scriptextender.h" -#include "utility.h" - -#include -#include -#include -#include - -#include -#include - -using namespace MOBase; - SaveGame::SaveGame(QObject *parent, const QString &filename, const MOBase::IPluginGame *game) : QObject(parent) , m_FileName(filename) @@ -43,27 +29,3 @@ SaveGame::SaveGame(QObject *parent, const QString &filename, const MOBase::IPlug SaveGame::~SaveGame() { } - -QStringList SaveGame::attachedFiles() const -{ - QStringList result; - ScriptExtender const *extender = m_Game->feature(); - if (extender != nullptr) { - for (QString const &ext : extender->saveGameAttachmentExtensions()) { - QFileInfo fi(fileName()); - fi.setFile(fi.canonicalPath() + "/" + fi.completeBaseName() + "." + ext); - if (fi.exists()) { - result.append(fi.filePath()); - } - } - } - - return result; -} - -QStringList SaveGame::saveFiles() const -{ - QStringList result = attachedFiles(); - result.append(fileName()); - return result; -} diff --git a/src/savegame.h b/src/savegame.h index d1bf4691..3afb2faa 100644 --- a/src/savegame.h +++ b/src/savegame.h @@ -24,10 +24,8 @@ along with Mod Organizer. If not, see . #include #include #include -#include -#include -#include +//Sigh - for SYSTEMTIME #define WIN32_LEAN_AND_MEAN #include @@ -63,16 +61,6 @@ public: */ const QString &fileName() const { return m_FileName; } - /** - * @return a list of additional files that belong to this savegame - */ - virtual QStringList attachedFiles() const; - - /** - * @return a list of all files that belong to this savegame - */ - virtual QStringList saveFiles() const; - /** * @return name of the player character **/ diff --git a/src/savegamegamebryo.cpp b/src/savegamegamebryo.cpp index 68ed30af..153be4b0 100644 --- a/src/savegamegamebryo.cpp +++ b/src/savegamegamebryo.cpp @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with Mod Organizer. If not, see . */ -#include "savegamegamebyro.h" +#include "savegamegamebryo.h" #include "isavegame.h" #include "savegameinfo.h" diff --git a/src/savegamegamebryo.h b/src/savegamegamebryo.h new file mode 100644 index 00000000..834cf8dd --- /dev/null +++ b/src/savegamegamebryo.h @@ -0,0 +1,78 @@ +/* +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 . +*/ + +#ifndef SAVEGAMEGAMEBRYO_H +#define SAVEGAMEGAMEBRYO_H + +#include "savegame.h" + +#include +#include +#include +#include + +namespace MOBase { class IPluginGame; class ISaveGame; } + +/** + * @brief represents a single save game + **/ +class SaveGameGamebryo : public SaveGame { + +Q_OBJECT + +public: + + /** + * @brief construct a save game and immediately read out information from the file + * + * @param filename absolute path of the save game file + **/ + SaveGameGamebryo(QObject *parent, const QString &filename, MOBase::IPluginGame const *game); + + /* + + SaveGameGamebryo(const SaveGameGamebryo &reference); + + SaveGameGamebryo &operator=(const SaveGameGamebryo &reference); + + ~SaveGameGamebryo(); + */ + + /** + * @return number of plugins that were enabled when the save game was created + **/ + int numPlugins() const { return m_Plugins.size(); } + + /** + * retrieve the name of one of the plugins that were enabled when the save game + * was created. valid indices are in the range between [0, numPlugins()[ + * @param index plugin index + * @return name of the plugin + **/ + const QString &plugin(int index) const { return m_Plugins.at(index); } + +private: + + QStringList m_Plugins; + //Note: This isn't owned by us so safe to copy + MOBase::ISaveGame const *m_Save; + +}; + +#endif // SAVEGAMEGAMEBRYO_H diff --git a/src/savegamegamebyro.h b/src/savegamegamebyro.h deleted file mode 100644 index bce08018..00000000 --- a/src/savegamegamebyro.h +++ /dev/null @@ -1,77 +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 . -*/ - -#ifndef SAVEGAMEGAMEBRYO_H -#define SAVEGAMEGAMEBRYO_H - -#include "savegame.h" - -#include -#include -#include - -namespace MOBase { class IPluginGame; class ISaveGame; } - -/** - * @brief represents a single save game - **/ -class SaveGameGamebryo : public SaveGame { - -Q_OBJECT - -public: - - /** - * @brief construct a save game and immediately read out information from the file - * - * @param filename absolute path of the save game file - **/ - SaveGameGamebryo(QObject *parent, const QString &filename, MOBase::IPluginGame const *game); - - /* - - SaveGameGamebryo(const SaveGameGamebryo &reference); - - SaveGameGamebryo &operator=(const SaveGameGamebryo &reference); - - ~SaveGameGamebryo(); - */ - - /** - * @return number of plugins that were enabled when the save game was created - **/ - int numPlugins() const { return m_Plugins.size(); } - - /** - * retrieve the name of one of the plugins that were enabled when the save game - * was created. valid indices are in the range between [0, numPlugins()[ - * @param index plugin index - * @return name of the plugin - **/ - const QString &plugin(int index) const { return m_Plugins.at(index); } - -private: - - QStringList m_Plugins; - //Note: This isn't owned by us so safe to copy - MOBase::ISaveGame const *m_Save; - -}; - -#endif // SAVEGAMEGAMEBRYO_H diff --git a/src/savegameinfowidgetgamebryo.cpp b/src/savegameinfowidgetgamebryo.cpp index c97e5810..d92025c2 100644 --- a/src/savegameinfowidgetgamebryo.cpp +++ b/src/savegameinfowidgetgamebryo.cpp @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with Mod Organizer. If not, see . */ -#include "savegamegamebyro.h" +#include "savegamegamebryo.h" #include "savegameinfowidgetgamebryo.h" #include #include -- cgit v1.3.1 From 0c536a4c12e37caec2c3107875a97d5343c2a0a0 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Tue, 15 Dec 2015 15:58:01 +0000 Subject: Makes iSaveGame responsible for returning all files involved in savegame. Cleans up save deletion and save transfer dialogue somewhat --- src/mainwindow.cpp | 86 +++++++++++++++++++++------------------------ src/transfersavesdialog.cpp | 19 +++++----- 2 files changed, 48 insertions(+), 57 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8c292f08..03233398 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -28,9 +28,11 @@ along with Mod Organizer. If not, see . #include "imodinterface.h" #include "iplugingame.h" #include "iplugindiagnose.h" +#include "isavegame.h" #include "nexusinterface.h" #include "organizercore.h" #include "previewgenerator.h" +#include "savegameinfo.h" #include "spawn.h" #include "versioninfo.h" @@ -70,7 +72,6 @@ along with Mod Organizer. If not, see . #include "safewritefile.h" #include "savegameinfowidget.h" #include "savegameinfowidgetgamebryo.h" -#include "scriptextender.h" #include "nxmaccessmanager.h" #include "appconfig.h" #include @@ -83,61 +84,63 @@ along with Mod Organizer. If not, see . #include #include #include +#include #include +#include #include +#include #include +#include +#include #include +#include #include #include #include +#include #include #include #include #include #include +#include #include +#include +#include +#include +#include #include #include +#include +#include +#include #include #include #include #include #include +#include +#include #include +#include #include #include +#include #include #include #include #include +#include +#include +#include +#include #include #include -#include -#include - -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include + +#include +#include #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) @@ -146,9 +149,6 @@ along with Mod Organizer. If not, see . #include #endif -#include -#include - #ifndef Q_MOC_RUN #include #include @@ -3220,34 +3220,26 @@ void MainWindow::on_categoriesList_itemSelectionChanged() void MainWindow::deleteSavegame_clicked() { - QModelIndexList selectedIndexes = ui->savegameList->selectionModel()->selectedIndexes(); - - //This feels wrong and should be part of savegame interface - QStringList extensions; - { - ScriptExtender *extender = m_OrganizerCore.managedGame()->feature(); - if (extender != nullptr) { - extensions += extender->saveGameAttachmentExtensions(); - } - } + SaveGameInfo const *info = m_OrganizerCore.managedGame()->feature(); QString savesMsgLabel; QStringList deleteFiles; int count = 0; - for (const QModelIndex &idx : selectedIndexes) { - //QString name = idx.data().toString(); - QFileInfo fileName(idx.data(Qt::UserRole).toString()); + for (const QModelIndex &idx : ui->savegameList->selectionModel()->selectedIndexes()) { + QString name = idx.data(Qt::UserRole).toString(); if (count < 10) { - savesMsgLabel += "
  • " + fileName.completeBaseName() + "
  • "; + savesMsgLabel += "
  • " + QFileInfo(name).completeBaseName() + "
  • "; } ++count; - deleteFiles << fileName.absoluteFilePath(); - for (QString const &ext : extensions) { - deleteFiles << fileName.absoluteDir().absoluteFilePath(fileName.completeBaseName() + "." + ext); + if (info == nullptr) { + deleteFiles.push_back(name); + } else { + ISaveGame const *save = info->getSaveGameInfo(name); + deleteFiles += save->allFiles(); } } @@ -3256,7 +3248,9 @@ void MainWindow::deleteSavegame_clicked() } if (QMessageBox::question(this, tr("Confirm"), - tr("Are you sure you want to remove the following %n save(s)?
      %1

    Removed saves will be sent to the Recycle Bin.", "", selectedIndexes.count()) + tr("Are you sure you want to remove the following %n save(s)?
    " + "
      %1

    " + "Removed saves will be sent to the Recycle Bin.", "", count) .arg(savesMsgLabel), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { shellDelete(deleteFiles, true); // recycle bin delete. diff --git a/src/transfersavesdialog.cpp b/src/transfersavesdialog.cpp index 710a33b9..b07a9510 100644 --- a/src/transfersavesdialog.cpp +++ b/src/transfersavesdialog.cpp @@ -71,6 +71,11 @@ public: return m_File; } + virtual QStringList allFiles() const override + { + return { m_File }; + } + private: QString m_File; }; @@ -298,19 +303,11 @@ bool TransferSavesDialog::transferCharacters(QString const &character, OverwriteMode overwriteMode = OVERWRITE_ASK; - QStringList extensions = { m_GamePlugin->savegameExtension() }; - { - ScriptExtender *ext = m_GamePlugin->feature(); - if (ext != nullptr) { - extensions += ext->saveGameAttachmentExtensions(); - } - } QDir destination(dest); for (SaveListItem const &save : saves) { - QFileInfo const saveFile = save->getFilename(); - for (QString const &ext : extensions) { - QFileInfo sourceFile(saveFile.absoluteDir().absoluteFilePath(saveFile.completeBaseName() + "." + ext)); - QString destinationFile = destination.absoluteFilePath(sourceFile.fileName()); + for (QString source : save->allFiles()) { + QFileInfo sourceFile(source); + QString destinationFile(destination.absoluteFilePath(sourceFile.fileName())); //If the file is already there, let them skip (or not). if (QFile::exists(destinationFile)) { -- cgit v1.3.1 From 30b29635f67d6ab1cd00b6787ab58bf36934da55 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Tue, 15 Dec 2015 16:00:15 +0000 Subject: unsaved edits... --- src/transfersavesdialog.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/transfersavesdialog.cpp b/src/transfersavesdialog.cpp index b07a9510..a2201a69 100644 --- a/src/transfersavesdialog.cpp +++ b/src/transfersavesdialog.cpp @@ -23,7 +23,6 @@ along with Mod Organizer. If not, see . #include "iplugingame.h" #include "isavegame.h" #include "savegameinfo.h" -#include "scriptextender.h" #include #include @@ -38,8 +37,6 @@ along with Mod Organizer. If not, see . #include #include -class QWidget; //Do we /really/ need this? - using namespace MOBase; using namespace MOShared; -- cgit v1.3.1 From 5f5184ebfe9a6b7102654863cbb390a610ab1563 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sat, 19 Dec 2015 20:49:54 +0000 Subject: Changes to support getting list of mods / esps to activate from game plugin --- src/activatemodsdialog.cpp | 22 +++++----- src/activatemodsdialog.h | 10 ++++- src/mainwindow.cpp | 97 ++++++++++----------------------------------- src/mainwindow.h | 3 +- src/modinfo.h | 1 - src/organizercore.cpp | 35 +++++++++++++--- src/organizercore.h | 29 ++++++++++---- src/organizerproxy.cpp | 8 +++- src/organizerproxy.h | 5 ++- src/transfersavesdialog.cpp | 6 +++ 10 files changed, 112 insertions(+), 104 deletions(-) (limited to 'src') diff --git a/src/activatemodsdialog.cpp b/src/activatemodsdialog.cpp index fd56ae3e..5ef0a4e5 100644 --- a/src/activatemodsdialog.cpp +++ b/src/activatemodsdialog.cpp @@ -21,9 +21,14 @@ along with Mod Organizer. If not, see . #include "ui_activatemodsdialog.h" #include +#include #include +#include +#include -ActivateModsDialog::ActivateModsDialog(const std::map > &missingPlugins, QWidget *parent) +#include + +ActivateModsDialog::ActivateModsDialog(SaveGameInfo::MissingAssets const &missingAssets, QWidget *parent) : TutorableDialog("ActivateMods", parent), ui(new Ui::ActivateModsDialog) { ui->setupUi(this); @@ -40,18 +45,17 @@ ActivateModsDialog::ActivateModsDialog(const std::mapsetRowCount(missingPlugins.size()); + modsTable->setRowCount(missingAssets.size()); - for (std::map >::const_iterator espIter = missingPlugins.begin(); - espIter != missingPlugins.end(); ++espIter, ++row) { - modsTable->setCellWidget(row, 0, new QLabel(espIter->first)); - if (espIter->second.size() == 0) { + for (SaveGameInfo::MissingAssets::const_iterator espIter = missingAssets.begin(); + espIter != missingAssets.end(); ++espIter, ++row) { + modsTable->setCellWidget(row, 0, new QLabel(espIter.key())); + if (espIter->size() == 0) { modsTable->setCellWidget(row, 1, new QLabel(tr("not found"))); } else { QComboBox* combo = new QComboBox(); - for (std::vector::const_iterator modIter = espIter->second.begin(); - modIter != espIter->second.end(); ++modIter) { - combo->addItem(*modIter); + for (QString const &mod : espIter.value()) { + combo->addItem(mod); } modsTable->setCellWidget(row, 1, combo); } diff --git a/src/activatemodsdialog.h b/src/activatemodsdialog.h index 08dbad8d..f36b5fde 100644 --- a/src/activatemodsdialog.h +++ b/src/activatemodsdialog.h @@ -20,8 +20,14 @@ along with Mod Organizer. If not, see . #ifndef ACTIVATEMODSDIALOG_H #define ACTIVATEMODSDIALOG_H +#include "savegameinfo.h" #include "tutorabledialog.h" -#include + +#include + +class QString; +class QWidget; + #include namespace Ui { @@ -42,7 +48,7 @@ public: * @param missingPlugins a map containing missing plugins that need to be activated * @param parent ... Defaults to 0. **/ - explicit ActivateModsDialog(const std::map > &missingPlugins, QWidget *parent = 0); + explicit ActivateModsDialog(SaveGameInfo::MissingAssets const &missingAssets, QWidget *parent = 0); ~ActivateModsDialog(); /** diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 03233398..0b551c5b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -31,6 +31,7 @@ along with Mod Organizer. If not, see . #include "isavegame.h" #include "nexusinterface.h" #include "organizercore.h" +#include "pluginlistsortproxy.h" #include "previewgenerator.h" #include "savegameinfo.h" #include "spawn.h" @@ -104,6 +105,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include #include #include #include @@ -124,6 +126,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include #include #include #include @@ -134,6 +137,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include #include #include #include @@ -3258,78 +3262,9 @@ void MainWindow::deleteSavegame_clicked() } -void MainWindow::fixMods_clicked() +void MainWindow::fixMods_clicked(SaveGameInfo::MissingAssets const &missingAssets) { - QListWidgetItem *selectedItem = ui->savegameList->currentItem(); - - if (selectedItem == nullptr) - return; - - // if required, parse the save game - if (selectedItem->data(Qt::UserRole).isNull()) { - QVariant temp; - SaveGameGamebryo *save = getSaveGame(selectedItem->data(Qt::UserRole).toString()); - save->setParent(selectedItem->listWidget()); - temp.setValue(save); - selectedItem->setData(Qt::UserRole, temp); - } - - const SaveGameGamebryo *save = getSaveGame(selectedItem); - - // collect the list of missing plugins - std::map > missingPlugins; - - for (int i = 0; i < save->numPlugins(); ++i) { - const QString &pluginName = save->plugin(i); - if (!m_OrganizerCore.pluginList()->isEnabled(pluginName)) { - missingPlugins[pluginName] = std::vector(); - } - } - - // figure out, for each esp/esm, which mod, if any, contains it - QStringList espFilter("*.esp"); - espFilter.append("*.esm"); - - // search in data - { - QDir dataDir(m_OrganizerCore.managedGame()->dataDirectory()); - QStringList esps = dataDir.entryList(espFilter); - for (const QString &esp : esps) { - std::map >::iterator iter = missingPlugins.find(esp); - if (iter != missingPlugins.end()) { - iter->second.push_back(""); - } - } - } - - // search in mods - for (unsigned int i = 0; i < m_OrganizerCore.currentProfile()->numRegularMods(); ++i) { - int modIndex = m_OrganizerCore.currentProfile()->modIndexByPriority(i); - ModInfo::Ptr modInfo = ModInfo::getByIndex(modIndex); - - QStringList esps = QDir(modInfo->absolutePath()).entryList(espFilter); - for (const QString &esp : esps) { - std::map >::iterator iter = missingPlugins.find(esp); - if (iter != missingPlugins.end()) { - iter->second.push_back(modInfo->name()); - } - } - } - - // search in overwrite - { - QDir overwriteDir(qApp->property("dataPath").toString() + "/" + QString::fromStdWString(AppConfig::overwritePath())); - QStringList esps = overwriteDir.entryList(espFilter); - for (const QString &esp : esps) { - std::map >::iterator iter = missingPlugins.find(esp); - if (iter != missingPlugins.end()) { - iter->second.push_back(""); - } - } - } - - - ActivateModsDialog dialog(missingPlugins, this); + ActivateModsDialog dialog(missingAssets, this); if (dialog.exec() == QDialog::Accepted) { // activate the required mods, then enable all esps std::set modsToActivate = dialog.getModsToActivate(); @@ -3356,13 +3291,25 @@ void MainWindow::on_savegameList_customContextMenuRequested(const QPoint &pos) { QItemSelectionModel *selection = ui->savegameList->selectionModel(); - if (!selection->hasSelection()) + if (!selection->hasSelection()) { return; + } QMenu menu; - - if (!(selection->selectedIndexes().count() > 1)) - menu.addAction(tr("Fix Mods..."), this, SLOT(fixMods_clicked())); + QAction *action = menu.addAction(tr("Enable Mods...")); + action->setEnabled(false); + + if (selection->selectedIndexes().count() == 1) { + SaveGameInfo const *info = this->m_OrganizerCore.managedGame()->feature(); + if (info != nullptr) { + QString save = ui->savegameList->currentItem()->data(Qt::UserRole).toString(); + SaveGameInfo::MissingAssets missing = info->getMissingAssets(save); + if (missing.size() != 0) { + connect(action, &QAction::triggered, this, [this, missing]{ fixMods_clicked(missing); }); + action->setEnabled(true); + } + } + } QString deleteMenuLabel = tr("Delete %n save(s)", "", selection->selectedIndexes().count()); diff --git a/src/mainwindow.h b/src/mainwindow.h index 04e9f221..a8c3ec0e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -28,6 +28,7 @@ along with Mod Organizer. If not, see . #include "iuserinterface.h" #include "modinfo.h" #include "modlistsortproxy.h" +#include "savegameinfo.h" #include "tutorialcontrol.h" //Note the commented headers here can be replaced with forward references, @@ -393,7 +394,7 @@ private slots: void information_clicked(); // savegame context menu void deleteSavegame_clicked(); - void fixMods_clicked(); + void fixMods_clicked(SaveGameInfo::MissingAssets const &missingAssets); // data-tree context menu void writeDataToFile(); void openDataFile(); diff --git a/src/modinfo.h b/src/modinfo.h index ae22ccd8..c10232da 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -22,7 +22,6 @@ along with Mod Organizer. If not, see . #include "imodinterface.h" #include "versioninfo.h" -//#include class QDateTime; class QDir; diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 06a6dba4..e92ecb97 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1,15 +1,19 @@ #include "organizercore.h" +#include "imodinterface.h" #include "iplugingame.h" -#include "mainwindow.h" +#include "iuserinterface.h" +#include "loadmechanism.h" #include "messagedialog.h" +#include "modlistsortproxy.h" +#include "plugincontainer.h" +#include "pluginlistsortproxy.h" #include "logbuffer.h" #include "credentialsdialog.h" #include "filedialogmemory.h" #include "lockeddialog.h" #include "modinfodialog.h" #include "spawn.h" -#include "safewritefile.h" #include "syncoverwritedialog.h" #include "nxmaccessmanager.h" #include @@ -17,18 +21,27 @@ #include #include #include -#include +#include "appconfig.h" #include #include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include + +#include #include +#include #include +#include +#include +#include using namespace MOShared; @@ -867,6 +880,16 @@ ModList *OrganizerCore::modList() return &m_ModList; } +QStringList OrganizerCore::modsSortedByProfilePriority() const +{ + QStringList res; + for (unsigned int i = 0; i < currentProfile()->numRegularMods(); ++i) { + int modIndex = currentProfile()->modIndexByPriority(i); + res.push_back(ModInfo::getByIndex(modIndex)->name()); + } + return res; +} + void OrganizerCore::spawnBinary(const QFileInfo &binary, const QString &arguments, const QDir ¤tDirectory, bool closeAfterStart, const QString &steamAppID) { LockedDialog *dialog = new LockedDialog(qApp->activeWindow()); diff --git a/src/organizercore.h b/src/organizercore.h index 5cfbaca4..b50b3e9f 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -2,30 +2,42 @@ #define ORGANIZERCORE_H -#include "profile.h" #include "selfupdater.h" -#include "iuserinterface.h" +#include "iuserinterface.h" //should be class IUserInterface; #include "settings.h" #include "modlist.h" +#include "modinfo.h" #include "pluginlist.h" #include "directoryrefresher.h" #include "installationmanager.h" #include "downloadmanager.h" -#include "modlistsortproxy.h" -#include "pluginlistsortproxy.h" #include "executableslist.h" -#include #include #include -#include #include -#include #include #include + +class ModListSortProxy; +class PluginListSortProxy; +class Profile; +namespace MOBase { template class GuessedValue; } +namespace MOShared { class DirectoryEntry; } + +#include +#include +#include #include #include +#include #include +class QNetworkReply; +class QUrl; +class QWidget; + +#include +#include class PluginContainer; @@ -89,7 +101,7 @@ public: m_ExecutablesList = executablesList; } - Profile *currentProfile() { return m_CurrentProfile; } + Profile *currentProfile() const { return m_CurrentProfile; } void setCurrentProfile(const QString &profileName); std::vector enabledArchives(); @@ -155,6 +167,7 @@ public: bool onAboutToRun(const std::function &func); bool onFinishedRun(const std::function &func); void refreshModList(bool saveChanges = true); + QStringList modsSortedByProfilePriority() const; //std::vector > fileMapping(); diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index ba07c154..474f0837 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -1,6 +1,7 @@ #include "organizerproxy.h" -#include +#include "appconfig.h" +#include "organizercore.h" #include @@ -170,3 +171,8 @@ MOBase::IPluginGame const *OrganizerProxy::managedGame() const { return m_Proxied->managedGame(); } + +QStringList OrganizerProxy::modsSortedByProfilePriority() const +{ + return m_Proxied->modsSortedByProfilePriority(); +} diff --git a/src/organizerproxy.h b/src/organizerproxy.h index 62a35498..2a0fc397 100644 --- a/src/organizerproxy.h +++ b/src/organizerproxy.h @@ -3,7 +3,8 @@ #include -#include "mainwindow.h" + +class OrganizerCore; class OrganizerProxy : public MOBase::IOrganizer { @@ -47,6 +48,8 @@ public: virtual MOBase::IPluginGame const *managedGame() const; + virtual QStringList modsSortedByProfilePriority() const; + private: OrganizerCore *m_Proxied; diff --git a/src/transfersavesdialog.cpp b/src/transfersavesdialog.cpp index a2201a69..b6be108b 100644 --- a/src/transfersavesdialog.cpp +++ b/src/transfersavesdialog.cpp @@ -84,6 +84,12 @@ public: { return new DummySave(file); } + + virtual MissingAssets getMissingAssets(QString const &) const override + { + return {}; + } + }; } //end anonymous namespace -- cgit v1.3.1 From f55a5f2b21664ccd2af1c24ef68f14f73e418b1c Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sun, 20 Dec 2015 21:08:14 +0000 Subject: Managed to remove SaveGame and SaveGameGamebryo classes from organizer --- src/CMakeLists.txt | 4 -- src/mainwindow.cpp | 32 +++++------ src/mainwindow.h | 8 +-- src/organizer.pro | 6 +- src/savegame.cpp | 31 ----------- src/savegame.h | 109 ------------------------------------- src/savegamegamebryo.cpp | 66 ---------------------- src/savegamegamebryo.h | 78 -------------------------- src/savegameinfowidget.cpp | 38 +++++++++---- src/savegameinfowidget.h | 8 ++- src/savegameinfowidgetgamebryo.cpp | 22 +++++--- src/savegameinfowidgetgamebryo.h | 8 +-- 12 files changed, 68 insertions(+), 342 deletions(-) delete mode 100644 src/savegame.cpp delete mode 100644 src/savegame.h delete mode 100644 src/savegamegamebryo.cpp delete mode 100644 src/savegamegamebryo.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3c786868..428f18f9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,8 +20,6 @@ SET(organizer_SRCS selectiondialog.cpp savegameinfowidgetgamebryo.cpp savegameinfowidget.cpp - savegamegamebryo.cpp - savegame.cpp queryoverwritedialog.cpp profilesdialog.cpp profile.cpp @@ -114,8 +112,6 @@ SET(organizer_HDRS selectiondialog.h savegameinfowidgetgamebryo.h savegameinfowidget.h - savegamegamebyro.h - savegame.h queryoverwritedialog.h profilesdialog.h profile.h diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0b551c5b..8f71f636 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -864,28 +864,24 @@ void MainWindow::setBrowserGeometry(const QByteArray &geometry) m_IntegratedBrowser.restoreGeometry(geometry); } - -SaveGameGamebryo *MainWindow::getSaveGame(const QString &name) -{ - IPluginGame const *game = m_OrganizerCore.managedGame(); - return new SaveGameGamebryo(this, name, game); -} - - -SaveGameGamebryo *MainWindow::getSaveGame(QListWidgetItem *item) +ISaveGame const *MainWindow::getSaveGame(QListWidgetItem *item) { try { - SaveGameGamebryo *saveGame = getSaveGame(item->data(Qt::UserRole).toString()); - saveGame->setParent(item->listWidget()); - return saveGame; + IPluginGame const *game = m_OrganizerCore.managedGame(); + SaveGameInfo const *info = game->feature(); + if (info != nullptr) { + return info->getSaveGameInfo(item->data(Qt::UserRole).toString()); + } + //SaveGameGamebryo *saveGame = new SaveGameGamebryo(/*this,*/ item->data(Qt::UserRole).toString(), game); + //saveGame->setParent(item->listWidget()); + //return saveGame; } catch (const std::exception &e) { reportError(tr("failed to read savegame: %1").arg(e.what())); - return nullptr; } + return nullptr; } - -void MainWindow::displaySaveGameInfo(const SaveGameGamebryo *save, QPoint pos) +void MainWindow::displaySaveGameInfo(MOBase::ISaveGame const *save, QPoint pos) { if (m_CurrentSaveView == nullptr) { m_CurrentSaveView = new SaveGameInfoWidgetGamebryo(save, m_OrganizerCore.pluginList(), this); @@ -918,11 +914,11 @@ void MainWindow::saveSelectionChanged(QListWidgetItem *newItem) { if (newItem == nullptr) { hideSaveGameInfo(); - } else if ((m_CurrentSaveView == nullptr) || (newItem != m_CurrentSaveView->property("displayItem").value())) { - const SaveGameGamebryo *save = getSaveGame(newItem); + } else if (m_CurrentSaveView == nullptr || newItem != m_CurrentSaveView->property("displayItem").value()) { + MOBase::ISaveGame const *save = getSaveGame(newItem); if (save != nullptr) { displaySaveGameInfo(save, QCursor::pos()); - m_CurrentSaveView->setProperty("displayItem", qVariantFromValue((void*)newItem)); + m_CurrentSaveView->setProperty("displayItem", qVariantFromValue(static_cast(newItem))); } } } diff --git a/src/mainwindow.h b/src/mainwindow.h index a8c3ec0e..07f24540 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -39,12 +39,13 @@ class LockedDialog; class OrganizerCore; #include "plugincontainer.h" //class PluginContainer; class PluginListSortProxy; -#include "savegamegamebryo.h" //class SaveGameGamebryo; class SaveGameInfoWidget; namespace BSA { class Archive; } #include "iplugingame.h" //namespace MOBase { class IPluginGame; } namespace MOBase { class IPluginModPage; } namespace MOBase { class IPluginTool; } +namespace MOBase { class ISaveGame; } + namespace MOShared { class DirectoryEntry; } #include @@ -255,10 +256,9 @@ private: void setCategoryListVisible(bool visible); - SaveGameGamebryo *getSaveGame(const QString &name); - SaveGameGamebryo *getSaveGame(QListWidgetItem *item); + MOBase::ISaveGame const *getSaveGame(QListWidgetItem *item); - void displaySaveGameInfo(const SaveGameGamebryo *save, QPoint pos); + void displaySaveGameInfo(MOBase::ISaveGame const *save, QPoint pos); HANDLE nextChildProcess(); diff --git a/src/organizer.pro b/src/organizer.pro index eed4190d..ee0526ed 100644 --- a/src/organizer.pro +++ b/src/organizer.pro @@ -29,8 +29,6 @@ SOURCES += \ selectiondialog.cpp \ savegameinfowidgetgamebryo.cpp \ savegameinfowidget.cpp \ - savegamegamebryo.cpp \ - savegame.cpp \ queryoverwritedialog.cpp \ profilesdialog.cpp \ profile.cpp \ @@ -109,7 +107,6 @@ HEADERS += \ selectiondialog.h \ savegameinfowidgetgamebryo.h \ savegameinfowidget.h \ - savegame.h \ queryoverwritedialog.h \ profilesdialog.h \ profile.h \ @@ -174,8 +171,7 @@ HEADERS += \ modinforegular.h \ modinfobackup.h \ modinfooverwrite.h \ - modinfoforeign.h \ - savegamegamebryo.h + modinfoforeign.h FORMS += \ transfersavesdialog.ui \ diff --git a/src/savegame.cpp b/src/savegame.cpp deleted file mode 100644 index 41120a88..00000000 --- a/src/savegame.cpp +++ /dev/null @@ -1,31 +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 . -*/ - -#include "savegame.h" - -SaveGame::SaveGame(QObject *parent, const QString &filename, const MOBase::IPluginGame *game) - : QObject(parent) - , m_FileName(filename) - , m_Game(game) -{ -} - -SaveGame::~SaveGame() -{ -} diff --git a/src/savegame.h b/src/savegame.h deleted file mode 100644 index 3afb2faa..00000000 --- a/src/savegame.h +++ /dev/null @@ -1,109 +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 . -*/ - -#ifndef SAVEGAME_H -#define SAVEGAME_H - - -#include -#include -#include - -//Sigh - for SYSTEMTIME -#define WIN32_LEAN_AND_MEAN -#include - -namespace MOBase { class IPluginGame; } - -/** - * @brief represents a single save game - **/ -class SaveGame : public QObject { - -Q_OBJECT - -public: - - /** - * @brief construct a save game and immediately read out information from the file - * - * @param filename absolute path of the save game file - **/ - SaveGame(QObject *parent, const QString &filename, MOBase::IPluginGame const *game); - - virtual ~SaveGame(); - - /** - * @brief read out information from a savegame - * - * @param fileName absolute path of the save game file - **/ - virtual void readFile(const QString) { } - - /** - * @return filename of this savegame - */ - const QString &fileName() const { return m_FileName; } - - /** - * @return name of the player character - **/ - const QString &pcName() const { return m_PCName; } - - /** - * @return level of the player character - **/ - unsigned short pcLevel() const { return m_PCLevel; } - - /** - * @return location of the player character - **/ - const QString &pcLocation() const { return m_PCLocation; } - - /** - * @return index of the save game - **/ - unsigned long saveNumber() const { return m_SaveNumber; } - - /** - * @return creation time of the save game - **/ - SYSTEMTIME creationTime() const { return m_CreationTime; } - - /** - * @return screenshot in the savegame - **/ - const QImage &screenshot() const { return m_Screenshot; } - -protected: - - QString m_FileName; - QString m_PCName; - unsigned short m_PCLevel; - QString m_PCLocation; - unsigned long m_SaveNumber; - SYSTEMTIME m_CreationTime; - QImage m_Screenshot; - -private: - MOBase::IPluginGame const * const m_Game; -}; - - -#endif // SAVEGAME_H diff --git a/src/savegamegamebryo.cpp b/src/savegamegamebryo.cpp deleted file mode 100644 index 153be4b0..00000000 --- a/src/savegamegamebryo.cpp +++ /dev/null @@ -1,66 +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 . -*/ - -#include "savegamegamebryo.h" - -#include "isavegame.h" -#include "savegameinfo.h" -#include "iplugingame.h" -#include "gamebryosavegame.h" - -#include -#include - -using namespace MOBase; - - -SaveGameGamebryo::SaveGameGamebryo(QObject *parent, const QString &fileName, IPluginGame const *game) - : SaveGame(parent, fileName, game) - , m_Plugins() -{ - SaveGameInfo const *info = game->feature(); - if (info != nullptr) { - ISaveGame const *save = info->getSaveGameInfo(fileName); - m_Save = save; - - //Kludgery - GamebryoSaveGame const *s = dynamic_cast(save); - m_PCName = s->getPCName(); - m_PCLevel = s->getPCLevel(); - m_PCLocation = s->getPCLocation(); - m_SaveNumber = s->getSaveNumber(); - - QDateTime modified = s->getCreationTime(); - memset(&m_CreationTime, 0, sizeof(SYSTEMTIME)); - - m_CreationTime.wDay = static_cast(modified.date().day()); - m_CreationTime.wDayOfWeek = static_cast(modified.date().dayOfWeek()); - m_CreationTime.wMonth = static_cast(modified.date().month()); - m_CreationTime.wYear =static_cast( modified.date().year()); - - m_CreationTime.wHour = static_cast(modified.time().hour()); - m_CreationTime.wMinute = static_cast(modified.time().minute()); - m_CreationTime.wSecond = static_cast(modified.time().second()); - m_CreationTime.wMilliseconds = static_cast(modified.time().msec()); - - m_Screenshot = s->getScreenshot(); - - m_Plugins = s->getPlugins(); - } -} diff --git a/src/savegamegamebryo.h b/src/savegamegamebryo.h deleted file mode 100644 index 834cf8dd..00000000 --- a/src/savegamegamebryo.h +++ /dev/null @@ -1,78 +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 . -*/ - -#ifndef SAVEGAMEGAMEBRYO_H -#define SAVEGAMEGAMEBRYO_H - -#include "savegame.h" - -#include -#include -#include -#include - -namespace MOBase { class IPluginGame; class ISaveGame; } - -/** - * @brief represents a single save game - **/ -class SaveGameGamebryo : public SaveGame { - -Q_OBJECT - -public: - - /** - * @brief construct a save game and immediately read out information from the file - * - * @param filename absolute path of the save game file - **/ - SaveGameGamebryo(QObject *parent, const QString &filename, MOBase::IPluginGame const *game); - - /* - - SaveGameGamebryo(const SaveGameGamebryo &reference); - - SaveGameGamebryo &operator=(const SaveGameGamebryo &reference); - - ~SaveGameGamebryo(); - */ - - /** - * @return number of plugins that were enabled when the save game was created - **/ - int numPlugins() const { return m_Plugins.size(); } - - /** - * retrieve the name of one of the plugins that were enabled when the save game - * was created. valid indices are in the range between [0, numPlugins()[ - * @param index plugin index - * @return name of the plugin - **/ - const QString &plugin(int index) const { return m_Plugins.at(index); } - -private: - - QStringList m_Plugins; - //Note: This isn't owned by us so safe to copy - MOBase::ISaveGame const *m_Save; - -}; - -#endif // SAVEGAMEGAMEBRYO_H diff --git a/src/savegameinfowidget.cpp b/src/savegameinfowidget.cpp index 63eefb93..bf4a9598 100644 --- a/src/savegameinfowidget.cpp +++ b/src/savegameinfowidget.cpp @@ -19,9 +19,22 @@ along with Mod Organizer. If not, see . #include "savegameinfowidget.h" #include "ui_savegameinfowidget.h" -#include "utility.h" -#include "savegame.h" -#include + +#include "isavegame.h" +#include "gamebryosavegame.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include SaveGameInfoWidget::SaveGameInfoWidget(QWidget *parent) @@ -41,14 +54,19 @@ SaveGameInfoWidget::~SaveGameInfoWidget() } -void SaveGameInfoWidget::setSave(const SaveGame *saveGame) +void SaveGameInfoWidget::setSave(MOBase::ISaveGame const *saveGame) { - ui->saveNumLabel->setText(QString("%1").arg(saveGame->saveNumber())); - ui->characterLabel->setText(saveGame->pcName()); - ui->locationLabel->setText(saveGame->pcLocation()); - ui->levelLabel->setText(QString("%1").arg(saveGame->pcLevel())); - ui->dateLabel->setText(MOBase::ToString(saveGame->creationTime())); - ui->screenshotLabel->setPixmap(QPixmap::fromImage(saveGame->screenshot())); + GamebryoSaveGame const *game = dynamic_cast(saveGame); + ui->saveNumLabel->setText(QString("%1").arg(game->getSaveNumber())); + ui->characterLabel->setText(game->getPCName()); + ui->locationLabel->setText(game->getPCLocation()); + ui->levelLabel->setText(QString("%1").arg(game->getPCLevel())); + //This somewhat contorted code is because on my system at least, the + //old way of doing this appears to give short date and long time. + QDateTime t = saveGame->getCreationTime(); + ui->dateLabel->setText(t.date().toString(Qt::DefaultLocaleShortDate) + " " + + t.time().toString(Qt::DefaultLocaleLongDate)); + ui->screenshotLabel->setPixmap(QPixmap::fromImage(game->getScreenshot())); if (ui->gameFrame->layout() != nullptr) { QLayoutItem *item = nullptr; while ((item = ui->gameFrame->layout()->takeAt(0)) != nullptr) { diff --git a/src/savegameinfowidget.h b/src/savegameinfowidget.h index dfb0f8b1..c811313c 100644 --- a/src/savegameinfowidget.h +++ b/src/savegameinfowidget.h @@ -20,14 +20,16 @@ along with Mod Organizer. If not, see . #ifndef SAVEGAMEINFOWIDGET_H #define SAVEGAMEINFOWIDGET_H +#include #include -#include + +class QFrame; namespace Ui { class SaveGameInfoWidget; } -class SaveGame; +namespace MOBase { class ISaveGame; } class SaveGameInfoWidget : public QWidget { @@ -38,7 +40,7 @@ public: explicit SaveGameInfoWidget(QWidget *parent = 0); ~SaveGameInfoWidget(); - virtual void setSave(const SaveGame *saveGame); + virtual void setSave(MOBase::ISaveGame const *saveGame); signals: diff --git a/src/savegameinfowidgetgamebryo.cpp b/src/savegameinfowidgetgamebryo.cpp index d92025c2..854043a3 100644 --- a/src/savegameinfowidgetgamebryo.cpp +++ b/src/savegameinfowidgetgamebryo.cpp @@ -17,13 +17,18 @@ You should have received a copy of the GNU General Public License along with Mod Organizer. If not, see . */ -#include "savegamegamebryo.h" #include "savegameinfowidgetgamebryo.h" + +#include "pluginlist.h" +#include "gamebryosavegame.h" + +#include #include +#include #include -SaveGameInfoWidgetGamebryo::SaveGameInfoWidgetGamebryo(const SaveGame *saveGame, PluginList *pluginList, QWidget *parent) +SaveGameInfoWidgetGamebryo::SaveGameInfoWidgetGamebryo(MOBase::ISaveGame const *saveGame, PluginList *pluginList, QWidget *parent) : SaveGameInfoWidget(parent), m_PluginList(pluginList) { QVBoxLayout *gameLayout = new QVBoxLayout(); @@ -34,10 +39,10 @@ SaveGameInfoWidgetGamebryo::SaveGameInfoWidgetGamebryo(const SaveGame *saveGame, } -void SaveGameInfoWidgetGamebryo::setSave(const SaveGame *saveGame) +void SaveGameInfoWidgetGamebryo::setSave(MOBase::ISaveGame const *saveGame) { SaveGameInfoWidget::setSave(saveGame); - const SaveGameGamebryo *gamebryoSave = qobject_cast(saveGame); + GamebryoSaveGame const *gamebryoSave = dynamic_cast(saveGame); QLayout *layout = getGameFrame()->layout(); QLabel *header = new QLabel(tr("Missing ESPs")); QFont headerFont = header->font(); @@ -48,19 +53,18 @@ void SaveGameInfoWidgetGamebryo::setSave(const SaveGame *saveGame) header->setFont(headerFont); layout->addWidget(header); int count = 0; - for (int i = 0; i < gamebryoSave->numPlugins(); ++i) { - const QString &pluginName = gamebryoSave->plugin(i); + for (QString const &pluginName : gamebryoSave->getPlugins()) { if (m_PluginList->isEnabled(pluginName)) { continue; - } else { - ++count; } + ++count; + if (count > 10) { break; } - QLabel *pluginLabel = new QLabel(gamebryoSave->plugin(i)); + QLabel *pluginLabel = new QLabel(pluginName); pluginLabel->setIndent(10); pluginLabel->setFont(contentFont); layout->addWidget(pluginLabel); diff --git a/src/savegameinfowidgetgamebryo.h b/src/savegameinfowidgetgamebryo.h index 149a8885..db6c91df 100644 --- a/src/savegameinfowidgetgamebryo.h +++ b/src/savegameinfowidgetgamebryo.h @@ -22,18 +22,16 @@ along with Mod Organizer. If not, see . #include "savegameinfowidget.h" -#include "pluginlist.h" - -class SaveGame; +class PluginList; class SaveGameInfoWidgetGamebryo : public SaveGameInfoWidget { public: - explicit SaveGameInfoWidgetGamebryo(const SaveGame *saveGame, PluginList *pluginList, QWidget *parent = 0); + explicit SaveGameInfoWidgetGamebryo(MOBase::ISaveGame const *saveGame, PluginList *pluginList, QWidget *parent = 0); - virtual void setSave(const SaveGame *saveGame); + virtual void setSave(MOBase::ISaveGame const *saveGame); private: -- cgit v1.3.1 From 6edf12f2f7089364611c7f979ad20fa867604477 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sun, 20 Dec 2015 21:22:38 +0000 Subject: Rename the save game identifier method to make it clearer what it's for. --- src/transfersavesdialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/transfersavesdialog.cpp b/src/transfersavesdialog.cpp index b6be108b..2f1c41a1 100644 --- a/src/transfersavesdialog.cpp +++ b/src/transfersavesdialog.cpp @@ -63,7 +63,7 @@ public: return QFileInfo(m_File).created(); } - virtual QString getIdentifier() const override + virtual QString getSaveGroupIdentifier() const override { return m_File; } @@ -269,7 +269,7 @@ void TransferSavesDialog::refreshSaves(SaveCollection &saveCollection, QString c for (const QString &filename : files) { QString file = savesDir.absoluteFilePath(filename); MOBase::ISaveGame const *save = info->getSaveGameInfo(file); - saveCollection[save->getIdentifier()].push_back( + saveCollection[save->getSaveGroupIdentifier()].push_back( std::unique_ptr(save)); } } -- cgit v1.3.1 From 3869eaaf2bfacf4a44733b8346d790999588c37f Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Fri, 25 Dec 2015 21:57:23 +0000 Subject: Transferring the savegame widget into gamebryo + some cleanup --- src/mainwindow.cpp | 40 +++++++++++++------------------------- src/mainwindow.h | 7 +++---- src/savegameinfowidgetgamebryo.cpp | 4 +++- src/transfersavesdialog.cpp | 4 ++++ 4 files changed, 24 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8f71f636..0a690a8e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -29,6 +29,7 @@ along with Mod Organizer. If not, see . #include "iplugingame.h" #include "iplugindiagnose.h" #include "isavegame.h" +#include "isavegameinfowidget.h" #include "nexusinterface.h" #include "organizercore.h" #include "pluginlistsortproxy.h" @@ -864,33 +865,25 @@ void MainWindow::setBrowserGeometry(const QByteArray &geometry) m_IntegratedBrowser.restoreGeometry(geometry); } -ISaveGame const *MainWindow::getSaveGame(QListWidgetItem *item) +void MainWindow::displaySaveGameInfo(QListWidgetItem *newItem) { - try { + QString const &save = newItem->data(Qt::UserRole).toString(); + if (m_CurrentSaveView == nullptr) { + //FIXME Is this the right place? IPluginGame const *game = m_OrganizerCore.managedGame(); SaveGameInfo const *info = game->feature(); if (info != nullptr) { - return info->getSaveGameInfo(item->data(Qt::UserRole).toString()); + m_CurrentSaveView = info->getSaveGameWidget(this); + } + if (m_CurrentSaveView == nullptr) { + return; } - //SaveGameGamebryo *saveGame = new SaveGameGamebryo(/*this,*/ item->data(Qt::UserRole).toString(), game); - //saveGame->setParent(item->listWidget()); - //return saveGame; - } catch (const std::exception &e) { - reportError(tr("failed to read savegame: %1").arg(e.what())); - } - return nullptr; -} - -void MainWindow::displaySaveGameInfo(MOBase::ISaveGame const *save, QPoint pos) -{ - if (m_CurrentSaveView == nullptr) { - m_CurrentSaveView = new SaveGameInfoWidgetGamebryo(save, m_OrganizerCore.pluginList(), this); - } else { - m_CurrentSaveView->setSave(save); } + m_CurrentSaveView->setSave(save); QRect screenRect = QApplication::desktop()->availableGeometry(m_CurrentSaveView); + QPoint pos = QCursor::pos(); if (pos.x() + m_CurrentSaveView->width() > screenRect.right()) { pos.rx() -= (m_CurrentSaveView->width() + 2); } else { @@ -905,8 +898,9 @@ void MainWindow::displaySaveGameInfo(MOBase::ISaveGame const *save, QPoint pos) m_CurrentSaveView->move(pos); m_CurrentSaveView->show(); + m_CurrentSaveView->setProperty("displayItem", qVariantFromValue(static_cast(newItem))); + ui->savegameList->activateWindow(); - connect(m_CurrentSaveView, SIGNAL(closeSaveInfo()), this, SLOT(hideSaveGameInfo())); } @@ -915,20 +909,14 @@ void MainWindow::saveSelectionChanged(QListWidgetItem *newItem) if (newItem == nullptr) { hideSaveGameInfo(); } else if (m_CurrentSaveView == nullptr || newItem != m_CurrentSaveView->property("displayItem").value()) { - MOBase::ISaveGame const *save = getSaveGame(newItem); - if (save != nullptr) { - displaySaveGameInfo(save, QCursor::pos()); - m_CurrentSaveView->setProperty("displayItem", qVariantFromValue(static_cast(newItem))); - } + displaySaveGameInfo(newItem); } } - void MainWindow::hideSaveGameInfo() { if (m_CurrentSaveView != nullptr) { - disconnect(m_CurrentSaveView, SIGNAL(closeSaveInfo()), this, SLOT(hideSaveGameInfo())); m_CurrentSaveView->deleteLater(); m_CurrentSaveView = nullptr; } diff --git a/src/mainwindow.h b/src/mainwindow.h index 07f24540..0fd15d85 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -256,9 +256,7 @@ private: void setCategoryListVisible(bool visible); - MOBase::ISaveGame const *getSaveGame(QListWidgetItem *item); - - void displaySaveGameInfo(MOBase::ISaveGame const *save, QPoint pos); + void displaySaveGameInfo(QListWidgetItem *newItem); HANDLE nextChildProcess(); @@ -333,7 +331,8 @@ private: QTimer m_UpdateProblemsTimer; QTime m_StartTime; - SaveGameInfoWidget *m_CurrentSaveView; + //SaveGameInfoWidget *m_CurrentSaveView; + MOBase::ISaveGameInfoWidget *m_CurrentSaveView; OrganizerCore &m_OrganizerCore; PluginContainer &m_PluginContainer; diff --git a/src/savegameinfowidgetgamebryo.cpp b/src/savegameinfowidgetgamebryo.cpp index 854043a3..1836a8f2 100644 --- a/src/savegameinfowidgetgamebryo.cpp +++ b/src/savegameinfowidgetgamebryo.cpp @@ -54,7 +54,9 @@ void SaveGameInfoWidgetGamebryo::setSave(MOBase::ISaveGame const *saveGame) layout->addWidget(header); int count = 0; for (QString const &pluginName : gamebryoSave->getPlugins()) { - if (m_PluginList->isEnabled(pluginName)) { + //if (m_PluginList->isEnabled(pluginName)) { + //should use IPluginList * in interface + if (m_PluginList->state(pluginName) == MOBase::IPluginList::STATE_ACTIVE) { continue; } diff --git a/src/transfersavesdialog.cpp b/src/transfersavesdialog.cpp index 2f1c41a1..cb3d0d61 100644 --- a/src/transfersavesdialog.cpp +++ b/src/transfersavesdialog.cpp @@ -90,6 +90,10 @@ public: return {}; } + MOBase::ISaveGameInfoWidget *getSaveGameWidget(QWidget *) const override + { + return nullptr; + } }; } //end anonymous namespace -- cgit v1.3.1 From ae6bb99c521af611989439b6db8a14a1b27866fc Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sat, 26 Dec 2015 08:23:43 +0000 Subject: Remove savegameinfowidget from organizer core --- src/CMakeLists.txt | 5 - src/mainwindow.cpp | 3 - src/mainwindow.h | 1 - src/organizer.pro | 5 - src/savegameinfowidget.cpp | 83 --------------- src/savegameinfowidget.h | 63 ----------- src/savegameinfowidget.ui | 209 ------------------------------------- src/savegameinfowidgetgamebryo.cpp | 86 --------------- src/savegameinfowidgetgamebryo.h | 42 -------- 9 files changed, 497 deletions(-) delete mode 100644 src/savegameinfowidget.cpp delete mode 100644 src/savegameinfowidget.h delete mode 100644 src/savegameinfowidget.ui delete mode 100644 src/savegameinfowidgetgamebryo.cpp delete mode 100644 src/savegameinfowidgetgamebryo.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 428f18f9..b80283af 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,8 +18,6 @@ SET(organizer_SRCS settings.cpp selfupdater.cpp selectiondialog.cpp - savegameinfowidgetgamebryo.cpp - savegameinfowidget.cpp queryoverwritedialog.cpp profilesdialog.cpp profile.cpp @@ -110,8 +108,6 @@ SET(organizer_HDRS settings.h selfupdater.h selectiondialog.h - savegameinfowidgetgamebryo.h - savegameinfowidget.h queryoverwritedialog.h profilesdialog.h profile.h @@ -200,7 +196,6 @@ SET(organizer_UIS simpleinstalldialog.ui settingsdialog.ui selectiondialog.ui - savegameinfowidget.ui queryoverwritedialog.ui profilesdialog.ui overwriteinfodialog.ui diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0a690a8e..4d608d59 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -72,8 +72,6 @@ along with Mod Organizer. If not, see . #include "browserdialog.h" #include "aboutdialog.h" #include "safewritefile.h" -#include "savegameinfowidget.h" -#include "savegameinfowidgetgamebryo.h" #include "nxmaccessmanager.h" #include "appconfig.h" #include @@ -869,7 +867,6 @@ void MainWindow::displaySaveGameInfo(QListWidgetItem *newItem) { QString const &save = newItem->data(Qt::UserRole).toString(); if (m_CurrentSaveView == nullptr) { - //FIXME Is this the right place? IPluginGame const *game = m_OrganizerCore.managedGame(); SaveGameInfo const *info = game->feature(); if (info != nullptr) { diff --git a/src/mainwindow.h b/src/mainwindow.h index 0fd15d85..177048b4 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -39,7 +39,6 @@ class LockedDialog; class OrganizerCore; #include "plugincontainer.h" //class PluginContainer; class PluginListSortProxy; -class SaveGameInfoWidget; namespace BSA { class Archive; } #include "iplugingame.h" //namespace MOBase { class IPluginGame; } namespace MOBase { class IPluginModPage; } diff --git a/src/organizer.pro b/src/organizer.pro index ee0526ed..0ef2638b 100644 --- a/src/organizer.pro +++ b/src/organizer.pro @@ -27,8 +27,6 @@ SOURCES += \ settings.cpp \ selfupdater.cpp \ selectiondialog.cpp \ - savegameinfowidgetgamebryo.cpp \ - savegameinfowidget.cpp \ queryoverwritedialog.cpp \ profilesdialog.cpp \ profile.cpp \ @@ -105,8 +103,6 @@ HEADERS += \ settings.h \ selfupdater.h \ selectiondialog.h \ - savegameinfowidgetgamebryo.h \ - savegameinfowidget.h \ queryoverwritedialog.h \ profilesdialog.h \ profile.h \ @@ -179,7 +175,6 @@ FORMS += \ simpleinstalldialog.ui \ settingsdialog.ui \ selectiondialog.ui \ - savegameinfowidget.ui \ queryoverwritedialog.ui \ profilesdialog.ui \ overwriteinfodialog.ui \ diff --git a/src/savegameinfowidget.cpp b/src/savegameinfowidget.cpp deleted file mode 100644 index bf4a9598..00000000 --- a/src/savegameinfowidget.cpp +++ /dev/null @@ -1,83 +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 . -*/ - -#include "savegameinfowidget.h" -#include "ui_savegameinfowidget.h" - -#include "isavegame.h" -#include "gamebryosavegame.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - - -SaveGameInfoWidget::SaveGameInfoWidget(QWidget *parent) - : QWidget(parent) - , ui(new Ui::SaveGameInfoWidget) -{ - ui->setupUi(this); - this->setWindowFlags(Qt::ToolTip | Qt::BypassGraphicsProxyWidget); - setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / qreal(255.0)); - ui->gameFrame->setStyleSheet("background-color: transparent;"); -// installEventFilter(this); -} - -SaveGameInfoWidget::~SaveGameInfoWidget() -{ - delete ui; -} - - -void SaveGameInfoWidget::setSave(MOBase::ISaveGame const *saveGame) -{ - GamebryoSaveGame const *game = dynamic_cast(saveGame); - ui->saveNumLabel->setText(QString("%1").arg(game->getSaveNumber())); - ui->characterLabel->setText(game->getPCName()); - ui->locationLabel->setText(game->getPCLocation()); - ui->levelLabel->setText(QString("%1").arg(game->getPCLevel())); - //This somewhat contorted code is because on my system at least, the - //old way of doing this appears to give short date and long time. - QDateTime t = saveGame->getCreationTime(); - ui->dateLabel->setText(t.date().toString(Qt::DefaultLocaleShortDate) + " " + - t.time().toString(Qt::DefaultLocaleLongDate)); - ui->screenshotLabel->setPixmap(QPixmap::fromImage(game->getScreenshot())); - if (ui->gameFrame->layout() != nullptr) { - QLayoutItem *item = nullptr; - while ((item = ui->gameFrame->layout()->takeAt(0)) != nullptr) { - delete item->widget(); - delete item; - } - ui->gameFrame->layout()->setSizeConstraint(QLayout::SetFixedSize); - } -} - -QFrame *SaveGameInfoWidget::getGameFrame() -{ - return ui->gameFrame; -} diff --git a/src/savegameinfowidget.h b/src/savegameinfowidget.h deleted file mode 100644 index c811313c..00000000 --- a/src/savegameinfowidget.h +++ /dev/null @@ -1,63 +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 . -*/ - -#ifndef SAVEGAMEINFOWIDGET_H -#define SAVEGAMEINFOWIDGET_H - -#include -#include - -class QFrame; - -namespace Ui { -class SaveGameInfoWidget; -} - -namespace MOBase { class ISaveGame; } - -class SaveGameInfoWidget : public QWidget -{ - Q_OBJECT - -public: - - explicit SaveGameInfoWidget(QWidget *parent = 0); - ~SaveGameInfoWidget(); - - virtual void setSave(MOBase::ISaveGame const *saveGame); - -signals: - - void closeSaveInfo(); - -protected: - -// virtual bool eventFilter(QObject *object, QEvent *event); - - QFrame *getGameFrame(); - -private: - -private: - - Ui::SaveGameInfoWidget *ui; - -}; - -#endif // SAVEGAMEINFOWIDGET_H diff --git a/src/savegameinfowidget.ui b/src/savegameinfowidget.ui deleted file mode 100644 index e2e9588c..00000000 --- a/src/savegameinfowidget.ui +++ /dev/null @@ -1,209 +0,0 @@ - - - SaveGameInfoWidget - - - - 0 - 0 - 400 - 300 - - - - - 0 - 0 - - - - - - - - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - - true - - - - Save # - - - - - - - - true - - - - Character - - - - - - - - true - - - - Level - - - - - - - - true - - - - Location - - - - - - - - true - - - - Date - - - - - - - - 75 - true - - - - - - - - - - - - 75 - true - - - - - - - - - - - - 75 - true - - - - - - - - - - - - 75 - true - - - - - - - - - - - - 75 - true - - - - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - false - - - - - - Qt::AlignCenter - - - - - - - - diff --git a/src/savegameinfowidgetgamebryo.cpp b/src/savegameinfowidgetgamebryo.cpp deleted file mode 100644 index 1836a8f2..00000000 --- a/src/savegameinfowidgetgamebryo.cpp +++ /dev/null @@ -1,86 +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 . -*/ - -#include "savegameinfowidgetgamebryo.h" - -#include "pluginlist.h" -#include "gamebryosavegame.h" - -#include -#include -#include -#include - - -SaveGameInfoWidgetGamebryo::SaveGameInfoWidgetGamebryo(MOBase::ISaveGame const *saveGame, PluginList *pluginList, QWidget *parent) - : SaveGameInfoWidget(parent), m_PluginList(pluginList) -{ - QVBoxLayout *gameLayout = new QVBoxLayout(); - gameLayout->setMargin(0); - gameLayout->setSpacing(2); - getGameFrame()->setLayout(gameLayout); - setSave(saveGame); -} - - -void SaveGameInfoWidgetGamebryo::setSave(MOBase::ISaveGame const *saveGame) -{ - SaveGameInfoWidget::setSave(saveGame); - GamebryoSaveGame const *gamebryoSave = dynamic_cast(saveGame); - QLayout *layout = getGameFrame()->layout(); - QLabel *header = new QLabel(tr("Missing ESPs")); - QFont headerFont = header->font(); - QFont contentFont = headerFont; - headerFont.setItalic(true); - contentFont.setBold(true); - contentFont.setPointSize(7); - header->setFont(headerFont); - layout->addWidget(header); - int count = 0; - for (QString const &pluginName : gamebryoSave->getPlugins()) { - //if (m_PluginList->isEnabled(pluginName)) { - //should use IPluginList * in interface - if (m_PluginList->state(pluginName) == MOBase::IPluginList::STATE_ACTIVE) { - continue; - } - - ++count; - - if (count > 10) { - break; - } - - QLabel *pluginLabel = new QLabel(pluginName); - pluginLabel->setIndent(10); - pluginLabel->setFont(contentFont); - layout->addWidget(pluginLabel); - } - if (count > 10) { - QLabel *dotDotLabel = new QLabel("..."); - dotDotLabel->setIndent(10); - dotDotLabel->setFont(contentFont); - layout->addWidget(dotDotLabel); - } - if (count == 0) { - QLabel *dotDotLabel = new QLabel(tr("None")); - dotDotLabel->setIndent(10); - dotDotLabel->setFont(contentFont); - layout->addWidget(dotDotLabel); - } -} diff --git a/src/savegameinfowidgetgamebryo.h b/src/savegameinfowidgetgamebryo.h deleted file mode 100644 index db6c91df..00000000 --- a/src/savegameinfowidgetgamebryo.h +++ /dev/null @@ -1,42 +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 . -*/ - -#ifndef SAVEGAMEINFOWIDGETGAMEBRYO_H -#define SAVEGAMEINFOWIDGETGAMEBRYO_H - - -#include "savegameinfowidget.h" - -class PluginList; - -class SaveGameInfoWidgetGamebryo : public SaveGameInfoWidget -{ -public: - - explicit SaveGameInfoWidgetGamebryo(MOBase::ISaveGame const *saveGame, PluginList *pluginList, QWidget *parent = 0); - - virtual void setSave(MOBase::ISaveGame const *saveGame); - -private: - - PluginList *m_PluginList; - -}; - -#endif // SAVEGAMEINFOWIDGETGAMEBRYO_H -- cgit v1.3.1 From 42417b6a010926c11beeefd7398c7e0089c09c7d Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sat, 26 Dec 2015 15:49:19 +0000 Subject: Fix missing functions and also a bit of const correctness --- src/organizerproxy.cpp | 5 +++++ src/organizerproxy.h | 1 + 2 files changed, 6 insertions(+) (limited to 'src') diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index 474f0837..de1b6d03 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -167,6 +167,11 @@ MOBase::IModList *OrganizerProxy::modList() const return m_Proxied->modList(); } +IProfile *OrganizerProxy::profile() const +{ + return m_Proxied->currentProfile(); +} + MOBase::IPluginGame const *OrganizerProxy::managedGame() const { return m_Proxied->managedGame(); diff --git a/src/organizerproxy.h b/src/organizerproxy.h index 2a0fc397..7ce8982e 100644 --- a/src/organizerproxy.h +++ b/src/organizerproxy.h @@ -38,6 +38,7 @@ public: virtual MOBase::IDownloadManager *downloadManager() const; virtual MOBase::IPluginList *pluginList() const; virtual MOBase::IModList *modList() const; + virtual MOBase::IProfile *profile() const override; virtual HANDLE startApplication(const QString &executable, const QStringList &args = QStringList(), const QString &cwd = "", const QString &profile = ""); virtual bool waitForApplication(HANDLE handle, LPDWORD exitCode = nullptr) const; virtual void refreshModList(bool saveChanges); -- cgit v1.3.1 From a4dbe82be792a75091ac57500c56b565778bc62a Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sun, 27 Dec 2015 13:50:46 +0000 Subject: Removes the gameinfo + related files from shared to hookdll --- src/CMakeLists.txt | 10 --- src/shared/fallout3info.cpp | 88 ----------------------- src/shared/fallout3info.h | 59 ---------------- src/shared/falloutnvinfo.cpp | 88 ----------------------- src/shared/falloutnvinfo.h | 59 ---------------- src/shared/gameinfo.cpp | 164 ------------------------------------------- src/shared/gameinfo.h | 95 ------------------------- src/shared/oblivioninfo.cpp | 88 ----------------------- src/shared/oblivioninfo.h | 58 --------------- src/shared/shared.pro | 10 --- src/shared/skyriminfo.cpp | 104 --------------------------- src/shared/skyriminfo.h | 62 ---------------- win.imp | 10 ++- 13 files changed, 9 insertions(+), 886 deletions(-) delete mode 100644 src/shared/fallout3info.cpp delete mode 100644 src/shared/fallout3info.h delete mode 100644 src/shared/falloutnvinfo.cpp delete mode 100644 src/shared/falloutnvinfo.h delete mode 100644 src/shared/gameinfo.cpp delete mode 100644 src/shared/gameinfo.h delete mode 100644 src/shared/oblivioninfo.cpp delete mode 100644 src/shared/oblivioninfo.h delete mode 100644 src/shared/skyriminfo.cpp delete mode 100644 src/shared/skyriminfo.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b80283af..94b75031 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -88,12 +88,7 @@ SET(organizer_SRCS shared/windows_error.cpp shared/error_report.cpp shared/directoryentry.cpp - shared/gameinfo.cpp - shared/oblivioninfo.cpp - shared/fallout3info.cpp - shared/falloutnvinfo.cpp shared/util.cpp - shared/skyriminfo.cpp shared/appconfig.cpp shared/leaktrace.cpp shared/stackdata.cpp @@ -178,12 +173,7 @@ SET(organizer_HDRS shared/windows_error.h shared/error_report.h shared/directoryentry.h - shared/gameinfo.h - shared/oblivioninfo.h - shared/fallout3info.h - shared/falloutnvinfo.h shared/util.h - shared/skyriminfo.h shared/appconfig.h shared/appconfig.inc shared/leaktrace.h diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp deleted file mode 100644 index 797d68ec..00000000 --- a/src/shared/fallout3info.cpp +++ /dev/null @@ -1,88 +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 . -*/ - -#include "fallout3info.h" -#include "util.h" -#include -#include -#include -#include "windows_error.h" -#include "error_report.h" -#define WIN32_LEAN_AND_MEAN -#include -#include - -namespace MOShared { - -Fallout3Info::Fallout3Info(const std::wstring &gameDirectory) - : GameInfo(gameDirectory) -{ - identifyMyGamesDirectory(L"fallout3"); -} - -bool Fallout3Info::identifyGame(const std::wstring &searchPath) -{ - return FileExists(searchPath, L"Fallout3.exe") && - FileExists(searchPath, L"FalloutLauncher.exe"); -} - -std::wstring Fallout3Info::getRegPathStatic() -{ - HKEY key; - LONG errorcode = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Bethesda Softworks\\Fallout3", - 0, KEY_QUERY_VALUE, &key); - - if (errorcode != ERROR_SUCCESS) { - return std::wstring(); - } - - WCHAR temp[MAX_PATH]; - DWORD bufferSize = MAX_PATH; - - if (::RegQueryValueExW(key, L"Installed Path", nullptr, nullptr, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) { - return std::wstring(temp); - } else { - return std::wstring(); - } -} - - -std::vector Fallout3Info::getIniFileNames() const -{ - return boost::assign::list_of(L"fallout.ini")(L"falloutprefs.ini"); -} - -std::wstring Fallout3Info::getReferenceDataFile() const -{ - return L"Fallout - Meshes.bsa"; -} - -bool Fallout3Info::rerouteToProfile(const wchar_t *fileName, const wchar_t*) const -{ - static LPCWSTR profileFiles[] = { L"fallout.ini", L"falloutprefs.ini", L"plugins.txt", nullptr }; - - for (int i = 0; profileFiles[i] != nullptr; ++i) { - if (_wcsicmp(fileName, profileFiles[i]) == 0) { - return true; - } - } - return false; -} - -} // namespace MOShared diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h deleted file mode 100644 index 5cf98e3b..00000000 --- a/src/shared/fallout3info.h +++ /dev/null @@ -1,59 +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 . -*/ - -#ifndef FALLOUT3INFO_H -#define FALLOUT3INFO_H - -#include "gameinfo.h" - -namespace MOShared { - - -class Fallout3Info : public GameInfo -{ - - friend class GameInfo; - -public: - - virtual ~Fallout3Info() {} - - static std::wstring getRegPathStatic(); - virtual std::wstring getRegPath() const { return getRegPathStatic(); } - - // file name of this games ini (no path) - virtual std::vector getIniFileNames() const; - - virtual std::wstring getReferenceDataFile() const; - - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) const; - - virtual std::wstring archiveListKey() const { return L"SArchiveList"; } - -private: - - Fallout3Info(const std::wstring &gameDirectory); - - static bool identifyGame(const std::wstring &searchPath); - -}; - -} // namespace MOShared - -#endif // FALLOUT3INFO_H diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp deleted file mode 100644 index 6347224d..00000000 --- a/src/shared/falloutnvinfo.cpp +++ /dev/null @@ -1,88 +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 . -*/ - -#include "falloutnvinfo.h" -#include "util.h" -#include -#include -#include -#include "windows_error.h" -#include "error_report.h" -#define WIN32_LEAN_AND_MEAN -#include -#include - -namespace MOShared { - - -FalloutNVInfo::FalloutNVInfo(const std::wstring &gameDirectory) - : GameInfo(gameDirectory) -{ - identifyMyGamesDirectory(L"falloutnv"); -} - -bool FalloutNVInfo::identifyGame(const std::wstring &searchPath) -{ - return FileExists(searchPath, L"FalloutNV.exe") && - FileExists(searchPath, L"FalloutNVLauncher.exe"); -} - -std::wstring FalloutNVInfo::getRegPathStatic() -{ - HKEY key; - LONG errorcode = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Bethesda Softworks\\FalloutNV", - 0, KEY_QUERY_VALUE, &key); - - if (errorcode != ERROR_SUCCESS) { - return std::wstring(); - } - - WCHAR temp[MAX_PATH]; - DWORD bufferSize = MAX_PATH; - - if (::RegQueryValueExW(key, L"Installed Path", nullptr, nullptr, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) { - return std::wstring(temp); - } else { - return std::wstring(); - } -} - -std::vector FalloutNVInfo::getIniFileNames() const -{ - return boost::assign::list_of(L"fallout.ini")(L"falloutprefs.ini"); -} - -std::wstring FalloutNVInfo::getReferenceDataFile() const -{ - return L"Fallout - Meshes.bsa"; -} - -bool FalloutNVInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t*) const -{ - static LPCWSTR profileFiles[] = { L"fallout.ini", L"falloutprefs.ini", L"plugins.txt", nullptr }; - - for (int i = 0; profileFiles[i] != nullptr; ++i) { - if (_wcsicmp(fileName, profileFiles[i]) == 0) { - return true; - } - } - return false; -} - -} // namespace MOShared diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h deleted file mode 100644 index 04c13c7d..00000000 --- a/src/shared/falloutnvinfo.h +++ /dev/null @@ -1,59 +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 . -*/ - -#ifndef FALLOUTNVINFO_H -#define FALLOUTNVINFO_H - - -#include "gameinfo.h" - -namespace MOShared { - - -class FalloutNVInfo : public GameInfo -{ - - friend class GameInfo; - -public: - - virtual ~FalloutNVInfo() {} - - static std::wstring getRegPathStatic(); - virtual std::wstring getRegPath() const { return getRegPathStatic(); } - - // file name of this games ini (no path) - virtual std::vector getIniFileNames() const; - - virtual std::wstring getReferenceDataFile() const; - - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) const; - - virtual std::wstring archiveListKey() const { return L"SArchiveList"; } - -private: - - FalloutNVInfo(const std::wstring &gameDirectory); - - static bool identifyGame(const std::wstring &searchPath); -}; - -} // namespace MOShared - -#endif // FALLOUTNVINFO_H diff --git a/src/shared/gameinfo.cpp b/src/shared/gameinfo.cpp deleted file mode 100644 index 5c13a520..00000000 --- a/src/shared/gameinfo.cpp +++ /dev/null @@ -1,164 +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 . -*/ - -#include "gameinfo.h" - -#include "windows_error.h" - -#include "oblivioninfo.h" -#include "fallout3info.h" -#include "falloutnvinfo.h" -#include "skyriminfo.h" -#include "util.h" - -#include -#include - -#include -#include -#include - -namespace MOShared { - - -GameInfo* GameInfo::s_Instance = nullptr; - - -GameInfo::GameInfo(const std::wstring &gameDirectory) - : m_GameDirectory(gameDirectory) -{ - atexit(&cleanup); -} - - -void GameInfo::cleanup() { - delete GameInfo::s_Instance; - GameInfo::s_Instance = nullptr; -} - - -void GameInfo::identifyMyGamesDirectory(const std::wstring &file) -{ - // this function attempts 3 (three!) ways to determine the correct "My Games" folder. - wchar_t myDocuments[MAX_PATH]; - memset(myDocuments, '\0', MAX_PATH * sizeof(wchar_t)); - - m_MyGamesDirectory.clear(); - - // a) this is the way it should work. get the configured My Documents\My Games directory - if (::SHGetFolderPathW(nullptr, CSIDL_PERSONAL, nullptr, SHGFP_TYPE_CURRENT, myDocuments) == S_OK) { - m_MyGamesDirectory = std::wstring(myDocuments) + L"\\My Games"; - } - - // b) if there is no directory there, look in the default directory - if (m_MyGamesDirectory.empty() - || !FileExists(m_MyGamesDirectory + L"\\" + file)) { - if (::SHGetFolderPathW(nullptr, CSIDL_PERSONAL, nullptr, SHGFP_TYPE_DEFAULT, myDocuments) == S_OK) { - std::wstring fromDefault = std::wstring(myDocuments) + L"\\My Games"; - if (FileExists(fromDefault + L"\\" + file)) { - m_MyGamesDirectory = fromDefault; - } - } - } - // c) finally, look in the registry. This is discouraged - if (m_MyGamesDirectory.empty() - || !FileExists(m_MyGamesDirectory + L"\\" + file)) { - std::wstring fromRegistry = getSpecialPath(L"Personal") + L"\\My Games"; - if (FileExists(fromRegistry + L"\\" + file)) { - m_MyGamesDirectory = fromRegistry; - } - } -} - -bool GameInfo::identifyGame(const std::wstring &searchPath) -{ - if (OblivionInfo::identifyGame(searchPath)) { - s_Instance = new OblivionInfo(searchPath); - } else if (Fallout3Info::identifyGame(searchPath)) { - s_Instance = new Fallout3Info(searchPath); - } else if (FalloutNVInfo::identifyGame(searchPath)) { - s_Instance = new FalloutNVInfo(searchPath); - } else if (SkyrimInfo::identifyGame(searchPath)) { - s_Instance = new SkyrimInfo(searchPath); - } - - return s_Instance != nullptr; -} - - -bool GameInfo::init(const std::wstring &moDirectory, const std::wstring &gamePath) -{ - if (s_Instance == nullptr) { - if (gamePath.length() == 0) { - // search upward in the directory until a recognized game-binary is found - std::wstring searchPath(moDirectory); - while (!identifyGame(searchPath)) { - size_t lastSep = searchPath.find_last_of(L"/\\"); - if (lastSep == std::string::npos) { - return false; - } - searchPath.erase(lastSep); - } - } else if (!identifyGame(gamePath)) { - return false; - } - } - return true; -} - - -GameInfo &GameInfo::instance() -{ - assert(s_Instance != nullptr && "gameinfo not yet initialized"); - return *s_Instance; -} - -std::wstring GameInfo::getGameDirectory() const -{ - return m_GameDirectory; -} - -std::wstring GameInfo::getSpecialPath(LPCWSTR name) const -{ - HKEY key; - LONG errorcode = ::RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders", - 0, KEY_QUERY_VALUE, &key); - - if (errorcode != ERROR_SUCCESS) { - throw windows_error("failed to look up special folder (path)", errorcode); - } - - WCHAR temp[MAX_PATH]; - DWORD bufferSize = MAX_PATH; - - errorcode = ::RegQueryValueExW(key, name, nullptr, nullptr, (LPBYTE)temp, &bufferSize); - if (errorcode != ERROR_SUCCESS) { - throw windows_error((boost::format("failed to look up special folder (%1%)") % ToString(name, true)).str(), errorcode); - } - - WCHAR temp2[MAX_PATH]; - // try to expand variables in the path, if any - if (::ExpandEnvironmentStringsW(temp, temp2, MAX_PATH) != 0) { - return temp2; - } else { - return temp; - } -} - -} // namespace MOShared diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h deleted file mode 100644 index 7bc86d3a..00000000 --- a/src/shared/gameinfo.h +++ /dev/null @@ -1,95 +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 . -*/ - -#ifndef GAMEINFO_H -#define GAMEINFO_H - -#include -#include -#include - -#define WIN32_LEAN_AND_MEAN -#include - -namespace MOShared { - - -/** - Class to manage information that depends on the used game type. The intention is to keep - as much of the rest of omo is game-agnostic. It is mostly concerned with figuring out the - correct paths, filenames and data types. -*/ -class GameInfo -{ - -public: - - virtual ~GameInfo() {} - - //**USED IN HOOKDLL and at startup to set up for hookdll to work - // initialise with the path to the mo directory (needs to be where hook.dll is stored). This - // needs to be called before the instance can be retrieved - static bool init(const std::wstring &moDirectory, const std::wstring &gamePath = L""); - - //**USED ONLY IN HOOKDLL - static GameInfo& instance(); - - //**USED ONLY IN HOOKDLL - virtual std::wstring getGameDirectory() const; - - //**USED ONLY IN HOOKDLL - virtual std::wstring getRegPath() const = 0; - - //**USED ONLY IN HOOKDLL - // file name of this games ini file(s) - virtual std::vector getIniFileNames() const = 0; - - //**USED ONLY IN HOOKDLL - virtual std::wstring getReferenceDataFile() const = 0; - - //**USED ONLY IN HOOKDLL - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) const = 0; - -protected: - - GameInfo(const std::wstring &gameDirectory); - - void identifyMyGamesDirectory(const std::wstring &file); - -private: - - static bool identifyGame(const std::wstring &searchPath); - std::wstring getSpecialPath(LPCWSTR name) const; - - static void cleanup(); - -private: - - static GameInfo *s_Instance; - - std::wstring m_MyGamesDirectory; - - std::wstring m_GameDirectory; - -}; - - -} // namespace MOShared - -#endif // GAMEINFO_H diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp deleted file mode 100644 index b50f1daa..00000000 --- a/src/shared/oblivioninfo.cpp +++ /dev/null @@ -1,88 +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 . -*/ - -#include "oblivioninfo.h" -#include -#include -#include "util.h" -#include -#include "windows_error.h" -#include "error_report.h" -#define WIN32_LEAN_AND_MEAN -#include -#include - -namespace MOShared { - - -OblivionInfo::OblivionInfo(const std::wstring &gameDirectory) - : GameInfo(gameDirectory) -{ - identifyMyGamesDirectory(L"oblivion"); -} - -bool OblivionInfo::identifyGame(const std::wstring &searchPath) -{ - return FileExists(searchPath, L"Oblivion.exe") && - FileExists(searchPath, L"OblivionLauncher.exe"); -} - -std::wstring OblivionInfo::getRegPathStatic() -{ - HKEY key; - LONG errorcode = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Bethesda Softworks\\Oblivion", - 0, KEY_QUERY_VALUE, &key); - - if (errorcode != ERROR_SUCCESS) { - return std::wstring(); - } - - WCHAR temp[MAX_PATH]; - DWORD bufferSize = MAX_PATH; - - if (::RegQueryValueExW(key, L"Installed Path", nullptr, nullptr, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) { - return std::wstring(temp); - } else { - return std::wstring(); - } -} - -std::vector OblivionInfo::getIniFileNames() const -{ - return boost::assign::list_of(L"oblivion.ini")(L"oblivionprefs.ini"); -} - -bool OblivionInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t*) const -{ - static LPCWSTR profileFiles[] = { L"oblivion.ini", L"oblivionprefs.ini", L"plugins.txt", nullptr }; - - for (int i = 0; profileFiles[i] != nullptr; ++i) { - if (_wcsicmp(fileName, profileFiles[i]) == 0) { - return true; - } - } - return false; -} - -std::wstring OblivionInfo::getReferenceDataFile() const -{ - return L"Oblivion - Meshes.bsa"; -} - -} // namespace MOShared diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h deleted file mode 100644 index bf0b2707..00000000 --- a/src/shared/oblivioninfo.h +++ /dev/null @@ -1,58 +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 . -*/ - -#ifndef OBLIVIONINFO_H -#define OBLIVIONINFO_H - -#include "gameinfo.h" - -namespace MOShared { - -class OblivionInfo : public GameInfo -{ - - friend class GameInfo; - -public: - - virtual ~OblivionInfo() {} - - static std::wstring getRegPathStatic(); - virtual std::wstring getRegPath() const { return getRegPathStatic(); } - - // file name of this games ini (no path) - virtual std::vector getIniFileNames() const; - - virtual std::wstring getReferenceDataFile() const; - - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) const; - - virtual std::wstring archiveListKey() const { return L"SArchiveList"; } - -private: - - OblivionInfo(const std::wstring &gameDirectory); - - static bool identifyGame(const std::wstring &searchPath); - -}; - -} // namespace MOShared - -#endif // OBLIVIONINFO_H diff --git a/src/shared/shared.pro b/src/shared/shared.pro index a64e781d..517e1e86 100644 --- a/src/shared/shared.pro +++ b/src/shared/shared.pro @@ -21,12 +21,7 @@ SOURCES += \ windows_error.cpp \ error_report.cpp \ directoryentry.cpp \ - gameinfo.cpp \ - oblivioninfo.cpp \ - fallout3info.cpp \ - falloutnvinfo.cpp \ util.cpp \ - skyriminfo.cpp \ appconfig.cpp \ leaktrace.cpp \ stackdata.cpp @@ -36,12 +31,7 @@ HEADERS += \ windows_error.h \ error_report.h \ directoryentry.h \ - gameinfo.h \ - oblivioninfo.h \ - fallout3info.h \ - falloutnvinfo.h \ util.h \ - skyriminfo.h \ appconfig.h \ appconfig.inc \ leaktrace.h \ diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp deleted file mode 100644 index 9662e66d..00000000 --- a/src/shared/skyriminfo.cpp +++ /dev/null @@ -1,104 +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 . -*/ - -#include "skyriminfo.h" - -#include "util.h" -#include -#include -#include -#include "windows_error.h" -#include "error_report.h" -#define WIN32_LEAN_AND_MEAN -#include -#include -#include - -namespace MOShared { - - -SkyrimInfo::SkyrimInfo(const std::wstring &gameDirectory) - : GameInfo(gameDirectory) -{ - identifyMyGamesDirectory(L"skyrim"); - - wchar_t appDataPath[MAX_PATH]; - if (SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, appDataPath))) { - m_AppData = appDataPath; - } -} - -bool SkyrimInfo::identifyGame(const std::wstring &searchPath) -{ - return FileExists(searchPath, L"TESV.exe") && - FileExists(searchPath, L"SkyrimLauncher.exe"); -} - - - - -std::wstring SkyrimInfo::getRegPathStatic() -{ - HKEY key; - LONG errorcode = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Bethesda Softworks\\Skyrim", - 0, KEY_QUERY_VALUE, &key); - - if (errorcode != ERROR_SUCCESS) { - return std::wstring(); - } - - WCHAR temp[MAX_PATH]; - DWORD bufferSize = MAX_PATH; - - if (::RegQueryValueExW(key, L"Installed Path", nullptr, nullptr, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) { - return std::wstring(temp); - } else { - return std::wstring(); - } -} - -std::vector SkyrimInfo::getIniFileNames() const -{ - return boost::assign::list_of(L"skyrim.ini")(L"skyrimprefs.ini"); -} - -std::wstring SkyrimInfo::getReferenceDataFile() const -{ - return L"Skyrim - Meshes.bsa"; -} - -bool SkyrimInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) const -{ - static LPCWSTR profileFiles[] = { L"skyrim.ini", L"skyrimprefs.ini", L"loadorder.txt", nullptr }; - - for (int i = 0; profileFiles[i] != nullptr; ++i) { - if (_wcsicmp(fileName, profileFiles[i]) == 0) { - return true; - } - } - - if ((_wcsicmp(fileName, L"plugins.txt") == 0) && - (m_AppData.empty() || (StrStrIW(fullPath, m_AppData.c_str()) != nullptr))) { - return true; - } - - return false; -} - -} // namespace MOShared diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h deleted file mode 100644 index bd329403..00000000 --- a/src/shared/skyriminfo.h +++ /dev/null @@ -1,62 +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 . -*/ - -#ifndef SKYRIMINFO_H -#define SKYRIMINFO_H - - -#include "gameinfo.h" - -namespace MOShared { - - -class SkyrimInfo : public GameInfo -{ - - friend class GameInfo; - -public: - - virtual ~SkyrimInfo() {} - - static std::wstring getRegPathStatic(); - virtual std::wstring getRegPath() const { return getRegPathStatic(); } - - // file name of this games ini (no path) - virtual std::vector getIniFileNames() const; - - virtual std::wstring getReferenceDataFile() const; - - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) const; - -private: - - SkyrimInfo(const std::wstring &gameDirectory); - - static bool identifyGame(const std::wstring &searchPath); - -private: - - std::wstring m_AppData; - -}; - -} // namespace MOShared - -#endif // SKYRIMINFO_H diff --git a/win.imp b/win.imp index cbecdc43..24635775 100644 --- a/win.imp +++ b/win.imp @@ -54,10 +54,18 @@ { include: [ "", "private", "", "public" ] }, # official name according to website { include: [ "", "private", "", "public" ] }, # - { include: [ "", "private", "", "public" ] }, { include: [ "", "private", "", "public" ] }, { include: [ "", "private", "", "public" ] }, +# These ones are in shtypes.h but the only documentation I can find says +# to include Knownfolders.h for these + { symbol: [ "REFKNOWNFOLDERID", "private", "", "public" ] }, + { symbol: [ "KNOWNFOLDERID", "private", "", "public" ] }, + +# IWYU doesn't understand upper/lower case which is *really* annoying on +# windows, though to be fair I'm not sure M/S understand it either. + { include: [ "", "private", "", "public" ] }, + # Files that are included by other files which seem to then come for free in Windows.h but # shouldn't. Again, should be cleaned up. -- cgit v1.3.1 From d07b4f7ff00b1113809c7824e7cd17518d92dc6b Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Thu, 31 Dec 2015 23:08:24 +0000 Subject: Fixes an issue with doing connect for download cancel at the wrong time Also cleaned up header usage per include-what-you-use --- src/selfupdater.cpp | 32 +++++++++++++++++++++++++++----- src/selfupdater.h | 17 ++++++++++------- 2 files changed, 37 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/selfupdater.cpp b/src/selfupdater.cpp index 11478fbc..e402d03c 100644 --- a/src/selfupdater.cpp +++ b/src/selfupdater.cpp @@ -19,6 +19,8 @@ along with Mod Organizer. If not, see . #include "selfupdater.h" +#include "archive.h" +#include "callback.h" #include "utility.h" #include "installationmanager.h" #include "iplugingame.h" @@ -30,15 +32,36 @@ along with Mod Organizer. If not, see . #include #include +#include +#include +#include +#include +#include #include #include #include -#include -#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + #include +#include //for VS_FIXEDFILEINFO, GetLastError + +#include +#include +#include //for size_t +#include using namespace MOBase; using namespace MOShared; @@ -77,8 +100,6 @@ SelfUpdater::SelfUpdater(NexusInterface *nexusInterface) throw MyException(InstallationManager::getErrorString(m_ArchiveHandler->getLastError())); } - connect(m_Progress, SIGNAL(canceled()), this, SLOT(downloadCancel())); - VS_FIXEDFILEINFO version = GetFileVersion(ToWString(QApplication::applicationFilePath())); m_MOVersion = VersionInfo(version.dwFileVersionMS >> 16, @@ -135,6 +156,7 @@ void SelfUpdater::showProgress() { if (m_Progress == nullptr) { m_Progress = new QProgressDialog(m_Parent, Qt::Dialog); + connect(m_Progress, SIGNAL(canceled()), this, SLOT(downloadCancel())); } m_Progress->setModal(true); m_Progress->show(); diff --git a/src/selfupdater.h b/src/selfupdater.h index 446778fb..37021b42 100644 --- a/src/selfupdater.h +++ b/src/selfupdater.h @@ -21,17 +21,20 @@ along with Mod Organizer. If not, see . #define SELFUPDATER_H -#include #include -#include -#include -#include -#include - +class Archive; +class NexusInterface; namespace MOBase { class IPluginGame; } -class NexusInterface; +#include +#include +#include +#include +#include //for qint64 + +class QNetworkReply; +class QProgressDialog; /** -- cgit v1.3.1 From 387326f2d62fe02babe3594e2e00f831355da9b7 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sat, 23 Jan 2016 07:29:06 +0000 Subject: thoughts --- SConstruct | 14 ++++++++++++++ src/organizercore.h | 2 +- src/organizerproxy.cpp | 5 +++++ src/organizerproxy.h | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/SConstruct b/SConstruct index b52cf509..c7248251 100644 --- a/SConstruct +++ b/SConstruct @@ -623,6 +623,20 @@ if qt_env['QT_MAJOR_VERSION'] > 4: ] # Finally, set up rules to install the DLLs. +# use windeployqt.exe to install all required libraries +#SET(windeploy_parameters --no-translations --no-plugins --libdir dlls --release-with-debug-info --no-compiler-runtime) +#INSTALL( +# CODE +# "EXECUTE_PROCESS( +# COMMAND +# ${qt5bin}/windeployqt.exe ModOrganizer.exe ${windeploy_parameters} +# COMMAND +# ${qt5bin}/windeployqt.exe uibase.dll ${windeploy_parameters} +# WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin +# )" +#) +# this should probably be a rule though it seems to produce an awful lot of +# Stuff(TM). or a postaction dll_path = os.path.join('$INSTALL_PATH', 'DLLs') diff --git a/src/organizercore.h b/src/organizercore.h index 5cfbaca4..f4cfabe7 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -89,7 +89,7 @@ public: m_ExecutablesList = executablesList; } - Profile *currentProfile() { return m_CurrentProfile; } + Profile *currentProfile() const { return m_CurrentProfile; } void setCurrentProfile(const QString &profileName); std::vector enabledArchives(); diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index ba07c154..b289b659 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -166,6 +166,11 @@ MOBase::IModList *OrganizerProxy::modList() const return m_Proxied->modList(); } +MOBase::IProfile *OrganizerProxy::profile() const +{ + return m_Proxied->currentProfile(); +} + MOBase::IPluginGame const *OrganizerProxy::managedGame() const { return m_Proxied->managedGame(); diff --git a/src/organizerproxy.h b/src/organizerproxy.h index 62a35498..95543ba3 100644 --- a/src/organizerproxy.h +++ b/src/organizerproxy.h @@ -37,6 +37,7 @@ public: virtual MOBase::IDownloadManager *downloadManager() const; virtual MOBase::IPluginList *pluginList() const; virtual MOBase::IModList *modList() const; + virtual MOBase::IProfile *profile() const override; virtual HANDLE startApplication(const QString &executable, const QStringList &args = QStringList(), const QString &cwd = "", const QString &profile = ""); virtual bool waitForApplication(HANDLE handle, LPDWORD exitCode = nullptr) const; virtual void refreshModList(bool saveChanges); -- cgit v1.3.1