1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-08 09:37:53 +00:00
OpenMW/apps/openmw/mwworld/actionread.cpp

56 lines
1.8 KiB
C++
Raw Normal View History

#include "actionread.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
2012-09-15 17:06:56 +00:00
#include "../mwbase/world.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/class.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwgui/bookwindow.hpp"
#include "../mwgui/scrollwindow.hpp"
2012-09-15 17:06:56 +00:00
#include <components/esm_store/store.hpp>
namespace MWWorld
{
ActionRead::ActionRead (const MWWorld::Ptr& object) : Action (false, object)
{
}
2012-07-27 10:00:10 +00:00
void ActionRead::executeImp (const MWWorld::Ptr& actor)
{
LiveCellRef<ESM::Book> *ref = getTarget().get<ESM::Book>();
2012-09-17 07:37:50 +00:00
if (ref->base->mData.mIsScroll)
{
2012-05-23 10:23:35 +00:00
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Scroll);
MWBase::Environment::get().getWindowManager()->getScrollWindow()->open(getTarget());
}
else
{
2012-05-23 10:23:35 +00:00
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Book);
MWBase::Environment::get().getWindowManager()->getBookWindow()->open(getTarget());
}
2012-09-15 17:06:56 +00:00
2012-09-25 16:59:24 +00:00
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer();
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats (player);
2012-09-15 18:03:53 +00:00
// Skill gain from books
2012-09-30 20:23:49 +00:00
if (ref->base->mData.mSkillID >= 0 && ref->base->mData.mSkillID < ESM::Skill::Length
&& !npcStats.hasBeenUsed (ref->base->mId))
2012-09-15 17:06:56 +00:00
{
MWWorld::LiveCellRef<ESM::NPC> *playerRef = player.get<ESM::NPC>();
const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find (
2012-09-30 20:23:49 +00:00
playerRef->base->mClass);
2012-09-15 17:06:56 +00:00
2012-09-30 20:23:49 +00:00
npcStats.increaseSkill (ref->base->mData.mSkillID, *class_, true);
2012-09-15 17:06:56 +00:00
2012-09-30 20:23:49 +00:00
npcStats.flagAsUsed (ref->base->mId);
2012-09-15 17:06:56 +00:00
}
}
}