1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 21:49:56 +00:00
openmw-tes3mp/apps/openmw/mwclass/lockpick.cpp

194 lines
5.5 KiB
C++
Raw Normal View History

2010-08-03 13:24:44 +00:00
#include "lockpick.hpp"
2013-03-22 04:50:54 +00:00
#include <components/esm/loadlock.hpp>
2010-08-03 13:24:44 +00:00
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
2010-08-03 15:11:41 +00:00
#include "../mwworld/ptr.hpp"
2010-08-07 18:25:17 +00:00
#include "../mwworld/actiontake.hpp"
#include "../mwworld/actionequip.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwgui/tooltips.hpp"
2010-08-03 15:11:41 +00:00
2012-01-27 14:11:02 +00:00
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
2012-01-27 14:11:02 +00:00
2010-08-03 13:24:44 +00:00
namespace MWClass
{
std::string Lockpick::getId (const MWWorld::Ptr& ptr) const
{
return ptr.get<ESM::Lockpick>()->mBase->mId;
}
void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
{
2012-07-24 16:22:11 +00:00
if (!model.empty()) {
2013-08-07 10:51:57 +00:00
renderingInterface.getObjects().insertModel(ptr, model);
}
}
void Lockpick::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWWorld::PhysicsSystem& physics) const
2012-07-24 16:22:11 +00:00
{
if(!model.empty())
physics.addObject(ptr, model, true);
2012-07-24 16:22:11 +00:00
}
2012-07-24 16:22:11 +00:00
std::string Lockpick::getModel(const MWWorld::Ptr &ptr) const
{
2013-03-22 04:50:54 +00:00
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
ptr.get<ESM::Lockpick>();
2012-11-05 12:07:59 +00:00
assert(ref->mBase != NULL);
2011-11-11 19:37:42 +00:00
2012-11-05 12:07:59 +00:00
const std::string &model = ref->mBase->mModel;
2012-07-24 16:22:11 +00:00
if (!model.empty()) {
return "meshes\\" + model;
}
2012-07-24 16:22:11 +00:00
return "";
}
2010-08-03 15:11:41 +00:00
std::string Lockpick::getName (const MWWorld::Ptr& ptr) const
{
2013-03-22 04:50:54 +00:00
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
ptr.get<ESM::Lockpick>();
2010-08-03 15:11:41 +00:00
2012-11-05 12:07:59 +00:00
return ref->mBase->mName;
2010-08-03 15:11:41 +00:00
}
2010-08-07 18:25:17 +00:00
boost::shared_ptr<MWWorld::Action> Lockpick::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
2010-08-07 18:25:17 +00:00
{
2013-08-09 05:34:53 +00:00
return defaultItemActivate(ptr, actor);
2010-08-07 18:25:17 +00:00
}
std::string Lockpick::getScript (const MWWorld::Ptr& ptr) const
{
2013-03-22 04:50:54 +00:00
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
ptr.get<ESM::Lockpick>();
2012-11-05 12:07:59 +00:00
return ref->mBase->mScript;
}
std::pair<std::vector<int>, bool> Lockpick::getEquipmentSlots (const MWWorld::Ptr& ptr) const
{
std::vector<int> slots_;
slots_.push_back (int (MWWorld::InventoryStore::Slot_CarriedRight));
return std::make_pair (slots_, false);
}
int Lockpick::getValue (const MWWorld::Ptr& ptr) const
{
2013-03-22 04:50:54 +00:00
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
ptr.get<ESM::Lockpick>();
return ref->mBase->mData.mValue;
}
2010-08-03 13:24:44 +00:00
void Lockpick::registerSelf()
{
boost::shared_ptr<Class> instance (new Lockpick);
2013-03-22 04:50:54 +00:00
registerClass (typeid (ESM::Lockpick).name(), instance);
2010-08-03 13:24:44 +00:00
}
std::string Lockpick::getUpSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Lockpick Up");
}
std::string Lockpick::getDownSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Lockpick Down");
}
2012-04-15 15:52:39 +00:00
std::string Lockpick::getInventoryIcon (const MWWorld::Ptr& ptr) const
{
2013-03-22 04:50:54 +00:00
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
ptr.get<ESM::Lockpick>();
2012-04-15 15:52:39 +00:00
2012-11-05 12:07:59 +00:00
return ref->mBase->mIcon;
2012-04-15 15:52:39 +00:00
}
bool Lockpick::hasToolTip (const MWWorld::Ptr& ptr) const
{
2013-03-22 04:50:54 +00:00
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
ptr.get<ESM::Lockpick>();
2012-11-05 12:07:59 +00:00
return (ref->mBase->mName != "");
}
MWGui::ToolTipInfo Lockpick::getToolTipInfo (const MWWorld::Ptr& ptr) const
{
2013-03-22 04:50:54 +00:00
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
ptr.get<ESM::Lockpick>();
MWGui::ToolTipInfo info;
2012-11-05 12:07:59 +00:00
info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
info.icon = ref->mBase->mIcon;
std::string text;
int remainingUses = getItemHealth(ptr);
text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
2012-11-05 12:07:59 +00:00
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
2012-11-05 12:07:59 +00:00
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
}
info.text = text;
return info;
}
boost::shared_ptr<MWWorld::Action> Lockpick::use (const MWWorld::Ptr& ptr) const
{
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
action->setSound(getUpSoundId(ptr));
return action;
}
MWWorld::Ptr
Lockpick::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
{
2013-03-22 04:50:54 +00:00
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
ptr.get<ESM::Lockpick>();
2014-02-23 20:21:27 +00:00
return MWWorld::Ptr(&cell.get<ESM::Lockpick>().insert(*ref), &cell);
}
bool Lockpick::canSell (const MWWorld::Ptr& item, int npcServices) const
{
return (npcServices & ESM::NPC::Picks) != 0;
}
int Lockpick::getItemMaxHealth (const MWWorld::Ptr& ptr) const
{
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
ptr.get<ESM::Lockpick>();
return ref->mBase->mData.mUses;
}
2013-05-11 16:38:27 +00:00
float Lockpick::getWeight(const MWWorld::Ptr &ptr) const
{
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
ptr.get<ESM::Lockpick>();
return ref->mBase->mData.mWeight;
}
2010-08-03 13:24:44 +00:00
}