#ifndef MWGUI_DIALOGE_H #define MWGUI_DIALOGE_H #include "windowbase.hpp" #include "referenceinterface.hpp" #include "bookpage.hpp" #include "../mwdialogue/keywordsearch.hpp" #include namespace Gui { class MWList; } namespace MWGui { class WindowManager; } namespace MWGui { class ResponseCallback; class PersuasionDialog : public WindowModal { public: PersuasionDialog(ResponseCallback* callback); void onOpen() override; MyGUI::Widget* getDefaultKeyFocus() override; private: std::unique_ptr mCallback; MyGUI::Button* mCancelButton; MyGUI::Button* mAdmireButton; MyGUI::Button* mIntimidateButton; MyGUI::Button* mTauntButton; MyGUI::Button* mBribe10Button; MyGUI::Button* mBribe100Button; MyGUI::Button* mBribe1000Button; MyGUI::TextBox* mGoldLabel; void onCancel (MyGUI::Widget* sender); void onPersuade (MyGUI::Widget* sender); }; struct Link { virtual ~Link() {} virtual void activated () = 0; }; struct Topic : Link { typedef MyGUI::delegates::CMultiDelegate1 EventHandle_TopicId; EventHandle_TopicId eventTopicActivated; Topic(const std::string& id) : mTopicId(id) {} std::string mTopicId; void activated () override; }; struct Choice : Link { typedef MyGUI::delegates::CMultiDelegate1 EventHandle_ChoiceId; EventHandle_ChoiceId eventChoiceActivated; Choice(int id) : mChoiceId(id) {} int mChoiceId; void activated () override; }; struct Goodbye : Link { typedef MyGUI::delegates::CMultiDelegate0 Event_Activated; Event_Activated eventActivated; void activated () override; }; typedef MWDialogue::KeywordSearch KeywordSearchT; struct DialogueText { virtual ~DialogueText() {} virtual void write (BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map& topicLinks) const = 0; std::string mText; }; struct Response : DialogueText { Response(const std::string& text, const std::string& title = "", bool needMargin = true); void write (BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map& topicLinks) const override; void addTopicLink (BookTypesetter::Ptr typesetter, intptr_t topicId, size_t begin, size_t end) const; std::string mTitle; bool mNeedMargin; }; struct Message : DialogueText { Message(const std::string& text); void write (BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map& topicLinks) const override; }; class DialogueWindow: public WindowBase, public ReferenceInterface { public: DialogueWindow(); ~DialogueWindow(); void onTradeComplete(); bool exit() override; // Events typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; void notifyLinkClicked (TypesetBook::InteractiveId link); /* Start of tes3mp addition Make it possible to get the Ptr of the actor involved in the dialogue */ MWWorld::Ptr getPtr(); /* End of tes3mp addition */ void setPtr(const MWWorld::Ptr& actor) override; void setKeywords(std::list keyWord); void addResponse (const std::string& title, const std::string& text, bool needMargin = true); void addMessageBox(const std::string& text); void onFrame(float dt) override; void clear() override { resetReference(); } void updateTopics(); void onClose() override; protected: void updateTopicsPane(); bool isCompanion(const MWWorld::Ptr& actor); bool isCompanion(); /* Start of tes3mp addition A different event that should be used in multiplayer when clicking on list items in the dialogue screen, sending DialogueChoice packets to the server so they can be approved or denied */ void onSendDialoguePacket(const std::string& topic, int id); /* End of tes3mp addition */ /* Start of tes3mp change (major) Turn onSelectListItem() into a public function so it can be used elsewhere when receiving ObjectDialogueChoice packets */ public: void onSelectListItem(const std::string& topic, int id); protected: /* End of tes3mp change (major) */ void onByeClicked(MyGUI::Widget* _sender); void onMouseWheel(MyGUI::Widget* _sender, int _rel); void onWindowResize(MyGUI::Window* _sender); void onTopicActivated(const std::string& topicId); void onChoiceActivated(int id); void onGoodbyeActivated(); void onScrollbarMoved (MyGUI::ScrollBar* sender, size_t pos); void updateHistory(bool scrollbar=false); void onReferenceUnavailable() override; private: void updateDisposition(); void restock(); void deleteLater(); bool mIsCompanion; std::list mKeywords; std::vector mHistoryContents; std::vector > mChoices; bool mGoodbye; std::vector mLinks; std::map mTopicLinks; std::vector mDeleteLater; KeywordSearchT mKeywordSearch; BookPage* mHistory; Gui::MWList* mTopicsList; MyGUI::ScrollBar* mScrollBar; MyGUI::ProgressBar* mDispositionBar; MyGUI::TextBox* mDispositionText; MyGUI::Button* mGoodbyeButton; PersuasionDialog mPersuasionDialog; MyGUI::IntSize mCurrentWindowSize; std::unique_ptr mCallback; std::unique_ptr mGreetingCallback; void updateTopicFormat(); }; } #endif