From 4174d3c235dad55d2ec7a908576861cd51ca3b98 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Wed, 10 Oct 2012 21:31:40 +0200 Subject: [PATCH 001/107] Added new plugin model for the Data Files tab in the launcher --- apps/launcher/CMakeLists.txt | 18 +- apps/launcher/model/datafilesmodel.cpp | 443 +++++++++++++++++++++++++ apps/launcher/model/datafilesmodel.hpp | 67 ++++ apps/launcher/model/esm/esmfile.cpp | 50 +++ apps/launcher/model/esm/esmfile.hpp | 54 +++ apps/launcher/model/modelitem.cpp | 57 ++++ apps/launcher/model/modelitem.hpp | 32 ++ 7 files changed, 718 insertions(+), 3 deletions(-) create mode 100644 apps/launcher/model/datafilesmodel.cpp create mode 100644 apps/launcher/model/datafilesmodel.hpp create mode 100644 apps/launcher/model/esm/esmfile.cpp create mode 100644 apps/launcher/model/esm/esmfile.hpp create mode 100644 apps/launcher/model/modelitem.cpp create mode 100644 apps/launcher/model/modelitem.hpp diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index 2bc43db80..53631ebdd 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -1,5 +1,6 @@ set(LAUNCHER datafilespage.cpp + filedialog.cpp graphicspage.cpp lineedit.cpp main.cpp @@ -8,14 +9,18 @@ set(LAUNCHER playpage.cpp pluginsmodel.cpp pluginsview.cpp - filedialog.cpp launcher.rc + + model/datafilesmodel.cpp + model/modelitem.cpp + model/esm/esmfile.cpp ) set(LAUNCHER_HEADER combobox.hpp datafilespage.hpp + filedialog.hpp graphicspage.hpp lineedit.hpp maindialog.hpp @@ -23,20 +28,27 @@ set(LAUNCHER_HEADER playpage.hpp pluginsmodel.hpp pluginsview.hpp - filedialog.hpp + + model/datafilesmodel.hpp + model/modelitem.hpp + model/esm/esmfile.hpp ) # Headers that must be pre-processed set(LAUNCHER_HEADER_MOC combobox.hpp datafilespage.hpp + filedialog.hpp graphicspage.hpp lineedit.hpp maindialog.hpp playpage.hpp pluginsmodel.hpp pluginsview.hpp - filedialog.hpp + + model/datafilesmodel.hpp + model/modelitem.hpp + model/esm/esmfile.hpp ) source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER} ${LAUNCHER_HEADER_MOC}) diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp new file mode 100644 index 000000000..be89902c8 --- /dev/null +++ b/apps/launcher/model/datafilesmodel.cpp @@ -0,0 +1,443 @@ +#include +#include +#include + +#include + +#include "esm/esmfile.hpp" + +#include "datafilesmodel.hpp" +#include "../naturalsort.hpp" + +DataFilesModel::DataFilesModel(QObject *parent) : + QAbstractTableModel(parent) +{ +} + +DataFilesModel::~DataFilesModel() +{ +} + +void DataFilesModel::setCheckState(const QModelIndex &index, Qt::CheckState state) +{ + setData(index, state, Qt::CheckStateRole); +} + +Qt::CheckState DataFilesModel::checkState(const QModelIndex &index) +{ + EsmFile *file = item(index.row()); + return mCheckStates[file->fileName()]; +} + +int DataFilesModel::columnCount(const QModelIndex &parent) const +{ + return parent.isValid() ? 0 : 9; +} + +int DataFilesModel::rowCount(const QModelIndex &parent) const +{ + return parent.isValid() ? 0 : mFiles.count(); +} + + +bool DataFilesModel::moveRow(int oldrow, int row, const QModelIndex &parent) +{ + if (oldrow < 0 || row < 0 || oldrow == row) + return false; + + emit layoutAboutToBeChanged(); + //emit beginMoveRows(parent, oldrow, oldrow, parent, row); + mFiles.swap(oldrow, row); + //emit endInsertRows(); + emit layoutChanged(); + + return true; +} + +QVariant DataFilesModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + +// if (index.row() < 0 || index.row() >= mPlugins.size()) +// return QVariant(); + + EsmFile *file = mFiles.at(index.row()); + + const int column = index.column(); + + switch (role) { + case Qt::DisplayRole: { + + switch (column) { + case 0: + return file->fileName(); + case 1: + return file->author(); + case 2: + return QString("%1 kB").arg(int((file->size() + 1023) / 1024)); + case 3: + //return file->modified().toString(Qt::TextDate); + return file->modified().toString(Qt::ISODate); + case 4: + return file->accessed().toString(Qt::TextDate); + case 5: + return file->version(); + case 6: + return file->path(); + case 7: + return file->masters().join(", "); + case 8: + return file->description(); + } + } + + case Qt::TextAlignmentRole: { + switch (column) { + case 0: + return Qt::AlignLeft + Qt::AlignVCenter; + case 1: + return Qt::AlignLeft + Qt::AlignVCenter; + case 2: + return Qt::AlignRight + Qt::AlignVCenter; + case 3: + return Qt::AlignRight + Qt::AlignVCenter; + case 4: + return Qt::AlignRight + Qt::AlignVCenter; + case 5: + return Qt::AlignRight + Qt::AlignVCenter; + default: + return Qt::AlignLeft + Qt::AlignVCenter; + } + } + + case Qt::CheckStateRole: { + if (column != 0) + return QVariant(); + return mCheckStates[file->fileName()]; + } + case Qt::ToolTipRole: + { + if (column != 0) + return QVariant(); + + if (file->version() == 0.0f) + return QVariant(); // Data not set + + QString tooltip = + QString("Author: %1
\ + Version: %2
\ +
Description:
%3
\ +
Dependencies: %4
") + .arg(file->author()) + .arg(QString::number(file->version())) + .arg(file->description()) + .arg(file->masters().join(", ")); + + + return tooltip; + + } + default: + return QVariant(); + } + +} + +Qt::ItemFlags DataFilesModel::flags(const QModelIndex &index) const +{ + if (!index.isValid()) + return Qt::NoItemFlags; + + EsmFile *file = mFiles.at(index.row()); + + if (mAvailableFiles.contains(file->fileName())) { + if (index.column() == 0) { + return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable; + } else { + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + } + } else { + if (index.column() == 0) { + return Qt::ItemIsUserCheckable | Qt::ItemIsSelectable; + } else { + return Qt::NoItemFlags | Qt::ItemIsSelectable; + } + } + +} + +QVariant DataFilesModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (role != Qt::DisplayRole) + return QVariant(); + + if (orientation == Qt::Horizontal) { + switch (section) { + case 0: return tr("Name"); + case 1: return tr("Author"); + case 2: return tr("Size"); + case 3: return tr("Modified"); + case 4: return tr("Accessed"); + case 5: return tr("Version"); + case 6: return tr("Path"); + case 7: return tr("Masters"); + case 8: return tr("Description"); + } + } else { + // Show row numbers + return ++section; + } + + return QVariant(); +} + +bool DataFilesModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if (!index.isValid()) + return false; + + if (role == Qt::CheckStateRole) { + + emit layoutAboutToBeChanged(); + + QString name = item(index.row())->fileName(); + mCheckStates[name] = static_cast(value.toInt()); + + emit checkedItemsChanged(checkedItems(), uncheckedItems()); + emit layoutChanged(); + return true; + } + + return false; +} + +void DataFilesModel::sort(int column, Qt::SortOrder order) +{ + // TODO: Make this more efficient + emit layoutAboutToBeChanged(); + + // A reference list we can sort + QStringList all = uncheckedItems(); + //all.append(uncheckedItems()); + + // Sort the list of items naturally + qSort(all.begin(), all.end(), naturalSortLessThanCI); + + for (int i = 0; i < all.size(); ++i) { + const QString currentItem = all.at(i); + QModelIndex index = indexFromItem(findItem(currentItem)); + + // Move the actual item from the old position to the new + if (index.isValid()) + mFiles.swap(index.row(), i); + } + + emit layoutChanged(); +} + +void DataFilesModel::addFile(EsmFile *file) +{ + emit beginInsertRows(QModelIndex(), mFiles.count(), mFiles.count()); + mFiles.append(file); + emit endInsertRows(); +} + +void DataFilesModel::addMasters(const QString &path) +{ + QDir dir(path); + dir.setNameFilters(QStringList(QLatin1String("*.esp"))); + + // Read the dependencies from the plugins + foreach (const QString &path, dir.entryList()) { + QFileInfo info(dir.absoluteFilePath(path)); + + try { + ESM::ESMReader fileReader; + fileReader.setEncoding(std::string("win1252")); + fileReader.open(dir.absoluteFilePath(path).toStdString()); + + ESM::ESMReader::MasterList mlist = fileReader.getMasters(); + + for (unsigned int i = 0; i < mlist.size(); ++i) { + QString master = QString::fromStdString(mlist[i].name); + + // Add the plugin to the internal dependency map + mDependencies[master].append(path); + + // Don't add esps + if (master.endsWith(".esp", Qt::CaseInsensitive)) + continue; + + EsmFile *file = new EsmFile(master); + + // Add the master to the table + if (findItem(master) == 0) + addFile(file); + + + } + + } catch(std::runtime_error &e) { + // An error occurred while reading the .esp + continue; + } + } + + // See if the masters actually exist in the filesystem + dir.setNameFilters(QStringList(QLatin1String("*.esm"))); + + foreach (const QString &path, dir.entryList()) { + + if (findItem(path) == 0) { + EsmFile *file = new EsmFile(path); + addFile(file); + } + + // Make the master selectable + mAvailableFiles.append(path); + } +} + +void DataFilesModel::addPlugins(const QString &path) +{ + QDir dir(path); + dir.setNameFilters(QStringList(QLatin1String("*.esp"))); + + foreach (const QString &path, dir.entryList()) { + QFileInfo info(dir.absoluteFilePath(path)); + EsmFile *file = new EsmFile(path); + + try { + ESM::ESMReader fileReader; + fileReader.setEncoding(std::string("win1252")); + fileReader.open(dir.absoluteFilePath(path).toStdString()); + + ESM::ESMReader::MasterList mlist = fileReader.getMasters(); + QStringList masters; + + for (unsigned int i = 0; i < mlist.size(); ++i) { + QString master = QString::fromStdString(mlist[i].name); + masters.append(master); + + // Add the plugin to the internal dependency map + mDependencies[master].append(path); + } + + file->setAuthor(QString::fromStdString(fileReader.getAuthor())); + file->setSize(info.size()); + file->setDates(info.lastModified(), info.lastRead()); + file->setVersion(fileReader.getFVer()); + file->setPath(info.absoluteFilePath()); + file->setMasters(masters); + file->setDescription(QString::fromStdString(fileReader.getDesc())); + + + // Put the file in the table + addFile(file); + } catch(std::runtime_error &e) { + // An error occurred while reading the .esp + continue; + } + + } +} + +QModelIndex DataFilesModel::indexFromItem(EsmFile *item) const +{ + if (item) + return createIndex(mFiles.indexOf(item), 0); + + return QModelIndex(); +} + +EsmFile* DataFilesModel::findItem(const QString &name) +{ + QList::ConstIterator it; + QList::ConstIterator itEnd = mFiles.constEnd(); + + int i = 0; + for (it = mFiles.constBegin(); it != itEnd; ++it) { + EsmFile *file = item(i); + ++i; + + if (name == file->fileName()) + return file; + } + + // Not found + return 0; +} + +EsmFile* DataFilesModel::item(int row) +{ + if (row >= 0 && row < mFiles.count()) + return mFiles.at(row); + else + return 0; +} + +QStringList DataFilesModel::checkedItems() +{ + QStringList list; + QHash::ConstIterator it; + QHash::ConstIterator itEnd = mCheckStates.constEnd(); + + for (it = mCheckStates.constBegin(); it != itEnd; ++it) { + if (it.value() == Qt::Checked) { + list << it.key(); + } + } + + return list; +} + +void DataFilesModel::uncheckAll() +{ + emit layoutAboutToBeChanged(); + mCheckStates.clear(); + emit layoutChanged(); +} + +QStringList DataFilesModel::uncheckedItems() +{ + QStringList list; + QStringList checked = checkedItems(); + + QList::ConstIterator it; + QList::ConstIterator itEnd = mFiles.constEnd(); + + int i = 0; + for (it = mFiles.constBegin(); it != itEnd; ++it) { + EsmFile *file = item(i); + ++i; + + // Add the items that are not in the checked list + if (!checked.contains(file->fileName())) + list << file->fileName(); + } + + return list; +} + +void DataFilesModel::slotcheckedItemsChanged(const QStringList &checkedItems, const QStringList &unCheckedItems) +{ + emit layoutAboutToBeChanged(); + + QStringList list; + + foreach (const QString &file, checkedItems) { + list << mDependencies[file]; + } + + foreach (const QString &file, unCheckedItems) { + foreach (const QString &remove, mDependencies[file]) { + list.removeAll(remove); + } + } + + mAvailableFiles.clear(); + mAvailableFiles.append(list); + + emit layoutChanged(); +} diff --git a/apps/launcher/model/datafilesmodel.hpp b/apps/launcher/model/datafilesmodel.hpp new file mode 100644 index 000000000..8710ba88d --- /dev/null +++ b/apps/launcher/model/datafilesmodel.hpp @@ -0,0 +1,67 @@ +#ifndef DATAFILESMODEL_HPP +#define DATAFILESMODEL_HPP + +#include +#include +#include +#include + + +class EsmFile; + +class DataFilesModel : public QAbstractTableModel +{ + Q_OBJECT + +public: + explicit DataFilesModel(QObject *parent = 0); + virtual ~DataFilesModel(); + virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; + virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; + + bool moveRow(int oldrow, int row, const QModelIndex &parent = QModelIndex()); + + virtual Qt::ItemFlags flags(const QModelIndex &index) const; + + virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + + virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); + + inline QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const + { return QAbstractTableModel::index(row, column, parent); } + + void addFile(EsmFile *file); + + void addMasters(const QString &path); + void addPlugins(const QString &path); + + void uncheckAll(); + + QStringList checkedItems(); + QStringList uncheckedItems(); + + Qt::CheckState checkState(const QModelIndex &index); + void setCheckState(const QModelIndex &index, Qt::CheckState state); + + QModelIndex indexFromItem(EsmFile *item) const; + EsmFile* findItem(const QString &name); + EsmFile* item(int row); + +signals: + void checkedItemsChanged(const QStringList checkedItems, const QStringList unCheckedItems); + +public slots: + void slotcheckedItemsChanged(const QStringList &checkedItems, const QStringList &unCheckedItems); + +private: + QList mFiles; + QStringList mAvailableFiles; + + QHash mDependencies; + QHash mCheckStates; + +}; + +#endif // DATAFILESMODEL_HPP diff --git a/apps/launcher/model/esm/esmfile.cpp b/apps/launcher/model/esm/esmfile.cpp new file mode 100644 index 000000000..93d83091e --- /dev/null +++ b/apps/launcher/model/esm/esmfile.cpp @@ -0,0 +1,50 @@ +#include "esmfile.hpp" + +EsmFile::EsmFile(QString fileName, ModelItem *parent) + : ModelItem(parent) +{ + mFileName = fileName; + mSize = 0; + mVersion = 0.0f; +} + +void EsmFile::setFileName(const QString &fileName) +{ + mFileName = fileName; +} + +void EsmFile::setAuthor(const QString &author) +{ + mAuthor = author; +} + +void EsmFile::setSize(const int size) +{ + mSize = size; +} + +void EsmFile::setDates(const QDateTime &modified, const QDateTime &accessed) +{ + mModified = modified; + mAccessed = accessed; +} + +void EsmFile::setVersion(float version) +{ + mVersion = version; +} + +void EsmFile::setPath(const QString &path) +{ + mPath = path; +} + +void EsmFile::setMasters(const QStringList &masters) +{ + mMasters = masters; +} + +void EsmFile::setDescription(const QString &description) +{ + mDescription = description; +} diff --git a/apps/launcher/model/esm/esmfile.hpp b/apps/launcher/model/esm/esmfile.hpp new file mode 100644 index 000000000..ad267aa75 --- /dev/null +++ b/apps/launcher/model/esm/esmfile.hpp @@ -0,0 +1,54 @@ +#ifndef ESMFILE_HPP +#define ESMFILE_HPP + +#include +#include + +#include "../modelitem.hpp" + +class EsmFile : public ModelItem +{ + Q_OBJECT + Q_PROPERTY(QString filename READ fileName) + +public: + EsmFile(QString fileName = QString(), ModelItem *parent = 0); + + ~EsmFile() + {} + + void setFileName(const QString &fileName); + void setAuthor(const QString &author); + void setSize(const int size); + void setDates(const QDateTime &modified, const QDateTime &accessed); + void setVersion(const float version); + void setPath(const QString &path); + void setMasters(const QStringList &masters); + void setDescription(const QString &description); + + inline QString fileName() { return mFileName; } + inline QString author() { return mAuthor; } + inline int size() { return mSize; } + inline QDateTime modified() { return mModified; } + inline QDateTime accessed() { return mAccessed; } + inline float version() { return mVersion; } + inline QString path() { return mPath; } + inline QStringList masters() { return mMasters; } + inline QString description() { return mDescription; } + + +private: + QString mFileName; + QString mAuthor; + int mSize; + QDateTime mModified; + QDateTime mAccessed; + float mVersion; + QString mPath; + QStringList mMasters; + QString mDescription; + +}; + + +#endif diff --git a/apps/launcher/model/modelitem.cpp b/apps/launcher/model/modelitem.cpp new file mode 100644 index 000000000..0ff7e45cb --- /dev/null +++ b/apps/launcher/model/modelitem.cpp @@ -0,0 +1,57 @@ +#include "modelitem.hpp" + +ModelItem::ModelItem(ModelItem *parent) + : mParentItem(parent) + , QObject(parent) +{ +} + +ModelItem::~ModelItem() +{ + qDeleteAll(mChildItems); +} + + +ModelItem *ModelItem::parent() +{ + return mParentItem; +} + +int ModelItem::row() const +{ + if (mParentItem) + return 1; + //return mParentItem->childRow(const_cast(this)); + //return mParentItem->mChildItems.indexOf(const_cast(this)); + + return -1; +} + + +int ModelItem::childCount() const +{ + return mChildItems.count(); +} + +int ModelItem::childRow(ModelItem *child) const +{ + Q_ASSERT(child); + + return mChildItems.indexOf(child); +} + +ModelItem *ModelItem::child(int row) +{ + return mChildItems.value(row); +} + + +void ModelItem::appendChild(ModelItem *item) +{ + mChildItems.append(item); +} + +void ModelItem::removeChild(int row) +{ + mChildItems.removeAt(row); +} diff --git a/apps/launcher/model/modelitem.hpp b/apps/launcher/model/modelitem.hpp new file mode 100644 index 000000000..f4cb4322f --- /dev/null +++ b/apps/launcher/model/modelitem.hpp @@ -0,0 +1,32 @@ +#ifndef MODELITEM_HPP +#define MODELITEM_HPP + +#include +#include + +class ModelItem : public QObject +{ + Q_OBJECT + +public: + ModelItem(ModelItem *parent = 0); + ~ModelItem(); + + ModelItem *parent(); + int row() const; + + int childCount() const; + int childRow(ModelItem *child) const; + ModelItem *child(int row); + + void appendChild(ModelItem *child); + void removeChild(int row); + + //virtual bool acceptChild(ModelItem *child); + +protected: + ModelItem *mParentItem; + QList mChildItems; +}; + +#endif From 57736769860c97eede190dfd6d3cfd92d5b2e37a Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Wed, 10 Oct 2012 22:58:04 +0200 Subject: [PATCH 002/107] Got the Data Files tab to use the new model --- apps/launcher/datafilespage.cpp | 1170 +++++++----------------- apps/launcher/datafilespage.hpp | 49 +- apps/launcher/model/datafilesmodel.cpp | 2 +- 3 files changed, 375 insertions(+), 846 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 8ca3c9aed..c0a447e26 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -3,12 +3,14 @@ #include #include +#include "model/datafilesmodel.hpp" +#include "model/esm/esmfile.hpp" + +#include "combobox.hpp" #include "datafilespage.hpp" -#include "lineedit.hpp" #include "filedialog.hpp" +#include "lineedit.hpp" #include "naturalsort.hpp" -#include "pluginsmodel.hpp" -#include "pluginsview.hpp" #include /** @@ -46,13 +48,15 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) : QWidget(parent) , mCfgMgr(cfg) { - mDataFilesModel = new QStandardItemModel(); // Contains all plugins with masters - mPluginsModel = new PluginsModel(); // Contains selectable plugins + // Models + mMastersModel = new DataFilesModel(this); + mPluginsModel = new DataFilesModel(this); mPluginsProxyModel = new QSortFilterProxyModel(); mPluginsProxyModel->setDynamicSortFilter(true); mPluginsProxyModel->setSourceModel(mPluginsModel); + // Filter toolbar QLabel *filterLabel = new QLabel(tr("&Filter:"), this); LineEdit *filterLineEdit = new LineEdit(this); filterLabel->setBuddy(filterLineEdit); @@ -71,40 +75,62 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) filterToolBar->addWidget(filterWidget); - mMastersWidget = new QTableWidget(this); // Contains the available masters - mMastersWidget->setObjectName("MastersWidget"); - mMastersWidget->setSelectionBehavior(QAbstractItemView::SelectRows); - mMastersWidget->setSelectionMode(QAbstractItemView::MultiSelection); - mMastersWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); - mMastersWidget->setAlternatingRowColors(true); - mMastersWidget->horizontalHeader()->setStretchLastSection(true); - mMastersWidget->horizontalHeader()->hide(); - mMastersWidget->verticalHeader()->hide(); - mMastersWidget->insertColumn(0); - - mPluginsTable = new PluginsView(this); - mPluginsTable->setModel(mPluginsProxyModel); - mPluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem); + QCheckBox checkBox; + unsigned int height = checkBox.sizeHint().height() + 4; - mPluginsTable->horizontalHeader()->setStretchLastSection(true); - mPluginsTable->horizontalHeader()->hide(); + mMastersTable = new QTableView(this); + mMastersTable->setModel(mMastersModel); + mMastersTable->setObjectName("MastersTable"); + mMastersTable->setSelectionBehavior(QAbstractItemView::SelectRows); + mMastersTable->setSelectionMode(QAbstractItemView::SingleSelection); + mMastersTable->setEditTriggers(QAbstractItemView::NoEditTriggers); + mMastersTable->setAlternatingRowColors(true); + mMastersTable->horizontalHeader()->setStretchLastSection(true); + mMastersTable->horizontalHeader()->hide(); // Set the row height to the size of the checkboxes - QCheckBox checkBox; - unsigned int height = checkBox.sizeHint().height() + 4; + mMastersTable->verticalHeader()->setDefaultSectionSize(height); + mMastersTable->verticalHeader()->hide(); + mMastersTable->setColumnHidden(1, true); + mMastersTable->setColumnHidden(2, true); + mMastersTable->setColumnHidden(3, true); + mMastersTable->setColumnHidden(4, true); + mMastersTable->setColumnHidden(5, true); + mMastersTable->setColumnHidden(6, true); + mMastersTable->setColumnHidden(7, true); + mMastersTable->setColumnHidden(8, true); + + mPluginsTable = new QTableView(this); + mPluginsTable->setModel(mPluginsProxyModel); + mPluginsTable->setObjectName("PluginsTable"); + mPluginsTable->setContextMenuPolicy(Qt::CustomContextMenu); + mPluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows); + mPluginsTable->setSelectionMode(QAbstractItemView::SingleSelection); + mPluginsTable->setEditTriggers(QAbstractItemView::NoEditTriggers); + mPluginsTable->setAlternatingRowColors(true); + mPluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem); + mPluginsTable->horizontalHeader()->setStretchLastSection(true); mPluginsTable->verticalHeader()->setDefaultSectionSize(height); + mPluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed); + mPluginsTable->setColumnHidden(1, true); + mPluginsTable->setColumnHidden(2, true); + mPluginsTable->setColumnHidden(3, true); + mPluginsTable->setColumnHidden(4, true); + mPluginsTable->setColumnHidden(5, true); + mPluginsTable->setColumnHidden(6, true); + mPluginsTable->setColumnHidden(7, true); + mPluginsTable->setColumnHidden(8, true); // Add both tables to a splitter QSplitter *splitter = new QSplitter(this); splitter->setOrientation(Qt::Horizontal); - - splitter->addWidget(mMastersWidget); + splitter->addWidget(mMastersTable); splitter->addWidget(mPluginsTable); // Adjust the default widget widths inside the splitter QList sizeList; - sizeList << 100 << 300; + sizeList << 175 << 200; splitter->setSizes(sizeList); // Bottom part with profile options @@ -127,20 +153,56 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) pageLayout->addWidget(splitter); pageLayout->addWidget(mProfileToolBar); - connect(mMastersWidget->selectionModel(), - SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), - this, SLOT(masterSelectionChanged(const QItemSelection&, const QItemSelection&))); + connect(mPluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex))); + connect(mMastersTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex))); + + connect(mMastersModel, SIGNAL(checkedItemsChanged(QStringList,QStringList)), mPluginsModel, SLOT(slotcheckedItemsChanged(QStringList,QStringList))); connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(const QString))); - connect(mPluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex))); connect(mPluginsTable, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showContextMenu(const QPoint&))); connect(mProfilesComboBox, SIGNAL(textChanged(const QString&, const QString&)), this, SLOT(profileChanged(const QString&, const QString&))); createActions(); setupConfig(); - //setupDataFiles(); +} + +void DataFilesPage::createActions() +{ + // Refresh the plugins + QAction *refreshAction = new QAction(tr("Refresh"), this); + refreshAction->setShortcut(QKeySequence(tr("F5"))); + connect(refreshAction, SIGNAL(triggered()), this, SLOT(refresh())); + + // Profile actions + mNewProfileAction = new QAction(QIcon::fromTheme("document-new"), tr("&New Profile"), this); + mNewProfileAction->setToolTip(tr("New Profile")); + mNewProfileAction->setShortcut(QKeySequence(tr("Ctrl+N"))); + connect(mNewProfileAction, SIGNAL(triggered()), this, SLOT(newProfile())); + + mDeleteProfileAction = new QAction(QIcon::fromTheme("edit-delete"), tr("Delete Profile"), this); + mDeleteProfileAction->setToolTip(tr("Delete Profile")); + mDeleteProfileAction->setShortcut(QKeySequence(tr("Delete"))); + connect(mDeleteProfileAction, SIGNAL(triggered()), this, SLOT(deleteProfile())); + + // Add the newly created actions to the toolbar + mProfileToolBar->addSeparator(); + mProfileToolBar->addAction(mNewProfileAction); + mProfileToolBar->addAction(mDeleteProfileAction); + + // Context menu actions + mCheckAction = new QAction(tr("Check selected"), this); + connect(mCheckAction, SIGNAL(triggered()), this, SLOT(check())); + + mUncheckAction = new QAction(tr("Uncheck selected"), this); + connect(mUncheckAction, SIGNAL(triggered()), this, SLOT(uncheck())); + + // Context menu for the plugins table + mContextMenu = new QMenu(this); + + mContextMenu->addAction(mCheckAction); + mContextMenu->addAction(mUncheckAction); } @@ -189,111 +251,81 @@ void DataFilesPage::setupConfig() } -void DataFilesPage::addDataFiles(Files::Collections &fileCollections, const QString &encoding) +void DataFilesPage::readConfig() { - // First we add all the master files - const Files::MultiDirCollection &esm = fileCollections.getCollection(".esm"); - unsigned int i = 0; // Row number - - for (Files::MultiDirCollection::TIter iter(esm.begin()); iter!=esm.end(); ++iter) { - QString currentMaster = QString::fromStdString( - boost::filesystem::path (iter->second.filename()).string()); + // Don't read the config if no masters are found + if (mMastersModel->rowCount() < 1) + return; - const QList itemList = mMastersWidget->findItems(currentMaster, Qt::MatchExactly); + QString profile = mProfilesComboBox->currentText(); - if (itemList.isEmpty()) { // Master is not yet in the widget - mMastersWidget->insertRow(i); - QTableWidgetItem *item = new QTableWidgetItem(currentMaster); - mMastersWidget->setItem(i, 0, item); - ++i; - } + // Make sure we have no groups open + while (!mLauncherConfig->group().isEmpty()) { + mLauncherConfig->endGroup(); } - // Now on to the plugins - const Files::MultiDirCollection &esp = fileCollections.getCollection(".esp"); - - for (Files::MultiDirCollection::TIter iter(esp.begin()); iter!=esp.end(); ++iter) { - - try { - ESMReader fileReader; - QStringList availableMasters; // Will contain all found masters - - fileReader.setEncoding(encoding.toStdString()); - fileReader.open(iter->second.string()); - - // First we fill the availableMasters and the mMastersWidget - ESMReader::MasterList mlist = fileReader.getMasters(); - - for (unsigned int i = 0; i < mlist.size(); ++i) { - const QString currentMaster = QString::fromStdString(mlist[i].name); - availableMasters.append(currentMaster); - - const QList itemList = mMastersWidget->findItems(currentMaster, Qt::MatchExactly); - - if (itemList.isEmpty()) { // Master is not yet in the widget - mMastersWidget->insertRow(i); + mLauncherConfig->beginGroup("Profiles"); + mLauncherConfig->beginGroup(profile); - QTableWidgetItem *item = new QTableWidgetItem(currentMaster); - item->setForeground(Qt::red); - item->setFlags(item->flags() & ~(Qt::ItemIsSelectable)); + QStringList childKeys = mLauncherConfig->childKeys(); + QStringList plugins; - mMastersWidget->setItem(i, 0, item); - } - } + // Sort the child keys numerical instead of alphabetically + // i.e. Plugin1, Plugin2 instead of Plugin1, Plugin10 + qSort(childKeys.begin(), childKeys.end(), naturalSortLessThanCI); - availableMasters.sort(); // Sort the masters alphabetically + foreach (const QString &key, childKeys) { + const QString keyValue = mLauncherConfig->value(key).toString(); - // Now we put the current plugin in the mDataFilesModel under its masters - QStandardItem *parent = new QStandardItem(availableMasters.join(",")); + if (key.startsWith("Plugin")) { + //QStringList checked = mPluginsModel->checkedItems(); + EsmFile *file = mPluginsModel->findItem(keyValue); + QModelIndex index = mPluginsModel->indexFromItem(file); + + mPluginsModel->setCheckState(index, Qt::Checked); + // Move the row to the top of te view + //mPluginsModel->moveRow(index.row(), checked.count()); + plugins << keyValue; + } - QString fileName = QString::fromStdString(boost::filesystem::path (iter->second.filename()).string()); - QStandardItem *child = new QStandardItem(fileName); + if (key.startsWith("Master")) { + EsmFile *file = mMastersModel->findItem(keyValue); + mMastersModel->setCheckState(mMastersModel->indexFromItem(file), Qt::Checked); + } + } - // Tooltip information - QString author = QString::fromStdString(fileReader.getAuthor()); - float version = fileReader.getFVer(); - QString description = QString::fromStdString(fileReader.getDesc()); + qDebug() << plugins; - // For the date created/modified - QFileInfo fi(QString::fromStdString(iter->second.string())); - QString toolTip= QString("Author: %1
\ - Version: %2

\ - Description:
\ - %3

\ - Created on: %4
\ - Last modified: %5") - .arg(author) - .arg(version) - .arg(description) - .arg(fi.created().toString(Qt::TextDate)) - .arg(fi.lastModified().toString(Qt::TextDate)); +// // Set the checked item positions +// const QStringList checked = mPluginsModel->checkedItems(); +// for (int i = 0; i < plugins.size(); ++i) { +// EsmFile *file = mPluginsModel->findItem(plugins.at(i)); +// QModelIndex index = mPluginsModel->indexFromItem(file); +// mPluginsModel->moveRow(index.row(), i); +// qDebug() << "Moving: " << plugins.at(i) << " from: " << index.row() << " to: " << i << " count: " << checked.count(); - child->setToolTip(toolTip); +// } - const QList masterList = mDataFilesModel->findItems(availableMasters.join(",")); + // Iterate over the plugins to set their checkstate and position +// for (int i = 0; i < plugins.size(); ++i) { +// const QString plugin = plugins.at(i); - if (masterList.isEmpty()) { // Masters node not yet in the mDataFilesModel - parent->appendRow(child); - mDataFilesModel->appendRow(parent); - } else { - // Masters node exists, append current plugin - foreach (QStandardItem *currentItem, masterList) { - currentItem->appendRow(child); - } - } +// const QList pluginList = mPluginsModel->findItems(plugin); - } catch(std::runtime_error &e) { - // An error occurred while reading the .esp - std::cerr << "Error reading .esp: " << e.what() << std::endl; - continue; - } - } +// if (!pluginList.isEmpty()) +// { +// foreach (const QStandardItem *currentPlugin, pluginList) { +// mPluginsModel->setData(currentPlugin->index(), Qt::Checked, Qt::CheckStateRole); +// // Move the plugin to the position specified in the config file +// mPluginsModel->insertRow(i, mPluginsModel->takeRow(currentPlugin->row())); +// } +// } +// } } - bool DataFilesPage::setupDataFiles() { // We use the Configuration Manager to retrieve the configuration values @@ -356,93 +388,185 @@ bool DataFilesPage::setupDataFiles() } } - // Add the plugins in the data directories - Files::Collections dataCollections(mDataDirs, !variables["fs-strict"].as()); - Files::Collections dataLocalCollections(mDataLocal, !variables["fs-strict"].as()); + // Add the paths to the respective models + for (Files::PathContainer::iterator it = mDataDirs.begin(); it != mDataDirs.end(); ++it) { + QString path = QString::fromStdString(it->string()); + path.remove(QChar('\"')); + mMastersModel->addMasters(path); + mPluginsModel->addPlugins(path); + } + + // Same for the data-local paths + for (Files::PathContainer::iterator it = mDataLocal.begin(); it != mDataLocal.end(); ++it) { + QString path = QString::fromStdString(it->string()); + path.remove(QChar('\"')); + mMastersModel->addMasters(path); + mPluginsModel->addPlugins(path); + } - addDataFiles(dataCollections, QString::fromStdString(variables["encoding"].as())); - addDataFiles(dataLocalCollections, QString::fromStdString(variables["encoding"].as())); +// mMastersModel->sort(0); +// mPluginsModel->sort(0); - mDataFilesModel->sort(0); readConfig(); return true; } -void DataFilesPage::createActions() +void DataFilesPage::writeConfig(QString profile) { - // Refresh the plugins - QAction *refreshAction = new QAction(tr("Refresh"), this); - refreshAction->setShortcut(QKeySequence(tr("F5"))); - connect(refreshAction, SIGNAL(triggered()), this, SLOT(refresh())); + // Don't overwrite the config if no masters are found + if (mMastersModel->rowCount() < 1) + return; - // Profile actions - mNewProfileAction = new QAction(QIcon::fromTheme("document-new"), tr("&New Profile"), this); - mNewProfileAction->setToolTip(tr("New Profile")); - mNewProfileAction->setShortcut(QKeySequence(tr("Ctrl+N"))); - connect(mNewProfileAction, SIGNAL(triggered()), this, SLOT(newProfile())); + QString pathStr = QString::fromStdString(mCfgMgr.getUserPath().string()); + QDir userPath(pathStr); + if (!userPath.exists()) { + if (!userPath.mkpath(pathStr)) { + QMessageBox msgBox; + msgBox.setWindowTitle("Error creating OpenMW configuration directory"); + msgBox.setIcon(QMessageBox::Critical); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setText(tr("
Could not create %0

\ + Please make sure you have the right permissions and try again.
").arg(pathStr)); + msgBox.exec(); - mCopyProfileAction = new QAction(QIcon::fromTheme("edit-copy"), tr("&Copy Profile"), this); - mCopyProfileAction->setToolTip(tr("Copy Profile")); - mCopyProfileAction->setShortcut(QKeySequence(tr("Ctrl+C"))); - connect(mCopyProfileAction, SIGNAL(triggered()), this, SLOT(copyProfile())); + qApp->quit(); + return; + } + } + // Open the OpenMW config as a QFile + QFile file(pathStr.append("openmw.cfg")); - mDeleteProfileAction = new QAction(QIcon::fromTheme("edit-delete"), tr("Delete Profile"), this); - mDeleteProfileAction->setToolTip(tr("Delete Profile")); - mDeleteProfileAction->setShortcut(QKeySequence(tr("Delete"))); - connect(mDeleteProfileAction, SIGNAL(triggered()), this, SLOT(deleteProfile())); + if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { + // File cannot be opened or created + QMessageBox msgBox; + msgBox.setWindowTitle("Error writing OpenMW configuration file"); + msgBox.setIcon(QMessageBox::Critical); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setText(tr("
Could not open or create %0

\ + Please make sure you have the right permissions and try again.
").arg(file.fileName())); + msgBox.exec(); - // Add the newly created actions to the toolbar - mProfileToolBar->addSeparator(); - mProfileToolBar->addAction(mNewProfileAction); - mProfileToolBar->addAction(mCopyProfileAction); - mProfileToolBar->addAction(mDeleteProfileAction); + qApp->quit(); + return; + } - // Context menu actions - mMoveUpAction = new QAction(QIcon::fromTheme("go-up"), tr("Move &Up"), this); - mMoveUpAction->setShortcut(QKeySequence(tr("Ctrl+U"))); - connect(mMoveUpAction, SIGNAL(triggered()), this, SLOT(moveUp())); + QTextStream in(&file); + QByteArray buffer; + + // Remove all previous entries from config + while (!in.atEnd()) { + QString line = in.readLine(); + if (!line.startsWith("master") && + !line.startsWith("plugin") && + !line.startsWith("data") && + !line.startsWith("data-local")) + { + buffer += line += "\n"; + } + } - mMoveDownAction = new QAction(QIcon::fromTheme("go-down"), tr("&Move Down"), this); - mMoveDownAction->setShortcut(QKeySequence(tr("Ctrl+M"))); - connect(mMoveDownAction, SIGNAL(triggered()), this, SLOT(moveDown())); + file.close(); - mMoveTopAction = new QAction(QIcon::fromTheme("go-top"), tr("Move to Top"), this); - mMoveTopAction->setShortcut(QKeySequence(tr("Ctrl+Shift+U"))); - connect(mMoveTopAction, SIGNAL(triggered()), this, SLOT(moveTop())); + // Now we write back the other config entries + if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) { + QMessageBox msgBox; + msgBox.setWindowTitle("Error writing OpenMW configuration file"); + msgBox.setIcon(QMessageBox::Critical); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setText(tr("
Could not write to %0

\ + Please make sure you have the right permissions and try again.
").arg(file.fileName())); + msgBox.exec(); - mMoveBottomAction = new QAction(QIcon::fromTheme("go-bottom"), tr("Move to Bottom"), this); - mMoveBottomAction->setShortcut(QKeySequence(tr("Ctrl+Shift+M"))); - connect(mMoveBottomAction, SIGNAL(triggered()), this, SLOT(moveBottom())); + qApp->quit(); + return; + } - mCheckAction = new QAction(tr("Check selected"), this); - connect(mCheckAction, SIGNAL(triggered()), this, SLOT(check())); + if (!buffer.isEmpty()) { + file.write(buffer); + } - mUncheckAction = new QAction(tr("Uncheck selected"), this); - connect(mUncheckAction, SIGNAL(triggered()), this, SLOT(uncheck())); + QTextStream gameConfig(&file); - // Makes shortcuts work even if the context menu is hidden - this->addAction(refreshAction); - this->addAction(mMoveUpAction); - this->addAction(mMoveDownAction); - this->addAction(mMoveTopAction); - this->addAction(mMoveBottomAction); + // First write the list of data dirs + mCfgMgr.processPaths(mDataDirs); + mCfgMgr.processPaths(mDataLocal); - // Context menu for the plugins table - mContextMenu = new QMenu(this); + QString path; - mContextMenu->addAction(mMoveUpAction); - mContextMenu->addAction(mMoveDownAction); - mContextMenu->addSeparator(); - mContextMenu->addAction(mMoveTopAction); - mContextMenu->addAction(mMoveBottomAction); - mContextMenu->addSeparator(); - mContextMenu->addAction(mCheckAction); - mContextMenu->addAction(mUncheckAction); + // data= directories + for (Files::PathContainer::iterator it = mDataDirs.begin(); it != mDataDirs.end(); ++it) { + path = QString::fromStdString(it->string()); + path.remove(QChar('\"')); + + // Make sure the string is quoted when it contains spaces + if (path.contains(" ")) { + gameConfig << "data=\"" << path << "\"" << endl; + } else { + gameConfig << "data=" << path << endl; + } + } + + // data-local directory + if (!mDataLocal.empty()) { + path = QString::fromStdString(mDataLocal.front().string()); + path.remove(QChar('\"')); + + if (path.contains(" ")) { + gameConfig << "data-local=\"" << path << "\"" << endl; + } else { + gameConfig << "data-local=" << path << endl; + } + } + + + if (profile.isEmpty()) + profile = mProfilesComboBox->currentText(); + + if (profile.isEmpty()) + return; + + // Make sure we have no groups open + while (!mLauncherConfig->group().isEmpty()) { + mLauncherConfig->endGroup(); + } + + mLauncherConfig->beginGroup("Profiles"); + mLauncherConfig->setValue("CurrentProfile", profile); + + // Open the profile-name subgroup + mLauncherConfig->beginGroup(profile); + mLauncherConfig->remove(""); // Clear the subgroup + + // Now write the masters to the configs + const QStringList masters = mMastersModel->checkedItems(); + + // We don't use foreach because we need i + for (int i = 0; i < masters.size(); ++i) { + const QString currentMaster = masters.at(i); + + mLauncherConfig->setValue(QString("Master%0").arg(i), currentMaster); + gameConfig << "master=" << currentMaster << endl; + + } + + // And finally write all checked plugins + const QStringList plugins = mPluginsModel->checkedItems(); + for (int i = 0; i < plugins.size(); ++i) { + const QString currentPlugin = plugins.at(i); + mLauncherConfig->setValue(QString("Plugin%1").arg(i), currentPlugin); + gameConfig << "plugin=" << currentPlugin << endl; + } + + file.close(); + mLauncherConfig->endGroup(); + mLauncherConfig->endGroup(); + mLauncherConfig->sync(); } + void DataFilesPage::newProfile() { bool ok; @@ -462,37 +586,9 @@ void DataFilesPage::newProfile() } } - } -void DataFilesPage::copyProfile() -{ - QString profile = mProfilesComboBox->currentText(); - bool ok; - - QString text = QInputDialog::getText(this, tr("Copy Profile"), - tr("Profile Name:"), QLineEdit::Normal, - tr("%0 Copy").arg(profile), &ok); - if (ok && !text.isEmpty()) { - if (mProfilesComboBox->findText(text) != -1) { - QMessageBox::warning(this, tr("Profile already exists"), - tr("the profile %0 already exists.").arg(text), - QMessageBox::Ok); - } else { - // Add the new profile to the combobox - mProfilesComboBox->addItem(text); - - // First write the current profile as the new profile - writeConfig(text); - mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(text)); - - } - - } - -} - -void DataFilesPage::deleteProfile() +void DataFilesPage::deleteProfile() { QString profile = mProfilesComboBox->currentText(); @@ -531,449 +627,87 @@ void DataFilesPage::deleteProfile() } } -void DataFilesPage::moveUp() -{ - // Shift the selected plugins up one row - - if (!mPluginsTable->selectionModel()->hasSelection()) { - return; - } - - QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); - - //sort selection ascending because selectedIndexes returns an unsorted list - qSort(selectedIndexes.begin(), selectedIndexes.end(), rowSmallerThan); - - QModelIndex firstIndex = mPluginsProxyModel->mapToSource(selectedIndexes.first()); - - // Check if the first selected plugin is the top one - if (firstIndex.row() == 0) { - return; - } - - foreach (const QModelIndex ¤tIndex, selectedIndexes) { - const QModelIndex sourceModelIndex = mPluginsProxyModel->mapToSource(currentIndex); - int currentRow = sourceModelIndex.row(); - - if (sourceModelIndex.isValid() && currentRow > 0) { - mPluginsModel->insertRow((currentRow - 1), mPluginsModel->takeRow(currentRow)); - - const QModelIndex targetIndex = mPluginsModel->index((currentRow - 1), 0, QModelIndex()); - - mPluginsTable->selectionModel()->select(targetIndex, QItemSelectionModel::Select | QItemSelectionModel::Rows); - scrollToSelection(); - } - } -} - -void DataFilesPage::moveDown() -{ - // Shift the selected plugins down one row - if (!mPluginsTable->selectionModel()->hasSelection()) { - return; - } - - QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); - - //sort selection descending because selectedIndexes returns an unsorted list - qSort(selectedIndexes.begin(), selectedIndexes.end(), rowGreaterThan); - - const QModelIndex lastIndex = mPluginsProxyModel->mapToSource(selectedIndexes.first()); - - // Check if last selected plugin is bottom one - if ((lastIndex.row() + 1) == mPluginsModel->rowCount()) { - return; - } - - foreach (const QModelIndex ¤tIndex, selectedIndexes) { - const QModelIndex sourceModelIndex = mPluginsProxyModel->mapToSource(currentIndex); - int currentRow = sourceModelIndex.row(); - - if (sourceModelIndex.isValid() && (currentRow + 1) < mPluginsModel->rowCount()) { - mPluginsModel->insertRow((currentRow + 1), mPluginsModel->takeRow(currentRow)); - - const QModelIndex targetIndex = mPluginsModel->index((currentRow + 1), 0, QModelIndex()); - - mPluginsTable->selectionModel()->select(targetIndex, QItemSelectionModel::Select | QItemSelectionModel::Rows); - scrollToSelection(); - } - } -} - -void DataFilesPage::moveTop() -{ - // Move the selection to the top of the table - - if (!mPluginsTable->selectionModel()->hasSelection()) { - return; - } - - QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); - - //sort selection ascending because selectedIndexes returns an unsorted list - qSort(selectedIndexes.begin(), selectedIndexes.end(), rowSmallerThan); - - QModelIndex firstIndex = mPluginsProxyModel->mapToSource(selectedIndexes.first()); - - // Check if the first selected plugin is the top one - if (firstIndex.row() == 0) { - return; - } - - for (int i=0; i < selectedIndexes.count(); ++i) { - - const QModelIndex sourceModelIndex = mPluginsProxyModel->mapToSource(selectedIndexes.at(i)); - - int currentRow = sourceModelIndex.row(); - - if (sourceModelIndex.isValid() && currentRow > 0) { - - mPluginsModel->insertRow(i, mPluginsModel->takeRow(currentRow)); - mPluginsTable->selectionModel()->select(mPluginsModel->index(i, 0, QModelIndex()), QItemSelectionModel::Select | QItemSelectionModel::Rows); - mPluginsTable->scrollToTop(); - } - } -} - -void DataFilesPage::moveBottom() -{ - // Move the selection to the bottom of the table - - if (!mPluginsTable->selectionModel()->hasSelection()) { - return; - } - - QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); - - //sort selection descending because selectedIndexes returns an unsorted list - qSort(selectedIndexes.begin(), selectedIndexes.end(), rowSmallerThan); - - const QModelIndex lastIndex = mPluginsProxyModel->mapToSource(selectedIndexes.last()); - - // Check if last selected plugin is bottom one - if ((lastIndex.row() + 1) == mPluginsModel->rowCount()) { - return; - } - - for (int i=0; i < selectedIndexes.count(); ++i) { - - const QModelIndex sourceModelIndex = mPluginsProxyModel->mapToSource(selectedIndexes.at(i)); - - // Subtract iterations because takeRow shifts the rows below the taken row up - int currentRow = sourceModelIndex.row() - i; - - if (sourceModelIndex.isValid() && (currentRow + 1) < mPluginsModel->rowCount()) { - mPluginsModel->appendRow(mPluginsModel->takeRow(currentRow)); - - // Rowcount starts with 1, row numbers start with 0 - const QModelIndex lastRow = mPluginsModel->index((mPluginsModel->rowCount() -1), 0, QModelIndex()); - - mPluginsTable->selectionModel()->select(lastRow, QItemSelectionModel::Select | QItemSelectionModel::Rows); - mPluginsTable->scrollToBottom(); - } - } -} - void DataFilesPage::check() { // Check the current selection - if (!mPluginsTable->selectionModel()->hasSelection()) { return; } - QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); + QModelIndexList indexes = mPluginsTable->selectionModel()->selectedIndexes(); //sort selection ascending because selectedIndexes returns an unsorted list - qSort(selectedIndexes.begin(), selectedIndexes.end(), rowSmallerThan); + //qSort(indexes.begin(), indexes.end(), rowSmallerThan); - foreach (const QModelIndex ¤tIndex, selectedIndexes) { - QModelIndex sourceModelIndex = mPluginsProxyModel->mapToSource(currentIndex); + foreach (const QModelIndex &index, indexes) { + if (!index.isValid()) + return; - if (sourceModelIndex.isValid()) { - mPluginsModel->setData(sourceModelIndex, Qt::Checked, Qt::CheckStateRole); - } + mPluginsModel->setCheckState(index, Qt::Checked); } } void DataFilesPage::uncheck() { - // Uncheck the current selection - + // uncheck the current selection if (!mPluginsTable->selectionModel()->hasSelection()) { return; } - QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); + QModelIndexList indexes = mPluginsTable->selectionModel()->selectedIndexes(); //sort selection ascending because selectedIndexes returns an unsorted list - qSort(selectedIndexes.begin(), selectedIndexes.end(), rowSmallerThan); + //qSort(indexes.begin(), indexes.end(), rowSmallerThan); - foreach (const QModelIndex ¤tIndex, selectedIndexes) { - QModelIndex sourceModelIndex = mPluginsProxyModel->mapToSource(currentIndex); + foreach (const QModelIndex &index, indexes) { + if (!index.isValid()) + return; - if (sourceModelIndex.isValid()) { - mPluginsModel->setData(sourceModelIndex, Qt::Unchecked, Qt::CheckStateRole); - } + mPluginsModel->setCheckState(index, Qt::Unchecked); } } void DataFilesPage::refresh() { - // Refresh the plugins table + mPluginsModel->sort(0); + + // Refresh the plugins table + mPluginsTable->scrollToTop(); writeConfig(); readConfig(); } -void DataFilesPage::scrollToSelection() -{ - // Scroll to the selected plugins - - if (!mPluginsTable->selectionModel()->hasSelection()) { - return; - } - - // Get the selected indexes visible by determining the middle index - QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); - qSort(selectedIndexes.begin(), selectedIndexes.end(), rowSmallerThan); - - // The selected rows including non-selected inside selection - unsigned int selectedRows = selectedIndexes.last().row() - selectedIndexes.first().row(); - - // Determine the row which is roughly in the middle of the selection - unsigned int middleRow = selectedIndexes.first().row() + (int)(selectedRows / 2) + 1; - - - const QModelIndex middleIndex = mPluginsProxyModel->mapFromSource(mPluginsModel->index(middleRow, 0, QModelIndex())); - - // Make sure the whole selection is visible - mPluginsTable->scrollTo(selectedIndexes.first()); - mPluginsTable->scrollTo(selectedIndexes.last()); - mPluginsTable->scrollTo(middleIndex); -} - -void DataFilesPage::showContextMenu(const QPoint &point) -{ - // Make sure there are plugins in the view - if (!mPluginsTable->selectionModel()->hasSelection()) { - return; - } - - QPoint globalPos = mPluginsTable->mapToGlobal(point); - - QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); - - // Show the check/uncheck actions depending on the state of the selected items - mUncheckAction->setEnabled(false); - mCheckAction->setEnabled(false); - - foreach (const QModelIndex ¤tIndex, selectedIndexes) { - if (currentIndex.isValid()) { - - const QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(currentIndex); - - if (!sourceIndex.isValid()) { - return; - } - - const QStandardItem *currentItem = mPluginsModel->itemFromIndex(sourceIndex); - - if (currentItem->checkState() == Qt::Checked) { - mUncheckAction->setEnabled(true); - } else { - mCheckAction->setEnabled(true); - } - } - - } - - // Make sure these are enabled because they might still be disabled - mMoveUpAction->setEnabled(true); - mMoveTopAction->setEnabled(true); - mMoveDownAction->setEnabled(true); - mMoveBottomAction->setEnabled(true); - - QModelIndex firstIndex = mPluginsProxyModel->mapToSource(selectedIndexes.first()); - QModelIndex lastIndex = mPluginsProxyModel->mapToSource(selectedIndexes.last()); - - // Check if selected first item is top row in model - if (firstIndex.row() == 0) { - mMoveUpAction->setEnabled(false); - mMoveTopAction->setEnabled(false); - } - - // Check if last row is bottom row in model - if ((lastIndex.row() + 1) == mPluginsModel->rowCount()) { - mMoveDownAction->setEnabled(false); - mMoveBottomAction->setEnabled(false); - } - - // Show menu - mContextMenu->exec(globalPos); -} - -void DataFilesPage::masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) -{ - if (mMastersWidget->selectionModel()->hasSelection()) { - - QStringList masters; - QString masterstr; - - // Create a QStringList containing all the masters - const QStringList masterList = selectedMasters(); - - foreach (const QString ¤tMaster, masterList) { - masters.append(currentMaster); - } - - masters.sort(); - masterstr = masters.join(","); // Make a comma-separated QString - - // Iterate over all masters in the datafilesmodel to see if they are selected - for (int r=0; rrowCount(); ++r) { - QModelIndex currentIndex = mDataFilesModel->index(r, 0); - QString master = currentIndex.data().toString(); - - if (currentIndex.isValid()) { - // See if the current master is in the string with selected masters - if (masterstr.contains(master)) - { - // Append the plugins from the current master to pluginsmodel - addPlugins(currentIndex); - } - } - } - } - - // See what plugins to remove - QModelIndexList deselectedIndexes = deselected.indexes(); - - if (!deselectedIndexes.isEmpty()) { - foreach (const QModelIndex ¤tIndex, deselectedIndexes) { - - QString master = currentIndex.data().toString(); - master.prepend("*"); - master.append("*"); - const QList itemList = mDataFilesModel->findItems(master, Qt::MatchWildcard); - foreach (const QStandardItem *currentItem, itemList) { - QModelIndex index = currentItem->index(); - removePlugins(index); - } - } - } - -} - -void DataFilesPage::addPlugins(const QModelIndex &index) +void DataFilesPage::setCheckState(QModelIndex index) { - // Find the plugins in the datafilesmodel and append them to the pluginsmodel if (!index.isValid()) return; - for (int r=0; rrowCount(index); ++r ) { - QModelIndex childIndex = index.child(r, 0); - - if (childIndex.isValid()) { - // Now we see if the pluginsmodel already contains this plugin - const QString childIndexData = QVariant(mDataFilesModel->data(childIndex)).toString(); - const QString childIndexToolTip = QVariant(mDataFilesModel->data(childIndex, Qt::ToolTipRole)).toString(); - - const QList itemList = mPluginsModel->findItems(childIndexData); - - if (itemList.isEmpty()) - { - // Plugin not yet in the pluginsmodel, add it - QStandardItem *item = new QStandardItem(childIndexData); - item->setFlags(item->flags() & ~(Qt::ItemIsDropEnabled)); - item->setCheckable(true); - item->setToolTip(childIndexToolTip); - - mPluginsModel->appendRow(item); - } - } - - } - -} + QObject *object = QObject::sender(); -void DataFilesPage::removePlugins(const QModelIndex &index) -{ - - if (!index.isValid()) + // Not a signal-slot call + if (!object) return; - for (int r=0; rrowCount(index); ++r) { - QModelIndex childIndex = index.child(r, 0); - - const QList itemList = mPluginsModel->findItems(QVariant(childIndex.data()).toString()); - - if (!itemList.isEmpty()) { - foreach (const QStandardItem *currentItem, itemList) { - mPluginsModel->removeRow(currentItem->row()); - } + if (object->objectName() == QLatin1String("PluginsTable")) { + if (mPluginsModel->checkState(index) == Qt::Checked) { + mPluginsModel->setCheckState(index, Qt::Unchecked); + } else { + mPluginsModel->setCheckState(index, Qt::Checked); } } -} - -void DataFilesPage::setCheckState(QModelIndex index) -{ - if (!index.isValid()) - return; - - QModelIndex sourceModelIndex = mPluginsProxyModel->mapToSource(index); - - if (mPluginsModel->data(sourceModelIndex, Qt::CheckStateRole) == Qt::Checked) { - // Selected row is checked, uncheck it - mPluginsModel->setData(sourceModelIndex, Qt::Unchecked, Qt::CheckStateRole); - } else { - mPluginsModel->setData(sourceModelIndex, Qt::Checked, Qt::CheckStateRole); - } -} - -const QStringList DataFilesPage::selectedMasters() -{ - QStringList masters; - const QList selectedMasters = mMastersWidget->selectedItems(); - - foreach (const QTableWidgetItem *item, selectedMasters) { - masters.append(item->data(Qt::DisplayRole).toString()); - } - - return masters; -} - -const QStringList DataFilesPage::checkedPlugins() -{ - QStringList checkedItems; - - for (int r=0; rrowCount(); ++r ) { - QModelIndex index = mPluginsModel->index(r, 0); - - if (index.isValid()) { - // See if the current item is checked - if (mPluginsModel->data(index, Qt::CheckStateRole) == Qt::Checked) { - checkedItems.append(index.data().toString()); - } + if (object->objectName() == QLatin1String("MastersTable")) { + if (mMastersModel->checkState(index) == Qt::Checked) { + mMastersModel->setCheckState(index, Qt::Unchecked); + } else { + mMastersModel->setCheckState(index, Qt::Checked); } } - return checkedItems; -} -void DataFilesPage::uncheckPlugins() -{ - for (int r=0; rrowCount(); ++r ) { - QModelIndex index = mPluginsModel->index(r, 0); + return; - if (index.isValid()) { - // See if the current item is checked - if (mPluginsModel->data(index, Qt::CheckStateRole) == Qt::Checked) { - mPluginsModel->setData(index, Qt::Unchecked, Qt::CheckStateRole); - } - } - } } void DataFilesPage::filterChanged(const QString filter) @@ -985,11 +719,8 @@ void DataFilesPage::filterChanged(const QString filter) void DataFilesPage::profileChanged(const QString &previous, const QString ¤t) { // Prevent the deletion of the default profile - if (current == "Default") { - mDeleteProfileAction->setEnabled(false); - } else { - mDeleteProfileAction->setEnabled(true); - } + (current == QLatin1String("Default")) ? mDeleteProfileAction->setEnabled(false) + : mDeleteProfileAction->setEnabled(true); if (!previous.isEmpty()) { writeConfig(previous); @@ -998,226 +729,37 @@ void DataFilesPage::profileChanged(const QString &previous, const QString &curre return; } - uncheckPlugins(); - // Deselect the masters - mMastersWidget->selectionModel()->clearSelection(); + mMastersModel->uncheckAll(); + mPluginsModel->uncheckAll(); readConfig(); } -void DataFilesPage::readConfig() -{ - QString profile = mProfilesComboBox->currentText(); - - // Make sure we have no groups open - while (!mLauncherConfig->group().isEmpty()) { - mLauncherConfig->endGroup(); - } - - mLauncherConfig->beginGroup("Profiles"); - mLauncherConfig->beginGroup(profile); - - QStringList childKeys = mLauncherConfig->childKeys(); - QStringList plugins; - - // Sort the child keys numerical instead of alphabetically - // i.e. Plugin1, Plugin2 instead of Plugin1, Plugin10 - qSort(childKeys.begin(), childKeys.end(), naturalSortLessThanCI); - - foreach (const QString &key, childKeys) { - const QString keyValue = mLauncherConfig->value(key).toString(); - - if (key.startsWith("Plugin")) { - plugins.append(keyValue); - continue; - } - - if (key.startsWith("Master")) { - const QList masterList = mMastersWidget->findItems(keyValue, Qt::MatchFixedString); - - if (!masterList.isEmpty()) { - foreach (QTableWidgetItem *currentMaster, masterList) { - mMastersWidget->selectionModel()->select(mMastersWidget->model()->index(currentMaster->row(), 0), QItemSelectionModel::Select); - } - } - } - } - - // Iterate over the plugins to set their checkstate and position - for (int i = 0; i < plugins.size(); ++i) { - const QString plugin = plugins.at(i); - - const QList pluginList = mPluginsModel->findItems(plugin); - - if (!pluginList.isEmpty()) - { - foreach (const QStandardItem *currentPlugin, pluginList) { - mPluginsModel->setData(currentPlugin->index(), Qt::Checked, Qt::CheckStateRole); - - // Move the plugin to the position specified in the config file - mPluginsModel->insertRow(i, mPluginsModel->takeRow(currentPlugin->row())); - } - } - } - -} - -void DataFilesPage::writeConfig(QString profile) +void DataFilesPage::showContextMenu(const QPoint &point) { - // Don't overwrite the config if no masters are found - if (mMastersWidget->rowCount() < 1) { - return; - } - - QString pathStr = QString::fromStdString(mCfgMgr.getUserPath().string()); - QDir userPath(pathStr); - - if (!userPath.exists()) { - if (!userPath.mkpath(pathStr)) { - QMessageBox msgBox; - msgBox.setWindowTitle("Error creating OpenMW configuration directory"); - msgBox.setIcon(QMessageBox::Critical); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setText(tr("
Could not create %0

\ - Please make sure you have the right permissions and try again.
").arg(pathStr)); - msgBox.exec(); - - qApp->quit(); - return; - } - } - // Open the OpenMW config as a QFile - QFile file(pathStr.append("openmw.cfg")); - - if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { - // File cannot be opened or created - QMessageBox msgBox; - msgBox.setWindowTitle("Error writing OpenMW configuration file"); - msgBox.setIcon(QMessageBox::Critical); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setText(tr("
Could not open or create %0

\ - Please make sure you have the right permissions and try again.
").arg(file.fileName())); - msgBox.exec(); - - qApp->quit(); - return; - } - - QTextStream in(&file); - QByteArray buffer; - - // Remove all previous entries from config - while (!in.atEnd()) { - QString line = in.readLine(); - if (!line.startsWith("master") && - !line.startsWith("plugin") && - !line.startsWith("data") && - !line.startsWith("data-local")) - { - buffer += line += "\n"; - } - } - - file.close(); - - // Now we write back the other config entries - if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) { - QMessageBox msgBox; - msgBox.setWindowTitle("Error writing OpenMW configuration file"); - msgBox.setIcon(QMessageBox::Critical); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setText(tr("
Could not write to %0

\ - Please make sure you have the right permissions and try again.
").arg(file.fileName())); - msgBox.exec(); - - qApp->quit(); - return; - } - - if (!buffer.isEmpty()) { - file.write(buffer); - } - - QTextStream gameConfig(&file); - - // First write the list of data dirs - mCfgMgr.processPaths(mDataDirs); - mCfgMgr.processPaths(mDataLocal); - - QString path; - - // data= directories - for (Files::PathContainer::iterator it = mDataDirs.begin(); it != mDataDirs.end(); ++it) { - path = QString::fromStdString(it->string()); - path.remove(QChar('\"')); - - QDir dir(path); - - // Make sure the string is quoted when it contains spaces - if (path.contains(" ")) { - gameConfig << "data=\"" << dir.absolutePath() << "\"" << endl; - } else { - gameConfig << "data=" << dir.absolutePath() << endl; - } - } - - // data-local directory - if (!mDataLocal.empty()) { - path = QString::fromStdString(mDataLocal.front().string()); - path.remove(QChar('\"')); - - QDir dir(path); - - if (path.contains(" ")) { - gameConfig << "data-local=\"" << dir.absolutePath() << "\"" << endl; - } else { - gameConfig << "data-local=" << dir.absolutePath() << endl; - } - } - - - if (profile.isEmpty()) { - profile = mProfilesComboBox->currentText(); - } - - if (profile.isEmpty()) { + // Make sure there are plugins in the view + if (!mPluginsTable->selectionModel()->hasSelection()) { return; } - // Make sure we have no groups open - while (!mLauncherConfig->group().isEmpty()) { - mLauncherConfig->endGroup(); - } - - mLauncherConfig->beginGroup("Profiles"); - mLauncherConfig->setValue("CurrentProfile", profile); - - // Open the profile-name subgroup - mLauncherConfig->beginGroup(profile); - mLauncherConfig->remove(""); // Clear the subgroup + QPoint globalPos = mPluginsTable->mapToGlobal(point); - // Now write the masters to the configs - const QStringList masters = selectedMasters(); + QModelIndexList indexes = mPluginsTable->selectionModel()->selectedIndexes(); - // We don't use foreach because we need i - for (int i = 0; i < masters.size(); ++i) { - const QString currentMaster = masters.at(i); - - mLauncherConfig->setValue(QString("Master%0").arg(i), currentMaster); - gameConfig << "master=" << currentMaster << endl; - - } + // Show the check/uncheck actions depending on the state of the selected items + mUncheckAction->setEnabled(false); + mCheckAction->setEnabled(false); - // And finally write all checked plugins - const QStringList plugins = checkedPlugins(); + foreach (const QModelIndex &index, indexes) { + if (!index.isValid()) + return; - for (int i = 0; i < plugins.size(); ++i) { - const QString currentPlugin = plugins.at(i); - mLauncherConfig->setValue(QString("Plugin%1").arg(i), currentPlugin); - gameConfig << "plugin=" << currentPlugin << endl; + if (mPluginsModel->checkState(index) == Qt::Checked) { + mUncheckAction->setEnabled(true); + } else { + mCheckAction->setEnabled(true); + } } - file.close(); - mLauncherConfig->endGroup(); - mLauncherConfig->endGroup(); - mLauncherConfig->sync(); + // Show menu + mContextMenu->exec(globalPos); } diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index 83b318677..648991254 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -8,19 +8,15 @@ #include "combobox.hpp" -class QTableWidget; -class QStandardItemModel; -class QItemSelection; -class QItemSelectionModel; +class QTableView; class QSortFilterProxyModel; -class QStringListModel; class QSettings; class QAction; class QToolBar; class QMenu; -class PluginsModel; -class PluginsView; class ComboBox; +class DataFilesModel; + namespace Files { struct ConfigurationManager; } @@ -37,7 +33,6 @@ public: bool setupDataFiles(); public slots: - void masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); void setCheckState(QModelIndex index); void filterChanged(const QString filter); @@ -46,37 +41,34 @@ public slots: // Action slots void newProfile(); - void copyProfile(); void deleteProfile(); - void moveUp(); - void moveDown(); - void moveTop(); - void moveBottom(); +// void moveUp(); +// void moveDown(); +// void moveTop(); +// void moveBottom(); void check(); void uncheck(); void refresh(); private: - QTableWidget *mMastersWidget; - PluginsView *mPluginsTable; - - QStandardItemModel *mDataFilesModel; - PluginsModel *mPluginsModel; + DataFilesModel *mMastersModel; + DataFilesModel *mPluginsModel; QSortFilterProxyModel *mPluginsProxyModel; - QItemSelectionModel *mPluginsSelectModel; + + QTableView *mMastersTable; + QTableView *mPluginsTable; QToolBar *mProfileToolBar; QMenu *mContextMenu; QAction *mNewProfileAction; - QAction *mCopyProfileAction; QAction *mDeleteProfileAction; - QAction *mMoveUpAction; - QAction *mMoveDownAction; - QAction *mMoveTopAction; - QAction *mMoveBottomAction; +// QAction *mMoveUpAction; +// QAction *mMoveDownAction; +// QAction *mMoveTopAction; +// QAction *mMoveBottomAction; QAction *mCheckAction; QAction *mUncheckAction; @@ -86,17 +78,12 @@ private: QSettings *mLauncherConfig; - const QStringList checkedPlugins(); - const QStringList selectedMasters(); +// const QStringList checkedPlugins(); +// const QStringList selectedMasters(); - void addDataFiles(Files::Collections &fileCollections, const QString &encoding); - void addPlugins(const QModelIndex &index); - void removePlugins(const QModelIndex &index); - void uncheckPlugins(); void createActions(); void setupConfig(); void readConfig(); - void scrollToSelection(); }; diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index be89902c8..f009c3df0 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include "esm/esmfile.hpp" From 85aaacb41a89e37f874ecdbd8f22ad55128dcb0f Mon Sep 17 00:00:00 2001 From: pvdk Date: Fri, 12 Oct 2012 02:25:14 +0200 Subject: [PATCH 003/107] Some cleaning of the launcher source dir --- apps/launcher/CMakeLists.txt | 35 +++-- apps/launcher/datafilespage.cpp | 10 +- apps/launcher/datafilespage.hpp | 1 - apps/launcher/graphicspage.cpp | 3 +- apps/launcher/maindialog.cpp | 2 + apps/launcher/model/datafilesmodel.cpp | 3 +- apps/launcher/pluginsmodel.cpp | 149 ---------------------- apps/launcher/pluginsmodel.hpp | 21 --- apps/launcher/pluginsview.cpp | 41 ------ apps/launcher/pluginsview.hpp | 29 ----- apps/launcher/{ => utils}/combobox.hpp | 0 apps/launcher/{ => utils}/filedialog.cpp | 0 apps/launcher/{ => utils}/filedialog.hpp | 0 apps/launcher/{ => utils}/lineedit.cpp | 0 apps/launcher/{ => utils}/lineedit.hpp | 0 apps/launcher/{ => utils}/naturalsort.cpp | 0 apps/launcher/{ => utils}/naturalsort.hpp | 0 17 files changed, 28 insertions(+), 266 deletions(-) delete mode 100644 apps/launcher/pluginsmodel.cpp delete mode 100644 apps/launcher/pluginsmodel.hpp delete mode 100644 apps/launcher/pluginsview.cpp delete mode 100644 apps/launcher/pluginsview.hpp rename apps/launcher/{ => utils}/combobox.hpp (100%) rename apps/launcher/{ => utils}/filedialog.cpp (100%) rename apps/launcher/{ => utils}/filedialog.hpp (100%) rename apps/launcher/{ => utils}/lineedit.cpp (100%) rename apps/launcher/{ => utils}/lineedit.hpp (100%) rename apps/launcher/{ => utils}/naturalsort.cpp (100%) rename apps/launcher/{ => utils}/naturalsort.hpp (100%) diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index 53631ebdd..92903b48d 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -1,54 +1,51 @@ set(LAUNCHER datafilespage.cpp - filedialog.cpp graphicspage.cpp - lineedit.cpp main.cpp maindialog.cpp - naturalsort.cpp playpage.cpp - pluginsmodel.cpp - pluginsview.cpp - - launcher.rc model/datafilesmodel.cpp model/modelitem.cpp model/esm/esmfile.cpp + + utils/filedialog.cpp + utils/naturalsort.cpp + utils/lineedit.cpp + + launcher.rc ) set(LAUNCHER_HEADER - combobox.hpp datafilespage.hpp - filedialog.hpp graphicspage.hpp - lineedit.hpp maindialog.hpp - naturalsort.hpp playpage.hpp - pluginsmodel.hpp - pluginsview.hpp model/datafilesmodel.hpp model/modelitem.hpp model/esm/esmfile.hpp + + utils/combobox.hpp + utils/lineedit.hpp + utils/filedialog.hpp + utils/naturalsort.hpp ) # Headers that must be pre-processed set(LAUNCHER_HEADER_MOC - combobox.hpp datafilespage.hpp - filedialog.hpp graphicspage.hpp - lineedit.hpp maindialog.hpp playpage.hpp - pluginsmodel.hpp - pluginsview.hpp model/datafilesmodel.hpp model/modelitem.hpp model/esm/esmfile.hpp + + utils/combobox.hpp + utils/lineedit.hpp + utils/filedialog.hpp ) source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER} ${LAUNCHER_HEADER_MOC}) @@ -87,7 +84,7 @@ add_executable(omwlauncher target_link_libraries(omwlauncher ${Boost_LIBRARIES} ${OGRE_LIBRARIES} - ${OGRE_STATIC_PLUGINS} + ${OGRE_STATIC_PLUGINS} ${QT_LIBRARIES} components ) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index c0a447e26..7b6c949c4 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -6,11 +6,12 @@ #include "model/datafilesmodel.hpp" #include "model/esm/esmfile.hpp" -#include "combobox.hpp" +#include "utils/combobox.hpp" +#include "utils/filedialog.hpp" +#include "utils/lineedit.hpp" +#include "utils/naturalsort.hpp" + #include "datafilespage.hpp" -#include "filedialog.hpp" -#include "lineedit.hpp" -#include "naturalsort.hpp" #include /** @@ -110,6 +111,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) mPluginsTable->setAlternatingRowColors(true); mPluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem); mPluginsTable->horizontalHeader()->setStretchLastSection(true); + mPluginsTable->horizontalHeader()->hide(); mPluginsTable->verticalHeader()->setDefaultSectionSize(height); mPluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed); diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index 648991254..64f255b57 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -6,7 +6,6 @@ #include -#include "combobox.hpp" class QTableView; class QSortFilterProxyModel; diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index c3c39cffc..7685cb3c2 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -9,8 +9,9 @@ #include #include +#include "utils/naturalsort.hpp" + #include "graphicspage.hpp" -#include "naturalsort.hpp" QString getAspect(int x, int y) { diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index f7dafd3af..f215b9118 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -1,5 +1,7 @@ #include +#include "utils/combobox.hpp" + #include "maindialog.hpp" #include "playpage.hpp" #include "graphicspage.hpp" diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index f009c3df0..0aa29a337 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -6,8 +6,9 @@ #include "esm/esmfile.hpp" +#include "../utils/naturalsort.hpp" + #include "datafilesmodel.hpp" -#include "../naturalsort.hpp" DataFilesModel::DataFilesModel(QObject *parent) : QAbstractTableModel(parent) diff --git a/apps/launcher/pluginsmodel.cpp b/apps/launcher/pluginsmodel.cpp deleted file mode 100644 index 86bd53027..000000000 --- a/apps/launcher/pluginsmodel.cpp +++ /dev/null @@ -1,149 +0,0 @@ -#include -#include - -#include - -#include "pluginsmodel.hpp" - -PluginsModel::PluginsModel(QObject *parent) : QStandardItemModel(parent) -{ - -} - -void decodeDataRecursive(QDataStream &stream, QStandardItem *item) -{ - int colCount, childCount; - stream >> *item; - stream >> colCount >> childCount; - item->setColumnCount(colCount); - - int childPos = childCount; - - while(childPos > 0) { - childPos--; - QStandardItem *child = new QStandardItem(); - decodeDataRecursive(stream, child); - item->setChild( childPos / colCount, childPos % colCount, child); - } -} - -bool PluginsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent) -{ - // Code largely based on QStandardItemModel::dropMimeData - - // check if the action is supported - if (!data || !(action == Qt::CopyAction || action == Qt::MoveAction)) - return false; - - // check if the format is supported - QString format = QLatin1String("application/x-qstandarditemmodeldatalist"); - if (!data->hasFormat(format)) - return QAbstractItemModel::dropMimeData(data, action, row, column, parent); - - if (row > rowCount(parent)) - row = rowCount(parent); - if (row == -1) - row = rowCount(parent); - if (column == -1) - column = 0; - - // decode and insert - QByteArray encoded = data->data(format); - QDataStream stream(&encoded, QIODevice::ReadOnly); - - - //code based on QAbstractItemModel::decodeData - // adapted to work with QStandardItem - int top = std::numeric_limits::max(); - int left = std::numeric_limits::max(); - int bottom = 0; - int right = 0; - QVector rows, columns; - QVector items; - - while (!stream.atEnd()) { - int r, c; - QStandardItem *item = new QStandardItem(); - stream >> r >> c; - decodeDataRecursive(stream, item); - - rows.append(r); - columns.append(c); - items.append(item); - top = qMin(r, top); - left = qMin(c, left); - bottom = qMax(r, bottom); - right = qMax(c, right); - } - - // insert the dragged items into the table, use a bit array to avoid overwriting items, - // since items from different tables can have the same row and column - int dragRowCount = 0; - int dragColumnCount = right - left + 1; - - // Compute the number of continuous rows upon insertion and modify the rows to match - QVector rowsToInsert(bottom + 1); - for (int i = 0; i < rows.count(); ++i) - rowsToInsert[rows.at(i)] = 1; - for (int i = 0; i < rowsToInsert.count(); ++i) { - if (rowsToInsert[i] == 1){ - rowsToInsert[i] = dragRowCount; - ++dragRowCount; - } - } - for (int i = 0; i < rows.count(); ++i) - rows[i] = top + rowsToInsert[rows[i]]; - - QBitArray isWrittenTo(dragRowCount * dragColumnCount); - - // make space in the table for the dropped data - int colCount = columnCount(parent); - if (colCount < dragColumnCount + column) { - insertColumns(colCount, dragColumnCount + column - colCount, parent); - colCount = columnCount(parent); - } - insertRows(row, dragRowCount, parent); - - row = qMax(0, row); - column = qMax(0, column); - - QStandardItem *parentItem = itemFromIndex (parent); - if (!parentItem) - parentItem = invisibleRootItem(); - - QVector newIndexes(items.size()); - // set the data in the table - for (int j = 0; j < items.size(); ++j) { - int relativeRow = rows.at(j) - top; - int relativeColumn = columns.at(j) - left; - int destinationRow = relativeRow + row; - int destinationColumn = relativeColumn + column; - int flat = (relativeRow * dragColumnCount) + relativeColumn; - // if the item was already written to, or we just can't fit it in the table, create a new row - if (destinationColumn >= colCount || isWrittenTo.testBit(flat)) { - destinationColumn = qBound(column, destinationColumn, colCount - 1); - destinationRow = row + dragRowCount; - insertRows(row + dragRowCount, 1, parent); - flat = (dragRowCount * dragColumnCount) + relativeColumn; - isWrittenTo.resize(++dragRowCount * dragColumnCount); - } - if (!isWrittenTo.testBit(flat)) { - newIndexes[j] = index(destinationRow, destinationColumn, parentItem->index()); - isWrittenTo.setBit(flat); - } - } - - for(int k = 0; k < newIndexes.size(); k++) { - if (newIndexes.at(k).isValid()) { - parentItem->setChild(newIndexes.at(k).row(), newIndexes.at(k).column(), items.at(k)); - } else { - delete items.at(k); - } - } - - // The important part, tell the view what is dropped - emit indexesDropped(newIndexes); - - return true; -} diff --git a/apps/launcher/pluginsmodel.hpp b/apps/launcher/pluginsmodel.hpp deleted file mode 100644 index 41df499b5..000000000 --- a/apps/launcher/pluginsmodel.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef PLUGINSMODEL_H -#define PLUGINSMODEL_H - -#include - -class PluginsModel : public QStandardItemModel -{ - Q_OBJECT - -public: - PluginsModel(QObject *parent = 0); - ~PluginsModel() {}; - - bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); - -signals: - void indexesDropped(QVector indexes); - -}; - -#endif \ No newline at end of file diff --git a/apps/launcher/pluginsview.cpp b/apps/launcher/pluginsview.cpp deleted file mode 100644 index 26cf337fb..000000000 --- a/apps/launcher/pluginsview.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include - -#include "pluginsview.hpp" - -PluginsView::PluginsView(QWidget *parent) : QTableView(parent) -{ - setSelectionBehavior(QAbstractItemView::SelectRows); - setSelectionMode(QAbstractItemView::ExtendedSelection); - setEditTriggers(QAbstractItemView::NoEditTriggers); - setAlternatingRowColors(true); - setDragEnabled(true); - setDragDropMode(QAbstractItemView::InternalMove); - setDropIndicatorShown(true); - setDragDropOverwriteMode(false); - setContextMenuPolicy(Qt::CustomContextMenu); - -} - -void PluginsView::startDrag(Qt::DropActions supportedActions) -{ - selectionModel()->select( selectionModel()->selection(), - QItemSelectionModel::Select | QItemSelectionModel::Rows ); - QAbstractItemView::startDrag( supportedActions ); -} - -void PluginsView::setModel(QSortFilterProxyModel *model) -{ - QTableView::setModel(model); - - qRegisterMetaType< QVector >(); - - connect(model->sourceModel(), SIGNAL(indexesDropped(QVector)), - this, SLOT(selectIndexes(QVector)), Qt::QueuedConnection); -} - -void PluginsView::selectIndexes( QVector aIndexes ) -{ - selectionModel()->clearSelection(); - foreach( QPersistentModelIndex pIndex, aIndexes ) - selectionModel()->select( pIndex, QItemSelectionModel::Select | QItemSelectionModel::Rows ); -} diff --git a/apps/launcher/pluginsview.hpp b/apps/launcher/pluginsview.hpp deleted file mode 100644 index 484351e33..000000000 --- a/apps/launcher/pluginsview.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef PLUGINSVIEW_H -#define PLUGINSVIEW_H - -#include - -#include "pluginsmodel.hpp" - -class QSortFilterProxyModel; - -class PluginsView : public QTableView -{ - Q_OBJECT -public: - PluginsView(QWidget *parent = 0); - - PluginsModel* model() const - { return qobject_cast(QAbstractItemView::model()); } - - void startDrag(Qt::DropActions supportedActions); - void setModel(QSortFilterProxyModel *model); - -public slots: - void selectIndexes(QVector aIndexes); - -}; - -Q_DECLARE_METATYPE(QVector) - -#endif diff --git a/apps/launcher/combobox.hpp b/apps/launcher/utils/combobox.hpp similarity index 100% rename from apps/launcher/combobox.hpp rename to apps/launcher/utils/combobox.hpp diff --git a/apps/launcher/filedialog.cpp b/apps/launcher/utils/filedialog.cpp similarity index 100% rename from apps/launcher/filedialog.cpp rename to apps/launcher/utils/filedialog.cpp diff --git a/apps/launcher/filedialog.hpp b/apps/launcher/utils/filedialog.hpp similarity index 100% rename from apps/launcher/filedialog.hpp rename to apps/launcher/utils/filedialog.hpp diff --git a/apps/launcher/lineedit.cpp b/apps/launcher/utils/lineedit.cpp similarity index 100% rename from apps/launcher/lineedit.cpp rename to apps/launcher/utils/lineedit.cpp diff --git a/apps/launcher/lineedit.hpp b/apps/launcher/utils/lineedit.hpp similarity index 100% rename from apps/launcher/lineedit.hpp rename to apps/launcher/utils/lineedit.hpp diff --git a/apps/launcher/naturalsort.cpp b/apps/launcher/utils/naturalsort.cpp similarity index 100% rename from apps/launcher/naturalsort.cpp rename to apps/launcher/utils/naturalsort.cpp diff --git a/apps/launcher/naturalsort.hpp b/apps/launcher/utils/naturalsort.hpp similarity index 100% rename from apps/launcher/naturalsort.hpp rename to apps/launcher/utils/naturalsort.hpp From 6433b1e0220fe08baff1e242fa2a6cd463f79002 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Mon, 22 Oct 2012 02:25:10 +0200 Subject: [PATCH 004/107] Some minor fixes --- apps/launcher/datafilespage.cpp | 3 ++- apps/launcher/maindialog.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index c0a447e26..ebbfb9960 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -90,6 +90,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) // Set the row height to the size of the checkboxes mMastersTable->verticalHeader()->setDefaultSectionSize(height); + mMastersTable->verticalHeader()->setResizeMode(QHeaderView::Fixed); mMastersTable->verticalHeader()->hide(); mMastersTable->setColumnHidden(1, true); mMastersTable->setColumnHidden(2, true); @@ -110,7 +111,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) mPluginsTable->setAlternatingRowColors(true); mPluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem); mPluginsTable->horizontalHeader()->setStretchLastSection(true); - + mPluginsTable->horizontalHeader()->hide(); mPluginsTable->verticalHeader()->setDefaultSectionSize(height); mPluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed); mPluginsTable->setColumnHidden(1, true); diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index f7dafd3af..3ce418ddf 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -244,10 +244,10 @@ void MainDialog::play() const std::string settingspath = (mCfgMgr.getUserPath() / "settings.cfg").string(); mSettings.saveUser(settingspath); -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN QString game = "./openmw.exe"; QFile file(game); -#elif defined(Q_WS_MAC) +#elif defined(Q_OS_MAC) QDir dir(QCoreApplication::applicationDirPath()); QString game = dir.absoluteFilePath("openmw"); QFile file(game); From fe9120bcb31a7653e7cfd772c8ad4cfb51ce059f Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Tue, 23 Oct 2012 01:47:07 +0200 Subject: [PATCH 005/107] Added support for the profiles and made creation/editing them more user friendly --- apps/launcher/CMakeLists.txt | 9 +- apps/launcher/datafilespage.cpp | 146 ++++++++++++++++------- apps/launcher/datafilespage.hpp | 11 +- apps/launcher/main.cpp | 2 +- apps/launcher/maindialog.cpp | 2 - apps/launcher/utils/combobox.hpp | 28 ----- apps/launcher/utils/profilescombobox.cpp | 52 ++++++++ apps/launcher/utils/profilescombobox.hpp | 30 +++++ apps/launcher/utils/textinputdialog.cpp | 61 ++++++++++ apps/launcher/utils/textinputdialog.hpp | 28 +++++ 10 files changed, 289 insertions(+), 80 deletions(-) delete mode 100644 apps/launcher/utils/combobox.hpp create mode 100644 apps/launcher/utils/profilescombobox.cpp create mode 100644 apps/launcher/utils/profilescombobox.hpp create mode 100644 apps/launcher/utils/textinputdialog.cpp create mode 100644 apps/launcher/utils/textinputdialog.hpp diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index 92903b48d..edc3dcf32 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -12,6 +12,8 @@ set(LAUNCHER utils/filedialog.cpp utils/naturalsort.cpp utils/lineedit.cpp + utils/profilescombobox.cpp + utils/textinputdialog.cpp launcher.rc ) @@ -26,10 +28,12 @@ set(LAUNCHER_HEADER model/modelitem.hpp model/esm/esmfile.hpp - utils/combobox.hpp utils/lineedit.hpp utils/filedialog.hpp utils/naturalsort.hpp + utils/profilescombobox.hpp + utils/textinputdialog.hpp + ) # Headers that must be pre-processed @@ -43,9 +47,10 @@ set(LAUNCHER_HEADER_MOC model/modelitem.hpp model/esm/esmfile.hpp - utils/combobox.hpp utils/lineedit.hpp utils/filedialog.hpp + utils/profilescombobox.hpp + utils/textinputdialog.hpp ) source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER} ${LAUNCHER_HEADER_MOC}) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index ce3d6b31d..01b879842 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -6,10 +6,11 @@ #include "model/datafilesmodel.hpp" #include "model/esm/esmfile.hpp" -#include "utils/combobox.hpp" +#include "utils/profilescombobox.hpp" #include "utils/filedialog.hpp" #include "utils/lineedit.hpp" #include "utils/naturalsort.hpp" +#include "utils/textinputdialog.hpp" #include "datafilespage.hpp" @@ -139,9 +140,11 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) // Bottom part with profile options QLabel *profileLabel = new QLabel(tr("Current Profile: "), this); - mProfilesComboBox = new ComboBox(this); + mProfilesComboBox = new ProfilesComboBox(this); mProfilesComboBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); - mProfilesComboBox->setInsertPolicy(QComboBox::InsertAtBottom); + mProfilesComboBox->setInsertPolicy(QComboBox::NoInsert); + mProfilesComboBox->setDuplicatesEnabled(false); + mProfilesComboBox->setEditEnabled(false); mProfileToolBar = new QToolBar(this); mProfileToolBar->setMovable(false); @@ -156,16 +159,22 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) pageLayout->addWidget(splitter); pageLayout->addWidget(mProfileToolBar); + // Create a dialog for the new profile name input + mNewProfileDialog = new TextInputDialog(tr("New Profile"), tr("Profile name:"), this); + + connect(mNewProfileDialog->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(updateOkButton(QString))); + connect(mPluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex))); connect(mMastersTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex))); connect(mMastersModel, SIGNAL(checkedItemsChanged(QStringList,QStringList)), mPluginsModel, SLOT(slotcheckedItemsChanged(QStringList,QStringList))); - connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(const QString))); + connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); - connect(mPluginsTable, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showContextMenu(const QPoint&))); + connect(mPluginsTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); - connect(mProfilesComboBox, SIGNAL(textChanged(const QString&, const QString&)), this, SLOT(profileChanged(const QString&, const QString&))); + connect(mProfilesComboBox, SIGNAL(profileRenamed(QString,QString)), this, SLOT(profileRenamed(QString,QString))); + connect(mProfilesComboBox, SIGNAL(profileChanged(QString,QString)), this, SLOT(profileChanged(QString,QString))); createActions(); setupConfig(); @@ -230,12 +239,21 @@ void DataFilesPage::setupConfig() mLauncherConfig->beginGroup("Profiles"); QStringList profiles = mLauncherConfig->childGroups(); - if (profiles.isEmpty()) { - // Add a default profile - profiles.append("Default"); + // Add the profiles to the combobox + foreach (const QString &profile, profiles) { + + if (profile.contains(QRegExp("[^a-zA-Z0-9_]"))) + continue; // Profile name contains garbage + + + qDebug() << "adding " << profile; + mProfilesComboBox->addItem(profile); } - mProfilesComboBox->addItems(profiles); + // Add a default profile + if (mProfilesComboBox->count() == 0) { + mProfilesComboBox->addItem(QString("Default")); + } QString currentProfile = mLauncherConfig->value("CurrentProfile").toString(); @@ -572,33 +590,37 @@ void DataFilesPage::writeConfig(QString profile) void DataFilesPage::newProfile() { - bool ok; - QString text = QInputDialog::getText(this, tr("New Profile"), - tr("Profile Name:"), QLineEdit::Normal, - tr("New Profile"), &ok); - if (ok && !text.isEmpty()) { - if (mProfilesComboBox->findText(text) != -1) { - QMessageBox::warning(this, tr("Profile already exists"), - tr("the profile %0 already exists.").arg(text), - QMessageBox::Ok); - } else { - // Add the new profile to the combobox - mProfilesComboBox->addItem(text); - mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(text)); + if (mNewProfileDialog->exec() == QDialog::Accepted) { - } + const QString text = mNewProfileDialog->lineEdit()->text(); + mProfilesComboBox->addItem(text); + // Copy the currently checked items to cfg + writeConfig(text); + mLauncherConfig->sync(); + + mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(text)); } } +void DataFilesPage::updateOkButton(const QString &text) +{ + if (text.isEmpty()) { + mNewProfileDialog->setOkButtonEnabled(false); + return; + } + + (mProfilesComboBox->findText(text) == -1) + ? mNewProfileDialog->setOkButtonEnabled(true) + : mNewProfileDialog->setOkButtonEnabled(false); +} + void DataFilesPage::deleteProfile() { QString profile = mProfilesComboBox->currentText(); - - if (profile.isEmpty()) { + if (profile.isEmpty()) return; - } QMessageBox msgBox(this); msgBox.setWindowTitle(tr("Delete Profile")); @@ -694,19 +716,17 @@ void DataFilesPage::setCheckState(QModelIndex index) return; if (object->objectName() == QLatin1String("PluginsTable")) { - if (mPluginsModel->checkState(index) == Qt::Checked) { - mPluginsModel->setCheckState(index, Qt::Unchecked); - } else { - mPluginsModel->setCheckState(index, Qt::Checked); - } + QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(index); + + (mPluginsModel->checkState(sourceIndex) == Qt::Checked) + ? mPluginsModel->setCheckState(index, Qt::Unchecked) + : mPluginsModel->setCheckState(index, Qt::Checked); } if (object->objectName() == QLatin1String("MastersTable")) { - if (mMastersModel->checkState(index) == Qt::Checked) { - mMastersModel->setCheckState(index, Qt::Unchecked); - } else { - mMastersModel->setCheckState(index, Qt::Checked); - } + (mMastersModel->checkState(index) == Qt::Checked) + ? mMastersModel->setCheckState(index, Qt::Unchecked) + : mMastersModel->setCheckState(index, Qt::Checked); } return; @@ -721,13 +741,23 @@ void DataFilesPage::filterChanged(const QString filter) void DataFilesPage::profileChanged(const QString &previous, const QString ¤t) { + qDebug() << "Profile is changed from: " << previous << " to " << current; // Prevent the deletion of the default profile - (current == QLatin1String("Default")) ? mDeleteProfileAction->setEnabled(false) - : mDeleteProfileAction->setEnabled(true); + if (current == QLatin1String("Default")) { + mDeleteProfileAction->setEnabled(false); + mProfilesComboBox->setEditEnabled(false); + } else { + mDeleteProfileAction->setEnabled(true); + mProfilesComboBox->setEditEnabled(true); + } if (!previous.isEmpty()) { writeConfig(previous); mLauncherConfig->sync(); + + if (mProfilesComboBox->currentIndex() == -1) + return; + } else { return; } @@ -737,6 +767,36 @@ void DataFilesPage::profileChanged(const QString &previous, const QString &curre readConfig(); } +void DataFilesPage::profileRenamed(const QString &previous, const QString ¤t) +{ + if (previous.isEmpty()) + return; + + // Save the new profile name + writeConfig(current); + + // Make sure we have no groups open + while (!mLauncherConfig->group().isEmpty()) { + mLauncherConfig->endGroup(); + } + + mLauncherConfig->beginGroup("Profiles"); + + // Open the profile-name subgroup + mLauncherConfig->beginGroup(previous); + mLauncherConfig->remove(""); // Clear the subgroup + mLauncherConfig->endGroup(); + mLauncherConfig->endGroup(); + mLauncherConfig->sync(); + + // Remove the profile from the combobox + mProfilesComboBox->removeItem(mProfilesComboBox->findText(previous)); + + mMastersModel->uncheckAll(); + mPluginsModel->uncheckAll(); + readConfig(); +} + void DataFilesPage::showContextMenu(const QPoint &point) { // Make sure there are plugins in the view @@ -756,11 +816,9 @@ void DataFilesPage::showContextMenu(const QPoint &point) if (!index.isValid()) return; - if (mPluginsModel->checkState(index) == Qt::Checked) { - mUncheckAction->setEnabled(true); - } else { - mCheckAction->setEnabled(true); - } + (mPluginsModel->checkState(index) == Qt::Checked) + ? mUncheckAction->setEnabled(true) + : mCheckAction->setEnabled(true); } // Show menu diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index 64f255b57..8b48c1e12 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -3,7 +3,7 @@ #include #include - +#include "utils/profilescombobox.hpp" #include @@ -13,9 +13,10 @@ class QSettings; class QAction; class QToolBar; class QMenu; -class ComboBox; +class ProfilesComboBox; class DataFilesModel; +class TextInputDialog; namespace Files { struct ConfigurationManager; } @@ -26,7 +27,7 @@ class DataFilesPage : public QWidget public: DataFilesPage(Files::ConfigurationManager& cfg, QWidget *parent = 0); - ComboBox *mProfilesComboBox; + ProfilesComboBox *mProfilesComboBox; void writeConfig(QString profile = QString()); bool setupDataFiles(); @@ -37,6 +38,8 @@ public slots: void filterChanged(const QString filter); void showContextMenu(const QPoint &point); void profileChanged(const QString &previous, const QString ¤t); + void profileRenamed(const QString &previous, const QString ¤t); + void updateOkButton(const QString &text); // Action slots void newProfile(); @@ -77,6 +80,8 @@ private: QSettings *mLauncherConfig; + TextInputDialog *mNewProfileDialog; + // const QStringList checkedPlugins(); // const QStringList selectedMasters(); diff --git a/apps/launcher/main.cpp b/apps/launcher/main.cpp index 4ae09f844..7c4cb5f7e 100644 --- a/apps/launcher/main.cpp +++ b/apps/launcher/main.cpp @@ -11,7 +11,7 @@ int main(int argc, char *argv[]) // Now we make sure the current dir is set to application path QDir dir(QCoreApplication::applicationDirPath()); - #if defined(Q_OS_MAC) + #ifdef Q_OS_MAC if (dir.dirName() == "MacOS") { dir.cdUp(); dir.cdUp(); diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index d65e51f24..3ce418ddf 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -1,7 +1,5 @@ #include -#include "utils/combobox.hpp" - #include "maindialog.hpp" #include "playpage.hpp" #include "graphicspage.hpp" diff --git a/apps/launcher/utils/combobox.hpp b/apps/launcher/utils/combobox.hpp deleted file mode 100644 index bc99575d7..000000000 --- a/apps/launcher/utils/combobox.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef COMBOBOX_H -#define COMBOBOX_H - -#include - -class ComboBox : public QComboBox -{ - Q_OBJECT -private: - QString oldText; -public: - ComboBox(QWidget *parent=0) : QComboBox(parent), oldText() - { - connect(this,SIGNAL(editTextChanged(const QString&)), this, - SLOT(textChangedSlot(const QString&))); - connect(this,SIGNAL(currentIndexChanged(const QString&)), this, - SLOT(textChangedSlot(const QString&))); - } -private slots: - void textChangedSlot(const QString &newText) - { - emit textChanged(oldText, newText); - oldText = newText; - } -signals: - void textChanged(const QString &oldText, const QString &newText); -}; -#endif \ No newline at end of file diff --git a/apps/launcher/utils/profilescombobox.cpp b/apps/launcher/utils/profilescombobox.cpp new file mode 100644 index 000000000..8354d4a78 --- /dev/null +++ b/apps/launcher/utils/profilescombobox.cpp @@ -0,0 +1,52 @@ +#include +#include +#include + +#include "profilescombobox.hpp" + +ProfilesComboBox::ProfilesComboBox(QWidget *parent) : + QComboBox(parent) +{ + mValidator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore + + setEditable(true); + setValidator(mValidator); + setCompleter(0); + + connect(this, SIGNAL(currentIndexChanged(int)), this, + SLOT(slotIndexChanged(int))); + connect(lineEdit(), SIGNAL(returnPressed()), this, + SLOT(slotReturnPressed())); +} + +void ProfilesComboBox::setEditEnabled(bool editable) +{ + if (!editable) + return setEditable(false); + + // Reset the completer and validator + setEditable(true); + setValidator(mValidator); + setCompleter(0); +} + +void ProfilesComboBox::slotReturnPressed() +{ + QString current = currentText(); + QString previous = itemText(currentIndex()); + + if (findText(current) != -1) + return; + + setItemText(currentIndex(), current); + emit(profileRenamed(previous, current)); +} + +void ProfilesComboBox::slotIndexChanged(int index) +{ + if (index == -1) + return; + + emit(profileChanged(mOldProfile, currentText())); + mOldProfile = itemText(index); +} diff --git a/apps/launcher/utils/profilescombobox.hpp b/apps/launcher/utils/profilescombobox.hpp new file mode 100644 index 000000000..c7da60d2a --- /dev/null +++ b/apps/launcher/utils/profilescombobox.hpp @@ -0,0 +1,30 @@ +#ifndef PROFILESCOMBOBOX_HPP +#define PROFILESCOMBOBOX_HPP + +#include + +class QString; + +class QRegExpValidator; + +class ProfilesComboBox : public QComboBox +{ + Q_OBJECT +public: + explicit ProfilesComboBox(QWidget *parent = 0); + void setEditEnabled(bool editable); + +signals: + void profileChanged(const QString &previous, const QString ¤t); + void profileRenamed(const QString &oldName, const QString &newName); + +private slots: + void slotReturnPressed(); + void slotIndexChanged(int index); + +private: + QString mOldProfile; + QRegExpValidator *mValidator; +}; + +#endif // PROFILESCOMBOBOX_HPP diff --git a/apps/launcher/utils/textinputdialog.cpp b/apps/launcher/utils/textinputdialog.cpp new file mode 100644 index 000000000..16cadb661 --- /dev/null +++ b/apps/launcher/utils/textinputdialog.cpp @@ -0,0 +1,61 @@ +#include +#include +#include +#include +#include +#include + +#include "lineedit.hpp" + +#include "textinputdialog.hpp" + +TextInputDialog::TextInputDialog(const QString& title, const QString &text, QWidget *parent) : + QDialog(parent) +{ + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + mButtonBox = new QDialogButtonBox(this); + mButtonBox->addButton(QDialogButtonBox::Ok); + mButtonBox->addButton(QDialogButtonBox::Cancel); + + setMaximumHeight(height()); + setOkButtonEnabled(false); + setModal(true); + + // Messageboxes on mac have no title +#ifndef Q_OS_MAC + setWindowTitle(title); +#else + Q_UNUSED(title); +#endif + + QLabel *label = new QLabel(this); + label->setText(text); + + // Line edit + QValidator *validator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore + mLineEdit = new LineEdit(this); + mLineEdit->setValidator(validator); + mLineEdit->setCompleter(0); + + QVBoxLayout *dialogLayout = new QVBoxLayout(this); + dialogLayout->addWidget(label); + dialogLayout->addWidget(mLineEdit); + dialogLayout->addWidget(mButtonBox); + + connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject())); +} + +int TextInputDialog::exec() +{ + mLineEdit->clear(); + mLineEdit->setFocus(); + return QDialog::exec(); +} + +void TextInputDialog::setOkButtonEnabled(bool enabled) +{ + + QPushButton *okButton = mButtonBox->button(QDialogButtonBox::Ok); + okButton->setEnabled(enabled); +} diff --git a/apps/launcher/utils/textinputdialog.hpp b/apps/launcher/utils/textinputdialog.hpp new file mode 100644 index 000000000..cbb453ac8 --- /dev/null +++ b/apps/launcher/utils/textinputdialog.hpp @@ -0,0 +1,28 @@ +#ifndef TEXTINPUTDIALOG_HPP +#define TEXTINPUTDIALOG_HPP + +#include +//#include "lineedit.hpp" + +class QDialogButtonBox; +class LineEdit; + +class TextInputDialog : public QDialog +{ + Q_OBJECT +public: + explicit TextInputDialog(const QString& title, const QString &text, QWidget *parent = 0); + inline LineEdit *lineEdit() { return mLineEdit; } + void setOkButtonEnabled(bool enabled); + + LineEdit *mLineEdit; + + int exec(); + +private: + QDialogButtonBox *mButtonBox; + + +}; + +#endif // TEXTINPUTDIALOG_HPP From d065b56948954a2809b22e78d6515a8725cb827c Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Tue, 30 Oct 2012 04:21:31 +0100 Subject: [PATCH 006/107] Fixed default profile adding and made switching profiles more efficient --- apps/launcher/datafilespage.cpp | 4 +++- apps/launcher/maindialog.cpp | 21 ++------------------- apps/launcher/maindialog.hpp | 1 - 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 01b879842..696b37819 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -251,7 +251,7 @@ void DataFilesPage::setupConfig() } // Add a default profile - if (mProfilesComboBox->count() == 0) { + if (mProfilesComboBox->findText(QString("Default")) == -1) { mProfilesComboBox->addItem(QString("Default")); } @@ -359,6 +359,8 @@ bool DataFilesPage::setupDataFiles() ("fs-strict", boost::program_options::value()->implicit_value(true)->default_value(false)) ("encoding", boost::program_options::value()->default_value("win1252")); + //boost::program_options::notify(variables); + mCfgMgr.readConfiguration(variables, desc); // Put the paths in a boost::filesystem vector to use with Files::Collections diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index 3ce418ddf..674ccdf67 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -141,11 +141,11 @@ void MainDialog::createPages() connect(mPlayPage->mProfilesComboBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(profileChanged(int))); + mDataFilesPage->mProfilesComboBox, SLOT(setCurrentIndex(int))); connect(mDataFilesPage->mProfilesComboBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(profileChanged(int))); + mPlayPage->mProfilesComboBox, SLOT(setCurrentIndex(int))); } @@ -196,23 +196,6 @@ bool MainDialog::setup() return true; } -void MainDialog::profileChanged(int index) -{ - // Just to be sure, should always have a selection - if (!mIconWidget->selectionModel()->hasSelection()) { - return; - } - - QString currentPage = mIconWidget->currentItem()->data(Qt::DisplayRole).toString(); - if (currentPage == QLatin1String("Play")) { - mDataFilesPage->mProfilesComboBox->setCurrentIndex(index); - } - - if (currentPage == QLatin1String("Data Files")) { - mPlayPage->mProfilesComboBox->setCurrentIndex(index); - } -} - void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) { if (!current) diff --git a/apps/launcher/maindialog.hpp b/apps/launcher/maindialog.hpp index 683cd58c2..bf98011cc 100644 --- a/apps/launcher/maindialog.hpp +++ b/apps/launcher/maindialog.hpp @@ -27,7 +27,6 @@ public: public slots: void changePage(QListWidgetItem *current, QListWidgetItem *previous); void play(); - void profileChanged(int index); bool setup(); private: From ef11a32fee482b630def1e7282d3c170c9832080 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Tue, 30 Oct 2012 05:03:58 +0100 Subject: [PATCH 007/107] Fixed a bug where a non-existant openmw.cfg would crash the launcher --- apps/launcher/datafilespage.cpp | 87 +++++++++++++++++++-------------- apps/launcher/datafilespage.hpp | 1 + 2 files changed, 51 insertions(+), 37 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 696b37819..50502f6e2 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -347,6 +347,47 @@ void DataFilesPage::readConfig() } +bool DataFilesPage::showDataFilesWarning() +{ + + QMessageBox msgBox; + msgBox.setWindowTitle("Error detecting Morrowind installation"); + msgBox.setIcon(QMessageBox::Warning); + msgBox.setStandardButtons(QMessageBox::Cancel); + msgBox.setText(tr("
Could not find the Data Files location

\ + The directory containing the data files was not found.

\ + Press \"Browse...\" to specify the location manually.
")); + + QAbstractButton *dirSelectButton = + msgBox.addButton(tr("B&rowse..."), QMessageBox::ActionRole); + + msgBox.exec(); + + if (msgBox.clickedButton() == dirSelectButton) { + + // Show a custom dir selection dialog which only accepts valid dirs + QString selectedDir = FileDialog::getExistingDirectory( + this, tr("Select Data Files Directory"), + QDir::currentPath(), + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + + // Add the user selected data directory + if (!selectedDir.isEmpty()) { + mDataDirs.push_back(Files::PathContainer::value_type(selectedDir.toStdString())); + mCfgMgr.processPaths(mDataDirs); + } else { + // Cancel from within the dir selection dialog + return false; + } + + } else { + // Cancel + return false; + } + + return true; +} + bool DataFilesPage::setupDataFiles() { // We use the Configuration Manager to retrieve the configuration values @@ -359,12 +400,16 @@ bool DataFilesPage::setupDataFiles() ("fs-strict", boost::program_options::value()->implicit_value(true)->default_value(false)) ("encoding", boost::program_options::value()->default_value("win1252")); - //boost::program_options::notify(variables); + boost::program_options::notify(variables); mCfgMgr.readConfiguration(variables, desc); - // Put the paths in a boost::filesystem vector to use with Files::Collections - mDataDirs = Files::PathContainer(variables["data"].as()); + if (variables["data"].empty()) { + if (!showDataFilesWarning()) + return false; + } else { + mDataDirs = Files::PathContainer(variables["data"].as()); + } std::string local = variables["data-local"].as(); if (!local.empty()) { @@ -374,43 +419,11 @@ bool DataFilesPage::setupDataFiles() mCfgMgr.processPaths(mDataDirs); mCfgMgr.processPaths(mDataLocal); + // Second chance to display the warning, the data= entries are invalid while (mDataDirs.empty()) { - QMessageBox msgBox; - msgBox.setWindowTitle("Error detecting Morrowind installation"); - msgBox.setIcon(QMessageBox::Warning); - msgBox.setStandardButtons(QMessageBox::Cancel); - msgBox.setText(tr("
Could not find the Data Files location

\ - The directory containing the data files was not found.

\ - Press \"Browse...\" to specify the location manually.
")); - - QAbstractButton *dirSelectButton = - msgBox.addButton(tr("B&rowse..."), QMessageBox::ActionRole); - - msgBox.exec(); - - if (msgBox.clickedButton() == dirSelectButton) { - - // Show a custom dir selection dialog which only accepts valid dirs - QString selectedDir = FileDialog::getExistingDirectory( - this, tr("Select Data Files Directory"), - QDir::currentPath(), - QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); - - // Add the user selected data directory - if (!selectedDir.isEmpty()) { - mDataDirs.push_back(Files::PathContainer::value_type(selectedDir.toStdString())); - mCfgMgr.processPaths(mDataDirs); - } else { - // Cancel from within the dir selection dialog - return false; - } - - } else { - // Cancel + if (!showDataFilesWarning()) return false; - } } - // Add the paths to the respective models for (Files::PathContainer::iterator it = mDataDirs.begin(); it != mDataDirs.end(); ++it) { QString path = QString::fromStdString(it->string()); diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index 8b48c1e12..13668ec30 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -30,6 +30,7 @@ public: ProfilesComboBox *mProfilesComboBox; void writeConfig(QString profile = QString()); + bool showDataFilesWarning(); bool setupDataFiles(); public slots: From 1c06a06f91b6e9ae41e9dd316663aae4eb426b98 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Tue, 30 Oct 2012 06:47:39 +0100 Subject: [PATCH 008/107] Files are now sorted by modified timestamp, fixes Bug #415 --- apps/launcher/datafilespage.cpp | 11 +++-- apps/launcher/model/datafilesmodel.cpp | 57 +++++++++++++++++--------- 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 50502f6e2..782c4fb01 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -424,6 +424,7 @@ bool DataFilesPage::setupDataFiles() if (!showDataFilesWarning()) return false; } + // Add the paths to the respective models for (Files::PathContainer::iterator it = mDataDirs.begin(); it != mDataDirs.end(); ++it) { QString path = QString::fromStdString(it->string()); @@ -440,8 +441,10 @@ bool DataFilesPage::setupDataFiles() mPluginsModel->addPlugins(path); } -// mMastersModel->sort(0); -// mPluginsModel->sort(0); + mMastersModel->sort(0); + mPluginsModel->sort(0); +// mMastersTable->sortByColumn(3, Qt::AscendingOrder); +// mPluginsTable->sortByColumn(3, Qt::AscendingOrder); readConfig(); @@ -734,8 +737,8 @@ void DataFilesPage::setCheckState(QModelIndex index) QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(index); (mPluginsModel->checkState(sourceIndex) == Qt::Checked) - ? mPluginsModel->setCheckState(index, Qt::Unchecked) - : mPluginsModel->setCheckState(index, Qt::Checked); + ? mPluginsModel->setCheckState(sourceIndex, Qt::Unchecked) + : mPluginsModel->setCheckState(sourceIndex, Qt::Checked); } if (object->objectName() == QLatin1String("MastersTable")) { diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index 0aa29a337..d4674b953 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -96,15 +96,11 @@ QVariant DataFilesModel::data(const QModelIndex &index, int role) const case Qt::TextAlignmentRole: { switch (column) { case 0: - return Qt::AlignLeft + Qt::AlignVCenter; case 1: return Qt::AlignLeft + Qt::AlignVCenter; case 2: - return Qt::AlignRight + Qt::AlignVCenter; case 3: - return Qt::AlignRight + Qt::AlignVCenter; case 4: - return Qt::AlignRight + Qt::AlignVCenter; case 5: return Qt::AlignRight + Qt::AlignVCenter; default: @@ -218,20 +214,34 @@ void DataFilesModel::sort(int column, Qt::SortOrder order) // TODO: Make this more efficient emit layoutAboutToBeChanged(); - // A reference list we can sort - QStringList all = uncheckedItems(); - //all.append(uncheckedItems()); - // Sort the list of items naturally - qSort(all.begin(), all.end(), naturalSortLessThanCI); + QMap timestamps; + + QList::ConstIterator it; + QList::ConstIterator itEnd = mFiles.constEnd(); + + // Make a list of files sorted by timestamp + int i = 0; + for (it = mFiles.constBegin(); it != itEnd; ++it) { + EsmFile *file = item(i); + ++i; + timestamps[file->modified().toString(Qt::ISODate)] = file->fileName(); + } + - for (int i = 0; i < all.size(); ++i) { - const QString currentItem = all.at(i); - QModelIndex index = indexFromItem(findItem(currentItem)); + // Now sort the actual list of files by timestamp + i = 0; + QMapIterator ti(timestamps); + while (ti.hasNext()) { + ti.next(); + i++; - // Move the actual item from the old position to the new - if (index.isValid()) + QModelIndex index = indexFromItem(findItem(ti.value())); + + if (index.isValid()) { mFiles.swap(index.row(), i); + } + } emit layoutChanged(); @@ -381,13 +391,20 @@ EsmFile* DataFilesModel::item(int row) QStringList DataFilesModel::checkedItems() { QStringList list; - QHash::ConstIterator it; - QHash::ConstIterator itEnd = mCheckStates.constEnd(); - for (it = mCheckStates.constBegin(); it != itEnd; ++it) { - if (it.value() == Qt::Checked) { - list << it.key(); - } + QList::ConstIterator it; + QList::ConstIterator itEnd = mFiles.constEnd(); + + int i = 0; + for (it = mFiles.constBegin(); it != itEnd; ++it) { + EsmFile *file = item(i); + ++i; + + QString name = file->fileName(); + + // Only add the items that are in the checked list and available + if (mCheckStates[name] == Qt::Checked && mAvailableFiles.contains(name)) + list << name; } return list; From 6e758af05c4898634a4f97dd1b2e41848800947a Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Tue, 30 Oct 2012 06:51:22 +0100 Subject: [PATCH 009/107] Launcher cfg is stored in the user location only, fixes Bug #414 --- apps/launcher/datafilespage.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 782c4fb01..32bd9acb7 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -220,16 +220,9 @@ void DataFilesPage::createActions() void DataFilesPage::setupConfig() { - QString config = QString::fromStdString((mCfgMgr.getLocalPath() / "launcher.cfg").string()); - QFile file(config); - - if (!file.exists()) { - config = QString::fromStdString((mCfgMgr.getUserPath() / "launcher.cfg").string()); - } - // Open our config file + QString config = QString::fromStdString((mCfgMgr.getUserPath() / "launcher.cfg").string()); mLauncherConfig = new QSettings(config, QSettings::IniFormat); - file.close(); // Make sure we have no groups open while (!mLauncherConfig->group().isEmpty()) { From 6920958e160149705c2c407839adba6e713d72ea Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Tue, 30 Oct 2012 10:08:24 +0100 Subject: [PATCH 010/107] Oops, forgot to add timestamps for master files --- apps/launcher/model/datafilesmodel.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index d4674b953..40dd78fce 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -281,6 +281,7 @@ void DataFilesModel::addMasters(const QString &path) continue; EsmFile *file = new EsmFile(master); + file->setDates(info.lastModified(), info.lastRead()); // Add the master to the table if (findItem(master) == 0) @@ -299,9 +300,12 @@ void DataFilesModel::addMasters(const QString &path) dir.setNameFilters(QStringList(QLatin1String("*.esm"))); foreach (const QString &path, dir.entryList()) { + QFileInfo info(dir.absoluteFilePath(path)); if (findItem(path) == 0) { EsmFile *file = new EsmFile(path); + file->setDates(info.lastModified(), info.lastRead()); + addFile(file); } From 433773e0eadb28823fff44151ba5059b1ab56c81 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Tue, 30 Oct 2012 11:10:06 +0100 Subject: [PATCH 011/107] Fixed segfault in datafilesmodel because of invalid modelindex row --- apps/launcher/model/datafilesmodel.cpp | 13 ++++++++----- apps/launcher/model/datafilesmodel.hpp | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index 40dd78fce..30453425b 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -60,10 +60,10 @@ QVariant DataFilesModel::data(const QModelIndex &index, int role) const if (!index.isValid()) return QVariant(); -// if (index.row() < 0 || index.row() >= mPlugins.size()) -// return QVariant(); + EsmFile *file = item(index.row()); - EsmFile *file = mFiles.at(index.row()); + if (!file) + return QVariant(); const int column = index.column(); @@ -146,7 +146,10 @@ Qt::ItemFlags DataFilesModel::flags(const QModelIndex &index) const if (!index.isValid()) return Qt::NoItemFlags; - EsmFile *file = mFiles.at(index.row()); + EsmFile *file = item(index.row()); + + if (!file) + return Qt::NoItemFlags; if (mAvailableFiles.contains(file->fileName())) { if (index.column() == 0) { @@ -384,7 +387,7 @@ EsmFile* DataFilesModel::findItem(const QString &name) return 0; } -EsmFile* DataFilesModel::item(int row) +EsmFile* DataFilesModel::item(int row) const { if (row >= 0 && row < mFiles.count()) return mFiles.at(row); diff --git a/apps/launcher/model/datafilesmodel.hpp b/apps/launcher/model/datafilesmodel.hpp index 8710ba88d..d45788c3c 100644 --- a/apps/launcher/model/datafilesmodel.hpp +++ b/apps/launcher/model/datafilesmodel.hpp @@ -47,7 +47,7 @@ public: QModelIndex indexFromItem(EsmFile *item) const; EsmFile* findItem(const QString &name); - EsmFile* item(int row); + EsmFile* item(int row) const; signals: void checkedItemsChanged(const QStringList checkedItems, const QStringList unCheckedItems); From 64c348c39ed6cc6fe5de0e042d7b1fb53c14cf25 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Tue, 30 Oct 2012 11:26:48 +0100 Subject: [PATCH 012/107] Added support for different encodings --- apps/launcher/datafilespage.cpp | 7 +++++++ apps/launcher/model/datafilesmodel.cpp | 10 ++++++++-- apps/launcher/model/datafilesmodel.hpp | 4 ++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 32bd9acb7..6b0539c1d 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -418,6 +418,13 @@ bool DataFilesPage::setupDataFiles() return false; } + // Set the charset for reading the esm/esp files + QString encoding = QString::fromStdString(variables["encoding"].as()); + if (!encoding.isEmpty() && encoding != QLatin1String("win1252")) { + mMastersModel->setEncoding(encoding); + mPluginsModel->setEncoding(encoding); + } + // Add the paths to the respective models for (Files::PathContainer::iterator it = mDataDirs.begin(); it != mDataDirs.end(); ++it) { QString path = QString::fromStdString(it->string()); diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index 30453425b..68f9336f2 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -13,12 +13,18 @@ DataFilesModel::DataFilesModel(QObject *parent) : QAbstractTableModel(parent) { + mEncoding = QString("win1252"); } DataFilesModel::~DataFilesModel() { } +void DataFilesModel::setEncoding(const QString &encoding) +{ + mEncoding = encoding; +} + void DataFilesModel::setCheckState(const QModelIndex &index, Qt::CheckState state) { setData(index, state, Qt::CheckStateRole); @@ -268,7 +274,7 @@ void DataFilesModel::addMasters(const QString &path) try { ESM::ESMReader fileReader; - fileReader.setEncoding(std::string("win1252")); + fileReader.setEncoding(mEncoding.toStdString()); fileReader.open(dir.absoluteFilePath(path).toStdString()); ESM::ESMReader::MasterList mlist = fileReader.getMasters(); @@ -328,7 +334,7 @@ void DataFilesModel::addPlugins(const QString &path) try { ESM::ESMReader fileReader; - fileReader.setEncoding(std::string("win1252")); + fileReader.setEncoding(mEncoding.toStdString()); fileReader.open(dir.absoluteFilePath(path).toStdString()); ESM::ESMReader::MasterList mlist = fileReader.getMasters(); diff --git a/apps/launcher/model/datafilesmodel.hpp b/apps/launcher/model/datafilesmodel.hpp index d45788c3c..29a770a86 100644 --- a/apps/launcher/model/datafilesmodel.hpp +++ b/apps/launcher/model/datafilesmodel.hpp @@ -32,6 +32,8 @@ public: inline QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const { return QAbstractTableModel::index(row, column, parent); } + void setEncoding(const QString &encoding); + void addFile(EsmFile *file); void addMasters(const QString &path); @@ -62,6 +64,8 @@ private: QHash mDependencies; QHash mCheckStates; + QString mEncoding; + }; #endif // DATAFILESMODEL_HPP From 60aea3653fcf0703a9fc8ba2625295d0b8e24fca Mon Sep 17 00:00:00 2001 From: pvdk Date: Tue, 30 Oct 2012 18:58:17 +0100 Subject: [PATCH 013/107] Modified sorting, should not crash anymore --- apps/launcher/model/datafilesmodel.cpp | 36 +++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index 68f9336f2..70b9d0ca7 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -223,36 +223,34 @@ void DataFilesModel::sort(int column, Qt::SortOrder order) // TODO: Make this more efficient emit layoutAboutToBeChanged(); + QList sortedFiles; - QMap timestamps; + QMultiMap timestamps; - QList::ConstIterator it; - QList::ConstIterator itEnd = mFiles.constEnd(); - - // Make a list of files sorted by timestamp - int i = 0; - for (it = mFiles.constBegin(); it != itEnd; ++it) { - EsmFile *file = item(i); - ++i; - timestamps[file->modified().toString(Qt::ISODate)] = file->fileName(); - } + foreach (EsmFile *file, mFiles) + timestamps.insert(file->modified().toString(Qt::ISODate), file->fileName()); - - // Now sort the actual list of files by timestamp - i = 0; QMapIterator ti(timestamps); + while (ti.hasNext()) { ti.next(); - i++; QModelIndex index = indexFromItem(findItem(ti.value())); - if (index.isValid()) { - mFiles.swap(index.row(), i); - } + if (!index.isValid()) + continue; + EsmFile *file = item(index.row()); + + if (!file) + continue; + + sortedFiles.append(file); } + mFiles.clear(); + mFiles = sortedFiles; + emit layoutChanged(); } @@ -301,6 +299,7 @@ void DataFilesModel::addMasters(const QString &path) } catch(std::runtime_error &e) { // An error occurred while reading the .esp + qWarning() << "Error reading esp: " << e.what(); continue; } } @@ -361,6 +360,7 @@ void DataFilesModel::addPlugins(const QString &path) addFile(file); } catch(std::runtime_error &e) { // An error occurred while reading the .esp + qWarning() << "Error reading esp: " << e.what(); continue; } From b0647d6c8a8f4057594f1b2e6c61f51fa1badc9f Mon Sep 17 00:00:00 2001 From: pvdk Date: Tue, 30 Oct 2012 19:05:44 +0100 Subject: [PATCH 014/107] Fix for Bug #413: resolutions no longer appear multiple times on Windows --- apps/launcher/graphicspage.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index 7685cb3c2..2c4f3430c 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -281,20 +281,18 @@ QStringList GraphicsPage::getAvailableResolutions(Ogre::RenderSystem *renderer) assert (tokens.size() >= 3); QString resolutionStr = tokens.at(0) + QString(" x ") + tokens.at(2); - // do not add duplicate resolutions - if (!result.contains(resolutionStr)) { - - QString aspect = getAspect(tokens.at(0).toInt(),tokens.at(2).toInt()); + QString aspect = getAspect(tokens.at(0).toInt(),tokens.at(2).toInt()); - if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) { - resolutionStr.append(tr("\t(Widescreen ") + aspect + ")"); + if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) { + resolutionStr.append(tr("\t(Widescreen ") + aspect + ")"); - } else if (aspect == QLatin1String("4:3")) { - resolutionStr.append(tr("\t(Standard 4:3)")); - } + } else if (aspect == QLatin1String("4:3")) { + resolutionStr.append(tr("\t(Standard 4:3)")); + } + // do not add duplicate resolutions + if (!result.contains(resolutionStr)) result << resolutionStr; - } } } From 648b53ef9352477cbedc7ae36a512f1736ff52c7 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 31 Oct 2012 10:09:27 +0100 Subject: [PATCH 015/107] removed unused launcher.cfg file --- CMakeLists.txt | 1 - apps/launcher/CMakeLists.txt | 5 ----- files/launcher.cfg | 5 ----- 3 files changed, 11 deletions(-) delete mode 100644 files/launcher.cfg diff --git a/CMakeLists.txt b/CMakeLists.txt index b10562eef..a6fdfceb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -659,7 +659,6 @@ if (NOT WIN32 AND NOT DPKG_PROGRAM AND NOT APPLE) #INSTALL(FILES "${OpenMW_BINARY_DIR}/plugins.cfg" DESTINATION "${SYSCONFDIR}" ) INSTALL(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${SYSCONFDIR}" ) INSTALL(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "${SYSCONFDIR}" ) - INSTALL(FILES "${OpenMW_BINARY_DIR}/launcher.cfg" DESTINATION "${SYSCONFDIR}" ) # Install resources INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${DATADIR}" ) diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index edc3dcf32..09beaf59d 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -101,8 +101,6 @@ endif() if (APPLE) configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss "${APP_BUNDLE_DIR}/../launcher.qss") - configure_file(${CMAKE_SOURCE_DIR}/files/launcher.cfg - "${APP_BUNDLE_DIR}/../launcher.cfg") else() configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/resources/launcher.qss") @@ -110,9 +108,6 @@ else() # Fallback in case getGlobalDataPath does not point to resources configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.qss") - - configure_file(${CMAKE_SOURCE_DIR}/files/launcher.cfg - "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.cfg") endif() if (BUILD_WITH_CODE_COVERAGE) diff --git a/files/launcher.cfg b/files/launcher.cfg deleted file mode 100644 index bc0e2b7fb..000000000 --- a/files/launcher.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[Profiles] -CurrentProfile=Default -Default\Master0=Morrowind.esm -Default\Master1=Tribunal.esm -Default\Master2=Bloodmoon.esm From 4bc4ca775cfd36b6fdd97dbaa071dc79a3c947ec Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 1 Nov 2012 15:11:13 +0100 Subject: [PATCH 016/107] Issue #432: fixed MWWorld::ContainerStore::clear --- apps/openmw/mwworld/containerstore.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 3bc06b581..5c4dd03a4 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -167,18 +167,8 @@ void MWWorld::ContainerStore::fill (const ESM::InventoryList& items, const ESMS: void MWWorld::ContainerStore::clear() { - potions.list.clear(); - appas.list.clear(); - armors.list.clear(); - books.list.clear(); - clothes.list.clear(); - ingreds.list.clear(); - lights.list.clear(); - lockpicks.list.clear(); - miscItems.list.clear(); - probes.list.clear(); - repairs.list.clear(); - weapons.list.clear(); + for (ContainerStoreIterator iter (begin()); iter!=end(); ++iter) + iter->getRefData().setCount (0); flagAsModified(); } From 37a42c7dbc1f700ee71a8abca41dea0717e7568d Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 1 Nov 2012 16:38:07 +0100 Subject: [PATCH 017/107] increased version number; updated changelog --- CMakeLists.txt | 2 +- readme.txt | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6fdfceb1..78388e20f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ include (OpenMWMacros) # Version set (OPENMW_VERSION_MAJOR 0) -set (OPENMW_VERSION_MINOR 18) +set (OPENMW_VERSION_MINOR 19) set (OPENMW_VERSION_RELEASE 0) set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") diff --git a/readme.txt b/readme.txt index 20aff18ae..9a9010994 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ OpenMW: A reimplementation of The Elder Scrolls III: Morrowind OpenMW is an attempt at recreating the engine for the popular role-playing game Morrowind by Bethesda Softworks. You need to own and install the original game for OpenMW to work. -Version: 0.18.0 +Version: 0.19.0 License: GPL (see GPL3.txt for more information) Website: http://www.openmw.org @@ -97,6 +97,32 @@ Allowed options: CHANGELOG +0.19.0 + +Bug #374: Character shakes in 3rd person mode near the origin +Bug #404: Gamma correct rendering +Bug #407: Shoes of St. Rilm do not work +Bug #408: Rugs has collision even if they are not supposed to +Bug #412: Birthsign menu sorted incorrectly +Bug #413: Resolutions presented multiple times in launcher +Bug #414: launcher.cfg file stored in wrong directory +Bug #415: Wrong esm order in openmw.cfg +Bug #418: Sound listener position updates incorrectly +Bug #423: wrong usage of "Version" entry in openmw.desktop +Bug #426: Do not use hardcoded splash images +Bug #431: Don't use markers for raycast +Bug #432: Crash after picking up items from an NPC +Feature #21/#95: Sleeping/resting +Feature #61: Alchemy Skill +Feature #68: Death +Feature #69/#86: Spell Creation +Feature #72/#84: Travel +Feature #76: Global Map, 1st Layer +Feature #120: Trainer Window +Feature #152: Skill Increase from Skill Books +Feature #160: Record Saving +Task #400: Review GMST access + 0.18.0 Bug #310: Button of the "preferences menu" are too small From 8cdd1e553968b76d893ae3731b5e2c08f72ff295 Mon Sep 17 00:00:00 2001 From: pvdk Date: Fri, 2 Nov 2012 15:06:14 +0100 Subject: [PATCH 018/107] Fixed problem with sorting of the masters in the launcher --- apps/launcher/model/datafilesmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index 70b9d0ca7..47811dcaf 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -268,8 +268,6 @@ void DataFilesModel::addMasters(const QString &path) // Read the dependencies from the plugins foreach (const QString &path, dir.entryList()) { - QFileInfo info(dir.absoluteFilePath(path)); - try { ESM::ESMReader fileReader; fileReader.setEncoding(mEncoding.toStdString()); @@ -287,6 +285,8 @@ void DataFilesModel::addMasters(const QString &path) if (master.endsWith(".esp", Qt::CaseInsensitive)) continue; + QFileInfo info(dir.absoluteFilePath(master)); + EsmFile *file = new EsmFile(master); file->setDates(info.lastModified(), info.lastRead()); From 15f972cc6256b26044ac1af4fbbf947c0e8bc037 Mon Sep 17 00:00:00 2001 From: emoose Date: Fri, 2 Nov 2012 20:33:08 +0000 Subject: [PATCH 019/107] fixes: compile: cast error; doors: key id case comparison; character creation: going from CharacterCreation to BirthDialog loses data; character creation: Class/Race/BirthDialog allowing no data; code: clean up a bit todo: going from CharacterCreation back to CreateClassDialog loses data --- apps/openmw/mwclass/door.cpp | 8 +++++- apps/openmw/mwgui/birth.cpp | 2 ++ apps/openmw/mwgui/charactercreation.cpp | 1 + apps/openmw/mwgui/class.cpp | 4 +++ apps/openmw/mwgui/race.cpp | 2 ++ apps/openmw/mwgui/stats_window.cpp | 2 +- apps/openmw/mwworld/physicssystem.cpp | 6 +---- apps/openmw/mwworld/scene.cpp | 33 +++++-------------------- 8 files changed, 24 insertions(+), 34 deletions(-) diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index b94a24ed5..4687a8230 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -81,9 +81,15 @@ namespace MWClass bool needKey = ptr.getCellRef().mLockLevel>0; bool hasKey = false; std::string keyName; + + // make key id lowercase + std::string keyId = ptr.getCellRef().mKey; + std::transform(keyId.begin(), keyId.end(), keyId.begin(), ::tolower); for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it) { - if (it->getCellRef ().mRefID == ptr.getCellRef().mKey) + std::string refId = it->getCellRef().mRefID; + std::transform(refId.begin(), refId.end(), refId.begin(), ::tolower); + if (refId == keyId) { hasKey = true; keyName = MWWorld::Class::get(*it).getName(*it); diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 284653aee..1cd542221 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -93,6 +93,8 @@ void BirthDialog::setBirthId(const std::string &birthId) void BirthDialog::onOkClicked(MyGUI::Widget* _sender) { + if(mBirthList->getIndexSelected() == MyGUI::ITEM_NONE) + return; eventDone(this); } diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index e5bcdbaf8..ad9866eca 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -232,6 +232,7 @@ void CharacterCreation::spawnDialog(const char id) mBirthSignDialog = 0; mBirthSignDialog = new BirthDialog(*mWM); mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen); + mBirthSignDialog->setBirthId(mPlayerBirthSignId); mBirthSignDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone); mBirthSignDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack); mBirthSignDialog->setVisible(true); diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 8757b62a3..4c889d42d 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -148,6 +148,8 @@ void PickClassDialog::setClassId(const std::string &classId) void PickClassDialog::onOkClicked(MyGUI::Widget* _sender) { + if(mClassList->getIndexSelected() == MyGUI::ITEM_NONE) + return; eventDone(this); } @@ -641,6 +643,8 @@ void CreateClassDialog::onDescriptionEntered(WindowBase* parWindow) void CreateClassDialog::onOkClicked(MyGUI::Widget* _sender) { + if(getName().size() <= 0) + return; eventDone(this); } diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 019a59cf4..c68c0edad 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -149,6 +149,8 @@ void RaceDialog::close() void RaceDialog::onOkClicked(MyGUI::Widget* _sender) { + if(mRaceList->getIndexSelected() == MyGUI::ITEM_NONE) + return; eventDone(this); } diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 5a670968e..665caaae1 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -67,7 +67,7 @@ StatsWindow::StatsWindow (MWBase::WindowManager& parWindowManager) for (int i = 0; i < ESM::Skill::Length; ++i) { mSkillValues.insert(std::pair >(i, MWMechanics::Stat())); - mSkillWidgetMap.insert(std::pair(i, nullptr)); + mSkillWidgetMap.insert(std::pair(i, (MyGUI::TextBox*)nullptr)); } MyGUI::WindowPtr t = static_cast(mMainWidget); diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 8fa1976ac..a2825fee9 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -345,11 +345,7 @@ namespace MWWorld bool PhysicsSystem::toggleCollisionMode() { - if(playerphysics->ps.move_type==PM_NOCLIP) - playerphysics->ps.move_type=PM_NORMAL; - - else - playerphysics->ps.move_type=PM_NOCLIP; + playerphysics->ps.move_type = (playerphysics->ps.move_type == PM_NOCLIP ? PM_NORMAL : PM_NOCLIP); for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) { if (it->first=="player") diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index f16077202..517025fb2 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -70,17 +70,9 @@ namespace MWWorld { std::cout << "Unloading cell\n"; ListHandles functor; - - - - - - + (*iter)->forEach(functor); - { - - // silence annoying g++ warning for (std::vector::const_iterator iter2 (functor.mHandles.begin()); iter2!=functor.mHandles.end(); ++iter2){ @@ -96,27 +88,20 @@ namespace MWWorld } } - mRendering.removeCell(*iter); - //mPhysics->removeObject("Unnamed_43"); + mRendering.removeCell(*iter); + //mPhysics->removeObject("Unnamed_43"); MWBase::Environment::get().getWorld()->getLocalScripts().clearCell (*iter); MWBase::Environment::get().getMechanicsManager()->dropActors (*iter); MWBase::Environment::get().getSoundManager()->stopSound (*iter); - mActiveCells.erase(*iter); - - - + mActiveCells.erase(*iter); } void Scene::loadCell (Ptr::CellStore *cell) { // register local scripts MWBase::Environment::get().getWorld()->getLocalScripts().addCell (cell); - - - - std::pair result = - mActiveCells.insert(cell); + std::pair result = mActiveCells.insert(cell); if(result.second) { @@ -138,16 +123,10 @@ namespace MWWorld mRendering.configureAmbient(*cell); mRendering.requestMap(cell); mRendering.configureAmbient(*cell); - } - } - void - Scene::playerCellChange( - MWWorld::CellStore *cell, - const ESM::Position& pos, - bool adjustPlayerPos) + void Scene::playerCellChange(MWWorld::CellStore *cell, const ESM::Position& pos, bool adjustPlayerPos) { bool hasWater = cell->cell->mData.mFlags & cell->cell->HasWater; mPhysics->setCurrentWater(hasWater, cell->cell->mWater); From 4a9821dc652cd5e50dd76ed257d06a37bdfa6332 Mon Sep 17 00:00:00 2001 From: emoose Date: Fri, 2 Nov 2012 20:43:07 +0000 Subject: [PATCH 020/107] fix kdevelop indentation... --- apps/openmw/mwclass/door.cpp | 12 ++++++------ apps/openmw/mwgui/birth.cpp | 2 +- apps/openmw/mwgui/charactercreation.cpp | 2 +- apps/openmw/mwgui/class.cpp | 2 +- apps/openmw/mwgui/race.cpp | 2 +- apps/openmw/mwworld/physicssystem.cpp | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 4687a8230..f944391e1 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -81,14 +81,14 @@ namespace MWClass bool needKey = ptr.getCellRef().mLockLevel>0; bool hasKey = false; std::string keyName; - - // make key id lowercase - std::string keyId = ptr.getCellRef().mKey; - std::transform(keyId.begin(), keyId.end(), keyId.begin(), ::tolower); + + // make key id lowercase + std::string keyId = ptr.getCellRef().mKey; + std::transform(keyId.begin(), keyId.end(), keyId.begin(), ::tolower); for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it) { - std::string refId = it->getCellRef().mRefID; - std::transform(refId.begin(), refId.end(), refId.begin(), ::tolower); + std::string refId = it->getCellRef().mRefID; + std::transform(refId.begin(), refId.end(), refId.begin(), ::tolower); if (refId == keyId) { hasKey = true; diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 1cd542221..e79eee236 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -94,7 +94,7 @@ void BirthDialog::setBirthId(const std::string &birthId) void BirthDialog::onOkClicked(MyGUI::Widget* _sender) { if(mBirthList->getIndexSelected() == MyGUI::ITEM_NONE) - return; + return; eventDone(this); } diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index ad9866eca..e4b77287c 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -232,7 +232,7 @@ void CharacterCreation::spawnDialog(const char id) mBirthSignDialog = 0; mBirthSignDialog = new BirthDialog(*mWM); mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen); - mBirthSignDialog->setBirthId(mPlayerBirthSignId); + mBirthSignDialog->setBirthId(mPlayerBirthSignId); mBirthSignDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone); mBirthSignDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack); mBirthSignDialog->setVisible(true); diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 4c889d42d..3e293a1b0 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -149,7 +149,7 @@ void PickClassDialog::setClassId(const std::string &classId) void PickClassDialog::onOkClicked(MyGUI::Widget* _sender) { if(mClassList->getIndexSelected() == MyGUI::ITEM_NONE) - return; + return; eventDone(this); } diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index c68c0edad..9abb05390 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -150,7 +150,7 @@ void RaceDialog::close() void RaceDialog::onOkClicked(MyGUI::Widget* _sender) { if(mRaceList->getIndexSelected() == MyGUI::ITEM_NONE) - return; + return; eventDone(this); } diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index a2825fee9..3be85c7f3 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -345,7 +345,7 @@ namespace MWWorld bool PhysicsSystem::toggleCollisionMode() { - playerphysics->ps.move_type = (playerphysics->ps.move_type == PM_NOCLIP ? PM_NORMAL : PM_NOCLIP); + playerphysics->ps.move_type = (playerphysics->ps.move_type == PM_NOCLIP ? PM_NORMAL : PM_NOCLIP); for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) { if (it->first=="player") From 96b56d98032b7453cc8e25b4f9d4a15f4697fc1a Mon Sep 17 00:00:00 2001 From: emoose Date: Fri, 2 Nov 2012 21:18:37 +0000 Subject: [PATCH 021/107] fixes: containers: key id case comparison --- apps/openmw/mwclass/container.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 28fa72378..07f1c26ce 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -95,9 +95,15 @@ namespace MWClass bool needKey = ptr.getCellRef().mLockLevel>0; bool hasKey = false; std::string keyName; + + // make key id lowercase + std::string keyId = ptr.getCellRef().mKey; + std::transform(keyId.begin(), keyId.end(), keyId.begin(), ::tolower); for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it) { - if (it->getCellRef ().mRefID == ptr.getCellRef().mKey) + std::string refId = it->getCellRef().mRefID; + std::transform(refId.begin(), refId.end(), refId.begin(), ::tolower); + if (refId == keyId) { hasKey = true; keyName = MWWorld::Class::get(*it).getName(*it); From 1c8e941f0d49a439273169130e08c5b3e7a33b83 Mon Sep 17 00:00:00 2001 From: emoose Date: Fri, 2 Nov 2012 21:21:32 +0000 Subject: [PATCH 022/107] fix kdevelop indentation again... --- apps/openmw/mwclass/container.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 07f1c26ce..237f451f3 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -95,14 +95,14 @@ namespace MWClass bool needKey = ptr.getCellRef().mLockLevel>0; bool hasKey = false; std::string keyName; - - // make key id lowercase - std::string keyId = ptr.getCellRef().mKey; - std::transform(keyId.begin(), keyId.end(), keyId.begin(), ::tolower); + + // make key id lowercase + std::string keyId = ptr.getCellRef().mKey; + std::transform(keyId.begin(), keyId.end(), keyId.begin(), ::tolower); for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it) { - std::string refId = it->getCellRef().mRefID; - std::transform(refId.begin(), refId.end(), refId.begin(), ::tolower); + std::string refId = it->getCellRef().mRefID; + std::transform(refId.begin(), refId.end(), refId.begin(), ::tolower); if (refId == keyId) { hasKey = true; From b70b8cc4bc32ad8867e716e61f28973d0dd50a99 Mon Sep 17 00:00:00 2001 From: emoose Date: Sat, 3 Nov 2012 06:02:33 +0000 Subject: [PATCH 023/107] Fixed: character creation: make OK button grayed out/disabled (loses the hoverover when it's re-enabled though...) --- apps/openmw/mwgui/birth.cpp | 8 ++++++++ apps/openmw/mwgui/class.cpp | 8 ++++++++ apps/openmw/mwgui/race.cpp | 7 +++++++ 3 files changed, 23 insertions(+) diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index e79eee236..56e566ffb 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -48,6 +48,7 @@ BirthDialog::BirthDialog(MWBase::WindowManager& parWindowManager) getWidget(okButton, "OKButton"); okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onOkClicked); + okButton->setTextColour(MyGUI::Colour(0.6f, 0.56f, 0.45f)); updateBirths(); updateSpells(); @@ -82,6 +83,9 @@ void BirthDialog::setBirthId(const std::string &birthId) if (boost::iequals(*mBirthList->getItemDataAt(i), birthId)) { mBirthList->setIndexSelected(i); + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); break; } } @@ -108,6 +112,10 @@ void BirthDialog::onSelectBirth(MyGUI::ListBox* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); + const std::string *birthId = mBirthList->getItemDataAt(_index); if (boost::iequals(mCurrentBirthId, *birthId)) return; diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 3e293a1b0..a798ca232 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -104,6 +104,7 @@ PickClassDialog::PickClassDialog(MWBase::WindowManager& parWindowManager) MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PickClassDialog::onOkClicked); + okButton->setTextColour(MyGUI::Colour(0.6f, 0.56f, 0.45f)); updateClasses(); updateStats(); @@ -137,6 +138,9 @@ void PickClassDialog::setClassId(const std::string &classId) if (boost::iequals(*mClassList->getItemDataAt(i), classId)) { mClassList->setIndexSelected(i); + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); break; } } @@ -163,6 +167,10 @@ void PickClassDialog::onSelectClass(MyGUI::ListBox* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); + const std::string *classId = mClassList->getItemDataAt(_index); if (boost::iequals(mCurrentClassId, *classId)) return; diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 9abb05390..b1d51db09 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -80,6 +80,7 @@ RaceDialog::RaceDialog(MWBase::WindowManager& parWindowManager) getWidget(okButton, "OKButton"); okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onOkClicked); + okButton->setTextColour(MyGUI::Colour(0.6f, 0.56f, 0.45f)); updateRaces(); updateSkills(); @@ -121,6 +122,9 @@ void RaceDialog::setRaceId(const std::string &raceId) if (boost::iequals(*mRaceList->getItemDataAt(i), raceId)) { mRaceList->setIndexSelected(i); + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); break; } } @@ -202,6 +206,9 @@ void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); const std::string *raceId = mRaceList->getItemDataAt(_index); if (boost::iequals(mCurrentRaceId, *raceId)) return; From c8cc6b6e65f04fff1b18d504c6f601dd8e66bb6e Mon Sep 17 00:00:00 2001 From: emoose Date: Sat, 3 Nov 2012 16:39:32 +0000 Subject: [PATCH 024/107] Fixed: engine: Bug #437 Stop animations when paused; tooltips: capitalize first letter (eg paper -> Paper) --- apps/openmw/engine.cpp | 3 ++- apps/openmw/mwgui/tooltips.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 617689bc6..5f1d0dd5f 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -101,7 +101,8 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) MWBase::Environment::get().getWorld()->doPhysics (movement, mEnvironment.getFrameDuration()); // update world - MWBase::Environment::get().getWorld()->update (evt.timeSinceLastFrame); + if (!MWBase::Environment::get().getWindowManager()->isGuiMode()) + MWBase::Environment::get().getWorld()->update (evt.timeSinceLastFrame); // update GUI Ogre::RenderWindow* window = mOgre->getWindow(); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 35224613c..02a4f0c39 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -364,6 +364,9 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info) if (text.size() > 0 && text[0] == '\n') text.erase(0, 1); + if(caption.size() > 0 && isalnum(caption[0])) + caption[0] = toupper(caption[0]); + const ESM::Enchantment* enchant = 0; const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); if (info.enchant != "") From cadc753216fda012917005c1d14c3d5b85b68698 Mon Sep 17 00:00:00 2001 From: emoose Date: Sat, 3 Nov 2012 19:29:55 +0000 Subject: [PATCH 025/107] Fixed: engine: Bug #437 Stop animations when paused better fix; scene: Bug #430 Teleporting and using loading doors linking within the same cell reloads the cell Bug #437 fix only pauses the RenderingManager, and still updates the mOcclusionQuery Bug #430 fix is only tested in interiors (ToddTest) --- apps/openmw/engine.cpp | 3 +- apps/openmw/mwbase/world.hpp | 2 +- apps/openmw/mwrender/renderingmanager.cpp | 8 ++- apps/openmw/mwrender/renderingmanager.hpp | 2 +- apps/openmw/mwworld/scene.cpp | 73 +++++++++++++---------- apps/openmw/mwworld/scene.hpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 4 +- apps/openmw/mwworld/worldimp.hpp | 2 +- 8 files changed, 56 insertions(+), 40 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 5f1d0dd5f..a75a60223 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -101,8 +101,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) MWBase::Environment::get().getWorld()->doPhysics (movement, mEnvironment.getFrameDuration()); // update world - if (!MWBase::Environment::get().getWindowManager()->isGuiMode()) - MWBase::Environment::get().getWorld()->update (evt.timeSinceLastFrame); + MWBase::Environment::get().getWorld()->update (evt.timeSinceLastFrame, MWBase::Environment::get().getWindowManager()->isGuiMode()); // update GUI Ogre::RenderWindow* window = mOgre->getWindow(); diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index d29e23c18..6710fc68b 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -265,7 +265,7 @@ namespace MWBase ///< Skip the animation for the given MW-reference for one frame. Calls to this function for /// references that are currently not in the rendered scene should be ignored. - virtual void update (float duration) = 0; + virtual void update (float duration, bool paused) = 0; virtual bool placeObject(const MWWorld::Ptr& object, float cursorX, float cursorY) = 0; ///< place an object into the gameworld at the specified cursor position diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 5b5fdce68..3bf6573bd 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -313,7 +313,7 @@ RenderingManager::moveObjectToCell( child->setPosition(pos); } -void RenderingManager::update (float duration) +void RenderingManager::update (float duration, bool paused) { Ogre::Vector3 orig, dest; mPlayer->setCameraDistance(); @@ -328,12 +328,16 @@ void RenderingManager::update (float duration) mPlayer->setCameraDistance(test.second * orig.distance(dest), false, false); } } + mOcclusionQuery->update(duration); + + if(paused) + return; + mPlayer->update(duration); mActors.update (duration); mObjects.update (duration); - mOcclusionQuery->update(duration); mSkyManager->update(duration); diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 359809b71..86346d1d6 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -125,7 +125,7 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList /// \param store Cell the object was in previously (\a ptr has already been updated to the new cell). void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::CellStore *store); - void update (float duration); + void update (float duration, bool paused); void setAmbientColour(const Ogre::ColourValue& colour); void setSunColour(const Ogre::ColourValue& colour); diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 517025fb2..3982b9b12 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -62,8 +62,8 @@ namespace namespace MWWorld { - void Scene::update (float duration){ - mRendering.update (duration); + void Scene::update (float duration, bool paused){ + mRendering.update (duration, paused); } void Scene::unloadCell (CellStoreCollection::iterator iter) @@ -306,45 +306,58 @@ namespace MWWorld { std::cout << "Changing to interior\n"; - CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName); - // remove active - CellStoreCollection::iterator active = mActiveCells.begin(); - - // count number of cells to unload - int numUnload = 0; - while (active!=mActiveCells.end()) + bool loadcell = (mCurrentCell == NULL); + if(!loadcell) { - ++active; - ++numUnload; + std::string nam = std::string(cellName); + std::string curnam = std::string(mCurrentCell->cell->mName); + std::transform(nam.begin(), nam.end(), nam.begin(), ::tolower); + std::transform(curnam.begin(), curnam.end(), curnam.begin(), ::tolower); + loadcell = nam != curnam; } - - // unload - int current = 0; - active = mActiveCells.begin(); - while (active!=mActiveCells.end()) + if(loadcell) { - MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Unloading cells", 0, current, numUnload); + CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName); - unloadCell (active++); - ++current; - } + // remove active + CellStoreCollection::iterator active = mActiveCells.begin(); - // Load cell. - std::cout << "cellName:" << cellName << std::endl; + // count number of cells to unload + int numUnload = 0; + while (active!=mActiveCells.end()) + { + ++active; + ++numUnload; + } + // unload + int current = 0; + active = mActiveCells.begin(); + while (active!=mActiveCells.end()) + { + MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Unloading cells", 0, current, numUnload); - MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 0, 0, 1); - loadCell (cell); + unloadCell (active++); + ++current; + } + + // Load cell. + std::cout << "cellName:" << cellName << std::endl; - // adjust player - mCurrentCell = cell; - playerCellChange (cell, position); - // adjust fog - mRendering.switchToInterior(); - mRendering.configureFog(*cell); + MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 0, 0, 1); + loadCell (cell); + mCurrentCell = cell; + + // adjust fog + mRendering.switchToInterior(); + mRendering.configureFog(*cell); + } + // adjust player + playerCellChange (mCurrentCell, position); + // Sky system MWBase::Environment::get().getWorld()->adjustSky(); diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index 59e13dafe..ad6ad1559 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -88,7 +88,7 @@ namespace MWWorld void insertCell (Ptr::CellStore &cell); - void update (float duration); + void update (float duration, bool paused); void addObjectToScene (const Ptr& ptr); ///< Add an object that already exists in the world model to the scene. diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index c7f0de245..7b938be5e 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -858,11 +858,11 @@ namespace MWWorld mRendering->skipAnimation (ptr); } - void World::update (float duration) + void World::update (float duration, bool paused) { /// \todo split this function up into subfunctions - mWorldScene->update (duration); + mWorldScene->update (duration, paused); float pitch, yaw; Ogre::Vector3 eyepos; diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 527a608a6..ad541048b 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -280,7 +280,7 @@ namespace MWWorld ///< Skip the animation for the given MW-reference for one frame. Calls to this function for /// references that are currently not in the rendered scene should be ignored. - virtual void update (float duration); + virtual void update (float duration, bool paused); virtual bool placeObject (const Ptr& object, float cursorX, float cursorY); ///< place an object into the gameworld at the specified cursor position From ba2fc2d6f8369047d21bfdae4e0dc363c334978e Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 4 Nov 2012 11:37:47 +0100 Subject: [PATCH 026/107] better fix for chargen button colors --- apps/openmw/mwgui/birth.cpp | 6 +++--- apps/openmw/mwgui/class.cpp | 6 +++--- apps/openmw/mwgui/race.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 56e566ffb..e7862c4e7 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -48,7 +48,7 @@ BirthDialog::BirthDialog(MWBase::WindowManager& parWindowManager) getWidget(okButton, "OKButton"); okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onOkClicked); - okButton->setTextColour(MyGUI::Colour(0.6f, 0.56f, 0.45f)); + okButton->setEnabled(false); updateBirths(); updateSpells(); @@ -85,7 +85,7 @@ void BirthDialog::setBirthId(const std::string &birthId) mBirthList->setIndexSelected(i); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); + okButton->setEnabled(true); break; } } @@ -114,7 +114,7 @@ void BirthDialog::onSelectBirth(MyGUI::ListBox* _sender, size_t _index) MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); + okButton->setEnabled(true); const std::string *birthId = mBirthList->getItemDataAt(_index); if (boost::iequals(mCurrentBirthId, *birthId)) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index a798ca232..f020010ec 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -104,7 +104,7 @@ PickClassDialog::PickClassDialog(MWBase::WindowManager& parWindowManager) MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PickClassDialog::onOkClicked); - okButton->setTextColour(MyGUI::Colour(0.6f, 0.56f, 0.45f)); + okButton->setEnabled(false); updateClasses(); updateStats(); @@ -140,7 +140,7 @@ void PickClassDialog::setClassId(const std::string &classId) mClassList->setIndexSelected(i); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); + okButton->setEnabled(true); break; } } @@ -169,7 +169,7 @@ void PickClassDialog::onSelectClass(MyGUI::ListBox* _sender, size_t _index) MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); + okButton->setEnabled(true); const std::string *classId = mClassList->getItemDataAt(_index); if (boost::iequals(mCurrentClassId, *classId)) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index b1d51db09..d681bc69d 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -80,7 +80,7 @@ RaceDialog::RaceDialog(MWBase::WindowManager& parWindowManager) getWidget(okButton, "OKButton"); okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onOkClicked); - okButton->setTextColour(MyGUI::Colour(0.6f, 0.56f, 0.45f)); + okButton->setEnabled(false); updateRaces(); updateSkills(); @@ -124,7 +124,7 @@ void RaceDialog::setRaceId(const std::string &raceId) mRaceList->setIndexSelected(i); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); + okButton->setEnabled(true); break; } } @@ -208,7 +208,7 @@ void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index) MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); + okButton->setEnabled(true); const std::string *raceId = mRaceList->getItemDataAt(_index); if (boost::iequals(mCurrentRaceId, *raceId)) return; From b7aa7e4cef5f27feeb76487b26404df42ad97989 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 4 Nov 2012 11:57:51 +0100 Subject: [PATCH 027/107] pause all animations --- apps/openmw/mwrender/renderingmanager.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 3bf6573bd..bcc3a311d 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -331,8 +332,13 @@ void RenderingManager::update (float duration, bool paused) mOcclusionQuery->update(duration); if(paused) + { + Ogre::ControllerManager::getSingleton().setTimeFactor(0.f); return; - + } + Ogre::ControllerManager::getSingleton().setTimeFactor( + MWBase::Environment::get().getWorld()->getTimeScaleFactor()/30.f); + mPlayer->update(duration); mActors.update (duration); From 6f7a621b6f4a6913950055411e1f747c8dd042f5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 4 Nov 2012 23:15:20 +0100 Subject: [PATCH 028/107] disabled enchanting unfinished enchantment GUI for now --- apps/openmw/mwgui/dialogue.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 23d2197b7..96b85b4c4 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -192,8 +192,8 @@ void DialogueWindow::setKeywords(std::list keyWords) if (mServices & Service_CreateSpells) mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpellmakingMenuTitle")->getString()); - if (mServices & Service_Enchant) - mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sEnchanting")->getString()); +// if (mServices & Service_Enchant) +// mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sEnchanting")->getString()); if (mServices & Service_Training) mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sServiceTrainingTitle")->getString()); From accf8b2f71bb52d3ddfe7384dfef4148166ed57c Mon Sep 17 00:00:00 2001 From: emoose Date: Sun, 4 Nov 2012 23:22:30 +0000 Subject: [PATCH 029/107] Updated Bug #430 fix so it only moves the player now --- apps/openmw/mwworld/scene.cpp | 82 ++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 3982b9b12..37cc23f5f 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -304,60 +304,62 @@ namespace MWWorld void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position) { - std::cout << "Changing to interior\n"; - - + CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName); bool loadcell = (mCurrentCell == NULL); + if(!loadcell) + loadcell = *mCurrentCell != *cell; + if(!loadcell) { - std::string nam = std::string(cellName); - std::string curnam = std::string(mCurrentCell->cell->mName); - std::transform(nam.begin(), nam.end(), nam.begin(), ::tolower); - std::transform(curnam.begin(), curnam.end(), curnam.begin(), ::tolower); - loadcell = nam != curnam; + MWBase::World *world = MWBase::Environment::get().getWorld(); + world->moveObject(world->getPlayer().getPlayer(), position.pos[0], position.pos[1], position.pos[2]); + + float x = Ogre::Radian(position.rot[0]).valueDegrees(); + float y = Ogre::Radian(position.rot[1]).valueDegrees(); + float z = Ogre::Radian(position.rot[2]).valueDegrees(); + world->rotateObject(world->getPlayer().getPlayer(), x, y, z); + return; } - if(loadcell) - { - CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName); - - // remove active - CellStoreCollection::iterator active = mActiveCells.begin(); + + std::cout << "Changing to interior\n"; - // count number of cells to unload - int numUnload = 0; - while (active!=mActiveCells.end()) - { - ++active; - ++numUnload; - } + // remove active + CellStoreCollection::iterator active = mActiveCells.begin(); - // unload - int current = 0; - active = mActiveCells.begin(); - while (active!=mActiveCells.end()) - { - MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Unloading cells", 0, current, numUnload); + // count number of cells to unload + int numUnload = 0; + while (active!=mActiveCells.end()) + { + ++active; + ++numUnload; + } - unloadCell (active++); - ++current; - } + // unload + int current = 0; + active = mActiveCells.begin(); + while (active!=mActiveCells.end()) + { + MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Unloading cells", 0, current, numUnload); - // Load cell. - std::cout << "cellName:" << cellName << std::endl; + unloadCell (active++); + ++current; + } + // Load cell. + std::cout << "cellName: " << cell->cell->mName << std::endl; - MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 0, 0, 1); - loadCell (cell); + MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 0, 0, 1); + loadCell (cell); - mCurrentCell = cell; + mCurrentCell = cell; - // adjust fog - mRendering.switchToInterior(); - mRendering.configureFog(*cell); - } + // adjust fog + mRendering.switchToInterior(); + mRendering.configureFog(*mCurrentCell); + // adjust player playerCellChange (mCurrentCell, position); - + // Sky system MWBase::Environment::get().getWorld()->adjustSky(); From f72f898bd9ea8c49c143ae650bcc94b0e45c5ef4 Mon Sep 17 00:00:00 2001 From: gugus Date: Mon, 5 Nov 2012 11:07:43 +0100 Subject: [PATCH 030/107] implement barterOffer. It's used for travel only. I've started to implement disposition, but it's very basic for now. --- apps/openmw/mwbase/mechanicsmanager.hpp | 6 +++ apps/openmw/mwclass/npc.cpp | 2 + apps/openmw/mwgui/travelwindow.cpp | 2 + .../mwmechanics/mechanicsmanagerimp.cpp | 52 +++++++++++++++++++ .../mwmechanics/mechanicsmanagerimp.hpp | 6 +++ apps/openmw/mwmechanics/npcstats.cpp | 12 ++++- apps/openmw/mwmechanics/npcstats.hpp | 5 ++ 7 files changed, 84 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwbase/mechanicsmanager.hpp b/apps/openmw/mwbase/mechanicsmanager.hpp index 39d7e6e1a..bf8d8dee4 100644 --- a/apps/openmw/mwbase/mechanicsmanager.hpp +++ b/apps/openmw/mwbase/mechanicsmanager.hpp @@ -74,6 +74,12 @@ namespace MWBase virtual void restoreDynamicStats() = 0; ///< If the player is sleeping, this should be called every hour. + + virtual int barterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying) = 0; + ///< This is used by every service to determine the price of objects given the trading skills of the player and NPC. + + virtual int disposition(const MWWorld::Ptr& ptr) = 0; + ///< Calculate the diposition of an NPC toward the player. }; } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 03b5e56aa..4bf6c24b7 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -94,6 +94,8 @@ namespace MWClass data->mCreatureStats.getFatigue().set (ref->base->mNpdt52.mFatigue); data->mCreatureStats.setLevel(ref->base->mNpdt52.mLevel); + + data->mNpcStats.setDisposition(ref->base->mNpdt52.mDisposition); } else { diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index c19639aa6..7195ea725 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -66,6 +66,8 @@ namespace MWGui price = d/MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelMult")->getFloat(); } + price = MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr,price,true); + MyGUI::Button* toAdd = mDestinationsView->createWidget((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SandTextButton", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default); mCurrentY += sLineHeight; /// \todo price adjustment depending on merchantile skill diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 364e65321..9a3ff610b 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -324,4 +324,56 @@ namespace MWMechanics buildPlayer(); mUpdatePlayer = true; } + + float min(float a,float b) + { + if(ab) return a; + else return b; + } + + int MechanicsManager::disposition(const MWWorld::Ptr& ptr) + { + MWMechanics::NpcStats npcSkill = MWWorld::Class::get(ptr).getNpcStats(ptr); + return npcSkill.getDisposition(); + } + + int MechanicsManager::barterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying) + { + MWMechanics::NpcStats sellerSkill = MWWorld::Class::get(ptr).getNpcStats(ptr); + MWMechanics::CreatureStats sellerStats = MWWorld::Class::get(ptr).getCreatureStats(ptr); + + MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + MWMechanics::NpcStats playerSkill = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr); + MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr); + + int clampedDisposition = min(disposition(ptr),100); + float a = min(playerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100); + float b = min(0.1 * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10); + float c = min(0.2 * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10); + float d = min(sellerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100); + float e = min(0.1 * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10); + float f = min(0.2 * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10); + + float pcTerm = (clampedDisposition - 50 + a + b + c) * playerStats.getFatigueTerm(); + float npcTerm = (d + e + f) * sellerStats.getFatigueTerm(); + float buyTerm = 0.01 * (100 - 0.5 * (pcTerm - npcTerm)); + float sellTerm = 0.01 * (50 - 0.5 * (npcTerm - pcTerm)); + + float x; + if(buying) x = buyTerm; + else x = min(buyTerm, sellTerm); + std::cout << "x" << x; + int offerPrice; + if (x < 1) offerPrice = int(x * basePrice); + if (x >= 1) offerPrice = basePrice + int((x - 1) * basePrice); + offerPrice = max(1, offerPrice); + std::cout <<"barteroffer"<< offerPrice << " " << basePrice << "\n"; + return offerPrice; + } } diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp index 3a41e8fa6..cdf418a81 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp @@ -76,6 +76,12 @@ namespace MWMechanics virtual void restoreDynamicStats(); ///< If the player is sleeping, this should be called every hour. + + virtual int barterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying); + ///< This is used by every service to determine the price of objects given the trading skills of the player and NPC. + + virtual int disposition(const MWWorld::Ptr& ptr); + ///< Calculate the diposition of an NPC toward the player. }; } diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index bbd42c147..f09b7b0bd 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -19,7 +19,7 @@ MWMechanics::NpcStats::NpcStats() : mMovementFlags (0), mDrawState (DrawState_Nothing) -, mLevelProgress(0) +, mLevelProgress(0), mDisposition(0) { mSkillIncreases.resize (ESM::Attribute::Length); for (int i=0; i mFactionRank; DrawState_ mDrawState; + unsigned int mDisposition; unsigned int mMovementFlags; Stat mSkill[27]; @@ -60,6 +61,10 @@ namespace MWMechanics void setDrawState (DrawState_ state); + unsigned int getDisposition() const; + + void setDisposition(unsigned int disposition); + bool getMovementFlag (Flag flag) const; void setMovementFlag (Flag flag, bool state); From 3c2ce25f5f3e889a54654cca360f10c5cfed8337 Mon Sep 17 00:00:00 2001 From: greye Date: Mon, 5 Nov 2012 16:07:59 +0400 Subject: [PATCH 031/107] m prefix for mwworld/cellstore.hpp --- apps/openmw/mwclass/activator.cpp | 16 +-- apps/openmw/mwclass/apparatus.cpp | 30 ++--- apps/openmw/mwclass/armor.cpp | 46 +++---- apps/openmw/mwclass/book.cpp | 32 ++--- apps/openmw/mwclass/clothing.cpp | 42 +++--- apps/openmw/mwclass/container.cpp | 26 ++-- apps/openmw/mwclass/creature.cpp | 58 ++++----- apps/openmw/mwclass/door.cpp | 42 +++--- apps/openmw/mwclass/ingredient.cpp | 38 +++--- apps/openmw/mwclass/light.cpp | 50 ++++---- apps/openmw/mwclass/lockpick.cpp | 32 ++--- apps/openmw/mwclass/misc.cpp | 42 +++--- apps/openmw/mwclass/npc.cpp | 74 +++++------ apps/openmw/mwclass/potion.cpp | 32 ++--- apps/openmw/mwclass/probe.cpp | 32 ++--- apps/openmw/mwclass/repair.cpp | 32 ++--- apps/openmw/mwclass/static.cpp | 6 +- apps/openmw/mwclass/weapon.cpp | 72 +++++------ apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 26 ++-- apps/openmw/mwgui/bookwindow.cpp | 2 +- apps/openmw/mwgui/container.cpp | 2 +- apps/openmw/mwgui/scrollwindow.cpp | 2 +- apps/openmw/mwgui/tradewindow.cpp | 24 ++-- apps/openmw/mwgui/trainingwindow.cpp | 2 +- apps/openmw/mwgui/travelwindow.cpp | 12 +- apps/openmw/mwgui/windowmanagerimp.cpp | 22 ++-- apps/openmw/mwmechanics/alchemy.cpp | 18 +-- .../mwmechanics/mechanicsmanagerimp.cpp | 2 +- apps/openmw/mwrender/creatureanimation.cpp | 6 +- apps/openmw/mwrender/debugging.cpp | 16 +-- apps/openmw/mwrender/localmap.cpp | 10 +- apps/openmw/mwrender/npcanimation.cpp | 42 +++--- apps/openmw/mwrender/objects.cpp | 12 +- apps/openmw/mwrender/renderingmanager.cpp | 26 ++-- apps/openmw/mwrender/terrain.cpp | 8 +- apps/openmw/mwscript/cellextensions.cpp | 9 +- apps/openmw/mwscript/statsextensions.cpp | 2 +- apps/openmw/mwsound/soundmanagerimp.cpp | 8 +- apps/openmw/mwworld/actionread.cpp | 12 +- apps/openmw/mwworld/cells.cpp | 62 ++++----- apps/openmw/mwworld/cellstore.cpp | 61 ++++----- apps/openmw/mwworld/cellstore.hpp | 120 +++++++++--------- apps/openmw/mwworld/containerstore.cpp | 116 ++++++++--------- apps/openmw/mwworld/localscripts.cpp | 42 +++--- apps/openmw/mwworld/manualref.hpp | 4 +- apps/openmw/mwworld/player.cpp | 4 +- apps/openmw/mwworld/ptr.hpp | 2 +- apps/openmw/mwworld/scene.cpp | 116 +++++++++-------- apps/openmw/mwworld/weather.cpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 77 ++++++----- 50 files changed, 792 insertions(+), 779 deletions(-) diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index e815549d8..a7f73278e 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -39,9 +39,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -53,7 +53,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mName; + return ref->mBase->mName; } std::string Activator::getScript (const MWWorld::Ptr& ptr) const @@ -61,7 +61,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } void Activator::registerSelf() @@ -76,7 +76,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Activator::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -85,11 +85,11 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); std::string text; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); info.text = text; return info; @@ -101,6 +101,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.activators.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mActivators.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index a05c24e86..9b2d0795c 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -42,9 +42,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -56,7 +56,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr Apparatus::activate (const MWWorld::Ptr& ptr, @@ -75,7 +75,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } int Apparatus::getValue (const MWWorld::Ptr& ptr) const @@ -83,7 +83,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Apparatus::registerSelf() @@ -108,7 +108,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Apparatus::hasToolTip (const MWWorld::Ptr& ptr) const @@ -116,7 +116,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Apparatus::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -125,17 +125,17 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; - text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->mData.mQuality); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -154,6 +154,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.appas.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mAppas.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 7254c37f8..36a1b25c4 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -45,9 +45,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -59,7 +59,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr Armor::activate (const MWWorld::Ptr& ptr, @@ -82,7 +82,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mData.mHealth; + return ref->mBase->mData.mHealth; } std::string Armor::getScript (const MWWorld::Ptr& ptr) const @@ -90,7 +90,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } std::pair, bool> Armor::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -118,7 +118,7 @@ namespace MWClass }; for (int i=0; ibase->mData.mType) + if (sMapping[i][0]==ref->mBase->mData.mType) { slots.push_back (int (sMapping[i][1])); break; @@ -134,7 +134,7 @@ namespace MWClass std::string typeGmst; - switch (ref->base->mData.mType) + switch (ref->mBase->mData.mType) { case ESM::Armor::Helmet: typeGmst = "iHelmWeight"; break; case ESM::Armor::Cuirass: typeGmst = "iCuirassWeight"; break; @@ -155,11 +155,11 @@ namespace MWClass float iWeight = MWBase::Environment::get().getWorld()->getStore().gameSettings.find (typeGmst)->getInt(); if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fLightMaxMod")->getFloat()>= - ref->base->mData.mWeight) + ref->mBase->mData.mWeight) return ESM::Skill::LightArmor; if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMedMaxMod")->getFloat()>= - ref->base->mData.mWeight) + ref->mBase->mData.mWeight) return ESM::Skill::MediumArmor; return ESM::Skill::HeavyArmor; @@ -170,7 +170,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Armor::registerSelf() @@ -207,7 +207,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Armor::hasToolTip (const MWWorld::Ptr& ptr) const @@ -215,7 +215,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Armor::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -224,8 +224,8 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; @@ -239,20 +239,20 @@ namespace MWClass else typeText = "#{sHeavy}"; - text += "\n#{sArmorRating}: " + MWGui::ToolTips::toString(ref->base->mData.mArmor); + text += "\n#{sArmorRating}: " + MWGui::ToolTips::toString(ref->mBase->mData.mArmor); /// \todo store the current armor health somewhere - text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->base->mData.mHealth); + text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->mBase->mData.mHealth); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight) + " (" + typeText + ")"; - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight) + " (" + typeText + ")"; + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } - info.enchant = ref->base->mEnchant; + info.enchant = ref->mBase->mEnchant; info.text = text; @@ -264,7 +264,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mEnchant; + return ref->mBase->mEnchant; } boost::shared_ptr Armor::use (const MWWorld::Ptr& ptr) const @@ -282,6 +282,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.armors.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mArmors.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 4a2ad1dcb..150865b5d 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -41,9 +41,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -55,7 +55,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr Book::activate (const MWWorld::Ptr& ptr, @@ -70,7 +70,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } int Book::getValue (const MWWorld::Ptr& ptr) const @@ -78,7 +78,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Book::registerSelf() @@ -103,7 +103,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Book::hasToolTip (const MWWorld::Ptr& ptr) const @@ -111,7 +111,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Book::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -120,20 +120,20 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } - info.enchant = ref->base->mEnchant; + info.enchant = ref->mBase->mEnchant; info.text = text; @@ -145,7 +145,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mEnchant; + return ref->mBase->mEnchant; } boost::shared_ptr Book::use (const MWWorld::Ptr& ptr) const @@ -159,6 +159,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.books.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mBooks.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index d746350df..ab0db50fa 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -43,9 +43,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -57,7 +57,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr Clothing::activate (const MWWorld::Ptr& ptr, @@ -75,7 +75,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } std::pair, bool> Clothing::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -85,7 +85,7 @@ namespace MWClass std::vector slots; - if (ref->base->mData.mType==ESM::Clothing::Ring) + if (ref->mBase->mData.mType==ESM::Clothing::Ring) { slots.push_back (int (MWWorld::InventoryStore::Slot_LeftRing)); slots.push_back (int (MWWorld::InventoryStore::Slot_RightRing)); @@ -108,7 +108,7 @@ namespace MWClass }; for (int i=0; ibase->mData.mType) + if (sMapping[i][0]==ref->mBase->mData.mType) { slots.push_back (int (sMapping[i][1])); break; @@ -123,7 +123,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (ref->base->mData.mType==ESM::Clothing::Shoes) + if (ref->mBase->mData.mType==ESM::Clothing::Shoes) return ESM::Skill::Unarmored; return -1; @@ -134,7 +134,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Clothing::registerSelf() @@ -149,7 +149,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (ref->base->mData.mType == 8) + if (ref->mBase->mData.mType == 8) { return std::string("Item Ring Up"); } @@ -161,7 +161,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (ref->base->mData.mType == 8) + if (ref->mBase->mData.mType == 8) { return std::string("Item Ring Down"); } @@ -173,7 +173,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Clothing::hasToolTip (const MWWorld::Ptr& ptr) const @@ -181,7 +181,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Clothing::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -190,20 +190,20 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } - info.enchant = ref->base->mEnchant; + info.enchant = ref->mBase->mEnchant; info.text = text; @@ -215,7 +215,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mEnchant; + return ref->mBase->mEnchant; } boost::shared_ptr Clothing::use (const MWWorld::Ptr& ptr) const @@ -233,6 +233,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.clothes.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mClothes.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 237f451f3..e4350324c 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -74,9 +74,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -149,7 +149,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mName; + return ref->mBase->mName; } MWWorld::ContainerStore& Container::getContainerStore (const MWWorld::Ptr& ptr) @@ -165,7 +165,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } void Container::registerSelf() @@ -180,7 +180,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Container::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -189,17 +189,17 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName; + info.caption = ref->mBase->mName; std::string text; - if (ref->ref.mLockLevel > 0) - text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->ref.mLockLevel); - if (ref->ref.mTrap != "") + if (ref->mRef.mLockLevel > 0) + text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->mRef.mLockLevel); + if (ref->mRef.mTrap != "") text += "\n#{sTrapped}"; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -212,7 +212,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mWeight; + return ref->mBase->mWeight; } float Container::getEncumbrance (const MWWorld::Ptr& ptr) const @@ -239,6 +239,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.containers.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mContainers.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index e4ff3c95b..361dbc308 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -48,28 +48,28 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); // creature stats - data->mCreatureStats.getAttribute(0).set (ref->base->mData.mStrength); - data->mCreatureStats.getAttribute(1).set (ref->base->mData.mIntelligence); - data->mCreatureStats.getAttribute(2).set (ref->base->mData.mWillpower); - data->mCreatureStats.getAttribute(3).set (ref->base->mData.mAgility); - data->mCreatureStats.getAttribute(4).set (ref->base->mData.mSpeed); - data->mCreatureStats.getAttribute(5).set (ref->base->mData.mEndurance); - data->mCreatureStats.getAttribute(6).set (ref->base->mData.mPersonality); - data->mCreatureStats.getAttribute(7).set (ref->base->mData.mLuck); - data->mCreatureStats.setHealth (ref->base->mData.mHealth); - data->mCreatureStats.setMagicka (ref->base->mData.mMana); - data->mCreatureStats.setFatigue (ref->base->mData.mFatigue); - - data->mCreatureStats.setLevel(ref->base->mData.mLevel); - - data->mCreatureStats.setHello(ref->base->mAiData.mHello); - data->mCreatureStats.setFight(ref->base->mAiData.mFight); - data->mCreatureStats.setFlee(ref->base->mAiData.mFlee); - data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm); + data->mCreatureStats.getAttribute(0).set (ref->mBase->mData.mStrength); + data->mCreatureStats.getAttribute(1).set (ref->mBase->mData.mIntelligence); + data->mCreatureStats.getAttribute(2).set (ref->mBase->mData.mWillpower); + data->mCreatureStats.getAttribute(3).set (ref->mBase->mData.mAgility); + data->mCreatureStats.getAttribute(4).set (ref->mBase->mData.mSpeed); + data->mCreatureStats.getAttribute(5).set (ref->mBase->mData.mEndurance); + data->mCreatureStats.getAttribute(6).set (ref->mBase->mData.mPersonality); + data->mCreatureStats.getAttribute(7).set (ref->mBase->mData.mLuck); + data->mCreatureStats.setHealth (ref->mBase->mData.mHealth); + data->mCreatureStats.setMagicka (ref->mBase->mData.mMana); + data->mCreatureStats.setFatigue (ref->mBase->mData.mFatigue); + + data->mCreatureStats.setLevel(ref->mBase->mData.mLevel); + + data->mCreatureStats.setHello(ref->mBase->mAiData.mHello); + data->mCreatureStats.setFight(ref->mBase->mAiData.mFight); + data->mCreatureStats.setFlee(ref->mBase->mAiData.mFlee); + data->mCreatureStats.setAlarm(ref->mBase->mAiData.mAlarm); // spells - for (std::vector::const_iterator iter (ref->base->mSpells.mList.begin()); - iter!=ref->base->mSpells.mList.end(); ++iter) + for (std::vector::const_iterator iter (ref->mBase->mSpells.mList.begin()); + iter!=ref->mBase->mSpells.mList.end(); ++iter) data->mCreatureStats.getSpells().add (*iter); // store @@ -82,7 +82,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mId; + return ref->mBase->mId; } void Creature::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -104,9 +104,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert (ref->base != NULL); + assert (ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -118,7 +118,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mName; + return ref->mBase->mName; } MWMechanics::CreatureStats& Creature::getCreatureStats (const MWWorld::Ptr& ptr) const @@ -150,7 +150,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } bool Creature::isEssential (const MWWorld::Ptr& ptr) const @@ -158,7 +158,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mFlags & ESM::Creature::Essential; + return ref->mBase->mFlags & ESM::Creature::Essential; } void Creature::registerSelf() @@ -181,11 +181,11 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName; + info.caption = ref->mBase->mName; std::string text; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); info.text = text; return info; @@ -219,6 +219,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.creatures.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mCreatures.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index f944391e1..3c4b94cd9 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -44,9 +44,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -58,10 +58,10 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (ref->ref.mTeleport && !ref->ref.mDestCell.empty()) // TODO doors that lead to exteriors - return ref->ref.mDestCell; + if (ref->mRef.mTeleport && !ref->mRef.mDestCell.empty()) // TODO doors that lead to exteriors + return ref->mRef.mDestCell; - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr Door::activate (const MWWorld::Ptr& ptr, @@ -70,8 +70,8 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - const std::string &openSound = ref->base->mOpenSound; - //const std::string &closeSound = ref->base->closeSound; + const std::string &openSound = ref->mBase->mOpenSound; + //const std::string &closeSound = ref->mBase->closeSound; const std::string lockedSound = "LockedDoor"; const std::string trapActivationSound = "Disarm Trap Fail"; @@ -119,13 +119,13 @@ namespace MWClass return action; } - if (ref->ref.mTeleport) + if (ref->mRef.mTeleport) { // teleport door /// \todo remove this if clause once ActionTeleport can also support other actors if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()==actor) { - boost::shared_ptr action(new MWWorld::ActionTeleport (ref->ref.mDestCell, ref->ref.mDoorDest)); + boost::shared_ptr action(new MWWorld::ActionTeleport (ref->mRef.mDestCell, ref->mRef.mDoorDest)); action->setSound(openSound); @@ -177,7 +177,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } void Door::registerSelf() @@ -192,7 +192,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Door::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -201,25 +201,25 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName; + info.caption = ref->mBase->mName; std::string text; const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); - if (ref->ref.mTeleport) + if (ref->mRef.mTeleport) { std::string dest; - if (ref->ref.mDestCell != "") + if (ref->mRef.mDestCell != "") { // door leads to an interior, use interior name as tooltip - dest = ref->ref.mDestCell; + dest = ref->mRef.mDestCell; } else { // door leads to exterior, use cell name (if any), otherwise translated region name int x,y; - MWBase::Environment::get().getWorld()->positionToIndex (ref->ref.mDoorDest.pos[0], ref->ref.mDoorDest.pos[1], x, y); + MWBase::Environment::get().getWorld()->positionToIndex (ref->mRef.mDoorDest.pos[0], ref->mRef.mDoorDest.pos[1], x, y); const ESM::Cell* cell = store.cells.findExt(x,y); if (cell->mName != "") dest = cell->mName; @@ -233,13 +233,13 @@ namespace MWClass text += "\n"+dest; } - if (ref->ref.mLockLevel > 0) - text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->ref.mLockLevel); - if (ref->ref.mTrap != "") + if (ref->mRef.mLockLevel > 0) + text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->mRef.mLockLevel); + if (ref->mRef.mTrap != "") text += "\n#{sTrapped}"; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); info.text = text; @@ -252,6 +252,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.doors.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mDoors.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 45779287f..7f87befe6 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -25,7 +25,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mId; + return ref->mBase->mId; } void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -50,9 +50,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -64,7 +64,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr Ingredient::activate (const MWWorld::Ptr& ptr, @@ -82,7 +82,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } int Ingredient::getValue (const MWWorld::Ptr& ptr) const @@ -90,7 +90,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } @@ -125,7 +125,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Ingredient::hasToolTip (const MWWorld::Ptr& ptr) const @@ -133,7 +133,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Ingredient::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -142,28 +142,28 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } MWGui::Widgets::SpellEffectList list; for (int i=0; i<4; ++i) { - if (ref->base->mData.mEffectID[i] < 0) + if (ref->mBase->mData.mEffectID[i] < 0) continue; MWGui::Widgets::SpellEffectParams params; - params.mEffectID = ref->base->mData.mEffectID[i]; - params.mAttribute = ref->base->mData.mAttributes[i]; - params.mSkill = ref->base->mData.mSkills[i]; + params.mEffectID = ref->mBase->mData.mEffectID[i]; + params.mAttribute = ref->mBase->mData.mAttributes[i]; + params.mSkill = ref->mBase->mData.mSkills[i]; list.push_back(params); } info.effects = list; @@ -179,6 +179,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.ingreds.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mIngreds.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 6ae9ed661..c2ac7c342 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -27,9 +27,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert (ref->base != NULL); + assert (ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; MWRender::Objects& objects = renderingInterface.getObjects(); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); @@ -37,11 +37,11 @@ namespace MWClass if (!model.empty()) objects.insertMesh(ptr, "meshes\\" + model); - const int color = ref->base->mData.mColor; + const int color = ref->mBase->mData.mColor; const float r = ((color >> 0) & 0xFF) / 255.0f; const float g = ((color >> 8) & 0xFF) / 255.0f; const float b = ((color >> 16) & 0xFF) / 255.0f; - const float radius = float (ref->base->mData.mRadius); + const float radius = float (ref->mBase->mData.mRadius); objects.insertLight (ptr, r, g, b, radius); } @@ -49,15 +49,15 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert (ref->base != NULL); + assert (ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if(!model.empty()) { physics.insertObjectPhysics(ptr, "meshes\\" + model); } - if (!ref->base->mSound.empty()) { - MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->base->mSound, 1.0, 1.0, MWBase::SoundManager::Play_Loop); + if (!ref->mBase->mSound.empty()) { + MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->mBase->mSound, 1.0, 1.0, MWBase::SoundManager::Play_Loop); } } @@ -65,9 +65,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert (ref->base != NULL); + assert (ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -79,10 +79,10 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (ref->base->mModel.empty()) + if (ref->mBase->mModel.empty()) return ""; - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr Light::activate (const MWWorld::Ptr& ptr, @@ -91,7 +91,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (!(ref->base->mData.mFlags & ESM::Light::Carry)) + if (!(ref->mBase->mData.mFlags & ESM::Light::Carry)) return boost::shared_ptr (new MWWorld::NullAction); boost::shared_ptr action(new MWWorld::ActionTake (ptr)); @@ -106,7 +106,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } std::pair, bool> Light::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -116,7 +116,7 @@ namespace MWClass std::vector slots; - if (ref->base->mData.mFlags & ESM::Light::Carry) + if (ref->mBase->mData.mFlags & ESM::Light::Carry) slots.push_back (int (MWWorld::InventoryStore::Slot_CarriedLeft)); return std::make_pair (slots, false); @@ -127,7 +127,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Light::registerSelf() @@ -153,7 +153,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Light::hasToolTip (const MWWorld::Ptr& ptr) const @@ -161,7 +161,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Light::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -170,17 +170,17 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -203,6 +203,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.lights.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mLights.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index a0ec65c98..62cf0e872 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -43,9 +43,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -57,7 +57,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr Lockpick::activate (const MWWorld::Ptr& ptr, @@ -75,7 +75,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } std::pair, bool> Lockpick::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -92,7 +92,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Lockpick::registerSelf() @@ -117,7 +117,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Lockpick::hasToolTip (const MWWorld::Ptr& ptr) const @@ -125,7 +125,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Lockpick::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -134,21 +134,21 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; /// \todo store remaining uses somewhere - text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->mData.mUses); - text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->mData.mQuality); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->mBase->mData.mUses); + text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -171,6 +171,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.lockpicks.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mLockpicks.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index edcfc7daa..133ba1adc 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -46,9 +46,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -60,7 +60,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr Miscellaneous::activate (const MWWorld::Ptr& ptr, @@ -78,7 +78,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } int Miscellaneous::getValue (const MWWorld::Ptr& ptr) const @@ -86,7 +86,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Miscellaneous::registerSelf() @@ -101,7 +101,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (ref->base->mName == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) + if (ref->mBase->mName == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) { return std::string("Item Gold Up"); } @@ -113,7 +113,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (ref->base->mName == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) + if (ref->mBase->mName == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) { return std::string("Item Gold Down"); } @@ -125,7 +125,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Miscellaneous::hasToolTip (const MWWorld::Ptr& ptr) const @@ -133,7 +133,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Miscellaneous::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -147,9 +147,9 @@ namespace MWClass int count = ptr.getRefData().getCount(); - bool isGold = (ref->base->mName == store.gameSettings.find("sGold")->getString()); + bool isGold = (ref->mBase->mName == store.gameSettings.find("sGold")->getString()); if (isGold && count == 1) - count = ref->base->mData.mValue; + count = ref->mBase->mData.mValue; std::string countString; if (!isGold) @@ -157,12 +157,12 @@ namespace MWClass else // gold displays its count also if it's 1. countString = " (" + boost::lexical_cast(count) + ")"; - info.caption = ref->base->mName + countString; - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + countString; + info.icon = ref->mBase->mIcon; - if (ref->ref.mSoul != "") + if (ref->mRef.mSoul != "") { - const ESM::Creature *creature = store.creatures.search(ref->ref.mSoul); + const ESM::Creature *creature = store.creatures.search(ref->mRef.mSoul); info.caption += " (" + creature->mName + ")"; } @@ -170,13 +170,13 @@ namespace MWClass if (!isGold) { - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); } if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -210,11 +210,11 @@ namespace MWClass MWWorld::ManualRef newRef(store, base); MWWorld::LiveCellRef *ref = newRef.getPtr().get(); - newPtr = MWWorld::Ptr(&cell.miscItems.insert(*ref), &cell); + newPtr = MWWorld::Ptr(&cell.mMiscItems.insert(*ref), &cell); } else { MWWorld::LiveCellRef *ref = ptr.get(); - newPtr = MWWorld::Ptr(&cell.miscItems.insert(*ref), &cell); + newPtr = MWWorld::Ptr(&cell.mMiscItems.insert(*ref), &cell); } return newPtr; } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 2e21f8f63..9da02895b 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -62,39 +62,39 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); // NPC stats - if (!ref->base->mFaction.empty()) + if (!ref->mBase->mFaction.empty()) { - std::string faction = ref->base->mFaction; + std::string faction = ref->mBase->mFaction; boost::algorithm::to_lower(faction); - if(ref->base->mNpdt52.mGold != -10) + if(ref->mBase->mNpdt52.mGold != -10) { - data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->mNpdt52.mRank; + data->mNpcStats.getFactionRanks()[faction] = (int)ref->mBase->mNpdt52.mRank; } else { - data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->mNpdt12.mRank; + data->mNpcStats.getFactionRanks()[faction] = (int)ref->mBase->mNpdt12.mRank; } } // creature stats - if(ref->base->mNpdt52.mGold != -10) + if(ref->mBase->mNpdt52.mGold != -10) { for (int i=0; i<27; ++i) - data->mNpcStats.getSkill (i).setBase (ref->base->mNpdt52.mSkills[i]); - - data->mCreatureStats.getAttribute(0).set (ref->base->mNpdt52.mStrength); - data->mCreatureStats.getAttribute(1).set (ref->base->mNpdt52.mIntelligence); - data->mCreatureStats.getAttribute(2).set (ref->base->mNpdt52.mWillpower); - data->mCreatureStats.getAttribute(3).set (ref->base->mNpdt52.mAgility); - data->mCreatureStats.getAttribute(4).set (ref->base->mNpdt52.mSpeed); - data->mCreatureStats.getAttribute(5).set (ref->base->mNpdt52.mEndurance); - data->mCreatureStats.getAttribute(6).set (ref->base->mNpdt52.mPersonality); - data->mCreatureStats.getAttribute(7).set (ref->base->mNpdt52.mLuck); - data->mCreatureStats.setHealth (ref->base->mNpdt52.mHealth); - data->mCreatureStats.setMagicka (ref->base->mNpdt52.mMana); - data->mCreatureStats.setFatigue (ref->base->mNpdt52.mFatigue); - - data->mCreatureStats.setLevel(ref->base->mNpdt52.mLevel); + data->mNpcStats.getSkill (i).setBase (ref->mBase->mNpdt52.mSkills[i]); + + data->mCreatureStats.getAttribute(0).set (ref->mBase->mNpdt52.mStrength); + data->mCreatureStats.getAttribute(1).set (ref->mBase->mNpdt52.mIntelligence); + data->mCreatureStats.getAttribute(2).set (ref->mBase->mNpdt52.mWillpower); + data->mCreatureStats.getAttribute(3).set (ref->mBase->mNpdt52.mAgility); + data->mCreatureStats.getAttribute(4).set (ref->mBase->mNpdt52.mSpeed); + data->mCreatureStats.getAttribute(5).set (ref->mBase->mNpdt52.mEndurance); + data->mCreatureStats.getAttribute(6).set (ref->mBase->mNpdt52.mPersonality); + data->mCreatureStats.getAttribute(7).set (ref->mBase->mNpdt52.mLuck); + data->mCreatureStats.setHealth (ref->mBase->mNpdt52.mHealth); + data->mCreatureStats.setMagicka (ref->mBase->mNpdt52.mMana); + data->mCreatureStats.setFatigue (ref->mBase->mNpdt52.mFatigue); + + data->mCreatureStats.setLevel(ref->mBase->mNpdt52.mLevel); } else { @@ -108,14 +108,14 @@ namespace MWClass data->mCreatureStats.setLevel (1); } - data->mCreatureStats.setHello(ref->base->mAiData.mHello); - data->mCreatureStats.setFight(ref->base->mAiData.mFight); - data->mCreatureStats.setFlee(ref->base->mAiData.mFlee); - data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm); + data->mCreatureStats.setHello(ref->mBase->mAiData.mHello); + data->mCreatureStats.setFight(ref->mBase->mAiData.mFight); + data->mCreatureStats.setFlee(ref->mBase->mAiData.mFlee); + data->mCreatureStats.setAlarm(ref->mBase->mAiData.mAlarm); // spells - for (std::vector::const_iterator iter (ref->base->mSpells.mList.begin()); - iter!=ref->base->mSpells.mList.end(); ++iter) + for (std::vector::const_iterator iter (ref->mBase->mSpells.mList.begin()); + iter!=ref->mBase->mSpells.mList.end(); ++iter) data->mCreatureStats.getSpells().add (*iter); // store @@ -128,7 +128,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mId; + return ref->mBase->mId; } void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -146,9 +146,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - std::string headID = ref->base->mHead; + std::string headID = ref->mBase->mHead; int end = headID.find_last_of("head_") - 4; std::string bodyRaceID = headID.substr(0, end); @@ -170,7 +170,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mName; + return ref->mBase->mName; } MWMechanics::CreatureStats& Npc::getCreatureStats (const MWWorld::Ptr& ptr) const @@ -217,7 +217,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } void Npc::setForceStance (const MWWorld::Ptr& ptr, Stance stance, bool force) const @@ -325,7 +325,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mFlags & ESM::NPC::Essential; + return ref->mBase->mFlags & ESM::NPC::Essential; } void Npc::registerSelf() @@ -347,11 +347,11 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName; + info.caption = ref->mBase->mName; std::string text; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); info.text = text; return info; @@ -396,7 +396,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( - ref->base->mClass); + ref->mBase->mClass); stats.useSkill (skill, *class_, usageType); } @@ -413,6 +413,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.npcs.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mNpcs.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index f641cc719..883ba3c6a 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -43,9 +43,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -57,7 +57,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr Potion::activate (const MWWorld::Ptr& ptr, @@ -76,7 +76,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } int Potion::getValue (const MWWorld::Ptr& ptr) const @@ -84,7 +84,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Potion::registerSelf() @@ -109,7 +109,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Potion::hasToolTip (const MWWorld::Ptr& ptr) const @@ -117,7 +117,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Potion::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -126,20 +126,20 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); - info.effects = MWGui::Widgets::MWEffectList::effectListFromESM(&ref->base->mEffects); + info.effects = MWGui::Widgets::MWEffectList::effectListFromESM(&ref->mBase->mEffects); info.isPotion = true; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -157,7 +157,7 @@ namespace MWClass MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); boost::shared_ptr action ( - new MWWorld::ActionApply (actor, ref->base->mId)); + new MWWorld::ActionApply (actor, ref->mBase->mId)); action->setSound ("Drink"); @@ -170,6 +170,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.potions.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mPotions.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 39472f2ec..5a6e37385 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -43,9 +43,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -57,7 +57,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr Probe::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const @@ -74,7 +74,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } std::pair, bool> Probe::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -91,7 +91,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Probe::registerSelf() @@ -116,7 +116,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Probe::hasToolTip (const MWWorld::Ptr& ptr) const @@ -124,7 +124,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Probe::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -133,21 +133,21 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; /// \todo store remaining uses somewhere - text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->mData.mUses); - text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->mData.mQuality); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->mBase->mData.mUses); + text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -170,6 +170,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.probes.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mProbes.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index 7ccb34913..25ec7c7ba 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -41,9 +41,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -55,7 +55,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr Repair::activate (const MWWorld::Ptr& ptr, @@ -73,7 +73,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } int Repair::getValue (const MWWorld::Ptr& ptr) const @@ -81,7 +81,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Repair::registerSelf() @@ -106,7 +106,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Repair::hasToolTip (const MWWorld::Ptr& ptr) const @@ -114,7 +114,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Repair::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -123,21 +123,21 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; /// \todo store remaining uses somewhere - text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->mData.mUses); - text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->mData.mQuality); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->mBase->mData.mUses); + text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -151,6 +151,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.repairs.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mRepairs.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/static.cpp b/apps/openmw/mwclass/static.cpp index 07ab54256..1ef215bee 100644 --- a/apps/openmw/mwclass/static.cpp +++ b/apps/openmw/mwclass/static.cpp @@ -33,9 +33,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -60,6 +60,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.statics.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mStatics.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index fee0dfdf1..c59fb0ac6 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -43,9 +43,9 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -57,7 +57,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr Weapon::activate (const MWWorld::Ptr& ptr, @@ -80,7 +80,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mData.mHealth; + return ref->mBase->mData.mHealth; } std::string Weapon::getScript (const MWWorld::Ptr& ptr) const @@ -88,7 +88,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mScript; + return ref->mBase->mScript; } std::pair, bool> Weapon::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -99,12 +99,12 @@ namespace MWClass std::vector slots; bool stack = false; - if (ref->base->mData.mType==ESM::Weapon::Arrow || ref->base->mData.mType==ESM::Weapon::Bolt) + if (ref->mBase->mData.mType==ESM::Weapon::Arrow || ref->mBase->mData.mType==ESM::Weapon::Bolt) { slots.push_back (int (MWWorld::InventoryStore::Slot_Ammunition)); stack = true; } - else if (ref->base->mData.mType==ESM::Weapon::MarksmanThrown) + else if (ref->mBase->mData.mType==ESM::Weapon::MarksmanThrown) { slots.push_back (int (MWWorld::InventoryStore::Slot_CarriedRight)); stack = true; @@ -139,7 +139,7 @@ namespace MWClass }; for (int i=0; ibase->mData.mType) + if (sMapping[i][0]==ref->mBase->mData.mType) return sMapping[i][1]; return -1; @@ -150,7 +150,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Weapon::registerSelf() @@ -165,7 +165,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - int type = ref->base->mData.mType; + int type = ref->mBase->mData.mType; // Ammo if (type == 12 || type == 13) { @@ -211,7 +211,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - int type = ref->base->mData.mType; + int type = ref->mBase->mData.mType; // Ammo if (type == 12 || type == 13) { @@ -257,7 +257,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Weapon::hasToolTip (const MWWorld::Ptr& ptr) const @@ -265,7 +265,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Weapon::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -274,15 +274,15 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); std::string text; // weapon type & damage. arrows / bolts don't have his info. - if (ref->base->mData.mType < 12) + if (ref->mBase->mData.mType < 12) { text += "\n#{sType} "; @@ -300,49 +300,49 @@ namespace MWClass mapping[ESM::Weapon::MarksmanCrossbow] = std::make_pair("sSkillMarksman", ""); mapping[ESM::Weapon::MarksmanThrown] = std::make_pair("sSkillMarksman", ""); - std::string type = mapping[ref->base->mData.mType].first; - std::string oneOrTwoHanded = mapping[ref->base->mData.mType].second; + std::string type = mapping[ref->mBase->mData.mType].first; + std::string oneOrTwoHanded = mapping[ref->mBase->mData.mType].second; text += store.gameSettings.find(type)->getString() + ((oneOrTwoHanded != "") ? ", " + store.gameSettings.find(oneOrTwoHanded)->getString() : ""); // weapon damage - if (ref->base->mData.mType >= 9) + if (ref->mBase->mData.mType >= 9) { // marksman text += "\n#{sAttack}: " - + MWGui::ToolTips::toString(static_cast(ref->base->mData.mChop[0])) - + " - " + MWGui::ToolTips::toString(static_cast(ref->base->mData.mChop[1])); + + MWGui::ToolTips::toString(static_cast(ref->mBase->mData.mChop[0])) + + " - " + MWGui::ToolTips::toString(static_cast(ref->mBase->mData.mChop[1])); } else { // Chop text += "\n#{sChop}: " - + MWGui::ToolTips::toString(static_cast(ref->base->mData.mChop[0])) - + " - " + MWGui::ToolTips::toString(static_cast(ref->base->mData.mChop[1])); + + MWGui::ToolTips::toString(static_cast(ref->mBase->mData.mChop[0])) + + " - " + MWGui::ToolTips::toString(static_cast(ref->mBase->mData.mChop[1])); // Slash text += "\n#{sSlash}: " - + MWGui::ToolTips::toString(static_cast(ref->base->mData.mSlash[0])) - + " - " + MWGui::ToolTips::toString(static_cast(ref->base->mData.mSlash[1])); + + MWGui::ToolTips::toString(static_cast(ref->mBase->mData.mSlash[0])) + + " - " + MWGui::ToolTips::toString(static_cast(ref->mBase->mData.mSlash[1])); // Thrust text += "\n#{sThrust}: " - + MWGui::ToolTips::toString(static_cast(ref->base->mData.mThrust[0])) - + " - " + MWGui::ToolTips::toString(static_cast(ref->base->mData.mThrust[1])); + + MWGui::ToolTips::toString(static_cast(ref->mBase->mData.mThrust[0])) + + " - " + MWGui::ToolTips::toString(static_cast(ref->mBase->mData.mThrust[1])); } } /// \todo store the current weapon health somewhere - if (ref->base->mData.mType < 11) // thrown weapons and arrows/bolts don't have health, only quantity - text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->base->mData.mHealth); + if (ref->mBase->mData.mType < 11) // thrown weapons and arrows/bolts don't have health, only quantity + text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->mBase->mData.mHealth); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); - info.enchant = ref->base->mEnchant; + info.enchant = ref->mBase->mEnchant; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -355,7 +355,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->mEnchant; + return ref->mBase->mEnchant; } boost::shared_ptr Weapon::use (const MWWorld::Ptr& ptr) const @@ -373,6 +373,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(&cell.weapons.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mWeapons.insert(*ref), &cell); } } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 62f7df679..899257239 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -391,7 +391,7 @@ namespace MWDialogue if(select.mType==ESM::VT_Int) { MWWorld::LiveCellRef* npc = actor.get(); - int isFaction = int(toLower(npc->base->mFaction) == toLower(name)); + int isFaction = int(toLower(npc->mBase->mFaction) == toLower(name)); if(selectCompare(comp,!isFaction,select.mI)) return false; } @@ -408,7 +408,7 @@ namespace MWDialogue if(select.mType==ESM::VT_Int) { MWWorld::LiveCellRef* npc = actor.get(); - int isClass = int(toLower(npc->base->mClass) == toLower(name)); + int isClass = int(toLower(npc->mBase->mClass) == toLower(name)); if(selectCompare(comp,!isClass,select.mI)) return false; } @@ -425,7 +425,7 @@ namespace MWDialogue if(select.mType==ESM::VT_Int) { MWWorld::LiveCellRef* npc = actor.get(); - int isRace = int(toLower(npc->base->mRace) == toLower(name)); + int isRace = int(toLower(npc->mBase->mRace) == toLower(name)); if(selectCompare(comp,!isRace,select.mI)) return false; } @@ -438,7 +438,7 @@ namespace MWDialogue case 'B'://not Cell if(select.mType==ESM::VT_Int) { - int isCell = int(toLower(actor.getCell()->cell->mName) == toLower(name)); + int isCell = int(toLower(actor.getCell()->mCell->mName) == toLower(name)); if(selectCompare(comp,!isCell,select.mI)) return false; } @@ -496,7 +496,7 @@ namespace MWDialogue if (!cellRef) return false; - if (toLower (info.mRace)!=toLower (cellRef->base->mRace)) + if (toLower (info.mRace)!=toLower (cellRef->mBase->mRace)) return false; } @@ -511,7 +511,7 @@ namespace MWDialogue if (!cellRef) return false; - if (toLower (info.mClass)!=toLower (cellRef->base->mClass)) + if (toLower (info.mClass)!=toLower (cellRef->mBase->mClass)) return false; } @@ -557,7 +557,7 @@ namespace MWDialogue if (!isCreature) { MWWorld::LiveCellRef* npc = actor.get(); - if(npc->base->mFlags & npc->base->Female) + if(npc->mBase->mFlags & npc->mBase->Female) { if(static_cast (info.mData.mGender)==0) return false; } @@ -569,7 +569,7 @@ namespace MWDialogue // check cell if (!info.mCell.empty()) - if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->mName != info.mCell) + if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->mCell->mName != info.mCell) return false; // TODO check DATAstruct @@ -770,14 +770,14 @@ namespace MWDialogue if (mActor.getTypeName() == typeid(ESM::NPC).name()) { MWWorld::LiveCellRef* ref = mActor.get(); - if (ref->base->mHasAI) - services = ref->base->mAiData.mServices; + if (ref->mBase->mHasAI) + services = ref->mBase->mAiData.mServices; } else if (mActor.getTypeName() == typeid(ESM::Creature).name()) { MWWorld::LiveCellRef* ref = mActor.get(); - if (ref->base->mHasAI) - services = ref->base->mAiData.mServices; + if (ref->mBase->mHasAI) + services = ref->mBase->mAiData.mServices; } int windowServices = 0; @@ -795,7 +795,7 @@ namespace MWDialogue || services & ESM::NPC::Misc) windowServices |= MWGui::DialogueWindow::Service_Trade; - if( !mActor.get()->base->mTransport.empty()) + if( !mActor.get()->mBase->mTransport.empty()) windowServices |= MWGui::DialogueWindow::Service_Travel; if (services & ESM::NPC::Spells) diff --git a/apps/openmw/mwgui/bookwindow.cpp b/apps/openmw/mwgui/bookwindow.cpp index cb142db60..bc3cd7b40 100644 --- a/apps/openmw/mwgui/bookwindow.cpp +++ b/apps/openmw/mwgui/bookwindow.cpp @@ -60,7 +60,7 @@ void BookWindow::open (MWWorld::Ptr book) MWWorld::LiveCellRef *ref = mBook.get(); BookTextParser parser; - std::vector results = parser.split(ref->base->mText, mLeftPage->getSize().width, mLeftPage->getSize().height); + std::vector results = parser.split(ref->mBase->mText, mLeftPage->getSize().width, mLeftPage->getSize().height); int i=0; for (std::vector::iterator it=results.begin(); diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 5c202941f..ff94e5151 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -274,7 +274,7 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender) if (mPtr.getTypeName() == typeid(ESM::Container).name()) { MWWorld::LiveCellRef* ref = mPtr.get(); - if (ref->base->mFlags & ESM::Container::Organic) + if (ref->mBase->mFlags & ESM::Container::Organic) { // user notification MWBase::Environment::get().getWindowManager()-> diff --git a/apps/openmw/mwgui/scrollwindow.cpp b/apps/openmw/mwgui/scrollwindow.cpp index c839e9b73..8317025e0 100644 --- a/apps/openmw/mwgui/scrollwindow.cpp +++ b/apps/openmw/mwgui/scrollwindow.cpp @@ -36,7 +36,7 @@ void ScrollWindow::open (MWWorld::Ptr scroll) MWWorld::LiveCellRef *ref = mScroll.get(); BookTextParser parser; - MyGUI::IntSize size = parser.parse(ref->base->mText, mTextView, 390); + MyGUI::IntSize size = parser.parse(ref->mBase->mText, mTextView, 390); if (size.height > mTextView->getSize().height) mTextView->setCanvasSize(MyGUI::IntSize(410, size.height)); diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 64710c279..0e755f49d 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -156,15 +156,15 @@ namespace MWGui if (mPtr.getTypeName() == typeid(ESM::NPC).name()) { MWWorld::LiveCellRef* ref = mPtr.get(); - if (ref->base->mNpdt52.mGold == -10) - merchantgold = ref->base->mNpdt12.mGold; + if (ref->mBase->mNpdt52.mGold == -10) + merchantgold = ref->mBase->mNpdt12.mGold; else - merchantgold = ref->base->mNpdt52.mGold; + merchantgold = ref->mBase->mNpdt52.mGold; } else // ESM::Creature { MWWorld::LiveCellRef* ref = mPtr.get(); - merchantgold = ref->base->mData.mGold; + merchantgold = ref->mBase->mData.mGold; } if (mCurrentBalance > 0 && merchantgold < mCurrentBalance) { @@ -217,15 +217,15 @@ namespace MWGui if (mPtr.getTypeName() == typeid(ESM::NPC).name()) { MWWorld::LiveCellRef* ref = mPtr.get(); - if (ref->base->mNpdt52.mGold == -10) - merchantgold = ref->base->mNpdt12.mGold; + if (ref->mBase->mNpdt52.mGold == -10) + merchantgold = ref->mBase->mNpdt12.mGold; else - merchantgold = ref->base->mNpdt52.mGold; + merchantgold = ref->mBase->mNpdt52.mGold; } else // ESM::Creature { MWWorld::LiveCellRef* ref = mPtr.get(); - merchantgold = ref->base->mData.mGold; + merchantgold = ref->mBase->mData.mGold; } mMerchantGold->setCaptionWithReplacing("#{sSellerGold} " + boost::lexical_cast(merchantgold)); @@ -261,14 +261,14 @@ namespace MWGui if (mPtr.getTypeName() == typeid(ESM::NPC).name()) { MWWorld::LiveCellRef* ref = mPtr.get(); - if (ref->base->mHasAI) - services = ref->base->mAiData.mServices; + if (ref->mBase->mHasAI) + services = ref->mBase->mAiData.mServices; } else if (mPtr.getTypeName() == typeid(ESM::Creature).name()) { MWWorld::LiveCellRef* ref = mPtr.get(); - if (ref->base->mHasAI) - services = ref->base->mAiData.mServices; + if (ref->mBase->mHasAI) + services = ref->mBase->mAiData.mServices; } /// \todo what about potions, there doesn't seem to be a flag for them?? diff --git a/apps/openmw/mwgui/trainingwindow.cpp b/apps/openmw/mwgui/trainingwindow.cpp index af61b3487..226167ba3 100644 --- a/apps/openmw/mwgui/trainingwindow.cpp +++ b/apps/openmw/mwgui/trainingwindow.cpp @@ -129,7 +129,7 @@ namespace MWGui // increase skill MWWorld::LiveCellRef *playerRef = player.get(); const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( - playerRef->base->mClass); + playerRef->mBase->mClass); pcStats.increaseSkill (skillId, *class_, true); // remove gold diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index c19639aa6..6431aa76e 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -104,15 +104,15 @@ namespace MWGui MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - for(unsigned int i = 0;i()->base->mTransport.size();i++) + for(unsigned int i = 0;i()->mBase->mTransport.size();i++) { - std::string cellname = mPtr.get()->base->mTransport[i].mCellName; + std::string cellname = mPtr.get()->mBase->mTransport[i].mCellName; bool interior = true; int x,y; - MWBase::Environment::get().getWorld()->positionToIndex(mPtr.get()->base->mTransport[i].mPos.pos[0], - mPtr.get()->base->mTransport[i].mPos.pos[1],x,y); - if(cellname == "") {cellname = MWBase::Environment::get().getWorld()->getExterior(x,y)->cell->mName; interior= false;} - addDestination(cellname,mPtr.get()->base->mTransport[i].mPos,interior); + MWBase::Environment::get().getWorld()->positionToIndex(mPtr.get()->mBase->mTransport[i].mPos.pos[0], + mPtr.get()->mBase->mTransport[i].mPos.pos[1],x,y); + if(cellname == "") {cellname = MWBase::Environment::get().getWorld()->getExterior(x,y)->mCell->mName; interior= false;} + addDestination(cellname,mPtr.get()->mBase->mTransport[i].mPos,interior); } updateLabels(); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 0350581e4..d5d88960a 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -604,17 +604,17 @@ void WindowManager::onFrame (float frameDuration) void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) { - if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) + if (cell->mCell->isExterior()) { std::string name; - if (cell->cell->mName != "") + if (cell->mCell->mName != "") { - name = cell->cell->mName; - mMap->addVisitedLocation (name, cell->cell->getGridX (), cell->cell->getGridY ()); + name = cell->mCell->mName; + mMap->addVisitedLocation (name, cell->mCell->getGridX (), cell->mCell->getGridY ()); } else { - const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().regions.search(cell->cell->mRegion); + const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().regions.search(cell->mCell->mRegion); if (region) name = region->mName; else @@ -626,15 +626,15 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) mMap->setCellPrefix("Cell"); mHud->setCellPrefix("Cell"); - mMap->setActiveCell( cell->cell->mData.mX, cell->cell->mData.mY ); - mHud->setActiveCell( cell->cell->mData.mX, cell->cell->mData.mY ); + mMap->setActiveCell( cell->mCell->getGridX(), cell->mCell->getGridY() ); + mHud->setActiveCell( cell->mCell->getGridX(), cell->mCell->getGridY() ); } else { - mMap->setCellName( cell->cell->mName ); - mHud->setCellName( cell->cell->mName ); - mMap->setCellPrefix( cell->cell->mName ); - mHud->setCellPrefix( cell->cell->mName ); + mMap->setCellName( cell->mCell->mName ); + mHud->setCellName( cell->mCell->mName ); + mMap->setCellPrefix( cell->mCell->mName ); + mHud->setCellPrefix( cell->mCell->mName ); } } diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 962350472..d3564382f 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -38,11 +38,11 @@ std::set MWMechanics::Alchemy::listEffects() const const MWWorld::LiveCellRef *ingredient = iter->get(); for (int i=0; i<4; ++i) - if (ingredient->base->mData.mEffectID[i]!=-1) + if (ingredient->mBase->mData.mEffectID[i]!=-1) { EffectKey key ( - ingredient->base->mData.mEffectID[i], ingredient->base->mData.mSkills[i]!=-1 ? - ingredient->base->mData.mSkills[i] : ingredient->base->mData.mAttributes[i]); + ingredient->mBase->mData.mEffectID[i], ingredient->mBase->mData.mSkills[i]!=-1 ? + ingredient->mBase->mData.mSkills[i] : ingredient->mBase->mData.mAttributes[i]); ++effects[key]; } @@ -77,9 +77,9 @@ void MWMechanics::Alchemy::applyTools (int flags, float& value) const else return; - float toolQuality = setup==1 || setup==2 ? mTools[tool].get()->base->mData.mQuality : 0; + float toolQuality = setup==1 || setup==2 ? mTools[tool].get()->mBase->mData.mQuality : 0; float calcinatorQuality = setup==1 || setup==3 ? - mTools[ESM::Apparatus::Calcinator].get()->base->mData.mQuality : 0; + mTools[ESM::Apparatus::Calcinator].get()->mBase->mData.mQuality : 0; float quality = 1; @@ -130,7 +130,7 @@ void MWMechanics::Alchemy::updateEffects() // general alchemy factor float x = getChance(); - x *= mTools[ESM::Apparatus::MortarPestle].get()->base->mData.mQuality; + x *= mTools[ESM::Apparatus::MortarPestle].get()->mBase->mData.mQuality; x *= MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fPotionStrengthMult")->getFloat(); // value @@ -258,7 +258,7 @@ void MWMechanics::Alchemy::addPotion (const std::string& name) for (TIngredientsIterator iter (beginIngredients()); iter!=endIngredients(); ++iter) if (!iter->isEmpty()) - newRecord.mData.mWeight += iter->get()->base->mData.mWeight; + newRecord.mData.mWeight += iter->get()->mBase->mData.mWeight; newRecord.mData.mWeight /= countIngredients(); @@ -332,13 +332,13 @@ void MWMechanics::Alchemy::setAlchemist (const MWWorld::Ptr& npc) { MWWorld::LiveCellRef* ref = iter->get(); - int type = ref->base->mData.mType; + int type = ref->mBase->mData.mType; if (type<0 || type>=static_cast (mTools.size())) throw std::runtime_error ("invalid apparatus type"); if (!mTools[type].isEmpty()) - if (ref->base->mData.mQuality<=mTools[type].get()->base->mData.mQuality) + if (ref->mBase->mData.mQuality<=mTools[type].get()->mBase->mData.mQuality) continue; mTools[type] = *iter; diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 873dd9498..293b7cab1 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -19,7 +19,7 @@ namespace MWMechanics MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr); MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr); - const ESM::NPC *player = ptr.get()->base; + const ESM::NPC *player = ptr.get()->mBase; // reset creatureStats.setLevel(player->mNpdt52.mLevel); diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index afd114972..7ee361a6f 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -21,10 +21,10 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation() mInsert = ptr.getRefData().getBaseNode(); MWWorld::LiveCellRef *ref = ptr.get(); - assert (ref->base != NULL); - if(!ref->base->mModel.empty()) + assert (ref->mBase != NULL); + if(!ref->mBase->mModel.empty()) { - std::string mesh = "meshes\\" + ref->base->mModel; + std::string mesh = "meshes\\" + ref->mBase->mModel; mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, mesh); for(size_t i = 0;i < mEntityList.mEntities.size();i++) diff --git a/apps/openmw/mwrender/debugging.cpp b/apps/openmw/mwrender/debugging.cpp index 4f7150754..8f16d5f78 100644 --- a/apps/openmw/mwrender/debugging.cpp +++ b/apps/openmw/mwrender/debugging.cpp @@ -228,22 +228,22 @@ void Debugging::togglePathgrid() void Debugging::enableCellPathgrid(MWWorld::Ptr::CellStore *store) { - ESM::Pathgrid *pathgrid = MWBase::Environment::get().getWorld()->getStore().pathgrids.search(*store->cell); + ESM::Pathgrid *pathgrid = MWBase::Environment::get().getWorld()->getStore().pathgrids.search(*store->mCell); if (!pathgrid) return; Vector3 cellPathGridPos(0, 0, 0); - if (store->cell->isExterior()) + if (store->mCell->isExterior()) { - cellPathGridPos.x = store->cell->mData.mX * ESM::Land::REAL_SIZE; - cellPathGridPos.y = store->cell->mData.mY * ESM::Land::REAL_SIZE; + cellPathGridPos.x = store->mCell->mData.mX * ESM::Land::REAL_SIZE; + cellPathGridPos.y = store->mCell->mData.mY * ESM::Land::REAL_SIZE; } SceneNode *cellPathGrid = mPathGridRoot->createChildSceneNode(cellPathGridPos); cellPathGrid->attachObject(createPathgridLines(pathgrid)); cellPathGrid->attachObject(createPathgridPoints(pathgrid)); - if (store->cell->isExterior()) + if (store->mCell->isExterior()) { - mExteriorPathgridNodes[std::make_pair(store->cell->mData.mX, store->cell->mData.mY)] = cellPathGrid; + mExteriorPathgridNodes[std::make_pair(store->mCell->getGridX(), store->mCell->getGridY())] = cellPathGrid; } else { @@ -254,10 +254,10 @@ void Debugging::enableCellPathgrid(MWWorld::Ptr::CellStore *store) void Debugging::disableCellPathgrid(MWWorld::Ptr::CellStore *store) { - if (store->cell->isExterior()) + if (store->mCell->isExterior()) { ExteriorPathgridNodes::iterator it = - mExteriorPathgridNodes.find(std::make_pair(store->cell->mData.mX, store->cell->mData.mY)); + mExteriorPathgridNodes.find(std::make_pair(store->mCell->getGridX(), store->mCell->getGridY())); if (it != mExteriorPathgridNodes.end()) { destroyCellPathgridNode(it->second); diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index 1bdbce6d9..d7614a78c 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -108,10 +108,10 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell) mCameraRotNode->setOrientation(Quaternion::IDENTITY); - std::string name = "Cell_"+coordStr(cell->cell->mData.mX, cell->cell->mData.mY); + int x = cell->mCell->getGridX(); + int y = cell->mCell->getGridY(); - int x = cell->cell->mData.mX; - int y = cell->cell->mData.mY; + std::string name = "Cell_"+coordStr(x, y); mCameraPosNode->setPosition(Vector3(0,0,0)); @@ -163,7 +163,7 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell, const int segsX = std::ceil( length.x / sSize ); const int segsY = std::ceil( length.y / sSize ); - mInteriorName = cell->cell->mName; + mInteriorName = cell->mCell->mName; for (int x=0; xcell->mName + "_" + coordStr(x,y)); + cell->mCell->mName + "_" + coordStr(x,y)); } } } diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 5c2b05aca..6a25818c1 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -63,18 +63,18 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor } const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::Race *race = store.races.find(ref->base->mRace); + const ESM::Race *race = store.races.find(ref->mBase->mRace); - std::string hairID = ref->base->mHair; - std::string headID = ref->base->mHead; + std::string hairID = ref->mBase->mHair; + std::string headID = ref->mBase->mHead; headModel = "meshes\\" + store.bodyParts.find(headID)->mModel; hairModel = "meshes\\" + store.bodyParts.find(hairID)->mModel; - npcName = ref->base->mName; + npcName = ref->mBase->mName; - isFemale = !!(ref->base->mFlags&ESM::NPC::Female); + isFemale = !!(ref->mBase->mFlags&ESM::NPC::Female); isBeast = !!(race->mData.mFlags&ESM::Race::Beast); - bodyRaceID = "b_n_"+ref->base->mRace; + bodyRaceID = "b_n_"+ref->mBase->mRace; std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower); @@ -170,7 +170,7 @@ void NpcAnimation::updateParts() { MWWorld::Ptr ptr = *robe; - const ESM::Clothing *clothes = (ptr.get())->base; + const ESM::Clothing *clothes = (ptr.get())->mBase; std::vector parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Robe, 5, parts); reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Robe, 5); @@ -190,7 +190,7 @@ void NpcAnimation::updateParts() { MWWorld::Ptr ptr = *skirtiter; - const ESM::Clothing *clothes = (ptr.get())->base; + const ESM::Clothing *clothes = (ptr.get())->mBase; std::vector parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Skirt, 4, parts); reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Skirt, 4); @@ -201,32 +201,32 @@ void NpcAnimation::updateParts() if(helmet != mInv.end()) { removeIndividualPart(ESM::PRT_Hair); - const ESM::Armor *armor = (helmet->get())->base; + const ESM::Armor *armor = (helmet->get())->mBase; std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Helmet, 3, parts); } if(cuirass != mInv.end()) { - const ESM::Armor *armor = (cuirass->get())->base; + const ESM::Armor *armor = (cuirass->get())->mBase; std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Cuirass, 3, parts); } if(greaves != mInv.end()) { - const ESM::Armor *armor = (greaves->get())->base; + const ESM::Armor *armor = (greaves->get())->mBase; std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Greaves, 3, parts); } if(leftpauldron != mInv.end()) { - const ESM::Armor *armor = (leftpauldron->get())->base; + const ESM::Armor *armor = (leftpauldron->get())->mBase; std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_LeftPauldron, 3, parts); } if(rightpauldron != mInv.end()) { - const ESM::Armor *armor = (rightpauldron->get())->base; + const ESM::Armor *armor = (rightpauldron->get())->mBase; std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts); } @@ -234,13 +234,13 @@ void NpcAnimation::updateParts() { if(boots->getTypeName() == typeid(ESM::Clothing).name()) { - const ESM::Clothing *clothes = (boots->get())->base; + const ESM::Clothing *clothes = (boots->get())->mBase; std::vector parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Boots, 2, parts); } else if(boots->getTypeName() == typeid(ESM::Armor).name()) { - const ESM::Armor *armor = (boots->get())->base; + const ESM::Armor *armor = (boots->get())->mBase; std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Boots, 3, parts); } @@ -249,13 +249,13 @@ void NpcAnimation::updateParts() { if(leftglove->getTypeName() == typeid(ESM::Clothing).name()) { - const ESM::Clothing *clothes = (leftglove->get())->base; + const ESM::Clothing *clothes = (leftglove->get())->mBase; std::vector parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 2, parts); } else { - const ESM::Armor *armor = (leftglove->get())->base; + const ESM::Armor *armor = (leftglove->get())->mBase; std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 3, parts); } @@ -264,13 +264,13 @@ void NpcAnimation::updateParts() { if(rightglove->getTypeName() == typeid(ESM::Clothing).name()) { - const ESM::Clothing *clothes = (rightglove->get())->base; + const ESM::Clothing *clothes = (rightglove->get())->mBase; std::vector parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 2, parts); } else { - const ESM::Armor *armor = (rightglove->get())->base; + const ESM::Armor *armor = (rightglove->get())->mBase; std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 3, parts); } @@ -279,13 +279,13 @@ void NpcAnimation::updateParts() if(shirt != mInv.end()) { - const ESM::Clothing *clothes = (shirt->get())->base; + const ESM::Clothing *clothes = (shirt->get())->mBase; std::vector parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Shirt, 2, parts); } if(pants != mInv.end()) { - const ESM::Clothing *clothes = (pants->get())->base; + const ESM::Clothing *clothes = (pants->get())->mBase; std::vector parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Pants, 2, parts); } diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index 69c853d86..36f09e6d9 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -219,18 +219,18 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, f info.radius = radius; info.colour = Ogre::ColourValue(r, g, b); - if (ref->base->mData.mFlags & ESM::Light::Negative) + if (ref->mBase->mData.mFlags & ESM::Light::Negative) info.colour *= -1; - info.interior = (ptr.getCell()->cell->mData.mFlags & ESM::Cell::Interior); + info.interior = !ptr.getCell()->mCell->isExterior(); - if (ref->base->mData.mFlags & ESM::Light::Flicker) + if (ref->mBase->mData.mFlags & ESM::Light::Flicker) info.type = LT_Flicker; - else if (ref->base->mData.mFlags & ESM::Light::FlickerSlow) + else if (ref->mBase->mData.mFlags & ESM::Light::FlickerSlow) info.type = LT_FlickerSlow; - else if (ref->base->mData.mFlags & ESM::Light::Pulse) + else if (ref->mBase->mData.mFlags & ESM::Light::Pulse) info.type = LT_Pulse; - else if (ref->base->mData.mFlags & ESM::Light::PulseSlow) + else if (ref->mBase->mData.mFlags & ESM::Light::PulseSlow) info.type = LT_PulseSlow; else info.type = LT_Normal; diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 5b5fdce68..32389c7bd 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -206,7 +206,7 @@ void RenderingManager::removeCell (MWWorld::Ptr::CellStore *store) mObjects.removeCell(store); mActors.removeCell(store); mDebugging->cellRemoved(store); - if (store->cell->isExterior()) + if (store->mCell->isExterior()) mTerrainManager->cellRemoved(store); } @@ -227,7 +227,7 @@ void RenderingManager::cellAdded (MWWorld::Ptr::CellStore *store) { mObjects.buildStaticGeometry (*store); mDebugging->cellAdded(store); - if (store->cell->isExterior()) + if (store->mCell->isExterior()) mTerrainManager->cellAdded(store); waterAdded(store); } @@ -366,7 +366,7 @@ void RenderingManager::update (float duration) mWater->updateUnderwater( world->isUnderwater( - *world->getPlayer().getPlayer().getCell()->cell, + *world->getPlayer().getPlayer().getCell()->mCell, Ogre::Vector3(cam.x, -cam.z, cam.y)) ); mWater->update(duration); @@ -374,14 +374,14 @@ void RenderingManager::update (float duration) } void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store){ - if(store->cell->mData.mFlags & store->cell->HasWater - || ((!(store->cell->mData.mFlags & ESM::Cell::Interior)) - && !MWBase::Environment::get().getWorld()->getStore().lands.search(store->cell->mData.mX,store->cell->mData.mY) )) // always use water, if the cell does not have land. + if(store->mCell->mData.mFlags & store->mCell->HasWater + || ((store->mCell->isExterior()) + && !MWBase::Environment::get().getWorld()->getStore().lands.search(store->mCell->getGridX(),store->mCell->getGridY()) )) // always use water, if the cell does not have land. { if(mWater == 0) - mWater = new MWRender::Water(mRendering.getCamera(), this, store->cell); + mWater = new MWRender::Water(mRendering.getCamera(), this, store->mCell); else - mWater->changeCell(store->cell); + mWater->changeCell(store->mCell); mWater->setActive(true); } else @@ -467,9 +467,9 @@ bool RenderingManager::toggleRenderMode(int mode) void RenderingManager::configureFog(MWWorld::Ptr::CellStore &mCell) { Ogre::ColourValue color; - color.setAsABGR (mCell.cell->mAmbi.mFog); + color.setAsABGR (mCell.mCell->mAmbi.mFog); - configureFog(mCell.cell->mAmbi.mFogDensity, color); + configureFog(mCell.mCell->mAmbi.mFogDensity, color); if (mWater) mWater->setViewportBackground (Ogre::ColourValue(0.8f, 0.9f, 1.0f)); @@ -519,7 +519,7 @@ void RenderingManager::setAmbientMode() void RenderingManager::configureAmbient(MWWorld::Ptr::CellStore &mCell) { - mAmbientColor.setAsABGR (mCell.cell->mAmbi.mAmbient); + mAmbientColor.setAsABGR (mCell.mCell->mAmbi.mAmbient); setAmbientMode(); // Create a "sun" that shines light downwards. It doesn't look @@ -529,7 +529,7 @@ void RenderingManager::configureAmbient(MWWorld::Ptr::CellStore &mCell) mSun = mRendering.getScene()->createLight(); } Ogre::ColourValue colour; - colour.setAsABGR (mCell.cell->mAmbi.mSunlight); + colour.setAsABGR (mCell.mCell->mAmbi.mSunlight); mSun->setDiffuseColour (colour); mSun->setType(Ogre::Light::LT_DIRECTIONAL); mSun->setDirection(0,-1,0); @@ -613,7 +613,7 @@ void RenderingManager::setGlare(bool glare) void RenderingManager::requestMap(MWWorld::Ptr::CellStore* cell) { - if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) + if (cell->mCell->isExterior()) mLocalMap->requestMap(cell); else mLocalMap->requestMap(cell, mObjects.getDimensions(cell)); diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index 114a9bc37..eaea3d0ec 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -92,8 +92,8 @@ namespace MWRender void TerrainManager::cellAdded(MWWorld::Ptr::CellStore *store) { - const int cellX = store->cell->getGridX(); - const int cellY = store->cell->getGridY(); + const int cellX = store->mCell->getGridX(); + const int cellY = store->mCell->getGridY(); ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cellX, cellY); if (land == NULL) // no land data means we're not going to create any terrain. @@ -188,8 +188,8 @@ namespace MWRender { for ( int y = 0; y < 2; y++ ) { - int terrainX = store->cell->getGridX() * 2 + x; - int terrainY = store->cell->getGridY() * 2 + y; + int terrainX = store->mCell->getGridX() * 2 + x; + int terrainY = store->mCell->getGridY() * 2 + y; if (mTerrainGroup.getTerrain(terrainX, terrainY) != NULL) mTerrainGroup.unloadTerrain(terrainX, terrainY); } diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index 57dd7962b..a9c31b7fe 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -87,8 +87,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { bool interior = - MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->mData.mFlags & - ESM::Cell::Interior; + !MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->mCell->isExterior(); runtime.push (interior ? 1 : 0); } @@ -103,7 +102,7 @@ namespace MWScript std::string name = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - const ESM::Cell *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell; + const ESM::Cell *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->mCell; std::string current = cell->mName; @@ -143,7 +142,7 @@ namespace MWScript MWWorld::Ptr::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); - if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) + if (cell->mCell->isExterior()) throw std::runtime_error("Can't set water level in exterior cell"); cell->mWaterLevel = level; @@ -161,7 +160,7 @@ namespace MWScript MWWorld::Ptr::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); - if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) + if (cell->mCell->isExterior()) throw std::runtime_error("Can't set water level in exterior cell"); cell->mWaterLevel +=level; diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 0d69608e1..828d8a5e0 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -328,7 +328,7 @@ namespace MWScript assert (ref); const ESM::Class& class_ = - *MWBase::Environment::get().getWorld()->getStore().classes.find (ref->base->mClass); + *MWBase::Environment::get().getWorld()->getStore().classes.find (ref->mBase->mClass); float level = 0; float progress = std::modf (stats.getSkill (mIndex).getBase(), &level); diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index 5d5ef3d1d..9aabffb98 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -414,13 +414,13 @@ namespace MWSound //If the region has changed timePassed += duration; - if((current->cell->mData.mFlags & current->cell->Interior) || timePassed < 10) + if(!current->mCell->isExterior() || timePassed < 10) return; timePassed = 0; - if(regionName != current->cell->mRegion) + if(regionName != current->mCell->mRegion) { - regionName = current->cell->mRegion; + regionName = current->mCell->mRegion; total = 0; } @@ -477,7 +477,7 @@ namespace MWSound MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - const ESM::Cell *cell = player.getCell()->cell; + const ESM::Cell *cell = player.getCell()->mCell; Environment env = Env_Normal; if((cell->mData.mFlags&cell->HasWater) && mListenerPos.z < cell->mWater) diff --git a/apps/openmw/mwworld/actionread.cpp b/apps/openmw/mwworld/actionread.cpp index 4ac613df7..92f232802 100644 --- a/apps/openmw/mwworld/actionread.cpp +++ b/apps/openmw/mwworld/actionread.cpp @@ -24,7 +24,7 @@ namespace MWWorld { LiveCellRef *ref = getTarget().get(); - if (ref->base->mData.mIsScroll) + if (ref->mBase->mData.mIsScroll) { MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Scroll); MWBase::Environment::get().getWindowManager()->getScrollWindow()->open(getTarget()); @@ -39,16 +39,16 @@ namespace MWWorld MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats (player); // Skill gain from books - if (ref->base->mData.mSkillID >= 0 && ref->base->mData.mSkillID < ESM::Skill::Length - && !npcStats.hasBeenUsed (ref->base->mId)) + if (ref->mBase->mData.mSkillID >= 0 && ref->mBase->mData.mSkillID < ESM::Skill::Length + && !npcStats.hasBeenUsed (ref->mBase->mId)) { MWWorld::LiveCellRef *playerRef = player.get(); const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( - playerRef->base->mClass); + playerRef->mBase->mClass); - npcStats.increaseSkill (ref->base->mData.mSkillID, *class_, true); + npcStats.increaseSkill (ref->mBase->mData.mSkillID, *class_, true); - npcStats.flagAsUsed (ref->base->mId); + npcStats.flagAsUsed (ref->mBase->mId); } } diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index e5a38d4be..0279c7480 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -24,12 +24,12 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell) else { std::map, Ptr::CellStore>::iterator result = - mExteriors.find (std::make_pair (cell->mData.mX, cell->mData.mY)); + mExteriors.find (std::make_pair (cell->getGridX(), cell->getGridY())); if (result==mExteriors.end()) { result = mExteriors.insert (std::make_pair ( - std::make_pair (cell->mData.mX, cell->mData.mY), Ptr::CellStore (cell))).first; + std::make_pair (cell->getGridX(), cell->getGridY()), Ptr::CellStore (cell))).first; } @@ -40,33 +40,33 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell) void MWWorld::Cells::fillContainers (Ptr::CellStore& cellStore) { for (CellRefList::List::iterator iter ( - cellStore.containers.list.begin()); - iter!=cellStore.containers.list.end(); ++iter) + cellStore.mContainers.mList.begin()); + iter!=cellStore.mContainers.mList.end(); ++iter) { Ptr container (&*iter, &cellStore); Class::get (container).getContainerStore (container).fill ( - iter->base->mInventory, mStore); + iter->mBase->mInventory, mStore); } for (CellRefList::List::iterator iter ( - cellStore.creatures.list.begin()); - iter!=cellStore.creatures.list.end(); ++iter) + cellStore.mCreatures.mList.begin()); + iter!=cellStore.mCreatures.mList.end(); ++iter) { Ptr container (&*iter, &cellStore); Class::get (container).getContainerStore (container).fill ( - iter->base->mInventory, mStore); + iter->mBase->mInventory, mStore); } for (CellRefList::List::iterator iter ( - cellStore.npcs.list.begin()); - iter!=cellStore.npcs.list.end(); ++iter) + cellStore.mNpcs.mList.begin()); + iter!=cellStore.mNpcs.mList.end(); ++iter) { Ptr container (&*iter, &cellStore); Class::get (container).getContainerStore (container).fill ( - iter->base->mInventory, mStore); + iter->mBase->mInventory, mStore); } } @@ -169,64 +169,64 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, Ptr::CellStore& ce } MWWorld::Ptr ptr; - if (MWWorld::LiveCellRef *ref = cell.activators.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mActivators.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.potions.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mPotions.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.appas.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mAppas.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.armors.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mArmors.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.books.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mBooks.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.clothes.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mClothes.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.containers.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mContainers.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.creatures.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mCreatures.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.doors.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mDoors.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.ingreds.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mIngreds.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.creatureLists.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mCreatureLists.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.itemLists.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mItemLists.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.lights.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mLights.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.lockpicks.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mLockpicks.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.miscItems.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mMiscItems.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.npcs.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mNpcs.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.probes.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mProbes.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.repairs.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mRepairs.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.statics.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mStatics.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = cell.weapons.find (name)) + if (MWWorld::LiveCellRef *ref = cell.mWeapons.find (name)) ptr = Ptr (ref, &cell); if (!ptr.isEmpty() && ptr.getRefData().getCount() > 0) { diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index fcdec1e7f..e0b435556 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -11,7 +11,8 @@ namespace MWWorld { - CellStore::CellStore (const ESM::Cell *cell_) : cell (cell_), mState (State_Unloaded) + CellStore::CellStore (const ESM::Cell *cell) + : mCell (cell), mState (State_Unloaded) { mWaterLevel = cell->mWater; } @@ -23,7 +24,7 @@ namespace MWWorld if (mState==State_Preloaded) mIds.clear(); - std::cout << "loading cell " << cell->getDescription() << std::endl; + std::cout << "loading cell " << mCell->getDescription() << std::endl; loadRefs (store, esm); @@ -43,18 +44,18 @@ namespace MWWorld void CellStore::listRefs(const ESMS::ESMStore &store, ESM::ESMReader &esm) { - assert (cell); + assert (mCell); - if (cell->mContext.filename.empty()) + if (mCell->mContext.filename.empty()) return; // this is a dynamically generated cell -> skipping. // Reopen the ESM reader and seek to the right position. - cell->restore (esm); + mCell->restore (esm); ESM::CellRef ref; // Get each reference in turn - while (cell->getNextRef (esm, ref)) + while (mCell->getNextRef (esm, ref)) { std::string lowerCase; @@ -69,18 +70,18 @@ namespace MWWorld void CellStore::loadRefs(const ESMS::ESMStore &store, ESM::ESMReader &esm) { - assert (cell); + assert (mCell); - if (cell->mContext.filename.empty()) + if (mCell->mContext.filename.empty()) return; // this is a dynamically generated cell -> skipping. // Reopen the ESM reader and seek to the right position. - cell->restore(esm); + mCell->restore(esm); ESM::CellRef ref; // Get each reference in turn - while(cell->getNextRef(esm, ref)) + while(mCell->getNextRef(esm, ref)) { std::string lowerCase; @@ -98,26 +99,26 @@ namespace MWWorld */ switch(rec) { - case ESM::REC_ACTI: activators.find(ref, store.activators); break; - case ESM::REC_ALCH: potions.find(ref, store.potions); break; - case ESM::REC_APPA: appas.find(ref, store.appas); break; - case ESM::REC_ARMO: armors.find(ref, store.armors); break; - case ESM::REC_BOOK: books.find(ref, store.books); break; - case ESM::REC_CLOT: clothes.find(ref, store.clothes); break; - case ESM::REC_CONT: containers.find(ref, store.containers); break; - case ESM::REC_CREA: creatures.find(ref, store.creatures); break; - case ESM::REC_DOOR: doors.find(ref, store.doors); break; - case ESM::REC_INGR: ingreds.find(ref, store.ingreds); break; - case ESM::REC_LEVC: creatureLists.find(ref, store.creatureLists); break; - case ESM::REC_LEVI: itemLists.find(ref, store.itemLists); break; - case ESM::REC_LIGH: lights.find(ref, store.lights); break; - case ESM::REC_LOCK: lockpicks.find(ref, store.lockpicks); break; - case ESM::REC_MISC: miscItems.find(ref, store.miscItems); break; - case ESM::REC_NPC_: npcs.find(ref, store.npcs); break; - case ESM::REC_PROB: probes.find(ref, store.probes); break; - case ESM::REC_REPA: repairs.find(ref, store.repairs); break; - case ESM::REC_STAT: statics.find(ref, store.statics); break; - case ESM::REC_WEAP: weapons.find(ref, store.weapons); break; + case ESM::REC_ACTI: mActivators.find(ref, store.activators); break; + case ESM::REC_ALCH: mPotions.find(ref, store.potions); break; + case ESM::REC_APPA: mAppas.find(ref, store.appas); break; + case ESM::REC_ARMO: mArmors.find(ref, store.armors); break; + case ESM::REC_BOOK: mBooks.find(ref, store.books); break; + case ESM::REC_CLOT: mClothes.find(ref, store.clothes); break; + case ESM::REC_CONT: mContainers.find(ref, store.containers); break; + case ESM::REC_CREA: mCreatures.find(ref, store.creatures); break; + case ESM::REC_DOOR: mDoors.find(ref, store.doors); break; + case ESM::REC_INGR: mIngreds.find(ref, store.ingreds); break; + case ESM::REC_LEVC: mCreatureLists.find(ref, store.creatureLists); break; + case ESM::REC_LEVI: mItemLists.find(ref, store.itemLists); break; + case ESM::REC_LIGH: mLights.find(ref, store.lights); break; + case ESM::REC_LOCK: mLockpicks.find(ref, store.lockpicks); break; + case ESM::REC_MISC: mMiscItems.find(ref, store.miscItems); break; + case ESM::REC_NPC_: mNpcs.find(ref, store.npcs); break; + case ESM::REC_PROB: mProbes.find(ref, store.probes); break; + case ESM::REC_REPA: mRepairs.find(ref, store.repairs); break; + case ESM::REC_STAT: mStatics.find(ref, store.statics); break; + case ESM::REC_WEAP: mWeapons.find(ref, store.weapons); break; case 0: std::cout << "Cell reference " + ref.mRefID + " not found!\n"; break; default: diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index 32ab6e07b..c48e90d31 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -26,19 +26,21 @@ namespace MWWorld template struct LiveCellRef { - LiveCellRef(const ESM::CellRef& cref, const X* b = NULL) : base(b), ref(cref), - mData(ref) {} + LiveCellRef(const ESM::CellRef& cref, const X* b = NULL) + : mBase(b), mRef(cref), mData(mRef) + {} - - LiveCellRef(const X* b = NULL) : base(b), mData(ref) {} + LiveCellRef(const X* b = NULL) + : mBase(b), mData(mRef) + {} // The object that this instance is based on. - const X* base; + const X* mBase; /* Information about this instance, such as 3D location and rotation and individual type-dependent data. */ - ESM::CellRef ref; + ESM::CellRef mRef; /// runtime-data RefData mData; @@ -50,7 +52,7 @@ namespace MWWorld { typedef LiveCellRef LiveRef; typedef std::list List; - List list; + List mList; // Search for the given reference in the given reclist from // ESMStore. Insert the reference into the list if a match is @@ -62,14 +64,14 @@ namespace MWWorld if(obj == NULL) throw std::runtime_error("Error resolving cell reference " + ref.mRefID); - list.push_back(LiveRef(ref, obj)); + mList.push_back(LiveRef(ref, obj)); } LiveRef *find (const std::string& name) { - for (typename std::list::iterator iter (list.begin()); iter!=list.end(); ++iter) + for (typename std::list::iterator iter (mList.begin()); iter!=mList.end(); ++iter) { - if (iter->mData.getCount() > 0 && iter->ref.mRefID == name) + if (iter->mData.getCount() > 0 && iter->mRef.mRefID == name) return &*iter; } @@ -77,8 +79,8 @@ namespace MWWorld } LiveRef &insert(const LiveRef &item) { - list.push_back(item); - return list.back(); + mList.push_back(item); + return mList.back(); } }; @@ -94,33 +96,33 @@ namespace MWWorld CellStore (const ESM::Cell *cell_); - const ESM::Cell *cell; + const ESM::Cell *mCell; State mState; std::vector mIds; float mWaterLevel; // Lists for each individual object type - CellRefList activators; - CellRefList potions; - CellRefList appas; - CellRefList armors; - CellRefList books; - CellRefList clothes; - CellRefList containers; - CellRefList creatures; - CellRefList doors; - CellRefList ingreds; - CellRefList creatureLists; - CellRefList itemLists; - CellRefList lights; - CellRefList lockpicks; - CellRefList miscItems; - CellRefList npcs; - CellRefList probes; - CellRefList repairs; - CellRefList statics; - CellRefList weapons; + CellRefList mActivators; + CellRefList mPotions; + CellRefList mAppas; + CellRefList mArmors; + CellRefList mBooks; + CellRefList mClothes; + CellRefList mContainers; + CellRefList mCreatures; + CellRefList mDoors; + CellRefList mIngreds; + CellRefList mCreatureLists; + CellRefList mItemLists; + CellRefList mLights; + CellRefList mLockpicks; + CellRefList mMiscItems; + CellRefList mNpcs; + CellRefList mProbes; + CellRefList mRepairs; + CellRefList mStatics; + CellRefList mWeapons; void load (const ESMS::ESMStore &store, ESM::ESMReader &esm); @@ -133,32 +135,32 @@ namespace MWWorld bool forEach (Functor& functor) { return - forEachImp (functor, activators) && - forEachImp (functor, potions) && - forEachImp (functor, appas) && - forEachImp (functor, armors) && - forEachImp (functor, books) && - forEachImp (functor, clothes) && - forEachImp (functor, containers) && - forEachImp (functor, creatures) && - forEachImp (functor, doors) && - forEachImp (functor, ingreds) && - forEachImp (functor, creatureLists) && - forEachImp (functor, itemLists) && - forEachImp (functor, lights) && - forEachImp (functor, lockpicks) && - forEachImp (functor, miscItems) && - forEachImp (functor, npcs) && - forEachImp (functor, probes) && - forEachImp (functor, repairs) && - forEachImp (functor, statics) && - forEachImp (functor, weapons); + forEachImp (functor, mActivators) && + forEachImp (functor, mPotions) && + forEachImp (functor, mAppas) && + forEachImp (functor, mArmors) && + forEachImp (functor, mBooks) && + forEachImp (functor, mClothes) && + forEachImp (functor, mContainers) && + forEachImp (functor, mCreatures) && + forEachImp (functor, mDoors) && + forEachImp (functor, mIngreds) && + forEachImp (functor, mCreatureLists) && + forEachImp (functor, mItemLists) && + forEachImp (functor, mLights) && + forEachImp (functor, mLockpicks) && + forEachImp (functor, mMiscItems) && + forEachImp (functor, mNpcs) && + forEachImp (functor, mProbes) && + forEachImp (functor, mRepairs) && + forEachImp (functor, mStatics) && + forEachImp (functor, mWeapons); } bool operator==(const CellStore &cell) { - return this->cell->mName == cell.cell->mName && - this->cell->mData.mX == cell.cell->mData.mX && - this->cell->mData.mY == cell.cell->mData.mY; + return mCell->mName == cell.mCell->mName && + mCell->mData.mX == cell.mCell->mData.mX && + mCell->mData.mY == cell.mCell->mData.mY; } bool operator!=(const CellStore &cell) { @@ -166,7 +168,7 @@ namespace MWWorld } bool isExterior() const { - return cell->isExterior(); + return mCell->isExterior(); } private: @@ -174,9 +176,9 @@ namespace MWWorld template bool forEachImp (Functor& functor, List& list) { - for (typename List::List::iterator iter (list.list.begin()); iter!=list.list.end(); + for (typename List::List::iterator iter (list.mList.begin()); iter!=list.mList.end(); ++iter) - if (!functor (iter->ref, iter->mData)) + if (!functor (iter->mRef, iter->mData)) return false; return true; diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 5c4dd03a4..78454be4b 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -24,12 +24,12 @@ namespace float sum = 0; for (typename MWWorld::CellRefList::List::const_iterator iter ( - cellRefList.list.begin()); - iter!=cellRefList.list.end(); + cellRefList.mList.begin()); + iter!=cellRefList.mList.end(); ++iter) { if (iter->mData.getCount()>0) - sum += iter->mData.getCount()*iter->base->mData.mWeight; + sum += iter->mData.getCount()*iter->mBase->mData.mWeight; } return sum; @@ -81,19 +81,19 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& ptr) MWWorld::LiveCellRef *gold = ptr.get(); - if (compare_string_ci(gold->ref.mRefID, "gold_001") - || compare_string_ci(gold->ref.mRefID, "gold_005") - || compare_string_ci(gold->ref.mRefID, "gold_010") - || compare_string_ci(gold->ref.mRefID, "gold_025") - || compare_string_ci(gold->ref.mRefID, "gold_100")) + if (compare_string_ci(gold->mRef.mRefID, "gold_001") + || compare_string_ci(gold->mRef.mRefID, "gold_005") + || compare_string_ci(gold->mRef.mRefID, "gold_010") + || compare_string_ci(gold->mRef.mRefID, "gold_025") + || compare_string_ci(gold->mRef.mRefID, "gold_100")) { MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), "Gold_001"); - int count = (ptr.getRefData().getCount() == 1) ? gold->base->mData.mValue : ptr.getRefData().getCount(); + int count = (ptr.getRefData().getCount() == 1) ? gold->mBase->mData.mValue : ptr.getRefData().getCount(); ref.getPtr().getRefData().setCount(count); for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter) { - if (compare_string_ci((*iter).get()->ref.mRefID, "gold_001")) + if (compare_string_ci((*iter).get()->mRef.mRefID, "gold_001")) { (*iter).getRefData().setCount( (*iter).getRefData().getCount() + count); flagAsModified(); @@ -127,18 +127,18 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::addImpl (const Ptr& ptr switch (getType(ptr)) { - case Type_Potion: potions.list.push_back (*ptr.get()); it = ContainerStoreIterator(this, --potions.list.end()); break; - case Type_Apparatus: appas.list.push_back (*ptr.get()); it = ContainerStoreIterator(this, --appas.list.end()); break; - case Type_Armor: armors.list.push_back (*ptr.get()); it = ContainerStoreIterator(this, --armors.list.end()); break; - case Type_Book: books.list.push_back (*ptr.get()); it = ContainerStoreIterator(this, --books.list.end()); break; - case Type_Clothing: clothes.list.push_back (*ptr.get()); it = ContainerStoreIterator(this, --clothes.list.end()); break; - case Type_Ingredient: ingreds.list.push_back (*ptr.get()); it = ContainerStoreIterator(this, --ingreds.list.end()); break; - case Type_Light: lights.list.push_back (*ptr.get()); it = ContainerStoreIterator(this, --lights.list.end()); break; - case Type_Lockpick: lockpicks.list.push_back (*ptr.get()); it = ContainerStoreIterator(this, --lockpicks.list.end()); break; - case Type_Miscellaneous: miscItems.list.push_back (*ptr.get()); it = ContainerStoreIterator(this, --miscItems.list.end()); break; - case Type_Probe: probes.list.push_back (*ptr.get()); it = ContainerStoreIterator(this, --probes.list.end()); break; - case Type_Repair: repairs.list.push_back (*ptr.get()); it = ContainerStoreIterator(this, --repairs.list.end()); break; - case Type_Weapon: weapons.list.push_back (*ptr.get()); it = ContainerStoreIterator(this, --weapons.list.end()); break; + case Type_Potion: potions.mList.push_back (*ptr.get()); it = ContainerStoreIterator(this, --potions.mList.end()); break; + case Type_Apparatus: appas.mList.push_back (*ptr.get()); it = ContainerStoreIterator(this, --appas.mList.end()); break; + case Type_Armor: armors.mList.push_back (*ptr.get()); it = ContainerStoreIterator(this, --armors.mList.end()); break; + case Type_Book: books.mList.push_back (*ptr.get()); it = ContainerStoreIterator(this, --books.mList.end()); break; + case Type_Clothing: clothes.mList.push_back (*ptr.get()); it = ContainerStoreIterator(this, --clothes.mList.end()); break; + case Type_Ingredient: ingreds.mList.push_back (*ptr.get()); it = ContainerStoreIterator(this, --ingreds.mList.end()); break; + case Type_Light: lights.mList.push_back (*ptr.get()); it = ContainerStoreIterator(this, --lights.mList.end()); break; + case Type_Lockpick: lockpicks.mList.push_back (*ptr.get()); it = ContainerStoreIterator(this, --lockpicks.mList.end()); break; + case Type_Miscellaneous: miscItems.mList.push_back (*ptr.get()); it = ContainerStoreIterator(this, --miscItems.mList.end()); break; + case Type_Probe: probes.mList.push_back (*ptr.get()); it = ContainerStoreIterator(this, --probes.mList.end()); break; + case Type_Repair: repairs.mList.push_back (*ptr.get()); it = ContainerStoreIterator(this, --repairs.mList.end()); break; + case Type_Weapon: weapons.mList.push_back (*ptr.get()); it = ContainerStoreIterator(this, --weapons.mList.end()); break; } flagAsModified(); @@ -326,63 +326,63 @@ bool MWWorld::ContainerStoreIterator::resetIterator() { case ContainerStore::Type_Potion: - mPotion = mContainer->potions.list.begin(); - return mPotion!=mContainer->potions.list.end(); + mPotion = mContainer->potions.mList.begin(); + return mPotion!=mContainer->potions.mList.end(); case ContainerStore::Type_Apparatus: - mApparatus = mContainer->appas.list.begin(); - return mApparatus!=mContainer->appas.list.end(); + mApparatus = mContainer->appas.mList.begin(); + return mApparatus!=mContainer->appas.mList.end(); case ContainerStore::Type_Armor: - mArmor = mContainer->armors.list.begin(); - return mArmor!=mContainer->armors.list.end(); + mArmor = mContainer->armors.mList.begin(); + return mArmor!=mContainer->armors.mList.end(); case ContainerStore::Type_Book: - mBook = mContainer->books.list.begin(); - return mBook!=mContainer->books.list.end(); + mBook = mContainer->books.mList.begin(); + return mBook!=mContainer->books.mList.end(); case ContainerStore::Type_Clothing: - mClothing = mContainer->clothes.list.begin(); - return mClothing!=mContainer->clothes.list.end(); + mClothing = mContainer->clothes.mList.begin(); + return mClothing!=mContainer->clothes.mList.end(); case ContainerStore::Type_Ingredient: - mIngredient = mContainer->ingreds.list.begin(); - return mIngredient!=mContainer->ingreds.list.end(); + mIngredient = mContainer->ingreds.mList.begin(); + return mIngredient!=mContainer->ingreds.mList.end(); case ContainerStore::Type_Light: - mLight = mContainer->lights.list.begin(); - return mLight!=mContainer->lights.list.end(); + mLight = mContainer->lights.mList.begin(); + return mLight!=mContainer->lights.mList.end(); case ContainerStore::Type_Lockpick: - mLockpick = mContainer->lockpicks.list.begin(); - return mLockpick!=mContainer->lockpicks.list.end(); + mLockpick = mContainer->lockpicks.mList.begin(); + return mLockpick!=mContainer->lockpicks.mList.end(); case ContainerStore::Type_Miscellaneous: - mMiscellaneous = mContainer->miscItems.list.begin(); - return mMiscellaneous!=mContainer->miscItems.list.end(); + mMiscellaneous = mContainer->miscItems.mList.begin(); + return mMiscellaneous!=mContainer->miscItems.mList.end(); case ContainerStore::Type_Probe: - mProbe = mContainer->probes.list.begin(); - return mProbe!=mContainer->probes.list.end(); + mProbe = mContainer->probes.mList.begin(); + return mProbe!=mContainer->probes.mList.end(); case ContainerStore::Type_Repair: - mRepair = mContainer->repairs.list.begin(); - return mRepair!=mContainer->repairs.list.end(); + mRepair = mContainer->repairs.mList.begin(); + return mRepair!=mContainer->repairs.mList.end(); case ContainerStore::Type_Weapon: - mWeapon = mContainer->weapons.list.begin(); - return mWeapon!=mContainer->weapons.list.end(); + mWeapon = mContainer->weapons.mList.begin(); + return mWeapon!=mContainer->weapons.mList.end(); } return false; @@ -395,62 +395,62 @@ bool MWWorld::ContainerStoreIterator::incIterator() case ContainerStore::Type_Potion: ++mPotion; - return mPotion==mContainer->potions.list.end(); + return mPotion==mContainer->potions.mList.end(); case ContainerStore::Type_Apparatus: ++mApparatus; - return mApparatus==mContainer->appas.list.end(); + return mApparatus==mContainer->appas.mList.end(); case ContainerStore::Type_Armor: ++mArmor; - return mArmor==mContainer->armors.list.end(); + return mArmor==mContainer->armors.mList.end(); case ContainerStore::Type_Book: ++mBook; - return mBook==mContainer->books.list.end(); + return mBook==mContainer->books.mList.end(); case ContainerStore::Type_Clothing: ++mClothing; - return mClothing==mContainer->clothes.list.end(); + return mClothing==mContainer->clothes.mList.end(); case ContainerStore::Type_Ingredient: ++mIngredient; - return mIngredient==mContainer->ingreds.list.end(); + return mIngredient==mContainer->ingreds.mList.end(); case ContainerStore::Type_Light: ++mLight; - return mLight==mContainer->lights.list.end(); + return mLight==mContainer->lights.mList.end(); case ContainerStore::Type_Lockpick: ++mLockpick; - return mLockpick==mContainer->lockpicks.list.end(); + return mLockpick==mContainer->lockpicks.mList.end(); case ContainerStore::Type_Miscellaneous: ++mMiscellaneous; - return mMiscellaneous==mContainer->miscItems.list.end(); + return mMiscellaneous==mContainer->miscItems.mList.end(); case ContainerStore::Type_Probe: ++mProbe; - return mProbe==mContainer->probes.list.end(); + return mProbe==mContainer->probes.mList.end(); case ContainerStore::Type_Repair: ++mRepair; - return mRepair==mContainer->repairs.list.end(); + return mRepair==mContainer->repairs.mList.end(); case ContainerStore::Type_Weapon: ++mWeapon; - return mWeapon==mContainer->weapons.list.end(); + return mWeapon==mContainer->weapons.mList.end(); } return true; diff --git a/apps/openmw/mwworld/localscripts.cpp b/apps/openmw/mwworld/localscripts.cpp index d0d698feb..1f11b6233 100644 --- a/apps/openmw/mwworld/localscripts.cpp +++ b/apps/openmw/mwworld/localscripts.cpp @@ -12,12 +12,12 @@ namespace MWWorld::CellRefList& cellRefList, MWWorld::Ptr::CellStore *cell) { for (typename MWWorld::CellRefList::List::iterator iter ( - cellRefList.list.begin()); - iter!=cellRefList.list.end(); ++iter) + cellRefList.mList.begin()); + iter!=cellRefList.mList.end(); ++iter) { - if (!iter->base->mScript.empty() && iter->mData.getCount()) + if (!iter->mBase->mScript.empty() && iter->mData.getCount()) { - localScripts.add (iter->base->mScript, MWWorld::Ptr (&*iter, cell)); + localScripts.add (iter->mBase->mScript, MWWorld::Ptr (&*iter, cell)); } } } @@ -73,23 +73,23 @@ void MWWorld::LocalScripts::add (const std::string& scriptName, const Ptr& ptr) void MWWorld::LocalScripts::addCell (Ptr::CellStore *cell) { - listCellScripts (*this, cell->activators, cell); - listCellScripts (*this, cell->potions, cell); - listCellScripts (*this, cell->appas, cell); - listCellScripts (*this, cell->armors, cell); - listCellScripts (*this, cell->books, cell); - listCellScripts (*this, cell->clothes, cell); - listCellScripts (*this, cell->containers, cell); - listCellScripts (*this, cell->creatures, cell); - listCellScripts (*this, cell->doors, cell); - listCellScripts (*this, cell->ingreds, cell); - listCellScripts (*this, cell->lights, cell); - listCellScripts (*this, cell->lockpicks, cell); - listCellScripts (*this, cell->miscItems, cell); - listCellScripts (*this, cell->npcs, cell); - listCellScripts (*this, cell->probes, cell); - listCellScripts (*this, cell->repairs, cell); - listCellScripts (*this, cell->weapons, cell); + listCellScripts (*this, cell->mActivators, cell); + listCellScripts (*this, cell->mPotions, cell); + listCellScripts (*this, cell->mAppas, cell); + listCellScripts (*this, cell->mArmors, cell); + listCellScripts (*this, cell->mBooks, cell); + listCellScripts (*this, cell->mClothes, cell); + listCellScripts (*this, cell->mContainers, cell); + listCellScripts (*this, cell->mCreatures, cell); + listCellScripts (*this, cell->mDoors, cell); + listCellScripts (*this, cell->mIngreds, cell); + listCellScripts (*this, cell->mLights, cell); + listCellScripts (*this, cell->mLockpicks, cell); + listCellScripts (*this, cell->mMiscItems, cell); + listCellScripts (*this, cell->mNpcs, cell); + listCellScripts (*this, cell->mProbes, cell); + listCellScripts (*this, cell->mRepairs, cell); + listCellScripts (*this, cell->mWeapons, cell); } void MWWorld::LocalScripts::clear() diff --git a/apps/openmw/mwworld/manualref.hpp b/apps/openmw/mwworld/manualref.hpp index 6570761ab..94e9dad15 100644 --- a/apps/openmw/mwworld/manualref.hpp +++ b/apps/openmw/mwworld/manualref.hpp @@ -25,7 +25,7 @@ namespace MWWorld if (const T *instance = list.search (name)) { LiveCellRef ref; - ref.base = instance; + ref.mBase = instance; mRef = ref; mPtr = Ptr (&boost::any_cast&> (mRef), 0); @@ -42,7 +42,7 @@ namespace MWWorld if (const T *instance = list.search (name)) { LiveCellRef ref; - ref.base = instance; + ref.mBase = instance; mRef = ref; mPtr = Ptr (&boost::any_cast&> (mRef), 0); diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index e1eb02c32..a436875ca 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -17,8 +17,8 @@ namespace MWWorld mCellStore (0), mClass (0), mAutoMove (false), mForwardBackward (0) { - mPlayer.base = player; - mPlayer.ref.mRefID = "player"; + mPlayer.mBase = player; + mPlayer.mRef.mRefID = "player"; mName = player->mName; mMale = !(player->mFlags & ESM::NPC::Female); mRace = player->mRace; diff --git a/apps/openmw/mwworld/ptr.hpp b/apps/openmw/mwworld/ptr.hpp index f74fdd3ef..594ddef2d 100644 --- a/apps/openmw/mwworld/ptr.hpp +++ b/apps/openmw/mwworld/ptr.hpp @@ -50,7 +50,7 @@ namespace MWWorld : mContainerStore (0) { mPtr = liveCellRef; - mCellRef = &liveCellRef->ref; + mCellRef = &liveCellRef->mRef; mRefData = &liveCellRef->mData; mCell = cell; mTypeName = typeid (T).name(); diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 517025fb2..ea62c0b3c 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -20,15 +20,15 @@ namespace void insertCellRefList(MWRender::RenderingManager& rendering, T& cellRefList, MWWorld::CellStore &cell, MWWorld::PhysicsSystem& physics) { - if (!cellRefList.list.empty()) + if (!cellRefList.mList.empty()) { const MWWorld::Class& class_ = - MWWorld::Class::get (MWWorld::Ptr (&*cellRefList.list.begin(), &cell)); + MWWorld::Class::get (MWWorld::Ptr (&*cellRefList.mList.begin(), &cell)); - int numRefs = cellRefList.list.size(); + int numRefs = cellRefList.mList.size(); int current = 0; - for (typename T::List::iterator it = cellRefList.list.begin(); - it != cellRefList.list.end(); it++) + for (typename T::List::iterator it = cellRefList.mList.begin(); + it != cellRefList.mList.end(); it++) { MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 1, current, numRefs); ++current; @@ -80,11 +80,15 @@ namespace MWWorld mPhysics->removeObject (node->getName()); } - if (!((*iter)->cell->mData.mFlags & ESM::Cell::Interior)) + if ((*iter)->mCell->isExterior()) { - ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search((*iter)->cell->mData.mX,(*iter)->cell->mData.mY); + ESM::Land* land = + MWBase::Environment::get().getWorld()->getStore().lands.search( + (*iter)->mCell->getGridX(), + (*iter)->mCell->getGridY() + ); if (land) - mPhysics->removeHeightField( (*iter)->cell->mData.mX, (*iter)->cell->mData.mY ); + mPhysics->removeHeightField( (*iter)->mCell->getGridX(), (*iter)->mCell->getGridY() ); } } @@ -111,13 +115,23 @@ namespace MWWorld float verts = ESM::Land::LAND_SIZE; float worldsize = ESM::Land::REAL_SIZE; - if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) + if (cell->mCell->isExterior()) { - ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cell->cell->mData.mX,cell->cell->mData.mY); - if (land) - mPhysics->addHeightField (land->mLandData->mHeights, - cell->cell->mData.mX, cell->cell->mData.mY, - 0, ( worldsize/(verts-1) ), verts); + ESM::Land* land = + MWBase::Environment::get().getWorld()->getStore().lands.search( + cell->mCell->getGridX(), + cell->mCell->getGridY() + ); + if (land) { + mPhysics->addHeightField ( + land->mLandData->mHeights, + cell->mCell->getGridX(), + cell->mCell->getGridY(), + 0, + worldsize / (verts-1), + verts) + ; + } } mRendering.configureAmbient(*cell); @@ -128,8 +142,8 @@ namespace MWWorld void Scene::playerCellChange(MWWorld::CellStore *cell, const ESM::Position& pos, bool adjustPlayerPos) { - bool hasWater = cell->cell->mData.mFlags & cell->cell->HasWater; - mPhysics->setCurrentWater(hasWater, cell->cell->mWater); + bool hasWater = cell->mCell->mData.mFlags & ESM::Cell::HasWater; + mPhysics->setCurrentWater(hasWater, cell->mCell->mWater); MWBase::World *world = MWBase::Environment::get().getWorld(); world->getPlayer().setCell(cell); @@ -167,10 +181,10 @@ namespace MWWorld int numUnload = 0; while (active!=mActiveCells.end()) { - if (!((*active)->cell->mData.mFlags & ESM::Cell::Interior)) + if ((*active)->mCell->isExterior()) { - if (std::abs (X-(*active)->cell->mData.mX)<=1 && - std::abs (Y-(*active)->cell->mData.mY)<=1) + if (std::abs (X-(*active)->mCell->getGridX())<=1 && + std::abs (Y-(*active)->mCell->getGridY())<=1) { // keep cells within the new 3x3 grid ++active; @@ -185,10 +199,10 @@ namespace MWWorld active = mActiveCells.begin(); while (active!=mActiveCells.end()) { - if (!((*active)->cell->mData.mFlags & ESM::Cell::Interior)) + if ((*active)->mCell->isExterior()) { - if (std::abs (X-(*active)->cell->mData.mX)<=1 && - std::abs (Y-(*active)->cell->mData.mY)<=1) + if (std::abs (X-(*active)->mCell->getGridX())<=1 && + std::abs (Y-(*active)->mCell->getGridY())<=1) { // keep cells within the new 3x3 grid ++active; @@ -210,10 +224,10 @@ namespace MWWorld while (iter!=mActiveCells.end()) { - assert (!((*iter)->cell->mData.mFlags & ESM::Cell::Interior)); + assert ((*iter)->mCell->isExterior()); - if (x==(*iter)->cell->mData.mX && - y==(*iter)->cell->mData.mY) + if (x==(*iter)->mCell->getGridX() && + y==(*iter)->mCell->getGridY()) break; ++iter; @@ -232,10 +246,10 @@ namespace MWWorld while (iter!=mActiveCells.end()) { - assert (!((*iter)->cell->mData.mFlags & ESM::Cell::Interior)); + assert ((*iter)->mCell->isExterior()); - if (x==(*iter)->cell->mData.mX && - y==(*iter)->cell->mData.mY) + if (x==(*iter)->mCell->getGridX() && + y==(*iter)->mCell->getGridY()) break; ++iter; @@ -256,10 +270,10 @@ namespace MWWorld while (iter!=mActiveCells.end()) { - assert (!((*iter)->cell->mData.mFlags & ESM::Cell::Interior)); + assert ((*iter)->mCell->isExterior()); - if (X==(*iter)->cell->mData.mX && - Y==(*iter)->cell->mData.mY) + if (X==(*iter)->mCell->getGridX() && + Y==(*iter)->mCell->getGridY()) break; ++iter; @@ -376,26 +390,26 @@ namespace MWWorld void Scene::insertCell (Ptr::CellStore &cell) { // Loop through all references in the cell - insertCellRefList(mRendering, cell.activators, cell, *mPhysics); - insertCellRefList(mRendering, cell.potions, cell, *mPhysics); - insertCellRefList(mRendering, cell.appas, cell, *mPhysics); - insertCellRefList(mRendering, cell.armors, cell, *mPhysics); - insertCellRefList(mRendering, cell.books, cell, *mPhysics); - insertCellRefList(mRendering, cell.clothes, cell, *mPhysics); - insertCellRefList(mRendering, cell.containers, cell, *mPhysics); - insertCellRefList(mRendering, cell.creatures, cell, *mPhysics); - insertCellRefList(mRendering, cell.doors, cell, *mPhysics); - insertCellRefList(mRendering, cell.ingreds, cell, *mPhysics); - insertCellRefList(mRendering, cell.creatureLists, cell, *mPhysics); - insertCellRefList(mRendering, cell.itemLists, cell, *mPhysics); - insertCellRefList(mRendering, cell.lights, cell, *mPhysics); - insertCellRefList(mRendering, cell.lockpicks, cell, *mPhysics); - insertCellRefList(mRendering, cell.miscItems, cell, *mPhysics); - insertCellRefList(mRendering, cell.npcs, cell, *mPhysics); - insertCellRefList(mRendering, cell.probes, cell, *mPhysics); - insertCellRefList(mRendering, cell.repairs, cell, *mPhysics); - insertCellRefList(mRendering, cell.statics, cell, *mPhysics); - insertCellRefList(mRendering, cell.weapons, cell, *mPhysics); + insertCellRefList(mRendering, cell.mActivators, cell, *mPhysics); + insertCellRefList(mRendering, cell.mPotions, cell, *mPhysics); + insertCellRefList(mRendering, cell.mAppas, cell, *mPhysics); + insertCellRefList(mRendering, cell.mArmors, cell, *mPhysics); + insertCellRefList(mRendering, cell.mBooks, cell, *mPhysics); + insertCellRefList(mRendering, cell.mClothes, cell, *mPhysics); + insertCellRefList(mRendering, cell.mContainers, cell, *mPhysics); + insertCellRefList(mRendering, cell.mCreatures, cell, *mPhysics); + insertCellRefList(mRendering, cell.mDoors, cell, *mPhysics); + insertCellRefList(mRendering, cell.mIngreds, cell, *mPhysics); + insertCellRefList(mRendering, cell.mCreatureLists, cell, *mPhysics); + insertCellRefList(mRendering, cell.mItemLists, cell, *mPhysics); + insertCellRefList(mRendering, cell.mLights, cell, *mPhysics); + insertCellRefList(mRendering, cell.mLockpicks, cell, *mPhysics); + insertCellRefList(mRendering, cell.mMiscItems, cell, *mPhysics); + insertCellRefList(mRendering, cell.mNpcs, cell, *mPhysics); + insertCellRefList(mRendering, cell.mProbes, cell, *mPhysics); + insertCellRefList(mRendering, cell.mRepairs, cell, *mPhysics); + insertCellRefList(mRendering, cell.mStatics, cell, *mPhysics); + insertCellRefList(mRendering, cell.mWeapons, cell, *mPhysics); } void Scene::addObjectToScene (const Ptr& ptr) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 391b34a84..7d40e8ed4 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -497,7 +497,7 @@ void WeatherManager::update(float duration) if (exterior) { - std::string regionstr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->mRegion; + std::string regionstr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->mCell->mRegion; boost::algorithm::to_lower(regionstr); if (mWeatherUpdateTime <= 0 || regionstr != mCurrentRegion) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index c7f0de245..1685798a2 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -25,10 +25,10 @@ namespace MWWorld::Ptr::CellStore *cell) { for (typename MWWorld::CellRefList::List::iterator iter ( - cellRefList.list.begin()); - iter!=cellRefList.list.end(); ++iter) + cellRefList.mList.begin()); + iter!=cellRefList.mList.end(); ++iter) { - if (!iter->base->script.empty() && iter->mData.getCount()) + if (!iter->mBase->script.empty() && iter->mData.getCount()) { if (const ESM::Script *script = store.scripts.find (iter->base->script)) { @@ -46,7 +46,7 @@ namespace { typedef typename MWWorld::CellRefList::List::iterator iterator; - for (iterator iter (refList.list.begin()); iter!=refList.list.end(); ++iter) + for (iterator iter (refList.mList.begin()); iter!=refList.mList.end(); ++iter) { if(iter->mData.getCount() > 0 && iter->mData.getBaseNode()){ if (iter->mData.getHandle()==handle) @@ -64,44 +64,44 @@ namespace MWWorld Ptr World::getPtrViaHandle (const std::string& handle, Ptr::CellStore& cell) { if (MWWorld::LiveCellRef *ref = - searchViaHandle (handle, cell.activators)) + searchViaHandle (handle, cell.mActivators)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.potions)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.mPotions)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.appas)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.mAppas)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.armors)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.mArmors)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.books)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.mBooks)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.clothes)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.mClothes)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = - searchViaHandle (handle, cell.containers)) + searchViaHandle (handle, cell.mContainers)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = - searchViaHandle (handle, cell.creatures)) + searchViaHandle (handle, cell.mCreatures)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.doors)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.mDoors)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = - searchViaHandle (handle, cell.ingreds)) + searchViaHandle (handle, cell.mIngreds)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.lights)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.mLights)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.lockpicks)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.mLockpicks)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.miscItems)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.mMiscItems)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.npcs)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.mNpcs)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.probes)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.mProbes)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.repairs)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.mRepairs)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.statics)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.mStatics)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.weapons)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.mWeapons)) return Ptr (ref, &cell); return Ptr(); } @@ -585,10 +585,10 @@ namespace MWWorld if (*currCell != newCell) { if (isPlayer) { if (!newCell.isExterior()) { - changeToInteriorCell(toLower(newCell.cell->mName), pos); + changeToInteriorCell(toLower(newCell.mCell->mName), pos); } else { - int cellX = newCell.cell->mData.mX; - int cellY = newCell.cell->mData.mY; + int cellX = newCell.mCell->getGridX(); + int cellY = newCell.mCell->getGridY(); mWorldScene->changeCell(cellX, cellY, pos, false); } } else { @@ -1033,10 +1033,7 @@ namespace MWWorld Ptr::CellStore *currentCell = mWorldScene->getCurrentCell(); if (currentCell) { - if (!(currentCell->cell->mData.mFlags & ESM::Cell::Interior)) - return true; - else - return false; + return currentCell->mCell->isExterior(); } return false; } @@ -1046,7 +1043,7 @@ namespace MWWorld Ptr::CellStore *currentCell = mWorldScene->getCurrentCell(); if (currentCell) { - if (!(currentCell->cell->mData.mFlags & ESM::Cell::QuasiEx)) + if (!(currentCell->mCell->mData.mFlags & ESM::Cell::QuasiEx)) return false; else return true; @@ -1071,7 +1068,7 @@ namespace MWWorld Ogre::Vector2 World::getNorthVector (CellStore* cell) { - MWWorld::CellRefList& statics = cell->statics; + MWWorld::CellRefList& statics = cell->mStatics; MWWorld::LiveCellRef* ref = statics.find("northmarker"); if (!ref) return Vector2(0, 1); @@ -1085,27 +1082,27 @@ namespace MWWorld { std::vector result; - MWWorld::CellRefList& doors = cell->doors; - std::list< MWWorld::LiveCellRef >& refList = doors.list; + MWWorld::CellRefList& doors = cell->mDoors; + std::list< MWWorld::LiveCellRef >& refList = doors.mList; for (std::list< MWWorld::LiveCellRef >::iterator it = refList.begin(); it != refList.end(); ++it) { MWWorld::LiveCellRef& ref = *it; - if (ref.ref.mTeleport) + if (ref.mRef.mTeleport) { World::DoorMarker newMarker; std::string dest; - if (ref.ref.mDestCell != "") + if (ref.mRef.mDestCell != "") { // door leads to an interior, use interior name - dest = ref.ref.mDestCell; + dest = ref.mRef.mDestCell; } else { // door leads to exterior, use cell name (if any), otherwise translated region name int x,y; - positionToIndex (ref.ref.mDoorDest.pos[0], ref.ref.mDoorDest.pos[1], x, y); + positionToIndex (ref.mRef.mDoorDest.pos[0], ref.mRef.mDoorDest.pos[1], x, y); const ESM::Cell* cell = mStore.cells.findExt(x,y); if (cell->mName != "") dest = cell->mName; @@ -1256,7 +1253,7 @@ namespace MWWorld /// \fixme should rely on object height pos.z += 30; - return isUnderwater(*object.getCell()->cell, pos); + return isUnderwater(*object.getCell()->mCell, pos); } bool @@ -1292,10 +1289,10 @@ namespace MWWorld mPhysics->castRay(playerPos, Ogre::Vector3(0,0,-1), 50); bool isOnGround = (hit.first ? (hit.second.distance (playerPos) < 25) : false); - if (!isOnGround || isUnderwater (*currentCell->cell, playerPos)) + if (!isOnGround || isUnderwater (*currentCell->mCell, playerPos)) return 2; - if (currentCell->cell->mData.mFlags & ESM::Cell::NoSleep) + if (currentCell->mCell->mData.mFlags & ESM::Cell::NoSleep) return 1; return 0; From f0a3ee0ef90b3fbd633c2f1c3dd8e69fca526f31 Mon Sep 17 00:00:00 2001 From: greye Date: Mon, 1 Oct 2012 17:15:16 +0400 Subject: [PATCH 032/107] gmst id should be lowercase, wipe RecIdListT --- components/esm/loadgmst.cpp | 32 ++++++++++-------- components/esm_store/reclists.hpp | 54 ------------------------------- components/esm_store/store.hpp | 2 +- 3 files changed, 19 insertions(+), 69 deletions(-) diff --git a/components/esm/loadgmst.cpp b/components/esm/loadgmst.cpp index dcc500125..14e29f4ae 100644 --- a/components/esm/loadgmst.cpp +++ b/components/esm/loadgmst.cpp @@ -2,6 +2,8 @@ #include +#include + #include "esmreader.hpp" #include "esmwriter.hpp" @@ -12,9 +14,9 @@ namespace ESM /// working properly in its current state and I doubt it can be fixed without breaking other stuff. // Some handy macros -#define cI(s,x) { if(mId == (s)) return (mI == (x)); } -#define cF(s,x) { if(mId == (s)) return (mF == (x)); } -#define cS(s,x) { if(mId == (s)) return (mStr == (x)); } +#define cI(s,x) { label = (s); boost::algorithm::to_lower(label); if (mId == label) return (mI == (x)); } +#define cF(s,x) { label = (s); boost::algorithm::to_lower(label); if (mId == label) return (mF == (x)); } +#define cS(s,x) { label = (s); boost::algorithm::to_lower(label); if (mId == label) return (mStr == (x)); } bool GameSetting::isDirtyTribunal() { @@ -28,6 +30,7 @@ bool GameSetting::isDirtyTribunal() from other mods. */ + std::string label; // Strings cS("sProfitValue", "Profit Value"); // 'Profit:' cS("sEditNote", "Edit Note"); // same @@ -51,13 +54,14 @@ bool GameSetting::isDirtyTribunal() // [The difference here is "Profit Value" -> "Profit"] // Strings that matches the mId - cS("sEffectSummonFabricant", mId);// 'Summon Fabricant' + cS("sEffectSummonFabricant", "sEffectSummonFabricant");// 'Summon Fabricant' return false; } // Bloodmoon variant bool GameSetting::isDirtyBloodmoon() { + std::string label; // Strings cS("sWerewolfPopup", "Werewolf"); // same cS("sWerewolfRestMessage", @@ -69,16 +73,16 @@ bool GameSetting::isDirtyBloodmoon() // 'You have been detected as a known werewolf.' // Strings that matches the mId - cS("sMagicCreature01ID", mId); // 'BM_wolf_grey_summon' - cS("sMagicCreature02ID", mId); // 'BM_bear_black_summon' - cS("sMagicCreature03ID", mId); // 'BM_wolf_bone_summon' - cS("sMagicCreature04ID", mId); // same - cS("sMagicCreature05ID", mId); // same - cS("sEffectSummonCreature01", mId); // 'Calf Wolf' - cS("sEffectSummonCreature02", mId); // 'Calf Bear' - cS("sEffectSummonCreature03", mId); // 'Summon Bonewolf' - cS("sEffectSummonCreature04", mId); // same - cS("sEffectSummonCreature05", mId); // same + cS("sMagicCreature01ID", "sMagicCreature01ID"); // 'BM_wolf_grey_summon' + cS("sMagicCreature02ID", "sMagicCreature02ID"); // 'BM_bear_black_summon' + cS("sMagicCreature03ID", "sMagicCreature03ID"); // 'BM_wolf_bone_summon' + cS("sMagicCreature04ID", "sMagicCreature04ID"); // same + cS("sMagicCreature05ID", "sMagicCreature05ID"); // same + cS("sEffectSummonCreature01", "sEffectSummonCreature01"); // 'Calf Wolf' + cS("sEffectSummonCreature02", "sEffectSummonCreature02"); // 'Calf Bear' + cS("sEffectSummonCreature03", "sEffectSummonCreature03"); // 'Summon Bonewolf' + cS("sEffectSummonCreature04", "sEffectSummonCreature04"); // same + cS("sEffectSummonCreature05", "sEffectSummonCreature05"); // same // Integers cI("iWereWolfBounty", 10000); // 1000 diff --git a/components/esm_store/reclists.hpp b/components/esm_store/reclists.hpp index 0b265a566..d9a764805 100644 --- a/components/esm_store/reclists.hpp +++ b/components/esm_store/reclists.hpp @@ -209,60 +209,6 @@ namespace ESMS } }; - // The only difference to the above is a slight change to the load() - // function. We might merge these together later, and store the id - // in all the structs. - template - struct RecIDListT : RecList - { - virtual ~RecIDListT() {} - - typedef std::map MapType; - - MapType list; - - void load(ESMReader &esm, const std::string &id) - { - std::string id2 = toLower (id); - X& ref = list[id2]; - - ref.mId = id; - ref.load(esm); - } - - // Find the given object ID, or return NULL if not found. - const X* search(const std::string &id) const - { - std::string id2 = toLower (id); - - typename MapType::const_iterator iter = list.find (id2); - - if (iter == list.end()) - return NULL; - - return &iter->second; - } - - // Find the given object ID (throws an exception if not found) - const X* find(const std::string &id) const - { - const X *object = search (id); - - if (!object) - throw std::runtime_error ("object " + id + " not found"); - - return object; - } - - int getSize() { return list.size(); } - - virtual void listIdentifier (std::vector& identifier) const - { - for (typename MapType::const_iterator iter (list.begin()); iter!=list.end(); ++iter) - identifier.push_back (iter->first); - } - }; - /* Land textures are indexed by an integer number */ struct LTexList : RecList diff --git a/components/esm_store/store.hpp b/components/esm_store/store.hpp index 7329386d4..db36afd33 100644 --- a/components/esm_store/store.hpp +++ b/components/esm_store/store.hpp @@ -68,7 +68,7 @@ namespace ESMS // Lists that need special rules CellList cells; - RecIDListT gameSettings; + RecListWithIDT gameSettings; LandList lands; LTexList landTexts; ScriptListT