1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 22:19:54 +00:00
openmw-tes3mp/apps/openmw/mwgui/dialogue.hpp

227 lines
6.2 KiB
C++
Raw Normal View History

2010-11-03 20:21:08 +00:00
#ifndef MWGUI_DIALOGE_H
#define MWGUI_DIALOGE_H
#include "windowbase.hpp"
#include "referenceinterface.hpp"
2012-05-17 15:15:44 +00:00
2013-05-04 12:15:47 +00:00
#include "bookpage.hpp"
#include "../mwdialogue/keywordsearch.hpp"
2013-05-04 12:15:47 +00:00
#include <MyGUI_Delegate.h>
namespace Gui
{
class MWList;
}
namespace MWGui
2010-11-03 20:21:08 +00:00
{
class WindowManager;
2010-11-03 20:21:08 +00:00
}
namespace MWGui
{
class ResponseCallback;
2012-11-09 19:18:38 +00:00
class PersuasionDialog : public WindowModal
{
public:
PersuasionDialog(ResponseCallback* callback);
void onOpen() override;
2012-11-09 19:18:38 +00:00
MyGUI::Widget* getDefaultKeyFocus() override;
2012-11-09 19:18:38 +00:00
private:
std::unique_ptr<ResponseCallback> mCallback;
2012-11-09 19:18:38 +00:00
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);
};
2013-05-04 12:15:47 +00:00
struct Link
{
virtual ~Link() {}
virtual void activated () = 0;
};
struct Topic : Link
{
typedef MyGUI::delegates::CMultiDelegate1<const std::string&> EventHandle_TopicId;
EventHandle_TopicId eventTopicActivated;
2013-05-04 12:15:47 +00:00
Topic(const std::string& id) : mTopicId(id) {}
std::string mTopicId;
void activated () override;
2013-05-04 12:15:47 +00:00
};
struct Choice : Link
{
typedef MyGUI::delegates::CMultiDelegate1<int> EventHandle_ChoiceId;
EventHandle_ChoiceId eventChoiceActivated;
2013-05-04 12:15:47 +00:00
Choice(int id) : mChoiceId(id) {}
int mChoiceId;
void activated () override;
2013-05-04 12:15:47 +00:00
};
2013-05-04 13:15:44 +00:00
struct Goodbye : Link
{
typedef MyGUI::delegates::CMultiDelegate0 Event_Activated;
Event_Activated eventActivated;
void activated () override;
2013-05-04 13:15:44 +00:00
};
typedef MWDialogue::KeywordSearch <std::string, intptr_t> KeywordSearchT;
2013-05-04 12:15:47 +00:00
struct DialogueText
{
virtual ~DialogueText() {}
virtual void write (BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map<std::string, Link*>& topicLinks) const = 0;
2013-05-04 12:15:47 +00:00
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<std::string, Link*>& topicLinks) const override;
void addTopicLink (BookTypesetter::Ptr typesetter, intptr_t topicId, size_t begin, size_t end) const;
2013-05-04 12:15:47 +00:00
std::string mTitle;
bool mNeedMargin;
2013-05-04 12:15:47 +00:00
};
struct Message : DialogueText
{
Message(const std::string& text);
void write (BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map<std::string, Link*>& topicLinks) const override;
2013-05-04 12:15:47 +00:00
};
class DialogueWindow: public WindowBase, public ReferenceInterface
2010-11-03 20:21:08 +00:00
{
public:
DialogueWindow();
~DialogueWindow();
2010-11-03 20:21:08 +00:00
void onTradeComplete();
bool exit() override;
2010-11-03 20:21:08 +00:00
// Events
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
2010-11-03 20:21:08 +00:00
2013-05-04 12:15:47 +00:00
void notifyLinkClicked (TypesetBook::InteractiveId link);
2010-11-03 20:21:08 +00:00
/*
Start of tes3mp addition
Make it possible to activate any dialogue choice from elsewhere in the code
*/
void activateDialogueChoice(unsigned char dialogueChoiceType, std::string topic = "");
/*
End of tes3mp addition
*/
/*
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;
/// @return true if stale keywords were updated successfully
bool setKeywords(std::list<std::string> keyWord);
2013-05-04 12:15:47 +00:00
void addResponse (const std::string& title, const std::string& text, bool needMargin = true);
2013-05-04 12:15:47 +00:00
void addMessageBox(const std::string& text);
2013-05-04 12:15:47 +00:00
void onFrame(float dt) override;
void clear() override { resetReference(); }
void updateTopics();
void onClose() override;
protected:
void updateTopicsPane();
2017-10-21 12:56:21 +00:00
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);
2010-11-03 20:21:08 +00:00
void onByeClicked(MyGUI::Widget* _sender);
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
2012-05-10 09:19:22 +00:00
void onWindowResize(MyGUI::Window* _sender);
void onTopicActivated(const std::string& topicId);
void onChoiceActivated(int id);
void onGoodbyeActivated();
2010-11-03 20:21:08 +00:00
2013-05-04 12:15:47 +00:00
void onScrollbarMoved (MyGUI::ScrollBar* sender, size_t pos);
void updateHistory(bool scrollbar=false);
void onReferenceUnavailable() override;
2010-11-03 20:21:08 +00:00
private:
2017-09-25 19:29:06 +00:00
void updateDisposition();
void restock();
void deleteLater();
2010-11-03 20:21:08 +00:00
bool mIsCompanion;
std::list<std::string> mKeywords;
2013-05-04 12:15:47 +00:00
std::vector<DialogueText*> mHistoryContents;
std::vector<std::pair<std::string, int> > mChoices;
bool mGoodbye;
2013-05-04 12:15:47 +00:00
std::vector<Link*> mLinks;
std::map<std::string, Link*> mTopicLinks;
std::vector<Link*> mDeleteLater;
2013-05-04 12:15:47 +00:00
KeywordSearchT mKeywordSearch;
BookPage* mHistory;
Gui::MWList* mTopicsList;
2013-05-04 12:15:47 +00:00
MyGUI::ScrollBar* mScrollBar;
2015-01-10 01:50:43 +00:00
MyGUI::ProgressBar* mDispositionBar;
2017-03-27 09:33:28 +00:00
MyGUI::TextBox* mDispositionText;
MyGUI::Button* mGoodbyeButton;
2012-11-09 19:18:38 +00:00
PersuasionDialog mPersuasionDialog;
2017-07-24 11:25:01 +00:00
MyGUI::IntSize mCurrentWindowSize;
std::unique_ptr<ResponseCallback> mCallback;
std::unique_ptr<ResponseCallback> mGreetingCallback;
void updateTopicFormat();
2010-11-03 20:21:08 +00:00
};
}
#endif