From 09c42589ccc0431788f1ccb78a41db62ac7ee678 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 6 Aug 2010 18:15:46 +0200 Subject: [PATCH] implemented npc/creature activation (enters dialog gui mode for now) --- apps/openmw/CMakeLists.txt | 2 ++ apps/openmw/mwclass/creature.cpp | 7 +++++++ apps/openmw/mwclass/creature.hpp | 4 ++++ apps/openmw/mwclass/npc.cpp | 7 +++++++ apps/openmw/mwclass/npc.hpp | 4 ++++ apps/openmw/mwworld/actiontalk.cpp | 16 ++++++++++++++++ apps/openmw/mwworld/actiontalk.hpp | 21 +++++++++++++++++++++ 7 files changed, 61 insertions(+) create mode 100644 apps/openmw/mwworld/actiontalk.cpp create mode 100644 apps/openmw/mwworld/actiontalk.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 0fe62ea4f9..f4b231807b 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -81,6 +81,7 @@ set(GAMEWORLD mwworld/globals.cpp mwworld/class.cpp mwworld/actionteleport.cpp + mwworld/actiontalk.cpp ) set(GAMEWORLD_HEADER mwworld/refdata.hpp @@ -92,6 +93,7 @@ set(GAMEWORLD_HEADER mwworld/action.hpp mwworld/nullaction.hpp mwworld/actionteleport.hpp + mwworld/actiontalk.hpp ) source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER}) diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index e34f92fb49..32575d7db2 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -6,6 +6,7 @@ #include "../mwmechanics/creaturestats.hpp" #include "../mwworld/ptr.hpp" +#include "../mwworld/actiontalk.hpp" namespace MWClass { @@ -44,6 +45,12 @@ namespace MWClass return *ptr.getRefData().getCreatureStats(); } + boost::shared_ptr Creature::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); + } + std::string Creature::getScript (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/creature.hpp b/apps/openmw/mwclass/creature.hpp index 03333a50a4..71fb4dbec4 100644 --- a/apps/openmw/mwclass/creature.hpp +++ b/apps/openmw/mwclass/creature.hpp @@ -16,6 +16,10 @@ namespace MWClass virtual MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const; ///< Return creature stats + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 2887ad0b58..56d601edc6 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -6,6 +6,7 @@ #include "../mwmechanics/creaturestats.hpp" #include "../mwworld/ptr.hpp" +#include "../mwworld/actiontalk.hpp" namespace MWClass { @@ -44,6 +45,12 @@ namespace MWClass return *ptr.getRefData().getCreatureStats(); } + boost::shared_ptr Npc::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); + } + std::string Npc::getScript (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index e0b828f61f..eb18cb2bd0 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -16,6 +16,10 @@ namespace MWClass virtual MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const; ///< Return creature stats + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwworld/actiontalk.cpp b/apps/openmw/mwworld/actiontalk.cpp new file mode 100644 index 0000000000..2b4aba735c --- /dev/null +++ b/apps/openmw/mwworld/actiontalk.cpp @@ -0,0 +1,16 @@ + +#include "actiontalk.hpp" + +#include "environment.hpp" + +#include "../mwgui/window_manager.hpp" + +namespace MWWorld +{ + ActionTalk::ActionTalk (const Ptr& actor) : mActor (actor) {} + + void ActionTalk::execute (Environment& environment) + { + environment.mWindowManager->setMode (MWGui::GM_Dialogue); + } +} diff --git a/apps/openmw/mwworld/actiontalk.hpp b/apps/openmw/mwworld/actiontalk.hpp new file mode 100644 index 0000000000..034d6131c2 --- /dev/null +++ b/apps/openmw/mwworld/actiontalk.hpp @@ -0,0 +1,21 @@ +#ifndef GAME_MWWORLD_ACTIONTALK_H +#define GAME_MWWORLD_ACTIONTALK_H + +#include "ptr.hpp" +#include "action.hpp" + +namespace MWWorld +{ + class ActionTalk : public Action + { + Ptr mActor; + + public: + + ActionTalk (const Ptr& actor); + + virtual void execute (Environment& environment); + }; +} + +#endif