diff --git a/CMakeLists.txt b/CMakeLists.txt index b83935bdc..84cef306e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ include (OpenMWMacros) # Version set (OPENMW_VERSION_MAJOR 0) -set (OPENMW_VERSION_MINOR 15) +set (OPENMW_VERSION_MINOR 16) set (OPENMW_VERSION_RELEASE 0) set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index ccefee1ee..ed3559fdc 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -8,6 +8,7 @@ set(LAUNCHER playpage.cpp pluginsmodel.cpp pluginsview.cpp + filedialog.cpp launcher.rc ) @@ -22,6 +23,7 @@ set(LAUNCHER_HEADER playpage.hpp pluginsmodel.hpp pluginsview.hpp + filedialog.hpp ) # Headers that must be pre-processed @@ -34,6 +36,7 @@ set(LAUNCHER_HEADER_MOC playpage.hpp pluginsmodel.hpp pluginsview.hpp + filedialog.hpp ) source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER} ${LAUNCHER_HEADER_MOC}) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index c15274e74..8545be835 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -5,6 +5,7 @@ #include "datafilespage.hpp" #include "lineedit.hpp" +#include "filedialog.hpp" #include "naturalsort.hpp" #include "pluginsmodel.hpp" #include "pluginsview.hpp" @@ -139,7 +140,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) createActions(); setupConfig(); - setupDataFiles(); + //setupDataFiles(); } @@ -188,7 +189,7 @@ void DataFilesPage::setupConfig() } -void DataFilesPage::setupDataFiles() +bool DataFilesPage::setupDataFiles() { // We use the Configuration Manager to retrieve the configuration values boost::program_options::variables_map variables; @@ -203,8 +204,7 @@ void DataFilesPage::setupDataFiles() mCfgMgr.readConfiguration(variables, desc); // Put the paths in a boost::filesystem vector to use with Files::Collections - Files::PathContainer dataDirs(variables["data"].as()); - mDataDirs = dataDirs; + mDataDirs = Files::PathContainer(variables["data"].as()); // std::string local = variables["data-local"].as(); // if (!local.empty()) { @@ -212,50 +212,50 @@ void DataFilesPage::setupDataFiles() // dataDirs.push_back(Files::PathContainer::value_type(local)); // } - if (dataDirs.size()>1) - dataDirs.resize (1); + if (mDataDirs.size()>1) + mDataDirs.resize (1); - mCfgMgr.processPaths(dataDirs); - - while (dataDirs.empty()) { - // No valid data files directory found + mCfgMgr.processPaths(mDataDirs); + 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.
")); + 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.addButton(tr("B&rowse..."), QMessageBox::ActionRole); msgBox.exec(); if (msgBox.clickedButton() == dirSelectButton) { - QString dataDir = QFileDialog::getExistingDirectory( - this, tr("Select Data Files Directory"), - "/home", - QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + // 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; + } - dataDirs.push_back(Files::PathContainer::value_type(dataDir.toStdString())); - mDataDirs.push_back(Files::PathContainer::value_type(dataDir.toStdString())); } else { // Cancel - break; + return false; } } - // Check if cancel was clicked because we can't exit from while loop - if (dataDirs.empty()) { - QApplication::exit(1); - return; - } - - // Create a file collection for the dataDirs - Files::Collections fileCollections(dataDirs, !variables["fs-strict"].as()); + // Create a file collection for the data dirs + Files::Collections fileCollections(mDataDirs, !variables["fs-strict"].as()); // First we add all the master files const Files::MultiDirCollection &esm = fileCollections.getCollection(".esm"); @@ -356,6 +356,7 @@ void DataFilesPage::setupDataFiles() } readConfig(); + return true; } void DataFilesPage::createActions() @@ -1057,8 +1058,25 @@ void DataFilesPage::writeConfig(QString profile) 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(QString::fromStdString((mCfgMgr.getUserPath() / "openmw.cfg").string())); + QFile file(pathStr.append("openmw.cfg")); if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { // File cannot be opened or created @@ -1067,10 +1085,10 @@ void DataFilesPage::writeConfig(QString profile) 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())); + Please make sure you have the right permissions and try again.
").arg(file.fileName())); msgBox.exec(); - qApp->exit(1); + qApp->quit(); return; } @@ -1098,10 +1116,10 @@ void DataFilesPage::writeConfig(QString profile) 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())); + Please make sure you have the right permissions and try again.
").arg(file.fileName())); msgBox.exec(); - qApp->exit(1); + qApp->quit(); return; } diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index ad5e90511..5078f6428 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -34,6 +34,7 @@ public: ComboBox *mProfilesComboBox; void writeConfig(QString profile = QString()); + bool setupDataFiles(); public slots: void masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); @@ -92,7 +93,6 @@ private: void removePlugins(const QModelIndex &index); void uncheckPlugins(); void createActions(); - void setupDataFiles(); void setupConfig(); void readConfig(); void scrollToSelection(); diff --git a/apps/launcher/filedialog.cpp b/apps/launcher/filedialog.cpp new file mode 100644 index 000000000..16d677533 --- /dev/null +++ b/apps/launcher/filedialog.cpp @@ -0,0 +1,57 @@ +#include "filedialog.hpp" +#include +#include + +FileDialog::FileDialog(QWidget *parent) + : QFileDialog(parent) +{ + // Remove the default Choose button to prevent it being updated elsewhere + QDialogButtonBox *box = qFindChild(this); + Q_ASSERT(box); + box->removeButton(box->button(QDialogButtonBox::Open)); + + // Add our own button so we can disable/enable it + mChooseButton = new QPushButton(tr("&Choose")); + mChooseButton->setIcon(QIcon::fromTheme("document-open")); + mChooseButton->setEnabled(false); + box->addButton(mChooseButton, QDialogButtonBox::AcceptRole); + + connect(this, SIGNAL(directoryEntered(const QString&)), this, SLOT(updateChooseButton(const QString&))); + emit directoryEntered(QDir::currentPath()); +} + +QString FileDialog::getExistingDirectory(QWidget *parent, + const QString &caption, + const QString &dir, + Options options) +{ + // create a non-native file dialog + FileDialog dialog; + dialog.setFileMode(DirectoryOnly); + dialog.setOptions(options |= QFileDialog::DontUseNativeDialog | QFileDialog::ShowDirsOnly | QFileDialog::ReadOnly); + + if (!caption.isEmpty()) + dialog.setWindowTitle(caption); + + if (!dir.isEmpty()) + dialog.setDirectory(dir); + + if (dialog.exec() == QDialog::Accepted) { + return dialog.selectedFiles().value(0); + } + return QString(); +} + +void FileDialog::updateChooseButton(const QString &directory) +{ + QDir currentDir = QDir(directory); + currentDir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); + currentDir.setNameFilters(QStringList() << "*.esm" << "*.esp"); + + if (!currentDir.entryList().isEmpty()) { + // There are data files in the current dir + mChooseButton->setEnabled(true); + } else { + mChooseButton->setEnabled(false); + } +} diff --git a/apps/launcher/filedialog.hpp b/apps/launcher/filedialog.hpp new file mode 100644 index 000000000..7a161ecb9 --- /dev/null +++ b/apps/launcher/filedialog.hpp @@ -0,0 +1,28 @@ +#ifndef FILEDIALOG_HPP +#define FILEDIALOG_HPP + +#include + +class QPushButton; + +class FileDialog : public QFileDialog +{ + Q_OBJECT + +public: + FileDialog(QWidget *parent = 0); + + static QString getExistingDirectory(QWidget *parent = 0, + const QString &caption = QString(), + const QString &dir = QString(), + Options options = ShowDirsOnly); + +private slots: + void updateChooseButton(const QString &directory); + +private: + QPushButton *mChooseButton; +}; + + +#endif // FILEDIALOG_HPP diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index e156e4fbc..fb798fee8 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -1,12 +1,25 @@ -#include "graphicspage.hpp" - #include -#include +#include #include #include +#include "graphicspage.hpp" +#include "naturalsort.hpp" + +QString getAspect(int x, int y) +{ + int gcd = boost::math::gcd (x, y); + int xaspect = x / gcd; + int yaspect = y / gcd; + // special case: 8 : 5 is usually referred to as 16:10 + if (xaspect == 8 && yaspect == 5) + return QString("16:10"); + + return QString(QString::number(xaspect) + ":" + QString::number(yaspect)); +} + GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, QWidget *parent) : QWidget(parent) , mCfgMgr(cfg) @@ -21,68 +34,41 @@ GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, QWidget *parent) renderSystemLayout->addWidget(rendererLabel, 0, 0, 1, 1); renderSystemLayout->addWidget(mRendererComboBox, 0, 1, 1, 1); - QVBoxLayout *rendererGroupLayout = new QVBoxLayout(rendererGroup); - - rendererGroupLayout->addLayout(renderSystemLayout); - // Display QGroupBox *displayGroup = new QGroupBox(tr("Display"), this); - mDisplayStackedWidget = new QStackedWidget(displayGroup); + mVSyncCheckBox = new QCheckBox(tr("Vertical Sync"), displayGroup); + mFullScreenCheckBox = new QCheckBox(tr("Full Screen"), displayGroup); - QVBoxLayout *displayGroupLayout = new QVBoxLayout(displayGroup); - QSpacerItem *vSpacer3 = new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Expanding); + QLabel *antiAliasingLabel = new QLabel(tr("Antialiasing:"), displayGroup); + QLabel *resolutionLabel = new QLabel(tr("Resolution:"), displayGroup); - displayGroupLayout->addWidget(mDisplayStackedWidget); - displayGroupLayout->addItem(vSpacer3); + mResolutionComboBox = new QComboBox(displayGroup); + mAntiAliasingComboBox = new QComboBox(displayGroup); + + QVBoxLayout *rendererGroupLayout = new QVBoxLayout(rendererGroup); + rendererGroupLayout->addLayout(renderSystemLayout); + + QGridLayout *displayGroupLayout = new QGridLayout(displayGroup); + displayGroupLayout->addWidget(mVSyncCheckBox, 0, 0, 1, 1); + displayGroupLayout->addWidget(mFullScreenCheckBox, 1, 0, 1, 1); + displayGroupLayout->addWidget(antiAliasingLabel, 2, 0, 1, 1); + displayGroupLayout->addWidget(mAntiAliasingComboBox, 2, 1, 1, 1); + displayGroupLayout->addWidget(resolutionLabel, 3, 0, 1, 1); + displayGroupLayout->addWidget(mResolutionComboBox, 3, 1, 1, 1); // Layout for the whole page QVBoxLayout *pageLayout = new QVBoxLayout(this); + QSpacerItem *vSpacer1 = new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Expanding); pageLayout->addWidget(rendererGroup); pageLayout->addWidget(displayGroup); + pageLayout->addItem(vSpacer1); connect(mRendererComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&))); - - createPages(); - setupConfig(); - setupOgre(); - - readConfig(); } -void GraphicsPage::createPages() -{ - QWidget *main = new QWidget(); - QGridLayout *grid = new QGridLayout(main); - - mVSyncCheckBox = new QCheckBox(tr("Vertical Sync"), main); - grid->addWidget(mVSyncCheckBox, 0, 0, 1, 1); - - mFullScreenCheckBox = new QCheckBox(tr("Full Screen"), main); - grid->addWidget(mFullScreenCheckBox, 1, 0, 1, 1); - - QLabel *antiAliasingLabel = new QLabel(tr("Antialiasing:"), main); - mAntiAliasingComboBox = new QComboBox(main); - grid->addWidget(antiAliasingLabel, 2, 0, 1, 1); - grid->addWidget(mAntiAliasingComboBox, 2, 1, 1, 1); - - QLabel *resolutionLabel = new QLabel(tr("Resolution:"), main); - mResolutionComboBox = new QComboBox(main); - grid->addWidget(resolutionLabel, 3, 0, 1, 1); - grid->addWidget(mResolutionComboBox, 3, 1, 1, 1); - - QSpacerItem *vSpacer1 = new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Expanding); - grid->addItem(vSpacer1, 4, 0, 1, 1); - - mDisplayStackedWidget->addWidget(main); -} - -void GraphicsPage::setupConfig() -{ -} - -void GraphicsPage::setupOgre() +bool GraphicsPage::setupOgre() { QString pluginCfg = mCfgMgr.getPluginsConfigPath().string().c_str(); QFile file(pluginCfg); @@ -93,11 +79,11 @@ void GraphicsPage::setupOgre() try { - #if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) +#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) mOgre = new Ogre::Root("", "", "./launcherOgre.log"); - #else +#else mOgre = new Ogre::Root(pluginCfg.toStdString(), "", "./launcherOgre.log"); - #endif +#endif } catch(Ogre::Exception &ex) { @@ -113,19 +99,17 @@ void GraphicsPage::setupOgre() msgBox.exec(); qCritical("Error creating Ogre::Root, the error reported was:\n %s", qPrintable(ogreError)); - - qApp->exit(1); - return; + return false; } - #ifdef ENABLE_PLUGIN_GL - mGLPlugin = new Ogre::GLPlugin(); - mOgre->installPlugin(mGLPlugin); - #endif - #ifdef ENABLE_PLUGIN_Direct3D9 - mD3D9Plugin = new Ogre::D3D9Plugin(); - mOgre->installPlugin(mD3D9Plugin); - #endif +#ifdef ENABLE_PLUGIN_GL + mGLPlugin = new Ogre::GLPlugin(); + mOgre->installPlugin(mGLPlugin); +#endif +#ifdef ENABLE_PLUGIN_Direct3D9 + mD3D9Plugin = new Ogre::D3D9Plugin(); + mOgre->installPlugin(mD3D9Plugin); +#endif // Get the available renderers and put them in the combobox const Ogre::RenderSystemList &renderers = mOgre->getAvailableRenderers(); @@ -135,6 +119,26 @@ void GraphicsPage::setupOgre() mRendererComboBox->addItem((*r)->getName().c_str()); } + QString openGLName = QString("OpenGL Rendering Subsystem"); + QString direct3DName = QString("Direct3D9 Rendering Subsystem"); + + // Create separate rendersystems + mOpenGLRenderSystem = mOgre->getRenderSystemByName(openGLName.toStdString()); + mDirect3DRenderSystem = mOgre->getRenderSystemByName(direct3DName.toStdString()); + + if (!mOpenGLRenderSystem && !mDirect3DRenderSystem) { + QMessageBox msgBox; + msgBox.setWindowTitle(tr("Error creating renderer")); + msgBox.setIcon(QMessageBox::Critical); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setText(tr("
Could not select a valid render system

\ + Please make sure the plugins.cfg file exists and contains a valid rendering plugin.
")); + msgBox.exec(); + + return false; + } + + // Now fill the GUI elements int index = mRendererComboBox->findText(QString::fromStdString(Settings::Manager::getString("render system", "Video"))); if ( index != -1) { @@ -143,37 +147,19 @@ void GraphicsPage::setupOgre() else { #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 - mRendererComboBox->setCurrentIndex(mRendererComboBox->findText("Direct3D9 Rendering Subsystem")); + mRendererComboBox->setCurrentIndex(mRendererComboBox->findText(direct3DName)); #else - mRendererComboBox->setCurrentIndex(mRendererComboBox->findText("OpenGL Rendering Subsystem")); + mRendererComboBox->setCurrentIndex(mRendererComboBox->findText(openGLName)); #endif } - // Create separate rendersystems - QString openGLName = mRendererComboBox->itemText(mRendererComboBox->findText(QString("OpenGL"), Qt::MatchStartsWith)); - QString direct3DName = mRendererComboBox->itemText(mRendererComboBox->findText(QString("Direct3D"), Qt::MatchStartsWith)); - - mOpenGLRenderSystem = mOgre->getRenderSystemByName(openGLName.toStdString()); - mDirect3DRenderSystem = mOgre->getRenderSystemByName(direct3DName.toStdString()); - - if (!mOpenGLRenderSystem && !mDirect3DRenderSystem) { - QMessageBox msgBox; - msgBox.setWindowTitle("Error creating renderer"); - msgBox.setIcon(QMessageBox::Critical); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setText(tr("
Could not select a valid render system

\ - Please make sure the plugins.cfg file exists and contains a valid rendering plugin.
")); - msgBox.exec(); - - qApp->exit(1); - return; - } - - // Now fill the GUI elements mAntiAliasingComboBox->clear(); mResolutionComboBox->clear(); mAntiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem)); - mResolutionComboBox->addItems(getAvailableOptions(QString("Video Mode"), mSelectedRenderSystem)); + mResolutionComboBox->addItems(getAvailableResolutions(mSelectedRenderSystem)); + + readConfig(); + return true; } void GraphicsPage::readConfig() @@ -188,9 +174,10 @@ void GraphicsPage::readConfig() if (aaIndex != -1) mAntiAliasingComboBox->setCurrentIndex(aaIndex); - std::string resolution = boost::lexical_cast(Settings::Manager::getInt("resolution x", "Video")) - + " x " + boost::lexical_cast(Settings::Manager::getInt("resolution y", "Video")); - int resIndex = mResolutionComboBox->findText(QString::fromStdString(resolution)); + QString resolution = QString::number(Settings::Manager::getInt("resolution x", "Video")); + resolution.append(" x " + QString::number(Settings::Manager::getInt("resolution y", "Video"))); + + int resIndex = mResolutionComboBox->findText(resolution, Qt::MatchStartsWith); if (resIndex != -1) mResolutionComboBox->setCurrentIndex(resIndex); } @@ -200,12 +187,14 @@ void GraphicsPage::writeConfig() Settings::Manager::setBool("vsync", "Video", mVSyncCheckBox->checkState()); Settings::Manager::setBool("fullscreen", "Video", mFullScreenCheckBox->checkState()); Settings::Manager::setString("antialiasing", "Video", mAntiAliasingComboBox->currentText().toStdString()); + Settings::Manager::setString("render system", "Video", mRendererComboBox->currentText().toStdString()); - std::string resolution = mResolutionComboBox->currentText().toStdString(); - // parse resolution x and y from a string like "800 x 600" - size_t xPos = resolution.find("x"); - int resX = boost::lexical_cast(resolution.substr(0, xPos-1)); - int resY = boost::lexical_cast(resolution.substr(xPos+2, resolution.size()-(xPos+2))); + // Get the current resolution, but with the tabs replaced with a single space + QString resolution = mResolutionComboBox->currentText().simplified(); + QStringList tokens = resolution.split(" ", QString::SkipEmptyParts); + + int resX = tokens.at(0).toInt(); + int resY = tokens.at(2).toInt(); Settings::Manager::setInt("resolution x", "Video", resX); Settings::Manager::setInt("resolution y", "Video", resY); } @@ -227,15 +216,69 @@ QStringList GraphicsPage::getAvailableOptions(const QString &key, Ogre::RenderSy if (strcmp (key.toStdString().c_str(), i->first.c_str()) == 0) { - if (key == "FSAA" && *opt_it == "0") - result << QString("none"); - else - result << ((key == "FSAA") ? QString("MSAA ") : QString("")) + QString::fromStdString((*opt_it).c_str()).simplified(); + result << ((key == "FSAA") ? QString("MSAA ") : QString("")) + QString::fromStdString((*opt_it).c_str()).simplified(); } } } + // Sort ascending + qSort(result.begin(), result.end(), naturalSortLessThanCI); + + // Replace the zero option with Off + int index = result.indexOf("MSAA 0"); + + if (index != -1) + result.replace(index, tr("Off")); + + return result; +} + +QStringList GraphicsPage::getAvailableResolutions(Ogre::RenderSystem *renderer) +{ + QString key ("Video Mode"); + QStringList result; + + uint row = 0; + Ogre::ConfigOptionMap options = renderer->getConfigOptions(); + + for (Ogre::ConfigOptionMap::iterator i = options.begin (); i != options.end (); i++, row++) + { + if (key.toStdString() != i->first) + continue; + + Ogre::StringVector::iterator opt_it; + uint idx = 0; + + for (opt_it = i->second.possibleValues.begin (); + opt_it != i->second.possibleValues.end (); opt_it++, idx++) + { + QString qval = QString::fromStdString(*opt_it).simplified(); + // remove extra tokens after the resolution (for example bpp, can be there or not depending on rendersystem) + QStringList tokens = qval.split(" ", QString::SkipEmptyParts); + 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()); + + 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)")); + } + + result << resolutionStr; + } + } + } + + // Sort the resolutions in descending order + qSort(result.begin(), result.end(), naturalSortGreaterThanCI); + return result; } @@ -247,5 +290,5 @@ void GraphicsPage::rendererChanged(const QString &renderer) mResolutionComboBox->clear(); mAntiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem)); - mResolutionComboBox->addItems(getAvailableOptions(QString("Video Mode"), mSelectedRenderSystem)); + mResolutionComboBox->addItems(getAvailableResolutions(mSelectedRenderSystem)); } diff --git a/apps/launcher/graphicspage.hpp b/apps/launcher/graphicspage.hpp index 1b0c6f388..b8166f672 100644 --- a/apps/launcher/graphicspage.hpp +++ b/apps/launcher/graphicspage.hpp @@ -30,6 +30,7 @@ class GraphicsPage : public QWidget public: GraphicsPage(Files::ConfigurationManager &cfg, QWidget *parent = 0); + bool setupOgre(); void writeConfig(); public slots: @@ -59,10 +60,9 @@ private: Files::ConfigurationManager &mCfgMgr; QStringList getAvailableOptions(const QString &key, Ogre::RenderSystem *renderer); + QStringList getAvailableResolutions(Ogre::RenderSystem *renderer); void createPages(); - void setupConfig(); - void setupOgre(); void readConfig(); }; diff --git a/apps/launcher/lineedit.cpp b/apps/launcher/lineedit.cpp index 254c09fce..dac196425 100644 --- a/apps/launcher/lineedit.cpp +++ b/apps/launcher/lineedit.cpp @@ -1,12 +1,3 @@ -/**************************************************************************** -** -** Copyright (c) 2007 Trolltech ASA -** -** Use, modification and distribution is allowed without limitation, -** warranty, liability or support of any kind. -** -****************************************************************************/ - #include "lineedit.hpp" #include #include @@ -14,33 +5,33 @@ LineEdit::LineEdit(QWidget *parent) : QLineEdit(parent) { - clearButton = new QToolButton(this); + mClearButton = new QToolButton(this); QPixmap pixmap(":images/clear.png"); - clearButton->setIcon(QIcon(pixmap)); - clearButton->setIconSize(pixmap.size()); - clearButton->setCursor(Qt::ArrowCursor); - clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }"); - clearButton->hide(); - connect(clearButton, SIGNAL(clicked()), this, SLOT(clear())); + mClearButton->setIcon(QIcon(pixmap)); + mClearButton->setIconSize(pixmap.size()); + mClearButton->setCursor(Qt::ArrowCursor); + mClearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }"); + mClearButton->hide(); + connect(mClearButton, SIGNAL(clicked()), this, SLOT(clear())); connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&))); int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - setStyleSheet(QString("QLineEdit { padding-right: %1px; } ").arg(clearButton->sizeHint().width() + frameWidth + 1)); + setStyleSheet(QString("QLineEdit { padding-right: %1px; } ").arg(mClearButton->sizeHint().width() + frameWidth + 1)); QSize msz = minimumSizeHint(); - setMinimumSize(qMax(msz.width(), clearButton->sizeHint().height() + frameWidth * 2 + 2), - qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2)); + setMinimumSize(qMax(msz.width(), mClearButton->sizeHint().height() + frameWidth * 2 + 2), + qMax(msz.height(), mClearButton->sizeHint().height() + frameWidth * 2 + 2)); } void LineEdit::resizeEvent(QResizeEvent *) { - QSize sz = clearButton->sizeHint(); + QSize sz = mClearButton->sizeHint(); int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - clearButton->move(rect().right() - frameWidth - sz.width(), + mClearButton->move(rect().right() - frameWidth - sz.width(), (rect().bottom() + 1 - sz.height())/2); } void LineEdit::updateCloseButton(const QString& text) { - clearButton->setVisible(!text.isEmpty()); + mClearButton->setVisible(!text.isEmpty()); } diff --git a/apps/launcher/lineedit.hpp b/apps/launcher/lineedit.hpp index 7a96a523c..2ed76d6eb 100644 --- a/apps/launcher/lineedit.hpp +++ b/apps/launcher/lineedit.hpp @@ -28,7 +28,7 @@ private slots: void updateCloseButton(const QString &text); private: - QToolButton *clearButton; + QToolButton *mClearButton; }; #endif // LIENEDIT_H diff --git a/apps/launcher/main.cpp b/apps/launcher/main.cpp index bd29e2bca..4ae09f844 100644 --- a/apps/launcher/main.cpp +++ b/apps/launcher/main.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include "maindialog.hpp" @@ -31,8 +30,14 @@ int main(int argc, char *argv[]) QDir::setCurrent(dir.absolutePath()); - MainDialog dialog; - return dialog.exec(); + MainDialog mainWin; + if (mainWin.setup()) { + + mainWin.show(); + return app.exec(); + } + + return 0; } diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index d404fed8e..f7dafd3af 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -7,29 +7,10 @@ MainDialog::MainDialog() { - // Create the settings manager and load default settings file - const std::string localdefault = mCfgMgr.getLocalPath().string() + "/settings-default.cfg"; - const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "/settings-default.cfg"; + QWidget *centralWidget = new QWidget(this); + setCentralWidget(centralWidget); - // prefer local - if (boost::filesystem::exists(localdefault)) - mSettings.loadDefault(localdefault); - else if (boost::filesystem::exists(globaldefault)) - mSettings.loadDefault(globaldefault); - else - throw std::runtime_error ("No default settings file found! Make sure the file \"settings-default.cfg\" was properly installed."); - - // load user settings if they exist, otherwise just load the default settings as user settings - const std::string settingspath = mCfgMgr.getUserPath().string() + "/settings.cfg"; - if (boost::filesystem::exists(settingspath)) - mSettings.loadUser(settingspath); - else if (boost::filesystem::exists(localdefault)) - mSettings.loadUser(localdefault); - else if (boost::filesystem::exists(globaldefault)) - mSettings.loadUser(globaldefault); - - - mIconWidget = new QListWidget; + mIconWidget = new QListWidget(centralWidget); mIconWidget->setObjectName("IconWidget"); mIconWidget->setViewMode(QListView::IconMode); mIconWidget->setWrapping(false); @@ -43,7 +24,7 @@ MainDialog::MainDialog() mIconWidget->setCurrentRow(0); mIconWidget->setFlow(QListView::LeftToRight); - QGroupBox *groupBox = new QGroupBox(this); + QGroupBox *groupBox = new QGroupBox(centralWidget); QVBoxLayout *groupLayout = new QVBoxLayout(groupBox); mPagesWidget = new QStackedWidget(groupBox); @@ -51,16 +32,15 @@ MainDialog::MainDialog() QPushButton *playButton = new QPushButton(tr("Play")); - QDialogButtonBox *buttonBox = new QDialogButtonBox(this); + QDialogButtonBox *buttonBox = new QDialogButtonBox(centralWidget); buttonBox->setStandardButtons(QDialogButtonBox::Close); buttonBox->addButton(playButton, QDialogButtonBox::AcceptRole); - QVBoxLayout *dialogLayout = new QVBoxLayout(this); + QVBoxLayout *dialogLayout = new QVBoxLayout(centralWidget); dialogLayout->addWidget(mIconWidget); dialogLayout->addWidget(groupBox); dialogLayout->addWidget(buttonBox); - setWindowTitle(tr("OpenMW Launcher")); setWindowIcon(QIcon(":/images/openmw.png")); // Remove what's this? button @@ -70,22 +50,22 @@ MainDialog::MainDialog() // Install the stylesheet font QFile file; QFontDatabase fontDatabase; - + const QStringList fonts = fontDatabase.families(); - + // Check if the font is installed if (!fonts.contains("EB Garamond")) { - + QString font = QString::fromStdString((mCfgMgr.getGlobalDataPath() / "resources/mygui/EBGaramond-Regular.ttf").string()); file.setFileName(font); - + if (!file.exists()) { - font = QString::fromStdString((mCfgMgr.getLocalPath() / "resources/mygui/EBGaramond-Regular.ttf").string()); + font = QString::fromStdString((mCfgMgr.getLocalPath() / "resources/mygui/EBGaramond-Regular.ttf").string()); } - + fontDatabase.addApplicationFont(font); } - + // Load the stylesheet QString config = QString::fromStdString((mCfgMgr.getGlobalDataPath() / "resources/launcher.qss").string()); file.setFileName(config); @@ -99,7 +79,6 @@ MainDialog::MainDialog() qApp->setStyleSheet(styleSheet); file.close(); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); connect(buttonBox, SIGNAL(accepted()), this, SLOT(play())); @@ -170,6 +149,53 @@ void MainDialog::createPages() } + +bool MainDialog::setup() +{ + // Create the settings manager and load default settings file + const std::string localdefault = (mCfgMgr.getLocalPath() / "settings-default.cfg").string(); + const std::string globaldefault = (mCfgMgr.getGlobalPath() / "settings-default.cfg").string(); + + // prefer local + if (boost::filesystem::exists(localdefault)) { + mSettings.loadDefault(localdefault); + } else if (boost::filesystem::exists(globaldefault)) { + mSettings.loadDefault(globaldefault); + } else { + QMessageBox msgBox; + msgBox.setWindowTitle("Error reading OpenMW configuration file"); + msgBox.setIcon(QMessageBox::Critical); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setText(tr("
Could not find %0

\ + The problem may be due to an incomplete installation of OpenMW.
\ + Reinstalling OpenMW may resolve the problem.").arg(QString::fromStdString(globaldefault))); + msgBox.exec(); + return false; + } + + // load user settings if they exist, otherwise just load the default settings as user settings + const std::string settingspath = (mCfgMgr.getUserPath() / "settings.cfg").string(); + + if (boost::filesystem::exists(settingspath)) + mSettings.loadUser(settingspath); + else if (boost::filesystem::exists(localdefault)) + mSettings.loadUser(localdefault); + else if (boost::filesystem::exists(globaldefault)) + mSettings.loadUser(globaldefault); + + // Setup the Graphics page + if (!mGraphicsPage->setupOgre()) { + return false; + } + + // Setup the Data Files page + if (!mDataFilesPage->setupDataFiles()) { + return false; + } + + return true; +} + void MainDialog::profileChanged(int index) { // Just to be sure, should always have a selection @@ -202,7 +228,7 @@ void MainDialog::closeEvent(QCloseEvent *event) mGraphicsPage->writeConfig(); // Save user settings - const std::string settingspath = mCfgMgr.getUserPath().string() + "/settings.cfg"; + const std::string settingspath = (mCfgMgr.getUserPath() / "settings.cfg").string(); mSettings.saveUser(settingspath); event->accept(); @@ -214,6 +240,10 @@ void MainDialog::play() mDataFilesPage->writeConfig(); mGraphicsPage->writeConfig(); + // Save user settings + const std::string settingspath = (mCfgMgr.getUserPath() / "settings.cfg").string(); + mSettings.saveUser(settingspath); + #ifdef Q_WS_WIN QString game = "./openmw.exe"; QFile file(game); @@ -246,7 +276,7 @@ void MainDialog::play() if (!info.isExecutable()) { QMessageBox msgBox; msgBox.setWindowTitle("Error starting OpenMW"); - msgBox.setIcon(QMessageBox::Critical); + msgBox.setIcon(QMessageBox::Warning); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setText(tr("
Could not start OpenMW

\ The OpenMW application is not executable.
\ @@ -270,6 +300,7 @@ void MainDialog::play() return; } else { - close(); + qApp->quit(); } } + diff --git a/apps/launcher/maindialog.hpp b/apps/launcher/maindialog.hpp index 0065aa8c4..683cd58c2 100644 --- a/apps/launcher/maindialog.hpp +++ b/apps/launcher/maindialog.hpp @@ -1,7 +1,7 @@ #ifndef MAINDIALOG_H #define MAINDIALOG_H -#include +#include #include #include @@ -17,7 +17,7 @@ class PlayPage; class GraphicsPage; class DataFilesPage; -class MainDialog : public QDialog +class MainDialog : public QMainWindow { Q_OBJECT @@ -28,6 +28,7 @@ public slots: void changePage(QListWidgetItem *current, QListWidgetItem *previous); void play(); void profileChanged(int index); + bool setup(); private: void createIcons(); diff --git a/apps/launcher/naturalsort.cpp b/apps/launcher/naturalsort.cpp index 648038ed7..50d1e77de 100644 --- a/apps/launcher/naturalsort.cpp +++ b/apps/launcher/naturalsort.cpp @@ -93,3 +93,13 @@ bool naturalSortLessThanCI( const QString &left, const QString &right ) { return (naturalCompare( left, right, Qt::CaseInsensitive ) < 0); } + +bool naturalSortGreaterThanCS( const QString &left, const QString &right ) +{ + return (naturalCompare( left, right, Qt::CaseSensitive ) > 0); +} + +bool naturalSortGreaterThanCI( const QString &left, const QString &right ) +{ + return (naturalCompare( left, right, Qt::CaseInsensitive ) > 0); +} diff --git a/apps/launcher/naturalsort.hpp b/apps/launcher/naturalsort.hpp index 2d314396f..59271547a 100644 --- a/apps/launcher/naturalsort.hpp +++ b/apps/launcher/naturalsort.hpp @@ -5,5 +5,7 @@ bool naturalSortLessThanCS( const QString &left, const QString &right ); bool naturalSortLessThanCI( const QString &left, const QString &right ); +bool naturalSortGreaterThanCS( const QString &left, const QString &right ); +bool naturalSortGreaterThanCI( const QString &left, const QString &right ); -#endif \ No newline at end of file +#endif diff --git a/apps/launcher/pluginsview.cpp b/apps/launcher/pluginsview.cpp index 27af45c56..26cf337fb 100644 --- a/apps/launcher/pluginsview.cpp +++ b/apps/launcher/pluginsview.cpp @@ -1,4 +1,3 @@ -#include #include #include "pluginsview.hpp" diff --git a/apps/launcher/resources/images/openmw-header.png b/apps/launcher/resources/images/openmw-header.png index a2ffab68b..82223e7fa 100644 Binary files a/apps/launcher/resources/images/openmw-header.png and b/apps/launcher/resources/images/openmw-header.png differ diff --git a/apps/launcher/resources/images/playpage-background.png b/apps/launcher/resources/images/playpage-background.png index 0116adc0f..ccd36d029 100644 Binary files a/apps/launcher/resources/images/playpage-background.png and b/apps/launcher/resources/images/playpage-background.png differ diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 045f504a7..9534ecc90 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -47,10 +47,10 @@ add_openmw_dir (mwsound ) add_openmw_dir (mwworld - refdata world physicssystem scene globals class action nullaction actionteleport + refdata worldimp physicssystem scene globals class action nullaction actionteleport containerstore actiontalk actiontake manualref player cellfunctors cells localscripts customdata weather inventorystore ptr actionopen actionread - actionequip timestamp actionalchemy + actionequip timestamp actionalchemy cellstore ) add_openmw_dir (mwclass @@ -64,7 +64,7 @@ add_openmw_dir (mwmechanics ) add_openmw_dir (mwbase - environment + environment world ) # Main executable diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index e192b1f88..45b4ab514 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -15,7 +15,6 @@ #include #include -#include #include #include #include @@ -39,9 +38,10 @@ #include "mwsound/soundmanager.hpp" -#include "mwworld/world.hpp" #include "mwworld/class.hpp" #include "mwworld/player.hpp" +#include "mwworld/cellstore.hpp" +#include "mwworld/worldimp.hpp" #include "mwclass/classes.hpp" @@ -51,6 +51,7 @@ #include "mwmechanics/mechanicsmanager.hpp" #include "mwbase/environment.hpp" +#include "mwbase/world.hpp" void OMW::Engine::executeLocalScripts() @@ -126,9 +127,9 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) // update GUI Ogre::RenderWindow* window = mOgre->getWindow(); - MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), - window->getTriangleCount(), - window->getBatchCount()); + unsigned int tri, batch; + MWBase::Environment::get().getWorld()->getTriangleBatchCount(tri, batch); + MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), tri, batch); MWBase::Environment::get().getWindowManager()->onFrame(evt.timeSinceLastFrame); } diff --git a/apps/openmw/mwbase/environment.cpp b/apps/openmw/mwbase/environment.cpp index 792e240f4..7218f22eb 100644 --- a/apps/openmw/mwbase/environment.cpp +++ b/apps/openmw/mwbase/environment.cpp @@ -9,13 +9,13 @@ #include "../mwsound/soundmanager.hpp" -#include "../mwworld/world.hpp" - #include "../mwdialogue/dialoguemanager.hpp" #include "../mwdialogue/journal.hpp" #include "../mwmechanics/mechanicsmanager.hpp" +#include "world.hpp" + MWBase::Environment *MWBase::Environment::sThis = 0; MWBase::Environment::Environment() @@ -32,7 +32,7 @@ MWBase::Environment::~Environment() sThis = 0; } -void MWBase::Environment::setWorld (MWWorld::World *world) +void MWBase::Environment::setWorld (World *world) { mWorld = world; } @@ -77,7 +77,7 @@ void MWBase::Environment::setFrameDuration (float duration) mFrameDuration = duration; } -MWWorld::World *MWBase::Environment::getWorld() const +MWBase::World *MWBase::Environment::getWorld() const { assert (mWorld); return mWorld; diff --git a/apps/openmw/mwbase/environment.hpp b/apps/openmw/mwbase/environment.hpp index 521beee0a..ad5a6f655 100644 --- a/apps/openmw/mwbase/environment.hpp +++ b/apps/openmw/mwbase/environment.hpp @@ -32,13 +32,10 @@ namespace MWInput struct MWInputManager; } -namespace MWWorld -{ - class World; -} - namespace MWBase { + class World; + /// \brief Central hub for mw-subsystems /// /// This class allows each mw-subsystem to access any others subsystem's top-level manager class. @@ -49,7 +46,7 @@ namespace MWBase { static Environment *sThis; - MWWorld::World *mWorld; + World *mWorld; MWSound::SoundManager *mSoundManager; MWScript::ScriptManager *mScriptManager; MWGui::WindowManager *mWindowManager; @@ -71,7 +68,7 @@ namespace MWBase ~Environment(); - void setWorld (MWWorld::World *world); + void setWorld (World *world); void setSoundManager (MWSound::SoundManager *soundManager); @@ -90,7 +87,7 @@ namespace MWBase void setFrameDuration (float duration); ///< Set length of current frame in seconds. - MWWorld::World *getWorld() const; + World *getWorld() const; MWSound::SoundManager *getSoundManager() const; diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp new file mode 100644 index 000000000..b2c19ab35 --- /dev/null +++ b/apps/openmw/mwbase/world.hpp @@ -0,0 +1,245 @@ +#ifndef GAME_MWBASE_WORLD_H +#define GAME_MWBASE_WORLD_H + +#include +#include +#include + +#include + +#include "../mwworld/globals.hpp" + +namespace Ogre +{ + class Vector2; + class Vector3; +} + +namespace OEngine +{ + namespace Render + { + class Fader; + } +} + +namespace ESM +{ + class ESMReader; + struct Position; + struct Cell; + struct Class; + struct Potion; +} + +namespace ESMS +{ + struct ESMStore; +} + +namespace MWWorld +{ + class CellStore; + class Player; + class LocalScripts; + class Ptr; + class TimeStamp; +} + +namespace MWBase +{ + class World + { + World (const World&); + ///< not implemented + + World& operator= (const World&); + ///< not implemented + + public: + + enum RenderMode + { + Render_CollisionDebug, + Render_Wireframe, + Render_Pathgrid, + Render_Compositors + }; + + World() {} + + virtual ~World() {} + + virtual OEngine::Render::Fader* getFader() = 0; + ///< \ŧodo remove this function. Rendering details should not be exposed. + + virtual MWWorld::CellStore *getExterior (int x, int y) = 0; + + virtual MWWorld::CellStore *getInterior (const std::string& name) = 0; + + virtual void setWaterHeight(const float height) = 0; + + virtual void toggleWater() = 0; + + virtual void adjustSky() = 0; + + virtual void getTriangleBatchCount(unsigned int &triangles, unsigned int &batches) = 0; + + virtual void setFallbackValues (const std::map& fallbackMap) = 0; + + virtual std::string getFallback (const std::string& key) const = 0; + + virtual std::string getFallback (const std::string& key, const std::string& def) const = 0; + + virtual MWWorld::Player& getPlayer() = 0; + + virtual const ESMS::ESMStore& getStore() const = 0; + + virtual ESM::ESMReader& getEsmReader() = 0; + + virtual MWWorld::LocalScripts& getLocalScripts() = 0; + + virtual bool hasCellChanged() const = 0; + ///< Has the player moved to a different cell, since the last frame? + + virtual bool isCellExterior() const = 0; + + virtual bool isCellQuasiExterior() const = 0; + + virtual Ogre::Vector2 getNorthVector (MWWorld::CellStore* cell) = 0; + ///< get north vector (OGRE coordinates) for given interior cell + + virtual MWWorld::Globals::Data& getGlobalVariable (const std::string& name) = 0; + + virtual MWWorld::Globals::Data getGlobalVariable (const std::string& name) const = 0; + + virtual char getGlobalVariableType (const std::string& name) const = 0; + ///< Return ' ', if there is no global variable with this name. + + virtual MWWorld::Ptr getPtr (const std::string& name, bool activeOnly) = 0; + ///< Return a pointer to a liveCellRef with the given name. + /// \param activeOnly do non search inactive cells. + + virtual MWWorld::Ptr getPtrViaHandle (const std::string& handle) = 0; + ///< Return a pointer to a liveCellRef with the given Ogre handle. + + /// \todo enable reference in the OGRE scene + virtual void enable (const MWWorld::Ptr& ptr) = 0; + + /// \todo disable reference in the OGRE scene + virtual void disable (const MWWorld::Ptr& ptr) = 0; + + virtual void advanceTime (double hours) = 0; + ///< Advance in-game time. + + virtual void setHour (double hour) = 0; + ///< Set in-game time hour. + + virtual void setMonth (int month) = 0; + ///< Set in-game time month. + + virtual void setDay (int day) = 0; + ///< Set in-game time day. + + virtual MWWorld::TimeStamp getTimeStamp() const = 0; + ///< Return current in-game time stamp. + + virtual bool toggleSky() = 0; + ///< \return Resulting mode + + virtual void changeWeather(const std::string& region, unsigned int id) = 0; + + virtual int getCurrentWeather() const = 0; + + virtual int getMasserPhase() const = 0; + + virtual int getSecundaPhase() const = 0; + + virtual void setMoonColour (bool red) = 0; + + virtual float getTimeScaleFactor() const = 0; + + virtual void changeToInteriorCell (const std::string& cellName, + const ESM::Position& position) = 0; + ///< Move to interior cell. + + virtual void changeToExteriorCell (const ESM::Position& position) = 0; + ///< Move to exterior cell. + + virtual const ESM::Cell *getExterior (const std::string& cellName) const = 0; + ///< Return a cell matching the given name or a 0-pointer, if there is no such cell. + + virtual void markCellAsUnchanged() = 0; + + virtual std::string getFacedHandle() = 0; + ///< Return handle of the object the player is looking at + + virtual void deleteObject (const MWWorld::Ptr& ptr) = 0; + + virtual void moveObject (const MWWorld::Ptr& ptr, float x, float y, float z) = 0; + + virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false) + const = 0; + ///< Convert cell numbers to position. + + virtual void positionToIndex (float x, float y, int &cellX, int &cellY) const = 0; + ///< Convert position to cell numbers + + virtual void doPhysics (const std::vector >& actors, + float duration) = 0; + ///< Run physics simulation and modify \a world accordingly. + + virtual bool toggleCollisionMode() = 0; + ///< Toggle collision mode for player. If disabled player object should ignore + /// collisions and gravity. + ///< \return Resulting mode + + virtual bool toggleRenderMode (RenderMode mode) = 0; + ///< Toggle a render mode. + ///< \return Resulting mode + + virtual std::pair createRecord (const ESM::Potion& record) + = 0; + ///< Create a new recrod (of type potion) in the ESM store. + /// \return ID, pointer to created record + + virtual std::pair createRecord (const ESM::Class& record) + = 0; + ///< Create a new recrod (of type class) in the ESM store. + /// \return ID, pointer to created record + + virtual const ESM::Cell *createRecord (const ESM::Cell& record) = 0; + ///< Create a new recrod (of type cell) in the ESM store. + /// \return ID, pointer to created record + + virtual void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, + int mode, int number = 1) = 0; + ///< Run animation for a MW-reference. Calls to this function for references that are + /// currently not in the rendered scene should be ignored. + /// + /// \param mode: 0 normal, 1 immediate start, 2 immediate loop + /// \param number How offen the animation should be run + + virtual void skipAnimation (const MWWorld::Ptr& ptr) = 0; + ///< 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 bool placeObject(const MWWorld::Ptr& object, float cursorX, float cursorY) = 0; + ///< place an object into the gameworld at the specified cursor position + /// @param object + /// @param cursor X (relative 0-1) + /// @param cursor Y (relative 0-1) + /// @return true if the object was placed, or false if it was rejected because the position is too far away + + virtual void dropObjectOnGround (const MWWorld::Ptr& object) = 0; + + virtual bool canPlaceObject (float cursorX, float cursorY) = 0; + ///< @return true if it is possible to place on object at specified cursor location + + virtual void processChangedSettings (const Settings::CategorySettingVector& settings) = 0; + }; +} + +#endif diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index 505f61f4c..81a47ccb0 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -3,18 +3,23 @@ #include -#include - -#include "../mwworld/ptr.hpp" -#include "../mwrender/objects.hpp" #include "../mwbase/environment.hpp" + +#include "../mwworld//cellstore.hpp" +#include "../mwworld/ptr.hpp" +#include "../mwworld/physicssystem.hpp" + +#include "../mwrender/objects.hpp" +#include "../mwrender/renderinginterface.hpp" + #include "../mwgui/window_manager.hpp" +#include "../mwgui/tooltips.hpp" namespace MWClass { void Activator::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -30,7 +35,7 @@ namespace MWClass void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); @@ -44,7 +49,7 @@ namespace MWClass std::string Activator::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->name; @@ -52,7 +57,7 @@ namespace MWClass std::string Activator::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -67,7 +72,7 @@ namespace MWClass bool Activator::hasToolTip (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return (ref->base->name != ""); @@ -75,7 +80,7 @@ namespace MWClass MWGui::ToolTipInfo Activator::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index 6945f3c27..7e3c3b8f9 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -3,16 +3,17 @@ #include -#include - #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" #include "../mwworld/actionalchemy.hpp" -#include "../mwworld/world.hpp" +#include "../mwworld/cellstore.hpp" +#include "../mwworld/physicssystem.hpp" #include "../mwrender/objects.hpp" +#include "../mwrender/renderinginterface.hpp" #include "../mwgui/window_manager.hpp" #include "../mwgui/tooltips.hpp" @@ -23,7 +24,7 @@ namespace MWClass { void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -39,7 +40,7 @@ namespace MWClass void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); @@ -53,7 +54,7 @@ namespace MWClass std::string Apparatus::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->name; @@ -70,7 +71,7 @@ namespace MWClass std::string Apparatus::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -78,7 +79,7 @@ namespace MWClass int Apparatus::getValue (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->data.value; @@ -103,7 +104,7 @@ namespace MWClass std::string Apparatus::getInventoryIcon (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->icon; @@ -111,7 +112,7 @@ namespace MWClass bool Apparatus::hasToolTip (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return (ref->base->name != ""); @@ -119,7 +120,7 @@ namespace MWClass MWGui::ToolTipInfo Apparatus::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 83c0120c7..380c596d7 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -5,19 +5,21 @@ #include #include -#include +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" #include "../mwworld/actionequip.hpp" #include "../mwworld/inventorystore.hpp" -#include "../mwworld/world.hpp" - -#include "../mwbase/environment.hpp" +#include "../mwworld/cellstore.hpp" +#include "../mwworld/physicssystem.hpp" #include "../mwrender/objects.hpp" +#include "../mwrender/renderinginterface.hpp" #include "../mwgui/window_manager.hpp" +#include "../mwgui/tooltips.hpp" #include "../mwsound/soundmanager.hpp" @@ -25,7 +27,7 @@ namespace MWClass { void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -41,7 +43,7 @@ namespace MWClass void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); const std::string &model = ref->base->model; @@ -54,7 +56,7 @@ namespace MWClass std::string Armor::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->name; @@ -76,7 +78,7 @@ namespace MWClass int Armor::getItemMaxHealth (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->data.health; @@ -84,7 +86,7 @@ namespace MWClass std::string Armor::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -92,7 +94,7 @@ namespace MWClass std::pair, bool> Armor::getEquipmentSlots (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); std::vector slots; @@ -126,7 +128,7 @@ namespace MWClass int Armor::getEquipmentSkill (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); std::string typeGmst; @@ -164,7 +166,7 @@ namespace MWClass int Armor::getValue (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->data.value; @@ -201,7 +203,7 @@ namespace MWClass std::string Armor::getInventoryIcon (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->icon; @@ -209,7 +211,7 @@ namespace MWClass bool Armor::hasToolTip (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return (ref->base->name != ""); @@ -217,7 +219,7 @@ namespace MWClass MWGui::ToolTipInfo Armor::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; @@ -260,7 +262,7 @@ namespace MWClass std::string Armor::getEnchantment (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->enchant; diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index a107d9b21..a37da0fd7 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -3,17 +3,19 @@ #include -#include - #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actionread.hpp" -#include "../mwworld/world.hpp" +#include "../mwworld/cellstore.hpp" +#include "../mwworld/physicssystem.hpp" #include "../mwrender/objects.hpp" +#include "../mwrender/renderinginterface.hpp" #include "../mwgui/window_manager.hpp" +#include "../mwgui/tooltips.hpp" #include "../mwsound/soundmanager.hpp" @@ -21,7 +23,7 @@ namespace MWClass { void Book::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -37,7 +39,7 @@ namespace MWClass void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); @@ -51,7 +53,7 @@ namespace MWClass std::string Book::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->name; @@ -66,7 +68,7 @@ namespace MWClass std::string Book::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -74,7 +76,7 @@ namespace MWClass int Book::getValue (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->data.value; @@ -99,7 +101,7 @@ namespace MWClass std::string Book::getInventoryIcon (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->icon; @@ -107,7 +109,7 @@ namespace MWClass bool Book::hasToolTip (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return (ref->base->name != ""); @@ -115,7 +117,7 @@ namespace MWClass MWGui::ToolTipInfo Book::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; @@ -143,7 +145,7 @@ namespace MWClass std::string Book::getEnchantment (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->enchant; diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 11b515faf..6c34b5e56 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -3,20 +3,21 @@ #include -#include - #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" #include "../mwworld/actionequip.hpp" #include "../mwworld/inventorystore.hpp" -#include "../mwworld/world.hpp" +#include "../mwworld/cellstore.hpp" +#include "../mwworld/physicssystem.hpp" #include "../mwgui/tooltips.hpp" #include "../mwgui/window_manager.hpp" #include "../mwrender/objects.hpp" +#include "../mwrender/renderinginterface.hpp" #include "../mwsound/soundmanager.hpp" @@ -24,7 +25,7 @@ namespace MWClass { void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -40,7 +41,7 @@ namespace MWClass void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); @@ -54,7 +55,7 @@ namespace MWClass std::string Clothing::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->name; @@ -71,7 +72,7 @@ namespace MWClass std::string Clothing::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -79,7 +80,7 @@ namespace MWClass std::pair, bool> Clothing::getEquipmentSlots (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); std::vector slots; @@ -119,7 +120,7 @@ namespace MWClass int Clothing::getEquipmentSkill (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); if (ref->base->data.type==ESM::Clothing::Shoes) @@ -130,7 +131,7 @@ namespace MWClass int Clothing::getValue (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->data.value; @@ -145,7 +146,7 @@ namespace MWClass std::string Clothing::getUpSoundId (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); if (ref->base->data.type == 8) @@ -157,7 +158,7 @@ namespace MWClass std::string Clothing::getDownSoundId (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); if (ref->base->data.type == 8) @@ -169,7 +170,7 @@ namespace MWClass std::string Clothing::getInventoryIcon (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->icon; @@ -177,7 +178,7 @@ namespace MWClass bool Clothing::hasToolTip (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return (ref->base->name != ""); @@ -185,7 +186,7 @@ namespace MWClass MWGui::ToolTipInfo Clothing::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; @@ -213,7 +214,7 @@ namespace MWClass std::string Clothing::getEnchantment (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->enchant; diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index e9b8ce31f..8dd27db42 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -3,21 +3,22 @@ #include -#include - #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/nullaction.hpp" #include "../mwworld/containerstore.hpp" #include "../mwworld/customdata.hpp" -#include "../mwworld/world.hpp" +#include "../mwworld/cellstore.hpp" +#include "../mwworld/actionopen.hpp" +#include "../mwworld/physicssystem.hpp" #include "../mwgui/window_manager.hpp" #include "../mwgui/tooltips.hpp" #include "../mwrender/objects.hpp" -#include "../mwworld/actionopen.hpp" +#include "../mwrender/renderinginterface.hpp" #include "../mwsound/soundmanager.hpp" @@ -53,7 +54,7 @@ namespace MWClass void Container::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -69,7 +70,7 @@ namespace MWClass void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); @@ -117,7 +118,7 @@ namespace MWClass std::string Container::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->name; @@ -133,7 +134,7 @@ namespace MWClass std::string Container::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -148,7 +149,7 @@ namespace MWClass bool Container::hasToolTip (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return (ref->base->name != ""); @@ -156,7 +157,7 @@ namespace MWClass MWGui::ToolTipInfo Container::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; @@ -182,7 +183,7 @@ namespace MWClass float Container::getCapacity (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->weight; @@ -192,4 +193,17 @@ namespace MWClass { return getContainerStore (ptr).getWeight(); } + + void Container::lock (const MWWorld::Ptr& ptr, int lockLevel) const + { + if (lockLevel<0) + lockLevel = 0; + + ptr.getCellRef().lockLevel = lockLevel; + } + + void Container::unlock (const MWWorld::Ptr& ptr) const + { + ptr.getCellRef().lockLevel = 0; + } } diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp index 44f0fe927..739c75c77 100644 --- a/apps/openmw/mwclass/container.hpp +++ b/apps/openmw/mwclass/container.hpp @@ -44,6 +44,12 @@ namespace MWClass ///< Returns total weight of objects inside this object (including modifications from magic /// effects). Throws an exception, if the object can't hold other objects. + virtual void lock (const MWWorld::Ptr& ptr, int lockLevel) const; + ///< Lock object + + virtual void unlock (const MWWorld::Ptr& ptr) const; + ///< Unlock object + static void registerSelf(); }; } diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index e33fd322a..a5a4f337a 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -13,8 +13,12 @@ #include "../mwworld/actiontalk.hpp" #include "../mwworld/customdata.hpp" #include "../mwworld/containerstore.hpp" +#include "../mwworld/physicssystem.hpp" + +#include "../mwrender/renderinginterface.hpp" #include "../mwgui/window_manager.hpp" +#include "../mwgui/tooltips.hpp" namespace { @@ -40,7 +44,7 @@ namespace MWClass { std::auto_ptr data (new CustomData); - ESMS::LiveCellRef *ref = ptr.get(); + MWWorld::LiveCellRef *ref = ptr.get(); // creature stats data->mCreatureStats.mAttributes[0].set (ref->base->data.strength); @@ -57,6 +61,11 @@ namespace MWClass data->mCreatureStats.mLevel = ref->base->data.level; + data->mCreatureStats.mHello = ref->base->AI.hello; + data->mCreatureStats.mFight = ref->base->AI.fight; + data->mCreatureStats.mFlee = ref->base->AI.flee; + data->mCreatureStats.mAlarm = ref->base->AI.alarm; + // store ptr.getRefData().setCustomData (data.release()); } @@ -64,7 +73,7 @@ namespace MWClass std::string Creature::getId (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->mId; @@ -78,7 +87,7 @@ namespace MWClass void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); const std::string &model = ref->base->model; @@ -92,7 +101,7 @@ namespace MWClass std::string Creature::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->name; @@ -121,7 +130,7 @@ namespace MWClass std::string Creature::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -143,7 +152,7 @@ namespace MWClass MWGui::ToolTipInfo Creature::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 7041de1c6..b0bba2c03 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -3,20 +3,21 @@ #include -#include - #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/player.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/nullaction.hpp" #include "../mwworld/actionteleport.hpp" -#include "../mwworld/world.hpp" +#include "../mwworld/cellstore.hpp" +#include "../mwworld/physicssystem.hpp" #include "../mwgui/window_manager.hpp" #include "../mwgui/tooltips.hpp" #include "../mwrender/objects.hpp" +#include "../mwrender/renderinginterface.hpp" #include "../mwsound/soundmanager.hpp" @@ -24,7 +25,7 @@ namespace MWClass { void Door::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -40,7 +41,7 @@ namespace MWClass void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); const std::string &model = ref->base->model; @@ -52,7 +53,7 @@ namespace MWClass std::string Door::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); if (ref->ref.teleport && !ref->ref.destCell.empty()) // TODO doors that lead to exteriors @@ -64,7 +65,7 @@ namespace MWClass boost::shared_ptr Door::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); const std::string &openSound = ref->base->openSound; @@ -134,7 +135,7 @@ namespace MWClass std::string Door::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -149,7 +150,7 @@ namespace MWClass bool Door::hasToolTip (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return (ref->base->name != ""); @@ -157,7 +158,7 @@ namespace MWClass MWGui::ToolTipInfo Door::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 0c7fa7e69..01146fe67 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -3,18 +3,19 @@ #include -#include - #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/world.hpp" +#include "../mwworld/cellstore.hpp" +#include "../mwworld/physicssystem.hpp" #include "../mwgui/window_manager.hpp" #include "../mwgui/tooltips.hpp" #include "../mwrender/objects.hpp" +#include "../mwrender/renderinginterface.hpp" #include "../mwsound/soundmanager.hpp" @@ -22,7 +23,7 @@ namespace MWClass { void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -38,7 +39,7 @@ namespace MWClass void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); const std::string &model = ref->base->model; @@ -50,7 +51,7 @@ namespace MWClass std::string Ingredient::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->name; @@ -67,7 +68,7 @@ namespace MWClass std::string Ingredient::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -75,7 +76,7 @@ namespace MWClass int Ingredient::getValue (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->data.value; @@ -100,7 +101,7 @@ namespace MWClass std::string Ingredient::getInventoryIcon (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->icon; @@ -108,7 +109,7 @@ namespace MWClass bool Ingredient::hasToolTip (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return (ref->base->name != ""); @@ -116,7 +117,7 @@ namespace MWClass MWGui::ToolTipInfo Ingredient::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 154033433..15cd89ac2 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -3,16 +3,16 @@ #include -#include - #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" #include "../mwworld/actionequip.hpp" #include "../mwworld/nullaction.hpp" #include "../mwworld/inventorystore.hpp" -#include "../mwworld/world.hpp" +#include "../mwworld/cellstore.hpp" +#include "../mwworld/physicssystem.hpp" #include "../mwgui/window_manager.hpp" #include "../mwgui/tooltips.hpp" @@ -20,12 +20,13 @@ #include "../mwsound/soundmanager.hpp" #include "../mwrender/objects.hpp" +#include "../mwrender/renderinginterface.hpp" namespace MWClass { void Light::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -47,7 +48,7 @@ namespace MWClass void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -65,7 +66,7 @@ namespace MWClass std::string Light::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); if (ref->base->model.empty()) @@ -77,7 +78,7 @@ namespace MWClass boost::shared_ptr Light::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); if (!(ref->base->data.flags & ESM::Light::Carry)) @@ -91,7 +92,7 @@ namespace MWClass std::string Light::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -99,7 +100,7 @@ namespace MWClass std::pair, bool> Light::getEquipmentSlots (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); std::vector slots; @@ -112,7 +113,7 @@ namespace MWClass int Light::getValue (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->data.value; @@ -138,7 +139,7 @@ namespace MWClass std::string Light::getInventoryIcon (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->icon; @@ -146,7 +147,7 @@ namespace MWClass bool Light::hasToolTip (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return (ref->base->name != ""); @@ -154,7 +155,7 @@ namespace MWClass MWGui::ToolTipInfo Light::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index 27e292bc0..d3d60315f 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -3,19 +3,21 @@ #include -#include - #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" #include "../mwworld/actionequip.hpp" #include "../mwworld/inventorystore.hpp" -#include "../mwworld/world.hpp" +#include "../mwworld/cellstore.hpp" +#include "../mwworld/physicssystem.hpp" + #include "../mwgui/window_manager.hpp" #include "../mwgui/tooltips.hpp" #include "../mwrender/objects.hpp" +#include "../mwrender/renderinginterface.hpp" #include "../mwsound/soundmanager.hpp" @@ -23,7 +25,7 @@ namespace MWClass { void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -39,7 +41,7 @@ namespace MWClass void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); @@ -54,7 +56,7 @@ namespace MWClass std::string Lockpick::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->name; @@ -71,7 +73,7 @@ namespace MWClass std::string Lockpick::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -88,7 +90,7 @@ namespace MWClass int Lockpick::getValue (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->data.value; @@ -113,7 +115,7 @@ namespace MWClass std::string Lockpick::getInventoryIcon (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->icon; @@ -121,7 +123,7 @@ namespace MWClass bool Lockpick::hasToolTip (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return (ref->base->name != ""); @@ -129,7 +131,7 @@ namespace MWClass MWGui::ToolTipInfo Lockpick::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index d8e0553b9..8484a5dd1 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -5,18 +5,19 @@ #include -#include - #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/world.hpp" +#include "../mwworld/cellstore.hpp" +#include "../mwworld/physicssystem.hpp" #include "../mwgui/window_manager.hpp" #include "../mwgui/tooltips.hpp" #include "../mwrender/objects.hpp" +#include "../mwrender/renderinginterface.hpp" #include "../mwsound/soundmanager.hpp" @@ -26,7 +27,7 @@ namespace MWClass { void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -42,7 +43,7 @@ namespace MWClass void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); @@ -56,7 +57,7 @@ namespace MWClass std::string Miscellaneous::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->name; @@ -73,7 +74,7 @@ namespace MWClass std::string Miscellaneous::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -81,7 +82,7 @@ namespace MWClass int Miscellaneous::getValue (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->data.value; @@ -96,7 +97,7 @@ namespace MWClass std::string Miscellaneous::getUpSoundId (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); if (ref->base->name == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGold")->str) @@ -108,7 +109,7 @@ namespace MWClass std::string Miscellaneous::getDownSoundId (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); if (ref->base->name == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGold")->str) @@ -120,7 +121,7 @@ namespace MWClass std::string Miscellaneous::getInventoryIcon (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->icon; @@ -128,7 +129,7 @@ namespace MWClass bool Miscellaneous::hasToolTip (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return (ref->base->name != ""); @@ -136,7 +137,7 @@ namespace MWClass MWGui::ToolTipInfo Miscellaneous::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 8062dc35e..d4f711885 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -9,6 +9,9 @@ #include +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + #include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/movement.hpp" @@ -16,13 +19,15 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" -#include "../mwworld/world.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwworld/customdata.hpp" +#include "../mwworld/physicssystem.hpp" + +#include "../mwrender/actors.hpp" +#include "../mwrender/renderinginterface.hpp" #include "../mwgui/window_manager.hpp" - -#include "../mwbase/environment.hpp" +#include "../mwgui/tooltips.hpp" namespace { @@ -53,7 +58,7 @@ namespace MWClass { std::auto_ptr data (new CustomData); - ESMS::LiveCellRef *ref = ptr.get(); + MWWorld::LiveCellRef *ref = ptr.get(); // NPC stats if (!ref->base->faction.empty()) @@ -70,12 +75,12 @@ namespace MWClass } } + // creature stats if(ref->base->npdt52.gold != -10) { for (int i=0; i<27; ++i) data->mNpcStats.mSkill[i].setBase (ref->base->npdt52.skills[i]); - // creature stats data->mCreatureStats.mAttributes[0].set (ref->base->npdt52.strength); data->mCreatureStats.mAttributes[1].set (ref->base->npdt52.intelligence); data->mCreatureStats.mAttributes[2].set (ref->base->npdt52.willpower); @@ -95,6 +100,11 @@ namespace MWClass /// \todo do something with npdt12 maybe:p } + data->mCreatureStats.mHello = ref->base->AI.hello; + data->mCreatureStats.mFight = ref->base->AI.fight; + data->mCreatureStats.mFlee = ref->base->AI.flee; + data->mCreatureStats.mAlarm = ref->base->AI.alarm; + // store ptr.getRefData().setCustomData (data.release()); } @@ -102,7 +112,7 @@ namespace MWClass std::string Npc::getId (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->mId; @@ -115,14 +125,10 @@ namespace MWClass void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); - - - std::string headID = ref->base->head; std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4); bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_"; @@ -130,15 +136,14 @@ namespace MWClass std::string smodel = "meshes\\base_anim.nif"; if(beast) smodel = "meshes\\base_animkna.nif"; - physics.insertActorPhysics(ptr, smodel); - + physics.insertActorPhysics(ptr, smodel); MWBase::Environment::get().getMechanicsManager()->addActor (ptr); } std::string Npc::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->name; @@ -182,7 +187,7 @@ namespace MWClass std::string Npc::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -302,7 +307,7 @@ namespace MWClass MWGui::ToolTipInfo Npc::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 157af01f5..5b446fbe9 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -3,18 +3,19 @@ #include -#include - #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/world.hpp" +#include "../mwworld/cellstore.hpp" +#include "../mwworld/physicssystem.hpp" #include "../mwgui/window_manager.hpp" #include "../mwgui/tooltips.hpp" #include "../mwrender/objects.hpp" +#include "../mwrender/renderinginterface.hpp" #include "../mwsound/soundmanager.hpp" @@ -22,7 +23,7 @@ namespace MWClass { void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -38,7 +39,7 @@ namespace MWClass void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); @@ -52,7 +53,7 @@ namespace MWClass std::string Potion::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->name; @@ -69,7 +70,7 @@ namespace MWClass std::string Potion::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -77,7 +78,7 @@ namespace MWClass int Potion::getValue (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->data.value; @@ -102,7 +103,7 @@ namespace MWClass std::string Potion::getInventoryIcon (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->icon; @@ -110,7 +111,7 @@ namespace MWClass bool Potion::hasToolTip (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return (ref->base->name != ""); @@ -118,7 +119,7 @@ namespace MWClass MWGui::ToolTipInfo Potion::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 0b256d729..f3a8406f5 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -3,19 +3,21 @@ #include -#include - #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" #include "../mwworld/actionequip.hpp" #include "../mwworld/inventorystore.hpp" -#include "../mwworld/world.hpp" +#include "../mwworld/cellstore.hpp" +#include "../mwworld/physicssystem.hpp" + #include "../mwgui/window_manager.hpp" #include "../mwgui/tooltips.hpp" #include "../mwrender/objects.hpp" +#include "../mwrender/renderinginterface.hpp" #include "../mwsound/soundmanager.hpp" @@ -23,7 +25,7 @@ namespace MWClass { void Probe::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -39,7 +41,7 @@ namespace MWClass void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); @@ -54,7 +56,7 @@ namespace MWClass std::string Probe::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->name; @@ -70,7 +72,7 @@ namespace MWClass std::string Probe::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -87,7 +89,7 @@ namespace MWClass int Probe::getValue (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->data.value; @@ -112,7 +114,7 @@ namespace MWClass std::string Probe::getInventoryIcon (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->icon; @@ -120,7 +122,7 @@ namespace MWClass bool Probe::hasToolTip (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return (ref->base->name != ""); @@ -128,7 +130,7 @@ namespace MWClass MWGui::ToolTipInfo Probe::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index 5666a95a5..464ba1091 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -3,17 +3,19 @@ #include -#include - #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/world.hpp" +#include "../mwworld/cellstore.hpp" +#include "../mwworld/physicssystem.hpp" + #include "../mwgui/window_manager.hpp" #include "../mwgui/tooltips.hpp" #include "../mwrender/objects.hpp" +#include "../mwrender/renderinginterface.hpp" #include "../mwsound/soundmanager.hpp" @@ -21,7 +23,7 @@ namespace MWClass { void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -37,7 +39,7 @@ namespace MWClass void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); @@ -51,7 +53,7 @@ namespace MWClass std::string Repair::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->name; @@ -68,7 +70,7 @@ namespace MWClass std::string Repair::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -76,7 +78,7 @@ namespace MWClass int Repair::getValue (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->data.value; @@ -101,7 +103,7 @@ namespace MWClass std::string Repair::getInventoryIcon (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->icon; @@ -109,7 +111,7 @@ namespace MWClass bool Repair::hasToolTip (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return (ref->base->name != ""); @@ -117,7 +119,7 @@ namespace MWClass MWGui::ToolTipInfo Repair::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; diff --git a/apps/openmw/mwclass/static.cpp b/apps/openmw/mwclass/static.cpp index 4a4136816..9b166b076 100644 --- a/apps/openmw/mwclass/static.cpp +++ b/apps/openmw/mwclass/static.cpp @@ -4,14 +4,16 @@ #include #include "../mwworld/ptr.hpp" +#include "../mwworld/physicssystem.hpp" #include "../mwrender/objects.hpp" +#include "../mwrender/renderinginterface.hpp" namespace MWClass { void Static::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -27,7 +29,7 @@ namespace MWClass void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 482d618b0..099312d2c 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -3,20 +3,21 @@ #include -#include - #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" #include "../mwworld/actionequip.hpp" #include "../mwworld/inventorystore.hpp" -#include "../mwworld/world.hpp" +#include "../mwworld/cellstore.hpp" +#include "../mwworld/physicssystem.hpp" #include "../mwgui/window_manager.hpp" #include "../mwgui/tooltips.hpp" #include "../mwrender/objects.hpp" +#include "../mwrender/renderinginterface.hpp" #include "../mwsound/soundmanager.hpp" @@ -24,7 +25,7 @@ namespace MWClass { void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -40,7 +41,7 @@ namespace MWClass void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); @@ -54,7 +55,7 @@ namespace MWClass std::string Weapon::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->name; @@ -76,7 +77,7 @@ namespace MWClass int Weapon::getItemMaxHealth (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->data.health; @@ -84,7 +85,7 @@ namespace MWClass std::string Weapon::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->script; @@ -92,7 +93,7 @@ namespace MWClass std::pair, bool> Weapon::getEquipmentSlots (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); std::vector slots; @@ -116,7 +117,7 @@ namespace MWClass int Weapon::getEquipmentSkill (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); const int size = 12; @@ -146,7 +147,7 @@ namespace MWClass int Weapon::getValue (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->data.value; @@ -161,7 +162,7 @@ namespace MWClass std::string Weapon::getUpSoundId (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); int type = ref->base->data.type; @@ -207,7 +208,7 @@ namespace MWClass std::string Weapon::getDownSoundId (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); int type = ref->base->data.type; @@ -253,7 +254,7 @@ namespace MWClass std::string Weapon::getInventoryIcon (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->icon; @@ -261,7 +262,7 @@ namespace MWClass bool Weapon::hasToolTip (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return (ref->base->name != ""); @@ -269,7 +270,7 @@ namespace MWClass MWGui::ToolTipInfo Weapon::getToolTipInfo (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); MWGui::ToolTipInfo info; @@ -351,7 +352,7 @@ namespace MWClass std::string Weapon::getEnchantment (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); return ref->base->enchant; diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index a19356d07..41ffd1e93 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -10,9 +10,9 @@ #include #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/class.hpp" -#include "../mwworld/world.hpp" #include "../mwworld/refdata.hpp" #include "../mwworld/player.hpp" #include "../mwworld/containerstore.hpp" @@ -121,24 +121,24 @@ namespace } template - bool checkGlobal (char comp, const std::string& name, T value, MWWorld::World& world) + bool checkGlobal (char comp, const std::string& name, T value) { - switch (world.getGlobalVariableType (name)) + switch (MWBase::Environment::get().getWorld()->getGlobalVariableType (name)) { case 's': - return selectCompare (comp, world.getGlobalVariable (name).mShort, value); + return selectCompare (comp, MWBase::Environment::get().getWorld()->getGlobalVariable (name).mShort, value); case 'l': - return selectCompare (comp, world.getGlobalVariable (name).mLong, value); + return selectCompare (comp, MWBase::Environment::get().getWorld()->getGlobalVariable (name).mLong, value); case 'f': - return selectCompare (comp, world.getGlobalVariable (name).mFloat, value); + return selectCompare (comp, MWBase::Environment::get().getWorld()->getGlobalVariable (name).mFloat, value); case ' ': - world.getGlobalVariable (name); // trigger exception + MWBase::Environment::get().getWorld()->getGlobalVariable (name); // trigger exception break; default: @@ -309,12 +309,12 @@ namespace MWDialogue if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || select.type==ESM::VT_Long) { - if (!checkGlobal (comp, toLower (name), select.i, *MWBase::Environment::get().getWorld())) + if (!checkGlobal (comp, toLower (name), select.i)) return false; } else if (select.type==ESM::VT_Float) { - if (!checkGlobal (comp, toLower (name), select.f, *MWBase::Environment::get().getWorld())) + if (!checkGlobal (comp, toLower (name), select.f)) return false; } else @@ -392,7 +392,7 @@ namespace MWDialogue if(select.type==ESM::VT_Int) { - ESMS::LiveCellRef* npc = actor.get(); + MWWorld::LiveCellRef* npc = actor.get(); int isFaction = int(toLower(npc->base->faction) == toLower(name)); if(selectCompare(comp,!isFaction,select.i)) return false; @@ -409,7 +409,7 @@ namespace MWDialogue if(select.type==ESM::VT_Int) { - ESMS::LiveCellRef* npc = actor.get(); + MWWorld::LiveCellRef* npc = actor.get(); int isClass = int(toLower(npc->base->cls) == toLower(name)); if(selectCompare(comp,!isClass,select.i)) return false; @@ -426,7 +426,7 @@ namespace MWDialogue if(select.type==ESM::VT_Int) { - ESMS::LiveCellRef* npc = actor.get(); + MWWorld::LiveCellRef* npc = actor.get(); int isRace = int(toLower(npc->base->race) == toLower(name)); if(selectCompare(comp,!isRace,select.i)) return false; @@ -493,7 +493,7 @@ namespace MWDialogue if (isCreature) return false; - ESMS::LiveCellRef *cellRef = actor.get(); + MWWorld::LiveCellRef *cellRef = actor.get(); if (!cellRef) return false; @@ -508,7 +508,7 @@ namespace MWDialogue if (isCreature) return false; - ESMS::LiveCellRef *cellRef = actor.get(); + MWWorld::LiveCellRef *cellRef = actor.get(); if (!cellRef) return false; @@ -558,7 +558,7 @@ namespace MWDialogue //check gender if (!isCreature) { - ESMS::LiveCellRef* npc = actor.get(); + MWWorld::LiveCellRef* npc = actor.get(); if(npc->base->flags&npc->base->Female) { if(static_cast (info.data.gender)==0) return false; @@ -706,7 +706,7 @@ namespace MWDialogue } return false; } - catch (const Compiler::SourceException& error) + catch (const Compiler::SourceException& /* error */) { // error has already been reported via error handler } @@ -771,13 +771,13 @@ namespace MWDialogue int services = 0; if (mActor.getTypeName() == typeid(ESM::NPC).name()) { - ESMS::LiveCellRef* ref = mActor.get(); + MWWorld::LiveCellRef* ref = mActor.get(); if (ref->base->hasAI) services = ref->base->AI.services; } else if (mActor.getTypeName() == typeid(ESM::Creature).name()) { - ESMS::LiveCellRef* ref = mActor.get(); + MWWorld::LiveCellRef* ref = mActor.get(); if (ref->base->hasAI) services = ref->base->AI.services; } @@ -843,7 +843,7 @@ namespace MWDialogue void DialogueManager::goodbyeSelected() { - MWBase::Environment::get().getWindowManager()->popGuiMode(); + MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Dialogue); } void DialogueManager::questionAnswered(std::string answere) diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journal.cpp index eb828a76c..ad10be3aa 100644 --- a/apps/openmw/mwdialogue/journal.cpp +++ b/apps/openmw/mwdialogue/journal.cpp @@ -2,12 +2,11 @@ #include "journal.hpp" #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwgui/window_manager.hpp" #include "../mwgui/messagebox.hpp" -#include "../mwworld/world.hpp" - namespace MWDialogue { Quest& Journal::getQuest (const std::string& id) @@ -30,14 +29,13 @@ namespace MWDialogue void Journal::addEntry (const std::string& id, int index) { - StampedJournalEntry entry = - StampedJournalEntry::makeFromQuest (id, index, *MWBase::Environment::get().getWorld()); + StampedJournalEntry entry = StampedJournalEntry::makeFromQuest (id, index); mJournal.push_back (entry); Quest& quest = getQuest (id); - quest.addEntry (entry, *MWBase::Environment::get().getWorld()); // we are doing slicing on purpose here + quest.addEntry (entry); // we are doing slicing on purpose here std::vector empty; std::string notification = MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sJournalEntry")->str; @@ -48,7 +46,7 @@ namespace MWDialogue { Quest& quest = getQuest (id); - quest.setIndex (index, *MWBase::Environment::get().getWorld()); + quest.setIndex (index); } void Journal::addTopic (const std::string& topicId, const std::string& infoId) @@ -63,7 +61,7 @@ namespace MWDialogue iter = result.first; } - iter->second.addEntry (JournalEntry (topicId, infoId), *MWBase::Environment::get().getWorld()); + iter->second.addEntry (JournalEntry (topicId, infoId)); } int Journal::getJournalIndex (const std::string& id) const diff --git a/apps/openmw/mwdialogue/journalentry.cpp b/apps/openmw/mwdialogue/journalentry.cpp index 4eb6b8001..9d58687e1 100644 --- a/apps/openmw/mwdialogue/journalentry.cpp +++ b/apps/openmw/mwdialogue/journalentry.cpp @@ -5,7 +5,8 @@ #include -#include "../mwworld/world.hpp" +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" namespace MWDialogue { @@ -27,16 +28,14 @@ namespace MWDialogue throw std::runtime_error ("unknown info ID " + mInfoId + " for topic " + mTopic); } - JournalEntry JournalEntry::makeFromQuest (const std::string& topic, int index, - const MWWorld::World& world) + JournalEntry JournalEntry::makeFromQuest (const std::string& topic, int index) { - return JournalEntry (topic, idFromIndex (topic, index, world)); + return JournalEntry (topic, idFromIndex (topic, index)); } - std::string JournalEntry::idFromIndex (const std::string& topic, int index, - const MWWorld::World& world) + std::string JournalEntry::idFromIndex (const std::string& topic, int index) { - const ESM::Dialogue *dialogue = world.getStore().dialogs.find (topic); + const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (topic); for (std::vector::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) @@ -57,13 +56,12 @@ namespace MWDialogue : JournalEntry (topic, infoId), mDay (day), mMonth (month), mDayOfMonth (dayOfMonth) {} - StampedJournalEntry StampedJournalEntry::makeFromQuest (const std::string& topic, int index, - const MWWorld::World& world) + StampedJournalEntry StampedJournalEntry::makeFromQuest (const std::string& topic, int index) { - int day = world.getGlobalVariable ("dayspassed").mLong; - int month = world.getGlobalVariable ("day").mLong; - int dayOfMonth = world.getGlobalVariable ("month").mLong; + int day = MWBase::Environment::get().getWorld()->getGlobalVariable ("dayspassed").mLong; + int month = MWBase::Environment::get().getWorld()->getGlobalVariable ("day").mLong; + int dayOfMonth = MWBase::Environment::get().getWorld()->getGlobalVariable ("month").mLong; - return StampedJournalEntry (topic, idFromIndex (topic, index, world), day, month, dayOfMonth); + return StampedJournalEntry (topic, idFromIndex (topic, index), day, month, dayOfMonth); } } diff --git a/apps/openmw/mwdialogue/journalentry.hpp b/apps/openmw/mwdialogue/journalentry.hpp index 11b715630..9a3270439 100644 --- a/apps/openmw/mwdialogue/journalentry.hpp +++ b/apps/openmw/mwdialogue/journalentry.hpp @@ -8,11 +8,6 @@ namespace ESMS struct ESMStore; } -namespace MWWorld -{ - class World; -} - namespace MWDialogue { /// \brief A quest or dialogue entry @@ -27,11 +22,9 @@ namespace MWDialogue std::string getText (const ESMS::ESMStore& store) const; - static JournalEntry makeFromQuest (const std::string& topic, int index, - const MWWorld::World& world); + static JournalEntry makeFromQuest (const std::string& topic, int index); - static std::string idFromIndex (const std::string& topic, int index, - const MWWorld::World& world); + static std::string idFromIndex (const std::string& topic, int index); }; /// \biref A quest entry with a timestamp. @@ -46,8 +39,7 @@ namespace MWDialogue StampedJournalEntry (const std::string& topic, const std::string& infoId, int day, int month, int dayOfMonth); - static StampedJournalEntry makeFromQuest (const std::string& topic, int index, - const MWWorld::World& world); + static StampedJournalEntry makeFromQuest (const std::string& topic, int index); }; } diff --git a/apps/openmw/mwdialogue/quest.cpp b/apps/openmw/mwdialogue/quest.cpp index 1f387e862..484c2c19c 100644 --- a/apps/openmw/mwdialogue/quest.cpp +++ b/apps/openmw/mwdialogue/quest.cpp @@ -3,7 +3,8 @@ #include -#include "../mwworld/world.hpp" +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" namespace MWDialogue { @@ -15,9 +16,9 @@ namespace MWDialogue : Topic (topic), mIndex (0), mFinished (false) {} - const std::string Quest::getName (const MWWorld::World& world) const + const std::string Quest::getName() const { - const ESM::Dialogue *dialogue = world.getStore().dialogs.find (mTopic); + const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (mTopic); for (std::vector::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) @@ -32,9 +33,9 @@ namespace MWDialogue return mIndex; } - void Quest::setIndex (int index, const MWWorld::World& world) + void Quest::setIndex (int index) { - const ESM::Dialogue *dialogue = world.getStore().dialogs.find (mTopic); + const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (mTopic); for (std::vector::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) @@ -58,11 +59,11 @@ namespace MWDialogue return mFinished; } - void Quest::addEntry (const JournalEntry& entry, const MWWorld::World& world) + void Quest::addEntry (const JournalEntry& entry) { int index = -1; - const ESM::Dialogue *dialogue = world.getStore().dialogs.find (entry.mTopic); + const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (entry.mTopic); for (std::vector::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) @@ -75,7 +76,7 @@ namespace MWDialogue if (index==-1) throw std::runtime_error ("unknown journal entry for topic " + mTopic); - setIndex (index, world); + setIndex (index); for (TEntryIter iter (mEntries.begin()); iter!=mEntries.end(); ++iter) if (*iter==entry.mInfoId) diff --git a/apps/openmw/mwdialogue/quest.hpp b/apps/openmw/mwdialogue/quest.hpp index c162c03f4..5fcc894ea 100644 --- a/apps/openmw/mwdialogue/quest.hpp +++ b/apps/openmw/mwdialogue/quest.hpp @@ -17,17 +17,17 @@ namespace MWDialogue Quest (const std::string& topic); - const std::string getName (const MWWorld::World& world) const; + const std::string getName() const; ///< May be an empty string int getIndex() const; - void setIndex (int index, const MWWorld::World& world); + void setIndex (int index); ///< Calling this function with a non-existant index while throw an exception. bool isFinished() const; - virtual void addEntry (const JournalEntry& entry, const MWWorld::World& world); + virtual void addEntry (const JournalEntry& entry); ///< Add entry and adjust index accordingly. /// /// \note Redundant entries are ignored, but the index is still adjusted. diff --git a/apps/openmw/mwdialogue/topic.cpp b/apps/openmw/mwdialogue/topic.cpp index 8f165d3c8..8c1dfafb8 100644 --- a/apps/openmw/mwdialogue/topic.cpp +++ b/apps/openmw/mwdialogue/topic.cpp @@ -3,8 +3,6 @@ #include -#include "../mwworld/world.hpp" - namespace MWDialogue { Topic::Topic() @@ -17,7 +15,7 @@ namespace MWDialogue Topic::~Topic() {} - void Topic::addEntry (const JournalEntry& entry, const MWWorld::World& world) + void Topic::addEntry (const JournalEntry& entry) { if (entry.mTopic!=mTopic) throw std::runtime_error ("topic does not match: " + mTopic); diff --git a/apps/openmw/mwdialogue/topic.hpp b/apps/openmw/mwdialogue/topic.hpp index c085f1ed9..3ad15903f 100644 --- a/apps/openmw/mwdialogue/topic.hpp +++ b/apps/openmw/mwdialogue/topic.hpp @@ -6,11 +6,6 @@ #include "journalentry.hpp" -namespace MWWorld -{ - class World; -} - namespace MWDialogue { /// \brief Collection of seen responses for a topic @@ -34,7 +29,7 @@ namespace MWDialogue virtual ~Topic(); - virtual void addEntry (const JournalEntry& entry, const MWWorld::World& world); + virtual void addEntry (const JournalEntry& entry); ///< Add entry /// /// \note Redundant entries are ignored. diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 9c26bfabe..9d691d371 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -3,10 +3,12 @@ #include #include "../mwbase/environment.hpp" -#include "../mwworld/world.hpp" +#include "../mwbase/world.hpp" + #include "../mwworld/player.hpp" #include "../mwworld/manualref.hpp" #include "../mwworld/containerstore.hpp" + #include "../mwsound/soundmanager.hpp" #include "window_manager.hpp" @@ -27,7 +29,7 @@ namespace namespace MWGui { AlchemyWindow::AlchemyWindow(WindowManager& parWindowManager) - : WindowBase("openmw_alchemy_window_layout.xml", parWindowManager) + : WindowBase("openmw_alchemy_window.layout", parWindowManager) , ContainerBase(0) { getWidget(mCreateButton, "CreateButton"); @@ -70,8 +72,8 @@ namespace MWGui void AlchemyWindow::onCancelButtonClicked(MyGUI::Widget* _sender) { - mWindowManager.popGuiMode(); - mWindowManager.popGuiMode(); + mWindowManager.removeGuiMode(GM_Alchemy); + mWindowManager.removeGuiMode(GM_Inventory); } void AlchemyWindow::onCreateButtonClicked(MyGUI::Widget* _sender) @@ -275,7 +277,7 @@ namespace MWGui for (MWWorld::ContainerStoreIterator it(store.begin(MWWorld::ContainerStore::Type_Apparatus)); it != store.end(); ++it) { - ESMS::LiveCellRef* ref = it->get(); + MWWorld::LiveCellRef* ref = it->get(); if (ref->base->data.type == ESM::Apparatus::Albemic && (bestAlbemic.isEmpty() || ref->base->data.quality > bestAlbemic.get()->base->data.quality)) bestAlbemic = *it; @@ -420,7 +422,7 @@ namespace MWGui continue; // add the effects of this ingredient to list of effects - ESMS::LiveCellRef* ref = ingredient->getUserData()->get(); + MWWorld::LiveCellRef* ref = ingredient->getUserData()->get(); for (int i=0; i<4; ++i) { if (ref->base->data.effectID[i] < 0) diff --git a/apps/openmw/mwgui/alchemywindow.hpp b/apps/openmw/mwgui/alchemywindow.hpp index c01a18e41..81c33a96d 100644 --- a/apps/openmw/mwgui/alchemywindow.hpp +++ b/apps/openmw/mwgui/alchemywindow.hpp @@ -3,6 +3,7 @@ #include "window_base.hpp" #include "container.hpp" +#include "widgets.hpp" namespace MWGui { diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 49f90d1a0..69056759d 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -10,7 +10,7 @@ using namespace MWGui; using namespace Widgets; BirthDialog::BirthDialog(WindowManager& parWindowManager) - : WindowBase("openmw_chargen_birth_layout.xml", parWindowManager) + : WindowBase("openmw_chargen_birth.layout", parWindowManager) { // Centre dialog center(); diff --git a/apps/openmw/mwgui/birth.hpp b/apps/openmw/mwgui/birth.hpp index b5f7db774..e61be736a 100644 --- a/apps/openmw/mwgui/birth.hpp +++ b/apps/openmw/mwgui/birth.hpp @@ -5,7 +5,7 @@ /* This file contains the dialog for choosing a birth sign. - Layout is defined by resources/mygui/openmw_chargen_race_layout.xml. + Layout is defined by resources/mygui/openmw_chargen_race.layout. */ namespace MWGui diff --git a/apps/openmw/mwgui/bookwindow.cpp b/apps/openmw/mwgui/bookwindow.cpp index f1873b550..1ea3da839 100644 --- a/apps/openmw/mwgui/bookwindow.cpp +++ b/apps/openmw/mwgui/bookwindow.cpp @@ -13,7 +13,7 @@ using namespace MWGui; BookWindow::BookWindow (WindowManager& parWindowManager) : - WindowBase("openmw_book_layout.xml", parWindowManager) + WindowBase("openmw_book.layout", parWindowManager) { getWidget(mCloseButton, "CloseButton"); mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onCloseButtonClicked); @@ -55,8 +55,7 @@ void BookWindow::open (MWWorld::Ptr book) MWBase::Environment::get().getSoundManager()->playSound ("book open", 1.0, 1.0); - ESMS::LiveCellRef *ref = - mBook.get(); + MWWorld::LiveCellRef *ref = mBook.get(); BookTextParser parser; std::vector results = parser.split(ref->base->text, mLeftPage->getSize().width, mLeftPage->getSize().height); @@ -92,7 +91,7 @@ void BookWindow::onCloseButtonClicked (MyGUI::Widget* _sender) // no 3d sounds because the object could be in a container. MWBase::Environment::get().getSoundManager()->playSound ("book close", 1.0, 1.0); - mWindowManager.popGuiMode(); + mWindowManager.removeGuiMode(GM_Book); } void BookWindow::onTakeButtonClicked (MyGUI::Widget* _sender) @@ -102,7 +101,7 @@ void BookWindow::onTakeButtonClicked (MyGUI::Widget* _sender) MWWorld::ActionTake take(mBook); take.execute(); - mWindowManager.popGuiMode(); + mWindowManager.removeGuiMode(GM_Book); } void BookWindow::onNextPageButtonClicked (MyGUI::Widget* _sender) diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index 3f9a94e2d..c39e305dc 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -708,6 +708,9 @@ void CharacterCreation::onGenerateClassDone(WindowBase* parWindow) if (mGenerateClassResultDialog) mWM->removeDialog(mGenerateClassResultDialog); MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass); + const ESM::Class *klass = MWBase::Environment::get().getWorld()->getStore().classes.find(mGenerateClass); + mPlayerClass = *klass; + mWM->setPlayerClass(mPlayerClass); if (mCreationStage == CSE_ReviewNext) { diff --git a/apps/openmw/mwgui/charactercreation.hpp b/apps/openmw/mwgui/charactercreation.hpp index 02b48ffe2..e9c90877e 100644 --- a/apps/openmw/mwgui/charactercreation.hpp +++ b/apps/openmw/mwgui/charactercreation.hpp @@ -3,10 +3,12 @@ #include "window_manager.hpp" +#include + +#include "../mwbase/world.hpp" + #include "../mwmechanics/mechanicsmanager.hpp" #include "../mwmechanics/stat.hpp" -#include "../mwworld/world.hpp" -#include namespace MWGui { diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 0961f6327..d0f21f945 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -19,7 +19,7 @@ using namespace MWGui; /* GenerateClassResultDialog */ GenerateClassResultDialog::GenerateClassResultDialog(WindowManager& parWindowManager) - : WindowBase("openmw_chargen_generate_class_result_layout.xml", parWindowManager) + : WindowBase("openmw_chargen_generate_class_result.layout", parWindowManager) { // Centre dialog center(); @@ -77,7 +77,7 @@ void GenerateClassResultDialog::onBackClicked(MyGUI::Widget* _sender) /* PickClassDialog */ PickClassDialog::PickClassDialog(WindowManager& parWindowManager) - : WindowBase("openmw_chargen_class_layout.xml", parWindowManager) + : WindowBase("openmw_chargen_class.layout", parWindowManager) { // Centre dialog center(); @@ -283,7 +283,7 @@ void InfoBoxDialog::layoutVertically(MyGUI::WidgetPtr widget, int margin) } InfoBoxDialog::InfoBoxDialog(WindowManager& parWindowManager) - : WindowBase("openmw_infobox_layout.xml", parWindowManager) + : WindowBase("openmw_infobox.layout", parWindowManager) , currentButton(-1) { getWidget(textBox, "TextBox"); @@ -381,7 +381,7 @@ ClassChoiceDialog::ClassChoiceDialog(WindowManager& parWindowManager) /* CreateClassDialog */ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager) - : WindowBase("openmw_chargen_create_class_layout.xml", parWindowManager) + : WindowBase("openmw_chargen_create_class.layout", parWindowManager) , specDialog(nullptr) , attribDialog(nullptr) , skillDialog(nullptr) @@ -703,7 +703,7 @@ void CreateClassDialog::onBackClicked(MyGUI::Widget* _sender) /* SelectSpecializationDialog */ SelectSpecializationDialog::SelectSpecializationDialog(WindowManager& parWindowManager) - : WindowBase("openmw_chargen_select_specialization_layout.xml", parWindowManager) + : WindowBase("openmw_chargen_select_specialization.layout", parWindowManager) { // Centre dialog center(); @@ -768,7 +768,7 @@ void SelectSpecializationDialog::onCancelClicked(MyGUI::Widget* _sender) /* SelectAttributeDialog */ SelectAttributeDialog::SelectAttributeDialog(WindowManager& parWindowManager) - : WindowBase("openmw_chargen_select_attribute_layout.xml", parWindowManager) + : WindowBase("openmw_chargen_select_attribute.layout", parWindowManager) { // Centre dialog center(); @@ -820,7 +820,7 @@ void SelectAttributeDialog::onCancelClicked(MyGUI::Widget* _sender) /* SelectSkillDialog */ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager) - : WindowBase("openmw_chargen_select_skill_layout.xml", parWindowManager) + : WindowBase("openmw_chargen_select_skill.layout", parWindowManager) { // Centre dialog center(); @@ -916,7 +916,7 @@ void SelectSkillDialog::onCancelClicked(MyGUI::Widget* _sender) /* DescriptionDialog */ DescriptionDialog::DescriptionDialog(WindowManager& parWindowManager) - : WindowBase("openmw_chargen_class_description_layout.xml", parWindowManager) + : WindowBase("openmw_chargen_class_description.layout", parWindowManager) { // Centre dialog center(); diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index 868052800..c9e7aef7b 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -7,7 +7,7 @@ /* This file contains the dialogs for choosing a class. - Layout is defined by resources/mygui/openmw_chargen_class_layout.xml. + Layout is defined by resources/mygui/openmw_chargen_class.layout. */ namespace MWGui diff --git a/apps/openmw/mwgui/confirmationdialog.cpp b/apps/openmw/mwgui/confirmationdialog.cpp index 5e12c3296..00bdca638 100644 --- a/apps/openmw/mwgui/confirmationdialog.cpp +++ b/apps/openmw/mwgui/confirmationdialog.cpp @@ -3,12 +3,12 @@ #include #include "../mwbase/environment.hpp" -#include "../mwworld/world.hpp" +#include "../mwbase/world.hpp" namespace MWGui { ConfirmationDialog::ConfirmationDialog(WindowManager& parWindowManager) : - WindowBase("openmw_confirmation_dialog_layout.xml", parWindowManager) + WindowBase("openmw_confirmation_dialog.layout", parWindowManager) { getWidget(mMessage, "Message"); getWidget(mOkButton, "OkButton"); diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 8115835f4..4101165c1 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -3,6 +3,9 @@ #include +#include +#include + #include #include "../mwscript/extensions.hpp" @@ -103,7 +106,7 @@ namespace MWGui } Console::Console(int w, int h, const Compiler::Extensions& extensions) - : Layout("openmw_console_layout.xml"), + : Layout("openmw_console.layout"), mCompilerContext (MWScript::CompilerContext::Type_Console) { setCoord(10,10, w-10, h/2); diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 6775fa643..44cb12d2d 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -3,19 +3,23 @@ #include #include #include -#include +#include #include #include #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + #include "../mwworld/manualref.hpp" -#include "../mwworld/world.hpp" #include "../mwworld/containerstore.hpp" #include "../mwworld/class.hpp" #include "../mwworld/player.hpp" + #include "../mwclass/container.hpp" + #include "../mwinput/inputmanager.hpp" + #include "../mwsound/soundmanager.hpp" #include "window_manager.hpp" @@ -273,7 +277,7 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender) // check the container's Organic flag (if this is a container). container with Organic flag doesn't allow putting items inside if (mPtr.getTypeName() == typeid(ESM::Container).name()) { - ESMS::LiveCellRef* ref = mPtr.get(); + MWWorld::LiveCellRef* ref = mPtr.get(); if (ref->base->flags & ESM::Container::Organic) { // user notification @@ -556,7 +560,7 @@ void ContainerBase::addItem(MWWorld::Ptr item, int count) { MWWorld::ContainerStore& containerStore = MWWorld::Class::get(mPtr).getContainerStore(mPtr); - int origCount = item.getRefData().getCount(); + int origCount = item.getRefData().getCount(); item.getRefData().setCount(count); MWWorld::ContainerStoreIterator it = containerStore.add(item); @@ -592,7 +596,7 @@ MWWorld::ContainerStore& ContainerBase::getContainerStore() ContainerWindow::ContainerWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop) : ContainerBase(dragAndDrop) - , WindowBase("openmw_container_window_layout.xml", parWindowManager) + , WindowBase("openmw_container_window.layout", parWindowManager) { getWidget(mTakeButton, "TakeButton"); getWidget(mCloseButton, "CloseButton"); @@ -612,12 +616,9 @@ ContainerWindow::ContainerWindow(WindowManager& parWindowManager,DragAndDrop* dr mCloseButton->setCoord(600-20-closeButtonWidth, mCloseButton->getCoord().top, closeButtonWidth, mCloseButton->getCoord().height); mTakeButton->setCoord(600-20-closeButtonWidth-takeButtonWidth-8, mTakeButton->getCoord().top, takeButtonWidth, mTakeButton->getCoord().height); - int w = MyGUI::RenderManager::getInstance().getViewSize().width; - //int h = MyGUI::RenderManager::getInstance().getViewSize().height; - static_cast(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &ContainerWindow::onWindowResize); - setCoord(w-600,0,600,300); + setCoord(200,0,600,300); } ContainerWindow::~ContainerWindow() @@ -640,7 +641,7 @@ void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender) { if(mDragAndDrop == NULL || !mDragAndDrop->mIsOnDragAndDrop) { - MWBase::Environment::get().getWindowManager()->popGuiMode(); + MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container); } } @@ -671,7 +672,7 @@ void ContainerWindow::onTakeAllButtonClicked(MyGUI::Widget* _sender) containerStore.clear(); - MWBase::Environment::get().getWindowManager()->popGuiMode(); + MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container); } } diff --git a/apps/openmw/mwgui/countdialog.cpp b/apps/openmw/mwgui/countdialog.cpp index e0a9bb908..07f1acb73 100644 --- a/apps/openmw/mwgui/countdialog.cpp +++ b/apps/openmw/mwgui/countdialog.cpp @@ -3,12 +3,12 @@ #include #include "../mwbase/environment.hpp" -#include "../mwworld/world.hpp" +#include "../mwbase/world.hpp" namespace MWGui { CountDialog::CountDialog(WindowManager& parWindowManager) : - WindowBase("openmw_count_window_layout.xml", parWindowManager) + WindowBase("openmw_count_window.layout", parWindowManager) { getWidget(mSlider, "CountSlider"); getWidget(mItemEdit, "ItemEdit"); @@ -77,7 +77,7 @@ namespace MWGui { if (_sender->getCaption() == "") return; - + unsigned int count; try { diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 79b2d68ba..acf0bf130 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -43,7 +43,7 @@ std::string::size_type find_str_ci(const std::string& str, const std::string& su DialogueWindow::DialogueWindow(WindowManager& parWindowManager) - : WindowBase("openmw_dialogue_window_layout.xml", parWindowManager) + : WindowBase("openmw_dialogue_window.layout", parWindowManager) , mEnabled(true) , mShowTrade(false) { @@ -205,11 +205,14 @@ void addColorInString(std::string& str, const std::string& keyword,std::string c std::string DialogueWindow::parseText(std::string text) { + bool separatorReached = false; // only parse topics that are below the separator (this prevents actions like "Barter" that are not topics from getting blue-colored) for(unsigned int i = 0;igetItemCount();i++) { std::string keyWord = topicsList->getItemNameAt(i); - if (keyWord != "") + if (separatorReached && keyWord != "") addColorInString(text,keyWord,"#686EBA","#B29154"); + else + separatorReached = true; } return text; } diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index aa66cd579..5d808b5a7 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -19,7 +19,7 @@ namespace MWGui /* This file contains the dialouge window - Layout is defined by resources/mygui/openmw_dialogue_window_layout.xml. + Layout is defined by resources/mygui/openmw_dialogue_window.layout. */ namespace MWGui diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 95d66eb81..78eefa338 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -7,11 +7,15 @@ #include #include "../mwbase/environment.hpp" -#include "../mwsound/soundmanager.hpp" +#include "../mwbase/world.hpp" + #include "../mwworld/class.hpp" -#include "../mwworld/world.hpp" #include "../mwworld/player.hpp" +#include "../mwsound/soundmanager.hpp" + +#include "../mwgui/widgets.hpp" + #include "inventorywindow.hpp" #include "window_manager.hpp" #include "container.hpp" @@ -20,7 +24,7 @@ using namespace MWGui; HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop) - : Layout("openmw_hud_layout.xml") + : Layout("openmw_hud.layout") , health(NULL) , magicka(NULL) , stamina(NULL) @@ -143,12 +147,12 @@ void HUD::setFPS(float fps) fpscounter->setCaption(boost::lexical_cast((int)fps)); } -void HUD::setTriangleCount(size_t count) +void HUD::setTriangleCount(unsigned int count) { trianglecounter->setCaption(boost::lexical_cast(count)); } -void HUD::setBatchCount(size_t count) +void HUD::setBatchCount(unsigned int count) { batchcounter->setCaption(boost::lexical_cast(count)); } @@ -239,7 +243,7 @@ void HUD::onWorldClicked(MyGUI::Widget* _sender) // drop item into the gameworld MWWorld::Ptr object = *mDragAndDrop->mDraggedWidget->getUserData(); - MWWorld::World* world = MWBase::Environment::get().getWorld(); + MWBase::World* world = MWBase::Environment::get().getWorld(); MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize(); MyGUI::IntPoint cursorPosition = MyGUI::InputManager::getInstance().getMousePosition(); @@ -282,7 +286,7 @@ void HUD::onWorldClicked(MyGUI::Widget* _sender) { object = MWBase::Environment::get().getWorld()->getPtrViaHandle(handle); } - catch (std::exception& e) + catch (std::exception& /* e */) { return; } @@ -308,7 +312,7 @@ void HUD::onWorldMouseOver(MyGUI::Widget* _sender, int x, int y) float mouseX = cursorPosition.left / float(viewSize.width); float mouseY = cursorPosition.top / float(viewSize.height); - MWWorld::World* world = MWBase::Environment::get().getWorld(); + MWBase::World* world = MWBase::Environment::get().getWorld(); // if we can't drop the object at the wanted position, show the "drop on ground" cursor. bool canDrop = world->canPlaceObject(mouseX, mouseY); diff --git a/apps/openmw/mwgui/hud.hpp b/apps/openmw/mwgui/hud.hpp index 0bfe5c20f..c6bcdd4e9 100644 --- a/apps/openmw/mwgui/hud.hpp +++ b/apps/openmw/mwgui/hud.hpp @@ -16,8 +16,8 @@ namespace MWGui void setEffect(const char *img); void setValue (const std::string& id, const MWMechanics::DynamicStat& value); void setFPS(float fps); - void setTriangleCount(size_t count); - void setBatchCount(size_t count); + void setTriangleCount(unsigned int count); + void setBatchCount(unsigned int count); void setBottomLeftVisibility(bool hmsVisible, bool weapVisible, bool spellVisible); void setBottomRightVisibility(bool effectBoxVisible, bool minimapVisible); void setFpsLevel(const int level); diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index a26a958bd..23a96b1d3 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -3,21 +3,24 @@ #include #include #include -#include -#include +#include #include -#include "../mwclass/container.hpp" +#include "../mwbase/world.hpp" +#include "../mwbase/environment.hpp" + #include "../mwworld/containerstore.hpp" #include "../mwworld/class.hpp" -#include "../mwworld/world.hpp" #include "../mwworld/player.hpp" -#include "../mwbase/environment.hpp" #include "../mwworld/manualref.hpp" #include "../mwworld/actiontake.hpp" +#include "../mwworld/inventorystore.hpp" + #include "../mwsound/soundmanager.hpp" +#include "../mwclass/container.hpp" + #include "window_manager.hpp" #include "widgets.hpp" #include "bookwindow.hpp" @@ -42,7 +45,7 @@ namespace MWGui InventoryWindow::InventoryWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop) : ContainerBase(dragAndDrop) - , WindowPinnableBase("openmw_inventory_window_layout.xml", parWindowManager) + , WindowPinnableBase("openmw_inventory_window.layout", parWindowManager) , mTrading(false) { static_cast(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize); @@ -171,7 +174,7 @@ namespace MWGui /// \todo scripts boost::shared_ptr action = MWWorld::Class::get(ptr).use(ptr); - + action->execute(); // this is necessary for books/scrolls: if they are already in the player's inventory, @@ -307,6 +310,9 @@ namespace MWGui && (type != typeid(ESM::Potion).name())) return; + if (MWWorld::Class::get(object).getName(object) == "") // objects without name presented to user can never be picked up + return; + // sound std::string sound = MWWorld::Class::get(object).getUpSoundId(object); MWBase::Environment::get().getSoundManager()->playSound(sound, 1, 1); diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 7f9000bc7..75b546c7b 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -1,11 +1,14 @@ #include "journalwindow.hpp" -#include "window_manager.hpp" -#include "../mwdialogue/journal.hpp" + #include "../mwbase/environment.hpp" -#include "../mwworld/world.hpp" +#include "../mwbase/world.hpp" + +#include "../mwdialogue/journal.hpp" #include "../mwsound/soundmanager.hpp" +#include "window_manager.hpp" + namespace { struct book @@ -80,7 +83,7 @@ book formatText(std::string text,book mBook,int maxLine, int lineSize) MWGui::JournalWindow::JournalWindow (WindowManager& parWindowManager) - : WindowBase("openmw_journal_layout.xml", parWindowManager) + : WindowBase("openmw_journal.layout", parWindowManager) , lastPos(0) , mVisible(false) { diff --git a/apps/openmw/mwgui/mainmenu.hpp b/apps/openmw/mwgui/mainmenu.hpp index b32f2d900..06c59396f 100644 --- a/apps/openmw/mwgui/mainmenu.hpp +++ b/apps/openmw/mwgui/mainmenu.hpp @@ -7,7 +7,7 @@ namespace MWGui { public: MainMenu(int w, int h) - : Layout("openmw_mainmenu_layout.xml") + : Layout("openmw_mainmenu.layout") { setCoord(0,0,w,h); } diff --git a/apps/openmw/mwgui/map_window.cpp b/apps/openmw/mwgui/map_window.cpp index a51b66e2b..4ebeb3874 100644 --- a/apps/openmw/mwgui/map_window.cpp +++ b/apps/openmw/mwgui/map_window.cpp @@ -155,7 +155,7 @@ void LocalMapBase::setPlayerDir(const float x, const float y) // ------------------------------------------------------------------------------------------ MapWindow::MapWindow(WindowManager& parWindowManager) : - MWGui::WindowPinnableBase("openmw_map_window_layout.xml", parWindowManager), + MWGui::WindowPinnableBase("openmw_map_window.layout", parWindowManager), mGlobal(false) { setCoord(500,0,320,300); diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 0bb7d3c1c..68326a3c3 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -58,7 +58,7 @@ void MessageBoxManager::onFrame (float frameDuration) if(mInterMessageBoxe != NULL && mInterMessageBoxe->mMarkedToDelete) { delete mInterMessageBoxe; mInterMessageBoxe = NULL; - mWindowManager->popGuiMode(); + mWindowManager->removeGuiMode(GM_InterMessageBox); } } @@ -86,13 +86,12 @@ void MessageBoxManager::createMessageBox (const std::string& message) bool MessageBoxManager::createInteractiveMessageBox (const std::string& message, const std::vector& buttons) { + /// \todo Don't write this kind of error message to cout. Either discard the old message box + /// silently or throw an exception. if(mInterMessageBoxe != NULL) { std::cout << "there is a MessageBox already" << std::endl; return false; } - std::cout << "interactive MessageBox: " << message << " - "; - std::copy (buttons.begin(), buttons.end(), std::ostream_iterator (std::cout, ", ")); - std::cout << std::endl; mInterMessageBoxe = new InteractiveMessageBox(*this, message, buttons); @@ -148,7 +147,7 @@ int MessageBoxManager::readPressedButton () MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message) - : Layout("openmw_messagebox_layout.xml") + : Layout("openmw_messagebox.layout") , mMessageBoxManager(parMessageBoxManager) , cMessage(message) { @@ -178,7 +177,7 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin size.height = mHeight = textSize.height + 20; // this is the padding between the text and the box mMainWidget->setSize(size); - size.width -= 15; // this is to center the text (see messagebox_layout.xml, Widget type="Edit" position="-2 -3 0 0") + size.width -= 15; // this is to center the text (see messagebox.layout, Widget type="Edit" position="-2 -3 0 0") mMessageWidget->setSize(size); } @@ -206,7 +205,7 @@ int MessageBox::getHeight () InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector& buttons) - : Layout("openmw_interactive_messagebox_layout.xml") + : Layout("openmw_interactive_messagebox.layout") , mMessageBoxManager(parMessageBoxManager) , mButtonPressed(-1) { @@ -266,11 +265,8 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan if(buttonsWidth < fixedWidth) { // on one line - std::cout << "on one line" << std::endl; - if(textSize.width + 2*textPadding < buttonsWidth) { - std::cout << "width = buttonsWidth" << std::endl; mainWidgetSize.width = buttonsWidth; } else @@ -283,13 +279,9 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan absCoord.left = (gameWindowSize.width - mainWidgetSize.width)/2; absCoord.top = (gameWindowSize.height - mainWidgetSize.height)/2; - std::cout << "width " << mainWidgetSize.width << " height " << mainWidgetSize.height << std::endl; - std::cout << "left " << absCoord.left << " top " << absCoord.top << std::endl; - mMainWidget->setCoord(absCoord); mMainWidget->setSize(mainWidgetSize); - MyGUI::IntCoord messageWidgetCoord; messageWidgetCoord.left = (mainWidgetSize.width - textSize.width)/2; messageWidgetCoord.top = textPadding; @@ -319,7 +311,6 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan else { // among each other - if(biggestButtonWidth > textSize.width) { mainWidgetSize.width = biggestButtonWidth + buttonTopPadding; } @@ -328,8 +319,6 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan } mainWidgetSize.height = textSize.height + 2*textPadding + textButtonPadding + buttonHeight * buttons.size() + buttonMainPadding; - std::cout << "biggestButtonWidth " << biggestButtonWidth << " textSize.width " << textSize.width << std::endl; - std::cout << "width " << mainWidgetSize.width << " height " << mainWidgetSize.height << std::endl; mMainWidget->setSize(mainWidgetSize); MyGUI::IntCoord absCoord; @@ -384,7 +373,6 @@ void InteractiveMessageBox::mousePressed (MyGUI::Widget* pressed) } index++; } - std::cout << "Cant be possible :/" << std::endl; } int InteractiveMessageBox::readPressedButton () diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index dea365ac2..9ae453016 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -17,7 +17,7 @@ using namespace MWGui; using namespace Widgets; RaceDialog::RaceDialog(WindowManager& parWindowManager) - : WindowBase("openmw_chargen_race_layout.xml", parWindowManager) + : WindowBase("openmw_chargen_race.layout", parWindowManager) , genderIndex(0) , faceIndex(0) , hairIndex(0) diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index bcd3b5185..217ce15aa 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -14,7 +14,7 @@ namespace MWGui /* This file contains the dialog for choosing a race. - Layout is defined by resources/mygui/openmw_chargen_race_layout.xml. + Layout is defined by resources/mygui/openmw_chargen_race.layout. */ namespace MWGui diff --git a/apps/openmw/mwgui/referenceinterface.cpp b/apps/openmw/mwgui/referenceinterface.cpp index c6e710952..b1f7affb6 100644 --- a/apps/openmw/mwgui/referenceinterface.cpp +++ b/apps/openmw/mwgui/referenceinterface.cpp @@ -1,9 +1,10 @@ #include "referenceinterface.hpp" -#include "../mwworld/player.hpp" -#include "../mwworld/world.hpp" +#include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" +#include "../mwworld/player.hpp" + namespace MWGui { ReferenceInterface::ReferenceInterface() @@ -11,6 +12,10 @@ namespace MWGui { } + ReferenceInterface::~ReferenceInterface() + { + } + void ReferenceInterface::checkReferenceAvailable() { if (mPtr.isEmpty()) diff --git a/apps/openmw/mwgui/referenceinterface.hpp b/apps/openmw/mwgui/referenceinterface.hpp index 40844b238..39574d0f7 100644 --- a/apps/openmw/mwgui/referenceinterface.hpp +++ b/apps/openmw/mwgui/referenceinterface.hpp @@ -13,6 +13,7 @@ namespace MWGui { public: ReferenceInterface(); + virtual ~ReferenceInterface(); void checkReferenceAvailable(); ///< closes the window, if the MW-reference has become unavailable @@ -22,7 +23,7 @@ namespace MWGui MWWorld::Ptr mPtr; private: - MWWorld::Ptr::CellStore* mCurrentPlayerCell; + MWWorld::CellStore* mCurrentPlayerCell; }; } diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index 97a3a6e15..f9792ea34 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -20,7 +20,7 @@ using namespace Widgets; const int ReviewDialog::lineHeight = 18; ReviewDialog::ReviewDialog(WindowManager& parWindowManager) - : WindowBase("openmw_chargen_review_layout.xml", parWindowManager) + : WindowBase("openmw_chargen_review.layout", parWindowManager) , lastPos(0) { // Centre dialog diff --git a/apps/openmw/mwgui/review.hpp b/apps/openmw/mwgui/review.hpp index 6118168d5..454a6c5a5 100644 --- a/apps/openmw/mwgui/review.hpp +++ b/apps/openmw/mwgui/review.hpp @@ -12,7 +12,7 @@ namespace MWGui /* This file contains the dialog for reviewing the generated character. -Layout is defined by resources/mygui/openmw_chargen_review_layout.xml. +Layout is defined by resources/mygui/openmw_chargen_review.layout. */ namespace MWGui diff --git a/apps/openmw/mwgui/scrollwindow.cpp b/apps/openmw/mwgui/scrollwindow.cpp index f4d45fc26..e6ff71a14 100644 --- a/apps/openmw/mwgui/scrollwindow.cpp +++ b/apps/openmw/mwgui/scrollwindow.cpp @@ -11,7 +11,7 @@ using namespace MWGui; ScrollWindow::ScrollWindow (WindowManager& parWindowManager) : - WindowBase("openmw_scroll_layout.xml", parWindowManager) + WindowBase("openmw_scroll.layout", parWindowManager) { getWidget(mTextView, "TextView"); @@ -31,8 +31,7 @@ void ScrollWindow::open (MWWorld::Ptr scroll) mScroll = scroll; - ESMS::LiveCellRef *ref = - mScroll.get(); + MWWorld::LiveCellRef *ref = mScroll.get(); BookTextParser parser; MyGUI::IntSize size = parser.parse(ref->base->text, mTextView, 390); @@ -56,7 +55,7 @@ void ScrollWindow::onCloseButtonClicked (MyGUI::Widget* _sender) { MWBase::Environment::get().getSoundManager()->playSound ("scroll", 1.0, 1.0); - mWindowManager.popGuiMode(); + mWindowManager.removeGuiMode(GM_Scroll); } void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender) @@ -66,5 +65,5 @@ void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender) MWWorld::ActionTake take(mScroll); take.execute(); - mWindowManager.popGuiMode(); + mWindowManager.removeGuiMode(GM_Scroll); } diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index 67ccf9d53..5e25d5ece 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -5,12 +5,18 @@ #include #include +#include +#include #include #include "../mwbase/environment.hpp" -#include "../mwworld/world.hpp" +#include "../mwbase/world.hpp" + +#include "../mwrender/renderingmanager.hpp" + #include "../mwsound/soundmanager.hpp" + #include "../mwinput/inputmanager.hpp" #include "window_manager.hpp" @@ -39,12 +45,41 @@ namespace else return "Trilinear"; } + + void parseResolution (int &x, int &y, const std::string& str) + { + std::vector split; + boost::algorithm::split (split, str, boost::is_any_of("@(x")); + assert (split.size() >= 2); + boost::trim(split[0]); + boost::trim(split[1]); + x = boost::lexical_cast (split[0]); + y = boost::lexical_cast (split[1]); + } + + bool sortResolutions (std::pair left, std::pair right) + { + if (left.first == right.first) + return left.second > right.second; + return left.first > right.first; + } + + std::string getAspect (int x, int y) + { + int gcd = boost::math::gcd (x, y); + int xaspect = x / gcd; + int yaspect = y / gcd; + // special case: 8 : 5 is usually referred to as 16:10 + if (xaspect == 8 && yaspect == 5) + return "16 : 10"; + return boost::lexical_cast(xaspect) + " : " + boost::lexical_cast(yaspect); + } } namespace MWGui { SettingsWindow::SettingsWindow(WindowManager& parWindowManager) : - WindowBase("openmw_settings_window_layout.xml", parWindowManager) + WindowBase("openmw_settings_window.layout", parWindowManager) { getWidget(mOkButton, "OkButton"); getWidget(mResolutionList, "ResolutionList"); @@ -99,11 +134,25 @@ namespace MWGui // fill resolution list Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem(); - const Ogre::StringVector& videoModes = rs->getConfigOptions()["Video Mode"].possibleValues; + Ogre::StringVector videoModes = rs->getConfigOptions()["Video Mode"].possibleValues; + std::vector < std::pair > resolutions; for (Ogre::StringVector::const_iterator it=videoModes.begin(); it!=videoModes.end(); ++it) { - mResolutionList->addItem(*it); + + int resX, resY; + parseResolution (resX, resY, *it); + resolutions.push_back(std::make_pair(resX, resY)); + } + std::sort(resolutions.begin(), resolutions.end(), sortResolutions); + for (std::vector < std::pair >::const_iterator it=resolutions.begin(); + it!=resolutions.end(); ++it) + { + std::string str = boost::lexical_cast(it->first) + " x " + boost::lexical_cast(it->second) + + " (" + getAspect(it->first,it->second) + ")"; + + if (mResolutionList->findItemIndexWith(str) == MyGUI::ITEM_NONE) + mResolutionList->addItem(str); } // read settings @@ -155,7 +204,7 @@ namespace MWGui void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender) { - mWindowManager.popGuiMode(); + mWindowManager.removeGuiMode(GM_Settings); } void SettingsWindow::onResolutionSelected(MyGUI::ListBox* _sender, size_t index) @@ -168,19 +217,13 @@ namespace MWGui dialog->eventOkClicked.clear(); dialog->eventOkClicked += MyGUI::newDelegate(this, &SettingsWindow::onResolutionAccept); dialog->eventCancelClicked.clear(); - dialog->eventCancelClicked += MyGUI::newDelegate(this, &SettingsWindow::onResolutionAccept); } void SettingsWindow::onResolutionAccept() { std::string resStr = mResolutionList->getItemNameAt(mResolutionList->getIndexSelected()); - size_t xPos = resStr.find("x"); - std::string resXStr = resStr.substr(0, xPos-1); - Ogre::StringUtil::trim(resXStr); - std::string resYStr = resStr.substr(xPos+2, resStr.size()-(xPos+2)); - Ogre::StringUtil::trim(resYStr); - int resX = boost::lexical_cast(resXStr); - int resY = boost::lexical_cast(resYStr); + int resX, resY; + parseResolution (resX, resY, resStr); Settings::Manager::setInt("resolution x", "Video", resX); Settings::Manager::setInt("resolution y", "Video", resY); @@ -217,13 +260,8 @@ namespace MWGui for (unsigned int i=0; igetItemCount(); ++i) { std::string resStr = mResolutionList->getItemNameAt(i); - size_t xPos = resStr.find("x"); - std::string resXStr = resStr.substr(0, xPos-1); - Ogre::StringUtil::trim(resXStr); - std::string resYStr = resStr.substr(xPos+2, resStr.size()-(xPos+2)); - Ogre::StringUtil::trim(resYStr); - int resX = boost::lexical_cast(resXStr); - int resY = boost::lexical_cast(resYStr); + int resX, resY; + parseResolution (resX, resY, resStr); if (resX == Settings::Manager::getInt("resolution x", "Video") && resY == Settings::Manager::getInt("resolution y", "Video")) diff --git a/apps/openmw/mwgui/spellwindow.cpp b/apps/openmw/mwgui/spellwindow.cpp index d34ce68d9..f6e7d3b77 100644 --- a/apps/openmw/mwgui/spellwindow.cpp +++ b/apps/openmw/mwgui/spellwindow.cpp @@ -4,13 +4,18 @@ #include #include -#include "../mwworld/world.hpp" +#include + +#include "../mwbase/world.hpp" +#include "../mwbase/environment.hpp" + #include "../mwworld/player.hpp" #include "../mwworld/inventorystore.hpp" -#include "../mwbase/environment.hpp" + #include "../mwmechanics/spells.hpp" #include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/spellsuccess.hpp" + #include "../mwsound/soundmanager.hpp" #include "window_manager.hpp" @@ -39,7 +44,7 @@ namespace namespace MWGui { SpellWindow::SpellWindow(WindowManager& parWindowManager) - : WindowPinnableBase("openmw_spell_window_layout.xml", parWindowManager) + : WindowPinnableBase("openmw_spell_window.layout", parWindowManager) , mHeight(0) , mWidth(0) { @@ -144,9 +149,11 @@ namespace MWGui powers.push_back(*it); it = spellList.erase(it); } - else if (spell->data.type == ESM::Spell::ST_Ability) + else if (spell->data.type == ESM::Spell::ST_Ability + || spell->data.type == ESM::Spell::ST_Blight + || spell->data.type == ESM::Spell::ST_Curse + || spell->data.type == ESM::Spell::ST_Disease) { - // abilities are always active and don't show in the spell window. it = spellList.erase(it); } else diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 3584af7c7..0f8b41b28 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -6,10 +6,13 @@ #include -#include "../mwmechanics/mechanicsmanager.hpp" -#include "../mwworld/world.hpp" -#include "../mwworld/player.hpp" #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + +#include "../mwworld/player.hpp" +#include "../mwworld/class.hpp" + +#include "../mwmechanics/mechanicsmanager.hpp" #include "window_manager.hpp" #include "tooltips.hpp" @@ -19,7 +22,7 @@ using namespace MWGui; const int StatsWindow::lineHeight = 18; StatsWindow::StatsWindow (WindowManager& parWindowManager) - : WindowPinnableBase("openmw_stats_window_layout.xml", parWindowManager) + : WindowPinnableBase("openmw_stats_window.layout", parWindowManager) , skillAreaWidget(NULL) , skillClientWidget(NULL) , skillScrollerWidget(NULL) @@ -539,7 +542,7 @@ void StatsWindow::updateSkillArea() skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipLayout", "TextToolTip"); skillWidgets[skillWidgets.size()-1-i]->setUserString("Caption_Text", "#{sSkillsMenuReputationHelp}"); } - + addValueItem(mWindowManager.getGameSettingString("sBounty", "Bounty"), boost::lexical_cast(static_cast(bounty)), "normal", coord1, coord2); diff --git a/apps/openmw/mwgui/text_input.cpp b/apps/openmw/mwgui/text_input.cpp index 7d84a9b9f..17852ba5a 100644 --- a/apps/openmw/mwgui/text_input.cpp +++ b/apps/openmw/mwgui/text_input.cpp @@ -4,7 +4,7 @@ using namespace MWGui; TextInputDialog::TextInputDialog(WindowManager& parWindowManager) - : WindowBase("openmw_text_input_layout.xml", parWindowManager) + : WindowBase("openmw_text_input.layout", parWindowManager) { // Centre dialog center(); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 7ec444168..679c7a59e 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -1,20 +1,24 @@ #include "tooltips.hpp" -#include "window_manager.hpp" -#include "widgets.hpp" -#include "../mwworld/class.hpp" -#include "../mwworld/world.hpp" -#include "../mwbase/environment.hpp" - #include +#include + #include +#include "../mwbase/world.hpp" +#include "../mwbase/environment.hpp" + +#include "../mwworld/class.hpp" + +#include "window_manager.hpp" +#include "widgets.hpp" + using namespace MWGui; using namespace MyGUI; ToolTips::ToolTips(WindowManager* windowManager) : - Layout("openmw_tooltips.xml") + Layout("openmw_tooltips.layout") , mGameMode(true) , mWindowManager(windowManager) , mFullHelp(false) @@ -77,7 +81,7 @@ void ToolTips::onFrame(float frameDuration) { mFocusObject = MWBase::Environment::get().getWorld()->getPtrViaHandle(handle); } - catch (std::exception& e) + catch (std::exception /* & e */) { return; } @@ -392,7 +396,7 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info) /** * \todo - * the various potion effects should appear in the tooltip depending if the player + * the various potion effects should appear in the tooltip depending if the player * has enough skill in alchemy to know about the effects of this potion. */ @@ -564,8 +568,6 @@ void ToolTips::createAttributeToolTip(MyGUI::Widget* widget, int attributeId) if (attributeId == -1) return; - const ESM::Attribute* attr = MWBase::Environment::get().getWorld()->getStore().attributes.search(attributeId); - assert(attr); std::string icon = ESM::Attribute::attributeIcons[attributeId]; std::string name = ESM::Attribute::gmstAttributeIds[attributeId]; std::string desc = ESM::Attribute::gmstAttributeDescIds[attributeId]; diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 47d299fdc..d9f9692ff 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -3,7 +3,8 @@ #include #include "../mwbase/environment.hpp" -#include "../mwworld/world.hpp" +#include "../mwbase/world.hpp" + #include "../mwworld/inventorystore.hpp" #include "../mwworld/manualref.hpp" #include "../mwsound/soundmanager.hpp" @@ -14,7 +15,7 @@ namespace MWGui { TradeWindow::TradeWindow(WindowManager& parWindowManager) : - WindowBase("openmw_trade_window_layout.xml", parWindowManager) + WindowBase("openmw_trade_window.layout", parWindowManager) , ContainerBase(NULL) // no drag&drop , mCurrentBalance(0) { @@ -86,7 +87,7 @@ namespace MWGui offerButtonWidth, mOfferButton->getHeight()); - setCoord(400, 0, 400, 300); + setCoord(400, 0, 400, 300); static_cast(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &TradeWindow::onWindowResize); } @@ -161,7 +162,7 @@ namespace MWGui int merchantgold; if (mPtr.getTypeName() == typeid(ESM::NPC).name()) { - ESMS::LiveCellRef* ref = mPtr.get(); + MWWorld::LiveCellRef* ref = mPtr.get(); if (ref->base->npdt52.gold == -10) merchantgold = ref->base->npdt12.gold; else @@ -169,7 +170,7 @@ namespace MWGui } else // ESM::Creature { - ESMS::LiveCellRef* ref = mPtr.get(); + MWWorld::LiveCellRef* ref = mPtr.get(); merchantgold = ref->base->data.gold; } if (mCurrentBalance > 0 && merchantgold < mCurrentBalance) @@ -212,7 +213,7 @@ namespace MWGui std::string sound = "Item Gold Up"; MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); - mWindowManager.popGuiMode(); + mWindowManager.removeGuiMode(GM_Barter); } void TradeWindow::onCancelButtonClicked(MyGUI::Widget* _sender) @@ -222,7 +223,7 @@ namespace MWGui // now gimme back my stuff! mWindowManager.getInventoryWindow()->returnBoughtItems(MWWorld::Class::get(mPtr).getContainerStore(mPtr)); - mWindowManager.popGuiMode(); + mWindowManager.removeGuiMode(GM_Barter); } void TradeWindow::updateLabels() @@ -244,7 +245,7 @@ namespace MWGui int merchantgold; if (mPtr.getTypeName() == typeid(ESM::NPC).name()) { - ESMS::LiveCellRef* ref = mPtr.get(); + MWWorld::LiveCellRef* ref = mPtr.get(); if (ref->base->npdt52.gold == -10) merchantgold = ref->base->npdt12.gold; else @@ -252,7 +253,7 @@ namespace MWGui } else // ESM::Creature { - ESMS::LiveCellRef* ref = mPtr.get(); + MWWorld::LiveCellRef* ref = mPtr.get(); merchantgold = ref->base->data.gold; } @@ -289,13 +290,13 @@ namespace MWGui int services = 0; if (mPtr.getTypeName() == typeid(ESM::NPC).name()) { - ESMS::LiveCellRef* ref = mPtr.get(); + MWWorld::LiveCellRef* ref = mPtr.get(); if (ref->base->hasAI) services = ref->base->AI.services; } else if (mPtr.getTypeName() == typeid(ESM::Creature).name()) { - ESMS::LiveCellRef* ref = mPtr.get(); + MWWorld::LiveCellRef* ref = mPtr.get(); if (ref->base->hasAI) services = ref->base->AI.services; } diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 5b963d3ae..62207d7d7 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -26,14 +26,16 @@ #include "../mwbase/environment.hpp" +#include "../mwworld/ptr.hpp" +#include "../mwworld/cellstore.hpp" + #include "console.hpp" #include "journalwindow.hpp" #include "charactercreation.hpp" #include -#include -#include +#include #include using namespace MWGui; @@ -82,7 +84,7 @@ WindowManager::WindowManager( // Set up the GUI system mGuiManager = new OEngine::GUI::MyGUIManager(mOgre->getWindow(), mOgre->getScene(), false, logpath); gui = mGuiManager->getGui(); - + //Register own widgets with MyGUI MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); @@ -464,7 +466,7 @@ void WindowManager::onDialogueWindowBye() //removeDialog(dialogueWindow); mDialogueWindow->setVisible(false); } - popGuiMode(); + removeGuiMode(GM_Dialogue); } void WindowManager::onFrame (float frameDuration) @@ -638,6 +640,9 @@ void WindowManager::processChangedSettings(const Settings::CategorySettingVector hud->onResChange(x, y); console->onResChange(x, y); mSettingsWindow->center(); + mAlchemyWindow->center(); + mScrollWindow->center(); + mBookWindow->center(); mDragAndDrop->mDragAndDropWidget->setSize(MyGUI::IntSize(x, y)); } } @@ -677,6 +682,9 @@ void WindowManager::removeGuiMode(GuiMode mode) ++it; } + bool gameMode = !isGuiMode(); + MWBase::Environment::get().getInputManager()->changeInputMode(!gameMode); + updateVisible(); } diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 37f30c59a..03ffa6b59 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -22,7 +22,6 @@ #include #include "../mwmechanics/stat.hpp" -#include "../mwworld/ptr.hpp" #include "mode.hpp" @@ -39,7 +38,8 @@ namespace Compiler namespace MWWorld { - class World; + class Ptr; + class CellStore; } namespace MWMechanics @@ -159,7 +159,7 @@ namespace MWGui MyGUI::Gui* getGui() const { return gui; } - void wmUpdateFps(float fps, size_t triangleCount, size_t batchCount) + void wmUpdateFps(float fps, unsigned int triangleCount, unsigned int batchCount) { mFPS = fps; mTriangleCount = triangleCount; @@ -181,7 +181,7 @@ namespace MWGui void setBounty (int bounty); ///< set the current bounty value void updateSkillArea(); ///< update display of skills, factions, birth sign, reputation and bounty - void changeCell(MWWorld::Ptr::CellStore* cell); ///< change the active cell + void changeCell(MWWorld::CellStore* cell); ///< change the active cell void setPlayerPos(const float x, const float y); ///< set player position in map space void setPlayerDir(const float x, const float y); ///< set player view direction in map space @@ -295,14 +295,14 @@ namespace MWGui int showFPSLevel; float mFPS; - size_t mTriangleCount; - size_t mBatchCount; + unsigned int mTriangleCount; + unsigned int mBatchCount; void onDialogueWindowBye(); /** * Called when MyGUI tries to retrieve a tag. This usually corresponds to a GMST string, - * so this method will retrieve the GMST with the name \a _tag and place the result in \a _result + * so this method will retrieve the GMST with the name \a _tag and place the result in \a _result */ void onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _result); }; diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index ced2a5c3f..aedfcd2ea 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -3,9 +3,10 @@ #include -#include "../mwbase/environment.hpp" +#include -#include "../mwworld/world.hpp" +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" namespace MWMechanics { diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 8f8fd6871..95747dbbf 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -3,6 +3,8 @@ #include +#include + #include #include "../mwworld/class.hpp" diff --git a/apps/openmw/mwmechanics/actors.hpp b/apps/openmw/mwmechanics/actors.hpp index 1be29463f..82f8a943c 100644 --- a/apps/openmw/mwmechanics/actors.hpp +++ b/apps/openmw/mwmechanics/actors.hpp @@ -5,13 +5,17 @@ #include #include -#include "../mwworld/ptr.hpp" - namespace Ogre { class Vector3; } +namespace MWWorld +{ + class Ptr; + class CellStore; +} + namespace MWMechanics { class Actors @@ -35,7 +39,7 @@ namespace MWMechanics /// /// \note Ignored, if \a ptr is not a registered actor. - void dropActors (const MWWorld::Ptr::CellStore *cellStore); + void dropActors (const MWWorld::CellStore *cellStore); ///< Deregister all actors in the given cell. void update (std::vector >& movement, diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index cc3c409da..8d40e1942 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -19,6 +19,10 @@ namespace MWMechanics Spells mSpells; ActiveSpells mActiveSpells; MagicEffects mMagicEffects; + int mHello; + int mFight; + int mFlee; + int mAlarm; }; } diff --git a/apps/openmw/mwmechanics/mechanicsmanager.cpp b/apps/openmw/mwmechanics/mechanicsmanager.cpp index 331074ef7..13052d064 100644 --- a/apps/openmw/mwmechanics/mechanicsmanager.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanager.cpp @@ -3,14 +3,14 @@ #include -#include "../mwgui/window_manager.hpp" - #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/class.hpp" -#include "../mwworld/world.hpp" #include "../mwworld/player.hpp" +#include "../mwgui/window_manager.hpp" + namespace MWMechanics { void MechanicsManager::buildPlayer() diff --git a/apps/openmw/mwmechanics/mechanicsmanager.hpp b/apps/openmw/mwmechanics/mechanicsmanager.hpp index 62bb4cf7e..97bb369fd 100644 --- a/apps/openmw/mwmechanics/mechanicsmanager.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanager.hpp @@ -15,6 +15,11 @@ namespace Ogre class Vector3; } +namespace MWWorld +{ + class CellStore; +} + namespace MWMechanics { class MechanicsManager @@ -43,7 +48,7 @@ namespace MWMechanics void removeActor (const MWWorld::Ptr& ptr); ///< Deregister an actor for stats management - void dropActors (const MWWorld::Ptr::CellStore *cellStore); + void dropActors (const MWWorld::CellStore *cellStore); ///< Deregister all actors in the given cell. void watchActor (const MWWorld::Ptr& ptr); diff --git a/apps/openmw/mwmechanics/spells.cpp b/apps/openmw/mwmechanics/spells.cpp index 70eb78639..5d21d96d0 100644 --- a/apps/openmw/mwmechanics/spells.cpp +++ b/apps/openmw/mwmechanics/spells.cpp @@ -1,11 +1,12 @@ #include "spells.hpp" +#include + #include #include "../mwbase/environment.hpp" - -#include "../mwworld/world.hpp" +#include "../mwbase/world.hpp" #include "magiceffects.hpp" diff --git a/apps/openmw/mwmechanics/spellsuccess.hpp b/apps/openmw/mwmechanics/spellsuccess.hpp index 11ac7cda7..54172a72a 100644 --- a/apps/openmw/mwmechanics/spellsuccess.hpp +++ b/apps/openmw/mwmechanics/spellsuccess.hpp @@ -1,9 +1,11 @@ #ifndef MWMECHANICS_SPELLSUCCESS_H #define MWMECHANICS_SPELLSUCCESS_H -#include "../mwworld/ptr.hpp" -#include "../mwworld/world.hpp" +#include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" + +#include "../mwworld/ptr.hpp" +#include "../mwworld/class.hpp" #include "../mwmechanics/creaturestats.hpp" #include "npcstats.hpp" diff --git a/apps/openmw/mwrender/actors.cpp b/apps/openmw/mwrender/actors.cpp index 152cf3277..b37921b0c 100644 --- a/apps/openmw/mwrender/actors.cpp +++ b/apps/openmw/mwrender/actors.cpp @@ -1,7 +1,7 @@ #include "actors.hpp" + #include - - +#include using namespace Ogre; diff --git a/apps/openmw/mwrender/actors.hpp b/apps/openmw/mwrender/actors.hpp index 432bcc297..63cd3baa1 100644 --- a/apps/openmw/mwrender/actors.hpp +++ b/apps/openmw/mwrender/actors.hpp @@ -1,26 +1,29 @@ #ifndef _GAME_RENDER_ACTORS_H #define _GAME_RENDER_ACTORS_H -#include "components/esm_store/cell_store.hpp" #include #include - - #include #include "components/nifogre/ogre_nif_loader.hpp" #include "../mwworld/refdata.hpp" -#include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" + #include "npcanimation.hpp" #include "creatureanimation.hpp" #include +namespace MWWorld +{ + class Ptr; + class CellStore; +} + namespace MWRender{ class Actors{ OEngine::Render::OgreRenderer &mRend; - std::map mCellSceneNodes; + std::map mCellSceneNodes; Ogre::SceneNode* mMwRoot; std::map mAllActors; @@ -36,7 +39,7 @@ namespace MWRender{ bool deleteObject (const MWWorld::Ptr& ptr); ///< \return found? - void removeCell(MWWorld::Ptr::CellStore* store); + void removeCell(MWWorld::CellStore* store); void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number = 1); diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index fc6258208..f0a6ab683 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -1,5 +1,10 @@ #include "animation.hpp" +#include +#include +#include +#include +#include namespace MWRender{ std::map Animation::mUniqueIDs; diff --git a/apps/openmw/mwrender/compositors.cpp b/apps/openmw/mwrender/compositors.cpp index 6f97269ab..b1c98a306 100644 --- a/apps/openmw/mwrender/compositors.cpp +++ b/apps/openmw/mwrender/compositors.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include using namespace MWRender; @@ -69,3 +71,38 @@ void Compositors::removeAll() mCompositors.clear(); } + +bool Compositors::anyCompositorEnabled() +{ + for (CompositorMap::iterator it=mCompositors.begin(); + it != mCompositors.end(); ++it) + { + if (it->second.first && mEnabled) + return true; + } + return false; +} + +void Compositors::countTrianglesBatches(unsigned int &triangles, unsigned int &batches) +{ + triangles = 0; + batches = 0; + + Ogre::CompositorInstance* c = NULL; + Ogre::CompositorChain* chain = Ogre::CompositorManager::getSingleton().getCompositorChain (mViewport); + // accumulate tris & batches from all compositors with all their render targets + for (unsigned int i=0; i < chain->getNumCompositors(); ++i) + { + if (chain->getCompositor(i)->getEnabled()) + { + c = chain->getCompositor(i); + for (unsigned int j = 0; j < c->getTechnique()->getNumTargetPasses(); ++j) + { + std::string textureName = c->getTechnique()->getTargetPass(j)->getOutputName(); + Ogre::RenderTarget* rt = c->getRenderTarget(textureName); + triangles += rt->getTriangleCount(); + batches += rt->getBatchCount(); + } + } + } +} diff --git a/apps/openmw/mwrender/compositors.hpp b/apps/openmw/mwrender/compositors.hpp index bbd838b8e..e5dd7503c 100644 --- a/apps/openmw/mwrender/compositors.hpp +++ b/apps/openmw/mwrender/compositors.hpp @@ -44,6 +44,10 @@ namespace MWRender */ void addCompositor (const std::string& name, const int priority); + bool anyCompositorEnabled(); + + void countTrianglesBatches(unsigned int &triangles, unsigned int &batches); + void removeAll (); protected: diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index 9ca3ed731..e1fa7868c 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -1,7 +1,12 @@ #include "creatureanimation.hpp" + +#include +#include +#include + #include "renderconst.hpp" -#include "../mwworld/world.hpp" +#include "../mwbase/world.hpp" using namespace Ogre; using namespace NifOgre; @@ -12,7 +17,7 @@ CreatureAnimation::~CreatureAnimation(){ } CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend): Animation(_rend){ insert = ptr.getRefData().getBaseNode(); - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); diff --git a/apps/openmw/mwrender/debugging.cpp b/apps/openmw/mwrender/debugging.cpp index 9086a9bc4..91b217a36 100644 --- a/apps/openmw/mwrender/debugging.cpp +++ b/apps/openmw/mwrender/debugging.cpp @@ -1,18 +1,23 @@ #include "debugging.hpp" -#include +#include #include #include #include #include +#include -#include "../mwworld/world.hpp" // these includes can be removed once the static-hack is gone -#include "../mwbase/environment.hpp" -#include "../mwworld/ptr.hpp" #include #include +#include + +#include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone +#include "../mwbase/environment.hpp" + +#include "../mwworld/ptr.hpp" + #include "player.hpp" using namespace Ogre; @@ -162,11 +167,11 @@ Debugging::~Debugging() bool Debugging::toggleRenderMode (int mode){ switch (mode) { - case MWWorld::World::Render_CollisionDebug: + case MWBase::World::Render_CollisionDebug: return mEngine->toggleDebugRendering(); - case MWWorld::World::Render_Pathgrid: + case MWBase::World::Render_Pathgrid: togglePathgrid(); return mPathgridEnabled; } diff --git a/apps/openmw/mwrender/debugging.hpp b/apps/openmw/mwrender/debugging.hpp index e12c0647c..d312b6d54 100644 --- a/apps/openmw/mwrender/debugging.hpp +++ b/apps/openmw/mwrender/debugging.hpp @@ -4,11 +4,15 @@ #include #include #include -#include "../mwworld/ptr.hpp" #include #include +namespace ESM +{ + struct Pathgrid; +} + namespace Ogre { class Camera; @@ -22,7 +26,8 @@ namespace Ogre namespace MWWorld { - class World; + class Ptr; + class CellStore; } namespace MWRender @@ -39,7 +44,7 @@ namespace MWRender void togglePathgrid(); - typedef std::vector CellList; + typedef std::vector CellList; CellList mActiveCells; Ogre::SceneNode *mMwRoot; @@ -50,8 +55,8 @@ namespace MWRender ExteriorPathgridNodes mExteriorPathgridNodes; Ogre::SceneNode *mInteriorPathgridNode; - void enableCellPathgrid(MWWorld::Ptr::CellStore *store); - void disableCellPathgrid(MWWorld::Ptr::CellStore *store); + void enableCellPathgrid(MWWorld::CellStore *store); + void disableCellPathgrid(MWWorld::CellStore *store); // utility void destroyCellPathgridNode(Ogre::SceneNode *node); @@ -70,8 +75,8 @@ namespace MWRender ~Debugging(); bool toggleRenderMode (int mode); - void cellAdded(MWWorld::Ptr::CellStore* store); - void cellRemoved(MWWorld::Ptr::CellStore* store); + void cellAdded(MWWorld::CellStore* store); + void cellRemoved(MWWorld::CellStore* store); }; diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index 2442700bb..dd0351721 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -1,13 +1,16 @@ #include "localmap.hpp" -#include "renderingmanager.hpp" - -#include "../mwbase/environment.hpp" -#include "../mwworld/world.hpp" -#include "../mwgui/window_manager.hpp" -#include "renderconst.hpp" #include #include +#include + +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + +#include "../mwgui/window_manager.hpp" + +#include "renderconst.hpp" +#include "renderingmanager.hpp" using namespace MWRender; using namespace Ogre; diff --git a/apps/openmw/mwrender/localmap.hpp b/apps/openmw/mwrender/localmap.hpp index 9e03988f3..c5cd908fc 100644 --- a/apps/openmw/mwrender/localmap.hpp +++ b/apps/openmw/mwrender/localmap.hpp @@ -1,10 +1,15 @@ #ifndef _GAME_RENDER_LOCALMAP_H #define _GAME_RENDER_LOCALMAP_H -#include "../mwworld/ptr.hpp" - #include +#include + +namespace MWWorld +{ + class CellStore; +} + namespace MWRender { class RenderingManager; @@ -24,7 +29,7 @@ namespace MWRender * or rendered if it is not already cached. * @param exterior cell */ - void requestMap (MWWorld::Ptr::CellStore* cell); + void requestMap (MWWorld::CellStore* cell); /** * Request the local map for an interior cell. @@ -33,7 +38,7 @@ namespace MWRender * @param interior cell * @param bounding box of the cell */ - void requestMap (MWWorld::Ptr::CellStore* cell, + void requestMap (MWWorld::CellStore* cell, Ogre::AxisAlignedBox bounds); /** @@ -51,7 +56,7 @@ namespace MWRender * new cell, as well as when the game is quit. * @param current cell */ - void saveFogOfWar(MWWorld::Ptr::CellStore* cell); + void saveFogOfWar(MWWorld::CellStore* cell); private: OEngine::Render::OgreRenderer* mRendering; diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 5ceafca36..fa88b7277 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -1,8 +1,15 @@ #include "npcanimation.hpp" -#include "../mwworld/world.hpp" -#include "renderconst.hpp" + +#include +#include +#include + +#include #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + +#include "renderconst.hpp" using namespace Ogre; using namespace NifOgre; @@ -38,7 +45,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRendere lfoot(0), rfoot(0) { - ESMS::LiveCellRef *ref = + MWWorld::LiveCellRef *ref = ptr.get(); Ogre::Entity* blank = 0; std::vector* blankshape = 0; diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index b9efcd3f5..fb2bfb3c5 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -1,9 +1,17 @@ #include "objects.hpp" #include +#include +#include +#include +#include +#include #include #include + +#include "../mwworld/ptr.hpp" + #include "renderconst.hpp" using namespace MWRender; @@ -56,7 +64,7 @@ void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_) insert->setPosition(f[0], f[1], f[2]); insert->setScale(ptr.getCellRef().scale, ptr.getCellRef().scale, ptr.getCellRef().scale); - + // Convert MW rotation to a quaternion: f = ptr.getCellRef().pos.rot; @@ -194,8 +202,7 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, f Ogre::Light *light = mRenderer.getScene()->createLight(); light->setDiffuseColour (r, g, b); - ESMS::LiveCellRef *ref = - ptr.get(); + MWWorld::LiveCellRef *ref = ptr.get(); LightInfo info; info.name = light->getName(); @@ -307,7 +314,7 @@ void Objects::removeCell(MWWorld::Ptr::CellStore* store) mBounds.erase(store); } -void Objects::buildStaticGeometry(ESMS::CellStore& cell) +void Objects::buildStaticGeometry(MWWorld::Ptr::CellStore& cell) { if(mStaticGeometry.find(&cell) != mStaticGeometry.end()) { diff --git a/apps/openmw/mwrender/objects.hpp b/apps/openmw/mwrender/objects.hpp index 6132879e6..e240b11c9 100644 --- a/apps/openmw/mwrender/objects.hpp +++ b/apps/openmw/mwrender/objects.hpp @@ -1,12 +1,15 @@ #ifndef _GAME_RENDER_OBJECTS_H #define _GAME_RENDER_OBJECTS_H +#include + #include -#include - -#include "../mwworld/refdata.hpp" -#include "../mwworld/ptr.hpp" +namespace MWWorld +{ + class Ptr; + class CellStore; +} namespace MWRender{ @@ -47,10 +50,10 @@ struct LightInfo class Objects{ OEngine::Render::OgreRenderer &mRenderer; - std::map mCellSceneNodes; - std::map mStaticGeometry; - std::map mStaticGeometrySmall; - std::map mBounds; + std::map mCellSceneNodes; + std::map mStaticGeometry; + std::map mStaticGeometrySmall; + std::map mBounds; std::vector mLights; Ogre::SceneNode* mMwRoot; bool mIsStatic; @@ -81,14 +84,14 @@ public: void update (const float dt); ///< per-frame update - Ogre::AxisAlignedBox getDimensions(MWWorld::Ptr::CellStore*); + Ogre::AxisAlignedBox getDimensions(MWWorld::CellStore*); ///< get a bounding box that encloses all objects in the specified cell bool deleteObject (const MWWorld::Ptr& ptr); ///< \return found? - void removeCell(MWWorld::Ptr::CellStore* store); - void buildStaticGeometry(ESMS::CellStore &cell); + void removeCell(MWWorld::CellStore* store); + void buildStaticGeometry(MWWorld::CellStore &cell); void setMwRoot(Ogre::SceneNode* root); }; } diff --git a/apps/openmw/mwrender/player.cpp b/apps/openmw/mwrender/player.cpp index d6baac4b5..27ae28e14 100644 --- a/apps/openmw/mwrender/player.cpp +++ b/apps/openmw/mwrender/player.cpp @@ -1,6 +1,8 @@ #include "player.hpp" +#include + namespace MWRender { Player::Player (Ogre::Camera *camera, Ogre::SceneNode* node) @@ -24,4 +26,9 @@ namespace MWRender pitchNode->setOrientation(xr); yawNode->setOrientation(yr); } + + std::string Player::getHandle() const + { + return mNode->getName(); + } } diff --git a/apps/openmw/mwrender/player.hpp b/apps/openmw/mwrender/player.hpp index 406bedb0a..0ba936f6f 100644 --- a/apps/openmw/mwrender/player.hpp +++ b/apps/openmw/mwrender/player.hpp @@ -1,12 +1,12 @@ #ifndef GAME_MWRENDER_PLAYER_H #define GAME_MWRENDER_PLAYER_H -#include -#include +#include namespace Ogre { class Camera; + class SceneNode; } namespace MWRender @@ -26,7 +26,7 @@ namespace MWRender /// Set where the player is looking at. Uses Morrowind (euler) angles void setRot(float x, float y, float z); - std::string getHandle() const { return mNode->getName(); } + std::string getHandle() const; Ogre::SceneNode* getNode() {return mNode;} }; } diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 266362f9b..5b76f5ae2 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -1,30 +1,37 @@ #include "renderingmanager.hpp" -#include +#include -#include "OgreRoot.h" -#include "OgreRenderWindow.h" -#include "OgreSceneManager.h" -#include "OgreViewport.h" -#include "OgreCamera.h" -#include "OgreTextureManager.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "../mwworld/world.hpp" // these includes can be removed once the static-hack is gone -#include "../mwworld/ptr.hpp" -#include "../mwworld/player.hpp" -#include "../mwbase/environment.hpp" #include #include +#include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone +#include "../mwbase/environment.hpp" + +#include "../mwworld/ptr.hpp" +#include "../mwworld/player.hpp" + +#include "../mwgui/window_manager.hpp" // FIXME +#include "../mwinput/inputmanager.hpp" // FIXME + #include "shadows.hpp" #include "shaderhelper.hpp" #include "localmap.hpp" #include "water.hpp" #include "compositors.hpp" -#include "../mwgui/window_manager.hpp" // FIXME -#include "../mwinput/inputmanager.hpp" // FIXME - using namespace MWRender; using namespace Ogre; @@ -298,9 +305,9 @@ void RenderingManager::skySetMoonColour (bool red){ bool RenderingManager::toggleRenderMode(int mode) { - if (mode == MWWorld::World::Render_CollisionDebug || mode == MWWorld::World::Render_Pathgrid) + if (mode == MWBase::World::Render_CollisionDebug || mode == MWBase::World::Render_Pathgrid) return mDebugging->toggleRenderMode(mode); - else if (mode == MWWorld::World::Render_Wireframe) + else if (mode == MWBase::World::Render_Wireframe) { if (mRendering.getCamera()->getPolygonMode() == PM_SOLID) { @@ -323,7 +330,7 @@ bool RenderingManager::toggleRenderMode(int mode) } } -void RenderingManager::configureFog(ESMS::CellStore &mCell) +void RenderingManager::configureFog(MWWorld::Ptr::CellStore &mCell) { Ogre::ColourValue color; color.setAsABGR (mCell.cell->ambi.fog); @@ -372,7 +379,7 @@ void RenderingManager::setAmbientMode() } } -void RenderingManager::configureAmbient(ESMS::CellStore &mCell) +void RenderingManager::configureAmbient(MWWorld::Ptr::CellStore &mCell) { mAmbientColor.setAsABGR (mCell.cell->ambi.ambient); setAmbientMode(); @@ -677,4 +684,17 @@ void RenderingManager::applyCompositors() mWater->assignTextures(); } +void RenderingManager::getTriangleBatchCount(unsigned int &triangles, unsigned int &batches) +{ + if (mCompositors->anyCompositorEnabled()) + { + mCompositors->countTrianglesBatches(triangles, batches); + } + else + { + triangles = mRendering.getWindow()->getTriangleCount(); + batches = mRendering.getWindow()->getBatchCount(); + } +} + } // namespace diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 642c42930..9aaba3803 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -20,8 +20,6 @@ #include #include -#include "../mwworld/ptr.hpp" - #include #include "renderinginterface.hpp" @@ -41,7 +39,8 @@ namespace Ogre namespace MWWorld { - class World; + class Ptr; + class CellStore; } namespace MWRender @@ -79,18 +78,18 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList OEngine::Render::Fader* getFader(); - void removeCell (MWWorld::Ptr::CellStore *store); + void removeCell (MWWorld::CellStore *store); /// \todo this function should be removed later. Instead the rendering subsystems should track /// when rebatching is needed and update automatically at the end of each frame. - void cellAdded (MWWorld::Ptr::CellStore *store); - void waterAdded(MWWorld::Ptr::CellStore *store); + void cellAdded (MWWorld::CellStore *store); + void waterAdded(MWWorld::CellStore *store); void removeWater(); static const bool useMRT(); - void preCellChange (MWWorld::Ptr::CellStore* store); + void preCellChange (MWWorld::CellStore* store); ///< this event is fired immediately before changing cell void addObject (const MWWorld::Ptr& ptr); @@ -105,7 +104,7 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList void toggleWater(); /// \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::Ptr::CellStore *store); + void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::CellStore *store); void update (float duration); @@ -118,14 +117,16 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList void disableLights(); void enableLights(); - bool occlusionQuerySupported() { return mOcclusionQuery->supported(); }; - OcclusionQuery* getOcclusionQuery() { return mOcclusionQuery; }; + bool occlusionQuerySupported() { return mOcclusionQuery->supported(); } + OcclusionQuery* getOcclusionQuery() { return mOcclusionQuery; } Shadows* getShadows(); void switchToInterior(); void switchToExterior(); + void getTriangleBatchCount(unsigned int &triangles, unsigned int &batches); + void setGlare(bool glare); void skyEnable (); void skyDisable (); @@ -134,13 +135,13 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList int skyGetMasserPhase() const; int skyGetSecundaPhase() const; void skySetMoonColour (bool red); - void configureAmbient(ESMS::CellStore &mCell); + void configureAmbient(MWWorld::CellStore &mCell); - void requestMap (MWWorld::Ptr::CellStore* cell); + void requestMap (MWWorld::CellStore* cell); ///< request the local map for a cell /// configure fog according to cell - void configureFog(ESMS::CellStore &mCell); + void configureFog(MWWorld::CellStore &mCell); /// configure fog manually void configureFog(const float density, const Ogre::ColourValue& colour); diff --git a/apps/openmw/mwrender/shaderhelper.cpp b/apps/openmw/mwrender/shaderhelper.cpp index 59154a295..1f9086db4 100644 --- a/apps/openmw/mwrender/shaderhelper.cpp +++ b/apps/openmw/mwrender/shaderhelper.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 19e45c189..45e48240b 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -4,14 +4,22 @@ #include #include #include +#include #include #include #include +#include +#include +#include +#include +#include +#include #include #include "../mwbase/environment.hpp" -#include "../mwworld/world.hpp" +#include "../mwbase/world.hpp" + #include "renderconst.hpp" #include "renderingmanager.hpp" diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index 4dac750c7..f14db34e6 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -1,16 +1,21 @@ -#include -#include #include -#include "../mwworld/world.hpp" +#include +#include +#include + +#include + +#include #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "terrainmaterial.hpp" #include "terrain.hpp" #include "renderconst.hpp" #include "shadows.hpp" -#include +#include "renderingmanager.hpp" using namespace Ogre; diff --git a/apps/openmw/mwrender/terrain.hpp b/apps/openmw/mwrender/terrain.hpp index 273ede084..7ac48047d 100644 --- a/apps/openmw/mwrender/terrain.hpp +++ b/apps/openmw/mwrender/terrain.hpp @@ -3,9 +3,10 @@ #include #include -#include "terrainmaterial.hpp" -#include "../mwworld/ptr.hpp" +#include + +#include "terrainmaterial.hpp" namespace Ogre{ class SceneManager; @@ -14,8 +15,15 @@ namespace Ogre{ class Terrain; } +namespace MWWorld +{ + class CellStore; +} + namespace MWRender{ + class RenderingManager; + /** * Implements the Morrowind terrain using the Ogre Terrain Component * @@ -30,8 +38,8 @@ namespace MWRender{ void setDiffuse(const Ogre::ColourValue& diffuse); void setAmbient(const Ogre::ColourValue& ambient); - void cellAdded(MWWorld::Ptr::CellStore* store); - void cellRemoved(MWWorld::Ptr::CellStore* store); + void cellAdded(MWWorld::CellStore* store); + void cellRemoved(MWWorld::CellStore* store); private: Ogre::TerrainGlobalOptions* mTerrainGlobals; Ogre::TerrainGroup mTerrainGroup; diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index dc9e1fbee..94fb3d6d9 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -1,5 +1,14 @@ #include "water.hpp" +#include +#include +#include +#include +#include +#include +#include +#include + #include "sky.hpp" #include "renderingmanager.hpp" #include "compositors.hpp" diff --git a/apps/openmw/mwrender/water.hpp b/apps/openmw/mwrender/water.hpp index 4d617ea47..71f261f2b 100644 --- a/apps/openmw/mwrender/water.hpp +++ b/apps/openmw/mwrender/water.hpp @@ -1,19 +1,34 @@ #ifndef GAME_MWRENDER_WATER_H #define GAME_MWRENDER_WATER_H -#include +#include +#include +#include +#include +#include +#include + #include #include #include "renderconst.hpp" +namespace Ogre +{ + class Camera; + class SceneManager; + class SceneNode; + class Entity; + class Vector3; + struct RenderTargetEvent; +}; namespace MWRender { class SkyManager; class RenderingManager; - /// Water rendering + /// Water rendering class Water : public Ogre::RenderTargetListener, public Ogre::RenderQueueListener { static const int CELL_SIZE = 8192; diff --git a/apps/openmw/mwscript/aiextensions.cpp b/apps/openmw/mwscript/aiextensions.cpp index aa541e55d..924a0e9dd 100644 --- a/apps/openmw/mwscript/aiextensions.cpp +++ b/apps/openmw/mwscript/aiextensions.cpp @@ -7,6 +7,10 @@ #include #include +#include "../mwworld/class.hpp" + +#include "../mwmechanics/creaturestats.hpp" + #include "interpretercontext.hpp" #include "ref.hpp" @@ -88,6 +92,95 @@ namespace MWScript } }; + template + class OpAiWander : public Interpreter::Opcode1 + { + public: + + virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) + { + MWWorld::Ptr ptr = R()(runtime); + +// Interpreter::Type_Float range = runtime[0].mFloat; + runtime.pop(); + +// Interpreter::Type_Float duration = runtime[0].mFloat; + runtime.pop(); + +// Interpreter::Type_Float time = runtime[0].mFloat; + runtime.pop(); + + // discard additional idle arguments for now + // discard additional arguments (reset), because we have no idea what they mean. + for (unsigned int i=0; i + class OpSetHello : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + Interpreter::Type_Integer value = runtime[0].mInteger; + runtime.pop(); + + MWWorld::Class::get (ptr).getCreatureStats (ptr).mHello = value; + } + }; + + template + class OpSetFight : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + Interpreter::Type_Integer value = runtime[0].mInteger; + runtime.pop(); + + MWWorld::Class::get (ptr).getCreatureStats (ptr).mFight = value; + } + }; + + template + class OpSetFlee : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + Interpreter::Type_Integer value = runtime[0].mInteger; + runtime.pop(); + + MWWorld::Class::get (ptr).getCreatureStats (ptr).mFlee = value; + } + }; + + template + class OpSetAlarm : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + Interpreter::Type_Integer value = runtime[0].mInteger; + runtime.pop(); + + MWWorld::Class::get (ptr).getCreatureStats (ptr).mAlarm = value; + } + }; const int opcodeAiTravel = 0x20000; @@ -96,6 +189,16 @@ namespace MWScript const int opcodeAiEscortExplicit = 0x20003; const int opcodeGetAiPackageDone = 0x200007c; const int opcodeGetAiPackageDoneExplicit = 0x200007d; + const int opcodeAiWander = 0x20010; + const int opcodeAiWanderExplicit = 0x20011; + const int opcodeSetHello = 0x200015e; + const int opcodeSetHelloExplicit = 0x200015d; + const int opcodeSetFight = 0x200015e; + const int opcodeSetFightExplicit = 0x200015f; + const int opcodeSetFlee = 0x2000160; + const int opcodeSetFleeExplicit = 0x2000161; + const int opcodeSetAlarm = 0x2000162; + const int opcodeSetAlarmExplicit = 0x2000163; void registerExtensions (Compiler::Extensions& extensions) { @@ -103,9 +206,16 @@ namespace MWScript opcodeAiTravelExplicit); extensions.registerInstruction ("aiescort", "cffff/l", opcodeAiEscort, opcodeAiEscortExplicit); + extensions.registerInstruction ("aiwander", "fff/llllllllll", opcodeAiWander, + opcodeAiWanderExplicit); extensions.registerFunction ("getaipackagedone", 'l', "", opcodeGetAiPackageDone, opcodeGetAiPackageDoneExplicit); + + extensions.registerInstruction ("sethello", "l", opcodeSetHello, opcodeSetHelloExplicit); + extensions.registerInstruction ("setfight", "l", opcodeSetFight, opcodeSetFightExplicit); + extensions.registerInstruction ("setflee", "l", opcodeSetFlee, opcodeSetFleeExplicit); + extensions.registerInstruction ("setalarm", "l", opcodeSetAlarm, opcodeSetAlarmExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -114,9 +224,19 @@ namespace MWScript interpreter.installSegment3 (opcodeAiTravelExplicit, new OpAiTravel); interpreter.installSegment3 (opcodeAiEscort, new OpAiEscort); interpreter.installSegment3 (opcodeAiEscortExplicit, new OpAiEscort); + interpreter.installSegment3 (opcodeAiWander, new OpAiWander); + interpreter.installSegment3 (opcodeAiWanderExplicit, new OpAiWander); interpreter.installSegment5 (opcodeGetAiPackageDone, new OpGetAiPackageDone); interpreter.installSegment5 (opcodeGetAiPackageDoneExplicit, new OpGetAiPackageDone); + interpreter.installSegment5 (opcodeSetHello, new OpSetHello); + interpreter.installSegment5 (opcodeSetHelloExplicit, new OpSetHello); + interpreter.installSegment5 (opcodeSetFight, new OpSetFight); + interpreter.installSegment5 (opcodeSetFightExplicit, new OpSetFight); + interpreter.installSegment5 (opcodeSetFlee, new OpSetFlee); + interpreter.installSegment5 (opcodeSetFleeExplicit, new OpSetFlee); + interpreter.installSegment5 (opcodeSetAlarm, new OpSetAlarm); + interpreter.installSegment5 (opcodeSetAlarmExplicit, new OpSetAlarm); } } } diff --git a/apps/openmw/mwscript/animationextensions.cpp b/apps/openmw/mwscript/animationextensions.cpp index 864a2bf1d..6f9253e5d 100644 --- a/apps/openmw/mwscript/animationextensions.cpp +++ b/apps/openmw/mwscript/animationextensions.cpp @@ -9,7 +9,7 @@ #include #include -#include "../mwworld/world.hpp" +#include "../mwbase/world.hpp" #include "interpretercontext.hpp" #include "ref.hpp" diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index a5db5fd5f..c1d09fac4 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -1,6 +1,8 @@ #include "cellextensions.hpp" +#include + #include #include @@ -8,8 +10,8 @@ #include #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" -#include "../mwworld/world.hpp" #include "../mwworld/player.hpp" #include "interpretercontext.hpp" diff --git a/apps/openmw/mwscript/compilercontext.cpp b/apps/openmw/mwscript/compilercontext.cpp index 078d0da5e..57e786b11 100644 --- a/apps/openmw/mwscript/compilercontext.cpp +++ b/apps/openmw/mwscript/compilercontext.cpp @@ -1,9 +1,15 @@ #include "compilercontext.hpp" -#include "../mwbase/environment.hpp" +#include -#include "../mwworld/world.hpp" +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + +#include "../mwworld/ptr.hpp" +#include "../mwworld/class.hpp" + +#include "scriptmanager.hpp" namespace MWScript { @@ -21,6 +27,18 @@ namespace MWScript return MWBase::Environment::get().getWorld()->getGlobalVariableType (name); } + char CompilerContext::getMemberType (const std::string& name, const std::string& id) const + { + MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPtr (id, false); + + std::string script = MWWorld::Class::get (ptr).getScript (ptr); + + if (script.empty()) + return ' '; + + return MWBase::Environment::get().getScriptManager()->getLocals (script).getType (name); + } + bool CompilerContext::isId (const std::string& name) const { return diff --git a/apps/openmw/mwscript/compilercontext.hpp b/apps/openmw/mwscript/compilercontext.hpp index 32b2f1881..5ec98e09a 100644 --- a/apps/openmw/mwscript/compilercontext.hpp +++ b/apps/openmw/mwscript/compilercontext.hpp @@ -30,6 +30,9 @@ namespace MWScript /// 'l: long, 's': short, 'f': float, ' ': does not exist. virtual char getGlobalType (const std::string& name) const; + virtual char getMemberType (const std::string& name, const std::string& id) const; + ///< 'l: long, 's': short, 'f': float, ' ': does not exist. + virtual bool isId (const std::string& name) const; ///< Does \a name match an ID, that can be referenced? }; diff --git a/apps/openmw/mwscript/controlextensions.cpp b/apps/openmw/mwscript/controlextensions.cpp index 363a09b6b..1f5bdcafb 100644 --- a/apps/openmw/mwscript/controlextensions.cpp +++ b/apps/openmw/mwscript/controlextensions.cpp @@ -10,8 +10,12 @@ #include "../mwbase/environment.hpp" #include "../mwworld/player.hpp" +#include "../mwworld/class.hpp" + +#include "../mwmechanics/npcstats.hpp" #include "interpretercontext.hpp" +#include "ref.hpp" #include @@ -54,11 +58,71 @@ namespace MWScript } }; + template + class OpClearForceRun : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + MWWorld::Class::get (ptr).getNpcStats (ptr).mForceRun = false; + } + }; + + template + class OpForceRun : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + MWWorld::Class::get (ptr).getNpcStats (ptr).mForceRun = true; + } + }; + + template + class OpClearForceSneak : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + MWWorld::Class::get (ptr).getNpcStats (ptr).mForceSneak = false; + } + }; + + template + class OpForceSneak : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + MWWorld::Class::get (ptr).getNpcStats (ptr).mForceSneak = true; + } + }; + const int numberOfControls = 7; const int opcodeEnable = 0x200007e; const int opcodeDisable = 0x2000085; const int opcodeToggleCollision = 0x2000130; + const int opcodeClearForceRun = 0x2000154; + const int opcodeClearForceRunExplicit = 0x2000155; + const int opcodeForceRun = 0x2000156; + const int opcodeForceRunExplicit = 0x2000157; + const int opcodeClearForceSneak = 0x2000158; + const int opcodeClearForceSneakExplicit = 0x2000159; + const int opcodeForceSneak = 0x200015a; + const int opcodeForceSneakExplicit = 0x200015b; const char *controls[numberOfControls] = { @@ -79,6 +143,16 @@ namespace MWScript extensions.registerInstruction ("togglecollision", "", opcodeToggleCollision); extensions.registerInstruction ("tcl", "", opcodeToggleCollision); + + extensions.registerInstruction ("clearforcerun", "", opcodeClearForceRun, + opcodeClearForceRunExplicit); + extensions.registerInstruction ("forcerun", "", opcodeForceRun, + opcodeForceRunExplicit); + + extensions.registerInstruction ("clearforcesneak", "", opcodeClearForceSneak, + opcodeClearForceSneakExplicit); + extensions.registerInstruction ("forcesneak", "", opcodeForceSneak, + opcodeForceSneakExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -90,6 +164,20 @@ namespace MWScript } interpreter.installSegment5 (opcodeToggleCollision, new OpToggleCollision); + + interpreter.installSegment5 (opcodeClearForceRun, new OpClearForceRun); + interpreter.installSegment5 (opcodeForceRun, new OpForceRun); + interpreter.installSegment5 (opcodeClearForceSneak, new OpClearForceSneak); + interpreter.installSegment5 (opcodeForceSneak, new OpForceSneak); + + interpreter.installSegment5 (opcodeClearForceRunExplicit, + new OpClearForceRun); + interpreter.installSegment5 (opcodeForceRunExplicit, + new OpForceRun); + interpreter.installSegment5 (opcodeClearForceSneakExplicit, + new OpClearForceSneak); + interpreter.installSegment5 (opcodeForceSneakExplicit, + new OpForceSneak); } } } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index dc353127d..b979420dd 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -29,7 +29,9 @@ op 0x2000c: PCLowerRank op 0x2000d: PCJoinFaction op 0x2000e: PCGetRank implicit op 0x2000f: PCGetRank explicit -opcodes 0x20010-0x3ffff unused +op 0x20010: AiWander +op 0x20011: AiWander, explicit reference +opcodes 0x20012-0x3ffff unused Segment 4: (not implemented yet) @@ -147,9 +149,25 @@ op 0x2000150: ForceGreeting, explicit reference op 0x2000151: ToggleFullHelp op 0x2000152: Goodbye op 0x2000153: DontSaveObject (left unimplemented) -op 0x2000154: SetScale -op 0x2000155: SetScale, explicit reference -op 0x2000156: SetAngle -op 0x2000157: SetAngle, explicit reference -opcodes 0x2000158-0x3ffffff unused +op 0x2000154: ClearForceRun +op 0x2000155: ClearForceRun, explicit reference +op 0x2000156: ForceRun +op 0x2000157: ForceRun, explicit reference +op 0x2000158: ClearForceSneak +op 0x2000159: ClearForceSneak, explicit reference +op 0x200015a: ForceSneak +op 0x200015b: ForceSneak, explicit reference +op 0x200015c: SetHello +op 0x200015d: SetHello, explicit reference +op 0x200015e: SetFight +op 0x200015f: SetFight, explicit reference +op 0x2000160: SetFlee +op 0x2000161: SetFlee, explicit reference +op 0x2000162: SetAlarm +op 0x2000163: SetAlarm, explicit reference +op 0x2000164: SetScale +op 0x2000165: SetScale, explicit reference +op 0x2000166: SetAngle +op 0x2000167: SetAngle, explicit reference +opcodes 0x2000168-0x3ffffff unused diff --git a/apps/openmw/mwscript/globalscripts.cpp b/apps/openmw/mwscript/globalscripts.cpp index eb96ba5e2..3f4cec723 100644 --- a/apps/openmw/mwscript/globalscripts.cpp +++ b/apps/openmw/mwscript/globalscripts.cpp @@ -3,6 +3,9 @@ #include +#include +#include + #include "interpretercontext.hpp" #include "scriptmanager.hpp" diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index b267cc6e4..8e5897298 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -104,7 +104,7 @@ namespace MWScript extensions.registerInstruction ("enableclassmenu", "", opcodeEnableClassMenu); extensions.registerInstruction ("enablenamemenu", "", opcodeEnableNameMenu); extensions.registerInstruction ("enableracemenu", "", opcodeEnableRaceMenu); - extensions.registerInstruction ("enablestatsreviewmenu", "", + extensions.registerInstruction ("enablestatreviewmenu", "", opcodeEnableStatsReviewMenu); extensions.registerInstruction ("enableinventorymenu", "", opcodeEnableInventoryMenu); diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index a369486fa..5da512778 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -3,13 +3,13 @@ #include #include -#include #include #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" -#include "../mwworld/world.hpp" +#include "../mwworld/class.hpp" #include "../mwgui/window_manager.hpp" @@ -270,6 +270,84 @@ namespace MWScript MWBase::Environment::get().getWorld()->disable (ref); } + int InterpreterContext::getMemberShort (const std::string& id, const std::string& name) const + { + const MWWorld::Ptr ptr = getReference (id, false); + + std::string scriptId = MWWorld::Class::get (ptr).getScript (ptr); + + int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 's'); + + ptr.getRefData().setLocals ( + *MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); + return ptr.getRefData().getLocals().mShorts[index]; + } + + int InterpreterContext::getMemberLong (const std::string& id, const std::string& name) const + { + const MWWorld::Ptr ptr = getReference (id, false); + + std::string scriptId = MWWorld::Class::get (ptr).getScript (ptr); + + int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'l'); + + ptr.getRefData().setLocals ( + *MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); + return ptr.getRefData().getLocals().mLongs[index]; + } + + float InterpreterContext::getMemberFloat (const std::string& id, const std::string& name) const + { + const MWWorld::Ptr ptr = getReference (id, false); + + std::string scriptId = MWWorld::Class::get (ptr).getScript (ptr); + + int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'f'); + + ptr.getRefData().setLocals ( + *MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); + return ptr.getRefData().getLocals().mFloats[index]; + } + + void InterpreterContext::setMemberShort (const std::string& id, const std::string& name, int value) + { + const MWWorld::Ptr ptr = getReference (id, false); + + std::string scriptId = MWWorld::Class::get (ptr).getScript (ptr); + + int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 's'); + + ptr.getRefData().setLocals ( + *MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); + ptr.getRefData().getLocals().mShorts[index] = value; + } + + void InterpreterContext::setMemberLong (const std::string& id, const std::string& name, int value) + { + const MWWorld::Ptr ptr = getReference (id, false); + + std::string scriptId = MWWorld::Class::get (ptr).getScript (ptr); + + int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'l'); + + ptr.getRefData().setLocals ( + *MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); + ptr.getRefData().getLocals().mLongs[index] = value; + } + + void InterpreterContext::setMemberFloat (const std::string& id, const std::string& name, float value) + { + const MWWorld::Ptr ptr = getReference (id, false); + + std::string scriptId = MWWorld::Class::get (ptr).getScript (ptr); + + int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'f'); + + ptr.getRefData().setLocals ( + *MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); + ptr.getRefData().getLocals().mFloats[index] = value; + } + MWWorld::Ptr InterpreterContext::getReference() { return getReference ("", true); diff --git a/apps/openmw/mwscript/interpretercontext.hpp b/apps/openmw/mwscript/interpretercontext.hpp index 40f53337d..6d97f7949 100644 --- a/apps/openmw/mwscript/interpretercontext.hpp +++ b/apps/openmw/mwscript/interpretercontext.hpp @@ -5,8 +5,9 @@ #include +#include "../mwbase/world.hpp" + #include "../mwworld/ptr.hpp" -#include "../mwworld/world.hpp" #include "../mwworld/action.hpp" namespace MWSound @@ -107,6 +108,18 @@ namespace MWScript virtual void disable (const std::string& id = ""); + virtual int getMemberShort (const std::string& id, const std::string& name) const; + + virtual int getMemberLong (const std::string& id, const std::string& name) const; + + virtual float getMemberFloat (const std::string& id, const std::string& name) const; + + virtual void setMemberShort (const std::string& id, const std::string& name, int value); + + virtual void setMemberLong (const std::string& id, const std::string& name, int value); + + virtual void setMemberFloat (const std::string& id, const std::string& name, float value); + MWWorld::Ptr getReference(); ///< Reference, that the script is running from (can be empty) }; diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index c7569ccdd..0c328e0da 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -1,6 +1,8 @@ #include "miscextensions.hpp" +#include + #include #include @@ -102,7 +104,7 @@ namespace MWScript static_cast (runtime.getContext()); bool enabled = - MWBase::Environment::get().getWorld()->toggleRenderMode (MWWorld::World::Render_CollisionDebug); + MWBase::Environment::get().getWorld()->toggleRenderMode (MWBase::World::Render_CollisionDebug); context.report (enabled ? "Collision Mesh Rendering -> On" : "Collision Mesh Rendering -> Off"); @@ -119,7 +121,7 @@ namespace MWScript static_cast (runtime.getContext()); bool enabled = - MWBase::Environment::get().getWorld()->toggleRenderMode (MWWorld::World::Render_Wireframe); + MWBase::Environment::get().getWorld()->toggleRenderMode (MWBase::World::Render_Wireframe); context.report (enabled ? "Wireframe Rendering -> On" : "Wireframe Rendering -> Off"); @@ -135,7 +137,7 @@ namespace MWScript static_cast (runtime.getContext()); bool enabled = - MWBase::Environment::get().getWorld()->toggleRenderMode (MWWorld::World::Render_Pathgrid); + MWBase::Environment::get().getWorld()->toggleRenderMode (MWBase::World::Render_Pathgrid); context.report (enabled ? "Path Grid rendering -> On" : "Path Grid Rendering -> Off"); diff --git a/apps/openmw/mwscript/ref.hpp b/apps/openmw/mwscript/ref.hpp index 28093c4e5..81b1d5ef9 100644 --- a/apps/openmw/mwscript/ref.hpp +++ b/apps/openmw/mwscript/ref.hpp @@ -6,9 +6,9 @@ #include #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwworld/ptr.hpp" -#include "../mwworld/world.hpp" #include "interpretercontext.hpp" diff --git a/apps/openmw/mwscript/scriptmanager.cpp b/apps/openmw/mwscript/scriptmanager.cpp index 506cf049c..d8bd269c6 100644 --- a/apps/openmw/mwscript/scriptmanager.cpp +++ b/apps/openmw/mwscript/scriptmanager.cpp @@ -11,6 +11,7 @@ #include #include +#include #include "extensions.hpp" @@ -46,8 +47,14 @@ namespace MWScript if (!mErrorHandler.isGood()) Success = false; } - catch (...) + catch (const Compiler::SourceException&) { + // error has already been reported via error handler + Success = false; + } + catch (const std::exception& error) + { + std::cerr << "An exception has been thrown: " << error.what() << std::endl; Success = false; } @@ -140,6 +147,9 @@ namespace MWScript { if (!compile (name)) { + /// \todo Handle case of cyclic member variable access. Currently this could look up + /// the whole application in an endless recursion. + // failed -> ignore script from now on. std::vector empty; mScripts.insert (std::make_pair (name, std::make_pair (empty, Compiler::Locals()))); @@ -156,4 +166,43 @@ namespace MWScript { return mGlobalScripts; } + + int ScriptManager::getLocalIndex (const std::string& scriptId, const std::string& variable, + char type) + { + const ESM::Script *script = mStore.scripts.find (scriptId); + + int offset = 0; + int size = 0; + + switch (type) + { + case 's': + + offset = 0; + size = script->data.numShorts; + break; + + case 'l': + + offset = script->data.numShorts; + size = script->data.numLongs; + break; + + case 'f': + + offset = script->data.numShorts+script->data.numLongs; + size = script->data.numFloats; + + default: + + throw std::runtime_error ("invalid variable type"); + } + + for (int i=0; ivarNames.at (i+offset)==variable) + return i; + + throw std::runtime_error ("unable to access local variable " + variable + " of " + scriptId); + } } diff --git a/apps/openmw/mwscript/scriptmanager.hpp b/apps/openmw/mwscript/scriptmanager.hpp index 35c1fadd9..34cc0defe 100644 --- a/apps/openmw/mwscript/scriptmanager.hpp +++ b/apps/openmw/mwscript/scriptmanager.hpp @@ -67,6 +67,10 @@ namespace MWScript ///< Return locals for script \a name. GlobalScripts& getGlobalScripts(); + + int getLocalIndex (const std::string& scriptId, const std::string& variable, char type); + ///< Return index of the variable of the given name and type in the given script. Will + /// throw an exception, if there is no such script or variable or the type does not match. }; }; diff --git a/apps/openmw/mwscript/soundextensions.cpp b/apps/openmw/mwscript/soundextensions.cpp index c2b45641a..3e05d72d3 100644 --- a/apps/openmw/mwscript/soundextensions.cpp +++ b/apps/openmw/mwscript/soundextensions.cpp @@ -8,8 +8,7 @@ #include #include "../mwbase/environment.hpp" - -#include "../mwworld/world.hpp" +#include "../mwbase/world.hpp" #include "../mwsound/soundmanager.hpp" diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 6fc640bdc..a824e9d6d 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -3,6 +3,8 @@ #include +#include + #include #include @@ -299,6 +301,9 @@ namespace MWScript std::string id = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); + // make sure a spell with this ID actually exists. + MWBase::Environment::get().getWorld()->getStore().spells.find (id); + MWWorld::Class::get (ptr).getCreatureStats (ptr).mSpells.add (id); } }; diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index ff618ac33..c6332d9f3 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -9,10 +9,12 @@ #include #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" -#include "../mwworld/world.hpp" #include "../mwworld/player.hpp" +#include "../mwrender/player.hpp" + #include "sound_output.hpp" #include "sound_decoder.hpp" #include "sound.hpp" @@ -88,7 +90,7 @@ namespace MWSound { if(devname.empty()) throw; - std::cout <<"Failed to open device \""<init(); Settings::Manager::setString("device", "Sound", ""); } diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index 562b2af00..ff360122b 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -130,7 +130,7 @@ namespace MWSound void stopSound3D(MWWorld::Ptr reference); ///< Stop the given object from playing all sounds. - void stopSound(const MWWorld::Ptr::CellStore *cell); + void stopSound(const MWWorld::CellStore *cell); ///< Stop all sounds for the given cell. void stopSound(const std::string& soundId); diff --git a/apps/openmw/mwworld/actionalchemy.cpp b/apps/openmw/mwworld/actionalchemy.cpp index a2f3bd1e4..eb91b6946 100644 --- a/apps/openmw/mwworld/actionalchemy.cpp +++ b/apps/openmw/mwworld/actionalchemy.cpp @@ -7,7 +7,6 @@ namespace MWWorld { void ActionAlchemy::execute() { - MWBase::Environment::get().getWindowManager()->popGuiMode(); MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Alchemy); } } diff --git a/apps/openmw/mwworld/actionequip.cpp b/apps/openmw/mwworld/actionequip.cpp index f3bb256fd..52b9437fd 100644 --- a/apps/openmw/mwworld/actionequip.cpp +++ b/apps/openmw/mwworld/actionequip.cpp @@ -1,9 +1,11 @@ #include "actionequip.hpp" #include "../mwbase/environment.hpp" -#include "../mwworld/world.hpp" -#include "../mwworld/inventorystore.hpp" -#include "../mwworld/player.hpp" +#include "../mwbase/world.hpp" + +#include "inventorystore.hpp" +#include "player.hpp" +#include "class.hpp" namespace MWWorld { @@ -14,7 +16,7 @@ namespace MWWorld void ActionEquip::execute () { MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - MWWorld::InventoryStore& invStore = static_cast(MWWorld::Class::get(player).getContainerStore(player)); + MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player); // slots that this item can be equipped in std::pair, bool> slots = MWWorld::Class::get(mObject).getEquipmentSlots(mObject); @@ -51,4 +53,3 @@ namespace MWWorld } } } - diff --git a/apps/openmw/mwworld/actionopen.cpp b/apps/openmw/mwworld/actionopen.cpp index dd36487dc..a70773af9 100644 --- a/apps/openmw/mwworld/actionopen.cpp +++ b/apps/openmw/mwworld/actionopen.cpp @@ -1,13 +1,14 @@ #include "actionopen.hpp" #include "../mwbase/environment.hpp" -#include "class.hpp" -#include "world.hpp" -#include "containerstore.hpp" + #include "../mwclass/container.hpp" #include "../mwgui/window_manager.hpp" #include "../mwgui/container.hpp" +#include "class.hpp" +#include "containerstore.hpp" + namespace MWWorld { ActionOpen::ActionOpen (const MWWorld::Ptr& container) : mContainer (container) { diff --git a/apps/openmw/mwworld/actionread.cpp b/apps/openmw/mwworld/actionread.cpp index 34e95cbd0..1e03230c7 100644 --- a/apps/openmw/mwworld/actionread.cpp +++ b/apps/openmw/mwworld/actionread.cpp @@ -13,8 +13,7 @@ namespace MWWorld void ActionRead::execute () { - ESMS::LiveCellRef *ref = - mObject.get(); + LiveCellRef *ref = mObject.get(); if (ref->base->data.isScroll) { @@ -28,4 +27,3 @@ namespace MWWorld } } } - diff --git a/apps/openmw/mwworld/actiontake.cpp b/apps/openmw/mwworld/actiontake.cpp index 9cff42812..39544b35d 100644 --- a/apps/openmw/mwworld/actiontake.cpp +++ b/apps/openmw/mwworld/actiontake.cpp @@ -2,10 +2,11 @@ #include "actiontake.hpp" #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + #include "../mwgui/window_manager.hpp" #include "class.hpp" -#include "world.hpp" #include "containerstore.hpp" namespace MWWorld diff --git a/apps/openmw/mwworld/actionteleport.cpp b/apps/openmw/mwworld/actionteleport.cpp index 6ebbd7b7f..8ae3244f8 100644 --- a/apps/openmw/mwworld/actionteleport.cpp +++ b/apps/openmw/mwworld/actionteleport.cpp @@ -2,8 +2,7 @@ #include "actionteleport.hpp" #include "../mwbase/environment.hpp" - -#include "world.hpp" +#include "../mwbase/world.hpp" namespace MWWorld { diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index b6d3e38ce..cd7ebf79a 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -4,7 +4,11 @@ #include -#include "world.hpp" +#include + +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + #include "class.hpp" #include "containerstore.hpp" @@ -39,7 +43,7 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell) void MWWorld::Cells::fillContainers (Ptr::CellStore& cellStore) { - for (ESMS::CellRefList::List::iterator iter ( + for (CellRefList::List::iterator iter ( cellStore.containers.list.begin()); iter!=cellStore.containers.list.end(); ++iter) { @@ -49,7 +53,7 @@ void MWWorld::Cells::fillContainers (Ptr::CellStore& cellStore) iter->base->inventory, mStore); } - for (ESMS::CellRefList::List::iterator iter ( + for (CellRefList::List::iterator iter ( cellStore.creatures.list.begin()); iter!=cellStore.creatures.list.end(); ++iter) { @@ -59,7 +63,7 @@ void MWWorld::Cells::fillContainers (Ptr::CellStore& cellStore) iter->base->inventory, mStore); } - for (ESMS::CellRefList::List::iterator iter ( + for (CellRefList::List::iterator iter ( cellStore.npcs.list.begin()); iter!=cellStore.npcs.list.end(); ++iter) { @@ -70,8 +74,26 @@ void MWWorld::Cells::fillContainers (Ptr::CellStore& cellStore) } } -MWWorld::Cells::Cells (const ESMS::ESMStore& store, ESM::ESMReader& reader, MWWorld::World& world) -: mStore (store), mReader (reader), mWorld (world) {} +MWWorld::Ptr MWWorld::Cells::getPtrAndCache (const std::string& name, Ptr::CellStore& cellStore) +{ + Ptr ptr = getPtr (name, cellStore); + + if (!ptr.isEmpty()) + { + mIdCache[mIdCacheIndex].first = name; + mIdCache[mIdCacheIndex].second = &cellStore; + if (++mIdCacheIndex>=mIdCache.size()) + mIdCacheIndex = 0; + } + + return ptr; +} + +MWWorld::Cells::Cells (const ESMS::ESMStore& store, ESM::ESMReader& reader) +: mStore (store), mReader (reader), + mIdCache (20, std::pair ("", (Ptr::CellStore*)0)), /// \todo make cache size configurable + mIdCacheIndex (0) +{} MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y) { @@ -93,11 +115,11 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y) record.water = 0; record.mapColor = 0; - cell = mWorld.createRecord (record); + cell = MWBase::Environment::get().getWorld()->createRecord (record); } result = mExteriors.insert (std::make_pair ( - std::make_pair (x, y), Ptr::CellStore (cell))).first; + std::make_pair (x, y), CellStore (cell))).first; } if (result->second.mState!=Ptr::CellStore::State_Loaded) @@ -142,69 +164,72 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, Ptr::CellStore& ce (int(*)(int)) std::tolower); if (std::binary_search (cell.mIds.begin(), cell.mIds.end(), lowerCase)) + { cell.load (mStore, mReader); + fillContainers (cell); + } else return Ptr(); } - if (ESMS::LiveCellRef *ref = cell.activators.find (name)) + if (MWWorld::LiveCellRef *ref = cell.activators.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.potions.find (name)) + if (MWWorld::LiveCellRef *ref = cell.potions.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.appas.find (name)) + if (MWWorld::LiveCellRef *ref = cell.appas.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.armors.find (name)) + if (MWWorld::LiveCellRef *ref = cell.armors.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.books.find (name)) + if (MWWorld::LiveCellRef *ref = cell.books.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.clothes.find (name)) + if (MWWorld::LiveCellRef *ref = cell.clothes.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.containers.find (name)) + if (MWWorld::LiveCellRef *ref = cell.containers.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.creatures.find (name)) + if (MWWorld::LiveCellRef *ref = cell.creatures.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.doors.find (name)) + if (MWWorld::LiveCellRef *ref = cell.doors.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.ingreds.find (name)) + if (MWWorld::LiveCellRef *ref = cell.ingreds.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.creatureLists.find (name)) + if (MWWorld::LiveCellRef *ref = cell.creatureLists.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.itemLists.find (name)) + if (MWWorld::LiveCellRef *ref = cell.itemLists.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.lights.find (name)) + if (MWWorld::LiveCellRef *ref = cell.lights.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.lockpicks.find (name)) + if (MWWorld::LiveCellRef *ref = cell.lockpicks.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.miscItems.find (name)) + if (MWWorld::LiveCellRef *ref = cell.miscItems.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.npcs.find (name)) + if (MWWorld::LiveCellRef *ref = cell.npcs.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.probes.find (name)) + if (MWWorld::LiveCellRef *ref = cell.probes.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.repairs.find (name)) + if (MWWorld::LiveCellRef *ref = cell.repairs.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.statics.find (name)) + if (MWWorld::LiveCellRef *ref = cell.statics.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.weapons.find (name)) + if (MWWorld::LiveCellRef *ref = cell.weapons.find (name)) return Ptr (ref, &cell); return Ptr(); @@ -212,19 +237,29 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, Ptr::CellStore& ce MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name) { - // First check cells that are already listed + // First check the cache + for (std::vector >::iterator iter (mIdCache.begin()); + iter!=mIdCache.end(); ++iter) + if (iter->first==name && iter->second) + { + Ptr ptr = getPtr (name, *iter->second); + if (!ptr.isEmpty()) + return ptr; + } + + // Then check cells that are already listed for (std::map::iterator iter = mInteriors.begin(); iter!=mInteriors.end(); ++iter) { - Ptr ptr = getPtr (name, iter->second); + Ptr ptr = getPtrAndCache (name, iter->second); if (!ptr.isEmpty()) - return ptr; + return ptr; } for (std::map, Ptr::CellStore>::iterator iter = mExteriors.begin(); iter!=mExteriors.end(); ++iter) { - Ptr ptr = getPtr (name, iter->second); + Ptr ptr = getPtrAndCache (name, iter->second); if (!ptr.isEmpty()) return ptr; } @@ -235,7 +270,7 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name) { Ptr::CellStore *cellStore = getCellStore (iter->second); - Ptr ptr = getPtr (name, *cellStore); + Ptr ptr = getPtrAndCache (name, *cellStore); if (!ptr.isEmpty()) return ptr; @@ -246,7 +281,7 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name) { Ptr::CellStore *cellStore = getCellStore (iter->second); - Ptr ptr = getPtr (name, *cellStore); + Ptr ptr = getPtrAndCache (name, *cellStore); if (!ptr.isEmpty()) return ptr; diff --git a/apps/openmw/mwworld/cells.hpp b/apps/openmw/mwworld/cells.hpp index 42aa1050c..3e1383166 100644 --- a/apps/openmw/mwworld/cells.hpp +++ b/apps/openmw/mwworld/cells.hpp @@ -18,35 +18,36 @@ namespace ESM namespace MWWorld { - class World; - /// \brief Cell container class Cells { const ESMS::ESMStore& mStore; ESM::ESMReader& mReader; - std::map mInteriors; - std::map, Ptr::CellStore> mExteriors; - MWWorld::World& mWorld; + std::map mInteriors; + std::map, CellStore> mExteriors; + std::vector > mIdCache; + std::size_t mIdCacheIndex; Cells (const Cells&); Cells& operator= (const Cells&); - Ptr::CellStore *getCellStore (const ESM::Cell *cell); + CellStore *getCellStore (const ESM::Cell *cell); - void fillContainers (Ptr::CellStore& cellStore); + void fillContainers (CellStore& cellStore); + + Ptr getPtrAndCache (const std::string& name, CellStore& cellStore); public: - Cells (const ESMS::ESMStore& store, ESM::ESMReader& reader, MWWorld::World& world); + Cells (const ESMS::ESMStore& store, ESM::ESMReader& reader); ///< \todo pass the dynamic part of the ESMStore isntead (once it is written) of the whole /// world - Ptr::CellStore *getExterior (int x, int y); + CellStore *getExterior (int x, int y); - Ptr::CellStore *getInterior (const std::string& name); + CellStore *getInterior (const std::string& name); - Ptr getPtr (const std::string& name, Ptr::CellStore& cellStore); + Ptr getPtr (const std::string& name, CellStore& cellStore); Ptr getPtr (const std::string& name); }; diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp new file mode 100644 index 000000000..60a7eb6e1 --- /dev/null +++ b/apps/openmw/mwworld/cellstore.cpp @@ -0,0 +1,124 @@ + +#include "cellstore.hpp" + +#include + +#include + +namespace MWWorld +{ + CellStore::CellStore (const ESM::Cell *cell_) : cell (cell_), mState (State_Unloaded) + { + mWaterLevel = cell->water; + } + + void CellStore::load (const ESMS::ESMStore &store, ESM::ESMReader &esm) + { + if (mState!=State_Loaded) + { + if (mState==State_Preloaded) + mIds.clear(); + + std::cout << "loading cell " << cell->getDescription() << std::endl; + + loadRefs (store, esm); + + mState = State_Loaded; + } + } + + void CellStore::preload (const ESMS::ESMStore &store, ESM::ESMReader &esm) + { + if (mState==State_Unloaded) + { + listRefs (store, esm); + + mState = State_Preloaded; + } + } + + void CellStore::listRefs(const ESMS::ESMStore &store, ESM::ESMReader &esm) + { + assert (cell); + + if (cell->context.filename.empty()) + return; // this is a dynamically generated cell -> skipping. + + // Reopen the ESM reader and seek to the right position. + cell->restore (esm); + + ESM::CellRef ref; + + // Get each reference in turn + while (cell->getNextRef (esm, ref)) + { + std::string lowerCase; + + std::transform (ref.refID.begin(), ref.refID.end(), std::back_inserter (lowerCase), + (int(*)(int)) std::tolower); + + mIds.push_back (lowerCase); + } + + std::sort (mIds.begin(), mIds.end()); + } + + void CellStore::loadRefs(const ESMS::ESMStore &store, ESM::ESMReader &esm) + { + assert (cell); + + if (cell->context.filename.empty()) + return; // this is a dynamically generated cell -> skipping. + + // Reopen the ESM reader and seek to the right position. + cell->restore(esm); + + ESM::CellRef ref; + + // Get each reference in turn + while(cell->getNextRef(esm, ref)) + { + std::string lowerCase; + + std::transform (ref.refID.begin(), ref.refID.end(), std::back_inserter (lowerCase), + (int(*)(int)) std::tolower); + + int rec = store.find(ref.refID); + + ref.refID = lowerCase; + + /* We can optimize this further by storing the pointer to the + record itself in store.all, so that we don't need to look it + up again here. However, never optimize. There are infinite + opportunities to do that later. + */ + 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 0: std::cout << "Cell reference " + ref.refID + " not found!\n"; break; + default: + std::cout << "WARNING: Ignoring reference '" << ref.refID << "' of unhandled type\n"; + } + } + } +} diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp new file mode 100644 index 000000000..8253f3f0b --- /dev/null +++ b/apps/openmw/mwworld/cellstore.hpp @@ -0,0 +1,174 @@ +#ifndef GAME_MWWORLD_CELLSTORE_H +#define GAME_MWWORLD_CELLSTORE_H + +#include + +#include +#include +#include +#include +#include + +#include "refdata.hpp" + +namespace ESMS +{ + struct ESMStore; +} + +namespace MWWorld +{ + /// A reference to one object (of any type) in a cell. + /// + /// Constructing this with a CellRef instance in the constructor means that + /// in practice (where D is RefData) the possibly mutable data is copied + /// across to mData. If later adding data (such as position) to CellRef + /// this would have to be manually copied across. + template + struct LiveCellRef + { + LiveCellRef(const ESM::CellRef& cref, const X* b = NULL) : base(b), ref(cref), + mData(ref) {} + + + LiveCellRef(const X* b = NULL) : base(b), mData(ref) {} + + // The object that this instance is based on. + const X* base; + + /* Information about this instance, such as 3D location and + rotation and individual type-dependent data. + */ + ESM::CellRef ref; + + /// runtime-data + RefData mData; + }; + + /// A list of cell references + template + struct CellRefList + { + typedef LiveCellRef LiveRef; + typedef std::list List; + List list; + + // Search for the given reference in the given reclist from + // ESMStore. Insert the reference into the list if a match is + // found. If not, throw an exception. + template + void find(ESM::CellRef &ref, const Y& recList) + { + const X* obj = recList.find(ref.refID); + if(obj == NULL) + throw std::runtime_error("Error resolving cell reference " + ref.refID); + + list.push_back(LiveRef(ref, obj)); + } + + LiveRef *find (const std::string& name) + { + for (typename std::list::iterator iter (list.begin()); iter!=list.end(); ++iter) + { + if (iter->ref.refID==name) + return &*iter; + } + + return 0; + } + }; + + /// A storage struct for one single cell reference. + class CellStore + { + public: + + enum State + { + State_Unloaded, State_Preloaded, State_Loaded + }; + + CellStore (const ESM::Cell *cell_); + + const ESM::Cell *cell; + 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; + + void load (const ESMS::ESMStore &store, ESM::ESMReader &esm); + + void preload (const ESMS::ESMStore &store, ESM::ESMReader &esm); + + /// Call functor (ref) for each reference. functor must return a bool. Returning + /// false will abort the iteration. + /// \return Iteration completed? + template + 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); + } + + private: + + template + bool forEachImp (Functor& functor, List& list) + { + for (typename List::List::iterator iter (list.list.begin()); iter!=list.list.end(); + ++iter) + if (!functor (iter->ref, iter->mData)) + return false; + + return true; + } + + /// Run through references and store IDs + void listRefs(const ESMS::ESMStore &store, ESM::ESMReader &esm); + + void loadRefs(const ESMS::ESMStore &store, ESM::ESMReader &esm); + }; +} + +#endif diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index b03ce1f2c..741e3e271 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -9,6 +9,8 @@ #include "nullaction.hpp" #include "containerstore.hpp" +#include "../mwgui/tooltips.hpp" + namespace MWWorld { std::map > Class::sClasses; diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 5e5a3f9ec..20b63a9b9 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -8,11 +8,6 @@ #include #include "action.hpp" -#include "refdata.hpp" -#include "physicssystem.hpp" - -#include "../mwrender/renderinginterface.hpp" -#include "../mwgui/tooltips.hpp" namespace Ogre { @@ -21,7 +16,7 @@ namespace Ogre namespace MWRender { - class CellRenderImp; + class RenderingInterface; } namespace MWMechanics @@ -31,11 +26,17 @@ namespace MWMechanics struct Movement; } +namespace MWGui +{ + struct ToolTipInfo; +} + namespace MWWorld { class Ptr; class ContainerStore; class InventoryStore; + class PhysicsSystem; /// \brief Base class for referenceable esm records class Class diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 3304d0e6d..1d473246c 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -5,12 +5,12 @@ #include #include -#include +#include #include #include "../mwbase/environment.hpp" -#include "../mwworld/world.hpp" +#include "../mwbase/world.hpp" #include "manualref.hpp" #include "refdata.hpp" @@ -19,11 +19,11 @@ namespace { template - float getTotalWeight (const ESMS::CellRefList& cellRefList) + float getTotalWeight (const MWWorld::CellRefList& cellRefList) { float sum = 0; - for (typename ESMS::CellRefList::List::const_iterator iter ( + for (typename MWWorld::CellRefList::List::const_iterator iter ( cellRefList.list.begin()); iter!=cellRefList.list.end(); ++iter) @@ -78,7 +78,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& ptr) // this ensures that gold piles of different sizes stack with each other (also, several scripts rely on Gold_001 for detecting player gold) if (MWWorld::Class::get(ptr).getName(ptr) == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGold")->str) { - ESMS::LiveCellRef *gold = + MWWorld::LiveCellRef *gold = ptr.get(); if (compare_string_ci(gold->ref.refID, "gold_001") @@ -281,29 +281,29 @@ MWWorld::ContainerStoreIterator::ContainerStoreIterator (int mask, ContainerStor ++*this; } -MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator iterator) +MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator iterator) : mType(MWWorld::ContainerStore::Type_Potion), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mPotion(iterator){} -MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator iterator) +MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator iterator) : mType(MWWorld::ContainerStore::Type_Apparatus), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mApparatus(iterator){} -MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator iterator) +MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator iterator) : mType(MWWorld::ContainerStore::Type_Armor), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mArmor(iterator){} -MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator iterator) +MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator iterator) : mType(MWWorld::ContainerStore::Type_Book), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mBook(iterator){} -MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator iterator) +MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator iterator) : mType(MWWorld::ContainerStore::Type_Clothing), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mClothing(iterator){} -MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator iterator) +MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator iterator) : mType(MWWorld::ContainerStore::Type_Ingredient), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mIngredient(iterator){} -MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator iterator) +MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator iterator) : mType(MWWorld::ContainerStore::Type_Light), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mLight(iterator){} -MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator iterator) +MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator iterator) : mType(MWWorld::ContainerStore::Type_Lockpick), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mLockpick(iterator){} -MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator iterator) +MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator iterator) : mType(MWWorld::ContainerStore::Type_Miscellaneous), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mMiscellaneous(iterator){} -MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator iterator) +MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator iterator) : mType(MWWorld::ContainerStore::Type_Probe), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mProbe(iterator){} -MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator iterator) +MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator iterator) : mType(MWWorld::ContainerStore::Type_Repair), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mRepair(iterator){} -MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator iterator) +MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator iterator) : mType(MWWorld::ContainerStore::Type_Weapon), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mWeapon(iterator){} void MWWorld::ContainerStoreIterator::incType() diff --git a/apps/openmw/mwworld/containerstore.hpp b/apps/openmw/mwworld/containerstore.hpp index 15b553f9d..f71b493bd 100644 --- a/apps/openmw/mwworld/containerstore.hpp +++ b/apps/openmw/mwworld/containerstore.hpp @@ -3,8 +3,7 @@ #include -#include - +#include "cellstore.hpp" #include "refdata.hpp" #include "ptr.hpp" @@ -40,18 +39,18 @@ namespace MWWorld private: - ESMS::CellRefList potions; - ESMS::CellRefList appas; - ESMS::CellRefList armors; - ESMS::CellRefList books; - ESMS::CellRefList clothes; - ESMS::CellRefList ingreds; - ESMS::CellRefList lights; - ESMS::CellRefList lockpicks; - ESMS::CellRefList miscItems; - ESMS::CellRefList probes; - ESMS::CellRefList repairs; - ESMS::CellRefList weapons; + MWWorld::CellRefList potions; + MWWorld::CellRefList appas; + MWWorld::CellRefList armors; + MWWorld::CellRefList books; + MWWorld::CellRefList clothes; + MWWorld::CellRefList ingreds; + MWWorld::CellRefList lights; + MWWorld::CellRefList lockpicks; + MWWorld::CellRefList miscItems; + MWWorld::CellRefList probes; + MWWorld::CellRefList repairs; + MWWorld::CellRefList weapons; int mStateId; mutable float mCachedWeight; mutable bool mWeightUpToDate; @@ -122,18 +121,18 @@ namespace MWWorld ContainerStore *mContainer; mutable Ptr mPtr; - ESMS::CellRefList::List::iterator mPotion; - ESMS::CellRefList::List::iterator mApparatus; - ESMS::CellRefList::List::iterator mArmor; - ESMS::CellRefList::List::iterator mBook; - ESMS::CellRefList::List::iterator mClothing; - ESMS::CellRefList::List::iterator mIngredient; - ESMS::CellRefList::List::iterator mLight; - ESMS::CellRefList::List::iterator mLockpick; - ESMS::CellRefList::List::iterator mMiscellaneous; - ESMS::CellRefList::List::iterator mProbe; - ESMS::CellRefList::List::iterator mRepair; - ESMS::CellRefList::List::iterator mWeapon; + MWWorld::CellRefList::List::iterator mPotion; + MWWorld::CellRefList::List::iterator mApparatus; + MWWorld::CellRefList::List::iterator mArmor; + MWWorld::CellRefList::List::iterator mBook; + MWWorld::CellRefList::List::iterator mClothing; + MWWorld::CellRefList::List::iterator mIngredient; + MWWorld::CellRefList::List::iterator mLight; + MWWorld::CellRefList::List::iterator mLockpick; + MWWorld::CellRefList::List::iterator mMiscellaneous; + MWWorld::CellRefList::List::iterator mProbe; + MWWorld::CellRefList::List::iterator mRepair; + MWWorld::CellRefList::List::iterator mWeapon; private: @@ -144,18 +143,18 @@ namespace MWWorld ///< Begin-iterator // construct iterator using a CellRefList iterator - ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator); - ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator); - ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator); - ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator); - ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator); - ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator); - ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator); - ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator); - ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator); - ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator); - ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator); - ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList::List::iterator); + ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator); + ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator); + ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator); + ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator); + ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator); + ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator); + ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator); + ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator); + ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator); + ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator); + ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator); + ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList::List::iterator); void incType(); diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 6df73004b..9d99227ed 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -6,9 +6,10 @@ #include -#include "../mwbase/environment.hpp" +#include -#include "../mwworld/world.hpp" +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" #include "../mwmechanics/npcstats.hpp" diff --git a/apps/openmw/mwworld/localscripts.cpp b/apps/openmw/mwworld/localscripts.cpp index 2d90d90e0..d15f00c92 100644 --- a/apps/openmw/mwworld/localscripts.cpp +++ b/apps/openmw/mwworld/localscripts.cpp @@ -1,13 +1,17 @@ #include "localscripts.hpp" +#include + +#include "cellstore.hpp" + namespace { template void listCellScripts (MWWorld::LocalScripts& localScripts, - ESMS::CellRefList& cellRefList, MWWorld::Ptr::CellStore *cell) + MWWorld::CellRefList& cellRefList, MWWorld::Ptr::CellStore *cell) { - for (typename ESMS::CellRefList::List::iterator iter ( + for (typename MWWorld::CellRefList::List::iterator iter ( cellRefList.list.begin()); iter!=cellRefList.list.end(); ++iter) { diff --git a/apps/openmw/mwworld/localscripts.hpp b/apps/openmw/mwworld/localscripts.hpp index 1ea2cf4d5..78f65e356 100644 --- a/apps/openmw/mwworld/localscripts.hpp +++ b/apps/openmw/mwworld/localscripts.hpp @@ -13,6 +13,8 @@ namespace ESMS namespace MWWorld { + class CellStore; + /// \brief List of active local scripts class LocalScripts { @@ -41,13 +43,13 @@ namespace MWWorld void add (const std::string& scriptName, const Ptr& ptr); ///< Add script to collection of active local scripts. - void addCell (Ptr::CellStore *cell); + void addCell (CellStore *cell); ///< Add all local scripts in a cell. void clear(); ///< Clear active local scripts collection. - void clearCell (Ptr::CellStore *cell); + void clearCell (CellStore *cell); ///< Remove all scripts belonging to \a cell. void remove (const Ptr& ptr); diff --git a/apps/openmw/mwworld/manualref.hpp b/apps/openmw/mwworld/manualref.hpp index f8bc7d983..6044ac8d5 100644 --- a/apps/openmw/mwworld/manualref.hpp +++ b/apps/openmw/mwworld/manualref.hpp @@ -3,10 +3,10 @@ #include -#include #include #include "ptr.hpp" +#include "cellstore.hpp" namespace MWWorld { @@ -24,11 +24,11 @@ namespace MWWorld { if (const T *instance = list.search (name)) { - ESMS::LiveCellRef ref; + LiveCellRef ref; ref.base = instance; mRef = ref; - mPtr = Ptr (&boost::any_cast&> (mRef), 0); + mPtr = Ptr (&boost::any_cast&> (mRef), 0); return true; } @@ -41,11 +41,11 @@ namespace MWWorld { if (const T *instance = list.search (name)) { - ESMS::LiveCellRef ref; + LiveCellRef ref; ref.base = instance; mRef = ref; - mPtr = Ptr (&boost::any_cast&> (mRef), 0); + mPtr = Ptr (&boost::any_cast&> (mRef), 0); return true; } diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 64d1c1386..58cb63675 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -1,18 +1,19 @@ +#include "physicssystem.hpp" + #include -#include "physicssystem.hpp" -#include "../mwworld/ptr.hpp" -#include "../mwworld/world.hpp" // FIXME +#include +#include +#include +#include +#include +#include + #include -#include "OgreRoot.h" -#include "OgreRenderWindow.h" -#include "OgreSceneManager.h" -#include "OgreViewport.h" -#include "OgreCamera.h" -#include "OgreTextureManager.h" - +#include "../mwbase/world.hpp" // FIXME +#include "ptr.hpp" using namespace Ogre; namespace MWWorld diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 91b030d1c..0eeebad4e 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -1,18 +1,22 @@ #include "player.hpp" +#include + +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + #include "../mwrender/player.hpp" #include "../mwmechanics/movement.hpp" #include "../mwmechanics/npcstats.hpp" -#include "world.hpp" #include "class.hpp" namespace MWWorld { - Player::Player (MWRender::Player *renderer, const ESM::NPC *player, MWWorld::World& world) : - mCellStore (0), mRenderer (renderer), mWorld (world), mClass (0), + Player::Player (MWRender::Player *renderer, const ESM::NPC *player, const MWBase::World& world) : + mCellStore (0), mRenderer (renderer), mClass (0), mAutoMove (false), mForwardBackward (0) { mPlayer.base = player; @@ -36,8 +40,8 @@ namespace MWWorld void Player::setPos(float x, float y, float z) { - /// \todo This fcuntion should be removed during the mwrender-refactoring. - mWorld.moveObject (getPlayer(), x, y, z); + /// \todo This fcuntion should be removed during the mwrender-refactoring. + MWBase::Environment::get().getWorld()->moveObject (getPlayer(), x, y, z); } void Player::setRot(float x, float y, float z) @@ -90,14 +94,13 @@ namespace MWWorld MWWorld::Class::get (ptr).getMovementSettings (ptr).mForwardBackward = value; } - void Player::setUpDown(int value) - { - MWWorld::Ptr ptr = getPlayer(); - + void Player::setUpDown(int value) + { + MWWorld::Ptr ptr = getPlayer(); MWWorld::Class::get (ptr).getMovementSettings (ptr).mUpDown = value; - } + } void Player::toggleRunning() { diff --git a/apps/openmw/mwworld/player.hpp b/apps/openmw/mwworld/player.hpp index a5c5ff308..6f6ee93bc 100644 --- a/apps/openmw/mwworld/player.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -3,13 +3,20 @@ #include "OgreCamera.h" -#include - +#include "../mwworld/cellstore.hpp" #include "../mwworld/refdata.hpp" #include "../mwworld/ptr.hpp" #include "../mwmechanics/drawstate.hpp" +#undef DrawState // How did this get defined again? + // Maybe it's defined by default in every file for windows? + +namespace MWBase +{ + class World; +} + namespace MWRender { class Player; @@ -17,15 +24,14 @@ namespace MWRender namespace MWWorld { - class World; + class CellStore; /// \brief NPC object representing the player and additional player data - class Player + class Player { - ESMS::LiveCellRef mPlayer; - MWWorld::Ptr::CellStore *mCellStore; + LiveCellRef mPlayer; + MWWorld::CellStore *mCellStore; MWRender::Player *mRenderer; - MWWorld::World& mWorld; std::string mName; bool mMale; std::string mRace; @@ -35,7 +41,7 @@ namespace MWWorld int mForwardBackward; public: - Player(MWRender::Player *renderer, const ESM::NPC *player, MWWorld::World& world); + Player(MWRender::Player *renderer, const ESM::NPC *player, const MWBase::World& world); ~Player(); @@ -45,7 +51,7 @@ namespace MWWorld /// Set where the player is looking at. Uses Morrowind (euler) angles void setRot(float x, float y, float z); - void setCell (MWWorld::Ptr::CellStore *cellStore) + void setCell (MWWorld::CellStore *cellStore) { mCellStore = cellStore; } @@ -119,7 +125,7 @@ namespace MWWorld void setLeftRight (int value); void setForwardBackward (int value); - void setUpDown(int value); + void setUpDown(int value); void toggleRunning(); }; diff --git a/apps/openmw/mwworld/ptr.hpp b/apps/openmw/mwworld/ptr.hpp index 4cf3e98da..b7469b8f5 100644 --- a/apps/openmw/mwworld/ptr.hpp +++ b/apps/openmw/mwworld/ptr.hpp @@ -7,9 +7,7 @@ #include -#include - -#include "refdata.hpp" +#include "cellstore.hpp" namespace MWWorld { @@ -21,7 +19,8 @@ namespace MWWorld { public: - typedef ESMS::CellStore CellStore; + typedef MWWorld::CellStore CellStore; + ///< \deprecated boost::any mPtr; ESM::CellRef *mCellRef; @@ -51,7 +50,7 @@ namespace MWWorld } template - Ptr (ESMS::LiveCellRef *liveCellRef, CellStore *cell) + Ptr (MWWorld::LiveCellRef *liveCellRef, CellStore *cell) : mContainerStore (0) { mPtr = liveCellRef; @@ -62,9 +61,9 @@ namespace MWWorld } template - ESMS::LiveCellRef *get() const + MWWorld::LiveCellRef *get() const { - return boost::any_cast*> (mPtr); + return boost::any_cast*> (mPtr); } ESM::CellRef& getCellRef() const; diff --git a/apps/openmw/mwworld/refdata.cpp b/apps/openmw/mwworld/refdata.cpp index e1c14b907..14ddd3ec5 100644 --- a/apps/openmw/mwworld/refdata.cpp +++ b/apps/openmw/mwworld/refdata.cpp @@ -1,9 +1,10 @@ #include "refdata.hpp" -#include +#include #include "customdata.hpp" +#include "cellstore.hpp" namespace MWWorld { diff --git a/apps/openmw/mwworld/refdata.hpp b/apps/openmw/mwworld/refdata.hpp index 30d676f13..41521e47a 100644 --- a/apps/openmw/mwworld/refdata.hpp +++ b/apps/openmw/mwworld/refdata.hpp @@ -3,12 +3,15 @@ #include -#include - #include #include "../mwscript/locals.hpp" +namespace Ogre +{ + class SceneNode; +} + namespace ESM { class Script; diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index a47137d25..39496def3 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -1,7 +1,7 @@ #include "scene.hpp" -#include "world.hpp" #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" /// FIXME #include "../mwmechanics/mechanicsmanager.hpp" @@ -9,12 +9,12 @@ #include "../mwgui/window_manager.hpp" -#include "../mwworld/world.hpp" /// FIXME #include "../mwworld/manualref.hpp" /// FIXME #include "ptr.hpp" #include "player.hpp" #include "class.hpp" +#include "localscripts.hpp" #include "cellfunctors.hpp" @@ -23,7 +23,7 @@ namespace template void insertCellRefList(MWRender::RenderingManager& rendering, - T& cellRefList, ESMS::CellStore &cell, MWWorld::PhysicsSystem& physics) + T& cellRefList, MWWorld::CellStore &cell, MWWorld::PhysicsSystem& physics) { if (!cellRefList.list.empty()) { @@ -86,7 +86,7 @@ namespace MWWorld if (!((*iter)->cell->data.flags & ESM::Cell::Interior)) { - ESM::Land* land = mWorld->getStore().lands.search((*iter)->cell->data.gridX,(*iter)->cell->data.gridY); + ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search((*iter)->cell->data.gridX,(*iter)->cell->data.gridY); if (land) mPhysics->removeHeightField( (*iter)->cell->data.gridX, (*iter)->cell->data.gridY ); } @@ -95,7 +95,7 @@ namespace MWWorld mRendering.removeCell(*iter); //mPhysics->removeObject("Unnamed_43"); - mWorld->getLocalScripts().clearCell (*iter); + MWBase::Environment::get().getWorld()->getLocalScripts().clearCell (*iter); MWBase::Environment::get().getMechanicsManager()->dropActors (*iter); MWBase::Environment::get().getSoundManager()->stopSound (*iter); mActiveCells.erase(*iter); @@ -107,7 +107,7 @@ namespace MWWorld void Scene::loadCell (Ptr::CellStore *cell) { // register local scripts - mWorld->getLocalScripts().addCell (cell); + MWBase::Environment::get().getWorld()->getLocalScripts().addCell (cell); @@ -124,7 +124,7 @@ namespace MWWorld if (!(cell->cell->data.flags & ESM::Cell::Interior)) { - ESM::Land* land = mWorld->getStore().lands.search(cell->cell->data.gridX,cell->cell->data.gridY); + ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cell->cell->data.gridX,cell->cell->data.gridY); if (land) mPhysics->addHeightField (land->landData->heights, cell->cell->data.gridX, cell->cell->data.gridY, @@ -146,14 +146,14 @@ namespace MWWorld mPhysics->setCurrentWater(hasWater, cell->cell->water); if (adjustPlayerPos) { - mWorld->getPlayer().setPos (position.pos[0], position.pos[1], position.pos[2]); - mWorld->getPlayer().setRot (position.rot[0], position.rot[1], position.rot[2]); + MWBase::Environment::get().getWorld()->getPlayer().setPos (position.pos[0], position.pos[1], position.pos[2]); + MWBase::Environment::get().getWorld()->getPlayer().setRot (position.rot[0], position.rot[1], position.rot[2]); } - mWorld->getPlayer().setCell (cell); + MWBase::Environment::get().getWorld()->getPlayer().setCell (cell); - MWBase::Environment::get().getMechanicsManager()->addActor (mWorld->getPlayer().getPlayer()); - MWBase::Environment::get().getMechanicsManager()->watchActor (mWorld->getPlayer().getPlayer()); + MWBase::Environment::get().getMechanicsManager()->addActor (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); + MWBase::Environment::get().getMechanicsManager()->watchActor (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); MWBase::Environment::get().getWindowManager()->changeCell( mCurrentCell ); } @@ -163,7 +163,7 @@ namespace MWWorld mRendering.preCellChange(mCurrentCell); // remove active - MWBase::Environment::get().getMechanicsManager()->removeActor (mWorld->getPlayer().getPlayer()); + MWBase::Environment::get().getMechanicsManager()->removeActor (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); CellStoreCollection::iterator active = mActiveCells.begin(); @@ -202,7 +202,7 @@ namespace MWWorld if (iter==mActiveCells.end()) { - Ptr::CellStore *cell = mWorld->getExterior(x, y); + CellStore *cell = MWBase::Environment::get().getWorld()->getExterior(x, y); loadCell (cell); } @@ -228,10 +228,10 @@ namespace MWWorld // adjust player - playerCellChange (mWorld->getExterior(X, Y), position, adjustPlayerPos); + playerCellChange (MWBase::Environment::get().getWorld()->getExterior(X, Y), position, adjustPlayerPos); // Sky system - mWorld->adjustSky(); + MWBase::Environment::get().getWorld()->adjustSky(); mRendering.switchToExterior(); @@ -239,9 +239,8 @@ namespace MWWorld } //We need the ogre renderer and a scene node. - Scene::Scene (World *world, MWRender::RenderingManager& rendering, PhysicsSystem *physics) - : mCurrentCell (0), mCellChanged (false), mWorld(world), - mPhysics(physics), mRendering(rendering) + Scene::Scene (MWRender::RenderingManager& rendering, PhysicsSystem *physics) + : mCurrentCell (0), mCellChanged (false), mPhysics(physics), mRendering(rendering) { } @@ -263,7 +262,7 @@ namespace MWWorld { std::cout << "Changing to interior\n"; - Ptr::CellStore *cell = mWorld->getInterior(cellName); + CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName); // remove active CellStoreCollection::iterator active = mActiveCells.begin(); @@ -287,7 +286,7 @@ namespace MWWorld mRendering.configureFog(*cell); // Sky system - mWorld->adjustSky(); + MWBase::Environment::get().getWorld()->adjustSky(); mCellChanged = true; } @@ -297,7 +296,7 @@ namespace MWWorld int x = 0; int y = 0; - mWorld->positionToIndex (position.pos[0], position.pos[1], x, y); + MWBase::Environment::get().getWorld()->positionToIndex (position.pos[0], position.pos[1], x, y); changeCell (x, y, position, true); } @@ -312,7 +311,7 @@ namespace MWWorld mCellChanged = false; } - void Scene::insertCell(ESMS::CellStore &cell) + void Scene::insertCell (Ptr::CellStore &cell) { // Loop through all references in the cell insertCellRefList(mRendering, cell.activators, cell, *mPhysics); @@ -339,7 +338,7 @@ namespace MWWorld /// \todo this whole code needs major clean up, and doesn't belong in this class. - void Scene::insertObject(MWWorld::Ptr ptr, Ptr::CellStore* cell) + void Scene::insertObject (const Ptr& ptr, CellStore* cell) { std::string type = ptr.getTypeName(); @@ -348,67 +347,67 @@ namespace MWWorld // insert into the correct CellRefList if (type == typeid(ESM::Potion).name()) { - ESMS::LiveCellRef* ref = ptr.get(); + MWWorld::LiveCellRef* ref = ptr.get(); cell->potions.list.push_back( *ref ); newPtr = MWWorld::Ptr(&cell->potions.list.back(), cell); } else if (type == typeid(ESM::Apparatus).name()) { - ESMS::LiveCellRef* ref = ptr.get(); + MWWorld::LiveCellRef* ref = ptr.get(); cell->appas.list.push_back( *ref ); newPtr = MWWorld::Ptr(&cell->appas.list.back(), cell); } else if (type == typeid(ESM::Armor).name()) { - ESMS::LiveCellRef* ref = ptr.get(); + MWWorld::LiveCellRef* ref = ptr.get(); cell->armors.list.push_back( *ref ); newPtr = MWWorld::Ptr(&cell->armors.list.back(), cell); } else if (type == typeid(ESM::Book).name()) { - ESMS::LiveCellRef* ref = ptr.get(); + MWWorld::LiveCellRef* ref = ptr.get(); cell->books.list.push_back( *ref ); newPtr = MWWorld::Ptr(&cell->books.list.back(), cell); } else if (type == typeid(ESM::Clothing).name()) { - ESMS::LiveCellRef* ref = ptr.get(); + MWWorld::LiveCellRef* ref = ptr.get(); cell->clothes.list.push_back( *ref ); newPtr = MWWorld::Ptr(&cell->clothes.list.back(), cell); } else if (type == typeid(ESM::Ingredient).name()) { - ESMS::LiveCellRef* ref = ptr.get(); + MWWorld::LiveCellRef* ref = ptr.get(); cell->ingreds.list.push_back( *ref ); newPtr = MWWorld::Ptr(&cell->ingreds.list.back(), cell); } else if (type == typeid(ESM::Light).name()) { - ESMS::LiveCellRef* ref = ptr.get(); + MWWorld::LiveCellRef* ref = ptr.get(); cell->lights.list.push_back( *ref ); newPtr = MWWorld::Ptr(&cell->lights.list.back(), cell); } else if (type == typeid(ESM::Tool).name()) { - ESMS::LiveCellRef* ref = ptr.get(); + MWWorld::LiveCellRef* ref = ptr.get(); cell->lockpicks.list.push_back( *ref ); newPtr = MWWorld::Ptr(&cell->lockpicks.list.back(), cell); } else if (type == typeid(ESM::Repair).name()) { - ESMS::LiveCellRef* ref = ptr.get(); + MWWorld::LiveCellRef* ref = ptr.get(); cell->repairs.list.push_back( *ref ); newPtr = MWWorld::Ptr(&cell->repairs.list.back(), cell); } else if (type == typeid(ESM::Probe).name()) { - ESMS::LiveCellRef* ref = ptr.get(); + MWWorld::LiveCellRef* ref = ptr.get(); cell->probes.list.push_back( *ref ); newPtr = MWWorld::Ptr(&cell->probes.list.back(), cell); } else if (type == typeid(ESM::Weapon).name()) { - ESMS::LiveCellRef* ref = ptr.get(); + MWWorld::LiveCellRef* ref = ptr.get(); cell->weapons.list.push_back( *ref ); newPtr = MWWorld::Ptr(&cell->weapons.list.back(), cell); } @@ -432,7 +431,7 @@ namespace MWWorld MWWorld::ManualRef newRef (MWBase::Environment::get().getWorld()->getStore(), base); - ESMS::LiveCellRef* ref = newRef.getPtr().get(); + MWWorld::LiveCellRef* ref = newRef.getPtr().get(); cell->miscItems.list.push_back( *ref ); newPtr = MWWorld::Ptr(&cell->miscItems.list.back(), cell); @@ -444,7 +443,7 @@ namespace MWWorld } else { - ESMS::LiveCellRef* ref = ptr.get(); + MWWorld::LiveCellRef* ref = ptr.get(); cell->miscItems.list.push_back( *ref ); newPtr = MWWorld::Ptr(&cell->miscItems.list.back(), cell); diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index 906580ff4..64a8c9f8e 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -8,14 +8,10 @@ #include -#include - #include "../mwrender/renderingmanager.hpp" #include "../mwrender/renderinginterface.hpp" #include "physicssystem.hpp" -#include "refdata.hpp" -#include "ptr.hpp" #include "globals.hpp" namespace Ogre @@ -47,43 +43,43 @@ namespace MWRender namespace MWWorld { class Player; + class CellStore; + class Ptr; class Scene { - public: - typedef std::set CellStoreCollection; + typedef std::set CellStoreCollection; private: //OEngine::Render::OgreRenderer& mRenderer; - Ptr::CellStore* mCurrentCell; // the cell, the player is in + CellStore* mCurrentCell; // the cell, the player is in CellStoreCollection mActiveCells; bool mCellChanged; - World *mWorld; PhysicsSystem *mPhysics; MWRender::RenderingManager& mRendering; - void playerCellChange (Ptr::CellStore *cell, const ESM::Position& position, + void playerCellChange (CellStore *cell, const ESM::Position& position, bool adjustPlayerPos = true); public: - Scene (World *world, MWRender::RenderingManager& rendering, PhysicsSystem *physics); + Scene (MWRender::RenderingManager& rendering, PhysicsSystem *physics); ~Scene(); void unloadCell (CellStoreCollection::iterator iter); - void loadCell (Ptr::CellStore *cell); + void loadCell (CellStore *cell); void changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos); ///< Move from exterior to interior or from interior cell to a different /// interior cell. - Ptr::CellStore* getCurrentCell (); + CellStore* getCurrentCell (); const CellStoreCollection& getActiveCells () const; @@ -98,11 +94,11 @@ namespace MWWorld void markCellAsUnchanged(); - void insertCell(ESMS::CellStore &cell); + void insertCell (Ptr::CellStore &cell); /// this method is only meant for dropping objects into the gameworld from a container /// and thus only handles object types that can be placed in a container - void insertObject(MWWorld::Ptr object, Ptr::CellStore* cell); + void insertObject (const Ptr& object, CellStore* cell); void update (float duration); diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 3d6547d6a..6c275ff80 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -1,17 +1,20 @@ #include "weather.hpp" -#include "world.hpp" -#include "player.hpp" - -#include "../mwrender/renderingmanager.hpp" -#include "../mwsound/soundmanager.hpp" #include #include -#include #include +#include + #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + +#include "../mwrender/renderingmanager.hpp" + +#include "../mwsound/soundmanager.hpp" + +#include "player.hpp" using namespace Ogre; using namespace MWWorld; diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/worldimp.cpp similarity index 91% rename from apps/openmw/mwworld/world.cpp rename to apps/openmw/mwworld/worldimp.cpp index 8cbb5477a..65095e2b7 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1,4 +1,4 @@ -#include "world.hpp" +#include "worldimp.hpp" #include #include @@ -33,10 +33,10 @@ namespace { template void listCellScripts (const ESMS::ESMStore& store, - ESMS::CellRefList& cellRefList, MWWorld::LocalScripts& localScripts, + MWWorld::CellRefList& cellRefList, MWWorld::LocalScripts& localScripts, MWWorld::Ptr::CellStore *cell) { - for (typename ESMS::CellRefList::List::iterator iter ( + for (typename MWWorld::CellRefList::List::iterator iter ( cellRefList.list.begin()); iter!=cellRefList.list.end(); ++iter) { @@ -53,10 +53,10 @@ namespace } template - ESMS::LiveCellRef *searchViaHandle (const std::string& handle, - ESMS::CellRefList& refList) + MWWorld::LiveCellRef *searchViaHandle (const std::string& handle, + MWWorld::CellRefList& refList) { - typedef typename ESMS::CellRefList::List::iterator iterator; + typedef typename MWWorld::CellRefList::List::iterator iterator; for (iterator iter (refList.list.begin()); iter!=refList.list.end(); ++iter) { @@ -75,45 +75,45 @@ namespace MWWorld { Ptr World::getPtrViaHandle (const std::string& handle, Ptr::CellStore& cell) { - if (ESMS::LiveCellRef *ref = + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.activators)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.potions)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.potions)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.appas)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.appas)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.armors)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.armors)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.books)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.books)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.clothes)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.clothes)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.containers)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.creatures)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.doors)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.doors)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.ingreds)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.lights)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.lights)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.lockpicks)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.lockpicks)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.miscItems)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.miscItems)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.npcs)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.npcs)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.probes)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.probes)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.repairs)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.repairs)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.statics)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.statics)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.weapons)) + if (MWWorld::LiveCellRef *ref = searchViaHandle (handle, cell.weapons)) return Ptr (ref, &cell); return Ptr(); } @@ -154,19 +154,19 @@ namespace MWWorld mRendering->skyDisable(); } - void World::setFallbackValues(std::map fallbackMap) + void World::setFallbackValues (const std::map& fallbackMap) { mFallback = fallbackMap; } - std::string World::getFallback(std::string key) + std::string World::getFallback (const std::string& key) const { return getFallback(key, ""); } - std::string World::getFallback(std::string key, std::string def) + std::string World::getFallback (const std::string& key, const std::string& def) const { - std::map::iterator it; + std::map::const_iterator it; if((it = mFallback.find(key)) == mFallback.end()) { return def; @@ -179,7 +179,7 @@ namespace MWWorld const std::string& master, const boost::filesystem::path& resDir, bool newGame, const std::string& encoding, std::map fallbackMap) : mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0), - mSky (true), mNextDynamicRecord (0), mCells (mStore, mEsm, *this), + mSky (true), mNextDynamicRecord (0), mCells (mStore, mEsm), mNumFacing(0) { mPhysics = new PhysicsSystem(renderer); @@ -211,7 +211,7 @@ namespace MWWorld mGlobalVariables->setInt ("chargenstate", 1); } - mWorldScene = new Scene(this, *mRendering, mPhysics); + mWorldScene = new Scene(*mRendering, mPhysics); setFallbackValues(fallbackMap); @@ -351,7 +351,7 @@ namespace MWWorld throw std::runtime_error ("unknown Ogre handle: " + handle); } - void World::enable (Ptr reference) + void World::enable (const Ptr& reference) { if (!reference.getRefData().isEnabled()) { @@ -362,7 +362,7 @@ namespace MWWorld } } - void World::disable (Ptr reference) + void World::disable (const Ptr& reference) { if (reference.getRefData().isEnabled()) { @@ -537,7 +537,7 @@ namespace MWWorld } } - void World::deleteObject (Ptr ptr) + void World::deleteObject (const Ptr& ptr) { if (ptr.getRefData().getCount()>0) { @@ -552,7 +552,7 @@ namespace MWWorld } } - bool World::moveObjectImp (Ptr ptr, float x, float y, float z) + bool World::moveObjectImp (const Ptr& ptr, float x, float y, float z) { bool ret = false; ptr.getRefData().getPosition().pos[0] = x; @@ -590,7 +590,7 @@ namespace MWWorld return ret; } - void World::moveObject (Ptr ptr, float x, float y, float z) + void World::moveObject (const Ptr& ptr, float x, float y, float z) { moveObjectImp(ptr, x, y, z); @@ -813,6 +813,8 @@ namespace MWWorld void World::update (float duration) { + /// \todo split this function up into subfunctions + mWorldScene->update (duration); mWeatherManager->update (duration); @@ -1019,10 +1021,10 @@ namespace MWWorld return mRendering->getFader(); } - Ogre::Vector2 World::getNorthVector(Ptr::CellStore* cell) + Ogre::Vector2 World::getNorthVector (CellStore* cell) { - ESMS::CellRefList statics = cell->statics; - ESMS::LiveCellRef* ref = statics.find("northmarker"); + MWWorld::CellRefList statics = cell->statics; + MWWorld::LiveCellRef* ref = statics.find("northmarker"); if (!ref) return Vector2(0, 1); Ogre::SceneNode* node = ref->mData.getBaseNode(); @@ -1041,14 +1043,14 @@ namespace MWWorld mRendering->toggleWater(); } - bool World::placeObject(MWWorld::Ptr object, float cursorX, float cursorY) + bool World::placeObject (const Ptr& object, float cursorX, float cursorY) { std::pair result = mPhysics->castRay(cursorX, cursorY); if (!result.first) return false; - MWWorld::Ptr::CellStore* cell; + CellStore* cell; if (isCellExterior()) { int cellX, cellY; @@ -1081,7 +1083,7 @@ namespace MWWorld return true; } - void World::dropObjectOnGround(MWWorld::Ptr object) + void World::dropObjectOnGround (const Ptr& object) { MWWorld::Ptr::CellStore* cell = getPlayer().getPlayer().getCell(); @@ -1099,4 +1101,9 @@ namespace MWWorld { mRendering->processChangedSettings(settings); } + + void World::getTriangleBatchCount(unsigned int &triangles, unsigned int &batches) + { + mRendering->getTriangleBatchCount(triangles, batches); + } } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/worldimp.hpp similarity index 53% rename from apps/openmw/mwworld/world.hpp rename to apps/openmw/mwworld/worldimp.hpp index 34757661c..62a24000e 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -1,12 +1,13 @@ -#ifndef GAME_MWWORLD_WORLD_H -#define GAME_MWWORLD_WORLD_H +#ifndef GAME_MWWORLD_WORLDIMP_H +#define GAME_MWWORLD_WORLDIMP_H #include #include #include -#include +#include + #include #include "../mwrender/debugging.hpp" @@ -26,6 +27,8 @@ #include +#include "../mwbase/world.hpp" + namespace Ogre { class Vector3; @@ -59,20 +62,8 @@ namespace MWWorld /// \brief The game world and its visual representation - class World + class World : public MWBase::World { - public: - - enum RenderMode - { - Render_CollisionDebug, - Render_Wireframe, - Render_Pathgrid, - Render_Compositors - }; - - private: - MWRender::RenderingManager* mRendering; MWWorld::WeatherManager* mWeatherManager; @@ -110,184 +101,183 @@ namespace MWWorld int getDaysPerMonth (int month) const; - bool moveObjectImp (Ptr ptr, float x, float y, float z); + bool moveObjectImp (const Ptr& ptr, float x, float y, float z); ///< @return true if the active cell (cell player is in) changed public: - World (OEngine::Render::OgreRenderer& renderer, + World (OEngine::Render::OgreRenderer& renderer, const Files::Collections& fileCollections, const std::string& master, const boost::filesystem::path& resDir, bool newGame, const std::string& encoding, std::map fallbackMap); - ~World(); + virtual ~World(); - OEngine::Render::Fader* getFader(); + virtual OEngine::Render::Fader* getFader(); + ///< \ŧodo remove this function. Rendering details should not be exposed. - Ptr::CellStore *getExterior (int x, int y); + virtual CellStore *getExterior (int x, int y); - Ptr::CellStore *getInterior (const std::string& name); + virtual CellStore *getInterior (const std::string& name); - void setWaterHeight(const float height); - void toggleWater(); + virtual void setWaterHeight(const float height); - void adjustSky(); + virtual void toggleWater(); - void setFallbackValues(std::map fallbackMap); + virtual void adjustSky(); - std::string getFallback(std::string key); + virtual void getTriangleBatchCount(unsigned int &triangles, unsigned int &batches); - std::string getFallback(std::string key, std::string def); + virtual void setFallbackValues (const std::map& fallbackMap); - MWWorld::Player& getPlayer(); + virtual std::string getFallback (const std::string& key) const; - const ESMS::ESMStore& getStore() const; + virtual std::string getFallback (const std::string& key, const std::string& def) const; - ESM::ESMReader& getEsmReader(); + virtual Player& getPlayer(); - LocalScripts& getLocalScripts(); + virtual const ESMS::ESMStore& getStore() const; - bool hasCellChanged() const; + virtual ESM::ESMReader& getEsmReader(); + + virtual LocalScripts& getLocalScripts(); + + virtual bool hasCellChanged() const; ///< Has the player moved to a different cell, since the last frame? - bool isCellExterior() const; - bool isCellQuasiExterior() const; + virtual bool isCellExterior() const; - Ogre::Vector2 getNorthVector(Ptr::CellStore* cell); + virtual bool isCellQuasiExterior() const; + + virtual Ogre::Vector2 getNorthVector (CellStore* cell); ///< get north vector (OGRE coordinates) for given interior cell - Globals::Data& getGlobalVariable (const std::string& name); + virtual Globals::Data& getGlobalVariable (const std::string& name); - Globals::Data getGlobalVariable (const std::string& name) const; + virtual Globals::Data getGlobalVariable (const std::string& name) const; - char getGlobalVariableType (const std::string& name) const; + virtual char getGlobalVariableType (const std::string& name) const; ///< Return ' ', if there is no global variable with this name. - Ptr getPtr (const std::string& name, bool activeOnly); + virtual Ptr getPtr (const std::string& name, bool activeOnly); ///< Return a pointer to a liveCellRef with the given name. /// \param activeOnly do non search inactive cells. - Ptr getPtrViaHandle (const std::string& handle); + virtual Ptr getPtrViaHandle (const std::string& handle); ///< Return a pointer to a liveCellRef with the given Ogre handle. - /// \todo enable reference in the OGRE scene - void enable (Ptr reference); + virtual void enable (const Ptr& ptr); - /// \todo 5disable reference in the OGRE scene - void disable (Ptr reference); + virtual void disable (const Ptr& ptr); - void advanceTime (double hours); + virtual void advanceTime (double hours); ///< Advance in-game time. - void setHour (double hour); + virtual void setHour (double hour); ///< Set in-game time hour. - void setMonth (int month); + virtual void setMonth (int month); ///< Set in-game time month. - void setDay (int day); + virtual void setDay (int day); ///< Set in-game time day. - TimeStamp getTimeStamp() const; + virtual TimeStamp getTimeStamp() const; ///< Return current in-game time stamp. - bool toggleSky(); + virtual bool toggleSky(); ///< \return Resulting mode - void changeWeather(const std::string& region, const unsigned int id); + virtual void changeWeather (const std::string& region, unsigned int id); - int getCurrentWeather() const; + virtual int getCurrentWeather() const; - int getMasserPhase() const; + virtual int getMasserPhase() const; - int getSecundaPhase() const; + virtual int getSecundaPhase() const; - void setMoonColour (bool red); + virtual void setMoonColour (bool red); - float getTimeScaleFactor() const; + virtual float getTimeScaleFactor() const; - void changeToInteriorCell (const std::string& cellName, const ESM::Position& position); + virtual void changeToInteriorCell (const std::string& cellName, + const ESM::Position& position); ///< Move to interior cell. - void changeToExteriorCell (const ESM::Position& position); + virtual void changeToExteriorCell (const ESM::Position& position); ///< Move to exterior cell. - const ESM::Cell *getExterior (const std::string& cellName) const; + virtual const ESM::Cell *getExterior (const std::string& cellName) const; ///< Return a cell matching the given name or a 0-pointer, if there is no such cell. - void markCellAsUnchanged(); + virtual void markCellAsUnchanged(); - std::string getFacedHandle(); + virtual std::string getFacedHandle(); ///< Return handle of the object the player is looking at - void deleteObject (Ptr ptr); + virtual void deleteObject (const Ptr& ptr); - void moveObject (Ptr ptr, float x, float y, float z); + virtual void moveObject (const Ptr& ptr, float x, float y, float z); - void scaleObject (Ptr ptr, float scale); - - void rotateObject (Ptr ptr,float x,float y,float z,bool WorldAxis); - - void setObjectRotation (Ptr ptr,float x,float y,float z); - - void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false) const; + virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false) + const; ///< Convert cell numbers to position. - void positionToIndex (float x, float y, int &cellX, int &cellY) const; + virtual void positionToIndex (float x, float y, int &cellX, int &cellY) const; ///< Convert position to cell numbers - void doPhysics (const std::vector >& actors, + virtual void doPhysics (const std::vector >& actors, float duration); ///< Run physics simulation and modify \a world accordingly. - bool toggleCollisionMode(); + virtual bool toggleCollisionMode(); ///< Toggle collision mode for player. If disabled player object should ignore /// collisions and gravity. ///< \return Resulting mode - bool toggleRenderMode (RenderMode mode); + virtual bool toggleRenderMode (RenderMode mode); ///< Toggle a render mode. ///< \return Resulting mode - std::pair createRecord (const ESM::Potion& record); + virtual std::pair createRecord (const ESM::Potion& record); ///< Create a new recrod (of type potion) in the ESM store. /// \return ID, pointer to created record - std::pair createRecord (const ESM::Class& record); + virtual std::pair createRecord (const ESM::Class& record); ///< Create a new recrod (of type class) in the ESM store. /// \return ID, pointer to created record - const ESM::Cell *createRecord (const ESM::Cell& record); + virtual const ESM::Cell *createRecord (const ESM::Cell& record); ///< Create a new recrod (of type cell) in the ESM store. /// \return ID, pointer to created record - void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode, - int number = 1); + virtual void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, + int mode, int number = 1); ///< Run animation for a MW-reference. Calls to this function for references that are /// currently not in the rendered scene should be ignored. /// /// \param mode: 0 normal, 1 immediate start, 2 immediate loop /// \param number How offen the animation should be run - void skipAnimation (const MWWorld::Ptr& ptr); + virtual void skipAnimation (const MWWorld::Ptr& ptr); ///< 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. - void update (float duration); + virtual void update (float duration); - bool placeObject(MWWorld::Ptr object, float cursorX, float cursorY); + virtual bool placeObject (const Ptr& object, float cursorX, float cursorY); ///< place an object into the gameworld at the specified cursor position /// @param object /// @param cursor X (relative 0-1) /// @param cursor Y (relative 0-1) /// @return true if the object was placed, or false if it was rejected because the position is too far away - void dropObjectOnGround(MWWorld::Ptr object); + virtual void dropObjectOnGround (const Ptr& object); - bool canPlaceObject(float cursorX, float cursorY); + virtual bool canPlaceObject(float cursorX, float cursorY); ///< @return true if it is possible to place on object at specified cursor location - void processChangedSettings(const Settings::CategorySettingVector& settings); + virtual void processChangedSettings(const Settings::CategorySettingVector& settings); }; } diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 8a1875d0f..284ca3cce 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -35,7 +35,7 @@ add_component_dir (file_finder ) add_component_dir (esm_store - cell_store reclists store + reclists store ) add_component_dir (esm @@ -74,4 +74,3 @@ target_link_libraries(components ${Boost_LIBRARIES} ${OGRE_LIBRARIES}) # Make the variable accessible for other subdirectories set(COMPONENT_FILES ${COMPONENT_FILES} PARENT_SCOPE) - diff --git a/components/compiler/context.hpp b/components/compiler/context.hpp index 929119cf4..1b02613c5 100644 --- a/components/compiler/context.hpp +++ b/components/compiler/context.hpp @@ -10,33 +10,35 @@ namespace Compiler class Context { const Extensions *mExtensions; - + public: - + Context() : mExtensions (0) {} - + virtual ~Context() {} - + virtual bool canDeclareLocals() const = 0; ///< Is the compiler allowed to declare local variables? - + void setExtensions (const Extensions *extensions = 0) { mExtensions = extensions; } - + const Extensions *getExtensions() const { return mExtensions; } - + virtual char getGlobalType (const std::string& name) const = 0; ///< 'l: long, 's': short, 'f': float, ' ': does not exist. - + + virtual char getMemberType (const std::string& name, const std::string& id) const = 0; + ///< 'l: long, 's': short, 'f': float, ' ': does not exist. + virtual bool isId (const std::string& name) const = 0; ///< Does \a name match an ID, that can be referenced? }; } #endif - diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index 95480c023..52192625b 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -195,10 +195,31 @@ namespace Compiler return parseArguments (arguments, scanner, mCode); } + bool ExprParser::handleMemberAccess (const std::string& name) + { + mMemberOp = false; + + std::string name2 = toLower (name); + std::string id = toLower (mExplicit); + + char type = getContext().getMemberType (name2, id); + + if (type!=' ') + { + Generator::fetchMember (mCode, mLiterals, type, name2, id); + mNextOperand = false; + mExplicit.clear(); + mOperands.push_back (type=='f' ? 'f' : 'l'); + return true; + } + + return false; + } + ExprParser::ExprParser (ErrorHandler& errorHandler, Context& context, Locals& locals, Literals& literals, bool argument) : Parser (errorHandler, context), mLocals (locals), mLiterals (literals), - mNextOperand (true), mFirst (true), mArgument (argument) + mNextOperand (true), mFirst (true), mArgument (argument), mRefOp (false), mMemberOp (false) {} bool ExprParser::parseInt (int value, const TokenLoc& loc, Scanner& scanner) @@ -251,7 +272,12 @@ namespace Compiler Scanner& scanner) { if (!mExplicit.empty()) + { + if (mMemberOp && handleMemberAccess (name)) + return true; + return Parser::parseName (name, loc, scanner); + } mFirst = false; @@ -281,9 +307,9 @@ namespace Compiler return true; } - if (mExplicit.empty() && getContext().isId (name)) + if (mExplicit.empty() && getContext().isId (name2)) { - mExplicit = name; + mExplicit = name2; return true; } } @@ -497,6 +523,12 @@ namespace Compiler return true; } + if (!mMemberOp && code==Scanner::S_member) + { + mMemberOp = true; + return true; + } + return Parser::parseSpecial (code, loc, scanner); } @@ -609,6 +641,7 @@ namespace Compiler mFirst = true; mExplicit.clear(); mRefOp = false; + mMemberOp = false; Parser::reset(); } diff --git a/components/compiler/exprparser.hpp b/components/compiler/exprparser.hpp index 87945c628..8ce5409d2 100644 --- a/components/compiler/exprparser.hpp +++ b/components/compiler/exprparser.hpp @@ -26,6 +26,7 @@ namespace Compiler bool mArgument; std::string mExplicit; bool mRefOp; + bool mMemberOp; int getPriority (char op) const; @@ -53,6 +54,8 @@ namespace Compiler int parseArguments (const std::string& arguments, Scanner& scanner); + bool handleMemberAccess (const std::string& name); + public: ExprParser (ErrorHandler& errorHandler, Context& context, Locals& locals, diff --git a/components/compiler/generator.cpp b/components/compiler/generator.cpp index 26a80387b..9b02e4273 100644 --- a/components/compiler/generator.cpp +++ b/components/compiler/generator.cpp @@ -260,6 +260,36 @@ namespace code.push_back (Compiler::Generator::segment5 (44)); } + void opStoreMemberShort (Compiler::Generator::CodeContainer& code) + { + code.push_back (Compiler::Generator::segment5 (59)); + } + + void opStoreMemberLong (Compiler::Generator::CodeContainer& code) + { + code.push_back (Compiler::Generator::segment5 (60)); + } + + void opStoreMemberFloat (Compiler::Generator::CodeContainer& code) + { + code.push_back (Compiler::Generator::segment5 (61)); + } + + void opFetchMemberShort (Compiler::Generator::CodeContainer& code) + { + code.push_back (Compiler::Generator::segment5 (62)); + } + + void opFetchMemberLong (Compiler::Generator::CodeContainer& code) + { + code.push_back (Compiler::Generator::segment5 (63)); + } + + void opFetchMemberFloat (Compiler::Generator::CodeContainer& code) + { + code.push_back (Compiler::Generator::segment5 (64)); + } + void opRandom (Compiler::Generator::CodeContainer& code) { code.push_back (Compiler::Generator::segment5 (45)); @@ -644,7 +674,7 @@ namespace Compiler if (localType!=valueType) { - if (localType=='f' && valueType=='l') + if (localType=='f' && (valueType=='l' || valueType=='s')) { opIntToFloat (code); } @@ -707,6 +737,88 @@ namespace Compiler } } + void assignToMember (CodeContainer& code, Literals& literals, char localType, + const std::string& name, const std::string& id, const CodeContainer& value, char valueType) + { + int index = literals.addString (name); + + opPushInt (code, index); + + index = literals.addString (id); + + opPushInt (code, index); + + std::copy (value.begin(), value.end(), std::back_inserter (code)); + + if (localType!=valueType) + { + if (localType=='f' && (valueType=='l' || valueType=='s')) + { + opIntToFloat (code); + } + else if ((localType=='l' || localType=='s') && valueType=='f') + { + opFloatToInt (code); + } + } + + switch (localType) + { + case 'f': + + opStoreMemberFloat (code); + break; + + case 's': + + opStoreMemberShort (code); + break; + + case 'l': + + opStoreMemberLong (code); + break; + + default: + + assert (0); + } + } + + void fetchMember (CodeContainer& code, Literals& literals, char localType, + const std::string& name, const std::string& id) + { + int index = literals.addString (name); + + opPushInt (code, index); + + index = literals.addString (id); + + opPushInt (code, index); + + switch (localType) + { + case 'f': + + opFetchMemberFloat (code); + break; + + case 's': + + opFetchMemberShort (code); + break; + + case 'l': + + opFetchMemberLong (code); + break; + + default: + + assert (0); + } + } + void random (CodeContainer& code) { opRandom (code); diff --git a/components/compiler/generator.hpp b/components/compiler/generator.hpp index 89e198431..feab26c93 100644 --- a/components/compiler/generator.hpp +++ b/components/compiler/generator.hpp @@ -101,6 +101,12 @@ namespace Compiler void fetchGlobal (CodeContainer& code, Literals& literals, char localType, const std::string& name); + void assignToMember (CodeContainer& code, Literals& literals, char memberType, + const std::string& name, const std::string& id, const CodeContainer& value, char valueType); + + void fetchMember (CodeContainer& code, Literals& literals, char memberType, + const std::string& name, const std::string& id); + void random (CodeContainer& code); void scriptRunning (CodeContainer& code); diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 834cd27b4..a4cbc1ffe 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -18,7 +18,10 @@ namespace Compiler if (!mExplicit.empty()) { mExprParser.parseName (mExplicit, loc, scanner); - mExprParser.parseSpecial (Scanner::S_ref, loc, scanner); + if (mState==MemberState) + mExprParser.parseSpecial (Scanner::S_member, loc, scanner); + else + mExprParser.parseSpecial (Scanner::S_ref, loc, scanner); } scanner.scan (mExprParser); @@ -110,12 +113,13 @@ namespace Compiler if (mState==SetState) { std::string name2 = toLower (name); + mName = name2; // local variable? char type = mLocals.getType (name2); if (type!=' ') { - mName = name2; + mType = type; mState = SetLocalVarState; return true; } @@ -123,12 +127,27 @@ namespace Compiler type = getContext().getGlobalType (name2); if (type!=' ') { - mName = name2; mType = type; mState = SetGlobalVarState; return true; } + mState = SetPotentialMemberVarState; + return true; + } + + if (mState==SetMemberVarState) + { + mMemberName = toLower (name); + char type = getContext().getMemberType (mMemberName, mName); + + if (type!=' ') + { + mState = SetMemberVarState2; + mType = type; + return true; + } + getErrorHandler().error ("unknown variable", loc); SkipParser skip (getErrorHandler(), getContext()); scanner.scan (skip); @@ -256,6 +275,7 @@ namespace Compiler { scanner.putbackKeyword (keyword, loc); parseExpression (scanner, loc); + mState = EndState; return true; } @@ -269,6 +289,7 @@ namespace Compiler { scanner.putbackKeyword (keyword, loc); parseExpression (scanner, loc); + mState = EndState; return true; } } @@ -333,6 +354,19 @@ namespace Compiler mState = EndState; return true; } + else if (mState==SetMemberVarState2 && keyword==Scanner::K_to) + { + mExprParser.reset(); + scanner.scan (mExprParser); + + std::vector code; + char type = mExprParser.append (code); + + Generator::assignToMember (mCode, mLiterals, mType, mMemberName, mName, code, type); + + mState = EndState; + return true; + } if (mAllowExpression) { @@ -342,6 +376,7 @@ namespace Compiler { scanner.putbackKeyword (keyword, loc); parseExpression (scanner, loc); + mState = EndState; return true; } } @@ -366,6 +401,14 @@ namespace Compiler return true; } + if (code==Scanner::S_member && mState==PotentialExplicitState) + { + mState = MemberState; + parseExpression (scanner, loc); + mState = EndState; + return true; + } + if (code==Scanner::S_newline && mState==MessageButtonState) { Generator::message (mCode, mLiterals, mName, mButtons); @@ -378,11 +421,18 @@ namespace Compiler return true; } + if (code==Scanner::S_member && mState==SetPotentialMemberVarState) + { + mState = SetMemberVarState; + return true; + } + if (mAllowExpression && mState==BeginState && (code==Scanner::S_open || code==Scanner::S_minus)) { scanner.putbackSpecial (code, loc); parseExpression (scanner, loc); + mState = EndState; return true; } diff --git a/components/compiler/lineparser.hpp b/components/compiler/lineparser.hpp index 531b7762f..aa74cd232 100644 --- a/components/compiler/lineparser.hpp +++ b/components/compiler/lineparser.hpp @@ -21,10 +21,11 @@ namespace Compiler { BeginState, ShortState, LongState, FloatState, - SetState, SetLocalVarState, SetGlobalVarState, + SetState, SetLocalVarState, SetGlobalVarState, SetPotentialMemberVarState, + SetMemberVarState, SetMemberVarState2, MessageState, MessageCommaState, MessageButtonState, MessageButtonCommaState, EndState, - PotentialExplicitState, ExplicitState + PotentialExplicitState, ExplicitState, MemberState }; Locals& mLocals; @@ -32,6 +33,7 @@ namespace Compiler std::vector& mCode; State mState; std::string mName; + std::string mMemberName; int mButtons; std::string mExplicit; char mType; diff --git a/components/compiler/scanner.cpp b/components/compiler/scanner.cpp index d0397e8cf..962699dfa 100644 --- a/components/compiler/scanner.cpp +++ b/components/compiler/scanner.cpp @@ -360,6 +360,8 @@ namespace Compiler special = S_open; else if (c==')') special = S_close; + else if (c=='.') + special = S_member; else if (c=='=') { if (get (c)) diff --git a/components/compiler/scanner.hpp b/components/compiler/scanner.hpp index 53cb92ef2..19f4ca96a 100644 --- a/components/compiler/scanner.hpp +++ b/components/compiler/scanner.hpp @@ -65,7 +65,8 @@ namespace Compiler S_cmpEQ, S_cmpNE, S_cmpLT, S_cmpLE, S_cmpGT, S_cmpGE, S_plus, S_minus, S_mult, S_div, S_comma, - S_ref + S_ref, + S_member }; private: diff --git a/components/esm_store/cell_store.hpp b/components/esm_store/cell_store.hpp deleted file mode 100644 index 024412291..000000000 --- a/components/esm_store/cell_store.hpp +++ /dev/null @@ -1,287 +0,0 @@ -#ifndef _GAME_CELL_STORE_H -#define _GAME_CELL_STORE_H - -/* - Cell storage. - - Used to load, look up and store all references in a single cell. - - Depends on esm/loadcell.hpp (loading from ESM) and esm_store.hpp - (looking up references.) Neither of these modules depend on us. - */ - -#include "store.hpp" -#include "components/esm/records.hpp" - -#include -#include -#include -#include -#include -#include - -namespace ESMS -{ - using namespace ESM; - - /// A reference to one object (of any type) in a cell. - /// - /// Constructing this with a CellRef instance in the constructor means that - /// in practice (where D is RefData) the possibly mutable data is copied - /// across to mData. If later adding data (such as position) to CellRef - /// this would have to be manually copied across. - template - struct LiveCellRef - { - LiveCellRef(const CellRef& cref, const X* b = NULL) : base(b), ref(cref), - mData(ref) {} - - - LiveCellRef(const X* b = NULL) : base(b), mData(ref) {} - - // The object that this instance is based on. - const X* base; - - /* Information about this instance, such as 3D location and - rotation and individual type-dependent data. - */ - CellRef ref; - - /// runtime-data - D mData; - }; - - /// A list of cell references - template - struct CellRefList - { - typedef LiveCellRef LiveRef; - typedef std::list List; - List list; - - // Search for the given reference in the given reclist from - // ESMStore. Insert the reference into the list if a match is - // found. If not, throw an exception. - template - void find(CellRef &ref, const Y& recList) - { - const X* obj = recList.find(ref.refID); - if(obj == NULL) - throw std::runtime_error("Error resolving cell reference " + ref.refID); - - list.push_back(LiveRef(ref, obj)); - } - - LiveRef *find (const std::string& name) - { - for (typename std::list::iterator iter (list.begin()); iter!=list.end(); ++iter) - { - if (iter->ref.refID==name) - return &*iter; - } - - return 0; - } - }; - - /// A storage struct for one single cell reference. - template - class CellStore - { - public: - - enum State - { - State_Unloaded, State_Preloaded, State_Loaded - }; - - CellStore (const ESM::Cell *cell_) : cell (cell_), mState (State_Unloaded) - { - mWaterLevel = cell->water; - } - - const ESM::Cell *cell; - 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; - - void load (const ESMStore &store, ESMReader &esm) - { - if (mState!=State_Loaded) - { - if (mState==State_Preloaded) - mIds.clear(); - - std::cout << "loading cell " << cell->getDescription() << std::endl; - - loadRefs (store, esm); - - mState = State_Loaded; - } - } - - void preload (const ESMStore &store, ESMReader &esm) - { - if (mState==State_Unloaded) - { - listRefs (store, esm); - - mState = State_Preloaded; - } - } - - /// Call functor (ref) for each reference. functor must return a bool. Returning - /// false will abort the iteration. - /// \return Iteration completed? - template - 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); - } - - private: - - template - bool forEachImp (Functor& functor, List& list) - { - for (typename List::List::iterator iter (list.list.begin()); iter!=list.list.end(); - ++iter) - if (!functor (iter->ref, iter->mData)) - return false; - - return true; - } - - /// Run through references and store IDs - void listRefs(const ESMStore &store, ESMReader &esm) - { - assert (cell); - - if (cell->context.filename.empty()) - return; // this is a dynamically generated cell -> skipping. - - // Reopen the ESM reader and seek to the right position. - cell->restore (esm); - - CellRef ref; - - // Get each reference in turn - while (cell->getNextRef (esm, ref)) - { - std::string lowerCase; - - std::transform (ref.refID.begin(), ref.refID.end(), std::back_inserter (lowerCase), - (int(*)(int)) std::tolower); - - mIds.push_back (lowerCase); - } - - std::sort (mIds.begin(), mIds.end()); - } - - void loadRefs(const ESMStore &store, ESMReader &esm) - { - assert (cell); - - if (cell->context.filename.empty()) - return; // this is a dynamically generated cell -> skipping. - - // Reopen the ESM reader and seek to the right position. - cell->restore(esm); - - CellRef ref; - - // Get each reference in turn - while(cell->getNextRef(esm, ref)) - { - std::string lowerCase; - - std::transform (ref.refID.begin(), ref.refID.end(), std::back_inserter (lowerCase), - (int(*)(int)) std::tolower); - - int rec = store.find(ref.refID); - - ref.refID = lowerCase; - - /* We can optimize this further by storing the pointer to the - record itself in store.all, so that we don't need to look it - up again here. However, never optimize. There are infinite - opportunities to do that later. - */ - switch(rec) - { - case REC_ACTI: activators.find(ref, store.activators); break; - case REC_ALCH: potions.find(ref, store.potions); break; - case REC_APPA: appas.find(ref, store.appas); break; - case REC_ARMO: armors.find(ref, store.armors); break; - case REC_BOOK: books.find(ref, store.books); break; - case REC_CLOT: clothes.find(ref, store.clothes); break; - case REC_CONT: containers.find(ref, store.containers); break; - case REC_CREA: creatures.find(ref, store.creatures); break; - case REC_DOOR: doors.find(ref, store.doors); break; - case REC_INGR: ingreds.find(ref, store.ingreds); break; - case REC_LEVC: creatureLists.find(ref, store.creatureLists); break; - case REC_LEVI: itemLists.find(ref, store.itemLists); break; - case REC_LIGH: lights.find(ref, store.lights); break; - case REC_LOCK: lockpicks.find(ref, store.lockpicks); break; - case REC_MISC: miscItems.find(ref, store.miscItems); break; - case REC_NPC_: npcs.find(ref, store.npcs); break; - case REC_PROB: probes.find(ref, store.probes); break; - case REC_REPA: repairs.find(ref, store.repairs); break; - case REC_STAT: statics.find(ref, store.statics); break; - case REC_WEAP: weapons.find(ref, store.weapons); break; - - case 0: std::cout << "Cell reference " + ref.refID + " not found!\n"; break; - default: - std::cout << "WARNING: Ignoring reference '" << ref.refID << "' of unhandled type\n"; - } - } - } - - }; -} - -#endif diff --git a/components/interpreter/context.hpp b/components/interpreter/context.hpp index 973b22d35..4221da36e 100644 --- a/components/interpreter/context.hpp +++ b/components/interpreter/context.hpp @@ -65,6 +65,19 @@ namespace Interpreter virtual void enable (const std::string& id = "") = 0; virtual void disable (const std::string& id = "") = 0; + + virtual int getMemberShort (const std::string& id, const std::string& name) const = 0; + + virtual int getMemberLong (const std::string& id, const std::string& name) const = 0; + + virtual float getMemberFloat (const std::string& id, const std::string& name) const = 0; + + virtual void setMemberShort (const std::string& id, const std::string& name, int value) = 0; + + virtual void setMemberLong (const std::string& id, const std::string& name, int value) = 0; + + virtual void setMemberFloat (const std::string& id, const std::string& name, float value) + = 0; }; } diff --git a/components/interpreter/docs/vmformat.txt b/components/interpreter/docs/vmformat.txt index 3e513aa44..91e0c060e 100644 --- a/components/interpreter/docs/vmformat.txt +++ b/components/interpreter/docs/vmformat.txt @@ -121,5 +121,11 @@ op 58: report string literal index in stack[0]; additional arguments (if any) in stack[n]..stack[1]; n is determined according to the message string all arguments are removed from stack -opcodes 59-33554431 unused +op 59: store stack[0] in member short stack[2] of object with ID stack[1] +op 60: store stack[0] in member long stack[2] of object with ID stack[1] +op 61: store stack[0] in member float stack[2] of object with ID stack[1] +op 62: replace stack[0] with member short stack[1] of object with ID stack[0] +op 63: replace stack[0] with member short stack[1] of object with ID stack[0] +op 64: replace stack[0] with member short stack[1] of object with ID stack[0] +opcodes 65-33554431 unused opcodes 33554432-67108863 reserved for extensions diff --git a/components/interpreter/installopcodes.cpp b/components/interpreter/installopcodes.cpp index 556477af2..05f71f1cc 100644 --- a/components/interpreter/installopcodes.cpp +++ b/components/interpreter/installopcodes.cpp @@ -40,6 +40,12 @@ namespace Interpreter interpreter.installSegment5 (42, new OpFetchGlobalShort); interpreter.installSegment5 (43, new OpFetchGlobalLong); interpreter.installSegment5 (44, new OpFetchGlobalFloat); + interpreter.installSegment5 (59, new OpStoreMemberShort); + interpreter.installSegment5 (60, new OpStoreMemberLong); + interpreter.installSegment5 (61, new OpStoreMemberFloat); + interpreter.installSegment5 (62, new OpFetchMemberShort); + interpreter.installSegment5 (63, new OpFetchMemberLong); + interpreter.installSegment5 (64, new OpFetchMemberFloat); // math interpreter.installSegment5 (9, new OpAddInt); diff --git a/components/interpreter/localopcodes.hpp b/components/interpreter/localopcodes.hpp index ea62b7ad8..731c16276 100644 --- a/components/interpreter/localopcodes.hpp +++ b/components/interpreter/localopcodes.hpp @@ -6,11 +6,11 @@ #include "context.hpp" namespace Interpreter -{ +{ class OpStoreLocalShort : public Opcode0 { public: - + virtual void execute (Runtime& runtime) { Type_Integer data = runtime[0].mInteger; @@ -20,13 +20,13 @@ namespace Interpreter runtime.pop(); runtime.pop(); - } + } }; - + class OpStoreLocalLong : public Opcode0 { public: - + virtual void execute (Runtime& runtime) { Type_Integer data = runtime[0].mInteger; @@ -36,13 +36,13 @@ namespace Interpreter runtime.pop(); runtime.pop(); - } - }; - + } + }; + class OpStoreLocalFloat : public Opcode0 { public: - + virtual void execute (Runtime& runtime) { Type_Float data = runtime[0].mFloat; @@ -52,71 +52,71 @@ namespace Interpreter runtime.pop(); runtime.pop(); - } + } }; - + class OpFetchIntLiteral : public Opcode0 { public: - + virtual void execute (Runtime& runtime) { Type_Integer intValue = runtime.getIntegerLiteral (runtime[0].mInteger); runtime[0].mInteger = intValue; - } - }; - + } + }; + class OpFetchFloatLiteral : public Opcode0 { public: - + virtual void execute (Runtime& runtime) { Type_Float floatValue = runtime.getFloatLiteral (runtime[0].mInteger); runtime[0].mFloat = floatValue; - } - }; - + } + }; + class OpFetchLocalShort : public Opcode0 { public: - + virtual void execute (Runtime& runtime) { int index = runtime[0].mInteger; int value = runtime.getContext().getLocalShort (index); runtime[0].mInteger = value; - } - }; + } + }; class OpFetchLocalLong : public Opcode0 { public: - + virtual void execute (Runtime& runtime) { - int index = runtime[0].mInteger; + int index = runtime[0].mInteger; int value = runtime.getContext().getLocalLong (index); runtime[0].mInteger = value; - } - }; + } + }; class OpFetchLocalFloat : public Opcode0 { public: - + virtual void execute (Runtime& runtime) { int index = runtime[0].mInteger; float value = runtime.getContext().getLocalFloat (index); runtime[0].mFloat = value; - } - }; - + } + }; + class OpStoreGlobalShort : public Opcode0 { public: - + virtual void execute (Runtime& runtime) { Type_Integer data = runtime[0].mInteger; @@ -128,13 +128,13 @@ namespace Interpreter runtime.pop(); runtime.pop(); - } + } }; - + class OpStoreGlobalLong : public Opcode0 { public: - + virtual void execute (Runtime& runtime) { Type_Integer data = runtime[0].mInteger; @@ -146,13 +146,13 @@ namespace Interpreter runtime.pop(); runtime.pop(); - } - }; - + } + }; + class OpStoreGlobalFloat : public Opcode0 { public: - + virtual void execute (Runtime& runtime) { Type_Float data = runtime[0].mFloat; @@ -164,48 +164,158 @@ namespace Interpreter runtime.pop(); runtime.pop(); - } + } }; - + class OpFetchGlobalShort : public Opcode0 { public: - + virtual void execute (Runtime& runtime) { - int index = runtime[0].mInteger; + int index = runtime[0].mInteger; std::string name = runtime.getStringLiteral (index); Type_Integer value = runtime.getContext().getGlobalShort (name); runtime[0].mInteger = value; - } - }; + } + }; class OpFetchGlobalLong : public Opcode0 { public: - + virtual void execute (Runtime& runtime) { - int index = runtime[0].mInteger; + int index = runtime[0].mInteger; std::string name = runtime.getStringLiteral (index); Type_Integer value = runtime.getContext().getGlobalLong (name); runtime[0].mInteger = value; - } - }; + } + }; class OpFetchGlobalFloat : public Opcode0 { public: - + virtual void execute (Runtime& runtime) { int index = runtime[0].mInteger; std::string name = runtime.getStringLiteral (index); Type_Float value = runtime.getContext().getGlobalFloat (name); runtime[0].mFloat = value; - } - }; + } + }; + + class OpStoreMemberShort : public Opcode0 + { + public: + + virtual void execute (Runtime& runtime) + { + Type_Integer data = runtime[0].mInteger; + Type_Integer index = runtime[1].mInteger; + std::string id = runtime.getStringLiteral (index); + index = runtime[2].mInteger; + std::string variable = runtime.getStringLiteral (index); + + runtime.getContext().setMemberShort (id, variable, data); + + runtime.pop(); + runtime.pop(); + runtime.pop(); + } + }; + + class OpStoreMemberLong : public Opcode0 + { + public: + + virtual void execute (Runtime& runtime) + { + Type_Integer data = runtime[0].mInteger; + Type_Integer index = runtime[1].mInteger; + std::string id = runtime.getStringLiteral (index); + index = runtime[2].mInteger; + std::string variable = runtime.getStringLiteral (index); + + runtime.getContext().setMemberLong (id, variable, data); + + runtime.pop(); + runtime.pop(); + runtime.pop(); + } + }; + + class OpStoreMemberFloat : public Opcode0 + { + public: + + virtual void execute (Runtime& runtime) + { + Type_Float data = runtime[0].mFloat; + Type_Integer index = runtime[1].mInteger; + std::string id = runtime.getStringLiteral (index); + index = runtime[2].mInteger; + std::string variable = runtime.getStringLiteral (index); + + runtime.getContext().setMemberFloat (id, variable, data); + + runtime.pop(); + runtime.pop(); + runtime.pop(); + } + }; + + class OpFetchMemberShort : public Opcode0 + { + public: + + virtual void execute (Runtime& runtime) + { + Type_Integer index = runtime[0].mInteger; + std::string id = runtime.getStringLiteral (index); + index = runtime[1].mInteger; + std::string variable = runtime.getStringLiteral (index); + runtime.pop(); + + int value = runtime.getContext().getMemberShort (id, variable); + runtime[0].mInteger = value; + } + }; + + class OpFetchMemberLong : public Opcode0 + { + public: + + virtual void execute (Runtime& runtime) + { + Type_Integer index = runtime[0].mInteger; + std::string id = runtime.getStringLiteral (index); + index = runtime[1].mInteger; + std::string variable = runtime.getStringLiteral (index); + runtime.pop(); + + int value = runtime.getContext().getMemberLong (id, variable); + runtime[0].mInteger = value; + } + }; + + class OpFetchMemberFloat : public Opcode0 + { + public: + + virtual void execute (Runtime& runtime) + { + Type_Integer index = runtime[0].mInteger; + std::string id = runtime.getStringLiteral (index); + index = runtime[1].mInteger; + std::string variable = runtime.getStringLiteral (index); + runtime.pop(); + + float value = runtime.getContext().getMemberFloat (id, variable); + runtime[0].mFloat = value; + } + }; } #endif - diff --git a/components/nif/data.hpp b/components/nif/data.hpp index df9079758..10337d2c9 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -25,8 +25,9 @@ #define _NIF_DATA_H_ #include "controlled.hpp" -#include -#include + +#include +#include namespace Nif { @@ -466,7 +467,7 @@ public: std::vector > getAdditionalVertices(){ return additionalVertices; } - + void read(NIFFile *nif) { int morphCount = nif->getInt(); @@ -481,7 +482,7 @@ void read(NIFFile *nif) float z = nif->getFloat(); initialVertices.push_back(Ogre::Vector3(x, y, z)); } - + for(int i=1; igetInt(); @@ -543,8 +544,8 @@ class NiKeyframeData : public Record std::vector tbcscale; int stype; - - + + public: void clone(NiKeyframeData c) { @@ -559,11 +560,11 @@ public: translist1 = c.getTranslist1(); - translist2 = c.getTranslist2(); + translist2 = c.getTranslist2(); translist3 = c.getTranslist3(); transtime = c.gettTime(); - + bonename = c.getBonename(); @@ -611,7 +612,7 @@ public: Ogre::Quaternion quat = Ogre::Quaternion(Ogre::Real(w), Ogre::Real(x), Ogre::Real(y), Ogre::Real(z)); quats.push_back(quat); rottime.push_back(time); - //if(time == 0.0 || time > 355.5) + //if(time == 0.0 || time > 355.5) // std::cout <<"Time:" << time << "W:" << w <<"X:" << x << "Y:" << y << "Z:" << z << "\n"; } } @@ -632,7 +633,7 @@ public: quats.push_back(quat); rottime.push_back(time); tbc.push_back(vec); - //if(time == 0.0 || time > 355.5) + //if(time == 0.0 || time > 355.5) // std::cout <<"Time:" << time << "W:" << w <<"X:" << x << "Y:" << y << "Z:" << z << "\n"; } @@ -661,7 +662,7 @@ public: // Then translation count = nif->getInt(); - + if(count) { ttype = nif->getInt(); @@ -700,7 +701,7 @@ public: translist2.push_back(trans2); translist3.push_back(trans3); } - + //nif->getFloatLen(count*10); // trans1 + forward + backward } else if(ttype == 3){ @@ -729,12 +730,12 @@ public: { stype = nif->getInt(); - + for(int i = 0; i < count; i++){ - - + + //int size = 0; - if(stype >= 1 && stype < 4) + if(stype >= 1 && stype < 4) { float time = nif->getFloat(); float scale = nif->getFloat(); @@ -759,10 +760,10 @@ public: //size = 5; // 1 + tbc } - + } } - else + else stype = 0; } int getRtype(){ diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 669ef584f..d8a57d796 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -25,6 +25,14 @@ #include "ogre_nif_loader.hpp" +#include +#include +#include +#include +#include +#include +#include + #include #include @@ -230,7 +238,7 @@ void NIFLoader::createMaterial(const String &name, //tech->setSchemeName("blahblah"); Pass* pass = tech->createPass(); pass->setVertexProgram("Ogre/BasicVertexPrograms/AmbientOneTexture");*/ - + // This assigns the texture to this material. If the texture name is // a file name, and this file exists (in a resource directory), it @@ -478,7 +486,7 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std bind->setBinding(nextBuf++, vbuf); } - + // Vertex colors if (data->colors.length) { @@ -795,7 +803,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou std::list vertexBoneAssignments; Nif::NiTriShapeCopy copy = shape->clone(); - + if(!shape->controller.empty()) { Nif::Controller* cont = shape->controller.getPtr(); @@ -984,7 +992,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou } if(!mSkel.isNull() ){ int boneIndex; - + boneIndex = mSkel->getNumBones() - 1; for(int i = 0; i < numVerts; i++){ VertexBoneAssignment vba; @@ -1388,7 +1396,7 @@ void NIFLoader::loadResource(Resource *resource) vba.boneIndex = boneIndex; vba.vertexIndex = 0; vba.weight = 1; - + (*iter)->addBoneAssignment(vba); } diff --git a/components/nifogre/ogre_nif_loader.hpp b/components/nifogre/ogre_nif_loader.hpp index 794459e46..d73948fa8 100644 --- a/components/nifogre/ogre_nif_loader.hpp +++ b/components/nifogre/ogre_nif_loader.hpp @@ -26,12 +26,10 @@ #include #include -#include + +#include #include -#include -#include -#include -#include +#include #include #include "../nif/nif_file.hpp" @@ -45,7 +43,6 @@ #include #include // For warning messages -#include #include using namespace boost::algorithm; @@ -193,7 +190,7 @@ class NIFLoader : Ogre::ManualResourceLoader std::vector mS; std::vector needBoneAssignments; bool inTheSkeletonTree; - + }; diff --git a/components/settings/settings.cpp b/components/settings/settings.cpp index 9b941e253..dd89dde65 100644 --- a/components/settings/settings.cpp +++ b/components/settings/settings.cpp @@ -66,6 +66,8 @@ void Manager::saveUser(const std::string& file) } fout << it->first.second << " = " << it->second << '\n'; } + + fout.close(); } const std::string Manager::getString (const std::string& setting, const std::string& category) diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index dad4afb46..f41cdf54e 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -15,52 +15,52 @@ configure_file("${SDIR}/openmw_box.skin.xml" "${DDIR}/openmw_box.skin.xml" COPYO configure_file("${SDIR}/openmw_button.skin.xml" "${DDIR}/openmw_button.skin.xml" COPYONLY) configure_file("${SDIR}/openmw_list.skin.xml" "${DDIR}/openmw_list.skin.xml" COPYONLY) configure_file("${SDIR}/openmw_edit.skin.xml" "${DDIR}/openmw_edit.skin.xml" COPYONLY) -configure_file("${SDIR}/openmw_console_layout.xml" "${DDIR}/openmw_console_layout.xml" COPYONLY) +configure_file("${SDIR}/openmw_console.layout" "${DDIR}/openmw_console.layout" COPYONLY) configure_file("${SDIR}/openmw_console.skin.xml" "${DDIR}/openmw_console.skin.xml" COPYONLY) configure_file("${SDIR}/openmw.font.xml" "${DDIR}/openmw.font.xml" COPYONLY) configure_file("${SDIR}/openmw_hud_box.skin.xml" "${DDIR}/openmw_hud_box.skin.xml" COPYONLY) configure_file("${SDIR}/openmw_hud_energybar.skin.xml" "${DDIR}/openmw_hud_energybar.skin.xml" COPYONLY) -configure_file("${SDIR}/openmw_hud_layout.xml" "${DDIR}/openmw_hud_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_text_input_layout.xml" "${DDIR}/openmw_text_input_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_infobox_layout.xml" "${DDIR}/openmw_infobox_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_chargen_race_layout.xml" "${DDIR}/openmw_chargen_race_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_chargen_class_layout.xml" "${DDIR}/openmw_chargen_class_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_chargen_generate_class_result_layout.xml" "${DDIR}/openmw_chargen_generate_class_result_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_chargen_create_class_layout.xml" "${DDIR}/openmw_chargen_create_class_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_chargen_select_specialization_layout.xml" "${DDIR}/openmw_chargen_select_specialization_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_chargen_select_attribute_layout.xml" "${DDIR}/openmw_chargen_select_attribute_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_chargen_select_skill_layout.xml" "${DDIR}/openmw_chargen_select_skill_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_chargen_class_description_layout.xml" "${DDIR}/openmw_chargen_class_description_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_chargen_birth_layout.xml" "${DDIR}/openmw_chargen_birth_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_chargen_review_layout.xml" "${DDIR}/openmw_chargen_review_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_dialogue_window_layout.xml" "${DDIR}/openmw_dialogue_window_layout.xml" COPYONLY) +configure_file("${SDIR}/openmw_hud.layout" "${DDIR}/openmw_hud.layout" COPYONLY) +configure_file("${SDIR}/openmw_text_input.layout" "${DDIR}/openmw_text_input.layout" COPYONLY) +configure_file("${SDIR}/openmw_infobox.layout" "${DDIR}/openmw_infobox.layout" COPYONLY) +configure_file("${SDIR}/openmw_chargen_race.layout" "${DDIR}/openmw_chargen_race.layout" COPYONLY) +configure_file("${SDIR}/openmw_chargen_class.layout" "${DDIR}/openmw_chargen_class.layout" COPYONLY) +configure_file("${SDIR}/openmw_chargen_generate_class_result.layout" "${DDIR}/openmw_chargen_generate_class_result.layout" COPYONLY) +configure_file("${SDIR}/openmw_chargen_create_class.layout" "${DDIR}/openmw_chargen_create_class.layout" COPYONLY) +configure_file("${SDIR}/openmw_chargen_select_specialization.layout" "${DDIR}/openmw_chargen_select_specialization.layout" COPYONLY) +configure_file("${SDIR}/openmw_chargen_select_attribute.layout" "${DDIR}/openmw_chargen_select_attribute.layout" COPYONLY) +configure_file("${SDIR}/openmw_chargen_select_skill.layout" "${DDIR}/openmw_chargen_select_skill.layout" COPYONLY) +configure_file("${SDIR}/openmw_chargen_class_description.layout" "${DDIR}/openmw_chargen_class_description.layout" COPYONLY) +configure_file("${SDIR}/openmw_chargen_birth.layout" "${DDIR}/openmw_chargen_birth.layout" COPYONLY) +configure_file("${SDIR}/openmw_chargen_review.layout" "${DDIR}/openmw_chargen_review.layout" COPYONLY) +configure_file("${SDIR}/openmw_dialogue_window.layout" "${DDIR}/openmw_dialogue_window.layout" COPYONLY) configure_file("${SDIR}/openmw_dialogue_window_skin.xml" "${DDIR}/openmw_dialogue_window_skin.xml" COPYONLY) -configure_file("${SDIR}/openmw_inventory_window_layout.xml" "${DDIR}/openmw_inventory_window_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_container_window_layout.xml" "${DDIR}/openmw_container_window_layout.xml" COPYONLY) +configure_file("${SDIR}/openmw_inventory_window.layout" "${DDIR}/openmw_inventory_window.layout" COPYONLY) +configure_file("${SDIR}/openmw_container_window.layout" "${DDIR}/openmw_container_window.layout" COPYONLY) configure_file("${SDIR}/openmw_layers.xml" "${DDIR}/openmw_layers.xml" COPYONLY) -configure_file("${SDIR}/openmw_mainmenu_layout.xml" "${DDIR}/openmw_mainmenu_layout.xml" COPYONLY) +configure_file("${SDIR}/openmw_mainmenu.layout" "${DDIR}/openmw_mainmenu.layout" COPYONLY) configure_file("${SDIR}/openmw_mainmenu_skin.xml" "${DDIR}/openmw_mainmenu_skin.xml" COPYONLY) -configure_file("${SDIR}/openmw_map_window_layout.xml" "${DDIR}/openmw_map_window_layout.xml" COPYONLY) +configure_file("${SDIR}/openmw_map_window.layout" "${DDIR}/openmw_map_window.layout" COPYONLY) configure_file("${SDIR}/openmw_map_window_skin.xml" "${DDIR}/openmw_map_window_skin.xml" COPYONLY) configure_file("${SDIR}/openmw.pointer.xml" "${DDIR}/openmw.pointer.xml" COPYONLY) configure_file("${SDIR}/openmw_progress.skin.xml" "${DDIR}/openmw_progress.skin.xml" COPYONLY) -configure_file("${SDIR}/openmw_stats_window_layout.xml" "${DDIR}/openmw_stats_window_layout.xml" COPYONLY) +configure_file("${SDIR}/openmw_stats_window.layout" "${DDIR}/openmw_stats_window.layout" COPYONLY) configure_file("${SDIR}/openmw_text.skin.xml" "${DDIR}/openmw_text.skin.xml" COPYONLY) configure_file("${SDIR}/openmw_windows.skin.xml" "${DDIR}/openmw_windows.skin.xml" COPYONLY) -configure_file("${SDIR}/openmw_messagebox_layout.xml" "${DDIR}/openmw_messagebox_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_interactive_messagebox_layout.xml" "${DDIR}/openmw_interactive_messagebox_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_journal_layout.xml" "${DDIR}/openmw_journal_layout.xml" COPYONLY) +configure_file("${SDIR}/openmw_messagebox.layout" "${DDIR}/openmw_messagebox.layout" COPYONLY) +configure_file("${SDIR}/openmw_interactive_messagebox.layout" "${DDIR}/openmw_interactive_messagebox.layout" COPYONLY) +configure_file("${SDIR}/openmw_journal.layout" "${DDIR}/openmw_journal.layout" COPYONLY) configure_file("${SDIR}/openmw_journal_skin.xml" "${DDIR}/openmw_journal_skin.xml" COPYONLY) -configure_file("${SDIR}/openmw_tooltips.xml" "${DDIR}/openmw_tooltips.xml" COPYONLY) -configure_file("${SDIR}/openmw_scroll_layout.xml" "${DDIR}/openmw_scroll_layout.xml" COPYONLY) +configure_file("${SDIR}/openmw_tooltips.layout" "${DDIR}/openmw_tooltips.layout" COPYONLY) +configure_file("${SDIR}/openmw_scroll.layout" "${DDIR}/openmw_scroll.layout" COPYONLY) configure_file("${SDIR}/openmw_scroll_skin.xml" "${DDIR}/openmw_scroll_skin.xml" COPYONLY) -configure_file("${SDIR}/openmw_book_layout.xml" "${DDIR}/openmw_book_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_count_window_layout.xml" "${DDIR}/openmw_count_window_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_trade_window_layout.xml" "${DDIR}/openmw_trade_window_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_settings_window_layout.xml" "${DDIR}/openmw_settings_window_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_confirmation_dialog_layout.xml" "${DDIR}/openmw_confirmation_dialog_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_alchemy_window_layout.xml" "${DDIR}/openmw_alchemy_window_layout.xml" COPYONLY) -configure_file("${SDIR}/openmw_spell_window_layout.xml" "${DDIR}/openmw_spell_window_layout.xml" COPYONLY) +configure_file("${SDIR}/openmw_book.layout" "${DDIR}/openmw_book.layout" COPYONLY) +configure_file("${SDIR}/openmw_count_window.layout" "${DDIR}/openmw_count_window.layout" COPYONLY) +configure_file("${SDIR}/openmw_trade_window.layout" "${DDIR}/openmw_trade_window.layout" COPYONLY) +configure_file("${SDIR}/openmw_settings_window.layout" "${DDIR}/openmw_settings_window.layout" COPYONLY) +configure_file("${SDIR}/openmw_confirmation_dialog.layout" "${DDIR}/openmw_confirmation_dialog.layout" COPYONLY) +configure_file("${SDIR}/openmw_alchemy_window.layout" "${DDIR}/openmw_alchemy_window.layout" COPYONLY) +configure_file("${SDIR}/openmw_spell_window.layout" "${DDIR}/openmw_spell_window.layout" COPYONLY) configure_file("${SDIR}/atlas1.cfg" "${DDIR}/atlas1.cfg" COPYONLY) configure_file("${SDIR}/smallbars.png" "${DDIR}/smallbars.png" COPYONLY) configure_file("${SDIR}/EBGaramond-Regular.ttf" "${DDIR}/EBGaramond-Regular.ttf" COPYONLY) diff --git a/files/mygui/openmw_alchemy_window_layout.xml b/files/mygui/openmw_alchemy_window.layout similarity index 100% rename from files/mygui/openmw_alchemy_window_layout.xml rename to files/mygui/openmw_alchemy_window.layout diff --git a/files/mygui/openmw_book_layout.xml b/files/mygui/openmw_book.layout similarity index 100% rename from files/mygui/openmw_book_layout.xml rename to files/mygui/openmw_book.layout diff --git a/files/mygui/openmw_chargen_birth_layout.xml b/files/mygui/openmw_chargen_birth.layout similarity index 100% rename from files/mygui/openmw_chargen_birth_layout.xml rename to files/mygui/openmw_chargen_birth.layout diff --git a/files/mygui/openmw_chargen_class_layout.xml b/files/mygui/openmw_chargen_class.layout similarity index 100% rename from files/mygui/openmw_chargen_class_layout.xml rename to files/mygui/openmw_chargen_class.layout diff --git a/files/mygui/openmw_chargen_class_description_layout.xml b/files/mygui/openmw_chargen_class_description.layout similarity index 100% rename from files/mygui/openmw_chargen_class_description_layout.xml rename to files/mygui/openmw_chargen_class_description.layout diff --git a/files/mygui/openmw_chargen_create_class_layout.xml b/files/mygui/openmw_chargen_create_class.layout similarity index 100% rename from files/mygui/openmw_chargen_create_class_layout.xml rename to files/mygui/openmw_chargen_create_class.layout diff --git a/files/mygui/openmw_chargen_generate_class_result_layout.xml b/files/mygui/openmw_chargen_generate_class_result.layout similarity index 100% rename from files/mygui/openmw_chargen_generate_class_result_layout.xml rename to files/mygui/openmw_chargen_generate_class_result.layout diff --git a/files/mygui/openmw_chargen_race_layout.xml b/files/mygui/openmw_chargen_race.layout similarity index 100% rename from files/mygui/openmw_chargen_race_layout.xml rename to files/mygui/openmw_chargen_race.layout diff --git a/files/mygui/openmw_chargen_review_layout.xml b/files/mygui/openmw_chargen_review.layout similarity index 100% rename from files/mygui/openmw_chargen_review_layout.xml rename to files/mygui/openmw_chargen_review.layout diff --git a/files/mygui/openmw_chargen_select_attribute_layout.xml b/files/mygui/openmw_chargen_select_attribute.layout similarity index 100% rename from files/mygui/openmw_chargen_select_attribute_layout.xml rename to files/mygui/openmw_chargen_select_attribute.layout diff --git a/files/mygui/openmw_chargen_select_skill_layout.xml b/files/mygui/openmw_chargen_select_skill.layout similarity index 100% rename from files/mygui/openmw_chargen_select_skill_layout.xml rename to files/mygui/openmw_chargen_select_skill.layout diff --git a/files/mygui/openmw_chargen_select_specialization_layout.xml b/files/mygui/openmw_chargen_select_specialization.layout similarity index 100% rename from files/mygui/openmw_chargen_select_specialization_layout.xml rename to files/mygui/openmw_chargen_select_specialization.layout diff --git a/files/mygui/openmw_confirmation_dialog_layout.xml b/files/mygui/openmw_confirmation_dialog.layout similarity index 100% rename from files/mygui/openmw_confirmation_dialog_layout.xml rename to files/mygui/openmw_confirmation_dialog.layout diff --git a/files/mygui/openmw_console_layout.xml b/files/mygui/openmw_console.layout similarity index 100% rename from files/mygui/openmw_console_layout.xml rename to files/mygui/openmw_console.layout diff --git a/files/mygui/openmw_container_window_layout.xml b/files/mygui/openmw_container_window.layout similarity index 100% rename from files/mygui/openmw_container_window_layout.xml rename to files/mygui/openmw_container_window.layout diff --git a/files/mygui/openmw_count_window_layout.xml b/files/mygui/openmw_count_window.layout similarity index 100% rename from files/mygui/openmw_count_window_layout.xml rename to files/mygui/openmw_count_window.layout diff --git a/files/mygui/openmw_dialogue_window_layout.xml b/files/mygui/openmw_dialogue_window.layout similarity index 100% rename from files/mygui/openmw_dialogue_window_layout.xml rename to files/mygui/openmw_dialogue_window.layout diff --git a/files/mygui/openmw_hud_layout.xml b/files/mygui/openmw_hud.layout similarity index 100% rename from files/mygui/openmw_hud_layout.xml rename to files/mygui/openmw_hud.layout diff --git a/files/mygui/openmw_infobox_layout.xml b/files/mygui/openmw_infobox.layout similarity index 100% rename from files/mygui/openmw_infobox_layout.xml rename to files/mygui/openmw_infobox.layout diff --git a/files/mygui/openmw_interactive_messagebox_layout.xml b/files/mygui/openmw_interactive_messagebox.layout similarity index 100% rename from files/mygui/openmw_interactive_messagebox_layout.xml rename to files/mygui/openmw_interactive_messagebox.layout diff --git a/files/mygui/openmw_inventory_window_layout.xml b/files/mygui/openmw_inventory_window.layout similarity index 100% rename from files/mygui/openmw_inventory_window_layout.xml rename to files/mygui/openmw_inventory_window.layout diff --git a/files/mygui/openmw_journal_layout.xml b/files/mygui/openmw_journal.layout similarity index 100% rename from files/mygui/openmw_journal_layout.xml rename to files/mygui/openmw_journal.layout diff --git a/files/mygui/openmw_mainmenu_layout.xml b/files/mygui/openmw_mainmenu.layout similarity index 100% rename from files/mygui/openmw_mainmenu_layout.xml rename to files/mygui/openmw_mainmenu.layout diff --git a/files/mygui/openmw_map_window_layout.xml b/files/mygui/openmw_map_window.layout similarity index 100% rename from files/mygui/openmw_map_window_layout.xml rename to files/mygui/openmw_map_window.layout diff --git a/files/mygui/openmw_messagebox_layout.xml b/files/mygui/openmw_messagebox.layout similarity index 100% rename from files/mygui/openmw_messagebox_layout.xml rename to files/mygui/openmw_messagebox.layout diff --git a/files/mygui/openmw_scroll_layout.xml b/files/mygui/openmw_scroll.layout similarity index 100% rename from files/mygui/openmw_scroll_layout.xml rename to files/mygui/openmw_scroll.layout diff --git a/files/mygui/openmw_settings_window_layout.xml b/files/mygui/openmw_settings_window.layout similarity index 100% rename from files/mygui/openmw_settings_window_layout.xml rename to files/mygui/openmw_settings_window.layout diff --git a/files/mygui/openmw_spell_window_layout.xml b/files/mygui/openmw_spell_window.layout similarity index 100% rename from files/mygui/openmw_spell_window_layout.xml rename to files/mygui/openmw_spell_window.layout diff --git a/files/mygui/openmw_stats_window_layout.xml b/files/mygui/openmw_stats_window.layout similarity index 100% rename from files/mygui/openmw_stats_window_layout.xml rename to files/mygui/openmw_stats_window.layout diff --git a/files/mygui/openmw_text_input_layout.xml b/files/mygui/openmw_text_input.layout similarity index 100% rename from files/mygui/openmw_text_input_layout.xml rename to files/mygui/openmw_text_input.layout diff --git a/files/mygui/openmw_tooltips.xml b/files/mygui/openmw_tooltips.layout similarity index 100% rename from files/mygui/openmw_tooltips.xml rename to files/mygui/openmw_tooltips.layout diff --git a/files/mygui/openmw_trade_window_layout.xml b/files/mygui/openmw_trade_window.layout similarity index 100% rename from files/mygui/openmw_trade_window_layout.xml rename to files/mygui/openmw_trade_window.layout diff --git a/files/water/underwater.cg b/files/water/underwater.cg index b853dd535..829d34347 100644 --- a/files/water/underwater.cg +++ b/files/water/underwater.cg @@ -28,14 +28,15 @@ float4 main_fp_nomrt (float2 iTexCoord : TEXCOORD0, float3 noiseCoord : TEXCOORD1, uniform sampler2D RT : register(s0), uniform sampler2D NormalMap : register(s1), - uniform sampler2D CausticMap : register(s2), - uniform float4 tintColour) : COLOR + uniform sampler2D CausticMap : register(s2)) : COLOR { float4 normal = tex2D(NormalMap, noiseCoord) * 2 - 1; - return tex2D(RT, iTexCoord + normal.xy * 0.015) + - (tex2D(CausticMap, noiseCoord) / 5) + - tintColour ; + float4 col = tex2D(RT, iTexCoord + normal.xy * 0.015) + + (tex2D(CausticMap, noiseCoord) / 5); + col.xyz = lerp(col.xyz, float3(0.15, 0.40, 0.40), 0.4); + return col; + } @@ -45,8 +46,7 @@ float4 main_fp (float2 iTexCoord : TEXCOORD0, uniform sampler2D RT : register(s0), uniform sampler2D NormalMap : register(s1), uniform sampler2D CausticMap : register(s2), - uniform sampler2D DepthMap : register(s3), - uniform float4 tintColour) : COLOR + uniform sampler2D DepthMap : register(s3)) : COLOR { float4 normal = tex2D(NormalMap, noiseCoord) * 2 - 1; @@ -54,8 +54,8 @@ float4 main_fp (float2 iTexCoord : TEXCOORD0, depth = saturate(depth / 2000.f); float4 color = tex2D(RT, iTexCoord + normal.xy * 0.015) + - (tex2D(CausticMap, noiseCoord) / 5) + - tintColour; + (tex2D(CausticMap, noiseCoord) / 5); + color.xyz = lerp(color.xyz, float3(0.15, 0.40, 0.40), 0.4); - return lerp(color, float4(0, 0.65, 0.65, 1), depth); + return lerp(color, float4(0.15, 0.40, 0.40, 1), depth); } diff --git a/files/water/water.cg b/files/water/water.cg index bf6d04c5c..ad0ff57f7 100644 --- a/files/water/water.cg +++ b/files/water/water.cg @@ -112,8 +112,8 @@ void main_fp oColor.xyz = lerp(refraction.xyz, reflection.xyz, opacity); - oColor.xyz += isUnderwater * float3(0, 0.35, 0.35); // underwater tint color - oColor.xyz = lerp(oColor.xyz, float3(0, 0.65, 0.65), saturate(isUnderwater * (iDepth / 2000.f))); // underwater fog + oColor.xyz = lerp(oColor.xyz, float3(0.15, 0.40, 0.40), isUnderwater*0.6); // underwater tint color + oColor.xyz = lerp(oColor.xyz, float3(0.15, 0.40, 0.40), saturate(isUnderwater * (iDepth / 2000.f))); // underwater fog // add fog //float fogValue = saturate((iDepth - fogParams.y) * fogParams.w); diff --git a/files/water/water.material b/files/water/water.material index a2a6b3e2d..d1f7fcf49 100644 --- a/files/water/water.material +++ b/files/water/water.material @@ -151,7 +151,6 @@ material Water/CompositorNoMRT fragment_program_ref UnderwaterEffectFP_NoMRT { - param_named tintColour float4 0 0.35 0.35 1 } texture_unit RT @@ -194,7 +193,6 @@ material Water/Compositor fragment_program_ref UnderwaterEffectFP { - param_named tintColour float4 0 0.35 0.35 1 param_named_auto far far_clip_distance } diff --git a/libs/openengine/bullet/BtOgre.cpp b/libs/openengine/bullet/BtOgre.cpp index 618739083..f50465159 100644 --- a/libs/openengine/bullet/BtOgre.cpp +++ b/libs/openengine/bullet/BtOgre.cpp @@ -17,6 +17,10 @@ #include "BtOgreGP.h" #include "BtOgreExtras.h" +#include +#include +#include + using namespace Ogre; namespace BtOgre { diff --git a/libs/openengine/bullet/BtOgreGP.h b/libs/openengine/bullet/BtOgreGP.h index f0534de4b..4ce2f181e 100644 --- a/libs/openengine/bullet/BtOgreGP.h +++ b/libs/openengine/bullet/BtOgreGP.h @@ -19,7 +19,10 @@ #include "btBulletDynamicsCommon.h" #include "BtOgreExtras.h" -#include "Ogre.h" + +#include +#include +#include namespace BtOgre { diff --git a/libs/openengine/bullet/CMotionState.cpp b/libs/openengine/bullet/CMotionState.cpp index d7746cbc5..dc28d9e5f 100644 --- a/libs/openengine/bullet/CMotionState.cpp +++ b/libs/openengine/bullet/CMotionState.cpp @@ -4,7 +4,6 @@ #include #include #include -//#include namespace OEngine { namespace Physic diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index 52e94addc..d07472025 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -3,7 +3,6 @@ #include #include #include -//#include #include "CMotionState.h" #include "OgreRoot.h" #include "btKinematicCharacterController.h" @@ -222,6 +221,14 @@ namespace Physic PhysicEngine::~PhysicEngine() { + HeightFieldContainer::iterator hf_it = mHeightFieldMap.begin(); + for (; hf_it != mHeightFieldMap.end(); ++hf_it) + { + dynamicsWorld->removeRigidBody(hf_it->second.mBody); + delete hf_it->second.mShape; + delete hf_it->second.mBody; + } + RigidBodyContainer::iterator rb_it = RigidBodyMap.begin(); for (; rb_it != RigidBodyMap.end(); ++rb_it) { @@ -278,7 +285,7 @@ namespace Physic minh = h; maxh = h; } - + if (h>maxh) maxh = h; if (hremoveRigidBody(hf.mBody); delete hf.mShape; delete hf.mBody; + + mHeightFieldMap.erase(name); } RigidBody* PhysicEngine::createRigidBody(std::string mesh,std::string name,float scale) @@ -501,7 +510,7 @@ namespace Physic dynamicsWorld->rayTest(from, to, resultCallback1); if (resultCallback1.hasHit()) { - name = static_cast(*resultCallback1.m_collisionObject).mName; + name = static_cast(*resultCallback1.m_collisionObject).mName; d1 = resultCallback1.m_closestHitFraction; d = d1; } @@ -515,7 +524,7 @@ namespace Physic d2 = resultCallback1.m_closestHitFraction; if(d2<=d1) { - name = static_cast(*resultCallback2.m_collisionObject).mName; + name = static_cast(*resultCallback2.m_collisionObject).mName; d = d2; } } @@ -528,25 +537,25 @@ namespace Physic MyRayResultCallback resultCallback1; resultCallback1.m_collisionFilterMask = COL_WORLD|COL_RAYCASTING; dynamicsWorld->rayTest(from, to, resultCallback1); - std::vector< std::pair > results = resultCallback1.results; + std::vector< std::pair > results = resultCallback1.results; MyRayResultCallback resultCallback2; resultCallback2.m_collisionFilterMask = COL_ACTOR_INTERNAL|COL_ACTOR_EXTERNAL; dynamicsWorld->rayTest(from, to, resultCallback2); - std::vector< std::pair > actorResults = resultCallback2.results; + std::vector< std::pair > actorResults = resultCallback2.results; std::vector< std::pair > results2; - for (std::vector< std::pair >::iterator it=results.begin(); + for (std::vector< std::pair >::iterator it=results.begin(); it != results.end(); ++it) { - results2.push_back( std::make_pair( (*it).first, static_cast(*(*it).second).mName ) ); + results2.push_back( std::make_pair( (*it).first, static_cast(*(*it).second).mName ) ); } - for (std::vector< std::pair >::iterator it=actorResults.begin(); + for (std::vector< std::pair >::iterator it=actorResults.begin(); it != actorResults.end(); ++it) { - results2.push_back( std::make_pair( (*it).first, static_cast(*(*it).second).mName ) ); + results2.push_back( std::make_pair( (*it).first, static_cast(*(*it).second).mName ) ); } std::sort(results2.begin(), results2.end(), MyRayResultCallback::cmp); diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index 811572320..e327f24e1 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -278,7 +278,7 @@ namespace Physic return false; } - std::vector < std::pair > results; + std::vector < std::pair > results; }; }} diff --git a/libs/openengine/bullet/pmove.h b/libs/openengine/bullet/pmove.h index ea27f03f2..dfa84c4ee 100644 --- a/libs/openengine/bullet/pmove.h +++ b/libs/openengine/bullet/pmove.h @@ -6,12 +6,12 @@ which was released under the GNU GPL (v2) in 2005. Quake 3 Arena is copyright (C) 1999-2005 Id Software, Inc. */ -#include #include #include #include "trace.h" #include "physic.hpp" +#include //#include "GameMath.h" //#include "GameTime.h" @@ -154,7 +154,7 @@ struct playerMove KEYUP }; - playercmd() : forwardmove(0), rightmove(0), upmove(0), serverTime(50), ducking(false), + playercmd() : forwardmove(0), rightmove(0), upmove(0), serverTime(50), ducking(false), activating(false), lastActivatingState(false), procActivating(NO_CHANGE), dropping(false), lastDroppingState(false), procDropping(NO_CHANGE) { diff --git a/libs/openengine/bullet/trace.h b/libs/openengine/bullet/trace.h index d446b6854..076baf56e 100644 --- a/libs/openengine/bullet/trace.h +++ b/libs/openengine/bullet/trace.h @@ -5,12 +5,11 @@ #include #include #include -//#include #include #include - + enum traceWorldType { collisionWorldTrace = 1, @@ -33,7 +32,7 @@ struct NewPhysTraceResults float fraction; bool startSolid; //const Object* hitObj; -}; +}; struct traceResults { Ogre::Vector3 endpos; diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index 7c0f88bd7..275b7385a 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -114,7 +114,7 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings& // create the semi-transparent black background texture used by the GUI. // has to be created in code with TU_DYNAMIC_WRITE_ONLY_DISCARDABLE param // so that it can be modified at runtime. - mTransparentBGTexture = Ogre::TextureManager::getSingleton().createManual( + Ogre::TextureManager::getSingleton().createManual( "transparent.png", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, diff --git a/libs/openengine/ogre/renderer.hpp b/libs/openengine/ogre/renderer.hpp index f1520a3db..c7c30c8d4 100644 --- a/libs/openengine/ogre/renderer.hpp +++ b/libs/openengine/ogre/renderer.hpp @@ -74,8 +74,6 @@ namespace OEngine Fader* mFader; bool logging; - Ogre::TexturePtr mTransparentBGTexture; - public: OgreRenderer() : mRoot(NULL) diff --git a/readme.txt b/readme.txt index 513474dd6..aa981dba3 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.15.0 +Version: 0.16.0 License: GPL (see GPL3.txt for more information) Website: http://www.openmw.org @@ -110,6 +110,7 @@ Nikolay “corristo” Kasyanov Pieter “pvdk” van der Kloet Roman "Kromgart" Melnik Sebastian “swick” Wick +Sylvain "Garvek" T. Retired Developers: Ardekantur @@ -132,6 +133,33 @@ Thanks to Kevin Ryan for kindly providing us with the icon used for the Data Fil CHANGELOG +0.16.0 + +Bug #250: OpenMW launcher erratic behaviour +Bug #270: Crash because of underwater effect on OS X +Bug #277: Auto-equipping in some cells not working +Bug #294: Container GUI ignores disabled inventory menu +Bug #297: Stats review dialog shows all skills and attribute values as 0 +Bug #298: MechanicsManager::buildPlayer does not remove previous bonuses +Bug #299: Crash in World::disable +Bug #306: Non-existent ~/.config/openmw "crash" the launcher. +Bug #307: False "Data Files" location make the launcher "crash" +Feature #81: Spell Window +Feature #85: Alchemy Window +Feature #181: Support for x.y script syntax +Feature #242: Weapon and Spell icons +Feature #254: Ingame settings window +Feature #293: Allow "stacking" game modes +Feature #295: Class creation dialog tooltips +Feature #296: Clicking on the HUD elements should show/hide the respective window +Feature #301: Direction after using a Teleport Door +Feature #303: Allow object selection in the console +Feature #305: Allow the use of = as a synonym for == +Feature #312: Compensation for slow object access in poorly written Morrowind.esm scripts +Task #176: Restructure enabling/disabling of MW-references +Task #283: Integrate ogre.cfg file in settings file +Task #290: Auto-Close MW-reference related GUI windows + 0.15.0 Bug #5: Physics reimplementation (fixes various issues)