From 6f89d453a5213a04eab4c168d495ea71e838a082 Mon Sep 17 00:00:00 2001 From: graffy76 Date: Fri, 22 Feb 2013 21:53:32 -0600 Subject: [PATCH 1/8] Operations widget height fix and abort button feature. Successfully tested resizing of Operations QDockWidget for multiple concurrent operations. --- apps/opencs/model/doc/document.cpp | 3 +- apps/opencs/view/doc/operation.cpp | 55 ++++++++++++++++++++++------ apps/opencs/view/doc/operation.hpp | 24 ++++++++++-- apps/opencs/view/doc/operations.cpp | 34 +++++++++++++---- apps/opencs/view/doc/operations.hpp | 6 ++- apps/opencs/view/doc/subview.cpp | 1 - apps/opencs/view/doc/view.cpp | 29 ++++++++++++--- apps/opencs/view/doc/view.hpp | 10 ++++- apps/opencs/view/doc/viewmanager.cpp | 6 ++- 9 files changed, 132 insertions(+), 36 deletions(-) diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index da29f6c68..d63aaeccb 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -249,6 +249,7 @@ void CSMDoc::Document::abortOperation (int type) if (type==State_Saving) { + mSaveCount=0; mSaveTimer.stop(); emit stateChanged (getState(), this); } @@ -297,4 +298,4 @@ CSMTools::ReportModel *CSMDoc::Document::getReport (const CSMWorld::UniversalId& void CSMDoc::Document::progress (int current, int max, int type) { emit progress (current, max, type, 1, this); -} \ No newline at end of file +} diff --git a/apps/opencs/view/doc/operation.cpp b/apps/opencs/view/doc/operation.cpp index c301195bc..6977d7953 100644 --- a/apps/opencs/view/doc/operation.cpp +++ b/apps/opencs/view/doc/operation.cpp @@ -1,8 +1,11 @@ - #include "operation.hpp" #include +#include +#include +#include + #include "../../model/doc/document.hpp" void CSVDoc::Operation::updateLabel (int threads) @@ -28,24 +31,44 @@ void CSVDoc::Operation::updateLabel (int threads) stream << name << " (%p%)"; } - setFormat (stream.str().c_str()); + mProgressBar->setFormat (stream.str().c_str()); } } -CSVDoc::Operation::Operation (int type) : mType (type), mStalling (false) +CSVDoc::Operation::Operation (int type, QWidget* parent) : mType (type), mStalling (false) { /// \todo Add a cancel button or a pop up menu with a cancel item + initWidgets(); setBarColor( type); updateLabel(); /// \todo assign different progress bar colours to allow the user to distinguish easily between operation types } +CSVDoc::Operation::~Operation() +{ + delete mLayout; + delete mProgressBar; + delete mAbortButton; +} + +void CSVDoc::Operation::initWidgets() +{ + mProgressBar = new QProgressBar (); + mAbortButton = new QPushButton("Abort"); + mLayout = new QHBoxLayout(); + + mLayout->addWidget (mProgressBar); + mLayout->addWidget (mAbortButton); + + connect (mAbortButton, SIGNAL (clicked()), this, SLOT (abortOperation())); +} + void CSVDoc::Operation::setProgress (int current, int max, int threads) { updateLabel (threads); - setRange (0, max); - setValue (current); + mProgressBar->setRange (0, max); + mProgressBar->setValue (current); } int CSVDoc::Operation::getType() const @@ -64,8 +87,6 @@ void CSVDoc::Operation::setBarColor (int type) "margin: 2px 1px 1p 2px;" "}"; - // "QProgressBar::chunk {background-color: %1;}"; - QString topColor = "#F2F6F8"; QString bottomColor = "#E0EFF9"; QString midTopColor = "#D8E1E7"; @@ -82,7 +103,7 @@ void CSVDoc::Operation::setBarColor (int type) midTopColor = "#F17432"; midBottomColor = "#EA5507"; bottomColor = "#FB955E"; // red gloss #2 - //break; + break; case CSMDoc::State_Searching: @@ -90,7 +111,7 @@ void CSVDoc::Operation::setBarColor (int type) midTopColor = "#ABD3EE"; midBottomColor = "#89C3EB"; bottomColor = "#D5EBFB"; //blue gloss #4 - //break; + break; case CSMDoc::State_Verifying: @@ -98,7 +119,7 @@ void CSVDoc::Operation::setBarColor (int type) midTopColor = "#8EB92A"; midBottomColor = "#72AA00"; bottomColor = "#9ECB2D"; //green gloss - //break; + break; case CSMDoc::State_Compiling: @@ -106,7 +127,7 @@ void CSVDoc::Operation::setBarColor (int type) midTopColor = "#C19E67"; midBottomColor = "#B68D4C"; bottomColor = "#E9D4B3"; //l Brown 3D - //break; + break; default: @@ -116,5 +137,15 @@ void CSVDoc::Operation::setBarColor (int type) midBottomColor = "#B5C6D0"; // gray gloss for undefined ops } - setStyleSheet(style.arg(topColor).arg(midTopColor).arg(midBottomColor).arg(bottomColor)); + mProgressBar->setStyleSheet(style.arg(topColor).arg(midTopColor).arg(midBottomColor).arg(bottomColor)); +} + +QHBoxLayout *CSVDoc::Operation::getLayout() const +{ + return mLayout; +} + +void CSVDoc::Operation::abortOperation() +{ + emit abortOperation (mType); } diff --git a/apps/opencs/view/doc/operation.hpp b/apps/opencs/view/doc/operation.hpp index a5abf73b7..48839fada 100644 --- a/apps/opencs/view/doc/operation.hpp +++ b/apps/opencs/view/doc/operation.hpp @@ -1,16 +1,23 @@ #ifndef CSV_DOC_OPERATION_H #define CSV_DOC_OPERATION_H -#include +#include + +class QHBoxLayout; +class QPushButton; +class QProgressBar; namespace CSVDoc { - class Operation : public QProgressBar + class Operation : public QObject { Q_OBJECT int mType; bool mStalling; + QProgressBar *mProgressBar; + QPushButton *mAbortButton; + QHBoxLayout *mLayout; // not implemented Operation (const Operation&); @@ -20,15 +27,26 @@ namespace CSVDoc public: - Operation (int type); + Operation (int type, QWidget *parent); + ~Operation(); void setProgress (int current, int max, int threads); int getType() const; + QHBoxLayout *getLayout() const; private: void setBarColor (int type); + void initWidgets(); + + signals: + + void abortOperation (int type); + + private slots: + + void abortOperation(); }; } diff --git a/apps/opencs/view/doc/operations.cpp b/apps/opencs/view/doc/operations.cpp index ba444a119..71cacbe17 100644 --- a/apps/opencs/view/doc/operations.cpp +++ b/apps/opencs/view/doc/operations.cpp @@ -1,7 +1,7 @@ - #include "operations.hpp" #include +#include #include "operation.hpp" @@ -11,12 +11,14 @@ CSVDoc::Operations::Operations() setFeatures (QDockWidget::NoDockWidgetFeatures); - QWidget *widget = new QWidget; - setWidget (widget); - + QWidget *widgetContainer = new QWidget (this); mLayout = new QVBoxLayout; - widget->setLayout (mLayout); + widgetContainer->setLayout (mLayout); + setWidget (widgetContainer); + + setFixedHeight (widgetContainer->height()); + setTitleBarWidget (new QWidget (this)); } void CSVDoc::Operations::setProgress (int current, int max, int type, int threads) @@ -28,11 +30,18 @@ void CSVDoc::Operations::setProgress (int current, int max, int type, int thread return; } - Operation *operation = new Operation (type); + int oldCount = mOperations.size(); + int newCount = oldCount + 1; - mLayout->addWidget (operation); + Operation *operation = new Operation (type, this); + connect (operation, SIGNAL (abortOperation (int)), this, SIGNAL (abortOperation (int))); + + mLayout->addLayout (operation->getLayout()); mOperations.push_back (operation); operation->setProgress (current, max, threads); + + if ( oldCount > 0) + setFixedHeight (height()/oldCount * newCount); } void CSVDoc::Operations::quitOperation (int type) @@ -40,8 +49,17 @@ void CSVDoc::Operations::quitOperation (int type) for (std::vector::iterator iter (mOperations.begin()); iter!=mOperations.end(); ++iter) if ((*iter)->getType()==type) { + int oldCount = mOperations.size(); + int newCount = oldCount - 1; + + mLayout->removeItem ((*iter)->getLayout()); + delete *iter; mOperations.erase (iter); + + if (oldCount > 1) + setFixedHeight (height() / oldCount * newCount); + break; } -} \ No newline at end of file +} diff --git a/apps/opencs/view/doc/operations.hpp b/apps/opencs/view/doc/operations.hpp index b96677450..71c595f66 100644 --- a/apps/opencs/view/doc/operations.hpp +++ b/apps/opencs/view/doc/operations.hpp @@ -31,7 +31,11 @@ namespace CSVDoc void quitOperation (int type); ///< Calling this function for an operation that is not running is a no-op. + + signals: + + void abortOperation (int type); }; } -#endif \ No newline at end of file +#endif diff --git a/apps/opencs/view/doc/subview.cpp b/apps/opencs/view/doc/subview.cpp index 1c356fa73..affada012 100644 --- a/apps/opencs/view/doc/subview.cpp +++ b/apps/opencs/view/doc/subview.cpp @@ -1,4 +1,3 @@ - #include "subview.hpp" CSVDoc::SubView::SubView (const CSMWorld::UniversalId& id) : mUniversalId (id) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 4fd03041f..6aafef4ed 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -1,4 +1,3 @@ - #include "view.hpp" #include @@ -7,6 +6,7 @@ #include #include #include +#include #include "../../model/doc/document.hpp" @@ -117,13 +117,16 @@ void CSVDoc::View::updateActions() mVerify->setEnabled (!(mDocument->getState() & CSMDoc::State_Verifying)); } -CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews) -: mViewManager (viewManager), mDocument (document), mViewIndex (totalViews-1), mViewTotal (totalViews) +CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews, QMainWindow *viewParent) + : mViewManager (viewManager), mDocument (document), mViewIndex (totalViews-1), mViewTotal (totalViews), QMainWindow (viewParent) { setDockOptions (QMainWindow::AllowNestedDocks); resize (300, 300); /// \todo get default size from settings and set reasonable minimal size + mSubViewWindow = new QMainWindow(); + setCentralWidget (mSubViewWindow); + mOperations = new Operations; addDockWidget (Qt::BottomDockWidgetArea, mOperations); @@ -133,6 +136,8 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to CSVWorld::addSubViewFactories (mSubViewFactory); CSVTools::addSubViewFactories (mSubViewFactory); + + connect (mOperations, SIGNAL (abortOperation (int)), this, SLOT (abortOperation (int))); } CSVDoc::View::~View() @@ -171,7 +176,7 @@ void CSVDoc::View::updateDocumentState() for (int i=0; operations[i]!=-1; ++i) if (!(state & operations[i])) - mOperations->quitOperation (operations[i]); + mOperations->quitOperation (operations[i]); QList subViews = findChildren(); @@ -195,7 +200,7 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id) /// \todo add an user setting to reuse sub views (on a per document basis or on a per top level view basis) SubView *view = mSubViewFactory.makeSubView (id, *mDocument); - addDockWidget (Qt::TopDockWidgetArea, view); + mSubViewWindow->addDockWidget (Qt::TopDockWidgetArea, view); connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&)), this, SLOT (addSubView (const CSMWorld::UniversalId&))); @@ -226,4 +231,16 @@ void CSVDoc::View::addGlobalsSubView() void CSVDoc::View::addGmstsSubView() { addSubView (CSMWorld::UniversalId::Type_Gmsts); -} \ No newline at end of file +} + +void CSVDoc::View::abortOperation (int type) +{ + mDocument->abortOperation (type); + mOperations->quitOperation (type); + updateActions(); +} + +QDockWidget *CSVDoc::View::getOperations() const +{ + return mOperations; +} diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index 6bdd54e6b..28ab24b74 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -9,6 +9,7 @@ #include "subviewfactory.hpp" class QAction; +class QDockWidget; namespace CSMDoc { @@ -40,6 +41,7 @@ namespace CSVDoc std::vector mEditingActions; Operations *mOperations; SubViewFactoryManager mSubViewFactory; + QMainWindow* mSubViewWindow; // not implemented View (const View&); @@ -65,7 +67,7 @@ namespace CSVDoc public: - View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews); + View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews, QMainWindow *viewParent); ///< The ownership of \a document is not transferred to *this. virtual ~View(); @@ -80,6 +82,8 @@ namespace CSVDoc void updateProgress (int current, int max, int type, int threads); + QDockWidget *getOperations() const; + signals: void newDocumentRequest(); @@ -101,7 +105,9 @@ namespace CSVDoc void addGlobalsSubView(); void addGmstsSubView(); + + void abortOperation (int type); }; } -#endif \ No newline at end of file +#endif diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index 473049999..a8faefb97 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -59,7 +59,9 @@ CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document) this, SLOT (progress (int, int, int, int, CSMDoc::Document *))); } - View *view = new View (*this, document, countViews (document)+1); + QMainWindow *mainWindow = new QMainWindow; + + View *view = new View (*this, document, countViews (document)+1, mainWindow); mViews.push_back (view); @@ -119,4 +121,4 @@ void CSVDoc::ViewManager::progress (int current, int max, int type, int threads, for (std::vector::const_iterator iter (mViews.begin()); iter!=mViews.end(); ++iter) if ((*iter)->getDocument()==document) (*iter)->updateProgress (current, max, type, threads); -} \ No newline at end of file +} From c9ca565462b599356e1681bb769218eeda3da411 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 23 Feb 2013 12:05:09 +0100 Subject: [PATCH 2/8] removed a redundant function call --- apps/opencs/view/doc/view.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 6aafef4ed..286d7a6ed 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -236,7 +236,6 @@ void CSVDoc::View::addGmstsSubView() void CSVDoc::View::abortOperation (int type) { mDocument->abortOperation (type); - mOperations->quitOperation (type); updateActions(); } From 6f5a772d02d886d3777de0b25f45db878f636aad Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 23 Feb 2013 12:35:05 +0100 Subject: [PATCH 3/8] fixed another case handling problem --- apps/opencs/model/world/idcollection.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/idcollection.hpp b/apps/opencs/model/world/idcollection.hpp index 5a1d21ae4..9b69dfb88 100644 --- a/apps/opencs/model/world/idcollection.hpp +++ b/apps/opencs/model/world/idcollection.hpp @@ -171,7 +171,7 @@ namespace CSMWorld record2.mModified = record; mRecords.push_back (record2); - mIndex.insert (std::make_pair (id, mRecords.size()-1)); + mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (id), mRecords.size()-1)); } else { @@ -306,7 +306,7 @@ namespace CSMWorld void IdCollection::appendRecord (const RecordBase& record) { mRecords.push_back (dynamic_cast&> (record)); - mIndex.insert (std::make_pair (getId (record), mRecords.size()-1)); + mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (getId (record)), mRecords.size()-1)); } template From 868916a9a22d0dd9f8713b6ea57206d6ee689d52 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 23 Feb 2013 12:51:45 +0100 Subject: [PATCH 4/8] added add-on global variables in the same way add-on GMSTs were added --- apps/opencs/model/doc/document.cpp | 32 ++++++++++++++++++++++++++++++ apps/opencs/model/doc/document.hpp | 5 +++++ 2 files changed, 37 insertions(+) diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index d63aaeccb..b361577be 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -20,6 +20,7 @@ void CSMDoc::Document::load (const std::vector::const_i getData().loadFile (*end2, false); addOptionalGmsts(); + addOptionalGlobals(); } void CSMDoc::Document::addOptionalGmsts() @@ -139,6 +140,26 @@ void CSMDoc::Document::addOptionalGmsts() } } +void CSMDoc::Document::addOptionalGlobals() +{ + static const char *sGlobals[] = + { + "dayspassed", + "pcwerewolf", + "pcyear", + 0 + }; + + for (int i=0; sGlobals[i]; ++i) + { + ESM::Global global; + global.mId = sGlobals[i]; + global.mType = ESM::VT_Int; + global.mValue = 0; + addOptionalGlobal (global); + } +} + void CSMDoc::Document::addOptionalGmst (const ESM::GameSetting& gmst) { if (getData().getGmsts().searchId (gmst.mId)==-1) @@ -150,6 +171,17 @@ void CSMDoc::Document::addOptionalGmst (const ESM::GameSetting& gmst) } } +void CSMDoc::Document::addOptionalGlobal (const ESM::Global& global) +{ + if (getData().getGlobals().searchId (global.mId)==-1) + { + CSMWorld::Record record; + record.mBase = global; + record.mState = CSMWorld::RecordBase::State_BaseOnly; + getData().getGlobals().appendRecord (record); + } +} + void CSMDoc::Document::createBase() { static const char *sGlobals[] = diff --git a/apps/opencs/model/doc/document.hpp b/apps/opencs/model/doc/document.hpp index 413e840d3..a7b198689 100644 --- a/apps/opencs/model/doc/document.hpp +++ b/apps/opencs/model/doc/document.hpp @@ -20,6 +20,7 @@ class QAbstractItemModel; namespace ESM { struct GameSetting; + struct Global; } namespace CSMDoc @@ -53,8 +54,12 @@ namespace CSMDoc void addOptionalGmsts(); + void addOptionalGlobals(); + void addOptionalGmst (const ESM::GameSetting& gmst); + void addOptionalGlobal (const ESM::Global& global); + public: Document (const std::vector& files, bool new_); From 9659b4a95e1d4bb40560046b288173ec54f07ab2 Mon Sep 17 00:00:00 2001 From: greye Date: Thu, 21 Feb 2013 23:56:34 +0400 Subject: [PATCH 5/8] update NpcAnimation inventory reference on cell change --- apps/openmw/mwrender/actors.cpp | 4 ++- apps/openmw/mwrender/npcanimation.cpp | 52 +++++++++++++-------------- apps/openmw/mwrender/npcanimation.hpp | 8 ++++- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/apps/openmw/mwrender/actors.cpp b/apps/openmw/mwrender/actors.cpp index 92f5cbe28..e886f3a09 100644 --- a/apps/openmw/mwrender/actors.cpp +++ b/apps/openmw/mwrender/actors.cpp @@ -163,7 +163,9 @@ void Actors::updateObjectCell(const MWWorld::Ptr &ptr) { /// \note Update key (Ptr's are compared only with refdata so mCell /// on key is outdated), maybe redundant - Animation *anim = iter->second; + NpcAnimation *anim = static_cast(iter->second); + anim->updateParts(MWWorld::Class::get(ptr).getInventoryStore(ptr)); + mAllActors.erase(iter); mAllActors[ptr] = anim; } diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index d33bdda91..6f6c9e740 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -48,21 +48,21 @@ NpcAnimation::~NpcAnimation() NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& inv, int visibilityFlags) : Animation(), mStateID(-1), - mInv(inv), + mInv(&inv), mTimeToChange(0), mVisibilityFlags(visibilityFlags), - mRobe(mInv.end()), - mHelmet(mInv.end()), - mShirt(mInv.end()), - mCuirass(mInv.end()), - mGreaves(mInv.end()), - mPauldronL(mInv.end()), - mPauldronR(mInv.end()), - mBoots(mInv.end()), - mPants(mInv.end()), - mGloveL(mInv.end()), - mGloveR(mInv.end()), - mSkirtIter(mInv.end()) + mRobe(mInv->end()), + mHelmet(mInv->end()), + mShirt(mInv->end()), + mCuirass(mInv->end()), + mGreaves(mInv->end()), + mPauldronL(mInv->end()), + mPauldronR(mInv->end()), + mBoots(mInv->end()), + mPants(mInv->end()), + mGloveL(mInv->end()), + mGloveR(mInv->end()), + mSkirtIter(mInv->end()) { mNpc = ptr.get()->mBase; @@ -160,7 +160,7 @@ void NpcAnimation::updateParts() }; for(size_t i = 0;i < sizeof(slotlist)/sizeof(slotlist[0]);i++) { - MWWorld::ContainerStoreIterator iter = mInv.getSlot(slotlist[i].slot); + MWWorld::ContainerStoreIterator iter = mInv->getSlot(slotlist[i].slot); if(*slotlist[i].iter != iter) { *slotlist[i].iter = iter; @@ -171,7 +171,7 @@ void NpcAnimation::updateParts() if(apparelChanged) { - if(mRobe != mInv.end()) + if(mRobe != mInv->end()) { MWWorld::Ptr ptr = *mRobe; @@ -191,7 +191,7 @@ void NpcAnimation::updateParts() reserveIndividualPart(ESM::PRT_RPauldron, MWWorld::InventoryStore::Slot_Robe, 5); reserveIndividualPart(ESM::PRT_LPauldron, MWWorld::InventoryStore::Slot_Robe, 5); } - if(mSkirtIter != mInv.end()) + if(mSkirtIter != mInv->end()) { MWWorld::Ptr ptr = *mSkirtIter; @@ -203,39 +203,39 @@ void NpcAnimation::updateParts() reserveIndividualPart(ESM::PRT_LLeg, MWWorld::InventoryStore::Slot_Skirt, 4); } - if(mHelmet != mInv.end()) + if(mHelmet != mInv->end()) { removeIndividualPart(ESM::PRT_Hair); const ESM::Armor *armor = (mHelmet->get())->mBase; std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Helmet, 3, parts); } - if(mCuirass != mInv.end()) + if(mCuirass != mInv->end()) { const ESM::Armor *armor = (mCuirass->get())->mBase; std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Cuirass, 3, parts); } - if(mGreaves != mInv.end()) + if(mGreaves != mInv->end()) { const ESM::Armor *armor = (mGreaves->get())->mBase; std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Greaves, 3, parts); } - if(mPauldronL != mInv.end()) + if(mPauldronL != mInv->end()) { const ESM::Armor *armor = (mPauldronL->get())->mBase; std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_LeftPauldron, 3, parts); } - if(mPauldronR != mInv.end()) + if(mPauldronR != mInv->end()) { const ESM::Armor *armor = (mPauldronR->get())->mBase; std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts); } - if(mBoots != mInv.end()) + if(mBoots != mInv->end()) { if(mBoots->getTypeName() == typeid(ESM::Clothing).name()) { @@ -250,7 +250,7 @@ void NpcAnimation::updateParts() addPartGroup(MWWorld::InventoryStore::Slot_Boots, 3, parts); } } - if(mGloveL != mInv.end()) + if(mGloveL != mInv->end()) { if(mGloveL->getTypeName() == typeid(ESM::Clothing).name()) { @@ -265,7 +265,7 @@ void NpcAnimation::updateParts() addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 3, parts); } } - if(mGloveR != mInv.end()) + if(mGloveR != mInv->end()) { if(mGloveR->getTypeName() == typeid(ESM::Clothing).name()) { @@ -282,13 +282,13 @@ void NpcAnimation::updateParts() } - if(mShirt != mInv.end()) + if(mShirt != mInv->end()) { const ESM::Clothing *clothes = (mShirt->get())->mBase; std::vector parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Shirt, 2, parts); } - if(mPants != mInv.end()) + if(mPants != mInv->end()) { const ESM::Clothing *clothes = (mPants->get())->mBase; std::vector parts = clothes->mParts.mParts; diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index ca76dcc22..fd1a96aa3 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -17,7 +17,7 @@ namespace MWRender{ class NpcAnimation: public Animation{ private: - MWWorld::InventoryStore& mInv; + MWWorld::InventoryStore *mInv; int mStateID; int mPartslots[27]; //Each part slot is taken by clothing, armor, or is empty @@ -78,7 +78,13 @@ public: virtual ~NpcAnimation(); NifOgre::EntityList insertBoundedPart(const std::string &mesh, int group, const std::string &bonename); virtual void runAnimation(float timepassed); + void updateParts(); + void updateParts(MWWorld::InventoryStore &inventory) { + mInv = &inventory; + updateParts(); + } + void removeEntities(NifOgre::EntityList &entities); void removeIndividualPart(int type); void reserveIndividualPart(int type, int group, int priority); From d983ed5c7819046ad4c0166c61f6cc47575196f7 Mon Sep 17 00:00:00 2001 From: greye Date: Fri, 22 Feb 2013 11:14:14 +0400 Subject: [PATCH 6/8] fix invalid SceneNode pointer on cell change --- apps/openmw/mwworld/worldimp.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index ca054e776..12193de40 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -746,7 +746,11 @@ namespace MWWorld copyObjectToCell(ptr, newCell, pos); else if (!mWorldScene->isCellActive(newCell)) { - MWWorld::Class::get(ptr).copyToCell(ptr, newCell); + MWWorld::Class::get(ptr) + .copyToCell(ptr, newCell) + .getRefData() + .setBaseNode(0); + mWorldScene->removeObjectFromScene(ptr); mLocalScripts.remove(ptr); removeContainerScripts (ptr); From ac7095537f9626f62ee9437b241371356b92526e Mon Sep 17 00:00:00 2001 From: greye Date: Sat, 23 Feb 2013 16:50:37 +0400 Subject: [PATCH 7/8] remove insertMesh() call on object cell change --- apps/openmw/mwrender/objects.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index ee36126f8..16ac163ec 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -514,9 +514,5 @@ void Objects::updateObjectCell(const MWWorld::Ptr &ptr) node = mCellSceneNodes[newCell]; } node->addChild(ptr.getRefData().getBaseNode()); - - /// \note Still unaware how to move aabb and static w/o full rebuild, - /// moving static objects may cause problems - insertMesh(ptr, MWWorld::Class::get(ptr).getModel(ptr)); } From a3adcf752d9796279f175d7fbd01080ac53b227f Mon Sep 17 00:00:00 2001 From: Sergey Shambir Date: Fri, 22 Feb 2013 21:33:23 +0400 Subject: [PATCH 8/8] TradeWindow: fixed coding style Mentioned here: https://github.com/zinnschlag/openmw/pull/554 --- apps/openmw/mwgui/tradewindow.cpp | 12 ++++++------ apps/openmw/mwgui/tradewindow.hpp | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 2cc8ff444..290310760 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -19,11 +19,11 @@ #include "inventorywindow.hpp" -static const float BALANCE_CHANGE_INITIAL_PAUSE = 0.5; // in seconds -static const float BALANCE_CHANGE_INTERVAL = 0.1; // in seconds - namespace MWGui { + const float TradeWindow::sBalanceChangeInitialPause = 0.5; + const float TradeWindow::sBalanceChangeInterval = 0.1; + TradeWindow::TradeWindow(MWBase::WindowManager& parWindowManager) : WindowBase("openmw_trade_window.layout", parWindowManager) , ContainerBase(NULL) // no drag&drop @@ -157,7 +157,7 @@ namespace MWGui mBalanceChangePause -= frameDuration; if (mBalanceChangePause < 0.0) { - mBalanceChangePause += BALANCE_CHANGE_INTERVAL; + mBalanceChangePause += sBalanceChangeInterval; if (mBalanceButtonsState == BBS_Increase) onIncreaseButtonTriggered(); else if (mBalanceButtonsState == BBS_Decrease) @@ -296,14 +296,14 @@ namespace MWGui void TradeWindow::onIncreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) { mBalanceButtonsState = BBS_Increase; - mBalanceChangePause = BALANCE_CHANGE_INITIAL_PAUSE; + mBalanceChangePause = sBalanceChangeInitialPause; onIncreaseButtonTriggered(); } void TradeWindow::onDecreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) { mBalanceButtonsState = BBS_Decrease; - mBalanceChangePause = BALANCE_CHANGE_INITIAL_PAUSE; + mBalanceChangePause = sBalanceChangeInitialPause; onDecreaseButtonTriggered(); } diff --git a/apps/openmw/mwgui/tradewindow.hpp b/apps/openmw/mwgui/tradewindow.hpp index 20d9b6069..c1d31917b 100644 --- a/apps/openmw/mwgui/tradewindow.hpp +++ b/apps/openmw/mwgui/tradewindow.hpp @@ -37,6 +37,9 @@ namespace MWGui void onFrame(float frameDuration); protected: + static const float sBalanceChangeInitialPause; // in seconds + static const float sBalanceChangeInterval; // in seconds + MyGUI::Button* mFilterAll; MyGUI::Button* mFilterWeapon; MyGUI::Button* mFilterApparel;