mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 12:58:00 +03:00
Merge branch 'dialogue_event' into 'master'
Some checks failed
Build and test / Ubuntu (push) Has been cancelled
Build and test / MacOS (push) Has been cancelled
Build and test / Read .env file and expose it as output (push) Has been cancelled
Build and test / Windows (2019) (push) Has been cancelled
Build and test / Windows (2022) (push) Has been cancelled
Some checks failed
Build and test / Ubuntu (push) Has been cancelled
Build and test / MacOS (push) Has been cancelled
Build and test / Read .env file and expose it as output (push) Has been cancelled
Build and test / Windows (2019) (push) Has been cancelled
Build and test / Windows (2022) (push) Has been cancelled
Add onInfoGetText event to lua API See merge request OpenMW/openmw!4028
This commit is contained in:
commit
4780a5e15e
5 changed files with 24 additions and 1 deletions
|
@ -60,6 +60,7 @@ namespace MWBase
|
|||
virtual void objectAddedToScene(const MWWorld::Ptr& ptr) = 0;
|
||||
virtual void objectRemovedFromScene(const MWWorld::Ptr& ptr) = 0;
|
||||
virtual void objectTeleported(const MWWorld::Ptr& ptr) = 0;
|
||||
virtual void onInfoGetText(const MWWorld::Ptr& actor, const ESM::RefId& infoId) = 0;
|
||||
virtual void itemConsumed(const MWWorld::Ptr& consumable, const MWWorld::Ptr& actor) = 0;
|
||||
virtual void objectActivated(const MWWorld::Ptr& object, const MWWorld::Ptr& actor) = 0;
|
||||
virtual void useItem(const MWWorld::Ptr& object, const MWWorld::Ptr& actor, bool force) = 0;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/journal.hpp"
|
||||
#include "../mwbase/luamanager.hpp"
|
||||
#include "../mwbase/mechanicsmanager.hpp"
|
||||
#include "../mwbase/scriptmanager.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
|
@ -177,6 +178,7 @@ namespace MWDialogue
|
|||
|
||||
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(), mActor);
|
||||
callback->addResponse({}, Interpreter::fixDefinesDialog(info->mResponse, interpreterContext));
|
||||
MWBase::Environment::get().getLuaManager()->onInfoGetText(mActor, info->mId);
|
||||
executeScript(info->mResultScript, mActor);
|
||||
mLastTopic = dialogue.mId;
|
||||
|
||||
|
@ -317,6 +319,7 @@ namespace MWDialogue
|
|||
|
||||
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(), mActor);
|
||||
callback->addResponse(title, Interpreter::fixDefinesDialog(info->mResponse, interpreterContext));
|
||||
MWBase::Environment::get().getLuaManager()->onInfoGetText(mActor, info->mId);
|
||||
|
||||
if (dialogue.mType == ESM::Dialogue::Topic)
|
||||
{
|
||||
|
@ -484,6 +487,7 @@ namespace MWDialogue
|
|||
|
||||
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(), mActor);
|
||||
callback->addResponse({}, Interpreter::fixDefinesDialog(text, interpreterContext));
|
||||
MWBase::Environment::get().getLuaManager()->onInfoGetText(mActor, info->mId);
|
||||
|
||||
if (dialogue->mType == ESM::Dialogue::Topic)
|
||||
{
|
||||
|
|
|
@ -413,6 +413,16 @@ namespace MWLua
|
|||
playerScripts->uiModeChanged(argId, false);
|
||||
}
|
||||
|
||||
void LuaManager::onInfoGetText(const MWWorld::Ptr& actor, const ESM::RefId& infoId)
|
||||
{
|
||||
if (mPlayer.isEmpty() || actor.isEmpty())
|
||||
return;
|
||||
|
||||
PlayerScripts* playerScripts = dynamic_cast<PlayerScripts*>(mPlayer.getRefData().getLuaScripts());
|
||||
if (playerScripts)
|
||||
playerScripts->onInfoGetText(getId(actor), infoId.serializeText());
|
||||
}
|
||||
|
||||
void LuaManager::actorDied(const MWWorld::Ptr& actor)
|
||||
{
|
||||
if (actor.isEmpty())
|
||||
|
|
|
@ -80,6 +80,7 @@ namespace MWLua
|
|||
{
|
||||
mEngineEvents.addToQueue(EngineEvents::OnConsume{ getId(actor), getId(consumable) });
|
||||
}
|
||||
void onInfoGetText(const MWWorld::Ptr& actor, const ESM::RefId& infoId) override;
|
||||
void objectActivated(const MWWorld::Ptr& object, const MWWorld::Ptr& actor) override
|
||||
{
|
||||
mEngineEvents.addToQueue(EngineEvents::OnActivate{ getId(actor), getId(object) });
|
||||
|
|
|
@ -20,7 +20,8 @@ namespace MWLua
|
|||
: LocalScripts(lua, obj)
|
||||
, mInputProcessor(this)
|
||||
{
|
||||
registerEngineHandlers({ &mConsoleCommandHandlers, &mOnFrameHandlers, &mQuestUpdate, &mUiModeChanged });
|
||||
registerEngineHandlers(
|
||||
{ &mConsoleCommandHandlers, &mOnFrameHandlers, &mQuestUpdate, &mUiModeChanged, &mOnInfoGetText });
|
||||
}
|
||||
|
||||
void processInputEvent(const MWBase::LuaManager::InputEvent& event)
|
||||
|
@ -47,6 +48,11 @@ namespace MWLua
|
|||
callEngineHandlers(mUiModeChanged, byLuaAction, LObject(arg));
|
||||
}
|
||||
|
||||
void onInfoGetText(ObjectId arg, const std::string_view infoId)
|
||||
{
|
||||
callEngineHandlers(mOnInfoGetText, LObject(arg), infoId);
|
||||
}
|
||||
|
||||
private:
|
||||
friend class MWLua::InputProcessor<PlayerScripts>;
|
||||
InputProcessor<PlayerScripts> mInputProcessor;
|
||||
|
@ -54,6 +60,7 @@ namespace MWLua
|
|||
EngineHandlerList mOnFrameHandlers{ "onFrame" };
|
||||
EngineHandlerList mQuestUpdate{ "onQuestUpdate" };
|
||||
EngineHandlerList mUiModeChanged{ "_onUiModeChanged" };
|
||||
EngineHandlerList mOnInfoGetText{ "onInfoGetText" };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue