OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
dialogue.hpp
Go to the documentation of this file.
1 #ifndef MWGUI_DIALOGE_H
2 #define MWGUI_DIALOGE_H
3 
4 #include "windowbase.hpp"
5 #include "referenceinterface.hpp"
6 
7 #include "bookpage.hpp"
8 
9 #include "../mwdialogue/keywordsearch.hpp"
10 
11 namespace Gui
12 {
13  class MWList;
14 }
15 
16 namespace MWGui
17 {
18  class WindowManager;
19 }
20 
21 namespace MWGui
22 {
23  class DialogueHistoryViewModel;
24  class BookPage;
25 
27  {
28  public:
30 
31  virtual void open();
32  virtual void exit();
33 
34  private:
35  MyGUI::Button* mCancelButton;
36  MyGUI::Button* mAdmireButton;
37  MyGUI::Button* mIntimidateButton;
38  MyGUI::Button* mTauntButton;
39  MyGUI::Button* mBribe10Button;
40  MyGUI::Button* mBribe100Button;
41  MyGUI::Button* mBribe1000Button;
42  MyGUI::TextBox* mGoldLabel;
43 
44  void onCancel (MyGUI::Widget* sender);
45  void onPersuade (MyGUI::Widget* sender);
46  };
47 
48 
49  struct Link
50  {
51  virtual ~Link() {}
52  virtual void activated () = 0;
53  };
54 
55  struct Topic : Link
56  {
57  Topic(const std::string& id) : mTopicId(id) {}
58  std::string mTopicId;
59  virtual void activated ();
60  };
61 
62  struct Choice : Link
63  {
64  Choice(int id) : mChoiceId(id) {}
65  int mChoiceId;
66  virtual void activated ();
67  };
68 
69  struct Goodbye : Link
70  {
71  virtual void activated ();
72  };
73 
75 
76  struct DialogueText
77  {
78  virtual ~DialogueText() {}
79  virtual void write (BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map<std::string, Link*>& topicLinks) const = 0;
80  std::string mText;
81  };
82 
84  {
85  Response(const std::string& text, const std::string& title = "");
86  virtual void write (BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map<std::string, Link*>& topicLinks) const;
87  void addTopicLink (BookTypesetter::Ptr typesetter, intptr_t topicId, size_t begin, size_t end) const;
88  std::string mTitle;
89  };
90 
92  {
93  Message(const std::string& text);
94  virtual void write (BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map<std::string, Link*>& topicLinks) const;
95  };
96 
98  {
99  public:
100  DialogueWindow();
101 
102  virtual void exit();
103 
104  // Events
105  typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
106 
108 
109  void startDialogue(MWWorld::Ptr actor, std::string npcName, bool resetHistory);
110  void setKeywords(std::list<std::string> keyWord);
111 
112  void addResponse (const std::string& text, const std::string& title="");
113 
114  void addMessageBox(const std::string& text);
115 
116  void addChoice(const std::string& choice, int id);
117  void clearChoices();
118 
119  void goodbye();
120  void onFrame();
121 
122  // make sure to call these before setKeywords()
123  void setServices(int services) { mServices = services; }
124 
125  enum Services
126  {
134  };
135 
136  protected:
137  void onSelectTopic(const std::string& topic, int id);
138  void onByeClicked(MyGUI::Widget* _sender);
139  void onMouseWheel(MyGUI::Widget* _sender, int _rel);
140  void onWindowResize(MyGUI::Window* _sender);
141 
142  void onScrollbarMoved (MyGUI::ScrollBar* sender, size_t pos);
143 
144  void updateHistory(bool scrollbar=false);
145 
146  virtual void onReferenceUnavailable();
147 
148  private:
149  void updateOptions();
150  void restock();
151 
153 
154  bool mEnabled;
155 
156  bool mGoodbye;
157 
158  std::vector<DialogueText*> mHistoryContents;
159  std::vector<std::pair<std::string, int> > mChoices;
160 
161  std::vector<Link*> mLinks;
162  std::map<std::string, Link*> mTopicLinks;
163 
165 
168  MyGUI::ScrollBar* mScrollBar;
169  MyGUI::ProgressBar* mDispositionBar;
170  MyGUI::EditBox* mDispositionText;
171 
173  };
174 }
175 #endif
virtual void open()
Notify that window has been made visible.
Definition: dialogue.cpp:88
void onCancel(MyGUI::Widget *sender)
Definition: dialogue.cpp:65
void onByeClicked(MyGUI::Widget *_sender)
Definition: dialogue.cpp:316
Definition: dialogue.hpp:128
virtual void onReferenceUnavailable()
called when reference has become unavailable
Definition: dialogue.cpp:633
int mChoiceId
Definition: dialogue.hpp:65
void setKeywords(std::list< std::string > keyWord)
Definition: dialogue.cpp:407
std::map< std::string, Link * > mTopicLinks
Definition: dialogue.hpp:162
void onMouseWheel(MyGUI::Widget *_sender, int _rel)
Definition: dialogue.cpp:307
KeywordSearchT mKeywordSearch
Definition: dialogue.hpp:164
a very simple list widget that supports word-wrapping entries
Definition: list.hpp:12
MyGUI::Button * mCancelButton
Definition: dialogue.hpp:35
Definition: dialogue.hpp:127
void updateHistory(bool scrollbar=false)
Definition: dialogue.cpp:466
Definition: dialogue.hpp:26
std::string mTitle
Definition: dialogue.hpp:88
MyGUI::TextBox * mGoldLabel
Definition: dialogue.hpp:42
BookPage * mHistory
Definition: dialogue.hpp:166
void addResponse(const std::string &text, const std::string &title="")
Definition: dialogue.cpp:553
Definition: dialogue.hpp:130
void notifyLinkClicked(TypesetBook::InteractiveId link)
Definition: dialogue.cpp:543
bool mGoodbye
Definition: dialogue.hpp:156
DialogueWindow()
Definition: dialogue.cpp:250
Definition: dialogue.hpp:69
virtual void exit()
Gracefully exits the window.
Definition: dialogue.cpp:286
MyGUI::EditBox * mDispositionText
Definition: dialogue.hpp:170
void onWindowResize(MyGUI::Window *_sender)
Definition: dialogue.cpp:301
std::vector< Link * > mLinks
Definition: dialogue.hpp:161
MyGUI::Button * mBribe1000Button
Definition: dialogue.hpp:41
Definition: dialogue.hpp:97
MyGUI::Button * mIntimidateButton
Definition: dialogue.hpp:37
void startDialogue(MWWorld::Ptr actor, std::string npcName, bool resetHistory)
Definition: dialogue.cpp:364
void addTopicLink(BookTypesetter::Ptr typesetter, intptr_t topicId, size_t begin, size_t end) const
Definition: dialogue.cpp:200
Topic(const std::string &id)
Definition: dialogue.hpp:57
MyGUI::Button * mTauntButton
Definition: dialogue.hpp:38
Definition: dialogue.hpp:76
Gui::MWList * mTopicsList
Definition: dialogue.hpp:167
virtual void activated()
Definition: dialogue.cpp:227
virtual void activated()
Definition: dialogue.cpp:241
std::vector< std::pair< std::string, int > > mChoices
Definition: dialogue.hpp:159
void clearChoices()
Definition: dialogue.cpp:588
std::string mTopicId
Definition: dialogue.hpp:58
Definition: dialogue.hpp:62
virtual void write(BookTypesetter::Ptr typesetter, KeywordSearchT *keywordSearch, std::map< std::string, Link * > &topicLinks) const
Definition: dialogue.cpp:218
virtual ~DialogueText()
Definition: dialogue.hpp:78
Definition: dialogue.hpp:133
void addMessageBox(const std::string &text)
Definition: dialogue.cpp:576
MyGUI::delegates::CMultiDelegate0 EventHandle_Void
Definition: dialogue.hpp:105
Definition: dialogue.hpp:83
MWDialogue::KeywordSearch< std::string, intptr_t > KeywordSearchT
Definition: dialogue.hpp:74
MyGUI::Button * mBribe10Button
Definition: dialogue.hpp:39
Response(const std::string &text, const std::string &title="")
Definition: dialogue.cpp:110
Choice(int id)
Definition: dialogue.hpp:64
void onPersuade(MyGUI::Widget *sender)
Definition: dialogue.cpp:70
Message(const std::string &text)
Definition: dialogue.cpp:213
virtual void activated()
Definition: dialogue.cpp:234
Definition: dialogue.hpp:131
void onScrollbarMoved(MyGUI::ScrollBar *sender, size_t pos)
Definition: dialogue.cpp:548
boost::shared_ptr< BookTypesetter > Ptr
Definition: bookpage.hpp:36
void goodbye()
Definition: dialogue.cpp:626
Definition: windowbase.hpp:16
MyGUI::ScrollBar * mScrollBar
Definition: dialogue.hpp:168
An interface to the BookPage widget.
Definition: bookpage.hpp:99
void restock()
Definition: dialogue.cpp:393
std::vector< DialogueText * > mHistoryContents
Definition: dialogue.hpp:158
this class is intended for GUI interfaces that access an MW-Reference for example dialogue window acc...
Definition: referenceinterface.hpp:12
void addChoice(const std::string &choice, int id)
Definition: dialogue.cpp:582
Definition: dialogue.hpp:55
PersuasionDialog()
Definition: dialogue.cpp:44
int mServices
Definition: dialogue.hpp:152
PersuasionDialog mPersuasionDialog
Definition: dialogue.hpp:172
MyGUI::Button * mBribe100Button
Definition: dialogue.hpp:40
std::string mText
Definition: dialogue.hpp:80
virtual void exit()
Gracefully exits the window.
Definition: dialogue.cpp:103
bool mEnabled
Definition: dialogue.hpp:154
virtual void write(BookTypesetter::Ptr typesetter, KeywordSearchT *keywordSearch, std::map< std::string, Link * > &topicLinks) const =0
MyGUI::Button * mAdmireButton
Definition: dialogue.hpp:36
void setServices(int services)
Definition: dialogue.hpp:123
void updateOptions()
Definition: dialogue.cpp:594
Definition: dialogue.hpp:132
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
void onSelectTopic(const std::string &topic, int id)
Definition: dialogue.cpp:321
void onFrame()
Definition: dialogue.cpp:638
virtual void write(BookTypesetter::Ptr typesetter, KeywordSearchT *keywordSearch, std::map< std::string, Link * > &topicLinks) const
Definition: dialogue.cpp:116
Services
Definition: dialogue.hpp:125
Definition: dialogue.hpp:91
MyGUI::ProgressBar * mDispositionBar
Definition: dialogue.hpp:169
Definition: windowbase.hpp:41