mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 20:26:43 +00:00 
			
		
		
		
	Merge branch 'master' into esxSelector
This commit is contained in:
		
						commit
						70ac14b8ba
					
				
					 23 changed files with 274 additions and 30 deletions
				
			
		|  | @ -18,12 +18,12 @@ opencs_hdrs_noqt (model/doc | |||
| 
 | ||||
| 
 | ||||
| opencs_units (model/world | ||||
|     idtable idtableproxymodel regionmap | ||||
|     idtable idtableproxymodel regionmap data | ||||
|     ) | ||||
| 
 | ||||
| 
 | ||||
| opencs_units_noqt (model/world | ||||
|     universalid data record commands columnbase scriptcontext cell refidcollection | ||||
|     universalid record commands columnbase scriptcontext cell refidcollection | ||||
|     refidadapter refiddata refidadapterimp ref collectionbase refcollection columns | ||||
|     ) | ||||
| 
 | ||||
|  |  | |||
|  | @ -107,6 +107,11 @@ namespace CSMWorld | |||
|             virtual int getAppendIndex (UniversalId::Type type = UniversalId::Type_None) const; | ||||
|             ///< \param type Will be ignored, unless the collection supports multiple record types
 | ||||
| 
 | ||||
|             virtual std::vector<std::string> getIds (bool listDeleted = true) const; | ||||
|             ///< Return a sorted collection of all IDs
 | ||||
|             ///
 | ||||
|             /// \param listDeleted include deleted record in the list
 | ||||
| 
 | ||||
|             void addColumn (Column<ESXRecordT> *column); | ||||
| 
 | ||||
|             void setRecord (int index, const Record<ESXRecordT>& record); | ||||
|  | @ -293,6 +298,21 @@ namespace CSMWorld | |||
|         return static_cast<int> (mRecords.size()); | ||||
|     } | ||||
| 
 | ||||
|     template<typename ESXRecordT, typename IdAccessorT> | ||||
|     std::vector<std::string> Collection<ESXRecordT, IdAccessorT>::getIds (bool listDeleted) const | ||||
|     { | ||||
|         std::vector<std::string> ids; | ||||
| 
 | ||||
|         for (typename std::map<std::string, int>::const_iterator iter = mIndex.begin(); | ||||
|             iter!=mIndex.end(); ++iter) | ||||
|         { | ||||
|             if (listDeleted || !mRecords[iter->second].isDeleted()) | ||||
|                 ids.push_back (IdAccessorT().getId (mRecords[iter->second].get())); | ||||
|         } | ||||
| 
 | ||||
|         return ids; | ||||
|     } | ||||
| 
 | ||||
|     template<typename ESXRecordT, typename IdAccessorT> | ||||
|     const Record<ESXRecordT>& Collection<ESXRecordT, IdAccessorT>::getRecord (const std::string& id) const | ||||
|     { | ||||
|  |  | |||
|  | @ -78,8 +78,12 @@ namespace CSMWorld | |||
| 
 | ||||
|             virtual int getAppendIndex (UniversalId::Type type = UniversalId::Type_None) const = 0; | ||||
|             ///< \param type Will be ignored, unless the collection supports multiple record types
 | ||||
|     }; | ||||
| 
 | ||||
|             virtual std::vector<std::string> getIds (bool listDeleted = true) const = 0; | ||||
|             ///< Return a sorted collection of all IDs
 | ||||
|             ///
 | ||||
|             /// \param listDeleted include deleted record in the list
 | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
|  | @ -2,6 +2,7 @@ | |||
| #include "data.hpp" | ||||
| 
 | ||||
| #include <stdexcept> | ||||
| #include <algorithm> | ||||
| 
 | ||||
| #include <QAbstractItemModel> | ||||
| 
 | ||||
|  | @ -15,13 +16,31 @@ | |||
| #include "columns.hpp" | ||||
| 
 | ||||
| void CSMWorld::Data::addModel (QAbstractItemModel *model, UniversalId::Type type1, | ||||
|     UniversalId::Type type2) | ||||
|     UniversalId::Type type2, bool update) | ||||
| { | ||||
|     mModels.push_back (model); | ||||
|     mModelIndex.insert (std::make_pair (type1, model)); | ||||
| 
 | ||||
|     if (type2!=UniversalId::Type_None) | ||||
|         mModelIndex.insert (std::make_pair (type2, model)); | ||||
| 
 | ||||
|     if (update) | ||||
|     { | ||||
|         connect (model, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)), | ||||
|             this, SLOT (dataChanged (const QModelIndex&, const QModelIndex&))); | ||||
|         connect (model, SIGNAL (rowsInserted (const QModelIndex&, int, int)), | ||||
|             this, SLOT (rowsChanged (const QModelIndex&, int, int))); | ||||
|         connect (model, SIGNAL (rowsRemoved (const QModelIndex&, int, int)), | ||||
|             this, SLOT (rowsChanged (const QModelIndex&, int, int))); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void CSMWorld::Data::appendIds (std::vector<std::string>& ids, const CollectionBase& collection, | ||||
|     bool listDeleted) | ||||
| { | ||||
|     std::vector<std::string> ids2 = collection.getIds (listDeleted); | ||||
| 
 | ||||
|     ids.insert (ids.end(), ids2.begin(), ids2.end()); | ||||
| } | ||||
| 
 | ||||
| CSMWorld::Data::Data() : mRefs (mCells) | ||||
|  | @ -155,7 +174,7 @@ CSMWorld::Data::Data() : mRefs (mCells) | |||
| 
 | ||||
|     addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global); | ||||
|     addModel (new IdTable (&mGmsts), UniversalId::Type_Gmsts, UniversalId::Type_Gmst); | ||||
|     addModel (new IdTable (&mSkills), UniversalId::Type_Skills, UniversalId::Type_Skill); | ||||
|     addModel (new IdTable (&mSkills), UniversalId::Type_Skills, UniversalId::Type_Skill, false); | ||||
|     addModel (new IdTable (&mClasses), UniversalId::Type_Classes, UniversalId::Type_Class); | ||||
|     addModel (new IdTable (&mFactions), UniversalId::Type_Factions, UniversalId::Type_Faction); | ||||
|     addModel (new IdTable (&mRaces), UniversalId::Type_Races, UniversalId::Type_Race); | ||||
|  | @ -167,8 +186,8 @@ CSMWorld::Data::Data() : mRefs (mCells) | |||
|     addModel (new IdTable (&mCells), UniversalId::Type_Cells, UniversalId::Type_Cell); | ||||
|     addModel (new IdTable (&mReferenceables), UniversalId::Type_Referenceables, | ||||
|         UniversalId::Type_Referenceable); | ||||
|     addModel (new IdTable (&mRefs), UniversalId::Type_References, UniversalId::Type_Reference); | ||||
|     addModel (new IdTable (&mFilters), UniversalId::Type_Filters, UniversalId::Type_Filter); | ||||
|     addModel (new IdTable (&mRefs), UniversalId::Type_References, UniversalId::Type_Reference, false); | ||||
|     addModel (new IdTable (&mFilters), UniversalId::Type_Filters, UniversalId::Type_Filter, false); | ||||
| } | ||||
| 
 | ||||
| CSMWorld::Data::~Data() | ||||
|  | @ -341,7 +360,7 @@ QAbstractItemModel *CSMWorld::Data::getTableModel (const UniversalId& id) | |||
|         { | ||||
|             RegionMap *table = 0; | ||||
|             addModel (table = new RegionMap (*this), UniversalId::Type_RegionMap, | ||||
|                 UniversalId::Type_None); | ||||
|                 UniversalId::Type_None, false); | ||||
|             return table; | ||||
|         } | ||||
|         throw std::logic_error ("No table model available for " + id.toString()); | ||||
|  | @ -440,3 +459,36 @@ bool CSMWorld::Data::hasId (const std::string& id) const | |||
|         getCells().searchId (id)!=-1 || | ||||
|         getReferenceables().searchId (id)!=-1; | ||||
| } | ||||
| 
 | ||||
| std::vector<std::string> CSMWorld::Data::getIds (bool listDeleted) const | ||||
| { | ||||
|     std::vector<std::string> ids; | ||||
| 
 | ||||
|     appendIds (ids, mGlobals, listDeleted); | ||||
|     appendIds (ids, mGmsts, listDeleted); | ||||
|     appendIds (ids, mClasses, listDeleted); | ||||
|     appendIds (ids, mFactions, listDeleted); | ||||
|     appendIds (ids, mRaces, listDeleted); | ||||
|     appendIds (ids, mSounds, listDeleted); | ||||
|     appendIds (ids, mScripts, listDeleted); | ||||
|     appendIds (ids, mRegions, listDeleted); | ||||
|     appendIds (ids, mBirthsigns, listDeleted); | ||||
|     appendIds (ids, mSpells, listDeleted); | ||||
|     appendIds (ids, mCells, listDeleted); | ||||
|     appendIds (ids, mReferenceables, listDeleted); | ||||
| 
 | ||||
|     std::sort (ids.begin(), ids.end()); | ||||
| 
 | ||||
|     return ids; | ||||
| } | ||||
| 
 | ||||
| void CSMWorld::Data::dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) | ||||
| { | ||||
|     if (topLeft.column()<=0) | ||||
|         emit idListChanged(); | ||||
| } | ||||
| 
 | ||||
| void CSMWorld::Data::rowsChanged (const QModelIndex& parent, int start, int end) | ||||
| { | ||||
|     emit idListChanged(); | ||||
| } | ||||
|  | @ -6,6 +6,9 @@ | |||
| 
 | ||||
| #include <boost/filesystem/path.hpp> | ||||
| 
 | ||||
| #include <QObject> | ||||
| #include <QModelIndex> | ||||
| 
 | ||||
| #include <components/esm/loadglob.hpp> | ||||
| #include <components/esm/loadgmst.hpp> | ||||
| #include <components/esm/loadskil.hpp> | ||||
|  | @ -30,8 +33,10 @@ class QAbstractItemModel; | |||
| 
 | ||||
| namespace CSMWorld | ||||
| { | ||||
|     class Data | ||||
|     class Data : public QObject | ||||
|     { | ||||
|             Q_OBJECT | ||||
| 
 | ||||
|             IdCollection<ESM::Global> mGlobals; | ||||
|             IdCollection<ESM::GameSetting> mGmsts; | ||||
|             IdCollection<ESM::Skill> mSkills; | ||||
|  | @ -55,13 +60,17 @@ namespace CSMWorld | |||
|             Data& operator= (const Data&); | ||||
| 
 | ||||
|             void addModel (QAbstractItemModel *model, UniversalId::Type type1, | ||||
|                 UniversalId::Type type2 = UniversalId::Type_None); | ||||
|                 UniversalId::Type type2 = UniversalId::Type_None, bool update = true); | ||||
| 
 | ||||
|             static void appendIds (std::vector<std::string>& ids, const CollectionBase& collection, | ||||
|                 bool listDeleted); | ||||
|             ///< Append all IDs from collection to \a ids.
 | ||||
| 
 | ||||
|         public: | ||||
| 
 | ||||
|             Data(); | ||||
| 
 | ||||
|             ~Data(); | ||||
|             virtual ~Data(); | ||||
| 
 | ||||
|             const IdCollection<ESM::Global>& getGlobals() const; | ||||
| 
 | ||||
|  | @ -136,6 +145,21 @@ namespace CSMWorld | |||
|             ///< Merging content of a file into base or modified.
 | ||||
| 
 | ||||
|             bool hasId (const std::string& id) const; | ||||
| 
 | ||||
|             std::vector<std::string> getIds (bool listDeleted = true) const; | ||||
|             ///< Return a sorted collection of all IDs that are not internal to the editor.
 | ||||
|             ///
 | ||||
|             /// \param listDeleted include deleted record in the list
 | ||||
| 
 | ||||
|         signals: | ||||
| 
 | ||||
|             void idListChanged(); | ||||
| 
 | ||||
|         private slots: | ||||
| 
 | ||||
|             void dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight); | ||||
| 
 | ||||
|             void rowsChanged (const QModelIndex& parent, int start, int end); | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -534,3 +534,8 @@ int CSMWorld::RefIdCollection::getAppendIndex (UniversalId::Type type) const | |||
| { | ||||
|     return mData.getAppendIndex (type); | ||||
| } | ||||
| 
 | ||||
| std::vector<std::string> CSMWorld::RefIdCollection::getIds (bool listDeleted) const | ||||
| { | ||||
|     return mData.getIds (listDeleted); | ||||
| } | ||||
|  |  | |||
|  | @ -89,6 +89,11 @@ namespace CSMWorld | |||
| 
 | ||||
|             virtual int getAppendIndex (UniversalId::Type type) const; | ||||
|             ///< \param type Will be ignored, unless the collection supports multiple record types
 | ||||
| 
 | ||||
|             virtual std::vector<std::string> getIds (bool listDeleted) const; | ||||
|             ///< Return a sorted collection of all IDs
 | ||||
|             ///
 | ||||
|             /// \param listDeleted include deleted record in the list
 | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -196,3 +196,25 @@ int CSMWorld::RefIdData::getSize() const | |||
| { | ||||
|     return mIndex.size(); | ||||
| } | ||||
| 
 | ||||
| std::vector<std::string> CSMWorld::RefIdData::getIds (bool listDeleted) const | ||||
| { | ||||
|     std::vector<std::string> ids; | ||||
| 
 | ||||
|     for (std::map<std::string, LocalIndex>::const_iterator iter (mIndex.begin()); iter!=mIndex.end(); | ||||
|          ++iter) | ||||
|     { | ||||
|         if (listDeleted || !getRecord (iter->second).isDeleted()) | ||||
|         { | ||||
|             std::map<UniversalId::Type, RefIdDataContainerBase *>::const_iterator container = | ||||
|                 mRecordContainers.find (iter->second.second); | ||||
| 
 | ||||
|             if (container==mRecordContainers.end()) | ||||
|                 throw std::logic_error ("Invalid referenceable ID type"); | ||||
| 
 | ||||
|             ids.push_back (container->second->getId (iter->second.first)); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     return ids; | ||||
| } | ||||
|  |  | |||
|  | @ -182,6 +182,11 @@ namespace CSMWorld | |||
|             void load (const LocalIndex& index, ESM::ESMReader& reader, bool base); | ||||
| 
 | ||||
|             int getSize() const; | ||||
| 
 | ||||
|             std::vector<std::string> getIds (bool listDeleted = true) const; | ||||
|             ///< Return a sorted collection of all IDs
 | ||||
|             ///
 | ||||
|             /// \param listDeleted include deleted record in the list
 | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,6 +1,14 @@ | |||
| 
 | ||||
| #include "scriptcontext.hpp" | ||||
| 
 | ||||
| #include <algorithm> | ||||
| 
 | ||||
| #include <components/misc/stringops.hpp> | ||||
| 
 | ||||
| #include "data.hpp" | ||||
| 
 | ||||
| CSMWorld::ScriptContext::ScriptContext (const Data& data) : mData (data), mIdsUpdated (false) {} | ||||
| 
 | ||||
| bool CSMWorld::ScriptContext::canDeclareLocals() const | ||||
| { | ||||
|     return false; | ||||
|  | @ -18,5 +26,19 @@ char CSMWorld::ScriptContext::getMemberType (const std::string& name, const std: | |||
| 
 | ||||
| bool CSMWorld::ScriptContext::isId (const std::string& name) const | ||||
| { | ||||
|     return false; | ||||
|     if (!mIdsUpdated) | ||||
|     { | ||||
|         mIds = mData.getIds(); | ||||
| 
 | ||||
|         std::for_each (mIds.begin(), mIds.end(), &Misc::StringUtils::lowerCase); | ||||
| 
 | ||||
|         mIdsUpdated = true; | ||||
|     } | ||||
| 
 | ||||
|     return std::binary_search (mIds.begin(), mIds.end(), Misc::StringUtils::lowerCase (name)); | ||||
| } | ||||
| 
 | ||||
| void CSMWorld::ScriptContext::invalidateIds() | ||||
| { | ||||
|     mIdsUpdated = false; | ||||
| } | ||||
|  | @ -1,14 +1,25 @@ | |||
| #ifndef CSM_WORLD_SCRIPTCONTEXT_H | ||||
| #define CSM_WORLD_SCRIPTCONTEXT_H | ||||
| 
 | ||||
| #include <string> | ||||
| #include <vector> | ||||
| 
 | ||||
| #include <components/compiler/context.hpp> | ||||
| 
 | ||||
| namespace CSMWorld | ||||
| { | ||||
|     class Data; | ||||
| 
 | ||||
|     class ScriptContext : public Compiler::Context | ||||
|     { | ||||
|             const Data& mData; | ||||
|             mutable std::vector<std::string> mIds; | ||||
|             mutable bool mIdsUpdated; | ||||
| 
 | ||||
|         public: | ||||
| 
 | ||||
|             ScriptContext (const Data& data); | ||||
| 
 | ||||
|             virtual bool canDeclareLocals() const; | ||||
|             ///< Is the compiler allowed to declare local variables?
 | ||||
| 
 | ||||
|  | @ -20,6 +31,8 @@ namespace CSMWorld | |||
| 
 | ||||
|             virtual bool isId (const std::string& name) const; | ||||
|             ///< Does \a name match an ID, that can be referenced?
 | ||||
| 
 | ||||
|             void invalidateIds(); | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -4,6 +4,7 @@ | |||
| #include <sstream> | ||||
| 
 | ||||
| #include <components/compiler/scanner.hpp> | ||||
| #include <components/compiler/extensions0.hpp> | ||||
| 
 | ||||
| bool CSVWorld::ScriptHighlighter::parseInt (int value, const Compiler::TokenLoc& loc, | ||||
|     Compiler::Scanner& scanner) | ||||
|  | @ -22,7 +23,7 @@ bool CSVWorld::ScriptHighlighter::parseFloat (float value, const Compiler::Token | |||
| bool CSVWorld::ScriptHighlighter::parseName (const std::string& name, const Compiler::TokenLoc& loc, | ||||
|     Compiler::Scanner& scanner) | ||||
| { | ||||
|     highlight (loc, Type_Name); | ||||
|     highlight (loc, mContext.isId (name) ? Type_Id : Type_Name); | ||||
|     return true; | ||||
| } | ||||
| 
 | ||||
|  | @ -62,10 +63,10 @@ void CSVWorld::ScriptHighlighter::highlight (const Compiler::TokenLoc& loc, Type | |||
|     setFormat (index, length, mScheme[type]); | ||||
| } | ||||
| 
 | ||||
| CSVWorld::ScriptHighlighter::ScriptHighlighter (QTextDocument *parent) | ||||
| : QSyntaxHighlighter (parent), Compiler::Parser (mErrorHandler, mContext) | ||||
| CSVWorld::ScriptHighlighter::ScriptHighlighter (const CSMWorld::Data& data, QTextDocument *parent) | ||||
| : QSyntaxHighlighter (parent), Compiler::Parser (mErrorHandler, mContext), mContext (data) | ||||
| { | ||||
|     /// \ŧodo replace this with user settings
 | ||||
|     /// \todo replace this with user settings
 | ||||
|     { | ||||
|         QTextCharFormat format; | ||||
|         format.setForeground (Qt::darkMagenta); | ||||
|  | @ -101,6 +102,16 @@ CSVWorld::ScriptHighlighter::ScriptHighlighter (QTextDocument *parent) | |||
|         format.setForeground (Qt::green); | ||||
|         mScheme.insert (std::make_pair (Type_Comment, format)); | ||||
|     } | ||||
| 
 | ||||
|     { | ||||
|         QTextCharFormat format; | ||||
|         format.setForeground (Qt::blue); | ||||
|         mScheme.insert (std::make_pair (Type_Id, format)); | ||||
|     } | ||||
| 
 | ||||
|     // configure compiler
 | ||||
|     Compiler::registerExtensions (mExtensions); | ||||
|     mContext.setExtensions (&mExtensions); | ||||
| } | ||||
| 
 | ||||
| void CSVWorld::ScriptHighlighter::highlightBlock (const QString& text) | ||||
|  | @ -114,5 +125,9 @@ void CSVWorld::ScriptHighlighter::highlightBlock (const QString& text) | |||
|         scanner.scan (*this); | ||||
|     } | ||||
|     catch (...) {} // ignore syntax errors
 | ||||
| } | ||||
| 
 | ||||
| void CSVWorld::ScriptHighlighter::invalidateIds() | ||||
| { | ||||
|     mContext.invalidateIds(); | ||||
| } | ||||
|  | @ -7,6 +7,7 @@ | |||
| 
 | ||||
| #include <components/compiler/nullerrorhandler.hpp> | ||||
| #include <components/compiler/parser.hpp> | ||||
| #include <components/compiler/extensions.hpp> | ||||
| 
 | ||||
| #include "../../model/world/scriptcontext.hpp" | ||||
| 
 | ||||
|  | @ -23,12 +24,14 @@ namespace CSVWorld | |||
|                 Type_Name, | ||||
|                 Type_Keyword, | ||||
|                 Type_Special, | ||||
|                 Type_Comment | ||||
|                 Type_Comment, | ||||
|                 Type_Id | ||||
|             }; | ||||
| 
 | ||||
|         private: | ||||
| 
 | ||||
|             Compiler::NullErrorHandler mErrorHandler; | ||||
|             Compiler::Extensions mExtensions; | ||||
|             CSMWorld::ScriptContext mContext; | ||||
|             std::map<Type, QTextCharFormat> mScheme; | ||||
| 
 | ||||
|  | @ -71,9 +74,11 @@ namespace CSVWorld | |||
| 
 | ||||
|         public: | ||||
| 
 | ||||
|             ScriptHighlighter (QTextDocument *parent); | ||||
|             ScriptHighlighter (const CSMWorld::Data& data, QTextDocument *parent); | ||||
| 
 | ||||
|             virtual void highlightBlock (const QString& text); | ||||
| 
 | ||||
|             void invalidateIds(); | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -58,7 +58,13 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc: | |||
|     connect (mModel, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)), | ||||
|         this, SLOT (rowsAboutToBeRemoved (const QModelIndex&, int, int))); | ||||
| 
 | ||||
|     new ScriptHighlighter (mEditor->document()); | ||||
|     connect (&document.getData(), SIGNAL (idListChanged()), this, SLOT (idListChanged())); | ||||
| 
 | ||||
|     mHighlighter = new ScriptHighlighter (document.getData(), mEditor->document()); | ||||
| 
 | ||||
|     connect (&mUpdateTimer, SIGNAL (timeout()), this, SLOT (updateHighlighting())); | ||||
| 
 | ||||
|     mUpdateTimer.setSingleShot (true); | ||||
| } | ||||
| 
 | ||||
| void CSVWorld::ScriptSubView::setEditLock (bool locked) | ||||
|  | @ -66,8 +72,19 @@ void CSVWorld::ScriptSubView::setEditLock (bool locked) | |||
|     mEditor->setReadOnly (locked); | ||||
| } | ||||
| 
 | ||||
| void CSVWorld::ScriptSubView::idListChanged() | ||||
| { | ||||
|     mHighlighter->invalidateIds(); | ||||
| 
 | ||||
|     if (!mUpdateTimer.isActive()) | ||||
|         mUpdateTimer.start (0); | ||||
| } | ||||
| 
 | ||||
| void CSVWorld::ScriptSubView::textChanged() | ||||
| { | ||||
|     if (mChangeLocked) | ||||
|         return; | ||||
| 
 | ||||
|     ChangeLock lock (*this); | ||||
| 
 | ||||
|     mDocument.getUndoStack().push (new CSMWorld::ModifyCommand (*mModel, | ||||
|  | @ -79,6 +96,8 @@ void CSVWorld::ScriptSubView::dataChanged (const QModelIndex& topLeft, const QMo | |||
|     if (mChangeLocked) | ||||
|         return; | ||||
| 
 | ||||
|     ChangeLock lock (*this); | ||||
| 
 | ||||
|     QModelIndex index = mModel->getModelIndex (getUniversalId().getId(), mColumn); | ||||
| 
 | ||||
|     if (index.row()>=topLeft.row() && index.row()<=bottomRight.row() && | ||||
|  | @ -96,4 +115,14 @@ void CSVWorld::ScriptSubView::rowsAboutToBeRemoved (const QModelIndex& parent, i | |||
| 
 | ||||
|     if (!parent.isValid() && index.row()>=start && index.row()<=end) | ||||
|         deleteLater(); | ||||
| } | ||||
| 
 | ||||
| void CSVWorld::ScriptSubView::updateHighlighting() | ||||
| { | ||||
|     if (mChangeLocked) | ||||
|         return; | ||||
| 
 | ||||
|     ChangeLock lock (*this); | ||||
| 
 | ||||
|     mHighlighter->rehighlight(); | ||||
| } | ||||
|  | @ -3,6 +3,8 @@ | |||
| 
 | ||||
| #include "../doc/subview.hpp" | ||||
| 
 | ||||
| #include <QTimer> | ||||
| 
 | ||||
| class QTextEdit; | ||||
| class QModelIndex; | ||||
| 
 | ||||
|  | @ -18,6 +20,8 @@ namespace CSMWorld | |||
| 
 | ||||
| namespace CSVWorld | ||||
| { | ||||
|     class ScriptHighlighter; | ||||
| 
 | ||||
|     class ScriptSubView : public CSVDoc::SubView | ||||
|     { | ||||
|             Q_OBJECT | ||||
|  | @ -27,6 +31,8 @@ namespace CSVWorld | |||
|             CSMWorld::IdTable *mModel; | ||||
|             int mColumn; | ||||
|             int mChangeLocked; | ||||
|             ScriptHighlighter *mHighlighter; | ||||
|             QTimer mUpdateTimer; | ||||
| 
 | ||||
|             class ChangeLock | ||||
|             { | ||||
|  | @ -49,13 +55,19 @@ namespace CSVWorld | |||
| 
 | ||||
|             virtual void setEditLock (bool locked); | ||||
| 
 | ||||
|         private slots: | ||||
|         public slots: | ||||
| 
 | ||||
|             void idListChanged(); | ||||
| 
 | ||||
|             void textChanged(); | ||||
| 
 | ||||
|             void dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight); | ||||
| 
 | ||||
|             void rowsAboutToBeRemoved (const QModelIndex& parent, int start, int end); | ||||
| 
 | ||||
|         private slots: | ||||
| 
 | ||||
|             void updateHighlighting(); | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -396,6 +396,8 @@ namespace MWBase | |||
|             /// It only applies to the current form the NPC is in.
 | ||||
|             virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor) = 0; | ||||
| 
 | ||||
|             virtual bool getGodModeState() = 0; | ||||
| 
 | ||||
|             virtual bool toggleGodMode() = 0; | ||||
|     }; | ||||
| } | ||||
|  |  | |||
|  | @ -585,7 +585,7 @@ namespace MWInput | |||
|                 mPlayer->pitch(-y/scale); | ||||
|             } | ||||
| 
 | ||||
|             if (arg.zrel) | ||||
|             if (arg.zrel && mControlSwitch["playerviewswitch"]) //Check to make sure you are allowed to zoomout and there is a change
 | ||||
|             { | ||||
|                 MWBase::Environment::get().getWorld()->changeVanityModeScale(arg.zrel); | ||||
|                 MWBase::Environment::get().getWorld()->setCameraDistance(arg.zrel, true, true); | ||||
|  |  | |||
|  | @ -275,9 +275,8 @@ namespace MWMechanics | |||
|                         continue; | ||||
|                 } | ||||
| 
 | ||||
|                 // workaround: always keep player alive for now
 | ||||
|                 // \todo remove workaround, once player death can be handled
 | ||||
|                 if(iter->first.getRefData().getHandle()=="player") | ||||
|                 // If it's the player and God Mode is turned on, keep it alive
 | ||||
|                 if(iter->first.getRefData().getHandle()=="player" && MWBase::Environment::get().getWorld()->getGodModeState()) | ||||
|                 { | ||||
|                     MWMechanics::DynamicStat<float> stat(stats.getHealth()); | ||||
| 
 | ||||
|  |  | |||
|  | @ -151,8 +151,7 @@ namespace MWMechanics | |||
|         for (Collection::const_iterator iter (prev.begin()); iter!=prev.end(); ++iter) | ||||
|         { | ||||
|             Collection::const_iterator other = now.mCollection.find (iter->first); | ||||
| 
 | ||||
|             if (other==prev.end()) | ||||
|             if (other==now.end()) | ||||
|             { | ||||
|                 result.add (iter->first, EffectParam() - iter->second); | ||||
|             } | ||||
|  |  | |||
|  | @ -726,8 +726,7 @@ namespace MWScript | |||
| 
 | ||||
|                     bool enabled = MWBase::Environment::get().getWorld()->toggleGodMode(); | ||||
| 
 | ||||
|                     // context.report (enabled ? "God Mode -> On" : "God Mode -> Off");
 | ||||
|                     context.report("Unimplemented"); | ||||
|                     context.report (enabled ? "God Mode -> On" : "God Mode -> Off"); | ||||
|                 } | ||||
|         }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -170,7 +170,7 @@ namespace MWWorld | |||
|       mSky (true), mCells (mStore, mEsm), | ||||
|       mActivationDistanceOverride (mActivationDistanceOverride), | ||||
|       mFallback(fallbackMap), mPlayIntro(0), mTeleportEnabled(true), | ||||
|       mFacedDistance(FLT_MAX) | ||||
|       mFacedDistance(FLT_MAX), mGodMode(false) | ||||
|     { | ||||
|         mPhysics = new PhysicsSystem(renderer); | ||||
|         mPhysEngine = mPhysics->getEngine(); | ||||
|  | @ -1948,9 +1948,16 @@ namespace MWWorld | |||
|         stats.getSkill(ESM::Skill::Acrobatics).setModified(gmst.find("fWerewolfAcrobatics")->getFloat(), 0); | ||||
|     } | ||||
| 
 | ||||
|     bool World::getGodModeState() | ||||
|     { | ||||
|         return mGodMode; | ||||
|     } | ||||
| 
 | ||||
|     bool World::toggleGodMode() | ||||
|     { | ||||
|         return false; | ||||
|         mGodMode = !mGodMode; | ||||
| 
 | ||||
|         return mGodMode; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -68,6 +68,8 @@ namespace MWWorld | |||
| 
 | ||||
|             OEngine::Physic::PhysicEngine* mPhysEngine; | ||||
| 
 | ||||
|             bool mGodMode; | ||||
| 
 | ||||
|             // not implemented
 | ||||
|             World (const World&); | ||||
|             World& operator= (const World&); | ||||
|  | @ -440,6 +442,8 @@ namespace MWWorld | |||
| 
 | ||||
|             virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor); | ||||
| 
 | ||||
|             virtual bool getGodModeState(); | ||||
| 
 | ||||
|             virtual bool toggleGodMode(); | ||||
|     }; | ||||
| } | ||||
|  |  | |||
|  | @ -47,6 +47,7 @@ Marc Bouvier (CramitDeFrog) | |||
| Marcin Hulist (Gohan) | ||||
| Mark Siewert (mark76) | ||||
| Mateusz Kołaczek (PL_kolek) | ||||
| Michael Hogan (Xethik) | ||||
| Michael Mc Donnell | ||||
| Michael Papageorgiou (werdanith) | ||||
| Michał Bień (Glorf) | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue