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 --- src/savegameinfowidgetgamebryo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/savegameinfowidgetgamebryo.cpp') 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 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/savegameinfowidgetgamebryo.cpp') 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 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/savegameinfowidgetgamebryo.cpp') 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/savegameinfowidgetgamebryo.cpp') 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