1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-01 20:36:42 +00:00

[Client] Use ObjectDialogueChoice for highlighted topics in dialogue

The packet is now sent not just for items in the list on the right of the dialogue screen, but also for the clickable topics in the dialogue text itself.
This commit is contained in:
David Cernat 2020-12-17 03:12:01 +02:00
parent 1a4b817b31
commit db32f7f9f8
4 changed files with 52 additions and 10 deletions

View file

@ -381,12 +381,7 @@ namespace MWGui
Instead of activating a list item here, send an ObjectDialogueChoice packet to the server
and let it decide whether the list item gets activated
*/
mwmp::ObjectList* objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = mwmp::CLIENT_GAMEPLAY;
objectList->addObjectDialogueChoice(mPtr, topic, id);
objectList->sendObjectDialogueChoice();
sendDialogueChoicePacket(topic);
return;
/*
End of tes3mp change (major)
@ -442,6 +437,25 @@ namespace MWGui
updateTopics();
}
/*
Start of tes3mp addition
A different event that should be used in multiplayer when clicking on choices
in the dialogue screen, sending DialogueChoice packets to the server so they can
be approved or denied
*/
void DialogueWindow::sendDialogueChoicePacket(const std::string& topic)
{
mwmp::ObjectList* objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = mwmp::CLIENT_GAMEPLAY;
objectList->addObjectDialogueChoice(mPtr, topic);
objectList->sendObjectDialogueChoice();
}
/*
End of tes3mp addition
*/
/*
Start of tes3mp addition
@ -650,7 +664,18 @@ namespace MWGui
mTopicsList->addItem(keyword);
Topic* t = new Topic(keyword);
t->eventTopicActivated += MyGUI::newDelegate(this, &DialogueWindow::onTopicActivated);
/*
Start of tes3mp change (major)
Instead of running DialogueWindow::onSelectListItem() when clicking a highlighted topic, run
onSendDialoguePacket() so the server can approve or deny a dialogue choice
*/
//t->eventTopicActivated += MyGUI::newDelegate(this, &DialogueWindow::onTopicActivated);
t->eventTopicActivated += MyGUI::newDelegate(this, &DialogueWindow::sendDialogueChoicePacket);
/*
End of tes3mp change (major)
*/
mTopicLinks[topicId] = t;
mKeywordSearch.seed(topicId, intptr_t(t));

View file

@ -160,6 +160,18 @@ namespace MWGui
bool isCompanion(const MWWorld::Ptr& actor);
bool isCompanion();
/*
Start of tes3mp addition
A different event that should be used in multiplayer when clicking on choices
in the dialogue screen, sending DialogueChoice packets to the server so they can
be approved or denied
*/
void sendDialogueChoicePacket(const std::string& topic);
/*
End of tes3mp addition
*/
void onSelectListItem(const std::string& topic, int id);
void onByeClicked(MyGUI::Widget* _sender);
void onMouseWheel(MyGUI::Widget* _sender, int _rel);

View file

@ -1009,6 +1009,12 @@ void ObjectList::makeDialogueChoices(MWWorld::CellStore* cellStore)
}
LOG_APPEND(TimedLog::LOG_VERBOSE, "-- Making dialogue choice of type %i", baseObject.dialogueChoiceType);
if (baseObject.dialogueChoiceType == DialogueChoiceType::TOPIC)
{
LOG_APPEND(TimedLog::LOG_VERBOSE, "-- topic was %s", baseObject.topicId.c_str());
}
MWBase::Environment::get().getWindowManager()->getDialogueWindow()->activateDialogueChoice(baseObject.dialogueChoiceType, baseObject.topicId);
}
else
@ -1268,7 +1274,7 @@ void ObjectList::addObjectLock(const MWWorld::Ptr& ptr, int lockLevel)
addBaseObject(baseObject);
}
void ObjectList::addObjectDialogueChoice(const MWWorld::Ptr& ptr, std::string dialogueChoice, int guiId)
void ObjectList::addObjectDialogueChoice(const MWWorld::Ptr& ptr, std::string dialogueChoice)
{
cell = *ptr.getCell()->getCell();
@ -1307,7 +1313,6 @@ void ObjectList::addObjectDialogueChoice(const MWWorld::Ptr& ptr, std::string di
baseObject.topicId = dialogueChoice;
}
baseObject.guiId = guiId;
addBaseObject(baseObject);
}

View file

@ -61,7 +61,7 @@ namespace mwmp
void addObjectSpawn(const MWWorld::Ptr& ptr);
void addObjectSpawn(const MWWorld::Ptr& ptr, const MWWorld::Ptr& master, std::string spellId, int effectId, float duration);
void addObjectLock(const MWWorld::Ptr& ptr, int lockLevel);
void addObjectDialogueChoice(const MWWorld::Ptr& ptr, std::string dialogueChoice, int guiId);
void addObjectDialogueChoice(const MWWorld::Ptr& ptr, std::string dialogueChoice);
void addObjectMiscellaneous(const MWWorld::Ptr& ptr, unsigned int goldPool, float lastGoldRestockHour, int lastGoldRestockDay);
void addObjectTrap(const MWWorld::Ptr& ptr, const ESM::Position& pos, bool isDisarmed);
void addObjectScale(const MWWorld::Ptr& ptr, float scale);