1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-04-28 22:36:50 +00:00

Merge branch 'master' into esxSelector

This commit is contained in:
graffy76 2013-09-21 23:07:53 -05:00
commit 70ac14b8ba
23 changed files with 274 additions and 30 deletions

View file

@ -18,12 +18,12 @@ opencs_hdrs_noqt (model/doc
opencs_units (model/world opencs_units (model/world
idtable idtableproxymodel regionmap idtable idtableproxymodel regionmap data
) )
opencs_units_noqt (model/world 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 refidadapter refiddata refidadapterimp ref collectionbase refcollection columns
) )

View file

@ -107,6 +107,11 @@ namespace CSMWorld
virtual int getAppendIndex (UniversalId::Type type = UniversalId::Type_None) const; virtual int getAppendIndex (UniversalId::Type type = UniversalId::Type_None) const;
///< \param type Will be ignored, unless the collection supports multiple record types ///< \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 addColumn (Column<ESXRecordT> *column);
void setRecord (int index, const Record<ESXRecordT>& record); void setRecord (int index, const Record<ESXRecordT>& record);
@ -293,6 +298,21 @@ namespace CSMWorld
return static_cast<int> (mRecords.size()); 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> template<typename ESXRecordT, typename IdAccessorT>
const Record<ESXRecordT>& Collection<ESXRecordT, IdAccessorT>::getRecord (const std::string& id) const const Record<ESXRecordT>& Collection<ESXRecordT, IdAccessorT>::getRecord (const std::string& id) const
{ {

View file

@ -78,8 +78,12 @@ namespace CSMWorld
virtual int getAppendIndex (UniversalId::Type type = UniversalId::Type_None) const = 0; virtual int getAppendIndex (UniversalId::Type type = UniversalId::Type_None) const = 0;
///< \param type Will be ignored, unless the collection supports multiple record types ///< \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 #endif

View file

@ -2,6 +2,7 @@
#include "data.hpp" #include "data.hpp"
#include <stdexcept> #include <stdexcept>
#include <algorithm>
#include <QAbstractItemModel> #include <QAbstractItemModel>
@ -15,13 +16,31 @@
#include "columns.hpp" #include "columns.hpp"
void CSMWorld::Data::addModel (QAbstractItemModel *model, UniversalId::Type type1, void CSMWorld::Data::addModel (QAbstractItemModel *model, UniversalId::Type type1,
UniversalId::Type type2) UniversalId::Type type2, bool update)
{ {
mModels.push_back (model); mModels.push_back (model);
mModelIndex.insert (std::make_pair (type1, model)); mModelIndex.insert (std::make_pair (type1, model));
if (type2!=UniversalId::Type_None) if (type2!=UniversalId::Type_None)
mModelIndex.insert (std::make_pair (type2, model)); 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) 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 (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global);
addModel (new IdTable (&mGmsts), UniversalId::Type_Gmsts, UniversalId::Type_Gmst); 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 (&mClasses), UniversalId::Type_Classes, UniversalId::Type_Class);
addModel (new IdTable (&mFactions), UniversalId::Type_Factions, UniversalId::Type_Faction); addModel (new IdTable (&mFactions), UniversalId::Type_Factions, UniversalId::Type_Faction);
addModel (new IdTable (&mRaces), UniversalId::Type_Races, UniversalId::Type_Race); 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 (&mCells), UniversalId::Type_Cells, UniversalId::Type_Cell);
addModel (new IdTable (&mReferenceables), UniversalId::Type_Referenceables, addModel (new IdTable (&mReferenceables), UniversalId::Type_Referenceables,
UniversalId::Type_Referenceable); UniversalId::Type_Referenceable);
addModel (new IdTable (&mRefs), UniversalId::Type_References, UniversalId::Type_Reference); addModel (new IdTable (&mRefs), UniversalId::Type_References, UniversalId::Type_Reference, false);
addModel (new IdTable (&mFilters), UniversalId::Type_Filters, UniversalId::Type_Filter); addModel (new IdTable (&mFilters), UniversalId::Type_Filters, UniversalId::Type_Filter, false);
} }
CSMWorld::Data::~Data() CSMWorld::Data::~Data()
@ -341,7 +360,7 @@ QAbstractItemModel *CSMWorld::Data::getTableModel (const UniversalId& id)
{ {
RegionMap *table = 0; RegionMap *table = 0;
addModel (table = new RegionMap (*this), UniversalId::Type_RegionMap, addModel (table = new RegionMap (*this), UniversalId::Type_RegionMap,
UniversalId::Type_None); UniversalId::Type_None, false);
return table; return table;
} }
throw std::logic_error ("No table model available for " + id.toString()); 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 || getCells().searchId (id)!=-1 ||
getReferenceables().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();
}

View file

@ -6,6 +6,9 @@
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
#include <QObject>
#include <QModelIndex>
#include <components/esm/loadglob.hpp> #include <components/esm/loadglob.hpp>
#include <components/esm/loadgmst.hpp> #include <components/esm/loadgmst.hpp>
#include <components/esm/loadskil.hpp> #include <components/esm/loadskil.hpp>
@ -30,8 +33,10 @@ class QAbstractItemModel;
namespace CSMWorld namespace CSMWorld
{ {
class Data class Data : public QObject
{ {
Q_OBJECT
IdCollection<ESM::Global> mGlobals; IdCollection<ESM::Global> mGlobals;
IdCollection<ESM::GameSetting> mGmsts; IdCollection<ESM::GameSetting> mGmsts;
IdCollection<ESM::Skill> mSkills; IdCollection<ESM::Skill> mSkills;
@ -55,13 +60,17 @@ namespace CSMWorld
Data& operator= (const Data&); Data& operator= (const Data&);
void addModel (QAbstractItemModel *model, UniversalId::Type type1, 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: public:
Data(); Data();
~Data(); virtual ~Data();
const IdCollection<ESM::Global>& getGlobals() const; const IdCollection<ESM::Global>& getGlobals() const;
@ -136,6 +145,21 @@ namespace CSMWorld
///< Merging content of a file into base or modified. ///< Merging content of a file into base or modified.
bool hasId (const std::string& id) const; 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);
}; };
} }

View file

@ -534,3 +534,8 @@ int CSMWorld::RefIdCollection::getAppendIndex (UniversalId::Type type) const
{ {
return mData.getAppendIndex (type); return mData.getAppendIndex (type);
} }
std::vector<std::string> CSMWorld::RefIdCollection::getIds (bool listDeleted) const
{
return mData.getIds (listDeleted);
}

View file

@ -89,6 +89,11 @@ namespace CSMWorld
virtual int getAppendIndex (UniversalId::Type type) const; virtual int getAppendIndex (UniversalId::Type type) const;
///< \param type Will be ignored, unless the collection supports multiple record types ///< \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
}; };
} }

View file

@ -196,3 +196,25 @@ int CSMWorld::RefIdData::getSize() const
{ {
return mIndex.size(); 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;
}

View file

@ -182,6 +182,11 @@ namespace CSMWorld
void load (const LocalIndex& index, ESM::ESMReader& reader, bool base); void load (const LocalIndex& index, ESM::ESMReader& reader, bool base);
int getSize() const; 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
}; };
} }

View file

@ -1,6 +1,14 @@
#include "scriptcontext.hpp" #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 bool CSMWorld::ScriptContext::canDeclareLocals() const
{ {
return false; 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 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;
} }

View file

@ -1,14 +1,25 @@
#ifndef CSM_WORLD_SCRIPTCONTEXT_H #ifndef CSM_WORLD_SCRIPTCONTEXT_H
#define CSM_WORLD_SCRIPTCONTEXT_H #define CSM_WORLD_SCRIPTCONTEXT_H
#include <string>
#include <vector>
#include <components/compiler/context.hpp> #include <components/compiler/context.hpp>
namespace CSMWorld namespace CSMWorld
{ {
class Data;
class ScriptContext : public Compiler::Context class ScriptContext : public Compiler::Context
{ {
const Data& mData;
mutable std::vector<std::string> mIds;
mutable bool mIdsUpdated;
public: public:
ScriptContext (const Data& data);
virtual bool canDeclareLocals() const; virtual bool canDeclareLocals() const;
///< Is the compiler allowed to declare local variables? ///< Is the compiler allowed to declare local variables?
@ -20,6 +31,8 @@ namespace CSMWorld
virtual bool isId (const std::string& name) const; virtual bool isId (const std::string& name) const;
///< Does \a name match an ID, that can be referenced? ///< Does \a name match an ID, that can be referenced?
void invalidateIds();
}; };
} }

View file

@ -4,6 +4,7 @@
#include <sstream> #include <sstream>
#include <components/compiler/scanner.hpp> #include <components/compiler/scanner.hpp>
#include <components/compiler/extensions0.hpp>
bool CSVWorld::ScriptHighlighter::parseInt (int value, const Compiler::TokenLoc& loc, bool CSVWorld::ScriptHighlighter::parseInt (int value, const Compiler::TokenLoc& loc,
Compiler::Scanner& scanner) 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, bool CSVWorld::ScriptHighlighter::parseName (const std::string& name, const Compiler::TokenLoc& loc,
Compiler::Scanner& scanner) Compiler::Scanner& scanner)
{ {
highlight (loc, Type_Name); highlight (loc, mContext.isId (name) ? Type_Id : Type_Name);
return true; return true;
} }
@ -62,10 +63,10 @@ void CSVWorld::ScriptHighlighter::highlight (const Compiler::TokenLoc& loc, Type
setFormat (index, length, mScheme[type]); setFormat (index, length, mScheme[type]);
} }
CSVWorld::ScriptHighlighter::ScriptHighlighter (QTextDocument *parent) CSVWorld::ScriptHighlighter::ScriptHighlighter (const CSMWorld::Data& data, QTextDocument *parent)
: QSyntaxHighlighter (parent), Compiler::Parser (mErrorHandler, mContext) : QSyntaxHighlighter (parent), Compiler::Parser (mErrorHandler, mContext), mContext (data)
{ {
/// \ŧodo replace this with user settings /// \todo replace this with user settings
{ {
QTextCharFormat format; QTextCharFormat format;
format.setForeground (Qt::darkMagenta); format.setForeground (Qt::darkMagenta);
@ -101,6 +102,16 @@ CSVWorld::ScriptHighlighter::ScriptHighlighter (QTextDocument *parent)
format.setForeground (Qt::green); format.setForeground (Qt::green);
mScheme.insert (std::make_pair (Type_Comment, format)); 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) void CSVWorld::ScriptHighlighter::highlightBlock (const QString& text)
@ -114,5 +125,9 @@ void CSVWorld::ScriptHighlighter::highlightBlock (const QString& text)
scanner.scan (*this); scanner.scan (*this);
} }
catch (...) {} // ignore syntax errors catch (...) {} // ignore syntax errors
}
void CSVWorld::ScriptHighlighter::invalidateIds()
{
mContext.invalidateIds();
} }

View file

@ -7,6 +7,7 @@
#include <components/compiler/nullerrorhandler.hpp> #include <components/compiler/nullerrorhandler.hpp>
#include <components/compiler/parser.hpp> #include <components/compiler/parser.hpp>
#include <components/compiler/extensions.hpp>
#include "../../model/world/scriptcontext.hpp" #include "../../model/world/scriptcontext.hpp"
@ -23,12 +24,14 @@ namespace CSVWorld
Type_Name, Type_Name,
Type_Keyword, Type_Keyword,
Type_Special, Type_Special,
Type_Comment Type_Comment,
Type_Id
}; };
private: private:
Compiler::NullErrorHandler mErrorHandler; Compiler::NullErrorHandler mErrorHandler;
Compiler::Extensions mExtensions;
CSMWorld::ScriptContext mContext; CSMWorld::ScriptContext mContext;
std::map<Type, QTextCharFormat> mScheme; std::map<Type, QTextCharFormat> mScheme;
@ -71,9 +74,11 @@ namespace CSVWorld
public: public:
ScriptHighlighter (QTextDocument *parent); ScriptHighlighter (const CSMWorld::Data& data, QTextDocument *parent);
virtual void highlightBlock (const QString& text); virtual void highlightBlock (const QString& text);
void invalidateIds();
}; };
} }

View file

@ -58,7 +58,13 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc:
connect (mModel, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)), connect (mModel, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
this, SLOT (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) void CSVWorld::ScriptSubView::setEditLock (bool locked)
@ -66,8 +72,19 @@ void CSVWorld::ScriptSubView::setEditLock (bool locked)
mEditor->setReadOnly (locked); mEditor->setReadOnly (locked);
} }
void CSVWorld::ScriptSubView::idListChanged()
{
mHighlighter->invalidateIds();
if (!mUpdateTimer.isActive())
mUpdateTimer.start (0);
}
void CSVWorld::ScriptSubView::textChanged() void CSVWorld::ScriptSubView::textChanged()
{ {
if (mChangeLocked)
return;
ChangeLock lock (*this); ChangeLock lock (*this);
mDocument.getUndoStack().push (new CSMWorld::ModifyCommand (*mModel, mDocument.getUndoStack().push (new CSMWorld::ModifyCommand (*mModel,
@ -79,6 +96,8 @@ void CSVWorld::ScriptSubView::dataChanged (const QModelIndex& topLeft, const QMo
if (mChangeLocked) if (mChangeLocked)
return; return;
ChangeLock lock (*this);
QModelIndex index = mModel->getModelIndex (getUniversalId().getId(), mColumn); QModelIndex index = mModel->getModelIndex (getUniversalId().getId(), mColumn);
if (index.row()>=topLeft.row() && index.row()<=bottomRight.row() && if (index.row()>=topLeft.row() && index.row()<=bottomRight.row() &&
@ -97,3 +116,13 @@ void CSVWorld::ScriptSubView::rowsAboutToBeRemoved (const QModelIndex& parent, i
if (!parent.isValid() && index.row()>=start && index.row()<=end) if (!parent.isValid() && index.row()>=start && index.row()<=end)
deleteLater(); deleteLater();
} }
void CSVWorld::ScriptSubView::updateHighlighting()
{
if (mChangeLocked)
return;
ChangeLock lock (*this);
mHighlighter->rehighlight();
}

View file

@ -3,6 +3,8 @@
#include "../doc/subview.hpp" #include "../doc/subview.hpp"
#include <QTimer>
class QTextEdit; class QTextEdit;
class QModelIndex; class QModelIndex;
@ -18,6 +20,8 @@ namespace CSMWorld
namespace CSVWorld namespace CSVWorld
{ {
class ScriptHighlighter;
class ScriptSubView : public CSVDoc::SubView class ScriptSubView : public CSVDoc::SubView
{ {
Q_OBJECT Q_OBJECT
@ -27,6 +31,8 @@ namespace CSVWorld
CSMWorld::IdTable *mModel; CSMWorld::IdTable *mModel;
int mColumn; int mColumn;
int mChangeLocked; int mChangeLocked;
ScriptHighlighter *mHighlighter;
QTimer mUpdateTimer;
class ChangeLock class ChangeLock
{ {
@ -49,13 +55,19 @@ namespace CSVWorld
virtual void setEditLock (bool locked); virtual void setEditLock (bool locked);
private slots: public slots:
void idListChanged();
void textChanged(); void textChanged();
void dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight); void dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
void rowsAboutToBeRemoved (const QModelIndex& parent, int start, int end); void rowsAboutToBeRemoved (const QModelIndex& parent, int start, int end);
private slots:
void updateHighlighting();
}; };
} }

View file

@ -396,6 +396,8 @@ namespace MWBase
/// It only applies to the current form the NPC is in. /// It only applies to the current form the NPC is in.
virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor) = 0; virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor) = 0;
virtual bool getGodModeState() = 0;
virtual bool toggleGodMode() = 0; virtual bool toggleGodMode() = 0;
}; };
} }

View file

@ -585,7 +585,7 @@ namespace MWInput
mPlayer->pitch(-y/scale); 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()->changeVanityModeScale(arg.zrel);
MWBase::Environment::get().getWorld()->setCameraDistance(arg.zrel, true, true); MWBase::Environment::get().getWorld()->setCameraDistance(arg.zrel, true, true);

View file

@ -275,9 +275,8 @@ namespace MWMechanics
continue; continue;
} }
// workaround: always keep player alive for now // If it's the player and God Mode is turned on, keep it alive
// \todo remove workaround, once player death can be handled if(iter->first.getRefData().getHandle()=="player" && MWBase::Environment::get().getWorld()->getGodModeState())
if(iter->first.getRefData().getHandle()=="player")
{ {
MWMechanics::DynamicStat<float> stat(stats.getHealth()); MWMechanics::DynamicStat<float> stat(stats.getHealth());

View file

@ -151,8 +151,7 @@ namespace MWMechanics
for (Collection::const_iterator iter (prev.begin()); iter!=prev.end(); ++iter) for (Collection::const_iterator iter (prev.begin()); iter!=prev.end(); ++iter)
{ {
Collection::const_iterator other = now.mCollection.find (iter->first); Collection::const_iterator other = now.mCollection.find (iter->first);
if (other==now.end())
if (other==prev.end())
{ {
result.add (iter->first, EffectParam() - iter->second); result.add (iter->first, EffectParam() - iter->second);
} }

View file

@ -726,8 +726,7 @@ namespace MWScript
bool enabled = MWBase::Environment::get().getWorld()->toggleGodMode(); bool enabled = MWBase::Environment::get().getWorld()->toggleGodMode();
// context.report (enabled ? "God Mode -> On" : "God Mode -> Off"); context.report (enabled ? "God Mode -> On" : "God Mode -> Off");
context.report("Unimplemented");
} }
}; };

View file

@ -170,7 +170,7 @@ namespace MWWorld
mSky (true), mCells (mStore, mEsm), mSky (true), mCells (mStore, mEsm),
mActivationDistanceOverride (mActivationDistanceOverride), mActivationDistanceOverride (mActivationDistanceOverride),
mFallback(fallbackMap), mPlayIntro(0), mTeleportEnabled(true), mFallback(fallbackMap), mPlayIntro(0), mTeleportEnabled(true),
mFacedDistance(FLT_MAX) mFacedDistance(FLT_MAX), mGodMode(false)
{ {
mPhysics = new PhysicsSystem(renderer); mPhysics = new PhysicsSystem(renderer);
mPhysEngine = mPhysics->getEngine(); mPhysEngine = mPhysics->getEngine();
@ -1948,9 +1948,16 @@ namespace MWWorld
stats.getSkill(ESM::Skill::Acrobatics).setModified(gmst.find("fWerewolfAcrobatics")->getFloat(), 0); stats.getSkill(ESM::Skill::Acrobatics).setModified(gmst.find("fWerewolfAcrobatics")->getFloat(), 0);
} }
bool World::getGodModeState()
{
return mGodMode;
}
bool World::toggleGodMode() bool World::toggleGodMode()
{ {
return false; mGodMode = !mGodMode;
return mGodMode;
} }
} }

View file

@ -68,6 +68,8 @@ namespace MWWorld
OEngine::Physic::PhysicEngine* mPhysEngine; OEngine::Physic::PhysicEngine* mPhysEngine;
bool mGodMode;
// not implemented // not implemented
World (const World&); World (const World&);
World& operator= (const World&); World& operator= (const World&);
@ -440,6 +442,8 @@ namespace MWWorld
virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor); virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor);
virtual bool getGodModeState();
virtual bool toggleGodMode(); virtual bool toggleGodMode();
}; };
} }

View file

@ -47,6 +47,7 @@ Marc Bouvier (CramitDeFrog)
Marcin Hulist (Gohan) Marcin Hulist (Gohan)
Mark Siewert (mark76) Mark Siewert (mark76)
Mateusz Kołaczek (PL_kolek) Mateusz Kołaczek (PL_kolek)
Michael Hogan (Xethik)
Michael Mc Donnell Michael Mc Donnell
Michael Papageorgiou (werdanith) Michael Papageorgiou (werdanith)
Michał Bień (Glorf) Michał Bień (Glorf)