mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-28 19:21:04 +00:00
Merge branch 'registered_class' into 'master'
Use static object to register classes See merge request OpenMW/openmw!1746
This commit is contained in:
commit
320e86156e
@ -28,6 +28,10 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
Activator::Activator()
|
||||||
|
: MWWorld::RegisteredClass<Activator>(ESM::Activator::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Activator::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
void Activator::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
@ -84,13 +88,6 @@ namespace MWClass
|
|||||||
return ref->mBase->mScript;
|
return ref->mBase->mScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Activator::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Activator);
|
|
||||||
|
|
||||||
registerClass (ESM::Activator::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Activator::hasToolTip (const MWWorld::ConstPtr& ptr) const
|
bool Activator::hasToolTip (const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
return !getName(ptr).empty();
|
return !getName(ptr).empty();
|
||||||
|
@ -1,19 +1,21 @@
|
|||||||
#ifndef GAME_MWCLASS_ACTIVATOR_H
|
#ifndef GAME_MWCLASS_ACTIVATOR_H
|
||||||
#define GAME_MWCLASS_ACTIVATOR_H
|
#define GAME_MWCLASS_ACTIVATOR_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Activator : public MWWorld::Class
|
class Activator final : public MWWorld::RegisteredClass<Activator>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Activator>;
|
||||||
|
|
||||||
|
Activator();
|
||||||
|
|
||||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
|
|
||||||
static int getSndGenTypeFromName(const std::string &name);
|
static int getSndGenTypeFromName(const std::string &name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||||
///< Add reference into a cell for rendering
|
///< Add reference into a cell for rendering
|
||||||
|
|
||||||
@ -36,8 +38,6 @@ namespace MWClass
|
|||||||
std::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
|
std::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
|
||||||
///< Generate action for activation
|
///< Generate action for activation
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getModel(const MWWorld::ConstPtr &ptr) const override;
|
std::string getModel(const MWWorld::ConstPtr &ptr) const override;
|
||||||
|
|
||||||
bool useAnim() const override;
|
bool useAnim() const override;
|
||||||
|
@ -17,7 +17,7 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Actor() = default;
|
explicit Actor(unsigned type) : Class(type) {}
|
||||||
|
|
||||||
template <class GMST>
|
template <class GMST>
|
||||||
float getSwimSpeedImpl(const MWWorld::Ptr& ptr, const GMST& gmst, const MWMechanics::MagicEffects& mageffects, float baseSpeed) const
|
float getSwimSpeedImpl(const MWWorld::Ptr& ptr, const GMST& gmst, const MWMechanics::MagicEffects& mageffects, float baseSpeed) const
|
||||||
|
@ -18,6 +18,10 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
Apparatus::Apparatus()
|
||||||
|
: MWWorld::RegisteredClass<Apparatus>(ESM::Apparatus::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
@ -65,13 +69,6 @@ namespace MWClass
|
|||||||
return ref->mBase->mData.mValue;
|
return ref->mBase->mData.mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Apparatus::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Apparatus);
|
|
||||||
|
|
||||||
registerClass (ESM::Apparatus::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Apparatus::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
std::string Apparatus::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
return std::string("Item Apparatus Up");
|
return std::string("Item Apparatus Up");
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
#ifndef GAME_MWCLASS_APPARATUS_H
|
#ifndef GAME_MWCLASS_APPARATUS_H
|
||||||
#define GAME_MWCLASS_APPARATUS_H
|
#define GAME_MWCLASS_APPARATUS_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Apparatus : public MWWorld::Class
|
class Apparatus : public MWWorld::RegisteredClass<Apparatus>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Apparatus>;
|
||||||
|
|
||||||
|
Apparatus();
|
||||||
|
|
||||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
|
|
||||||
@ -33,8 +36,6 @@ namespace MWClass
|
|||||||
MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override;
|
MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override;
|
||||||
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
|
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return the pick up sound Id
|
///< Return the pick up sound Id
|
||||||
|
|
||||||
|
@ -26,6 +26,10 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
Armor::Armor()
|
||||||
|
: MWWorld::RegisteredClass<Armor>(ESM::Armor::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
@ -159,13 +163,6 @@ namespace MWClass
|
|||||||
return ref->mBase->mData.mValue;
|
return ref->mBase->mData.mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Armor::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Armor);
|
|
||||||
|
|
||||||
registerClass (ESM::Armor::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Armor::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
std::string Armor::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
int es = getEquipmentSkill(ptr);
|
int es = getEquipmentSkill(ptr);
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#ifndef GAME_MWCLASS_ARMOR_H
|
#ifndef GAME_MWCLASS_ARMOR_H
|
||||||
#define GAME_MWCLASS_ARMOR_H
|
#define GAME_MWCLASS_ARMOR_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Armor : public MWWorld::Class
|
class Armor : public MWWorld::RegisteredClass<Armor>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Armor>;
|
||||||
|
|
||||||
|
Armor();
|
||||||
|
|
||||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -46,8 +50,6 @@ namespace MWClass
|
|||||||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return the pick up sound Id
|
///< Return the pick up sound Id
|
||||||
|
|
||||||
|
@ -7,6 +7,10 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
BodyPart::BodyPart()
|
||||||
|
: MWWorld::RegisteredClass<BodyPart>(ESM::BodyPart::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
MWWorld::Ptr BodyPart::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
|
MWWorld::Ptr BodyPart::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
|
||||||
{
|
{
|
||||||
@ -32,13 +36,6 @@ namespace MWClass
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BodyPart::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<MWWorld::Class> instance (new BodyPart);
|
|
||||||
|
|
||||||
registerClass (ESM::BodyPart::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string BodyPart::getModel(const MWWorld::ConstPtr &ptr) const
|
std::string BodyPart::getModel(const MWWorld::ConstPtr &ptr) const
|
||||||
{
|
{
|
||||||
const MWWorld::LiveCellRef<ESM::BodyPart> *ref = ptr.get<ESM::BodyPart>();
|
const MWWorld::LiveCellRef<ESM::BodyPart> *ref = ptr.get<ESM::BodyPart>();
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
#ifndef GAME_MWCLASS_BODYPART_H
|
#ifndef GAME_MWCLASS_BODYPART_H
|
||||||
#define GAME_MWCLASS_BODYPART_H
|
#define GAME_MWCLASS_BODYPART_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
|
||||||
class BodyPart : public MWWorld::Class
|
class BodyPart : public MWWorld::RegisteredClass<BodyPart>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<BodyPart>;
|
||||||
|
|
||||||
|
BodyPart();
|
||||||
|
|
||||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -21,8 +25,6 @@ namespace MWClass
|
|||||||
bool hasToolTip (const MWWorld::ConstPtr& ptr) const override;
|
bool hasToolTip (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< @return true if this object has a tooltip when focused (default implementation: true)
|
///< @return true if this object has a tooltip when focused (default implementation: true)
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getModel(const MWWorld::ConstPtr &ptr) const override;
|
std::string getModel(const MWWorld::ConstPtr &ptr) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,6 +23,10 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
Book::Book()
|
||||||
|
: MWWorld::RegisteredClass<Book>(ESM::Book::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Book::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
void Book::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
@ -82,13 +86,6 @@ namespace MWClass
|
|||||||
return ref->mBase->mData.mValue;
|
return ref->mBase->mData.mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Book::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Book);
|
|
||||||
|
|
||||||
registerClass (ESM::Book::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Book::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
std::string Book::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
return std::string("Item Book Up");
|
return std::string("Item Book Up");
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#ifndef GAME_MWCLASS_BOOK_H
|
#ifndef GAME_MWCLASS_BOOK_H
|
||||||
#define GAME_MWCLASS_BOOK_H
|
#define GAME_MWCLASS_BOOK_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Book : public MWWorld::Class
|
class Book : public MWWorld::RegisteredClass<Book>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Book>;
|
||||||
|
|
||||||
|
Book();
|
||||||
|
|
||||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -30,8 +34,6 @@ namespace MWClass
|
|||||||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return the pick up sound Id
|
///< Return the pick up sound Id
|
||||||
|
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
Clothing::Clothing()
|
||||||
|
: MWWorld::RegisteredClass<Clothing>(ESM::Clothing::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
@ -117,13 +121,6 @@ namespace MWClass
|
|||||||
return ref->mBase->mData.mValue;
|
return ref->mBase->mData.mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clothing::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Clothing);
|
|
||||||
|
|
||||||
registerClass (ESM::Clothing::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Clothing::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
std::string Clothing::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>();
|
const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>();
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#ifndef GAME_MWCLASS_CLOTHING_H
|
#ifndef GAME_MWCLASS_CLOTHING_H
|
||||||
#define GAME_MWCLASS_CLOTHING_H
|
#define GAME_MWCLASS_CLOTHING_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Clothing : public MWWorld::Class
|
class Clothing : public MWWorld::RegisteredClass<Clothing>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Clothing>;
|
||||||
|
|
||||||
|
Clothing();
|
||||||
|
|
||||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -38,8 +42,6 @@ namespace MWClass
|
|||||||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return the pick up sound Id
|
///< Return the pick up sound Id
|
||||||
|
|
||||||
|
@ -54,8 +54,9 @@ namespace MWClass
|
|||||||
}
|
}
|
||||||
|
|
||||||
Container::Container()
|
Container::Container()
|
||||||
|
: MWWorld::RegisteredClass<Container>(ESM::Container::sRecordId)
|
||||||
|
, mHarvestEnabled(Settings::Manager::getBool("graphic herbalism", "Game"))
|
||||||
{
|
{
|
||||||
mHarvestEnabled = Settings::Manager::getBool("graphic herbalism", "Game");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Container::ensureCustomData (const MWWorld::Ptr& ptr) const
|
void Container::ensureCustomData (const MWWorld::Ptr& ptr) const
|
||||||
@ -236,13 +237,6 @@ namespace MWClass
|
|||||||
return ref->mBase->mScript;
|
return ref->mBase->mScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Container::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Container);
|
|
||||||
|
|
||||||
registerClass (ESM::Container::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Container::hasToolTip (const MWWorld::ConstPtr& ptr) const
|
bool Container::hasToolTip (const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
if (const MWWorld::CustomData* data = ptr.getRefData().getCustomData())
|
if (const MWWorld::CustomData* data = ptr.getRefData().getCustomData())
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef GAME_MWCLASS_CONTAINER_H
|
#ifndef GAME_MWCLASS_CONTAINER_H
|
||||||
#define GAME_MWCLASS_CONTAINER_H
|
#define GAME_MWCLASS_CONTAINER_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
#include "../mwworld/containerstore.hpp"
|
#include "../mwworld/containerstore.hpp"
|
||||||
#include "../mwworld/customdata.hpp"
|
#include "../mwworld/customdata.hpp"
|
||||||
|
|
||||||
@ -26,9 +26,13 @@ namespace MWClass
|
|||||||
friend class Container;
|
friend class Container;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Container : public MWWorld::Class
|
class Container : public MWWorld::RegisteredClass<Container>
|
||||||
{
|
{
|
||||||
bool mHarvestEnabled;
|
friend MWWorld::RegisteredClass<Container>;
|
||||||
|
|
||||||
|
const bool mHarvestEnabled;
|
||||||
|
|
||||||
|
Container();
|
||||||
|
|
||||||
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
||||||
|
|
||||||
@ -37,8 +41,6 @@ namespace MWClass
|
|||||||
bool canBeHarvested(const MWWorld::ConstPtr& ptr) const;
|
bool canBeHarvested(const MWWorld::ConstPtr& ptr) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Container();
|
|
||||||
|
|
||||||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||||
///< Add reference into a cell for rendering
|
///< Add reference into a cell for rendering
|
||||||
|
|
||||||
@ -81,8 +83,6 @@ namespace MWClass
|
|||||||
void writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) const override;
|
void writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) const override;
|
||||||
///< Write additional state from \a ptr into \a state.
|
///< Write additional state from \a ptr into \a state.
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
void respawn (const MWWorld::Ptr& ptr) const override;
|
void respawn (const MWWorld::Ptr& ptr) const override;
|
||||||
|
|
||||||
std::string getModel(const MWWorld::ConstPtr &ptr) const override;
|
std::string getModel(const MWWorld::ConstPtr &ptr) const override;
|
||||||
|
@ -78,6 +78,11 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Creature::Creature()
|
||||||
|
: MWWorld::RegisteredClass<Creature, Actor>(ESM::Creature::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
const Creature::GMST& Creature::getGmst()
|
const Creature::GMST& Creature::getGmst()
|
||||||
{
|
{
|
||||||
static const GMST staticGmst = []
|
static const GMST staticGmst = []
|
||||||
@ -496,13 +501,6 @@ namespace MWClass
|
|||||||
return isFlagBitSet(ptr, ESM::Creature::Essential);
|
return isFlagBitSet(ptr, ESM::Creature::Essential);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Creature);
|
|
||||||
|
|
||||||
registerClass (ESM::Creature::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
float Creature::getMaxSpeed(const MWWorld::Ptr &ptr) const
|
float Creature::getMaxSpeed(const MWWorld::Ptr &ptr) const
|
||||||
{
|
{
|
||||||
const MWMechanics::CreatureStats& stats = getCreatureStats(ptr);
|
const MWMechanics::CreatureStats& stats = getCreatureStats(ptr);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef GAME_MWCLASS_CREATURE_H
|
#ifndef GAME_MWCLASS_CREATURE_H
|
||||||
#define GAME_MWCLASS_CREATURE_H
|
#define GAME_MWCLASS_CREATURE_H
|
||||||
|
|
||||||
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
#include "actor.hpp"
|
#include "actor.hpp"
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
@ -10,8 +12,12 @@ namespace ESM
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Creature : public Actor
|
class Creature : public MWWorld::RegisteredClass<Creature, Actor>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Creature, Actor>;
|
||||||
|
|
||||||
|
Creature();
|
||||||
|
|
||||||
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
||||||
|
|
||||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
@ -96,8 +102,6 @@ namespace MWClass
|
|||||||
|
|
||||||
float getMaxSpeed (const MWWorld::Ptr& ptr) const override;
|
float getMaxSpeed (const MWWorld::Ptr& ptr) const override;
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getModel(const MWWorld::ConstPtr &ptr) const override;
|
std::string getModel(const MWWorld::ConstPtr &ptr) const override;
|
||||||
|
|
||||||
void getModelsToPreload(const MWWorld::Ptr& ptr, std::vector<std::string>& models) const override;
|
void getModelsToPreload(const MWWorld::Ptr& ptr, std::vector<std::string>& models) const override;
|
||||||
|
@ -28,6 +28,11 @@ namespace MWClass
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CreatureLevList::CreatureLevList()
|
||||||
|
: MWWorld::RegisteredClass<CreatureLevList>(ESM::CreatureLevList::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
MWWorld::Ptr CreatureLevList::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
|
MWWorld::Ptr CreatureLevList::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
|
||||||
{
|
{
|
||||||
const MWWorld::LiveCellRef<ESM::CreatureLevList> *ref = ptr.get<ESM::CreatureLevList>();
|
const MWWorld::LiveCellRef<ESM::CreatureLevList> *ref = ptr.get<ESM::CreatureLevList>();
|
||||||
@ -91,13 +96,6 @@ namespace MWClass
|
|||||||
customData.mSpawn = true;
|
customData.mSpawn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreatureLevList::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new CreatureLevList);
|
|
||||||
|
|
||||||
registerClass (ESM::CreatureLevList::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreatureLevList::getModelsToPreload(const MWWorld::Ptr &ptr, std::vector<std::string> &models) const
|
void CreatureLevList::getModelsToPreload(const MWWorld::Ptr &ptr, std::vector<std::string> &models) const
|
||||||
{
|
{
|
||||||
// disable for now, too many false positives
|
// disable for now, too many false positives
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
#ifndef GAME_MWCLASS_CREATURELEVLIST_H
|
#ifndef GAME_MWCLASS_CREATURELEVLIST_H
|
||||||
#define GAME_MWCLASS_CREATURELEVLIST_H
|
#define GAME_MWCLASS_CREATURELEVLIST_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class CreatureLevList : public MWWorld::Class
|
class CreatureLevList : public MWWorld::RegisteredClass<CreatureLevList>
|
||||||
{
|
{
|
||||||
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
friend MWWorld::RegisteredClass<CreatureLevList>;
|
||||||
|
|
||||||
|
CreatureLevList();
|
||||||
|
|
||||||
|
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -17,8 +21,6 @@ namespace MWClass
|
|||||||
bool hasToolTip (const MWWorld::ConstPtr& ptr) const override;
|
bool hasToolTip (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< @return true if this object has a tooltip when focused (default implementation: true)
|
///< @return true if this object has a tooltip when focused (default implementation: true)
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
void getModelsToPreload(const MWWorld::Ptr& ptr, std::vector<std::string>& models) const override;
|
void getModelsToPreload(const MWWorld::Ptr& ptr, std::vector<std::string>& models) const override;
|
||||||
///< Get a list of models to preload that this object may use (directly or indirectly). default implementation: list getModel().
|
///< Get a list of models to preload that this object may use (directly or indirectly). default implementation: list getModel().
|
||||||
|
|
||||||
|
@ -46,6 +46,11 @@ namespace MWClass
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Door::Door()
|
||||||
|
: MWWorld::RegisteredClass<Door>(ESM::Door::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Door::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
void Door::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
if (!model.empty())
|
if (!model.empty())
|
||||||
@ -259,13 +264,6 @@ namespace MWClass
|
|||||||
return ref->mBase->mScript;
|
return ref->mBase->mScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Door::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Door);
|
|
||||||
|
|
||||||
registerClass (ESM::Door::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
MWGui::ToolTipInfo Door::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
|
MWGui::ToolTipInfo Door::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
|
||||||
{
|
{
|
||||||
const MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>();
|
const MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>();
|
||||||
|
@ -3,12 +3,16 @@
|
|||||||
|
|
||||||
#include <components/esm3/loaddoor.hpp>
|
#include <components/esm3/loaddoor.hpp>
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Door : public MWWorld::Class
|
class Door : public MWWorld::RegisteredClass<Door>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Door>;
|
||||||
|
|
||||||
|
Door();
|
||||||
|
|
||||||
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
||||||
|
|
||||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
@ -46,8 +50,6 @@ namespace MWClass
|
|||||||
std::string getScript (const MWWorld::ConstPtr& ptr) const override;
|
std::string getScript (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return name of the script attached to ptr
|
///< Return name of the script attached to ptr
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getModel(const MWWorld::ConstPtr &ptr) const override;
|
std::string getModel(const MWWorld::ConstPtr &ptr) const override;
|
||||||
|
|
||||||
MWWorld::DoorState getDoorState (const MWWorld::ConstPtr &ptr) const override;
|
MWWorld::DoorState getDoorState (const MWWorld::ConstPtr &ptr) const override;
|
||||||
|
@ -20,6 +20,10 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
Ingredient::Ingredient()
|
||||||
|
: MWWorld::RegisteredClass<Ingredient>(ESM::Ingredient::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
@ -77,13 +81,6 @@ namespace MWClass
|
|||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ingredient::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Ingredient);
|
|
||||||
|
|
||||||
registerClass (ESM::Ingredient::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Ingredient::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
std::string Ingredient::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
return std::string("Item Ingredient Up");
|
return std::string("Item Ingredient Up");
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#ifndef GAME_MWCLASS_INGREDIENT_H
|
#ifndef GAME_MWCLASS_INGREDIENT_H
|
||||||
#define GAME_MWCLASS_INGREDIENT_H
|
#define GAME_MWCLASS_INGREDIENT_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Ingredient : public MWWorld::Class
|
class Ingredient : public MWWorld::RegisteredClass<Ingredient>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Ingredient>;
|
||||||
|
|
||||||
|
Ingredient();
|
||||||
|
|
||||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -32,8 +36,6 @@ namespace MWClass
|
|||||||
|
|
||||||
std::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
|
std::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
|
||||||
///< Generate action for using via inventory menu
|
///< Generate action for using via inventory menu
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return the pick up sound Id
|
///< Return the pick up sound Id
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
ItemLevList::ItemLevList()
|
||||||
|
: MWWorld::RegisteredClass<ItemLevList>(ESM::ItemLevList::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
std::string ItemLevList::getName (const MWWorld::ConstPtr& ptr) const
|
std::string ItemLevList::getName (const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
@ -14,11 +18,4 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemLevList::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new ItemLevList);
|
|
||||||
|
|
||||||
registerClass (ESM::ItemLevList::sRecordId, instance);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#ifndef GAME_MWCLASS_ITEMLEVLIST_H
|
#ifndef GAME_MWCLASS_ITEMLEVLIST_H
|
||||||
#define GAME_MWCLASS_ITEMLEVLIST_H
|
#define GAME_MWCLASS_ITEMLEVLIST_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class ItemLevList : public MWWorld::Class
|
class ItemLevList : public MWWorld::RegisteredClass<ItemLevList>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<ItemLevList>;
|
||||||
|
|
||||||
|
ItemLevList();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
std::string getName (const MWWorld::ConstPtr& ptr) const override;
|
||||||
@ -14,8 +18,6 @@ namespace MWClass
|
|||||||
|
|
||||||
bool hasToolTip (const MWWorld::ConstPtr& ptr) const override;
|
bool hasToolTip (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< @return true if this object has a tooltip when focused (default implementation: true)
|
///< @return true if this object has a tooltip when focused (default implementation: true)
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,10 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
Light::Light()
|
||||||
|
: MWWorld::RegisteredClass<Light>(ESM::Light::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Light::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
void Light::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
@ -120,13 +124,6 @@ namespace MWClass
|
|||||||
return ref->mBase->mData.mValue;
|
return ref->mBase->mData.mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Light::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Light);
|
|
||||||
|
|
||||||
registerClass (ESM::Light::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Light::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
std::string Light::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
return std::string("Item Misc Up");
|
return std::string("Item Misc Up");
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#ifndef GAME_MWCLASS_LIGHT_H
|
#ifndef GAME_MWCLASS_LIGHT_H
|
||||||
#define GAME_MWCLASS_LIGHT_H
|
#define GAME_MWCLASS_LIGHT_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Light : public MWWorld::Class
|
class Light : public MWWorld::RegisteredClass<Light>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Light>;
|
||||||
|
|
||||||
|
Light();
|
||||||
|
|
||||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -44,8 +48,6 @@ namespace MWClass
|
|||||||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return the pick up sound Id
|
///< Return the pick up sound Id
|
||||||
|
|
||||||
|
@ -20,6 +20,10 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
Lockpick::Lockpick()
|
||||||
|
: MWWorld::RegisteredClass<Lockpick>(ESM::Lockpick::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
@ -76,13 +80,6 @@ namespace MWClass
|
|||||||
return ref->mBase->mData.mValue;
|
return ref->mBase->mData.mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lockpick::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Lockpick);
|
|
||||||
|
|
||||||
registerClass (ESM::Lockpick::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Lockpick::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
std::string Lockpick::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
return std::string("Item Lockpick Up");
|
return std::string("Item Lockpick Up");
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#ifndef GAME_MWCLASS_LOCKPICK_H
|
#ifndef GAME_MWCLASS_LOCKPICK_H
|
||||||
#define GAME_MWCLASS_LOCKPICK_H
|
#define GAME_MWCLASS_LOCKPICK_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Lockpick : public MWWorld::Class
|
class Lockpick : public MWWorld::RegisteredClass<Lockpick>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Lockpick>;
|
||||||
|
|
||||||
|
Lockpick();
|
||||||
|
|
||||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -34,8 +38,6 @@ namespace MWClass
|
|||||||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return the pick up sound Id
|
///< Return the pick up sound Id
|
||||||
|
|
||||||
|
@ -21,6 +21,11 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
Miscellaneous::Miscellaneous()
|
||||||
|
: MWWorld::RegisteredClass<Miscellaneous>(ESM::Miscellaneous::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
bool Miscellaneous::isGold (const MWWorld::ConstPtr& ptr) const
|
bool Miscellaneous::isGold (const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
return Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_001")
|
return Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_001")
|
||||||
@ -102,13 +107,6 @@ namespace MWClass
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Miscellaneous::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Miscellaneous);
|
|
||||||
|
|
||||||
registerClass (ESM::Miscellaneous::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Miscellaneous::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
std::string Miscellaneous::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
if (isGold(ptr))
|
if (isGold(ptr))
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#ifndef GAME_MWCLASS_MISC_H
|
#ifndef GAME_MWCLASS_MISC_H
|
||||||
#define GAME_MWCLASS_MISC_H
|
#define GAME_MWCLASS_MISC_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Miscellaneous : public MWWorld::Class
|
class Miscellaneous : public MWWorld::RegisteredClass<Miscellaneous>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Miscellaneous>;
|
||||||
|
|
||||||
|
Miscellaneous();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MWWorld::Ptr copyToCell(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell, int count) const override;
|
MWWorld::Ptr copyToCell(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell, int count) const override;
|
||||||
@ -30,8 +34,6 @@ namespace MWClass
|
|||||||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return the pick up sound Id
|
///< Return the pick up sound Id
|
||||||
|
|
||||||
|
@ -245,6 +245,10 @@ namespace
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
Npc::Npc()
|
||||||
|
: MWWorld::RegisteredClass<Npc, Actor>(ESM::NPC::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
class NpcCustomData : public MWWorld::TypedCustomData<NpcCustomData>
|
class NpcCustomData : public MWWorld::TypedCustomData<NpcCustomData>
|
||||||
{
|
{
|
||||||
@ -1039,12 +1043,6 @@ namespace MWClass
|
|||||||
return (ref->mBase->mFlags & ESM::NPC::Essential) != 0;
|
return (ref->mBase->mFlags & ESM::NPC::Essential) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Npc::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Npc);
|
|
||||||
registerClass (ESM::NPC::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Npc::hasToolTip(const MWWorld::ConstPtr& ptr) const
|
bool Npc::hasToolTip(const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
if (!ptr.getRefData().getCustomData() || MWBase::Environment::get().getWindowManager()->isGuiMode())
|
if (!ptr.getRefData().getCustomData() || MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef GAME_MWCLASS_NPC_H
|
#ifndef GAME_MWCLASS_NPC_H
|
||||||
#define GAME_MWCLASS_NPC_H
|
#define GAME_MWCLASS_NPC_H
|
||||||
|
|
||||||
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
#include "actor.hpp"
|
#include "actor.hpp"
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
@ -10,8 +12,12 @@ namespace ESM
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Npc : public Actor
|
class Npc : public MWWorld::RegisteredClass<Npc, Actor>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Npc, Actor>;
|
||||||
|
|
||||||
|
Npc();
|
||||||
|
|
||||||
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
||||||
|
|
||||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
@ -125,8 +131,6 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const override;
|
std::string getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const override;
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getModel(const MWWorld::ConstPtr &ptr) const override;
|
std::string getModel(const MWWorld::ConstPtr &ptr) const override;
|
||||||
|
|
||||||
float getSkill(const MWWorld::Ptr& ptr, int skill) const override;
|
float getSkill(const MWWorld::Ptr& ptr, int skill) const override;
|
||||||
|
@ -22,6 +22,10 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
Potion::Potion()
|
||||||
|
: MWWorld::RegisteredClass<Potion>(ESM::Potion::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
@ -70,13 +74,6 @@ namespace MWClass
|
|||||||
return ref->mBase->mData.mValue;
|
return ref->mBase->mData.mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Potion::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Potion);
|
|
||||||
|
|
||||||
registerClass (ESM::Potion::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Potion::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
std::string Potion::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
return std::string("Item Potion Up");
|
return std::string("Item Potion Up");
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#ifndef GAME_MWCLASS_POTION_H
|
#ifndef GAME_MWCLASS_POTION_H
|
||||||
#define GAME_MWCLASS_POTION_H
|
#define GAME_MWCLASS_POTION_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Potion : public MWWorld::Class
|
class Potion : public MWWorld::RegisteredClass<Potion>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Potion>;
|
||||||
|
|
||||||
|
Potion();
|
||||||
|
|
||||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -33,8 +37,6 @@ namespace MWClass
|
|||||||
std::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
|
std::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
|
||||||
///< Generate action for using via inventory menu
|
///< Generate action for using via inventory menu
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return the pick up sound Id
|
///< Return the pick up sound Id
|
||||||
|
|
||||||
|
@ -20,6 +20,10 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
Probe::Probe()
|
||||||
|
: MWWorld::RegisteredClass<Probe>(ESM::Probe::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Probe::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
void Probe::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
@ -76,13 +80,6 @@ namespace MWClass
|
|||||||
return ref->mBase->mData.mValue;
|
return ref->mBase->mData.mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Probe::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Probe);
|
|
||||||
|
|
||||||
registerClass (ESM::Probe::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Probe::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
std::string Probe::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
return std::string("Item Probe Up");
|
return std::string("Item Probe Up");
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#ifndef GAME_MWCLASS_PROBE_H
|
#ifndef GAME_MWCLASS_PROBE_H
|
||||||
#define GAME_MWCLASS_PROBE_H
|
#define GAME_MWCLASS_PROBE_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Probe : public MWWorld::Class
|
class Probe : public MWWorld::RegisteredClass<Probe>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Probe>;
|
||||||
|
|
||||||
|
Probe();
|
||||||
|
|
||||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -34,8 +38,6 @@ namespace MWClass
|
|||||||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return the pick up sound Id
|
///< Return the pick up sound Id
|
||||||
|
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
Repair::Repair()
|
||||||
|
: MWWorld::RegisteredClass<Repair>(ESM::Repair::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
@ -65,13 +69,6 @@ namespace MWClass
|
|||||||
return ref->mBase->mData.mValue;
|
return ref->mBase->mData.mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Repair::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Repair);
|
|
||||||
|
|
||||||
registerClass (ESM::Repair::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Repair::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
std::string Repair::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
return std::string("Item Repair Up");
|
return std::string("Item Repair Up");
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#ifndef GAME_MWCLASS_REPAIR_H
|
#ifndef GAME_MWCLASS_REPAIR_H
|
||||||
#define GAME_MWCLASS_REPAIR_H
|
#define GAME_MWCLASS_REPAIR_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Repair : public MWWorld::Class
|
class Repair : public MWWorld::RegisteredClass<Repair>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Repair>;
|
||||||
|
|
||||||
|
Repair();
|
||||||
|
|
||||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -30,8 +34,6 @@ namespace MWClass
|
|||||||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return the pick up sound Id
|
///< Return the pick up sound Id
|
||||||
|
|
||||||
|
@ -13,6 +13,10 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
Static::Static()
|
||||||
|
: MWWorld::RegisteredClass<Static>(ESM::Static::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Static::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
void Static::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
@ -54,13 +58,6 @@ namespace MWClass
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Static::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Static);
|
|
||||||
|
|
||||||
registerClass (ESM::Static::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
MWWorld::Ptr Static::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
|
MWWorld::Ptr Static::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
|
||||||
{
|
{
|
||||||
const MWWorld::LiveCellRef<ESM::Static> *ref = ptr.get<ESM::Static>();
|
const MWWorld::LiveCellRef<ESM::Static> *ref = ptr.get<ESM::Static>();
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#ifndef GAME_MWCLASS_STATIC_H
|
#ifndef GAME_MWCLASS_STATIC_H
|
||||||
#define GAME_MWCLASS_STATIC_H
|
#define GAME_MWCLASS_STATIC_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Static : public MWWorld::Class
|
class Static : public MWWorld::RegisteredClass<Static>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Static>;
|
||||||
|
|
||||||
|
Static();
|
||||||
|
|
||||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -23,8 +27,6 @@ namespace MWClass
|
|||||||
bool hasToolTip (const MWWorld::ConstPtr& ptr) const override;
|
bool hasToolTip (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< @return true if this object has a tooltip when focused (default implementation: true)
|
///< @return true if this object has a tooltip when focused (default implementation: true)
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getModel(const MWWorld::ConstPtr &ptr) const override;
|
std::string getModel(const MWWorld::ConstPtr &ptr) const override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,10 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
Weapon::Weapon()
|
||||||
|
: MWWorld::RegisteredClass<Weapon>(ESM::Weapon::sRecordId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
@ -121,13 +125,6 @@ namespace MWClass
|
|||||||
return ref->mBase->mData.mValue;
|
return ref->mBase->mData.mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Weapon::registerSelf()
|
|
||||||
{
|
|
||||||
std::shared_ptr<Class> instance (new Weapon);
|
|
||||||
|
|
||||||
registerClass (ESM::Weapon::sRecordId, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Weapon::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
std::string Weapon::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||||
{
|
{
|
||||||
const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>();
|
const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>();
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
#ifndef GAME_MWCLASS_WEAPON_H
|
#ifndef GAME_MWCLASS_WEAPON_H
|
||||||
#define GAME_MWCLASS_WEAPON_H
|
#define GAME_MWCLASS_WEAPON_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/registeredclass.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
class Weapon : public MWWorld::Class
|
class Weapon : public MWWorld::RegisteredClass<Weapon>
|
||||||
{
|
{
|
||||||
|
friend MWWorld::RegisteredClass<Weapon>;
|
||||||
|
|
||||||
MWWorld::Ptr
|
MWWorld::Ptr
|
||||||
copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Weapon();
|
||||||
|
|
||||||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||||
///< Add reference into a cell for rendering
|
///< Add reference into a cell for rendering
|
||||||
@ -45,8 +48,6 @@ namespace MWClass
|
|||||||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||||
///< Return the pick up sound Id
|
///< Return the pick up sound Id
|
||||||
|
|
||||||
|
@ -21,7 +21,11 @@
|
|||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
std::map<unsigned int, std::shared_ptr<Class> > Class::sClasses;
|
std::map<unsigned, Class*>& Class::getClasses()
|
||||||
|
{
|
||||||
|
static std::map<unsigned, Class*> values;
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
void Class::insertObjectRendering (const Ptr& ptr, const std::string& mesh, MWRender::RenderingInterface& renderingInterface) const
|
void Class::insertObjectRendering (const Ptr& ptr, const std::string& mesh, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
@ -228,9 +232,10 @@ namespace MWWorld
|
|||||||
|
|
||||||
const Class& Class::get (unsigned int key)
|
const Class& Class::get (unsigned int key)
|
||||||
{
|
{
|
||||||
auto iter = sClasses.find (key);
|
const auto& classes = getClasses();
|
||||||
|
auto iter = classes.find(key);
|
||||||
|
|
||||||
if (iter==sClasses.end())
|
if (iter == classes.end())
|
||||||
throw std::logic_error ("Class::get(): unknown class key: " + std::to_string(key));
|
throw std::logic_error ("Class::get(): unknown class key: " + std::to_string(key));
|
||||||
|
|
||||||
return *iter->second;
|
return *iter->second;
|
||||||
@ -241,10 +246,9 @@ namespace MWWorld
|
|||||||
throw std::runtime_error ("class does not support persistence");
|
throw std::runtime_error ("class does not support persistence");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Class::registerClass(unsigned int key, std::shared_ptr<Class> instance)
|
void Class::registerClass(Class& instance)
|
||||||
{
|
{
|
||||||
instance->mType = key;
|
getClasses().emplace(instance.getType(), &instance);
|
||||||
sClasses.insert(std::make_pair(key, instance));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Class::getUpSoundId (const ConstPtr& ptr) const
|
std::string Class::getUpSoundId (const ConstPtr& ptr) const
|
||||||
|
@ -54,12 +54,13 @@ namespace MWWorld
|
|||||||
/// \brief Base class for referenceable esm records
|
/// \brief Base class for referenceable esm records
|
||||||
class Class
|
class Class
|
||||||
{
|
{
|
||||||
static std::map<unsigned int, std::shared_ptr<Class> > sClasses;
|
const unsigned mType;
|
||||||
unsigned int mType;
|
|
||||||
|
static std::map<unsigned, Class*>& getClasses();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Class() = default;
|
explicit Class(unsigned type) : mType(type) {}
|
||||||
|
|
||||||
std::shared_ptr<Action> defaultItemActivate(const Ptr &ptr, const Ptr &actor) const;
|
std::shared_ptr<Action> defaultItemActivate(const Ptr &ptr, const Ptr &actor) const;
|
||||||
///< Generate default action for activating inventory items
|
///< Generate default action for activating inventory items
|
||||||
@ -340,7 +341,7 @@ namespace MWWorld
|
|||||||
static const Class& get (unsigned int key);
|
static const Class& get (unsigned int key);
|
||||||
///< If there is no class for this \a key, an exception is thrown.
|
///< If there is no class for this \a key, an exception is thrown.
|
||||||
|
|
||||||
static void registerClass (unsigned int key, std::shared_ptr<Class> instance);
|
static void registerClass(Class& instance);
|
||||||
|
|
||||||
virtual int getBaseGold(const MWWorld::ConstPtr& ptr) const;
|
virtual int getBaseGold(const MWWorld::ConstPtr& ptr) const;
|
||||||
|
|
||||||
|
23
apps/openmw/mwworld/registeredclass.hpp
Normal file
23
apps/openmw/mwworld/registeredclass.hpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef GAME_MWWORLD_REGISTEREDCLASS_H
|
||||||
|
#define GAME_MWWORLD_REGISTEREDCLASS_H
|
||||||
|
|
||||||
|
#include "class.hpp"
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
template <class Derived, class Base = Class>
|
||||||
|
class RegisteredClass : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void registerSelf()
|
||||||
|
{
|
||||||
|
static Derived instance;
|
||||||
|
Base::registerClass(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
explicit RegisteredClass(unsigned type) : Base(type) {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user