diff options
| author | Thomas Tanner <trtanner@btinternet.com> | 2015-12-20 21:08:14 +0000 |
|---|---|---|
| committer | Thomas Tanner <trtanner@btinternet.com> | 2015-12-20 21:08:14 +0000 |
| commit | f55a5f2b21664ccd2af1c24ef68f14f73e418b1c (patch) | |
| tree | 968bfb8e726271fa6096cb4410acb53319af1d4f | |
| parent | 5f5184ebfe9a6b7102654863cbb390a610ab1563 (diff) | |
Managed to remove SaveGame and SaveGameGamebryo classes from organizer
| -rw-r--r-- | src/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 32 | ||||
| -rw-r--r-- | src/mainwindow.h | 8 | ||||
| -rw-r--r-- | src/organizer.pro | 6 | ||||
| -rw-r--r-- | src/savegame.cpp | 31 | ||||
| -rw-r--r-- | src/savegame.h | 109 | ||||
| -rw-r--r-- | src/savegamegamebryo.cpp | 66 | ||||
| -rw-r--r-- | src/savegamegamebryo.h | 78 | ||||
| -rw-r--r-- | src/savegameinfowidget.cpp | 38 | ||||
| -rw-r--r-- | src/savegameinfowidget.h | 8 | ||||
| -rw-r--r-- | src/savegameinfowidgetgamebryo.cpp | 22 | ||||
| -rw-r--r-- | src/savegameinfowidgetgamebryo.h | 8 |
12 files changed, 68 insertions, 342 deletions
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<SaveGameInfo>();
+ 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<void*>())) {
- const SaveGameGamebryo *save = getSaveGame(newItem);
+ } else if (m_CurrentSaveView == nullptr || newItem != m_CurrentSaveView->property("displayItem").value<void*>()) {
+ 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<void *>(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 <QByteArray>
@@ -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 <http://www.gnu.org/licenses/>.
-*/
-
-#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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef SAVEGAME_H
-#define SAVEGAME_H
-
-
-#include <QString>
-#include <QObject>
-#include <QImage>
-
-//Sigh - for SYSTEMTIME
-#define WIN32_LEAN_AND_MEAN
-#include <Windows.h>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "savegamegamebryo.h"
-
-#include "isavegame.h"
-#include "savegameinfo.h"
-#include "iplugingame.h"
-#include "gamebryosavegame.h"
-
-#include <limits>
-#include <set>
-
-using namespace MOBase;
-
-
-SaveGameGamebryo::SaveGameGamebryo(QObject *parent, const QString &fileName, IPluginGame const *game)
- : SaveGame(parent, fileName, game)
- , m_Plugins()
-{
- SaveGameInfo const *info = game->feature<SaveGameInfo>();
- if (info != nullptr) {
- ISaveGame const *save = info->getSaveGameInfo(fileName);
- m_Save = save;
-
- //Kludgery
- GamebryoSaveGame const *s = dynamic_cast<GamebryoSaveGame const *>(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<WORD>(modified.date().day());
- m_CreationTime.wDayOfWeek = static_cast<WORD>(modified.date().dayOfWeek());
- m_CreationTime.wMonth = static_cast<WORD>(modified.date().month());
- m_CreationTime.wYear =static_cast<WORD>( modified.date().year());
-
- m_CreationTime.wHour = static_cast<WORD>(modified.time().hour());
- m_CreationTime.wMinute = static_cast<WORD>(modified.time().minute());
- m_CreationTime.wSecond = static_cast<WORD>(modified.time().second());
- m_CreationTime.wMilliseconds = static_cast<WORD>(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 <http://www.gnu.org/licenses/>. -*/ - -#ifndef SAVEGAMEGAMEBRYO_H -#define SAVEGAMEGAMEBRYO_H - -#include "savegame.h" - -#include <QMetaType> -#include <QObject> -#include <QString> -#include <QStringList> - -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 <http://www.gnu.org/licenses/>. #include "savegameinfowidget.h"
#include "ui_savegameinfowidget.h"
-#include "utility.h"
-#include "savegame.h"
-#include <QGraphicsDropShadowEffect>
+
+#include "isavegame.h"
+#include "gamebryosavegame.h"
+
+#include <QDate>
+#include <QDateTime>
+#include <QFrame>
+#include <QLabel>
+#include <QLayout>
+#include <QLayoutItem>
+#include <QPixmap>
+#include <QString>
+#include <QStyle>
+#include <QTime>
+
+#include <Qt>
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<GamebryoSaveGame const *>(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 <http://www.gnu.org/licenses/>. #ifndef SAVEGAMEINFOWIDGET_H
#define SAVEGAMEINFOWIDGET_H
+#include <QObject>
#include <QWidget>
-#include <QFrame>
+
+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 <http://www.gnu.org/licenses/>.
*/
-#include "savegamegamebryo.h"
#include "savegameinfowidgetgamebryo.h"
+
+#include "pluginlist.h"
+#include "gamebryosavegame.h"
+
+#include <QFont>
#include <QLabel>
+#include <QLayout>
#include <QVBoxLayout>
-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<const SaveGameGamebryo*>(saveGame);
+ GamebryoSaveGame const *gamebryoSave = dynamic_cast<GamebryoSaveGame const *>(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 <http://www.gnu.org/licenses/>. #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:
|
