Merge pull request #337 from OpenMW/master

Add OpenMW commits up to 15 Nov 2017
new-script-api
David Cernat 7 years ago committed by GitHub
commit 5aff515d3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -104,6 +104,7 @@ namespace MWDialogue
void DialogueManager::parseText (const std::string& text) void DialogueManager::parseText (const std::string& text)
{ {
updateActorKnownTopics();
std::vector<HyperTextParser::Token> hypertext = HyperTextParser::parseHyperText(text); std::vector<HyperTextParser::Token> hypertext = HyperTextParser::parseHyperText(text);
for (std::vector<HyperTextParser::Token>::iterator tok = hypertext.begin(); tok != hypertext.end(); ++tok) for (std::vector<HyperTextParser::Token>::iterator tok = hypertext.begin(); tok != hypertext.end(); ++tok)
@ -183,18 +184,13 @@ namespace MWDialogue
// TODO play sound // TODO play sound
} }
// first topics update so that parseText knows the keywords to highlight
updateActorKnownTopics();
parseText (info->mResponse);
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor); MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor);
callback->addResponse("", Interpreter::fixDefinesDialog(info->mResponse, interpreterContext)); callback->addResponse("", Interpreter::fixDefinesDialog(info->mResponse, interpreterContext));
executeScript (info->mResultScript, mActor); executeScript (info->mResultScript, mActor);
mLastTopic = it->mId; mLastTopic = it->mId;
// update topics again to accommodate changes resulting from executeScript parseText (info->mResponse);
updateActorKnownTopics();
return true; return true;
} }
@ -290,8 +286,6 @@ namespace MWDialogue
const ESM::DialInfo* info = filter.search(dialogue, true); const ESM::DialInfo* info = filter.search(dialogue, true);
if (info) if (info)
{ {
parseText (info->mResponse);
std::string title; std::string title;
if (dialogue.mType==ESM::Dialogue::Persuasion) if (dialogue.mType==ESM::Dialogue::Persuasion)
{ {
@ -330,6 +324,8 @@ namespace MWDialogue
executeScript (info->mResultScript, mActor); executeScript (info->mResultScript, mActor);
parseText (info->mResponse);
mLastTopic = topic; mLastTopic = topic;
} }
} }

@ -45,6 +45,11 @@ namespace MWGui
mWindow->addResponse(title, text, mNeedMargin); mWindow->addResponse(title, text, mNeedMargin);
} }
void updateTopics()
{
mWindow->updateTopics();
}
private: private:
DialogueWindow* mWindow; DialogueWindow* mWindow;
bool mNeedMargin; bool mNeedMargin;
@ -91,6 +96,7 @@ namespace MWGui
type = MWBase::MechanicsManager::PT_Bribe1000; type = MWBase::MechanicsManager::PT_Bribe1000;
MWBase::Environment::get().getDialogueManager()->persuade(type, mCallback.get()); MWBase::Environment::get().getDialogueManager()->persuade(type, mCallback.get());
mCallback->updateTopics();
setVisible(false); setVisible(false);
} }
@ -395,6 +401,8 @@ namespace MWGui
else if (topic == gmst.find("sRepair")->getString()) else if (topic == gmst.find("sRepair")->getString())
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_MerchantRepair, mPtr); MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_MerchantRepair, mPtr);
} }
else
updateTopics();
} }
} }
@ -432,7 +440,9 @@ namespace MWGui
setTitle(mPtr.getClass().getName(mPtr)); setTitle(mPtr.getClass().getName(mPtr));
updateTopicsPane(); updateTopics();
updateTopicsPane(); // force update for new services
updateDisposition(); updateDisposition();
restock(); restock();
} }
@ -620,11 +630,13 @@ namespace MWGui
void DialogueWindow::onTopicActivated(const std::string &topicId) void DialogueWindow::onTopicActivated(const std::string &topicId)
{ {
MWBase::Environment::get().getDialogueManager()->keywordSelected(topicId, mCallback.get()); MWBase::Environment::get().getDialogueManager()->keywordSelected(topicId, mCallback.get());
updateTopics();
} }
void DialogueWindow::onChoiceActivated(int id) void DialogueWindow::onChoiceActivated(int id)
{ {
MWBase::Environment::get().getDialogueManager()->questionAnswered(id, mCallback.get()); MWBase::Environment::get().getDialogueManager()->questionAnswered(id, mCallback.get());
updateTopics();
} }
void DialogueWindow::onGoodbyeActivated() void DialogueWindow::onGoodbyeActivated()

@ -131,8 +131,9 @@ namespace MWGui
void onFrame(float dt); void onFrame(float dt);
void clear() { resetReference(); } void clear() { resetReference(); }
protected:
void updateTopics(); void updateTopics();
protected:
void updateTopicsPane(); void updateTopicsPane();
bool isCompanion(const MWWorld::Ptr& actor); bool isCompanion(const MWWorld::Ptr& actor);
bool isCompanion(); bool isCompanion();

@ -85,7 +85,7 @@ bool AiPursue::execute (const MWWorld::Ptr& actor, CharacterController& characte
float pathTolerance = 100.0; float pathTolerance = 100.0;
if (pathTo(actor, dest, duration, pathTolerance) && if (pathTo(actor, dest, duration, pathTolerance) &&
abs(dest.mZ - aPos.pos[2]) < pathTolerance) // check the true distance in case the target is far away in Z-direction std::abs(dest.mZ - aPos.pos[2]) < pathTolerance) // check the true distance in case the target is far away in Z-direction
{ {
target.getClass().activate(target,actor).get()->execute(actor); //Arrest player when reached target.getClass().activate(target,actor).get()->execute(actor); //Arrest player when reached

@ -196,8 +196,6 @@ class CharacterController : public MWRender::Animation::TextKeyListener
float mSecondsOfSwimming; float mSecondsOfSwimming;
float mSecondsOfRunning; float mSecondsOfRunning;
float mTimeUntilWake;
MWWorld::ConstPtr mHeadTrackTarget; MWWorld::ConstPtr mHeadTrackTarget;
float mTurnAnimationThreshold; // how long to continue playing turning animation after actor stopped turning float mTurnAnimationThreshold; // how long to continue playing turning animation after actor stopped turning
@ -206,6 +204,8 @@ class CharacterController : public MWRender::Animation::TextKeyListener
bool mAttackingOrSpell; bool mAttackingOrSpell;
float mTimeUntilWake;
void setAttackTypeBasedOnMovement(); void setAttackTypeBasedOnMovement();
void refreshCurrentAnims(CharacterState idle, CharacterState movement, JumpingState jump, bool force=false); void refreshCurrentAnims(CharacterState idle, CharacterState movement, JumpingState jump, bool force=false);

@ -13,6 +13,7 @@
<Property key="TextAlign" value="Left Top"/> <Property key="TextAlign" value="Left Top"/>
<Property key="TextColour" value="1 1 1"/> <Property key="TextColour" value="1 1 1"/>
<Property key="InvertSelected" value="false"/> <Property key="InvertSelected" value="false"/>
<Property key="WordWrap" value="true"/>
</Widget> </Widget>
<!-- Command line --> <!-- Command line -->

Loading…
Cancel
Save