());
+ } else
+ {
+ mBrushTextureLabel = "No selected texture or invalid texture";
+ mSelectedBrush->setText(QString::fromStdString(mBrushTextureLabel));
+ }
+
+ emit passBrushShape(mBrushShape); // update icon
+}
+
+void CSVWidget::TextureBrushWindow::setBrushSize(int brushSize)
+{
+ mBrushSize = brushSize;
+ emit passBrushSize(mBrushSize);
+}
+
+void CSVWidget::TextureBrushWindow::setBrushShape()
+{
+ if(mButtonPoint->isChecked()) mBrushShape = 0;
+ if(mButtonSquare->isChecked()) mBrushShape = 1;
+ if(mButtonCircle->isChecked()) mBrushShape = 2;
+ if(mButtonCustom->isChecked()) mBrushShape = 3;
+ emit passBrushShape(mBrushShape);
+}
+
+void CSVWidget::SceneToolTextureBrush::adjustToolTips()
+{
+}
+
+CSVWidget::SceneToolTextureBrush::SceneToolTextureBrush (SceneToolbar *parent, const QString& toolTip, CSMDoc::Document& document)
+: SceneTool (parent, Type_TopAction),
+ mToolTip (toolTip),
+ mDocument (document),
+ mTextureBrushWindow(new TextureBrushWindow(document, this))
+{
+ mBrushHistory.resize(1);
+ mBrushHistory[0] = "L0#0";
+
+ setAcceptDrops(true);
+ connect(mTextureBrushWindow, SIGNAL(passBrushShape(int)), this, SLOT(setButtonIcon(int)));
+ setButtonIcon(mTextureBrushWindow->mBrushShape);
+
+ mPanel = new QFrame (this, Qt::Popup);
+
+ QHBoxLayout *layout = new QHBoxLayout (mPanel);
+
+ layout->setContentsMargins (QMargins (0, 0, 0, 0));
+
+ mTable = new QTableWidget (0, 2, this);
+
+ mTable->setShowGrid (true);
+ mTable->verticalHeader()->hide();
+ mTable->horizontalHeader()->hide();
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+ mTable->horizontalHeader()->setSectionResizeMode (0, QHeaderView::Stretch);
+ mTable->horizontalHeader()->setSectionResizeMode (1, QHeaderView::Stretch);
+#else
+ mTable->horizontalHeader()->setResizeMode (0, QHeaderView::Stretch);
+ mTable->horizontalHeader()->setResizeMode (1, QHeaderView::Stretch);
+#endif
+ mTable->setSelectionMode (QAbstractItemView::NoSelection);
+
+ layout->addWidget (mTable);
+
+ connect (mTable, SIGNAL (clicked (const QModelIndex&)),
+ this, SLOT (clicked (const QModelIndex&)));
+
+}
+
+void CSVWidget::SceneToolTextureBrush::setButtonIcon (int brushShape)
+{
+ QString tooltip = "Change brush settings Currently selected: ";
+
+ switch (brushShape)
+ {
+ case 0:
+
+ setIcon (QIcon (QPixmap (":scenetoolbar/brush-point")));
+ tooltip += mTextureBrushWindow->toolTipPoint;
+ break;
+
+ case 1:
+
+ setIcon (QIcon (QPixmap (":scenetoolbar/brush-square")));
+ tooltip += mTextureBrushWindow->toolTipSquare;
+ break;
+
+ case 2:
+
+ setIcon (QIcon (QPixmap (":scenetoolbar/brush-circle")));
+ tooltip += mTextureBrushWindow->toolTipCircle;
+ break;
+
+ case 3:
+
+ setIcon (QIcon (QPixmap (":scenetoolbar/brush-custom")));
+ tooltip += mTextureBrushWindow->toolTipCustom;
+ break;
+ }
+
+ tooltip += "
(right click to access of previously used brush settings)";
+
+
+ CSMWorld::IdCollection& landtexturesCollection = mDocument.getData().getLandTextures();
+
+ int landTextureFilename = landtexturesCollection.findColumnIndex(CSMWorld::Columns::ColumnId_Texture);
+ int index = landtexturesCollection.searchId(mTextureBrushWindow->mBrushTexture);
+
+ if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted())
+ {
+ tooltip += "Selected texture: " + QString::fromStdString(mTextureBrushWindow->mBrushTexture) + " ";
+
+ tooltip += landtexturesCollection.getData(index, landTextureFilename).value();
+ } else
+ {
+ tooltip += "No selected texture or invalid texture";
+ }
+
+ tooltip += "
(drop texture here to change)";
+ setToolTip (tooltip);
+}
+
+void CSVWidget::SceneToolTextureBrush::showPanel (const QPoint& position)
+{
+ updatePanel();
+ mPanel->move (position);
+ mPanel->show();
+}
+
+void CSVWidget::SceneToolTextureBrush::updatePanel()
+{
+ mTable->setRowCount (mBrushHistory.size());
+
+ for (int i = mBrushHistory.size()-1; i >= 0; --i)
+ {
+ CSMWorld::IdCollection& landtexturesCollection = mDocument.getData().getLandTextures();
+ int landTextureFilename = landtexturesCollection.findColumnIndex(CSMWorld::Columns::ColumnId_Texture);
+ int index = landtexturesCollection.searchId(mBrushHistory[i]);
+
+ if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted())
+ {
+ mTable->setItem (i, 1, new QTableWidgetItem (landtexturesCollection.getData(index, landTextureFilename).value()));
+ mTable->setItem (i, 0, new QTableWidgetItem (QString::fromStdString(mBrushHistory[i])));
+ } else
+ {
+ mTable->setItem (i, 1, new QTableWidgetItem ("Invalid/deleted texture"));
+ mTable->setItem (i, 0, new QTableWidgetItem (QString::fromStdString(mBrushHistory[i])));
+ }
+ }
+}
+
+void CSVWidget::SceneToolTextureBrush::updateBrushHistory (const std::string& brushTexture)
+{
+ mBrushHistory.insert(mBrushHistory.begin(), brushTexture);
+ if(mBrushHistory.size() > 5) mBrushHistory.pop_back();
+}
+
+void CSVWidget::SceneToolTextureBrush::clicked (const QModelIndex& index)
+{
+ if (index.column()==0 || index.column()==1)
+ {
+ std::string brushTexture = mBrushHistory[index.row()];
+ std::swap(mBrushHistory[index.row()], mBrushHistory[0]);
+ mTextureBrushWindow->setBrushTexture(brushTexture);
+ emit passTextureId(brushTexture);
+ updatePanel();
+ mPanel->hide();
+ }
+}
+
+void CSVWidget::SceneToolTextureBrush::activate ()
+{
+ QPoint position = QCursor::pos();
+ mTextureBrushWindow->mSizeSliders->mBrushSizeSlider->setRange(1, CSMPrefs::get()["3D Scene Editing"]["texturebrush-maximumsize"].toInt());
+ mTextureBrushWindow->mSizeSliders->mBrushSizeSpinBox->setRange(1, CSMPrefs::get()["3D Scene Editing"]["texturebrush-maximumsize"].toInt());
+ mTextureBrushWindow->move (position);
+ mTextureBrushWindow->show();
+}
+
+void CSVWidget::SceneToolTextureBrush::dragEnterEvent (QDragEnterEvent *event)
+{
+ emit passEvent(event);
+ event->accept();
+}
+void CSVWidget::SceneToolTextureBrush::dropEvent (QDropEvent *event)
+{
+ emit passEvent(event);
+ event->accept();
+}
diff --git a/apps/opencs/view/widget/scenetooltexturebrush.hpp b/apps/opencs/view/widget/scenetooltexturebrush.hpp
new file mode 100644
index 000000000..4669f432e
--- /dev/null
+++ b/apps/opencs/view/widget/scenetooltexturebrush.hpp
@@ -0,0 +1,133 @@
+#ifndef CSV_WIDGET_SCENETOOLTEXTUREBRUSH_H
+#define CSV_WIDGET_SCENETOOLTEXTUREBRUSH_H
+
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "scenetool.hpp"
+
+#include "../../model/doc/document.hpp"
+
+class QTableWidget;
+
+namespace CSVRender
+{
+ class TerrainTextureMode;
+}
+
+namespace CSVWidget
+{
+ class SceneToolTextureBrush;
+
+ /// \brief Layout-box for some brush button settings
+ class BrushSizeControls : public QGroupBox
+ {
+ Q_OBJECT
+
+ public:
+ BrushSizeControls(const QString &title, QWidget *parent);
+
+ private:
+ QHBoxLayout *mLayoutSliderSize;
+ QSlider *mBrushSizeSlider;
+ QSpinBox *mBrushSizeSpinBox;
+
+ friend class SceneToolTextureBrush;
+ friend class CSVRender::TerrainTextureMode;
+ };
+
+ class SceneToolTextureBrush;
+
+ /// \brief Brush settings window
+ class TextureBrushWindow : public QFrame
+ {
+ Q_OBJECT
+
+ public:
+ TextureBrushWindow(CSMDoc::Document& document, QWidget *parent = 0);
+ void configureButtonInitialSettings(QPushButton *button);
+
+ const QString toolTipPoint = "Paint single point";
+ const QString toolTipSquare = "Paint with square brush";
+ const QString toolTipCircle = "Paint with circle brush";
+ const QString toolTipCustom = "Paint custom selection (not implemented yet)";
+
+ private:
+ int mBrushShape;
+ int mBrushSize;
+ std::string mBrushTexture;
+ CSMDoc::Document& mDocument;
+ QLabel *mSelectedBrush;
+ QGroupBox *mHorizontalGroupBox;
+ std::string mBrushTextureLabel;
+ QPushButton *mButtonPoint;
+ QPushButton *mButtonSquare;
+ QPushButton *mButtonCircle;
+ QPushButton *mButtonCustom;
+ BrushSizeControls* mSizeSliders;
+
+ friend class SceneToolTextureBrush;
+ friend class CSVRender::TerrainTextureMode;
+
+ public slots:
+ void setBrushTexture(std::string brushTexture);
+ void setBrushShape();
+ void setBrushSize(int brushSize);
+
+ signals:
+ void passBrushSize (int brushSize);
+ void passBrushShape(int brushShape);
+ void passTextureId(std::string brushTexture);
+ };
+
+ class SceneToolTextureBrush : public SceneTool
+ {
+ Q_OBJECT
+
+ QString mToolTip;
+ CSMDoc::Document& mDocument;
+ QFrame *mPanel;
+ QTableWidget *mTable;
+ std::vector mBrushHistory;
+ TextureBrushWindow *mTextureBrushWindow;
+
+ private:
+
+ void adjustToolTips();
+
+ public:
+
+ SceneToolTextureBrush (SceneToolbar *parent, const QString& toolTip, CSMDoc::Document& document);
+
+ virtual void showPanel (const QPoint& position);
+ void updatePanel ();
+
+ void dropEvent (QDropEvent *event);
+ void dragEnterEvent (QDragEnterEvent *event);
+
+ friend class CSVRender::TerrainTextureMode;
+
+ public slots:
+ void setButtonIcon(int brushShape);
+ void updateBrushHistory (const std::string& mBrushTexture);
+ void clicked (const QModelIndex& index);
+ virtual void activate();
+
+ signals:
+ void passEvent(QDropEvent *event);
+ void passEvent(QDragEnterEvent *event);
+ void passTextureId(std::string brushTexture);
+ };
+}
+
+#endif
diff --git a/apps/opencs/view/world/recordbuttonbar.cpp b/apps/opencs/view/world/recordbuttonbar.cpp
index 40a24bf65..9fea7b303 100644
--- a/apps/opencs/view/world/recordbuttonbar.cpp
+++ b/apps/opencs/view/world/recordbuttonbar.cpp
@@ -57,12 +57,12 @@ CSVWorld::RecordButtonBar::RecordButtonBar (const CSMWorld::UniversalId& id,
// left section
mPrevButton = new QToolButton (this);
- mPrevButton->setIcon(QIcon(":/go-previous.png"));
+ mPrevButton->setIcon(QIcon(":record-previous"));
mPrevButton->setToolTip ("Switch to previous record");
buttonsLayout->addWidget (mPrevButton, 0);
mNextButton = new QToolButton (this);
- mNextButton->setIcon(QIcon(":/go-next.png"));
+ mNextButton->setIcon(QIcon(":/record-next"));
mNextButton->setToolTip ("Switch to next record");
buttonsLayout->addWidget (mNextButton, 1);
@@ -72,7 +72,7 @@ CSVWorld::RecordButtonBar::RecordButtonBar (const CSMWorld::UniversalId& id,
if (mTable.getFeatures() & CSMWorld::IdTable::Feature_Preview)
{
QToolButton* previewButton = new QToolButton (this);
- previewButton->setIcon(QIcon(":/edit-preview.png"));
+ previewButton->setIcon(QIcon(":edit-preview"));
previewButton->setToolTip ("Open a preview of this record");
buttonsLayout->addWidget(previewButton);
connect (previewButton, SIGNAL(clicked()), this, SIGNAL (showPreview()));
@@ -89,22 +89,22 @@ CSVWorld::RecordButtonBar::RecordButtonBar (const CSMWorld::UniversalId& id,
// right section
mCloneButton = new QToolButton (this);
- mCloneButton->setIcon(QIcon(":/edit-clone.png"));
+ mCloneButton->setIcon(QIcon(":edit-clone"));
mCloneButton->setToolTip ("Clone record");
buttonsLayout->addWidget(mCloneButton);
mAddButton = new QToolButton (this);
- mAddButton->setIcon(QIcon(":/add.png"));
+ mAddButton->setIcon(QIcon(":edit-add"));
mAddButton->setToolTip ("Add new record");
buttonsLayout->addWidget(mAddButton);
mDeleteButton = new QToolButton (this);
- mDeleteButton->setIcon(QIcon(":/edit-delete.png"));
+ mDeleteButton->setIcon(QIcon(":edit-delete"));
mDeleteButton->setToolTip ("Delete record");
buttonsLayout->addWidget(mDeleteButton);
mRevertButton = new QToolButton (this);
- mRevertButton->setIcon(QIcon(":/edit-undo.png"));
+ mRevertButton->setIcon(QIcon(":edit-undo"));
mRevertButton->setToolTip ("Revert record");
buttonsLayout->addWidget(mRevertButton);
diff --git a/apps/opencs/view/world/recordstatusdelegate.cpp b/apps/opencs/view/world/recordstatusdelegate.cpp
index 12d545339..4a229657d 100644
--- a/apps/opencs/view/world/recordstatusdelegate.cpp
+++ b/apps/opencs/view/world/recordstatusdelegate.cpp
@@ -27,7 +27,7 @@ CSVWorld::RecordStatusDelegateFactory::RecordStatusDelegateFactory()
static const char *sIcons[] =
{
- ":./base.png", ":./modified.png", ":./added.png", ":./removed.png", ":./removed.png", 0
+ ":list-base", ":list-modified", ":list-added", ":list-removed", ":list-removed", 0
};
for (int i=0; sIcons[i]; ++i)
diff --git a/apps/opencs/view/world/referencecreator.cpp b/apps/opencs/view/world/referencecreator.cpp
index 1363f489a..e939b9baf 100644
--- a/apps/opencs/view/world/referencecreator.cpp
+++ b/apps/opencs/view/world/referencecreator.cpp
@@ -63,19 +63,9 @@ std::string CSVWorld::ReferenceCreator::getErrors() const
std::string cell = mCell->text().toUtf8().constData();
if (cell.empty())
- {
- if (!errors.empty())
- errors += "
";
-
errors += "Missing Cell ID";
- }
else if (getData().getCells().searchId (cell)==-1)
- {
- if (!errors.empty())
- errors += "
";
-
errors += "Invalid Cell ID";
- }
return errors;
}
diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp
index 34ecd57d0..986717cb2 100644
--- a/apps/opencs/view/world/table.cpp
+++ b/apps/opencs/view/world/table.cpp
@@ -764,10 +764,8 @@ std::vector< CSMWorld::UniversalId > CSVWorld::Table::getDraggedRecords() const
QModelIndexList selectedRows = selectionModel()->selectedRows();
std::vector idToDrag;
- foreach (QModelIndex it, selectedRows) //I had a dream. Dream where you could use C++11 in OpenMW.
- {
+ for (QModelIndex& it : selectedRows)
idToDrag.push_back (getUniversalId (it.row()));
- }
return idToDrag;
}
diff --git a/apps/opencs/view/world/tablebottombox.cpp b/apps/opencs/view/world/tablebottombox.cpp
index cfde5c694..f6b060a8f 100644
--- a/apps/opencs/view/world/tablebottombox.cpp
+++ b/apps/opencs/view/world/tablebottombox.cpp
@@ -28,6 +28,12 @@ void CSVWorld::TableBottomBox::updateStatus()
{
if (mShowStatusBar)
{
+ if (!mStatusMessage.isEmpty())
+ {
+ mStatus->setText (mStatusMessage);
+ return;
+ }
+
static const char *sLabels[4] = { "record", "deleted", "touched", "selected" };
static const char *sLabelsPlural[4] = { "records", "deleted", "touched", "selected" };
@@ -178,10 +184,17 @@ void CSVWorld::TableBottomBox::currentWidgetChanged(int /*index*/)
updateSize();
}
+void CSVWorld::TableBottomBox::setStatusMessage (const QString& message)
+{
+ mStatusMessage = message;
+ updateStatus();
+}
+
void CSVWorld::TableBottomBox::selectionSizeChanged (int size)
{
if (mStatusCount[3]!=size)
{
+ mStatusMessage = "";
mStatusCount[3] = size;
updateStatus();
}
@@ -210,7 +223,10 @@ void CSVWorld::TableBottomBox::tableSizeChanged (int size, int deleted, int modi
}
if (changed)
+ {
+ mStatusMessage = "";
updateStatus();
+ }
}
void CSVWorld::TableBottomBox::positionChanged (int row, int column)
diff --git a/apps/opencs/view/world/tablebottombox.hpp b/apps/opencs/view/world/tablebottombox.hpp
index 5402c466e..baa68087b 100644
--- a/apps/opencs/view/world/tablebottombox.hpp
+++ b/apps/opencs/view/world/tablebottombox.hpp
@@ -39,6 +39,7 @@ namespace CSVWorld
bool mHasPosition;
int mRow;
int mColumn;
+ QString mStatusMessage;
private:
@@ -73,6 +74,8 @@ namespace CSVWorld
///
/// \note The BotomBox does not partake in the deletion of records.
+ void setStatusMessage (const QString& message);
+
signals:
void requestFocus (const std::string& id);
diff --git a/apps/opencs/view/world/util.cpp b/apps/opencs/view/world/util.cpp
index efba1ea82..eab37e1bf 100644
--- a/apps/opencs/view/world/util.cpp
+++ b/apps/opencs/view/world/util.cpp
@@ -233,6 +233,15 @@ QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleO
return dsb;
}
+ case CSMWorld::ColumnBase::Display_Double:
+ {
+ DialogueDoubleSpinBox *dsb = new DialogueDoubleSpinBox(parent);
+ dsb->setRange(-FLT_MAX, FLT_MAX);
+ dsb->setSingleStep(0.01f);
+ dsb->setDecimals(6);
+ return dsb;
+ }
+
case CSMWorld::ColumnBase::Display_LongString:
{
QPlainTextEdit *edit = new QPlainTextEdit(parent);
diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt
index e869e2915..e64998077 100644
--- a/apps/openmw/CMakeLists.txt
+++ b/apps/openmw/CMakeLists.txt
@@ -89,7 +89,7 @@ add_openmw_dir (mwmechanics
)
add_openmw_dir (mwstate
- statemanagerimp charactermanager character
+ statemanagerimp charactermanager character quicksavemanager
)
add_openmw_dir (mwbase
@@ -222,4 +222,3 @@ endif (MSVC)
if (WIN32)
INSTALL(TARGETS openmw RUNTIME DESTINATION ".")
endif (WIN32)
-
diff --git a/apps/openmw/android_main.c b/apps/openmw/android_main.c
index 3f28afa1b..d234a369d 100644
--- a/apps/openmw/android_main.c
+++ b/apps/openmw/android_main.c
@@ -35,28 +35,11 @@ int Java_org_libsdl_app_SDLActivity_isMouseShown(JNIEnv *env, jclass cls, jobjec
return SDL_ShowCursor(SDL_QUERY);
}
-
-int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls,
- jobject obj) {
-
+int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj) {
setenv("OPENMW_DECOMPRESS_TEXTURES", "1", 1);
- SDL_Android_Init(env, cls);
-
- SDL_SetMainReady();
-
// On Android, we use a virtual controller with guid="Virtual"
SDL_GameControllerAddMapping("5669727475616c000000000000000000,Virtual,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4");
- /* Run the application code! */
-
- int status;
-
- status = main(argcData+1, argvData);
- releaseArgv();
- /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
- /* exit(status); */
-
- return status;
+ return 0;
}
-
diff --git a/apps/openmw/mwbase/dialoguemanager.hpp b/apps/openmw/mwbase/dialoguemanager.hpp
index a9afae786..7bace3790 100644
--- a/apps/openmw/mwbase/dialoguemanager.hpp
+++ b/apps/openmw/mwbase/dialoguemanager.hpp
@@ -39,6 +39,7 @@ namespace MWBase
class ResponseCallback
{
public:
+ virtual ~ResponseCallback() = default;
virtual void addResponse(const std::string& title, const std::string& text) = 0;
};
diff --git a/apps/openmw/mwbase/mechanicsmanager.hpp b/apps/openmw/mwbase/mechanicsmanager.hpp
index e40bf56bb..f15a86918 100644
--- a/apps/openmw/mwbase/mechanicsmanager.hpp
+++ b/apps/openmw/mwbase/mechanicsmanager.hpp
@@ -239,7 +239,7 @@ namespace MWBase
virtual std::vector > getStolenItemOwners(const std::string& itemid) = 0;
/// Has the player stolen this item from the given owner?
- virtual bool isItemStolenFrom(const std::string& itemid, const std::string& ownerid) = 0;
+ virtual bool isItemStolenFrom(const std::string& itemid, const MWWorld::Ptr& ptr) = 0;
virtual bool isBoundItem(const MWWorld::Ptr& item) = 0;
virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target, MWWorld::Ptr& victim) = 0;
diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp
index f72f74c53..23353cbfe 100644
--- a/apps/openmw/mwbase/world.hpp
+++ b/apps/openmw/mwbase/world.hpp
@@ -492,12 +492,14 @@ namespace MWBase
virtual void launchProjectile (MWWorld::Ptr actor, MWWorld::ConstPtr projectile,
const osg::Vec3f& worldPos, const osg::Quat& orient, MWWorld::Ptr bow, float speed, float attackStrength) = 0;
+ virtual void applyLoopingParticles(const MWWorld::Ptr& ptr) = 0;
+
virtual const std::vector& getContentFiles() const = 0;
virtual void breakInvisibility (const MWWorld::Ptr& actor) = 0;
- // Are we in an exterior or pseudo-exterior cell and it's night?
- virtual bool isDark() const = 0;
+ // Allow NPCs to use torches?
+ virtual bool useTorches() const = 0;
virtual bool findInteriorPositionInWorldSpace(const MWWorld::CellStore* cell, osg::Vec3f& result) = 0;
@@ -563,6 +565,8 @@ namespace MWBase
virtual bool isPlayerInJail() const = 0;
+ virtual void rotateWorldObject (const MWWorld::Ptr& ptr, osg::Quat rotate) = 0;
+
/// Return terrain height at \a worldPos position.
virtual float getTerrainHeightAt(const osg::Vec3f& worldPos) const = 0;
diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp
index b6a46cff8..1d51a7830 100644
--- a/apps/openmw/mwclass/container.cpp
+++ b/apps/openmw/mwclass/container.cpp
@@ -139,24 +139,21 @@ namespace MWClass
const std::string trapActivationSound = "Disarm Trap Fail";
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
- const MWWorld::InventoryStore& invStore = player.getClass().getInventoryStore(player);
+ MWWorld::InventoryStore& invStore = player.getClass().getInventoryStore(player);
bool isLocked = ptr.getCellRef().getLockLevel() > 0;
bool isTrapped = !ptr.getCellRef().getTrap().empty();
bool hasKey = false;
std::string keyName;
- // make key id lowercase
- std::string keyId = ptr.getCellRef().getKey();
- Misc::StringUtils::lowerCaseInPlace(keyId);
- for (MWWorld::ConstContainerStoreIterator it = invStore.cbegin(); it != invStore.cend(); ++it)
+ const std::string keyId = ptr.getCellRef().getKey();
+ if (!keyId.empty())
{
- std::string refId = it->getCellRef().getRefId();
- Misc::StringUtils::lowerCaseInPlace(refId);
- if (refId == keyId)
+ MWWorld::Ptr keyPtr = invStore.search(keyId);
+ if (!keyPtr.isEmpty())
{
hasKey = true;
- keyName = it->getClass().getName(*it);
+ keyName = keyPtr.getClass().getName(keyPtr);
}
}
diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp
index 903ec4958..eba87a47b 100644
--- a/apps/openmw/mwclass/door.cpp
+++ b/apps/openmw/mwclass/door.cpp
@@ -114,7 +114,7 @@ namespace MWClass
const std::string lockedSound = "LockedDoor";
const std::string trapActivationSound = "Disarm Trap Fail";
- const MWWorld::ContainerStore &invStore = actor.getClass().getContainerStore(actor);
+ MWWorld::ContainerStore &invStore = actor.getClass().getContainerStore(actor);
bool isLocked = ptr.getCellRef().getLockLevel() > 0;
bool isTrapped = !ptr.getCellRef().getTrap().empty();
@@ -135,21 +135,14 @@ namespace MWClass
animation->addSpellCastGlow(effect, 1); // 1 second glow to match the time taken for a door opening or closing
}
- // make key id lowercase
- std::string keyId = ptr.getCellRef().getKey();
+ const std::string keyId = ptr.getCellRef().getKey();
if (!keyId.empty())
{
- Misc::StringUtils::lowerCaseInPlace(keyId);
- for (MWWorld::ConstContainerStoreIterator it = invStore.cbegin(); it != invStore.cend(); ++it)
+ MWWorld::Ptr keyPtr = invStore.search(keyId);
+ if (!keyPtr.isEmpty())
{
- std::string refId = it->getCellRef().getRefId();
- Misc::StringUtils::lowerCaseInPlace(refId);
- if (refId == keyId)
- {
- hasKey = true;
- keyName = it->getClass().getName(*it);
- break;
- }
+ hasKey = true;
+ keyName = keyPtr.getClass().getName(keyPtr);
}
}
diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp
index f9056b75d..aeeb89a72 100644
--- a/apps/openmw/mwclass/light.cpp
+++ b/apps/openmw/mwclass/light.cpp
@@ -233,24 +233,6 @@ namespace MWClass
if (!(ref->mBase->mData.mFlags & ESM::Light::Carry))
return std::make_pair(0,"");
- const MWWorld::InventoryStore& invStore = npc.getClass().getInventoryStore(npc);
- MWWorld::ConstContainerStoreIterator weapon = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
-
- if(weapon == invStore.end())
- return std::make_pair(1,"");
-
- /// \todo the 2h check is repeated many times; put it in a function
- if(weapon->getTypeName() == typeid(ESM::Weapon).name() &&
- (weapon->get()->mBase->mData.mType == ESM::Weapon::LongBladeTwoHand ||
- weapon->get()->mBase->mData.mType == ESM::Weapon::BluntTwoClose ||
- weapon->get()->mBase->mData.mType == ESM::Weapon::BluntTwoWide ||
- weapon->get()->mBase->mData.mType == ESM::Weapon::SpearTwoWide ||
- weapon->get()->mBase->mData.mType == ESM::Weapon::AxeTwoHand ||
- weapon->get()->mBase->mData.mType == ESM::Weapon::MarksmanBow ||
- weapon->get()->mBase->mData.mType == ESM::Weapon::MarksmanCrossbow))
- {
- return std::make_pair(3,"");
- }
return std::make_pair(1,"");
}
diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp
index a68176226..62b15bc86 100644
--- a/apps/openmw/mwclass/misc.cpp
+++ b/apps/openmw/mwclass/misc.cpp
@@ -1,6 +1,7 @@
#include "misc.hpp"
#include
+#include
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
@@ -83,8 +84,24 @@ namespace MWClass
if (ptr.getCellRef().getSoul() != "")
{
- const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get