1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-03 20:15:31 +00:00

Merge branch 'master' into pathgrid-edit

Conflicts:
	apps/opencs/view/render/cell.cpp
	apps/opencs/view/render/mousestate.cpp
	apps/opencs/view/render/object.cpp
	apps/opencs/view/render/object.hpp
	apps/opencs/view/render/pagedworldspacewidget.cpp
	apps/opencs/view/render/unpagedworldspacewidget.cpp
	apps/opencs/view/render/worldspacewidget.cpp
This commit is contained in:
cc9cii 2014-12-09 14:02:26 +11:00
commit 84f0ddd51c
226 changed files with 4043 additions and 960 deletions

View file

@ -600,11 +600,6 @@ if (BUILD_OPENCS)
endif() endif()
if (BUILD_WIZARD) if (BUILD_WIZARD)
find_package(LIBUNSHIELD REQUIRED)
if(NOT LIBUNSHIELD_FOUND)
message(FATAL_ERROR "Failed to find Unshield library")
endif(NOT LIBUNSHIELD_FOUND)
add_subdirectory(apps/wizard) add_subdirectory(apps/wizard)
endif() endif()

View file

@ -137,6 +137,7 @@ void Launcher::DataFilesPage::saveSettings(const QString &profile)
void Launcher::DataFilesPage::removeProfile(const QString &profile) void Launcher::DataFilesPage::removeProfile(const QString &profile)
{ {
mLauncherSettings.remove(QString("Profiles/") + profile); mLauncherSettings.remove(QString("Profiles/") + profile);
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/content"));
} }
QAbstractItemModel *Launcher::DataFilesPage::profilesModel() const QAbstractItemModel *Launcher::DataFilesPage::profilesModel() const

View file

@ -11,7 +11,7 @@ opencs_units (model/doc
) )
opencs_units_noqt (model/doc opencs_units_noqt (model/doc
stage savingstate savingstages blacklist stage savingstate savingstages blacklist messages
) )
opencs_hdrs_noqt (model/doc opencs_hdrs_noqt (model/doc
@ -68,11 +68,12 @@ opencs_units (view/world
opencs_units_noqt (view/world opencs_units_noqt (view/world
subviews enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate subviews enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate
scripthighlighter idvalidator dialoguecreator physicssystem physicsmanager scripthighlighter idvalidator dialoguecreator physicssystem
) )
opencs_units (view/widget opencs_units (view/widget
scenetoolbar scenetool scenetoolmode pushbutton scenetooltoggle scenetoolrun modebutton scenetoolbar scenetool scenetoolmode pushbutton scenetooltoggle scenetoolrun modebutton
scenetooltoggle2
) )
opencs_units (view/render opencs_units (view/render
@ -92,7 +93,7 @@ opencs_hdrs_noqt (view/render
opencs_units (view/tools opencs_units (view/tools
reportsubview reportsubview reporttable
) )
opencs_units_noqt (view/tools opencs_units_noqt (view/tools

View file

@ -1,6 +1,8 @@
#include "editor.hpp" #include "editor.hpp"
#include <openengine/bullet/BulletShapeLoader.h>
#include <QApplication> #include <QApplication>
#include <QLocalServer> #include <QLocalServer>
#include <QLocalSocket> #include <QLocalSocket>
@ -21,8 +23,8 @@
CS::Editor::Editor (OgreInit::OgreInit& ogreInit) CS::Editor::Editor (OgreInit::OgreInit& ogreInit)
: mUserSettings (mCfgMgr), mOverlaySystem (0), mDocumentManager (mCfgMgr), : mUserSettings (mCfgMgr), mOverlaySystem (0), mDocumentManager (mCfgMgr),
mViewManager (mDocumentManager), mPhysicsManager (0), mViewManager (mDocumentManager),
mIpcServerName ("org.openmw.OpenCS"), mServer(NULL), mClientSocket(NULL) mIpcServerName ("org.openmw.OpenCS"), mServer(NULL), mClientSocket(NULL), mPid(""), mLock()
{ {
std::pair<Files::PathContainer, std::vector<std::string> > config = readConfig(); std::pair<Files::PathContainer, std::vector<std::string> > config = readConfig();
@ -34,7 +36,6 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit)
ogreInit.init ((mCfgMgr.getUserConfigPath() / "opencsOgre.log").string()); ogreInit.init ((mCfgMgr.getUserConfigPath() / "opencsOgre.log").string());
mOverlaySystem.reset (new CSVRender::OverlaySystem); mOverlaySystem.reset (new CSVRender::OverlaySystem);
mPhysicsManager.reset (new CSVWorld::PhysicsManager);
Bsa::registerResources (Files::Collections (config.first, !mFsStrict), config.second, true, Bsa::registerResources (Files::Collections (config.first, !mFsStrict), config.second, true,
mFsStrict); mFsStrict);
@ -70,7 +71,15 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit)
} }
CS::Editor::~Editor () CS::Editor::~Editor ()
{} {
mPidFile.close();
if(mServer && boost::filesystem::exists(mPid))
remove(mPid.string().c_str()); // ignore any error
// cleanup global resources used by OEngine
delete OEngine::Physic::BulletShapeManager::getSingletonPtr();
}
void CS::Editor::setupDataFiles (const Files::PathContainer& dataDirs) void CS::Editor::setupDataFiles (const Files::PathContainer& dataDirs)
{ {
@ -233,7 +242,53 @@ void CS::Editor::showSettings()
bool CS::Editor::makeIPCServer() bool CS::Editor::makeIPCServer()
{ {
mServer = new QLocalServer(this); try
{
mPid = boost::filesystem::temp_directory_path();
mPid /= "opencs.pid";
bool pidExists = boost::filesystem::exists(mPid);
mPidFile.open(mPid);
mLock = boost::interprocess::file_lock(mPid.string().c_str());
if(!mLock.try_lock())
{
std::cerr << "OpenCS already running." << std::endl;
return false;
}
#ifdef _WIN32
mPidFile << GetCurrentProcessId() << std::endl;
#else
mPidFile << getpid() << std::endl;
#endif
mServer = new QLocalServer(this);
if(pidExists)
{
// hack to get the temp directory path
mServer->listen("dummy");
QString fullPath = mServer->fullServerName();
mServer->close();
fullPath.remove(QRegExp("dummy$"));
fullPath += mIpcServerName;
if(boost::filesystem::exists(fullPath.toStdString().c_str()))
{
// TODO: compare pid of the current process with that in the file
std::cout << "Detected unclean shutdown." << std::endl;
// delete the stale file
if(remove(fullPath.toStdString().c_str()))
std::cerr << "ERROR removing stale connection file" << std::endl;
}
}
}
catch(const std::exception& e)
{
std::cerr << "ERROR " << e.what() << std::endl;
return false;
}
if(mServer->listen(mIpcServerName)) if(mServer->listen(mIpcServerName))
{ {
@ -242,6 +297,7 @@ bool CS::Editor::makeIPCServer()
} }
mServer->close(); mServer->close();
mServer = NULL;
return false; return false;
} }

View file

@ -3,6 +3,9 @@
#include <memory> #include <memory>
#include <boost/interprocess/sync/file_lock.hpp>
#include <boost/filesystem/fstream.hpp>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QLocalServer> #include <QLocalServer>
@ -28,7 +31,6 @@
#include "view/settings/dialog.hpp" #include "view/settings/dialog.hpp"
#include "view/render/overlaysystem.hpp" #include "view/render/overlaysystem.hpp"
#include "view/world/physicsmanager.hpp"
namespace OgreInit namespace OgreInit
{ {
@ -45,7 +47,6 @@ namespace CS
Files::ConfigurationManager mCfgMgr; Files::ConfigurationManager mCfgMgr;
CSMSettings::UserSettings mUserSettings; CSMSettings::UserSettings mUserSettings;
std::auto_ptr<CSVRender::OverlaySystem> mOverlaySystem; std::auto_ptr<CSVRender::OverlaySystem> mOverlaySystem;
std::auto_ptr<CSVWorld::PhysicsManager> mPhysicsManager;
CSMDoc::DocumentManager mDocumentManager; CSMDoc::DocumentManager mDocumentManager;
CSVDoc::ViewManager mViewManager; CSVDoc::ViewManager mViewManager;
CSVDoc::StartupDialogue mStartup; CSVDoc::StartupDialogue mStartup;
@ -54,6 +55,9 @@ namespace CS
CSVDoc::FileDialog mFileDialog; CSVDoc::FileDialog mFileDialog;
boost::filesystem::path mLocal; boost::filesystem::path mLocal;
boost::filesystem::path mResources; boost::filesystem::path mResources;
boost::filesystem::path mPid;
boost::interprocess::file_lock mLock;
boost::filesystem::ofstream mPidFile;
bool mFsStrict; bool mFsStrict;
void setupDataFiles (const Files::PathContainer& dataDirs); void setupDataFiles (const Files::PathContainer& dataDirs);

View file

@ -83,7 +83,7 @@ int main(int argc, char *argv[])
if(!editor.makeIPCServer()) if(!editor.makeIPCServer())
{ {
editor.connectToIPCServer(); editor.connectToIPCServer();
// return 0; return 0;
} }
shinyFactory = editor.setupGraphics(); shinyFactory = editor.setupGraphics();

View file

@ -9,6 +9,8 @@
#include <components/files/configurationmanager.hpp> #include <components/files/configurationmanager.hpp>
#endif #endif
#include "../../view/world/physicssystem.hpp"
void CSMDoc::Document::addGmsts() void CSMDoc::Document::addGmsts()
{ {
static const char *gmstFloats[] = static const char *gmstFloats[] =
@ -2253,7 +2255,7 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
mProjectPath ((configuration.getUserDataPath() / "projects") / mProjectPath ((configuration.getUserDataPath() / "projects") /
(savePath.filename().string() + ".project")), (savePath.filename().string() + ".project")),
mSaving (*this, mProjectPath, encoding), mSaving (*this, mProjectPath, encoding),
mRunner (mProjectPath) mRunner (mProjectPath), mPhysics(boost::shared_ptr<CSVWorld::PhysicsSystem>())
{ {
if (mContentFiles.empty()) if (mContentFiles.empty())
throw std::runtime_error ("Empty content file sequence"); throw std::runtime_error ("Empty content file sequence");
@ -2299,8 +2301,8 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
connect (&mSaving, SIGNAL (done (int, bool)), this, SLOT (operationDone (int, bool))); connect (&mSaving, SIGNAL (done (int, bool)), this, SLOT (operationDone (int, bool)));
connect ( connect (
&mSaving, SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, int)), &mSaving, SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)),
this, SLOT (reportMessage (const CSMWorld::UniversalId&, const std::string&, int))); this, SLOT (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)));
connect (&mRunner, SIGNAL (runStateChanged()), this, SLOT (runStateChanged())); connect (&mRunner, SIGNAL (runStateChanged()), this, SLOT (runStateChanged()));
} }
@ -2385,7 +2387,7 @@ void CSMDoc::Document::modificationStateChanged (bool clean)
} }
void CSMDoc::Document::reportMessage (const CSMWorld::UniversalId& id, const std::string& message, void CSMDoc::Document::reportMessage (const CSMWorld::UniversalId& id, const std::string& message,
int type) const std::string& hint, int type)
{ {
/// \todo find a better way to get these messages to the user. /// \todo find a better way to get these messages to the user.
std::cout << message << std::endl; std::cout << message << std::endl;
@ -2464,3 +2466,11 @@ void CSMDoc::Document::progress (int current, int max, int type)
{ {
emit progress (current, max, type, 1, this); emit progress (current, max, type, 1, this);
} }
boost::shared_ptr<CSVWorld::PhysicsSystem> CSMDoc::Document::getPhysics ()
{
if(!mPhysics)
mPhysics = boost::shared_ptr<CSVWorld::PhysicsSystem> (new CSVWorld::PhysicsSystem());
return mPhysics;
}

View file

@ -3,6 +3,7 @@
#include <string> #include <string>
#include <boost/shared_ptr.hpp>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
#include <QUndoStack> #include <QUndoStack>
@ -39,6 +40,11 @@ namespace CSMWorld
class ResourcesManager; class ResourcesManager;
} }
namespace CSVWorld
{
class PhysicsSystem;
}
namespace CSMDoc namespace CSMDoc
{ {
class Document : public QObject class Document : public QObject
@ -57,6 +63,7 @@ namespace CSMDoc
boost::filesystem::path mResDir; boost::filesystem::path mResDir;
Blacklist mBlacklist; Blacklist mBlacklist;
Runner mRunner; Runner mRunner;
boost::shared_ptr<CSVWorld::PhysicsSystem> mPhysics;
// It is important that the undo stack is declared last, because on desctruction it fires a signal, that is connected to a slot, that is // It is important that the undo stack is declared last, because on desctruction it fires a signal, that is connected to a slot, that is
// using other member variables. Unfortunately this connection is cut only in the QObject destructor, which is way too late. // using other member variables. Unfortunately this connection is cut only in the QObject destructor, which is way too late.
@ -129,6 +136,8 @@ namespace CSMDoc
QTextDocument *getRunLog(); QTextDocument *getRunLog();
boost::shared_ptr<CSVWorld::PhysicsSystem> getPhysics();
signals: signals:
void stateChanged (int state, CSMDoc::Document *document); void stateChanged (int state, CSMDoc::Document *document);
@ -140,7 +149,7 @@ namespace CSMDoc
void modificationStateChanged (bool clean); void modificationStateChanged (bool clean);
void reportMessage (const CSMWorld::UniversalId& id, const std::string& message, void reportMessage (const CSMWorld::UniversalId& id, const std::string& message,
int type); const std::string& hint, int type);
void operationDone (int type, bool failed); void operationDone (int type, bool failed);

View file

@ -52,7 +52,7 @@ void CSMDoc::Loader::load()
{ {
if (iter->second.mRecordsLeft) if (iter->second.mRecordsLeft)
{ {
CSMDoc::Stage::Messages messages; CSMDoc::Messages messages;
for (int i=0; i<batchingSize; ++i) // do not flood the system with update signals for (int i=0; i<batchingSize; ++i) // do not flood the system with update signals
if (document->getData().continueLoading (messages)) if (document->getData().continueLoading (messages))
{ {
@ -65,11 +65,11 @@ void CSMDoc::Loader::load()
CSMWorld::UniversalId log (CSMWorld::UniversalId::Type_LoadErrorLog, 0); CSMWorld::UniversalId log (CSMWorld::UniversalId::Type_LoadErrorLog, 0);
{ // silence a g++ warning { // silence a g++ warning
for (CSMDoc::Stage::Messages::const_iterator iter (messages.begin()); for (CSMDoc::Messages::Iterator iter (messages.begin());
iter!=messages.end(); ++iter) iter!=messages.end(); ++iter)
{ {
document->getReport (log)->add (iter->first, iter->second); document->getReport (log)->add (iter->mId, iter->mMessage);
emit loadMessage (document, iter->second); emit loadMessage (document, iter->mMessage);
} }
} }

View file

@ -0,0 +1,28 @@
#include "messages.hpp"
void CSMDoc::Messages::add (const CSMWorld::UniversalId& id, const std::string& message,
const std::string& hint)
{
Message data;
data.mId = id;
data.mMessage = message;
data.mHint = hint;
mMessages.push_back (data);
}
void CSMDoc::Messages::push_back (const std::pair<CSMWorld::UniversalId, std::string>& data)
{
add (data.first, data.second);
}
CSMDoc::Messages::Iterator CSMDoc::Messages::begin() const
{
return mMessages.begin();
}
CSMDoc::Messages::Iterator CSMDoc::Messages::end() const
{
return mMessages.end();
}

View file

@ -0,0 +1,44 @@
#ifndef CSM_DOC_MESSAGES_H
#define CSM_DOC_MESSAGES_H
#include <string>
#include <vector>
#include "../world/universalid.hpp"
namespace CSMDoc
{
class Messages
{
public:
struct Message
{
CSMWorld::UniversalId mId;
std::string mMessage;
std::string mHint;
};
typedef std::vector<Message> Collection;
typedef Collection::const_iterator Iterator;
private:
Collection mMessages;
public:
void add (const CSMWorld::UniversalId& id, const std::string& message,
const std::string& hint = "");
/// \deprecated Use add instead.
void push_back (const std::pair<CSMWorld::UniversalId, std::string>& data);
Iterator begin() const;
Iterator end() const;
};
}
#endif

View file

@ -84,7 +84,7 @@ void CSMDoc::Operation::abort()
void CSMDoc::Operation::executeStage() void CSMDoc::Operation::executeStage()
{ {
Stage::Messages messages; Messages messages;
while (mCurrentStage!=mStages.end()) while (mCurrentStage!=mStages.end())
{ {
@ -101,7 +101,7 @@ void CSMDoc::Operation::executeStage()
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
emit reportMessage (CSMWorld::UniversalId(), e.what(), mType); emit reportMessage (CSMWorld::UniversalId(), e.what(), "", mType);
abort(); abort();
} }
@ -112,8 +112,8 @@ void CSMDoc::Operation::executeStage()
emit progress (mCurrentStepTotal, mTotalSteps ? mTotalSteps : 1, mType); emit progress (mCurrentStepTotal, mTotalSteps ? mTotalSteps : 1, mType);
for (Stage::Messages::const_iterator iter (messages.begin()); iter!=messages.end(); ++iter) for (Messages::Iterator iter (messages.begin()); iter!=messages.end(); ++iter)
emit reportMessage (iter->first, iter->second, mType); emit reportMessage (iter->mId, iter->mMessage, iter->mHint, mType);
if (mCurrentStage==mStages.end()) if (mCurrentStage==mStages.end())
exit(); exit();

View file

@ -52,7 +52,7 @@ namespace CSMDoc
void progress (int current, int max, int type); void progress (int current, int max, int type);
void reportMessage (const CSMWorld::UniversalId& id, const std::string& message, void reportMessage (const CSMWorld::UniversalId& id, const std::string& message,
int type); const std::string& hint, int type);
void done (int type, bool failed); void done (int type, bool failed);

View file

@ -6,14 +6,14 @@
#include "../world/universalid.hpp" #include "../world/universalid.hpp"
#include "messages.hpp"
namespace CSMDoc namespace CSMDoc
{ {
class Stage class Stage
{ {
public: public:
typedef std::vector<std::pair<CSMWorld::UniversalId, std::string> > Messages;
virtual ~Stage(); virtual ~Stage();
virtual int setup() = 0; virtual int setup() = 0;

View file

@ -17,7 +17,7 @@ int CSMTools::BirthsignCheckStage::setup()
return mBirthsigns.getSize(); return mBirthsigns.getSize();
} }
void CSMTools::BirthsignCheckStage::perform (int stage, Messages& messages) void CSMTools::BirthsignCheckStage::perform (int stage, CSMDoc::Messages& messages)
{ {
const CSMWorld::Record<ESM::BirthSign>& record = mBirthsigns.getRecord (stage); const CSMWorld::Record<ESM::BirthSign>& record = mBirthsigns.getRecord (stage);

View file

@ -21,7 +21,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, Messages& messages); virtual void perform (int stage, CSMDoc::Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View file

@ -14,7 +14,7 @@ int CSMTools::BodyPartCheckStage::setup()
return mBodyParts.getSize(); return mBodyParts.getSize();
} }
void CSMTools::BodyPartCheckStage::perform ( int stage, Messages &messages ) void CSMTools::BodyPartCheckStage::perform (int stage, CSMDoc::Messages &messages)
{ {
const CSMWorld::Record<ESM::BodyPart> &record = mBodyParts.getRecord(stage); const CSMWorld::Record<ESM::BodyPart> &record = mBodyParts.getRecord(stage);

View file

@ -27,7 +27,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform( int stage, Messages &messages ); virtual void perform( int stage, CSMDoc::Messages &messages );
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View file

@ -18,7 +18,7 @@ int CSMTools::ClassCheckStage::setup()
return mClasses.getSize(); return mClasses.getSize();
} }
void CSMTools::ClassCheckStage::perform (int stage, Messages& messages) void CSMTools::ClassCheckStage::perform (int stage, CSMDoc::Messages& messages)
{ {
const CSMWorld::Record<ESM::Class>& record = mClasses.getRecord (stage); const CSMWorld::Record<ESM::Class>& record = mClasses.getRecord (stage);

View file

@ -21,7 +21,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, Messages& messages); virtual void perform (int stage, CSMDoc::Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View file

@ -18,7 +18,7 @@ int CSMTools::FactionCheckStage::setup()
return mFactions.getSize(); return mFactions.getSize();
} }
void CSMTools::FactionCheckStage::perform (int stage, Messages& messages) void CSMTools::FactionCheckStage::perform (int stage, CSMDoc::Messages& messages)
{ {
const CSMWorld::Record<ESM::Faction>& record = mFactions.getRecord (stage); const CSMWorld::Record<ESM::Faction>& record = mFactions.getRecord (stage);

View file

@ -21,7 +21,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, Messages& messages); virtual void perform (int stage, CSMDoc::Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View file

@ -15,10 +15,9 @@ int CSMTools::MandatoryIdStage::setup()
return mIds.size(); return mIds.size();
} }
void CSMTools::MandatoryIdStage::perform (int stage, Messages& messages) void CSMTools::MandatoryIdStage::perform (int stage, CSMDoc::Messages& messages)
{ {
if (mIdCollection.searchId (mIds.at (stage))==-1 || if (mIdCollection.searchId (mIds.at (stage))==-1 ||
mIdCollection.getRecord (mIds.at (stage)).isDeleted()) mIdCollection.getRecord (mIds.at (stage)).isDeleted())
messages.push_back (std::make_pair (mCollectionId, messages.add (mCollectionId, "Missing mandatory record: " + mIds.at (stage));
"Missing mandatory record: " + mIds.at (stage)));
} }

View file

@ -30,7 +30,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, Messages& messages); virtual void perform (int stage, CSMDoc::Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View file

@ -7,7 +7,7 @@
#include "../world/universalid.hpp" #include "../world/universalid.hpp"
void CSMTools::RaceCheckStage::performPerRecord (int stage, Messages& messages) void CSMTools::RaceCheckStage::performPerRecord (int stage, CSMDoc::Messages& messages)
{ {
const CSMWorld::Record<ESM::Race>& record = mRaces.getRecord (stage); const CSMWorld::Record<ESM::Race>& record = mRaces.getRecord (stage);
@ -46,7 +46,7 @@ void CSMTools::RaceCheckStage::performPerRecord (int stage, Messages& messages)
/// \todo check data members that can't be edited in the table view /// \todo check data members that can't be edited in the table view
} }
void CSMTools::RaceCheckStage::performFinal (Messages& messages) void CSMTools::RaceCheckStage::performFinal (CSMDoc::Messages& messages)
{ {
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Races); CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Races);
@ -64,7 +64,7 @@ int CSMTools::RaceCheckStage::setup()
return mRaces.getSize()+1; return mRaces.getSize()+1;
} }
void CSMTools::RaceCheckStage::perform (int stage, Messages& messages) void CSMTools::RaceCheckStage::perform (int stage, CSMDoc::Messages& messages)
{ {
if (stage==mRaces.getSize()) if (stage==mRaces.getSize())
performFinal (messages); performFinal (messages);

View file

@ -15,9 +15,9 @@ namespace CSMTools
const CSMWorld::IdCollection<ESM::Race>& mRaces; const CSMWorld::IdCollection<ESM::Race>& mRaces;
bool mPlayable; bool mPlayable;
void performPerRecord (int stage, Messages& messages); void performPerRecord (int stage, CSMDoc::Messages& messages);
void performFinal (Messages& messages); void performFinal (CSMDoc::Messages& messages);
public: public:
@ -26,7 +26,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, Messages& messages); virtual void perform (int stage, CSMDoc::Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View file

@ -18,7 +18,7 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(
{ {
} }
void CSMTools::ReferenceableCheckStage::perform (int stage, Messages& messages) void CSMTools::ReferenceableCheckStage::perform (int stage, CSMDoc::Messages& messages)
{ {
//Checks for books, than, when stage is above mBooksSize goes to other checks, with (stage - PrevSum) as stage. //Checks for books, than, when stage is above mBooksSize goes to other checks, with (stage - PrevSum) as stage.
const int bookSize(mReferencables.getBooks().getSize()); const int bookSize(mReferencables.getBooks().getSize());
@ -232,7 +232,7 @@ int CSMTools::ReferenceableCheckStage::setup()
void CSMTools::ReferenceableCheckStage::bookCheck( void CSMTools::ReferenceableCheckStage::bookCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Book >& records, const CSMWorld::RefIdDataContainer< ESM::Book >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -250,7 +250,7 @@ void CSMTools::ReferenceableCheckStage::bookCheck(
void CSMTools::ReferenceableCheckStage::activatorCheck( void CSMTools::ReferenceableCheckStage::activatorCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Activator >& records, const CSMWorld::RefIdDataContainer< ESM::Activator >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -270,7 +270,7 @@ void CSMTools::ReferenceableCheckStage::activatorCheck(
void CSMTools::ReferenceableCheckStage::potionCheck( void CSMTools::ReferenceableCheckStage::potionCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Potion >& records, const CSMWorld::RefIdDataContainer< ESM::Potion >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -290,7 +290,7 @@ void CSMTools::ReferenceableCheckStage::potionCheck(
void CSMTools::ReferenceableCheckStage::apparatusCheck( void CSMTools::ReferenceableCheckStage::apparatusCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Apparatus >& records, const CSMWorld::RefIdDataContainer< ESM::Apparatus >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -310,7 +310,7 @@ void CSMTools::ReferenceableCheckStage::apparatusCheck(
void CSMTools::ReferenceableCheckStage::armorCheck( void CSMTools::ReferenceableCheckStage::armorCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Armor >& records, const CSMWorld::RefIdDataContainer< ESM::Armor >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -336,7 +336,7 @@ void CSMTools::ReferenceableCheckStage::armorCheck(
void CSMTools::ReferenceableCheckStage::clothingCheck( void CSMTools::ReferenceableCheckStage::clothingCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Clothing >& records, const CSMWorld::RefIdDataContainer< ESM::Clothing >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -353,7 +353,7 @@ void CSMTools::ReferenceableCheckStage::clothingCheck(
void CSMTools::ReferenceableCheckStage::containerCheck( void CSMTools::ReferenceableCheckStage::containerCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Container >& records, const CSMWorld::RefIdDataContainer< ESM::Container >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -381,7 +381,7 @@ void CSMTools::ReferenceableCheckStage::containerCheck(
void CSMTools::ReferenceableCheckStage::creatureCheck ( void CSMTools::ReferenceableCheckStage::creatureCheck (
int stage, const CSMWorld::RefIdDataContainer< ESM::Creature >& records, int stage, const CSMWorld::RefIdDataContainer< ESM::Creature >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -448,7 +448,7 @@ void CSMTools::ReferenceableCheckStage::creatureCheck (
void CSMTools::ReferenceableCheckStage::doorCheck( void CSMTools::ReferenceableCheckStage::doorCheck(
int stage, const CSMWorld::RefIdDataContainer< ESM::Door >& records, int stage, const CSMWorld::RefIdDataContainer< ESM::Door >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -469,7 +469,7 @@ void CSMTools::ReferenceableCheckStage::doorCheck(
void CSMTools::ReferenceableCheckStage::ingredientCheck( void CSMTools::ReferenceableCheckStage::ingredientCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Ingredient >& records, const CSMWorld::RefIdDataContainer< ESM::Ingredient >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -487,7 +487,7 @@ void CSMTools::ReferenceableCheckStage::ingredientCheck(
void CSMTools::ReferenceableCheckStage::creaturesLevListCheck( void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::CreatureLevList >& records, const CSMWorld::RefIdDataContainer< ESM::CreatureLevList >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -505,7 +505,7 @@ void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(
void CSMTools::ReferenceableCheckStage::itemLevelledListCheck( void CSMTools::ReferenceableCheckStage::itemLevelledListCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::ItemLevList >& records, const CSMWorld::RefIdDataContainer< ESM::ItemLevList >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -522,7 +522,7 @@ void CSMTools::ReferenceableCheckStage::itemLevelledListCheck(
void CSMTools::ReferenceableCheckStage::lightCheck( void CSMTools::ReferenceableCheckStage::lightCheck(
int stage, const CSMWorld::RefIdDataContainer< ESM::Light >& records, int stage, const CSMWorld::RefIdDataContainer< ESM::Light >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -547,7 +547,7 @@ void CSMTools::ReferenceableCheckStage::lightCheck(
void CSMTools::ReferenceableCheckStage::lockpickCheck( void CSMTools::ReferenceableCheckStage::lockpickCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Lockpick >& records, const CSMWorld::RefIdDataContainer< ESM::Lockpick >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -567,7 +567,7 @@ void CSMTools::ReferenceableCheckStage::lockpickCheck(
void CSMTools::ReferenceableCheckStage::miscCheck( void CSMTools::ReferenceableCheckStage::miscCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Miscellaneous >& records, const CSMWorld::RefIdDataContainer< ESM::Miscellaneous >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -584,7 +584,7 @@ void CSMTools::ReferenceableCheckStage::miscCheck(
void CSMTools::ReferenceableCheckStage::npcCheck ( void CSMTools::ReferenceableCheckStage::npcCheck (
int stage, const CSMWorld::RefIdDataContainer< ESM::NPC >& records, int stage, const CSMWorld::RefIdDataContainer< ESM::NPC >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -701,7 +701,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck (
void CSMTools::ReferenceableCheckStage::weaponCheck( void CSMTools::ReferenceableCheckStage::weaponCheck(
int stage, const CSMWorld::RefIdDataContainer< ESM::Weapon >& records, int stage, const CSMWorld::RefIdDataContainer< ESM::Weapon >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord (stage); const CSMWorld::RecordBase& baseRecord = records.getRecord (stage);
@ -778,7 +778,7 @@ void CSMTools::ReferenceableCheckStage::weaponCheck(
void CSMTools::ReferenceableCheckStage::probeCheck( void CSMTools::ReferenceableCheckStage::probeCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Probe >& records, const CSMWorld::RefIdDataContainer< ESM::Probe >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -796,7 +796,7 @@ void CSMTools::ReferenceableCheckStage::probeCheck(
void CSMTools::ReferenceableCheckStage::repairCheck ( void CSMTools::ReferenceableCheckStage::repairCheck (
int stage, const CSMWorld::RefIdDataContainer< ESM::Repair >& records, int stage, const CSMWorld::RefIdDataContainer< ESM::Repair >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord (stage); const CSMWorld::RecordBase& baseRecord = records.getRecord (stage);
@ -812,7 +812,7 @@ void CSMTools::ReferenceableCheckStage::repairCheck (
void CSMTools::ReferenceableCheckStage::staticCheck ( void CSMTools::ReferenceableCheckStage::staticCheck (
int stage, const CSMWorld::RefIdDataContainer< ESM::Static >& records, int stage, const CSMWorld::RefIdDataContainer< ESM::Static >& records,
Messages& messages) CSMDoc::Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord (stage); const CSMWorld::RecordBase& baseRecord = records.getRecord (stage);
@ -828,7 +828,7 @@ void CSMTools::ReferenceableCheckStage::staticCheck (
//final check //final check
void CSMTools::ReferenceableCheckStage::finalCheck (Messages& messages) void CSMTools::ReferenceableCheckStage::finalCheck (CSMDoc::Messages& messages)
{ {
if (!mPlayerPresent) if (!mPlayerPresent)
messages.push_back (std::make_pair (CSMWorld::UniversalId::Type_Referenceables, messages.push_back (std::make_pair (CSMWorld::UniversalId::Type_Referenceables,
@ -839,7 +839,7 @@ void CSMTools::ReferenceableCheckStage::finalCheck (Messages& messages)
//Templates begins here //Templates begins here
template<typename Item> void CSMTools::ReferenceableCheckStage::inventoryItemCheck ( template<typename Item> void CSMTools::ReferenceableCheckStage::inventoryItemCheck (
const Item& someItem, Messages& messages, const std::string& someID, bool enchantable) const Item& someItem, CSMDoc::Messages& messages, const std::string& someID, bool enchantable)
{ {
if (someItem.mName.empty()) if (someItem.mName.empty())
messages.push_back (std::make_pair (someID, someItem.mId + " has an empty name")); messages.push_back (std::make_pair (someID, someItem.mId + " has an empty name"));
@ -865,7 +865,7 @@ template<typename Item> void CSMTools::ReferenceableCheckStage::inventoryItemChe
} }
template<typename Item> void CSMTools::ReferenceableCheckStage::inventoryItemCheck ( template<typename Item> void CSMTools::ReferenceableCheckStage::inventoryItemCheck (
const Item& someItem, Messages& messages, const std::string& someID) const Item& someItem, CSMDoc::Messages& messages, const std::string& someID)
{ {
if (someItem.mName.empty()) if (someItem.mName.empty())
messages.push_back (std::make_pair (someID, someItem.mId + " has an empty name")); messages.push_back (std::make_pair (someID, someItem.mId + " has an empty name"));
@ -888,7 +888,7 @@ template<typename Item> void CSMTools::ReferenceableCheckStage::inventoryItemChe
} }
template<typename Tool> void CSMTools::ReferenceableCheckStage::toolCheck ( template<typename Tool> void CSMTools::ReferenceableCheckStage::toolCheck (
const Tool& someTool, Messages& messages, const std::string& someID, bool canBeBroken) const Tool& someTool, CSMDoc::Messages& messages, const std::string& someID, bool canBeBroken)
{ {
if (someTool.mData.mQuality <= 0) if (someTool.mData.mQuality <= 0)
messages.push_back (std::make_pair (someID, someTool.mId + " has non-positive quality")); messages.push_back (std::make_pair (someID, someTool.mId + " has non-positive quality"));
@ -899,14 +899,14 @@ template<typename Tool> void CSMTools::ReferenceableCheckStage::toolCheck (
} }
template<typename Tool> void CSMTools::ReferenceableCheckStage::toolCheck ( template<typename Tool> void CSMTools::ReferenceableCheckStage::toolCheck (
const Tool& someTool, Messages& messages, const std::string& someID) const Tool& someTool, CSMDoc::Messages& messages, const std::string& someID)
{ {
if (someTool.mData.mQuality <= 0) if (someTool.mData.mQuality <= 0)
messages.push_back (std::make_pair (someID, someTool.mId + " has non-positive quality")); messages.push_back (std::make_pair (someID, someTool.mId + " has non-positive quality"));
} }
template<typename List> void CSMTools::ReferenceableCheckStage::listCheck ( template<typename List> void CSMTools::ReferenceableCheckStage::listCheck (
const List& someList, Messages& messages, const std::string& someID) const List& someList, CSMDoc::Messages& messages, const std::string& someID)
{ {
for (unsigned i = 0; i < someList.mList.size(); ++i) for (unsigned i = 0; i < someList.mList.size(); ++i)
{ {

View file

@ -17,56 +17,56 @@ namespace CSMTools
const CSMWorld::IdCollection<ESM::Class>& classes, const CSMWorld::IdCollection<ESM::Class>& classes,
const CSMWorld::IdCollection<ESM::Faction>& factions); const CSMWorld::IdCollection<ESM::Faction>& factions);
virtual void perform(int stage, Messages& messages); virtual void perform(int stage, CSMDoc::Messages& messages);
virtual int setup(); virtual int setup();
private: private:
//CONCRETE CHECKS //CONCRETE CHECKS
void bookCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Book >& records, Messages& messages); void bookCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Book >& records, CSMDoc::Messages& messages);
void activatorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Activator >& records, Messages& messages); void activatorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Activator >& records, CSMDoc::Messages& messages);
void potionCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Potion>& records, Messages& messages); void potionCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Potion>& records, CSMDoc::Messages& messages);
void apparatusCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Apparatus>& records, Messages& messages); void apparatusCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Apparatus>& records, CSMDoc::Messages& messages);
void armorCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Armor>& records, Messages& messages); void armorCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Armor>& records, CSMDoc::Messages& messages);
void clothingCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Clothing>& records, Messages& messages); void clothingCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Clothing>& records, CSMDoc::Messages& messages);
void containerCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Container>& records, Messages& messages); void containerCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Container>& records, CSMDoc::Messages& messages);
void creatureCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Creature>& records, Messages& messages); void creatureCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Creature>& records, CSMDoc::Messages& messages);
void doorCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Door>& records, Messages& messages); void doorCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Door>& records, CSMDoc::Messages& messages);
void ingredientCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Ingredient>& records, Messages& messages); void ingredientCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Ingredient>& records, CSMDoc::Messages& messages);
void creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::CreatureLevList>& records, Messages& messages); void creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::CreatureLevList>& records, CSMDoc::Messages& messages);
void itemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::ItemLevList>& records, Messages& messages); void itemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::ItemLevList>& records, CSMDoc::Messages& messages);
void lightCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Light>& records, Messages& messages); void lightCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Light>& records, CSMDoc::Messages& messages);
void lockpickCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Lockpick>& records, Messages& messages); void lockpickCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Lockpick>& records, CSMDoc::Messages& messages);
void miscCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Miscellaneous>& records, Messages& messages); void miscCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Miscellaneous>& records, CSMDoc::Messages& messages);
void npcCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::NPC>& records, Messages& messages); void npcCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::NPC>& records, CSMDoc::Messages& messages);
void weaponCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Weapon>& records, Messages& messages); void weaponCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Weapon>& records, CSMDoc::Messages& messages);
void probeCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Probe>& records, Messages& messages); void probeCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Probe>& records, CSMDoc::Messages& messages);
void repairCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Repair>& records, Messages& messages); void repairCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Repair>& records, CSMDoc::Messages& messages);
void staticCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Static>& records, Messages& messages); void staticCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Static>& records, CSMDoc::Messages& messages);
//FINAL CHECK //FINAL CHECK
void finalCheck (Messages& messages); void finalCheck (CSMDoc::Messages& messages);
//TEMPLATE CHECKS //TEMPLATE CHECKS
template<typename ITEM> void inventoryItemCheck(const ITEM& someItem, template<typename ITEM> void inventoryItemCheck(const ITEM& someItem,
Messages& messages, CSMDoc::Messages& messages,
const std::string& someID, const std::string& someID,
bool enchantable); //for all enchantable items. bool enchantable); //for all enchantable items.
template<typename ITEM> void inventoryItemCheck(const ITEM& someItem, template<typename ITEM> void inventoryItemCheck(const ITEM& someItem,
Messages& messages, CSMDoc::Messages& messages,
const std::string& someID); //for non-enchantable items. const std::string& someID); //for non-enchantable items.
template<typename TOOL> void toolCheck(const TOOL& someTool, template<typename TOOL> void toolCheck(const TOOL& someTool,
Messages& messages, CSMDoc::Messages& messages,
const std::string& someID, const std::string& someID,
bool canbebroken); //for tools with uses. bool canbebroken); //for tools with uses.
template<typename TOOL> void toolCheck(const TOOL& someTool, template<typename TOOL> void toolCheck(const TOOL& someTool,
Messages& messages, CSMDoc::Messages& messages,
const std::string& someID); //for tools without uses. const std::string& someID); //for tools without uses.
template<typename LIST> void listCheck(const LIST& someList, template<typename LIST> void listCheck(const LIST& someList,
Messages& messages, CSMDoc::Messages& messages,
const std::string& someID); const std::string& someID);
const CSMWorld::RefIdData& mReferencables; const CSMWorld::RefIdData& mReferencables;

View file

@ -17,7 +17,7 @@ int CSMTools::RegionCheckStage::setup()
return mRegions.getSize(); return mRegions.getSize();
} }
void CSMTools::RegionCheckStage::perform (int stage, Messages& messages) void CSMTools::RegionCheckStage::perform (int stage, CSMDoc::Messages& messages)
{ {
const CSMWorld::Record<ESM::Region>& record = mRegions.getRecord (stage); const CSMWorld::Record<ESM::Region>& record = mRegions.getRecord (stage);

View file

@ -21,7 +21,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, Messages& messages); virtual void perform (int stage, CSMDoc::Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View file

@ -16,7 +16,7 @@ int CSMTools::ReportModel::columnCount (const QModelIndex & parent) const
if (parent.isValid()) if (parent.isValid())
return 0; return 0;
return 2; return 3;
} }
QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const
@ -26,8 +26,11 @@ QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const
if (index.column()==0) if (index.column()==0)
return static_cast<int> (mRows.at (index.row()).first.getType()); return static_cast<int> (mRows.at (index.row()).first.getType());
else
return mRows.at (index.row()).second.c_str(); if (index.column()==1)
return QString::fromUtf8 (mRows.at (index.row()).second.first.c_str());
return QString::fromUtf8 (mRows.at (index.row()).second.second.c_str());
} }
QVariant CSMTools::ReportModel::headerData (int section, Qt::Orientation orientation, int role) const QVariant CSMTools::ReportModel::headerData (int section, Qt::Orientation orientation, int role) const
@ -38,7 +41,13 @@ QVariant CSMTools::ReportModel::headerData (int section, Qt::Orientation orienta
if (orientation==Qt::Vertical) if (orientation==Qt::Vertical)
return QVariant(); return QVariant();
return tr (section==0 ? "Type" : "Description"); if (section==0)
return "Type";
if (section==1)
return "Description";
return "Hint";
} }
bool CSMTools::ReportModel::removeRows (int row, int count, const QModelIndex& parent) bool CSMTools::ReportModel::removeRows (int row, int count, const QModelIndex& parent)
@ -51,11 +60,12 @@ bool CSMTools::ReportModel::removeRows (int row, int count, const QModelIndex& p
return true; return true;
} }
void CSMTools::ReportModel::add (const CSMWorld::UniversalId& id, const std::string& message) void CSMTools::ReportModel::add (const CSMWorld::UniversalId& id, const std::string& message,
const std::string& hint)
{ {
beginInsertRows (QModelIndex(), mRows.size(), mRows.size()); beginInsertRows (QModelIndex(), mRows.size(), mRows.size());
mRows.push_back (std::make_pair (id, message)); mRows.push_back (std::make_pair (id, std::make_pair (message, hint)));
endInsertRows(); endInsertRows();
} }
@ -64,3 +74,8 @@ const CSMWorld::UniversalId& CSMTools::ReportModel::getUniversalId (int row) con
{ {
return mRows.at (row).first; return mRows.at (row).first;
} }
std::string CSMTools::ReportModel::getHint (int row) const
{
return mRows.at (row).second.second;
}

View file

@ -14,7 +14,7 @@ namespace CSMTools
{ {
Q_OBJECT Q_OBJECT
std::vector<std::pair<CSMWorld::UniversalId, std::string> > mRows; std::vector<std::pair<CSMWorld::UniversalId, std::pair<std::string, std::string> > > mRows;
public: public:
@ -28,9 +28,12 @@ namespace CSMTools
virtual bool removeRows (int row, int count, const QModelIndex& parent = QModelIndex()); virtual bool removeRows (int row, int count, const QModelIndex& parent = QModelIndex());
void add (const CSMWorld::UniversalId& id, const std::string& message); void add (const CSMWorld::UniversalId& id, const std::string& message,
const std::string& hint = "");
const CSMWorld::UniversalId& getUniversalId (int row) const; const CSMWorld::UniversalId& getUniversalId (int row) const;
std::string getHint (int row) const;
}; };
} }

View file

@ -28,7 +28,11 @@ void CSMTools::ScriptCheckStage::report (const std::string& message, const Compi
<< ", line " << loc.mLine << ", column " << loc.mColumn << ", line " << loc.mLine << ", column " << loc.mColumn
<< " (" << loc.mLiteral << "): " << message; << " (" << loc.mLiteral << "): " << message;
mMessages->push_back (std::make_pair (id, stream.str())); std::ostringstream hintStream;
hintStream << "l:" << loc.mLine << " " << loc.mColumn;
mMessages->add (id, stream.str(), hintStream.str());
} }
void CSMTools::ScriptCheckStage::report (const std::string& message, Type type) void CSMTools::ScriptCheckStage::report (const std::string& message, Type type)
@ -58,7 +62,7 @@ int CSMTools::ScriptCheckStage::setup()
return mDocument.getData().getScripts().getSize(); return mDocument.getData().getScripts().getSize();
} }
void CSMTools::ScriptCheckStage::perform (int stage, Messages& messages) void CSMTools::ScriptCheckStage::perform (int stage, CSMDoc::Messages& messages)
{ {
mId = mDocument.getData().getScripts().getId (stage); mId = mDocument.getData().getScripts().getId (stage);

View file

@ -23,7 +23,7 @@ namespace CSMTools
CSMWorld::ScriptContext mContext; CSMWorld::ScriptContext mContext;
std::string mId; std::string mId;
std::string mFile; std::string mFile;
Messages *mMessages; CSMDoc::Messages *mMessages;
virtual void report (const std::string& message, const Compiler::TokenLoc& loc, Type type); virtual void report (const std::string& message, const Compiler::TokenLoc& loc, Type type);
///< Report error to the user. ///< Report error to the user.
@ -38,7 +38,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, Messages& messages); virtual void perform (int stage, CSMDoc::Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View file

@ -16,7 +16,7 @@ int CSMTools::SkillCheckStage::setup()
return mSkills.getSize(); return mSkills.getSize();
} }
void CSMTools::SkillCheckStage::perform (int stage, Messages& messages) void CSMTools::SkillCheckStage::perform (int stage, CSMDoc::Messages& messages)
{ {
const CSMWorld::Record<ESM::Skill>& record = mSkills.getRecord (stage); const CSMWorld::Record<ESM::Skill>& record = mSkills.getRecord (stage);

View file

@ -21,7 +21,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, Messages& messages); virtual void perform (int stage, CSMDoc::Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View file

@ -16,7 +16,7 @@ int CSMTools::SoundCheckStage::setup()
return mSounds.getSize(); return mSounds.getSize();
} }
void CSMTools::SoundCheckStage::perform (int stage, Messages& messages) void CSMTools::SoundCheckStage::perform (int stage, CSMDoc::Messages& messages)
{ {
const CSMWorld::Record<ESM::Sound>& record = mSounds.getRecord (stage); const CSMWorld::Record<ESM::Sound>& record = mSounds.getRecord (stage);

View file

@ -21,7 +21,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, Messages& messages); virtual void perform (int stage, CSMDoc::Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View file

@ -17,7 +17,7 @@ int CSMTools::SpellCheckStage::setup()
return mSpells.getSize(); return mSpells.getSize();
} }
void CSMTools::SpellCheckStage::perform (int stage, Messages& messages) void CSMTools::SpellCheckStage::perform (int stage, CSMDoc::Messages& messages)
{ {
const CSMWorld::Record<ESM::Spell>& record = mSpells.getRecord (stage); const CSMWorld::Record<ESM::Spell>& record = mSpells.getRecord (stage);

View file

@ -21,7 +21,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, Messages& messages); virtual void perform (int stage, CSMDoc::Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View file

@ -48,8 +48,8 @@ CSMDoc::Operation *CSMTools::Tools::getVerifier()
connect (mVerifier, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int))); connect (mVerifier, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int)));
connect (mVerifier, SIGNAL (done (int, bool)), this, SIGNAL (done (int, bool))); connect (mVerifier, SIGNAL (done (int, bool)), this, SIGNAL (done (int, bool)));
connect (mVerifier, connect (mVerifier,
SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, int)), SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)),
this, SLOT (verifierMessage (const CSMWorld::UniversalId&, const std::string&, int))); this, SLOT (verifierMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)));
std::vector<std::string> mandatoryIds; // I want C++11, damn it! std::vector<std::string> mandatoryIds; // I want C++11, damn it!
mandatoryIds.push_back ("Day"); mandatoryIds.push_back ("Day");
@ -155,11 +155,11 @@ CSMTools::ReportModel *CSMTools::Tools::getReport (const CSMWorld::UniversalId&
} }
void CSMTools::Tools::verifierMessage (const CSMWorld::UniversalId& id, const std::string& message, void CSMTools::Tools::verifierMessage (const CSMWorld::UniversalId& id, const std::string& message,
int type) const std::string& hint, int type)
{ {
std::map<int, int>::iterator iter = mActiveReports.find (type); std::map<int, int>::iterator iter = mActiveReports.find (type);
if (iter!=mActiveReports.end()) if (iter!=mActiveReports.end())
mReports[iter->second]->add (id, message); mReports[iter->second]->add (id, message, hint);
} }

View file

@ -64,7 +64,7 @@ namespace CSMTools
private slots: private slots:
void verifierMessage (const CSMWorld::UniversalId& id, const std::string& message, void verifierMessage (const CSMWorld::UniversalId& id, const std::string& message,
int type); const std::string& hint, int type);
signals: signals:

View file

@ -272,7 +272,7 @@ namespace CSMWorld
{ {
ESXRecordT record2 = record.get(); ESXRecordT record2 = record.get();
record2.mData.mUseValue[mIndex] = data.toInt(); record2.mData.mUseValue[mIndex] = data.toFloat();
record.setModified (record2); record.setModified (record2);
} }

View file

@ -671,16 +671,24 @@ int CSMWorld::Data::startLoading (const boost::filesystem::path& path, bool base
return mReader->getRecordCount(); return mReader->getRecordCount();
} }
bool CSMWorld::Data::continueLoading (CSMDoc::Stage::Messages& messages) bool CSMWorld::Data::continueLoading (CSMDoc::Messages& messages)
{ {
if (!mReader) if (!mReader)
throw std::logic_error ("can't continue loading, because no load has been started"); throw std::logic_error ("can't continue loading, because no load has been started");
if (!mReader->hasMoreRecs()) if (!mReader->hasMoreRecs())
{ {
// Don't delete the Reader yet. Some record types store a reference to the Reader to handle on-demand loading if (mBase)
boost::shared_ptr<ESM::ESMReader> ptr(mReader); {
mReaders.push_back(ptr); // Don't delete the Reader yet. Some record types store a reference to the Reader to handle on-demand loading.
// We don't store non-base reader, because everything going into modified will be
// fully loaded during the initial loading process.
boost::shared_ptr<ESM::ESMReader> ptr(mReader);
mReaders.push_back(ptr);
}
else
delete mReader;
mReader = 0; mReader = 0;
mDialogue = 0; mDialogue = 0;
@ -713,7 +721,18 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Stage::Messages& messages)
case ESM::REC_PGRD: mPathgrids.load (*mReader, mBase); break; case ESM::REC_PGRD: mPathgrids.load (*mReader, mBase); break;
case ESM::REC_LTEX: mLandTextures.load (*mReader, mBase); break; case ESM::REC_LTEX: mLandTextures.load (*mReader, mBase); break;
case ESM::REC_LAND: mLand.load(*mReader, mBase); break;
case ESM::REC_LAND:
{
int index = mLand.load(*mReader, mBase);
if (index!=-1 && !mBase)
mLand.getRecord (index).mModified.mLand->loadData (
ESM::Land::DATA_VHGT | ESM::Land::DATA_VNML | ESM::Land::DATA_VCLR |
ESM::Land::DATA_VTEX);
break;
}
case ESM::REC_CELL: case ESM::REC_CELL:
{ {
@ -775,8 +794,8 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Stage::Messages& messages)
} }
else else
{ {
messages.push_back (std::make_pair (UniversalId::Type_None, messages.add (UniversalId::Type_None,
"Trying to delete dialogue record " + id + " which does not exist")); "Trying to delete dialogue record " + id + " which does not exist");
} }
} }
else else
@ -792,8 +811,8 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Stage::Messages& messages)
{ {
if (!mDialogue) if (!mDialogue)
{ {
messages.push_back (std::make_pair (UniversalId::Type_None, messages.add (UniversalId::Type_None,
"Found info record not following a dialogue record")); "Found info record not following a dialogue record");
mReader->skipRecord(); mReader->skipRecord();
break; break;
@ -836,8 +855,7 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Stage::Messages& messages)
if (unhandledRecord) if (unhandledRecord)
{ {
messages.push_back (std::make_pair (UniversalId::Type_None, messages.add (UniversalId::Type_None, "Unsupported record type: " + n.toString());
"Unsupported record type: " + n.toString()));
mReader->skipRecord(); mReader->skipRecord();
} }

View file

@ -244,7 +244,7 @@ namespace CSMWorld
/// ///
///< \return estimated number of records ///< \return estimated number of records
bool continueLoading (CSMDoc::Stage::Messages& messages); bool continueLoading (CSMDoc::Messages& messages);
///< \return Finished? ///< \return Finished?
bool hasId (const std::string& id) const; bool hasId (const std::string& id) const;

View file

@ -15,12 +15,15 @@ namespace CSMWorld
public: public:
void load (ESM::ESMReader& reader, bool base); /// \return Index of loaded record (-1 if no record was loaded)
int load (ESM::ESMReader& reader, bool base);
/// \param index Index at which the record can be found. /// \param index Index at which the record can be found.
/// Special values: -2 index unknown, -1 record does not exist yet and therefore /// Special values: -2 index unknown, -1 record does not exist yet and therefore
/// does not have an index /// does not have an index
void load (const ESXRecordT& record, bool base, int index = -2); ///
/// \return index
int load (const ESXRecordT& record, bool base, int index = -2);
bool tryDelete (const std::string& id); bool tryDelete (const std::string& id);
///< Try deleting \a id. If the id does not exist or can't be deleted the call is ignored. ///< Try deleting \a id. If the id does not exist or can't be deleted the call is ignored.
@ -36,7 +39,7 @@ namespace CSMWorld
} }
template<typename ESXRecordT, typename IdAccessorT> template<typename ESXRecordT, typename IdAccessorT>
void IdCollection<ESXRecordT, IdAccessorT>::load (ESM::ESMReader& reader, bool base) int IdCollection<ESXRecordT, IdAccessorT>::load (ESM::ESMReader& reader, bool base)
{ {
std::string id = reader.getHNOString ("NAME"); std::string id = reader.getHNOString ("NAME");
@ -64,6 +67,8 @@ namespace CSMWorld
record.mState = RecordBase::State_Deleted; record.mState = RecordBase::State_Deleted;
this->setRecord (index, record); this->setRecord (index, record);
} }
return -1;
} }
else else
{ {
@ -88,12 +93,12 @@ namespace CSMWorld
index = newIndex; index = newIndex;
} }
load (record, base, index); return load (record, base, index);
} }
} }
template<typename ESXRecordT, typename IdAccessorT> template<typename ESXRecordT, typename IdAccessorT>
void IdCollection<ESXRecordT, IdAccessorT>::load (const ESXRecordT& record, bool base, int IdCollection<ESXRecordT, IdAccessorT>::load (const ESXRecordT& record, bool base,
int index) int index)
{ {
if (index==-2) if (index==-2)
@ -106,6 +111,7 @@ namespace CSMWorld
record2.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly; record2.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
(base ? record2.mBase : record2.mModified) = record; (base ? record2.mBase : record2.mModified) = record;
index = this->getSize();
this->appendRecord (record2); this->appendRecord (record2);
} }
else else
@ -120,6 +126,8 @@ namespace CSMWorld
this->setRecord (index, record2); this->setRecord (index, record2);
} }
return index;
} }
template<typename ESXRecordT, typename IdAccessorT> template<typename ESXRecordT, typename IdAccessorT>

View file

@ -11,7 +11,7 @@
#include "record.hpp" #include "record.hpp"
void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool base, void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool base,
std::map<ESM::RefNum, std::string>& cache, CSMDoc::Stage::Messages& messages) std::map<ESM::RefNum, std::string>& cache, CSMDoc::Messages& messages)
{ {
Record<Cell> cell = mCells.getRecord (cellIndex); Record<Cell> cell = mCells.getRecord (cellIndex);
@ -36,8 +36,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Cell, CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Cell,
mCells.getId (cellIndex)); mCells.getId (cellIndex));
messages.push_back (std::make_pair (id, messages.add (id, "Attempt to delete a non-existing reference");
"Attempt to delete a non-existing reference"));
continue; continue;
} }

View file

@ -28,7 +28,7 @@ namespace CSMWorld
void load (ESM::ESMReader& reader, int cellIndex, bool base, void load (ESM::ESMReader& reader, int cellIndex, bool base,
std::map<ESM::RefNum, std::string>& cache, std::map<ESM::RefNum, std::string>& cache,
CSMDoc::Stage::Messages& messages); CSMDoc::Messages& messages);
///< Load a sequence of references. ///< Load a sequence of references.
std::string getNewId(); std::string getNewId();

View file

@ -3,6 +3,7 @@
#include <sstream> #include <sstream>
#include <stdexcept> #include <stdexcept>
#include <algorithm>
#include <OgreResourceGroupManager.h> #include <OgreResourceGroupManager.h>
@ -55,7 +56,9 @@ CSMWorld::Resources::Resources (const std::string& baseDirectory, UniversalId::T
std::string file = iter->substr (baseSize+1); std::string file = iter->substr (baseSize+1);
mFiles.push_back (file); mFiles.push_back (file);
mIndex.insert (std::make_pair (file, static_cast<int> (mFiles.size())-1)); std::replace (file.begin(), file.end(), '\\', '/');
mIndex.insert (std::make_pair (
Misc::StringUtils::lowerCase (file), static_cast<int> (mFiles.size())-1));
} }
} }
} }
@ -89,6 +92,8 @@ int CSMWorld::Resources::searchId (const std::string& id) const
{ {
std::string id2 = Misc::StringUtils::lowerCase (id); std::string id2 = Misc::StringUtils::lowerCase (id);
std::replace (id2.begin(), id2.end(), '\\', '/');
std::map<std::string, int>::const_iterator iter = mIndex.find (id2); std::map<std::string, int>::const_iterator iter = mIndex.find (id2);
if (iter==mIndex.end()) if (iter==mIndex.end())

View file

@ -16,7 +16,6 @@
#include "../../model/world/idtable.hpp" #include "../../model/world/idtable.hpp"
#include "../world/subviews.hpp" #include "../world/subviews.hpp"
#include "../world/physicsmanager.hpp"
#include "../tools/subviews.hpp" #include "../tools/subviews.hpp"
@ -407,8 +406,6 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to
mSubViewFactory.add (CSMWorld::UniversalId::Type_RunLog, new SubViewFactory<RunLogSubView>); mSubViewFactory.add (CSMWorld::UniversalId::Type_RunLog, new SubViewFactory<RunLogSubView>);
connect (mOperations, SIGNAL (abortOperation (int)), this, SLOT (abortOperation (int))); connect (mOperations, SIGNAL (abortOperation (int)), this, SLOT (abortOperation (int)));
CSVWorld::PhysicsManager::instance()->setupPhysics(document);
} }
CSVDoc::View::~View() CSVDoc::View::~View()

View file

@ -16,7 +16,6 @@
#include "../world/vartypedelegate.hpp" #include "../world/vartypedelegate.hpp"
#include "../world/recordstatusdelegate.hpp" #include "../world/recordstatusdelegate.hpp"
#include "../world/idtypedelegate.hpp" #include "../world/idtypedelegate.hpp"
#include "../world/physicsmanager.hpp"
#include "../../model/settings/usersettings.hpp" #include "../../model/settings/usersettings.hpp"
@ -219,7 +218,6 @@ void CSVDoc::ViewManager::removeDocAndView (CSMDoc::Document *document)
mDocumentManager.removeDocument(document); mDocumentManager.removeDocument(document);
(*iter)->deleteLater(); (*iter)->deleteLater();
mViews.erase (iter); mViews.erase (iter);
CSVWorld::PhysicsManager::instance()->removeDocument(document);
updateIndices(); updateIndices();
return; return;

View file

@ -119,7 +119,7 @@ bool CSVRender::Cell::addObjects (int start, int end)
} }
CSVRender::Cell::Cell (CSMWorld::Data& data, Ogre::SceneManager *sceneManager, CSVRender::Cell::Cell (CSMWorld::Data& data, Ogre::SceneManager *sceneManager,
const std::string& id, CSVWorld::PhysicsSystem *physics, const Ogre::Vector3& origin) const std::string& id, boost::shared_ptr<CSVWorld::PhysicsSystem> physics, const Ogre::Vector3& origin)
: mData (data), mId (Misc::StringUtils::lowerCase (id)), mSceneMgr(sceneManager), mPhysics(physics), : mData (data), mId (Misc::StringUtils::lowerCase (id)), mSceneMgr(sceneManager), mPhysics(physics),
mPathgridId("") mPathgridId("")
{ {

View file

@ -5,6 +5,8 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include <boost/shared_ptr.hpp>
#include <OgreVector3.h> #include <OgreVector3.h>
#include <components/terrain/terraingrid.hpp> #include <components/terrain/terraingrid.hpp>
@ -50,7 +52,7 @@ namespace CSVRender
std::string mPathgridId; // FIXME: temporary storage until saving to document std::string mPathgridId; // FIXME: temporary storage until saving to document
std::auto_ptr<Terrain::TerrainGrid> mTerrain; std::auto_ptr<Terrain::TerrainGrid> mTerrain;
CSVWorld::PhysicsSystem *mPhysics; boost::shared_ptr<CSVWorld::PhysicsSystem> mPhysics;
Ogre::SceneManager *mSceneMgr; Ogre::SceneManager *mSceneMgr;
int mX; int mX;
int mY; int mY;
@ -68,7 +70,7 @@ namespace CSVRender
public: public:
Cell (CSMWorld::Data& data, Ogre::SceneManager *sceneManager, const std::string& id, Cell (CSMWorld::Data& data, Ogre::SceneManager *sceneManager, const std::string& id,
CSVWorld::PhysicsSystem *physics, const Ogre::Vector3& origin = Ogre::Vector3 (0, 0, 0)); boost::shared_ptr<CSVWorld::PhysicsSystem> physics, const Ogre::Vector3& origin = Ogre::Vector3 (0, 0, 0));
~Cell(); ~Cell();

View file

@ -8,10 +8,10 @@ namespace CSVRender
{ {
// elements that are part of the actual scene // elements that are part of the actual scene
Element_Reference = 0x1, Element_Reference = 0x1,
Element_Terrain = 0x2, Element_Pathgrid = 0x2,
Element_Water = 0x4, Element_Water = 0x4,
Element_Pathgrid = 0x8, Element_Fog = 0x8,
Element_Fog = 0x10, Element_Terrain = 0x10,
// control elements // control elements
Element_CellMarker = 0x10000, Element_CellMarker = 0x10000,

View file

@ -56,7 +56,7 @@ namespace CSVRender
// //
MouseState::MouseState(WorldspaceWidget *parent) MouseState::MouseState(WorldspaceWidget *parent)
: mParent(parent), mPhysics(parent->getPhysics()), mSceneManager(parent->getSceneManager()) : mParent(parent), mPhysics(parent->mDocument.getPhysics()), mSceneManager(parent->getSceneManager())
, mCurrentObj(""), mMouseState(Mouse_Default), mOldCursorPos(0,0), mMouseEventTimer(0) , mCurrentObj(""), mMouseState(Mouse_Default), mOldCursorPos(0,0), mMouseEventTimer(0)
, mGrabbedSceneNode(""), mGrabbedRefId(""), mOrigObjPos(Ogre::Vector3()) , mGrabbedSceneNode(""), mGrabbedRefId(""), mOrigObjPos(Ogre::Vector3())
, mOrigMousePos(Ogre::Vector3()), mOldMousePos(Ogre::Vector3()), mPlane(0) , mOrigMousePos(Ogre::Vector3()), mOldMousePos(Ogre::Vector3()), mPlane(0)

View file

@ -2,6 +2,7 @@
#define OPENCS_VIEW_MOUSESTATE_H #define OPENCS_VIEW_MOUSESTATE_H
#include <map> #include <map>
#include <boost/shared_ptr.hpp>
#include <QPoint> #include <QPoint>
#include <OgreVector3.h> #include <OgreVector3.h>
@ -43,7 +44,7 @@ namespace CSVRender
MouseStates mMouseState; MouseStates mMouseState;
WorldspaceWidget *mParent; WorldspaceWidget *mParent;
CSVWorld::PhysicsSystem *mPhysics; // local copy boost::shared_ptr<CSVWorld::PhysicsSystem> mPhysics;
Ogre::SceneManager *mSceneManager; // local copy Ogre::SceneManager *mSceneManager; // local copy
QPoint mOldCursorPos; QPoint mOldCursorPos;

View file

@ -93,7 +93,6 @@ void CSVRender::Object::update()
Ogre::Quaternion yr (Ogre::Radian (-reference.mPos.rot[1]), Ogre::Vector3::UNIT_Y); Ogre::Quaternion yr (Ogre::Radian (-reference.mPos.rot[1]), Ogre::Vector3::UNIT_Y);
Ogre::Quaternion zr (Ogre::Radian (-reference.mPos.rot[2]), Ogre::Vector3::UNIT_Z); Ogre::Quaternion zr (Ogre::Radian (-reference.mPos.rot[2]), Ogre::Vector3::UNIT_Z);
mPhysicsObject = mReferenceId;
mPhysics->addObject("meshes\\" + model, mBase->getName(), mReferenceId, reference.mScale, position, xr*yr*zr); mPhysics->addObject("meshes\\" + model, mBase->getName(), mReferenceId, reference.mScale, position, xr*yr*zr);
} }
} }
@ -133,9 +132,9 @@ const CSMWorld::CellRef& CSVRender::Object::getReference() const
} }
CSVRender::Object::Object (const CSMWorld::Data& data, Ogre::SceneNode *cellNode, CSVRender::Object::Object (const CSMWorld::Data& data, Ogre::SceneNode *cellNode,
const std::string& id, bool referenceable, CSVWorld::PhysicsSystem *physics, const std::string& id, bool referenceable, boost::shared_ptr<CSVWorld::PhysicsSystem> physics,
bool forceBaseToZero) bool forceBaseToZero)
: mData (data), mBase (0), mForceBaseToZero (forceBaseToZero), mPhysics(physics), mPhysicsObject("") : mData (data), mBase (0), mForceBaseToZero (forceBaseToZero), mPhysics(physics)
{ {
mBase = cellNode->createChildSceneNode(); mBase = cellNode->createChildSceneNode();
@ -157,7 +156,7 @@ CSVRender::Object::~Object()
{ {
clear(); clear();
if(mPhysicsObject != "") if(mPhysics) // preview may not have physics enabled
mPhysics->removeObject(mBase->getName()); mPhysics->removeObject(mBase->getName());
if (mBase) if (mBase)

View file

@ -1,6 +1,8 @@
#ifndef OPENCS_VIEW_OBJECT_H #ifndef OPENCS_VIEW_OBJECT_H
#define OPENCS_VIEW_OBJECT_H #define OPENCS_VIEW_OBJECT_H
#include <boost/shared_ptr.hpp>
#include <components/nifogre/ogrenifloader.hpp> #include <components/nifogre/ogrenifloader.hpp>
class QModelIndex; class QModelIndex;
@ -31,7 +33,7 @@ namespace CSVRender
Ogre::SceneNode *mBase; Ogre::SceneNode *mBase;
NifOgre::ObjectScenePtr mObject; NifOgre::ObjectScenePtr mObject;
bool mForceBaseToZero; bool mForceBaseToZero;
CSVWorld::PhysicsSystem *mPhysics; boost::shared_ptr<CSVWorld::PhysicsSystem> mPhysics;
std::string mPhysicsObject; std::string mPhysicsObject;
/// Not implemented /// Not implemented
@ -59,7 +61,8 @@ namespace CSVRender
Object (const CSMWorld::Data& data, Ogre::SceneNode *cellNode, Object (const CSMWorld::Data& data, Ogre::SceneNode *cellNode,
const std::string& id, bool referenceable, const std::string& id, bool referenceable,
CSVWorld::PhysicsSystem *physics = NULL, bool forceBaseToZero = false); boost::shared_ptr<CSVWorld::PhysicsSystem> physics = boost::shared_ptr<CSVWorld::PhysicsSystem> (),
bool forceBaseToZero = false);
/// \param forceBaseToZero If this is a reference ignore the coordinates and place /// \param forceBaseToZero If this is a reference ignore the coordinates and place
/// it at 0, 0, 0 instead. /// it at 0, 0, 0 instead.

View file

@ -22,6 +22,7 @@
#include "../widget/scenetooltoggle.hpp" #include "../widget/scenetooltoggle.hpp"
#include "../widget/scenetoolmode.hpp" #include "../widget/scenetoolmode.hpp"
#include "../widget/scenetooltoggle2.hpp"
#include "../world/physicssystem.hpp" #include "../world/physicssystem.hpp"
#include "pathgridpoint.hpp" #include "pathgridpoint.hpp"
@ -113,7 +114,7 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
mCells.find (*iter)==mCells.end()) mCells.find (*iter)==mCells.end())
{ {
Cell *cell = new Cell (mDocument.getData(), getSceneManager(), Cell *cell = new Cell (mDocument.getData(), getSceneManager(),
iter->getId (mWorldspace), getPhysics()); iter->getId (mWorldspace), mDocument.getPhysics());
mCells.insert (std::make_pair (*iter, cell)); mCells.insert (std::make_pair (*iter, cell));
float height = cell->getTerrainHeightAt(Ogre::Vector3( float height = cell->getTerrainHeightAt(Ogre::Vector3(
@ -214,6 +215,14 @@ void CSVRender::PagedWorldspaceWidget::mouseDoubleClickEvent (QMouseEvent *event
WorldspaceWidget::mouseDoubleClickEvent(event); WorldspaceWidget::mouseDoubleClickEvent(event);
} }
void CSVRender::PagedWorldspaceWidget::addVisibilitySelectorButtons (
CSVWidget::SceneToolToggle2 *tool)
{
WorldspaceWidget::addVisibilitySelectorButtons (tool);
tool->addButton (Element_Terrain, "Terrain");
tool->addButton (Element_Fog, "Fog", "", true);
}
void CSVRender::PagedWorldspaceWidget::addEditModeSelectorButtons ( void CSVRender::PagedWorldspaceWidget::addEditModeSelectorButtons (
CSVWidget::SceneToolMode *tool) CSVWidget::SceneToolMode *tool)
{ {
@ -474,9 +483,12 @@ CSVRender::PagedWorldspaceWidget::~PagedWorldspaceWidget()
delete iter->second; delete iter->second;
} }
if(mOverlayMask)
{
removeRenderTargetListener(mOverlayMask); removeRenderTargetListener(mOverlayMask);
delete mOverlayMask; delete mOverlayMask;
} }
}
void CSVRender::PagedWorldspaceWidget::useViewHint (const std::string& hint) void CSVRender::PagedWorldspaceWidget::useViewHint (const std::string& hint)
{ {

View file

@ -8,9 +8,13 @@
#include "worldspacewidget.hpp" #include "worldspacewidget.hpp"
#include "cell.hpp" #include "cell.hpp"
namespace CSVWidget
{
class SceneToolToggle;
}
namespace CSVRender namespace CSVRender
{ {
class TextOverlay; class TextOverlay;
class OverlayMask; class OverlayMask;
@ -87,6 +91,8 @@ namespace CSVRender
protected: protected:
virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle2 *tool);
virtual void addEditModeSelectorButtons (CSVWidget::SceneToolMode *tool); virtual void addEditModeSelectorButtons (CSVWidget::SceneToolMode *tool);
virtual void updateOverlay(); virtual void updateOverlay();

View file

@ -10,7 +10,7 @@
CSVRender::PreviewWidget::PreviewWidget (CSMWorld::Data& data, CSVRender::PreviewWidget::PreviewWidget (CSMWorld::Data& data,
const std::string& id, bool referenceable, QWidget *parent) const std::string& id, bool referenceable, QWidget *parent)
: SceneWidget (parent), mData (data), : SceneWidget (parent), mData (data),
mObject (data, getSceneManager()->getRootSceneNode(), id, referenceable, NULL, true) mObject (data, getSceneManager()->getRootSceneNode(), id, referenceable, boost::shared_ptr<CSVWorld::PhysicsSystem>(), true)
{ {
setNavigation (&mOrbit); setNavigation (&mOrbit);

View file

@ -15,6 +15,7 @@
#include "../../model/world/tablemimedata.hpp" #include "../../model/world/tablemimedata.hpp"
#include "../widget/scenetooltoggle.hpp" #include "../widget/scenetooltoggle.hpp"
#include "../widget/scenetooltoggle2.hpp"
#include "elements.hpp" #include "elements.hpp"
@ -32,14 +33,6 @@ void CSVRender::UnpagedWorldspaceWidget::update()
flagAsModified(); flagAsModified();
} }
void CSVRender::UnpagedWorldspaceWidget::addVisibilitySelectorButtons (
CSVWidget::SceneToolToggle *tool)
{
WorldspaceWidget::addVisibilitySelectorButtons (tool);
tool->addButton (":armor.png", Element_Fog, ":armor.png", "Fog");
}
CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document, QWidget* parent) CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document, QWidget* parent)
: WorldspaceWidget (document, parent), mCellId (cellId) : WorldspaceWidget (document, parent), mCellId (cellId)
{ {
@ -56,7 +49,7 @@ CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string&
update(); update();
mCell.reset (new Cell (document.getData(), getSceneManager(), mCellId, getPhysics())); mCell.reset (new Cell (document.getData(), getSceneManager(), mCellId, document.getPhysics()));
} }
void CSVRender::UnpagedWorldspaceWidget::cellDataChanged (const QModelIndex& topLeft, void CSVRender::UnpagedWorldspaceWidget::cellDataChanged (const QModelIndex& topLeft,
@ -98,7 +91,7 @@ bool CSVRender::UnpagedWorldspaceWidget::handleDrop (const std::vector<CSMWorld:
return false; return false;
mCellId = data.begin()->getId(); mCellId = data.begin()->getId();
mCell.reset (new Cell (getDocument().getData(), getSceneManager(), mCellId, getPhysics())); mCell.reset (new Cell (getDocument().getData(), getSceneManager(), mCellId, getDocument().getPhysics()));
update(); update();
emit cellChanged(*data.begin()); emit cellChanged(*data.begin());
@ -160,6 +153,14 @@ void CSVRender::UnpagedWorldspaceWidget::referenceAdded (const QModelIndex& pare
flagAsModified(); flagAsModified();
} }
void CSVRender::UnpagedWorldspaceWidget::addVisibilitySelectorButtons (
CSVWidget::SceneToolToggle2 *tool)
{
WorldspaceWidget::addVisibilitySelectorButtons (tool);
tool->addButton (Element_Terrain, "Terrain", "", true);
tool->addButton (Element_Fog, "Fog");
}
//void CSVRender::UnpagedWorldspaceWidget::pathgridAdded (const QModelIndex& parent, //void CSVRender::UnpagedWorldspaceWidget::pathgridAdded (const QModelIndex& parent,
// int start, int end) // int start, int end)
//{ //{

View file

@ -32,10 +32,6 @@ namespace CSVRender
void update(); void update();
protected:
virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle *tool);
public: public:
UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document, UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document,
@ -70,6 +66,10 @@ namespace CSVRender
virtual std::string getStartupInstruction(); virtual std::string getStartupInstruction();
protected:
virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle2 *tool);
private slots: private slots:
void cellDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight); void cellDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);

View file

@ -14,17 +14,16 @@
#include "../../model/world/idtable.hpp" #include "../../model/world/idtable.hpp"
#include "../widget/scenetoolmode.hpp" #include "../widget/scenetoolmode.hpp"
#include "../widget/scenetooltoggle.hpp" #include "../widget/scenetooltoggle2.hpp"
#include "../widget/scenetoolrun.hpp" #include "../widget/scenetoolrun.hpp"
#include "../world/physicsmanager.hpp"
#include "../world/physicssystem.hpp" #include "../world/physicssystem.hpp"
#include "elements.hpp" #include "elements.hpp"
#include "editmode.hpp" #include "editmode.hpp"
CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent) CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent)
: SceneWidget (parent), mDocument(document), mSceneElements(0), mRun(0), mPhysics(0), mMouse(0), : SceneWidget (parent), mDocument(document), mSceneElements(0), mRun(0), mPhysics(boost::shared_ptr<CSVWorld::PhysicsSystem>()), mMouse(0),
mInteractionMask (0) mInteractionMask (0)
{ {
setAcceptDrops(true); setAcceptDrops(true);
@ -67,9 +66,7 @@ CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidg
//connect (pathgrids, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)), //connect (pathgrids, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
//this, SLOT (pathgridAboutToBeRemoved (const QModelIndex&, int, int))); //this, SLOT (pathgridAboutToBeRemoved (const QModelIndex&, int, int)));
// associate WorldSpaceWidgets (and their SceneManagers) with Documents mPhysics = document.getPhysics(); // create physics if one doesn't exist
// then create physics if there is a new document
mPhysics = CSVWorld::PhysicsManager::instance()->addSceneWidget(document, this);
mPhysics->addSceneManager(getSceneManager(), this); mPhysics->addSceneManager(getSceneManager(), this);
mMouse = new MouseState(this); mMouse = new MouseState(this);
} }
@ -78,7 +75,6 @@ CSVRender::WorldspaceWidget::~WorldspaceWidget ()
{ {
delete mMouse; delete mMouse;
mPhysics->removeSceneManager(getSceneManager()); mPhysics->removeSceneManager(getSceneManager());
CSVWorld::PhysicsManager::instance()->removeSceneWidget(this);
} }
void CSVRender::WorldspaceWidget::selectNavigationMode (const std::string& mode) void CSVRender::WorldspaceWidget::selectNavigationMode (const std::string& mode)
@ -138,10 +134,10 @@ CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector (
return tool; return tool;
} }
CSVWidget::SceneToolToggle *CSVRender::WorldspaceWidget::makeSceneVisibilitySelector (CSVWidget::SceneToolbar *parent) CSVWidget::SceneToolToggle2 *CSVRender::WorldspaceWidget::makeSceneVisibilitySelector (CSVWidget::SceneToolbar *parent)
{ {
mSceneElements= new CSVWidget::SceneToolToggle (parent, mSceneElements = new CSVWidget::SceneToolToggle2 (parent,
"Scene Element Visibility", ":placeholder"); "Scene Element Visibility", ":scenetoolbar/scene-view-c", ":scenetoolbar/scene-view-");
addVisibilitySelectorButtons (mSceneElements); addVisibilitySelectorButtons (mSceneElements);
@ -183,7 +179,7 @@ CSVWidget::SceneToolRun *CSVRender::WorldspaceWidget::makeRunTool (
std::sort (profiles.begin(), profiles.end()); std::sort (profiles.begin(), profiles.end());
mRun = new CSVWidget::SceneToolRun (parent, "Run OpenMW from the current camera position", mRun = new CSVWidget::SceneToolRun (parent, "Run OpenMW from the current camera position",
":placeholder", ":placeholder", profiles); ":scenetoolbar/play", profiles);
connect (mRun, SIGNAL (runRequest (const std::string&)), connect (mRun, SIGNAL (runRequest (const std::string&)),
this, SLOT (runRequest (const std::string&))); this, SLOT (runRequest (const std::string&)));
@ -271,12 +267,11 @@ unsigned int CSVRender::WorldspaceWidget::getInteractionMask() const
} }
void CSVRender::WorldspaceWidget::addVisibilitySelectorButtons ( void CSVRender::WorldspaceWidget::addVisibilitySelectorButtons (
CSVWidget::SceneToolToggle *tool) CSVWidget::SceneToolToggle2 *tool)
{ {
tool->addButton (":placeholder", Element_Reference, ":placeholder", "References"); tool->addButton (Element_Reference, "References");
tool->addButton (":placeholder", Element_Terrain, ":placeholder", "Terrain"); tool->addButton (Element_Water, "Water");
tool->addButton (":placeholder", Element_Water, ":placeholder", "Water"); tool->addButton (Element_Pathgrid, "Pathgrid");
tool->addButton (":placeholder", Element_Pathgrid, ":placeholder", "Pathgrid");
} }
void CSVRender::WorldspaceWidget::addEditModeSelectorButtons (CSVWidget::SceneToolMode *tool) void CSVRender::WorldspaceWidget::addEditModeSelectorButtons (CSVWidget::SceneToolMode *tool)
@ -380,12 +375,6 @@ void CSVRender::WorldspaceWidget::updateOverlay()
{ {
} }
CSVWorld::PhysicsSystem *CSVRender::WorldspaceWidget::getPhysics()
{
assert(mPhysics);
return mPhysics;
}
void CSVRender::WorldspaceWidget::mouseMoveEvent (QMouseEvent *event) void CSVRender::WorldspaceWidget::mouseMoveEvent (QMouseEvent *event)
{ {
if(event->buttons() & Qt::RightButton) if(event->buttons() & Qt::RightButton)

View file

@ -1,6 +1,8 @@
#ifndef OPENCS_VIEW_WORLDSPACEWIDGET_H #ifndef OPENCS_VIEW_WORLDSPACEWIDGET_H
#define OPENCS_VIEW_WORLDSPACEWIDGET_H #define OPENCS_VIEW_WORLDSPACEWIDGET_H
#include <boost/shared_ptr.hpp>
#include "scenewidget.hpp" #include "scenewidget.hpp"
#include "mousestate.hpp" #include "mousestate.hpp"
@ -18,7 +20,7 @@ namespace CSMWorld
namespace CSVWidget namespace CSVWidget
{ {
class SceneToolMode; class SceneToolMode;
class SceneToolToggle; class SceneToolToggle2;
class SceneToolbar; class SceneToolbar;
class SceneToolRun; class SceneToolRun;
} }
@ -37,10 +39,10 @@ namespace CSVRender
CSVRender::Navigation1st m1st; CSVRender::Navigation1st m1st;
CSVRender::NavigationFree mFree; CSVRender::NavigationFree mFree;
CSVRender::NavigationOrbit mOrbit; CSVRender::NavigationOrbit mOrbit;
CSVWidget::SceneToolToggle *mSceneElements; CSVWidget::SceneToolToggle2 *mSceneElements;
CSVWidget::SceneToolRun *mRun; CSVWidget::SceneToolRun *mRun;
CSMDoc::Document& mDocument; CSMDoc::Document& mDocument;
CSVWorld::PhysicsSystem *mPhysics; boost::shared_ptr<CSVWorld::PhysicsSystem> mPhysics;
MouseState *mMouse; MouseState *mMouse;
unsigned int mInteractionMask; unsigned int mInteractionMask;
@ -71,7 +73,7 @@ namespace CSVRender
/// \attention The created tool is not added to the toolbar (via addTool). Doing /// \attention The created tool is not added to the toolbar (via addTool). Doing
/// that is the responsibility of the calling function. /// that is the responsibility of the calling function.
CSVWidget::SceneToolToggle *makeSceneVisibilitySelector ( CSVWidget::SceneToolToggle2 *makeSceneVisibilitySelector (
CSVWidget::SceneToolbar *parent); CSVWidget::SceneToolbar *parent);
/// \attention The created tool is not added to the toolbar (via addTool). Doing /// \attention The created tool is not added to the toolbar (via addTool). Doing
@ -107,7 +109,7 @@ namespace CSVRender
protected: protected:
virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle *tool); virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle2 *tool);
virtual void addEditModeSelectorButtons (CSVWidget::SceneToolMode *tool); virtual void addEditModeSelectorButtons (CSVWidget::SceneToolMode *tool);
@ -115,8 +117,6 @@ namespace CSVRender
virtual void updateOverlay(); virtual void updateOverlay();
CSVWorld::PhysicsSystem *getPhysics();
virtual void mouseMoveEvent (QMouseEvent *event); virtual void mouseMoveEvent (QMouseEvent *event);
virtual void mousePressEvent (QMouseEvent *event); virtual void mousePressEvent (QMouseEvent *event);
virtual void mouseReleaseEvent (QMouseEvent *event); virtual void mouseReleaseEvent (QMouseEvent *event);

View file

@ -1,31 +1,15 @@
#include "reportsubview.hpp" #include "reportsubview.hpp"
#include <QTableView> #include "reporttable.hpp"
#include <QHeaderView>
#include "../../model/tools/reportmodel.hpp"
#include "../../view/world/idtypedelegate.hpp"
CSVTools::ReportSubView::ReportSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) CSVTools::ReportSubView::ReportSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
: CSVDoc::SubView (id), mModel (document.getReport (id)) : CSVDoc::SubView (id)
{ {
setWidget (mTable = new QTableView (this)); setWidget (mTable = new ReportTable (document, id, this));
mTable->setModel (mModel);
mTable->horizontalHeader()->setResizeMode (QHeaderView::Interactive); connect (mTable, SIGNAL (editRequest (const CSMWorld::UniversalId&, const std::string&)),
mTable->verticalHeader()->hide(); SIGNAL (focusId (const CSMWorld::UniversalId&, const std::string&)));
mTable->setSortingEnabled (true);
mTable->setSelectionBehavior (QAbstractItemView::SelectRows);
mTable->setSelectionMode (QAbstractItemView::ExtendedSelection);
mIdTypeDelegate = CSVWorld::IdTypeDelegateFactory().makeDelegate (
document, this);
mTable->setItemDelegateForColumn (0, mIdTypeDelegate);
connect (mTable, SIGNAL (doubleClicked (const QModelIndex&)), this, SLOT (show (const QModelIndex&)));
} }
void CSVTools::ReportSubView::setEditLock (bool locked) void CSVTools::ReportSubView::setEditLock (bool locked)
@ -33,13 +17,7 @@ void CSVTools::ReportSubView::setEditLock (bool locked)
// ignored. We don't change document state anyway. // ignored. We don't change document state anyway.
} }
void CSVTools::ReportSubView::updateUserSetting void CSVTools::ReportSubView::updateUserSetting (const QString &name, const QStringList &list)
(const QString &name, const QStringList &list)
{ {
mIdTypeDelegate->updateUserSetting (name, list); mTable->updateUserSetting (name, list);
}
void CSVTools::ReportSubView::show (const QModelIndex& index)
{
focusId (mModel->getUniversalId (index.row()), "");
} }

View file

@ -11,27 +11,15 @@ namespace CSMDoc
class Document; class Document;
} }
namespace CSMTools
{
class ReportModel;
}
namespace CSVWorld
{
class CommandDelegate;
}
namespace CSVTools namespace CSVTools
{ {
class Table; class ReportTable;
class ReportSubView : public CSVDoc::SubView class ReportSubView : public CSVDoc::SubView
{ {
Q_OBJECT Q_OBJECT
CSMTools::ReportModel *mModel; ReportTable *mTable;
QTableView *mTable;
CSVWorld::CommandDelegate *mIdTypeDelegate;
public: public:
@ -39,12 +27,7 @@ namespace CSVTools
virtual void setEditLock (bool locked); virtual void setEditLock (bool locked);
virtual void updateUserSetting virtual void updateUserSetting (const QString &, const QStringList &);
(const QString &, const QStringList &);
private slots:
void show (const QModelIndex& index);
}; };
} }

View file

@ -0,0 +1,136 @@
#include "reporttable.hpp"
#include <algorithm>
#include <QHeaderView>
#include <QAction>
#include <QMenu>
#include "../../model/tools/reportmodel.hpp"
#include "../../view/world/idtypedelegate.hpp"
void CSVTools::ReportTable::contextMenuEvent (QContextMenuEvent *event)
{
QModelIndexList selectedRows = selectionModel()->selectedRows();
// create context menu
QMenu menu (this);
if (!selectedRows.empty())
{
menu.addAction (mShowAction);
menu.addAction (mRemoveAction);
}
menu.exec (event->globalPos());
}
void CSVTools::ReportTable::mouseMoveEvent (QMouseEvent *event)
{
if (event->buttons() & Qt::LeftButton)
startDrag (*this);
}
void CSVTools::ReportTable::mouseDoubleClickEvent (QMouseEvent *event)
{
Qt::KeyboardModifiers modifiers =
event->modifiers() & (Qt::ShiftModifier | Qt::ControlModifier);
QModelIndex index = currentIndex();
selectionModel()->select (index,
QItemSelectionModel::Clear | QItemSelectionModel::Select | QItemSelectionModel::Rows);
switch (modifiers)
{
case 0:
event->accept();
showSelection();
break;
case Qt::ShiftModifier:
event->accept();
removeSelection();
break;
case Qt::ControlModifier:
event->accept();
showSelection();
removeSelection();
break;
}
}
CSVTools::ReportTable::ReportTable (CSMDoc::Document& document,
const CSMWorld::UniversalId& id, QWidget *parent)
: CSVWorld::DragRecordTable (document, parent), mModel (document.getReport (id))
{
horizontalHeader()->setResizeMode (QHeaderView::Interactive);
verticalHeader()->hide();
setSortingEnabled (true);
setSelectionBehavior (QAbstractItemView::SelectRows);
setSelectionMode (QAbstractItemView::ExtendedSelection);
setModel (mModel);
setColumnHidden (2, true);
mIdTypeDelegate = CSVWorld::IdTypeDelegateFactory().makeDelegate (
document, this);
setItemDelegateForColumn (0, mIdTypeDelegate);
mShowAction = new QAction (tr ("Show"), this);
connect (mShowAction, SIGNAL (triggered()), this, SLOT (showSelection()));
addAction (mShowAction);
mRemoveAction = new QAction (tr ("Remove from list"), this);
connect (mRemoveAction, SIGNAL (triggered()), this, SLOT (removeSelection()));
addAction (mRemoveAction);
}
std::vector<CSMWorld::UniversalId> CSVTools::ReportTable::getDraggedRecords() const
{
std::vector<CSMWorld::UniversalId> ids;
QModelIndexList selectedRows = selectionModel()->selectedRows();
for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end();
++iter)
{
ids.push_back (mModel->getUniversalId (iter->row()));
}
return ids;
}
void CSVTools::ReportTable::updateUserSetting (const QString& name, const QStringList& list)
{
mIdTypeDelegate->updateUserSetting (name, list);
}
void CSVTools::ReportTable::showSelection()
{
QModelIndexList selectedRows = selectionModel()->selectedRows();
for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end();
++iter)
emit editRequest (mModel->getUniversalId (iter->row()), mModel->getHint (iter->row()));
}
void CSVTools::ReportTable::removeSelection()
{
QModelIndexList selectedRows = selectionModel()->selectedRows();
std::reverse (selectedRows.begin(), selectedRows.end());
for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end();
++iter)
mModel->removeRows (iter->row(), 1);
selectionModel()->clear();
}

View file

@ -0,0 +1,58 @@
#ifndef CSV_TOOLS_REPORTTABLE_H
#define CSV_TOOLS_REPORTTABLE_H
#include "../world/dragrecordtable.hpp"
class QAction;
namespace CSMTools
{
class ReportModel;
}
namespace CSVWorld
{
class CommandDelegate;
}
namespace CSVTools
{
class ReportTable : public CSVWorld::DragRecordTable
{
Q_OBJECT
CSMTools::ReportModel *mModel;
CSVWorld::CommandDelegate *mIdTypeDelegate;
QAction *mShowAction;
QAction *mRemoveAction;
private:
void contextMenuEvent (QContextMenuEvent *event);
void mouseMoveEvent (QMouseEvent *event);
virtual void mouseDoubleClickEvent (QMouseEvent *event);
public:
ReportTable (CSMDoc::Document& document, const CSMWorld::UniversalId& id,
QWidget *parent = 0);
virtual std::vector<CSMWorld::UniversalId> getDraggedRecords() const;
void updateUserSetting (const QString& name, const QStringList& list);
private slots:
void showSelection();
void removeSelection();
signals:
void editRequest (const CSMWorld::UniversalId& id, const std::string& hint);
};
}
#endif

View file

@ -72,6 +72,11 @@ CSVWidget::PushButton::PushButton (const QIcon& icon, Type type, const QString&
QWidget *parent) QWidget *parent)
: QPushButton (icon, "", parent), mKeepOpen (false), mType (type), mToolTip (tooltip) : QPushButton (icon, "", parent), mKeepOpen (false), mType (type), mToolTip (tooltip)
{ {
if (type==Type_Mode || type==Type_Toggle)
{
setCheckable (true);
connect (this, SIGNAL (toggled (bool)), this, SLOT (checkedStateChanged (bool)));
}
setCheckable (type==Type_Mode || type==Type_Toggle); setCheckable (type==Type_Mode || type==Type_Toggle);
setExtendedToolTip(); setExtendedToolTip();
} }
@ -96,4 +101,9 @@ QString CSVWidget::PushButton::getBaseToolTip() const
CSVWidget::PushButton::Type CSVWidget::PushButton::getType() const CSVWidget::PushButton::Type CSVWidget::PushButton::getType() const
{ {
return mType; return mType;
}
void CSVWidget::PushButton::checkedStateChanged (bool checked)
{
setExtendedToolTip();
} }

View file

@ -53,6 +53,10 @@ namespace CSVWidget
QString getBaseToolTip() const; QString getBaseToolTip() const;
Type getType() const; Type getType() const;
private slots:
void checkedStateChanged (bool checked);
}; };
} }

View file

@ -26,7 +26,7 @@ void CSVWidget::SceneToolRun::adjustToolTips()
void CSVWidget::SceneToolRun::updateIcon() void CSVWidget::SceneToolRun::updateIcon()
{ {
setIcon (QIcon (mSelected==mProfiles.end() ? mIconDisabled : mIcon)); setDisabled (mSelected==mProfiles.end());
} }
void CSVWidget::SceneToolRun::updatePanel() void CSVWidget::SceneToolRun::updatePanel()
@ -46,11 +46,11 @@ void CSVWidget::SceneToolRun::updatePanel()
} }
CSVWidget::SceneToolRun::SceneToolRun (SceneToolbar *parent, const QString& toolTip, CSVWidget::SceneToolRun::SceneToolRun (SceneToolbar *parent, const QString& toolTip,
const QString& icon, const QString& iconDisabled, const std::vector<std::string>& profiles) const QString& icon, const std::vector<std::string>& profiles)
: SceneTool (parent, Type_TopAction), mProfiles (profiles.begin(), profiles.end()), : SceneTool (parent, Type_TopAction), mProfiles (profiles.begin(), profiles.end()),
mSelected (mProfiles.begin()), mToolTip (toolTip), mIcon (icon), mSelected (mProfiles.begin()), mToolTip (toolTip)
mIconDisabled (iconDisabled)
{ {
setIcon (QIcon (icon));
updateIcon(); updateIcon();
adjustToolTips(); adjustToolTips();

View file

@ -19,8 +19,6 @@ namespace CSVWidget
std::set<std::string> mProfiles; std::set<std::string> mProfiles;
std::set<std::string>::iterator mSelected; std::set<std::string>::iterator mSelected;
QString mToolTip; QString mToolTip;
QString mIcon;
QString mIconDisabled;
QFrame *mPanel; QFrame *mPanel;
QTableWidget *mTable; QTableWidget *mTable;
@ -35,7 +33,7 @@ namespace CSVWidget
public: public:
SceneToolRun (SceneToolbar *parent, const QString& toolTip, const QString& icon, SceneToolRun (SceneToolbar *parent, const QString& toolTip, const QString& icon,
const QString& iconDisabled, const std::vector<std::string>& profiles); const std::vector<std::string>& profiles);
virtual void showPanel (const QPoint& position); virtual void showPanel (const QPoint& position);

View file

@ -0,0 +1,142 @@
#include "scenetooltoggle2.hpp"
#include <stdexcept>
#include <sstream>
#include <QHBoxLayout>
#include <QFrame>
#include <QIcon>
#include <QPainter>
#include "scenetoolbar.hpp"
#include "pushbutton.hpp"
void CSVWidget::SceneToolToggle2::adjustToolTip()
{
QString toolTip = mToolTip;
toolTip += "<p>Currently enabled: ";
bool first = true;
for (std::map<PushButton *, ButtonDesc>::const_iterator iter (mButtons.begin());
iter!=mButtons.end(); ++iter)
if (iter->first->isChecked())
{
if (!first)
toolTip += ", ";
else
first = false;
toolTip += iter->second.mName;
}
if (first)
toolTip += "none";
toolTip += "<p>(left click to alter selection)";
setToolTip (toolTip);
}
void CSVWidget::SceneToolToggle2::adjustIcon()
{
std::ostringstream stream;
stream << mCompositeIcon << getSelection();
setIcon (QIcon (QString::fromUtf8 (stream.str().c_str())));
}
CSVWidget::SceneToolToggle2::SceneToolToggle2 (SceneToolbar *parent, const QString& toolTip,
const std::string& compositeIcon, const std::string& singleIcon)
: SceneTool (parent), mCompositeIcon (compositeIcon), mSingleIcon (singleIcon),
mButtonSize (parent->getButtonSize()), mIconSize (parent->getIconSize()), mToolTip (toolTip),
mFirst (0)
{
mPanel = new QFrame (this, Qt::Popup);
mLayout = new QHBoxLayout (mPanel);
mLayout->setContentsMargins (QMargins (0, 0, 0, 0));
mPanel->setLayout (mLayout);
}
void CSVWidget::SceneToolToggle2::showPanel (const QPoint& position)
{
mPanel->move (position);
mPanel->show();
if (mFirst)
mFirst->setFocus (Qt::OtherFocusReason);
}
void CSVWidget::SceneToolToggle2::addButton (unsigned int id,
const QString& name, const QString& tooltip, bool disabled)
{
std::ostringstream stream;
stream << mSingleIcon << id;
PushButton *button = new PushButton (QIcon (QPixmap (stream.str().c_str())),
PushButton::Type_Toggle, tooltip.isEmpty() ? name: tooltip, mPanel);
button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
button->setIconSize (QSize (mIconSize, mIconSize));
button->setFixedSize (mButtonSize, mButtonSize);
if (disabled)
button->setDisabled (true);
mLayout->addWidget (button);
ButtonDesc desc;
desc.mId = id;
desc.mName = name;
desc.mIndex = mButtons.size();
mButtons.insert (std::make_pair (button, desc));
connect (button, SIGNAL (clicked()), this, SLOT (selected()));
if (mButtons.size()==1 && !disabled)
mFirst = button;
}
unsigned int CSVWidget::SceneToolToggle2::getSelection() const
{
unsigned int selection = 0;
for (std::map<PushButton *, ButtonDesc>::const_iterator iter (mButtons.begin());
iter!=mButtons.end(); ++iter)
if (iter->first->isChecked())
selection |= iter->second.mId;
return selection;
}
void CSVWidget::SceneToolToggle2::setSelection (unsigned int selection)
{
for (std::map<PushButton *, ButtonDesc>::iterator iter (mButtons.begin());
iter!=mButtons.end(); ++iter)
iter->first->setChecked (selection & iter->second.mId);
adjustToolTip();
adjustIcon();
}
void CSVWidget::SceneToolToggle2::selected()
{
std::map<PushButton *, ButtonDesc>::const_iterator iter =
mButtons.find (dynamic_cast<PushButton *> (sender()));
if (iter!=mButtons.end())
{
if (!iter->first->hasKeepOpen())
mPanel->hide();
adjustToolTip();
adjustIcon();
emit selectionChanged();
}
}

View file

@ -0,0 +1,76 @@
#ifndef CSV_WIDGET_SCENETOOL_TOGGLE2_H
#define CSV_WIDGET_SCENETOOL_TOGGLE2_H
#include "scenetool.hpp"
#include <map>
class QHBoxLayout;
class QRect;
namespace CSVWidget
{
class SceneToolbar;
class PushButton;
///< \brief Multi-Toggle tool
///
/// Top level button is using predefined icons instead building a composite icon.
class SceneToolToggle2 : public SceneTool
{
Q_OBJECT
struct ButtonDesc
{
unsigned int mId;
QString mName;
int mIndex;
};
std::string mCompositeIcon;
std::string mSingleIcon;
QWidget *mPanel;
QHBoxLayout *mLayout;
std::map<PushButton *, ButtonDesc> mButtons; // widget, id
int mButtonSize;
int mIconSize;
QString mToolTip;
PushButton *mFirst;
void adjustToolTip();
void adjustIcon();
public:
/// The top level icon is compositeIcon + sum of bitpatterns for active buttons (in
/// decimal)
///
/// The icon for individual toggle buttons is signleIcon + bitmask for button (in
/// decimal)
SceneToolToggle2 (SceneToolbar *parent, const QString& toolTip,
const std::string& compositeIcon, const std::string& singleIcon);
virtual void showPanel (const QPoint& position);
/// \attention After the last button has been added, setSelection must be called at
/// least once to finalise the layout.
void addButton (unsigned int id,
const QString& name, const QString& tooltip = "", bool disabled = false);
unsigned int getSelection() const;
/// \param or'ed button IDs. IDs that do not exist will be ignored.
void setSelection (unsigned int selection);
signals:
void selectionChanged();
private slots:
void selected();
};
}
#endif

View file

@ -1,110 +0,0 @@
#include "physicsmanager.hpp"
#include <iostream>
#include <openengine/bullet/BulletShapeLoader.h>
#include "../render/worldspacewidget.hpp"
#include "physicssystem.hpp"
namespace CSVWorld
{
PhysicsManager *PhysicsManager::mPhysicsManagerInstance = 0;
PhysicsManager::PhysicsManager()
{
assert(!mPhysicsManagerInstance);
mPhysicsManagerInstance = this;
}
PhysicsManager::~PhysicsManager()
{
std::map<CSMDoc::Document *, CSVWorld::PhysicsSystem *>::iterator iter = mPhysics.begin();
for(; iter != mPhysics.end(); ++iter)
delete iter->second; // shouldn't be any left but just in case
}
PhysicsManager *PhysicsManager::instance()
{
assert(mPhysicsManagerInstance);
return mPhysicsManagerInstance;
}
// create a physics instance per document, called from CSVDoc::View() to get Document*
void PhysicsManager::setupPhysics(CSMDoc::Document *doc)
{
std::map<CSMDoc::Document *, std::list<CSVRender::SceneWidget *> >::iterator iter = mSceneWidgets.find(doc);
if(iter == mSceneWidgets.end())
{
mSceneWidgets[doc] = std::list<CSVRender::SceneWidget *> (); // zero elements
mPhysics[doc] = new PhysicsSystem();
}
}
// destroy physics, called from CSVDoc::ViewManager
void PhysicsManager::removeDocument(CSMDoc::Document *doc)
{
std::map<CSMDoc::Document *, CSVWorld::PhysicsSystem *>::iterator iter = mPhysics.find(doc);
if(iter != mPhysics.end())
{
delete iter->second;
mPhysics.erase(iter);
}
std::map<CSMDoc::Document *, std::list<CSVRender::SceneWidget *> >::iterator it = mSceneWidgets.find(doc);
if(it != mSceneWidgets.end())
{
mSceneWidgets.erase(it);
}
// cleanup global resources used by OEngine
if(mPhysics.empty())
{
delete OEngine::Physic::BulletShapeManager::getSingletonPtr();
}
}
// called from CSVRender::WorldspaceWidget() to get widgets' association with Document&
PhysicsSystem *PhysicsManager::addSceneWidget(CSMDoc::Document &doc, CSVRender::WorldspaceWidget *widget)
{
CSVRender::SceneWidget *sceneWidget = static_cast<CSVRender::SceneWidget *>(widget);
std::map<CSMDoc::Document *, std::list<CSVRender::SceneWidget *> >::iterator iter = mSceneWidgets.begin();
for(; iter != mSceneWidgets.end(); ++iter)
{
if((*iter).first == &doc)
{
(*iter).second.push_back(sceneWidget);
return mPhysics[(*iter).first]; // TODO: consider using shared_ptr instead
}
}
throw std::runtime_error("No physics system found for the given document.");
}
// deprecated by removeDocument() and may be deleted in future code updates
// however there may be some value in removing the deleted scene widgets from the
// list so that the list does not grow forever
void PhysicsManager::removeSceneWidget(CSVRender::WorldspaceWidget *widget)
{
CSVRender::SceneWidget *sceneWidget = static_cast<CSVRender::SceneWidget *>(widget);
std::map<CSMDoc::Document *, std::list<CSVRender::SceneWidget *> >::iterator iter = mSceneWidgets.begin();
for(; iter != mSceneWidgets.end(); ++iter)
{
std::list<CSVRender::SceneWidget *>::iterator itWidget = (*iter).second.begin();
for(; itWidget != (*iter).second.end(); ++itWidget)
{
if((*itWidget) == sceneWidget)
{
(*iter).second.erase(itWidget);
//if((*iter).second.empty()) // last one for the document
// NOTE: do not delete physics until the document itself is closed
break;
}
}
}
}
}

View file

@ -1,54 +0,0 @@
#ifndef CSV_WORLD_PHYSICSMANAGER_H
#define CSV_WORLD_PHYSICSMANAGER_H
#include <map>
#include <list>
namespace Ogre
{
class SceneManager;
}
namespace CSMDoc
{
class Document;
}
namespace CSVRender
{
class WorldspaceWidget;
class SceneWidget;
}
namespace CSVWorld
{
class PhysicsSystem;
}
namespace CSVWorld
{
class PhysicsManager
{
static PhysicsManager *mPhysicsManagerInstance;
std::map<CSMDoc::Document *, std::list<CSVRender::SceneWidget *> > mSceneWidgets;
std::map<CSMDoc::Document *, CSVWorld::PhysicsSystem *> mPhysics;
public:
PhysicsManager();
~PhysicsManager();
static PhysicsManager *instance();
void setupPhysics(CSMDoc::Document *);
PhysicsSystem *addSceneWidget(CSMDoc::Document &doc, CSVRender::WorldspaceWidget *widget);
void removeSceneWidget(CSVRender::WorldspaceWidget *widget);
void removeDocument(CSMDoc::Document *doc);
};
}
#endif // CSV_WORLD_PHYSICSMANAGER_H

View file

@ -20,6 +20,7 @@
#include "../widget/scenetoolbar.hpp" #include "../widget/scenetoolbar.hpp"
#include "../widget/scenetoolmode.hpp" #include "../widget/scenetoolmode.hpp"
#include "../widget/scenetooltoggle.hpp" #include "../widget/scenetooltoggle.hpp"
#include "../widget/scenetooltoggle2.hpp"
#include "../widget/scenetoolrun.hpp" #include "../widget/scenetoolrun.hpp"
#include "tablebottombox.hpp" #include "tablebottombox.hpp"
@ -109,7 +110,7 @@ CSVWidget::SceneToolbar* CSVWorld::SceneSubView::makeToolbar (CSVRender::Worldsp
CSVWidget::SceneToolMode *lightingTool = widget->makeLightingSelector (toolbar); CSVWidget::SceneToolMode *lightingTool = widget->makeLightingSelector (toolbar);
toolbar->addTool (lightingTool); toolbar->addTool (lightingTool);
CSVWidget::SceneToolToggle *sceneVisibilityTool = CSVWidget::SceneToolToggle2 *sceneVisibilityTool =
widget->makeSceneVisibilitySelector (toolbar); widget->makeSceneVisibilitySelector (toolbar);
toolbar->addTool (sceneVisibilityTool); toolbar->addTool (sceneVisibilityTool);

View file

@ -47,6 +47,32 @@ void CSVWorld::ScriptSubView::setEditLock (bool locked)
mEditor->setReadOnly (locked); mEditor->setReadOnly (locked);
} }
void CSVWorld::ScriptSubView::useHint (const std::string& hint)
{
if (hint.empty())
return;
if (hint[0]=='l')
{
std::istringstream stream (hint.c_str()+1);
char ignore;
int line;
int column;
if (stream >> ignore >> line >> column)
{
QTextCursor cursor = mEditor->textCursor();
cursor.movePosition (QTextCursor::Start);
if (cursor.movePosition (QTextCursor::Down, QTextCursor::MoveAnchor, line))
cursor.movePosition (QTextCursor::Right, QTextCursor::MoveAnchor, column);
mEditor->setTextCursor (cursor);
}
}
}
void CSVWorld::ScriptSubView::textChanged() void CSVWorld::ScriptSubView::textChanged()
{ {
if (mEditor->isChangeLocked()) if (mEditor->isChangeLocked())

View file

@ -34,6 +34,8 @@ namespace CSVWorld
virtual void setEditLock (bool locked); virtual void setEditLock (bool locked);
virtual void useHint (const std::string& hint);
public slots: public slots:
void textChanged(); void textChanged();

View file

@ -2,6 +2,8 @@
#include "util.hpp" #include "util.hpp"
#include <stdexcept> #include <stdexcept>
#include <climits>
#include <cfloat>
#include <QUndoStack> #include <QUndoStack>
#include <QMetaProperty> #include <QMetaProperty>
@ -157,16 +159,24 @@ QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleO
return new QLineEdit(parent); return new QLineEdit(parent);
case CSMWorld::ColumnBase::Display_Integer: case CSMWorld::ColumnBase::Display_Integer:
{
return new QSpinBox(parent); QSpinBox *sb = new QSpinBox(parent);
sb->setRange(INT_MIN, INT_MAX);
return sb;
}
case CSMWorld::ColumnBase::Display_Var: case CSMWorld::ColumnBase::Display_Var:
return new QLineEdit(parent); return new QLineEdit(parent);
case CSMWorld::ColumnBase::Display_Float: case CSMWorld::ColumnBase::Display_Float:
{
return new QDoubleSpinBox(parent); QDoubleSpinBox *dsb = new QDoubleSpinBox(parent);
dsb->setRange(FLT_MIN, FLT_MAX);
dsb->setSingleStep(0.01f);
dsb->setDecimals(3);
return dsb;
}
case CSMWorld::ColumnBase::Display_LongString: case CSMWorld::ColumnBase::Display_LongString:
{ {

View file

@ -79,8 +79,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
{ {
try try
{ {
float frametime = std::min(evt.timeSinceLastFrame, 0.2f); float frametime = evt.timeSinceLastFrame;
mEnvironment.setFrameDuration (frametime); mEnvironment.setFrameDuration (frametime);
// update input // update input
@ -478,9 +477,15 @@ void OMW::Engine::go()
} }
// Start the main rendering loop // Start the main rendering loop
Ogre::Timer timer;
while (!MWBase::Environment::get().getStateManager()->hasQuitRequest()) while (!MWBase::Environment::get().getStateManager()->hasQuitRequest())
Ogre::Root::getSingleton().renderOneFrame(); {
float dt = timer.getMilliseconds()/1000.f;
dt = std::min(dt, 0.2f);
timer.reset();
Ogre::Root::getSingleton().renderOneFrame(dt);
}
// Save user settings // Save user settings
settings.saveUser(settingspath); settings.saveUser(settingspath);

View file

@ -330,11 +330,11 @@ namespace MWBase
virtual void pinWindow (MWGui::GuiWindow window) = 0; virtual void pinWindow (MWGui::GuiWindow window) = 0;
/// Fade the screen in, over \a time seconds /// Fade the screen in, over \a time seconds
virtual void fadeScreenIn(const float time) = 0; virtual void fadeScreenIn(const float time, bool clearQueue=true) = 0;
/// Fade the screen out to black, over \a time seconds /// Fade the screen out to black, over \a time seconds
virtual void fadeScreenOut(const float time) = 0; virtual void fadeScreenOut(const float time, bool clearQueue=true) = 0;
/// Fade the screen to a specified percentage of black, over \a time seconds /// Fade the screen to a specified percentage of black, over \a time seconds
virtual void fadeScreenTo(const int percent, const float time) = 0; virtual void fadeScreenTo(const int percent, const float time, bool clearQueue=true) = 0;
/// Darken the screen to a specified percentage /// Darken the screen to a specified percentage
virtual void setBlindness(const int percent) = 0; virtual void setBlindness(const int percent) = 0;

View file

@ -279,6 +279,7 @@ namespace MWBase
///< Attempt to fix position so that the Ptr is no longer inside collision geometry. ///< Attempt to fix position so that the Ptr is no longer inside collision geometry.
virtual void deleteObject (const MWWorld::Ptr& ptr) = 0; virtual void deleteObject (const MWWorld::Ptr& ptr) = 0;
virtual void undeleteObject (const MWWorld::Ptr& ptr) = 0;
virtual void moveObject (const MWWorld::Ptr& ptr, float x, float y, float z) = 0; virtual void moveObject (const MWWorld::Ptr& ptr, float x, float y, float z) = 0;

View file

@ -7,6 +7,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/failedaction.hpp" #include "../mwworld/failedaction.hpp"
@ -21,7 +22,7 @@
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/actors.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/npcstats.hpp"
@ -87,7 +88,8 @@ namespace MWClass
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if (!model.empty()) { if (!model.empty()) {
renderingInterface.getObjects().insertModel(ptr, model); MWRender::Actors& actors = renderingInterface.getActors();
actors.insertActivator(ptr);
} }
} }
@ -96,6 +98,7 @@ namespace MWClass
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) if(!model.empty())
physics.addObject(ptr); physics.addObject(ptr);
MWBase::Environment::get().getMechanicsManager()->add(ptr);
} }
std::string Container::getModel(const MWWorld::Ptr &ptr) const std::string Container::getModel(const MWWorld::Ptr &ptr) const

View file

@ -969,6 +969,9 @@ namespace MWClass
float Npc::getJump(const MWWorld::Ptr &ptr) const float Npc::getJump(const MWWorld::Ptr &ptr) const
{ {
if(getEncumbrance(ptr) > getCapacity(ptr))
return 0.f;
const NpcCustomData *npcdata = static_cast<const NpcCustomData*>(ptr.getRefData().getCustomData()); const NpcCustomData *npcdata = static_cast<const NpcCustomData*>(ptr.getRefData().getCustomData());
const GMST& gmst = getGmst(); const GMST& gmst = getGmst();
const MWMechanics::MagicEffects &mageffects = npcdata->mNpcStats.getMagicEffects(); const MWMechanics::MagicEffects &mageffects = npcdata->mNpcStats.getMagicEffects();

View file

@ -533,9 +533,11 @@ namespace MWGui
if (mGoodbye) if (mGoodbye)
{ {
Goodbye* link = new Goodbye();
mLinks.push_back(link);
std::string goodbye = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGoodbye")->getString(); std::string goodbye = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGoodbye")->getString();
BookTypesetter::Style* questionStyle = typesetter->createHotStyle(body, linkNormal, linkHot, linkActive, BookTypesetter::Style* questionStyle = typesetter->createHotStyle(body, linkNormal, linkHot, linkActive,
TypesetBook::InteractiveId(mLinks.back())); TypesetBook::InteractiveId(link));
typesetter->lineBreak(); typesetter->lineBreak();
typesetter->write(questionStyle, to_utf8_span(goodbye.c_str())); typesetter->write(questionStyle, to_utf8_span(goodbye.c_str()));
} }
@ -654,7 +656,6 @@ namespace MWGui
void DialogueWindow::goodbye() void DialogueWindow::goodbye()
{ {
mLinks.push_back(new Goodbye());
mGoodbye = true; mGoodbye = true;
mEnabled = false; mEnabled = false;
updateHistory(); updateHistory();

View file

@ -128,11 +128,17 @@ namespace MWGui
setRaceId(proto.mRace); setRaceId(proto.mRace);
recountParts(); recountParts();
std::string index = proto.mHead.substr(proto.mHead.size() - 2, 2); for (unsigned int i=0; i<mAvailableHeads.size(); ++i)
mFaceIndex = boost::lexical_cast<int>(index) - 1; {
if (mAvailableHeads[i] == proto.mHead)
mFaceIndex = i;
}
index = proto.mHair.substr(proto.mHair.size() - 2, 2); for (unsigned int i=0; i<mAvailableHairs.size(); ++i)
mHairIndex = boost::lexical_cast<int>(index) - 1; {
if (mAvailableHairs[i] == proto.mHair)
mHairIndex = i;
}
mPreviewImage->setImageTexture (textureName); mPreviewImage->setImageTexture (textureName);
@ -162,6 +168,9 @@ namespace MWGui
void RaceDialog::close() void RaceDialog::close()
{ {
mPreviewImage->setImageTexture("");
const std::string textureName = "CharacterHeadPreview";
MyGUI::RenderManager::getInstance().destroyTexture(MyGUI::RenderManager::getInstance().getTexture(textureName));
mPreview.reset(NULL); mPreview.reset(NULL);
} }
@ -304,7 +313,15 @@ namespace MWGui
record.mHead = mAvailableHeads[mFaceIndex]; record.mHead = mAvailableHeads[mFaceIndex];
record.mHair = mAvailableHairs[mHairIndex]; record.mHair = mAvailableHairs[mHairIndex];
mPreview->setPrototype(record); try
{
mPreview->setPrototype(record);
}
catch (std::exception& e)
{
std::cerr << "Error creating preview: " << e.what() << std::endl;
}
mPreviewDirty = true; mPreviewDirty = true;
} }

View file

@ -9,6 +9,8 @@
#include <SDL_video.h> #include <SDL_video.h>
#include <components/widgets/sharedstatebutton.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
@ -454,16 +456,21 @@ namespace MWGui
std::string binding = MWBase::Environment::get().getInputManager()->getActionBindingName (*it); std::string binding = MWBase::Environment::get().getInputManager()->getActionBindingName (*it);
MyGUI::TextBox* leftText = mControlsBox->createWidget<MyGUI::TextBox>("SandText", MyGUI::IntCoord(0,curH,w,h), MyGUI::Align::Default); Gui::SharedStateButton* leftText = mControlsBox->createWidget<Gui::SharedStateButton>("SandTextButton", MyGUI::IntCoord(0,curH,w,h), MyGUI::Align::Default);
leftText->setCaptionWithReplacing(desc); leftText->setCaptionWithReplacing(desc);
MyGUI::Button* rightText = mControlsBox->createWidget<MyGUI::Button>("SandTextButton", MyGUI::IntCoord(0,curH,w,h), MyGUI::Align::Default); Gui::SharedStateButton* rightText = mControlsBox->createWidget<Gui::SharedStateButton>("SandTextButton", MyGUI::IntCoord(0,curH,w,h), MyGUI::Align::Default);
rightText->setCaptionWithReplacing(binding); rightText->setCaptionWithReplacing(binding);
rightText->setTextAlign (MyGUI::Align::Right); rightText->setTextAlign (MyGUI::Align::Right);
rightText->setUserData(*it); // save the action id for callbacks rightText->setUserData(*it); // save the action id for callbacks
rightText->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onRebindAction); rightText->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onRebindAction);
rightText->eventMouseWheel += MyGUI::newDelegate(this, &SettingsWindow::onInputTabMouseWheel); rightText->eventMouseWheel += MyGUI::newDelegate(this, &SettingsWindow::onInputTabMouseWheel);
curH += h; curH += h;
Gui::ButtonGroup group;
group.push_back(leftText);
group.push_back(rightText);
Gui::SharedStateButton::createButtonGroup(group);
} }
// Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden // Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden

View file

@ -3,6 +3,8 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <components/widgets/sharedstatebutton.hpp>
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -177,7 +179,7 @@ namespace MWGui
for (std::vector<std::string>::const_iterator it = spellList.begin(); it != spellList.end(); ++it) for (std::vector<std::string>::const_iterator it = spellList.begin(); it != spellList.end(); ++it)
{ {
const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it); const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it);
MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>("SandTextButton", Gui::SharedStateButton* t = mSpellView->createWidget<Gui::SharedStateButton>("SandTextButton",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
t->setCaption(spell->mName); t->setCaption(spell->mName);
t->setTextAlign(MyGUI::Align::Left); t->setTextAlign(MyGUI::Align::Left);
@ -185,20 +187,28 @@ namespace MWGui
t->setUserString("Spell", *it); t->setUserString("Spell", *it);
t->eventMouseWheel += MyGUI::newDelegate(this, &SpellWindow::onMouseWheel); t->eventMouseWheel += MyGUI::newDelegate(this, &SpellWindow::onMouseWheel);
t->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellWindow::onSpellSelected); t->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellWindow::onSpellSelected);
t->setStateSelected(*it == MWBase::Environment::get().getWindowManager()->getSelectedSpell());
// cost / success chance // cost / success chance
MyGUI::Button* costChance = mSpellView->createWidget<MyGUI::Button>("SandTextButton", Gui::SharedStateButton* costChance = mSpellView->createWidget<Gui::SharedStateButton>("SandTextButton",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
std::string cost = boost::lexical_cast<std::string>(spell->mData.mCost); std::string cost = boost::lexical_cast<std::string>(spell->mData.mCost);
std::string chance = boost::lexical_cast<std::string>(int(MWMechanics::getSpellSuccessChance(*it, player))); std::string chance = boost::lexical_cast<std::string>(int(MWMechanics::getSpellSuccessChance(*it, player)));
costChance->setCaption(cost + "/" + chance); costChance->setCaption(cost + "/" + chance);
costChance->setTextAlign(MyGUI::Align::Right); costChance->setTextAlign(MyGUI::Align::Right);
costChance->setNeedMouseFocus(false); costChance->setUserString("ToolTipType", "Spell");
costChance->setStateSelected(*it == MWBase::Environment::get().getWindowManager()->getSelectedSpell()); costChance->setUserString("Spell", *it);
costChance->eventMouseWheel += MyGUI::newDelegate(this, &SpellWindow::onMouseWheel);
costChance->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellWindow::onSpellSelected);
t->setSize(mWidth-12-costChance->getTextSize().width, t->getHeight()); t->setSize(mWidth-12-costChance->getTextSize().width, t->getHeight());
Gui::ButtonGroup group;
group.push_back(t);
group.push_back(costChance);
Gui::SharedStateButton::createButtonGroup(group);
t->setStateSelected(*it == MWBase::Environment::get().getWindowManager()->getSelectedSpell());
mHeight += spellHeight; mHeight += spellHeight;
} }
@ -224,7 +234,7 @@ namespace MWGui
} }
} }
MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>(equipped ? "SandTextButton" : "SpellTextUnequipped", Gui::SharedStateButton* t = mSpellView->createWidget<Gui::SharedStateButton>(equipped ? "SandTextButton" : "SpellTextUnequipped",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
t->setCaption(item.getClass().getName(item)); t->setCaption(item.getClass().getName(item));
t->setTextAlign(MyGUI::Align::Left); t->setTextAlign(MyGUI::Align::Left);
@ -233,12 +243,9 @@ namespace MWGui
t->setUserString("Equipped", equipped ? "true" : "false"); t->setUserString("Equipped", equipped ? "true" : "false");
t->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellWindow::onEnchantedItemSelected); t->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellWindow::onEnchantedItemSelected);
t->eventMouseWheel += MyGUI::newDelegate(this, &SpellWindow::onMouseWheel); t->eventMouseWheel += MyGUI::newDelegate(this, &SpellWindow::onMouseWheel);
if (store.getSelectedEnchantItem() != store.end())
t->setStateSelected(item == *store.getSelectedEnchantItem());
// cost / charge // cost / charge
MyGUI::Button* costCharge = mSpellView->createWidget<MyGUI::Button>(equipped ? "SandTextButton" : "SpellTextUnequipped", Gui::SharedStateButton* costCharge = mSpellView->createWidget<Gui::SharedStateButton>(equipped ? "SandTextButton" : "SpellTextUnequipped",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
float enchantCost = enchant->mData.mCost; float enchantCost = enchant->mData.mCost;
@ -257,11 +264,22 @@ namespace MWGui
charge = "100"; charge = "100";
} }
costCharge->setUserData(item);
costCharge->setUserString("ToolTipType", "ItemPtr");
costCharge->setUserString("Equipped", equipped ? "true" : "false");
costCharge->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellWindow::onEnchantedItemSelected);
costCharge->eventMouseWheel += MyGUI::newDelegate(this, &SpellWindow::onMouseWheel);
costCharge->setCaption(cost + "/" + charge); costCharge->setCaption(cost + "/" + charge);
costCharge->setTextAlign(MyGUI::Align::Right); costCharge->setTextAlign(MyGUI::Align::Right);
costCharge->setNeedMouseFocus(false);
Gui::ButtonGroup group;
group.push_back(t);
group.push_back(costCharge);
Gui::SharedStateButton::createButtonGroup(group);
if (store.getSelectedEnchantItem() != store.end()) if (store.getSelectedEnchantItem() != store.end())
costCharge->setStateSelected(item == *store.getSelectedEnchantItem()); t->setStateSelected(item == *store.getSelectedEnchantItem());
t->setSize(mWidth-12-costCharge->getTextSize().width, t->getHeight()); t->setSize(mWidth-12-costCharge->getTextSize().width, t->getHeight());

View file

@ -633,8 +633,8 @@ namespace MWGui
MWWorld::Store<ESM::Skill>::iterator it = skills.begin(); MWWorld::Store<ESM::Skill>::iterator it = skills.begin();
for (; it != skills.end(); ++it) for (; it != skills.end(); ++it)
{ {
if (it->mData.mSpecialization == specId) if (it->second.mData.mSpecialization == specId)
specText += std::string("\n#{") + ESM::Skill::sSkillNameIds[it->mIndex] + "}"; specText += std::string("\n#{") + ESM::Skill::sSkillNameIds[it->first] + "}";
} }
widget->setUserString("Caption_CenteredCaptionText", specText); widget->setUserString("Caption_CenteredCaptionText", specText);
widget->setUserString("ToolTipLayout", "TextWithCenteredCaptionToolTip"); widget->setUserString("ToolTipLayout", "TextWithCenteredCaptionToolTip");

View file

@ -1748,21 +1748,24 @@ namespace MWGui
updateVisible(); updateVisible();
} }
void WindowManager::fadeScreenIn(const float time) void WindowManager::fadeScreenIn(const float time, bool clearQueue)
{ {
mScreenFader->clearQueue(); if (clearQueue)
mScreenFader->clearQueue();
mScreenFader->fadeOut(time); mScreenFader->fadeOut(time);
} }
void WindowManager::fadeScreenOut(const float time) void WindowManager::fadeScreenOut(const float time, bool clearQueue)
{ {
mScreenFader->clearQueue(); if (clearQueue)
mScreenFader->clearQueue();
mScreenFader->fadeIn(time); mScreenFader->fadeIn(time);
} }
void WindowManager::fadeScreenTo(const int percent, const float time) void WindowManager::fadeScreenTo(const int percent, const float time, bool clearQueue)
{ {
mScreenFader->clearQueue(); if (clearQueue)
mScreenFader->clearQueue();
mScreenFader->fadeTo(percent, time); mScreenFader->fadeTo(percent, time);
} }

View file

@ -325,11 +325,11 @@ namespace MWGui
virtual void pinWindow (MWGui::GuiWindow window); virtual void pinWindow (MWGui::GuiWindow window);
/// Fade the screen in, over \a time seconds /// Fade the screen in, over \a time seconds
virtual void fadeScreenIn(const float time); virtual void fadeScreenIn(const float time, bool clearQueue);
/// Fade the screen out to black, over \a time seconds /// Fade the screen out to black, over \a time seconds
virtual void fadeScreenOut(const float time); virtual void fadeScreenOut(const float time, bool clearQueue);
/// Fade the screen to a specified percentage of black, over \a time seconds /// Fade the screen to a specified percentage of black, over \a time seconds
virtual void fadeScreenTo(const int percent, const float time); virtual void fadeScreenTo(const int percent, const float time, bool clearQueue);
/// Darken the screen to a specified percentage /// Darken the screen to a specified percentage
virtual void setBlindness(const int percent); virtual void setBlindness(const int percent);

View file

@ -190,14 +190,12 @@ namespace MWInput
int action = channel->getNumber(); int action = channel->getNumber();
if (action == A_Use) if (mControlSwitch["playercontrols"])
{ {
mPlayer->getPlayer().getClass().getCreatureStats(mPlayer->getPlayer()).setAttackingOrSpell(currentValue); if (action == A_Use)
} mPlayer->getPlayer().getClass().getCreatureStats(mPlayer->getPlayer()).setAttackingOrSpell(currentValue);
else if (action == A_Jump)
if (action == A_Jump) mAttemptJump = (currentValue == 1.0 && previousValue == 0.0);
{
mAttemptJump = (currentValue == 1.0 && previousValue == 0.0);
} }
if (currentValue == 1) if (currentValue == 1)
@ -373,6 +371,7 @@ namespace MWInput
{ {
mPlayer->setUpDown (1); mPlayer->setUpDown (1);
triedToMove = true; triedToMove = true;
mOverencumberedMessageDelay = 0.f;
} }
if (mAlwaysRunActive) if (mAlwaysRunActive)
@ -603,7 +602,7 @@ namespace MWInput
MyGUI::InputManager::getInstance().injectMouseMove( int(mMouseX), int(mMouseY), mMouseWheel); MyGUI::InputManager::getInstance().injectMouseMove( int(mMouseX), int(mMouseY), mMouseWheel);
} }
if (mMouseLookEnabled) if (mMouseLookEnabled && !mControlsDisabled)
{ {
resetIdleTime(); resetIdleTime();
@ -622,10 +621,12 @@ namespace MWInput
mPlayer->pitch(y); mPlayer->pitch(y);
} }
if (arg.zrel && mControlSwitch["playerviewswitch"]) //Check to make sure you are allowed to zoomout and there is a change if (arg.zrel && mControlSwitch["playerviewswitch"] && mControlSwitch["playercontrols"]) //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);
if (Settings::Manager::getBool("allow third person zoom", "Input"))
MWBase::Environment::get().getWorld()->setCameraDistance(arg.zrel, true, true);
} }
} }
} }
@ -680,7 +681,7 @@ namespace MWInput
if (MWBase::Environment::get().getWindowManager()->isGuiMode()) return; if (MWBase::Environment::get().getWindowManager()->isGuiMode()) return;
// Not allowed before the magic window is accessible // Not allowed before the magic window is accessible
if (!mControlSwitch["playermagic"]) if (!mControlSwitch["playermagic"] || !mControlSwitch["playercontrols"])
return; return;
// Not allowed if no spell selected // Not allowed if no spell selected
@ -701,7 +702,7 @@ namespace MWInput
if (MWBase::Environment::get().getWindowManager()->isGuiMode()) return; if (MWBase::Environment::get().getWindowManager()->isGuiMode()) return;
// Not allowed before the inventory window is accessible // Not allowed before the inventory window is accessible
if (!mControlSwitch["playerfighting"]) if (!mControlSwitch["playerfighting"] || !mControlSwitch["playercontrols"])
return; return;
MWMechanics::DrawState_ state = mPlayer->getDrawState(); MWMechanics::DrawState_ state = mPlayer->getDrawState();
@ -713,6 +714,9 @@ namespace MWInput
void InputManager::rest() void InputManager::rest()
{ {
if (!mControlSwitch["playercontrols"])
return;
if (!MWBase::Environment::get().getWindowManager()->getRestEnabled () || MWBase::Environment::get().getWindowManager()->isGuiMode ()) if (!MWBase::Environment::get().getWindowManager()->getRestEnabled () || MWBase::Environment::get().getWindowManager()->isGuiMode ())
return; return;
@ -734,6 +738,9 @@ namespace MWInput
void InputManager::toggleInventory() void InputManager::toggleInventory()
{ {
if (!mControlSwitch["playercontrols"])
return;
if (MyGUI::InputManager::getInstance ().isModalAny()) if (MyGUI::InputManager::getInstance ().isModalAny())
return; return;
@ -770,6 +777,8 @@ namespace MWInput
void InputManager::toggleJournal() void InputManager::toggleJournal()
{ {
if (!mControlSwitch["playercontrols"])
return;
if (MyGUI::InputManager::getInstance ().isModalAny()) if (MyGUI::InputManager::getInstance ().isModalAny())
return; return;
@ -787,6 +796,8 @@ namespace MWInput
void InputManager::quickKey (int index) void InputManager::quickKey (int index)
{ {
if (!mControlSwitch["playercontrols"])
return;
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
if (player.getClass().getNpcStats(player).isWerewolf()) if (player.getClass().getNpcStats(player).isWerewolf())
{ {

View file

@ -17,18 +17,35 @@ namespace MWMechanics
MWWorld::TimeStamp now = MWBase::Environment::get().getWorld()->getTimeStamp(); MWWorld::TimeStamp now = MWBase::Environment::get().getWorld()->getTimeStamp();
// Erase no longer active spells // Erase no longer active spells and effects
if (mLastUpdate!=now) if (mLastUpdate!=now)
{ {
TContainer::iterator iter (mSpells.begin()); TContainer::iterator iter (mSpells.begin());
while (iter!=mSpells.end()) while (iter!=mSpells.end())
{
if (!timeToExpire (iter)) if (!timeToExpire (iter))
{ {
mSpells.erase (iter++); mSpells.erase (iter++);
rebuild = true; rebuild = true;
} }
else else
{
std::vector<ActiveEffect>& effects = iter->second.mEffects;
for (std::vector<ActiveEffect>::iterator effectIt = effects.begin(); effectIt != effects.end();)
{
MWWorld::TimeStamp start = iter->second.mTimeStamp;
MWWorld::TimeStamp end = start + static_cast<double>(effectIt->mDuration)*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/(60*60);
if (end <= now)
{
effectIt = effects.erase(effectIt);
rebuild = true;
}
else
++effectIt;
}
++iter; ++iter;
}
}
mLastUpdate = now; mLastUpdate = now;
} }

View file

@ -396,11 +396,7 @@ namespace MWMechanics
{ {
CreatureStats& creatureStats = ptr.getClass().getCreatureStats (ptr); CreatureStats& creatureStats = ptr.getClass().getCreatureStats (ptr);
int strength = creatureStats.getAttribute(ESM::Attribute::Strength).getModified();
int intelligence = creatureStats.getAttribute(ESM::Attribute::Intelligence).getModified(); int intelligence = creatureStats.getAttribute(ESM::Attribute::Intelligence).getModified();
int willpower = creatureStats.getAttribute(ESM::Attribute::Willpower).getModified();
int agility = creatureStats.getAttribute(ESM::Attribute::Agility).getModified();
int endurance = creatureStats.getAttribute(ESM::Attribute::Endurance).getModified();
float base = 1.f; float base = 1.f;
if (ptr.getCellRef().getRefId() == "player") if (ptr.getCellRef().getRefId() == "player")
@ -415,11 +411,6 @@ namespace MWMechanics
float diff = (static_cast<int>(magickaFactor*intelligence)) - magicka.getBase(); float diff = (static_cast<int>(magickaFactor*intelligence)) - magicka.getBase();
magicka.modify(diff); magicka.modify(diff);
creatureStats.setMagicka(magicka); creatureStats.setMagicka(magicka);
DynamicStat<float> fatigue = creatureStats.getFatigue();
diff = (strength+willpower+agility+endurance) - fatigue.getBase();
fatigue.modify(diff);
creatureStats.setFatigue(fatigue);
} }
void Actors::restoreDynamicStats (const MWWorld::Ptr& ptr, bool sleep) void Actors::restoreDynamicStats (const MWWorld::Ptr& ptr, bool sleep)

View file

@ -325,6 +325,11 @@ namespace MWMechanics
currentAction = prepareNextAction(actor, target); currentAction = prepareNextAction(actor, target);
actionCooldown = currentAction->getActionCooldown(); actionCooldown = currentAction->getActionCooldown();
} }
// Stop attacking if target is not seen
if (!MWBase::Environment::get().getMechanicsManager()->awarenessCheck(target, actor))
return true;
if (currentAction.get()) if (currentAction.get())
currentAction->getCombatRange(rangeAttack, rangeFollow); currentAction->getCombatRange(rangeAttack, rangeFollow);

View file

@ -9,6 +9,7 @@
#include "../mwworld/actionequip.hpp" #include "../mwworld/actionequip.hpp"
#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/spellcasting.hpp"
#include <components/esm/loadench.hpp> #include <components/esm/loadench.hpp>
#include <components/esm/loadmgef.hpp> #include <components/esm/loadmgef.hpp>
@ -166,6 +167,9 @@ namespace MWMechanics
{ {
const CreatureStats& stats = actor.getClass().getCreatureStats(actor); const CreatureStats& stats = actor.getClass().getCreatureStats(actor);
if (MWMechanics::getSpellSuccessChance(spell, actor) == 0)
return 0.f;
if (spell->mData.mType != ESM::Spell::ST_Spell) if (spell->mData.mType != ESM::Spell::ST_Spell)
return 0.f; return 0.f;

View file

@ -69,6 +69,7 @@ namespace MWMechanics
/** \return If the actor has arrived at his destination **/ /** \return If the actor has arrived at his destination **/
bool pathTo(const MWWorld::Ptr& actor, ESM::Pathgrid::Point dest, float duration); bool pathTo(const MWWorld::Ptr& actor, ESM::Pathgrid::Point dest, float duration);
// TODO: all this does not belong here, move into temporary storage
PathFinder mPathFinder; PathFinder mPathFinder;
ObstacleCheck mObstacleCheck; ObstacleCheck mObstacleCheck;

View file

@ -57,6 +57,8 @@ namespace MWMechanics
bool mWalking; bool mWalking;
unsigned short mPlayedIdle; unsigned short mPlayedIdle;
PathFinder mPathFinder;
AiWanderStorage(): AiWanderStorage():
mTargetAngle(0), mTargetAngle(0),
@ -211,9 +213,9 @@ namespace MWMechanics
// Are we there yet? // Are we there yet?
bool& chooseAction = storage.mChooseAction; bool& chooseAction = storage.mChooseAction;
if(walking && if(walking &&
mPathFinder.checkPathCompleted(pos.pos[0], pos.pos[1], pos.pos[2])) storage.mPathFinder.checkPathCompleted(pos.pos[0], pos.pos[1], pos.pos[2]))
{ {
stopWalking(actor); stopWalking(actor, storage);
moveNow = false; moveNow = false;
walking = false; walking = false;
chooseAction = true; chooseAction = true;
@ -225,7 +227,7 @@ namespace MWMechanics
if(walking) // have not yet reached the destination if(walking) // have not yet reached the destination
{ {
// turn towards the next point in mPath // turn towards the next point in mPath
zTurn(actor, Ogre::Degree(mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]))); zTurn(actor, Ogre::Degree(storage.mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1])));
actor.getClass().getMovementSettings(actor).mPosition[1] = 1; actor.getClass().getMovementSettings(actor).mPosition[1] = 1;
// Returns true if evasive action needs to be taken // Returns true if evasive action needs to be taken
@ -236,9 +238,9 @@ namespace MWMechanics
{ {
// remove allowed points then select another random destination // remove allowed points then select another random destination
mTrimCurrentNode = true; mTrimCurrentNode = true;
trimAllowedNodes(mAllowedNodes, mPathFinder); trimAllowedNodes(mAllowedNodes, storage.mPathFinder);
mObstacleCheck.clear(); mObstacleCheck.clear();
mPathFinder.clearPath(); storage.mPathFinder.clearPath();
walking = false; walking = false;
moveNow = true; moveNow = true;
} }
@ -249,7 +251,7 @@ namespace MWMechanics
actor.getClass().getMovementSettings(actor).mPosition[0] = 1; actor.getClass().getMovementSettings(actor).mPosition[0] = 1;
actor.getClass().getMovementSettings(actor).mPosition[1] = 0.1f; actor.getClass().getMovementSettings(actor).mPosition[1] = 0.1f;
// change the angle a bit, too // change the angle a bit, too
zTurn(actor, Ogre::Degree(mPathFinder.getZAngleToNext(pos.pos[0] + 1, pos.pos[1]))); zTurn(actor, Ogre::Degree(storage.mPathFinder.getZAngleToNext(pos.pos[0] + 1, pos.pos[1])));
} }
mStuckCount++; // TODO: maybe no longer needed mStuckCount++; // TODO: maybe no longer needed
} }
@ -260,7 +262,7 @@ namespace MWMechanics
//std::cout << "Reset \""<< cls.getName(actor) << "\"" << std::endl; //std::cout << "Reset \""<< cls.getName(actor) << "\"" << std::endl;
mObstacleCheck.clear(); mObstacleCheck.clear();
stopWalking(actor); stopWalking(actor, storage);
moveNow = false; moveNow = false;
walking = false; walking = false;
chooseAction = true; chooseAction = true;
@ -280,6 +282,58 @@ namespace MWMechanics
rotate = false; rotate = false;
} }
// Check if idle animation finished
short unsigned& playedIdle = storage.mPlayedIdle;
GreetingState& greetingState = storage.mSaidGreeting;
if(idleNow && !checkIdle(actor, playedIdle) && (greetingState == Greet_Done || greetingState == Greet_None))
{
playedIdle = 0;
idleNow = false;
chooseAction = true;
}
MWBase::World *world = MWBase::Environment::get().getWorld();
if(chooseAction)
{
playedIdle = 0;
getRandomIdle(playedIdle); // NOTE: sets mPlayedIdle with a random selection
if(!playedIdle && mDistance)
{
chooseAction = false;
moveNow = true;
}
else
{
// Play idle animation and recreate vanilla (broken?) behavior of resetting start time of AIWander:
MWWorld::TimeStamp currentTime = world->getTimeStamp();
mStartTime = currentTime;
playIdle(actor, playedIdle);
chooseAction = false;
idleNow = true;
// Play idle voiced dialogue entries randomly
int hello = cStats.getAiSetting(CreatureStats::AI_Hello).getModified();
if (hello > 0)
{
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
// Don't bother if the player is out of hearing range
static float fVoiceIdleOdds = MWBase::Environment::get().getWorld()->getStore()
.get<ESM::GameSetting>().find("fVoiceIdleOdds")->getFloat();
// Only say Idle voices when player is in LOS
// A bit counterintuitive, likely vanilla did this to reduce the appearance of
// voices going through walls?
if (roll < fVoiceIdleOdds && Ogre::Vector3(player.getRefData().getPosition().pos).squaredDistance(Ogre::Vector3(pos.pos)) < 1500*1500
&& MWBase::Environment::get().getWorld()->getLOS(player, actor))
MWBase::Environment::get().getDialogueManager()->say(actor, "idle");
}
}
}
float& lastReaction = storage.mReaction; float& lastReaction = storage.mReaction;
lastReaction += duration; lastReaction += duration;
if(lastReaction < REACTION_INTERVAL) if(lastReaction < REACTION_INTERVAL)
@ -291,7 +345,6 @@ namespace MWMechanics
// NOTE: everything below get updated every REACTION_INTERVAL seconds // NOTE: everything below get updated every REACTION_INTERVAL seconds
MWBase::World *world = MWBase::Environment::get().getWorld();
if(mDuration) if(mDuration)
{ {
// End package if duration is complete or mid-night hits: // End package if duration is complete or mid-night hits:
@ -300,7 +353,7 @@ namespace MWMechanics
{ {
if(!mRepeat) if(!mRepeat)
{ {
stopWalking(actor); stopWalking(actor, storage);
return true; return true;
} }
else else
@ -310,7 +363,7 @@ namespace MWMechanics
{ {
if(!mRepeat) if(!mRepeat)
{ {
stopWalking(actor); stopWalking(actor, storage);
return true; return true;
} }
else else
@ -411,7 +464,7 @@ namespace MWMechanics
chooseAction = false; chooseAction = false;
idleNow = false; idleNow = false;
if (!mPathFinder.isPathConstructed()) if (!storage.mPathFinder.isPathConstructed())
{ {
Ogre::Vector3 destNodePos = mReturnPosition; Ogre::Vector3 destNodePos = mReturnPosition;
@ -427,9 +480,9 @@ namespace MWMechanics
start.mZ = pos.pos[2]; start.mZ = pos.pos[2];
// don't take shortcuts for wandering // don't take shortcuts for wandering
mPathFinder.buildPath(start, dest, actor.getCell(), false); storage.mPathFinder.buildPath(start, dest, actor.getCell(), false);
if(mPathFinder.isPathConstructed()) if(storage.mPathFinder.isPathConstructed())
{ {
moveNow = false; moveNow = false;
walking = true; walking = true;
@ -437,48 +490,6 @@ namespace MWMechanics
} }
} }
AiWander::GreetingState& greetingState = storage.mSaidGreeting;
short unsigned& playedIdle = storage.mPlayedIdle;
if(chooseAction)
{
playedIdle = 0;
getRandomIdle(playedIdle); // NOTE: sets mPlayedIdle with a random selection
if(!playedIdle && mDistance)
{
chooseAction = false;
moveNow = true;
}
else
{
// Play idle animation and recreate vanilla (broken?) behavior of resetting start time of AIWander:
MWWorld::TimeStamp currentTime = world->getTimeStamp();
mStartTime = currentTime;
playIdle(actor, playedIdle);
chooseAction = false;
idleNow = true;
// Play idle voiced dialogue entries randomly
int hello = cStats.getAiSetting(CreatureStats::AI_Hello).getModified();
if (hello > 0)
{
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
// Don't bother if the player is out of hearing range
static float fVoiceIdleOdds = MWBase::Environment::get().getWorld()->getStore()
.get<ESM::GameSetting>().find("fVoiceIdleOdds")->getFloat();
// Only say Idle voices when player is in LOS
// A bit counterintuitive, likely vanilla did this to reduce the appearance of
// voices going through walls?
if (roll < fVoiceIdleOdds && Ogre::Vector3(player.getRefData().getPosition().pos).squaredDistance(Ogre::Vector3(pos.pos)) < 1500*1500
&& MWBase::Environment::get().getWorld()->getLOS(player, actor))
MWBase::Environment::get().getDialogueManager()->say(actor, "idle");
}
}
}
// Allow interrupting a walking actor to trigger a greeting // Allow interrupting a walking actor to trigger a greeting
if(idleNow || walking) if(idleNow || walking)
{ {
@ -494,7 +505,7 @@ namespace MWMechanics
Ogre::Vector3 playerPos(player.getRefData().getPosition().pos); Ogre::Vector3 playerPos(player.getRefData().getPosition().pos);
Ogre::Vector3 actorPos(actor.getRefData().getPosition().pos); Ogre::Vector3 actorPos(actor.getRefData().getPosition().pos);
float playerDistSqr = playerPos.squaredDistance(actorPos); float playerDistSqr = playerPos.squaredDistance(actorPos);
int& greetingTimer = storage.mGreetingTimer; int& greetingTimer = storage.mGreetingTimer;
if (greetingState == Greet_None) if (greetingState == Greet_None)
{ {
@ -517,7 +528,7 @@ namespace MWMechanics
if(walking) if(walking)
{ {
stopWalking(actor); stopWalking(actor, storage);
moveNow = false; moveNow = false;
walking = false; walking = false;
mObstacleCheck.clear(); mObstacleCheck.clear();
@ -554,20 +565,12 @@ namespace MWMechanics
if (playerDistSqr >= fGreetDistanceReset*fGreetDistanceReset) if (playerDistSqr >= fGreetDistanceReset*fGreetDistanceReset)
greetingState = Greet_None; greetingState = Greet_None;
} }
// Check if idle animation finished
if(!checkIdle(actor, playedIdle) && (playerDistSqr > helloDistance*helloDistance || greetingState == MWMechanics::AiWander::Greet_Done))
{
playedIdle = 0;
idleNow = false;
chooseAction = true;
}
} }
if(moveNow && mDistance) if(moveNow && mDistance)
{ {
// Construct a new path if there isn't one // Construct a new path if there isn't one
if(!mPathFinder.isPathConstructed()) if(!storage.mPathFinder.isPathConstructed())
{ {
assert(mAllowedNodes.size()); assert(mAllowedNodes.size());
unsigned int randNode = (int)(rand() / ((double)RAND_MAX + 1) * mAllowedNodes.size()); unsigned int randNode = (int)(rand() / ((double)RAND_MAX + 1) * mAllowedNodes.size());
@ -589,16 +592,16 @@ namespace MWMechanics
start.mZ = pos.pos[2]; start.mZ = pos.pos[2];
// don't take shortcuts for wandering // don't take shortcuts for wandering
mPathFinder.buildPath(start, dest, actor.getCell(), false); storage.mPathFinder.buildPath(start, dest, actor.getCell(), false);
if(mPathFinder.isPathConstructed()) if(storage.mPathFinder.isPathConstructed())
{ {
// buildPath inserts dest in case it is not a pathgraph point // buildPath inserts dest in case it is not a pathgraph point
// index which is a duplicate for AiWander. However below code // index which is a duplicate for AiWander. However below code
// does not work since getPath() returns a copy of path not a // does not work since getPath() returns a copy of path not a
// reference // reference
//if(mPathFinder.getPathSize() > 1) //if(storage.mPathFinder.getPathSize() > 1)
//mPathFinder.getPath().pop_back(); //storage.mPathFinder.getPath().pop_back();
// Remove this node as an option and add back the previously used node (stops NPC from picking the same node): // Remove this node as an option and add back the previously used node (stops NPC from picking the same node):
ESM::Pathgrid::Point temp = mAllowedNodes[randNode]; ESM::Pathgrid::Point temp = mAllowedNodes[randNode];
@ -616,7 +619,7 @@ namespace MWMechanics
// Choose a different node and delete this one from possible nodes because it is uncreachable: // Choose a different node and delete this one from possible nodes because it is uncreachable:
else else
mAllowedNodes.erase(mAllowedNodes.begin() + randNode); mAllowedNodes.erase(mAllowedNodes.begin() + randNode);
} }
} }
return false; // AiWander package not yet completed return false; // AiWander package not yet completed
@ -653,9 +656,9 @@ namespace MWMechanics
return TypeIdWander; return TypeIdWander;
} }
void AiWander::stopWalking(const MWWorld::Ptr& actor) void AiWander::stopWalking(const MWWorld::Ptr& actor, AiWanderStorage& storage)
{ {
mPathFinder.clearPath(); storage.mPathFinder.clearPath();
actor.getClass().getMovementSettings(actor).mPosition[1] = 0; actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
} }

Some files were not shown because too many files have changed in this diff Show more