1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-11 09:36:37 +00:00
OpenMW/apps/openmw/mwgui/dialogue.hpp

176 lines
4.4 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
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
{
2013-05-04 12:15:47 +00:00
class DialogueHistoryViewModel;
class BookPage;
2010-11-03 20:21:08 +00:00
2012-11-09 19:18:38 +00:00
class PersuasionDialog : public WindowModal
{
public:
PersuasionDialog();
2012-11-09 19:18:38 +00:00
virtual void open();
virtual void exit();
2012-11-09 19:18:38 +00:00
private:
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
{
Topic(const std::string& id) : mTopicId(id) {}
std::string mTopicId;
virtual void activated ();
};
struct Choice : Link
{
Choice(int id) : mChoiceId(id) {}
int mChoiceId;
virtual void activated ();
};
2013-05-04 13:15:44 +00:00
struct Goodbye : Link
{
virtual void activated ();
};
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 = "");
virtual void write (BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map<std::string, Link*>& topicLinks) const;
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;
};
struct Message : DialogueText
{
Message(const std::string& text);
virtual void write (BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map<std::string, Link*>& topicLinks) const;
2013-05-04 12:15:47 +00:00
};
class DialogueWindow: public WindowBase, public ReferenceInterface
2010-11-03 20:21:08 +00:00
{
public:
DialogueWindow();
2010-11-03 20:21:08 +00:00
virtual void exit();
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
void startDialogue(MWWorld::Ptr actor, std::string npcName, bool resetHistory);
2012-03-19 17:30:52 +00:00
void setKeywords(std::list<std::string> keyWord);
2013-05-04 12:15:47 +00:00
void addResponse (const std::string& text, const std::string& title="");
void addMessageBox(const std::string& text);
2013-05-04 12:15:47 +00:00
void addChoice(const std::string& choice, int id);
void clearChoices();
void goodbye();
2012-11-05 22:16:37 +00:00
void onFrame();
// make sure to call these before setKeywords()
2012-09-22 22:36:20 +00:00
void setServices(int services) { mServices = services; }
enum Services
{
Service_Trade = 0x01,
Service_BuySpells = 0x02,
Service_CreateSpells = 0x04,
2012-10-17 16:03:02 +00:00
Service_Enchant = 0x08,
Service_Training = 0x10,
2013-03-22 13:13:10 +00:00
Service_Travel = 0x20,
Service_Repair = 0x40
2012-09-22 22:36:20 +00:00
};
2010-11-03 20:21:08 +00:00
protected:
void onSelectTopic(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);
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);
virtual void onReferenceUnavailable();
2010-11-03 20:21:08 +00:00
private:
void updateOptions();
void restock();
2010-11-03 20:21:08 +00:00
2012-09-22 22:36:20 +00:00
int mServices;
bool mEnabled;
2013-05-04 13:15:44 +00:00
bool mGoodbye;
2013-05-04 12:15:47 +00:00
std::vector<DialogueText*> mHistoryContents;
std::vector<std::pair<std::string, int> > mChoices;
2013-05-04 12:15:47 +00:00
std::vector<Link*> mLinks;
std::map<std::string, Link*> mTopicLinks;
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;
MyGUI::EditBox* mDispositionText;
2012-11-09 19:18:38 +00:00
PersuasionDialog mPersuasionDialog;
2010-11-03 20:21:08 +00:00
};
}
#endif