ScummVM API documentation
dialogue_runtime.h
1 #ifndef HARVESTER_NPC_DIALOGUE_RUNTIME_H
2 #define HARVESTER_NPC_DIALOGUE_RUNTIME_H
3 
4 #include "common/error.h"
5 #include "common/str.h"
6 #include "harvester/script.h"
7 
8 namespace Harvester {
9 
10 class HarvesterEngine;
11 class Flow;
12 class Text;
13 
15  int wavId;
16  const char *speakerId;
17  int headVariant;
18 };
19 
22  : fromTypedInput(false), fromEscape(false), fromGenericBye(false) {
23  }
24 
25  bool fromTypedInput;
26  bool fromEscape;
27  bool fromGenericBye;
28 };
29 
31 public:
32  virtual ~DialogueRuntimeCallbacks() {}
33 
34  virtual Common::Error playDialogueLineWithVariant(int wavId, const Common::String &speakerId,
35  int headVariant) = 0;
36  virtual Common::Error playDialogueLine(int wavId, const Common::String &speakerId) = 0;
37  virtual Common::Error playDialogueEntrySequence(const DialogueLineEntry *lines, uint count) = 0;
38  virtual Common::Error playDialogueFst(const Common::String &path) = 0;
39  virtual Common::Error clearScreenToBlack() = 0;
40  virtual Common::Error showCdChangePrompt(int discNumber) = 0;
41  virtual Common::Error runKeywordMenu(const Common::String &topicBuffer, int topicBufferLineIndex,
42  Common::String &selectedTopic, DialogueKeywordMenuSelectionState &selection) = 0;
43  virtual Common::Error runResponseMenu(int responseLineIndex, int &responseIndex) = 0;
44  virtual Common::Error runResponseMenuText(const Common::String &responseLine, int &responseIndex) = 0;
45  virtual Common::Error runGameOverScreen() = 0;
46  virtual void assignTopicBuffer(Common::String &topicBuffer, int &topicBufferLineIndex,
47  int responseLineIndex, const char *label) = 0;
48  virtual bool matchesResponseLine(const Common::String &selectedTopic, int responseLineIndex) = 0;
49  virtual bool matchesAnyResponseLine(const Common::String &selectedTopic,
50  const int *responseLineIndices, uint responseLineCount) = 0;
51  virtual void queueDialogueInteractionIfNeeded(const InteractionResult &interaction) = 0;
52  virtual void applyImmediateDialogueInteractionEffects(InteractionResult &interaction) = 0;
53  virtual int getRandomNumber(int maxValue) = 0;
54  virtual void setActiveSpeakerPortrait(const Common::String &speakerId, int headVariant) = 0;
55 };
56 
58 public:
60 
61  DialogueRuntime(HarvesterEngine &engine, Script &script, Text &text,
62  Flow &flow, const Common::String &currentRoomName,
63  const Common::String &genericByeTopic,
64  DialogueRuntimeCallbacks &callbacks)
65  : _engine(engine), _script(script), _text(text),
66  _flow(flow), _currentRoomName(currentRoomName),
67  _genericByeTopic(genericByeTopic),
68  _callbacks(callbacks) {
69  }
70 
71  HarvesterEngine &engine() const { return _engine; }
72  Script &startupScript() const { return _script; }
73  Text &startupText() const { return _text; }
74  Flow &startupFlow() const { return _flow; }
75  const Common::String &currentRoomName() const { return _currentRoomName; }
76  const Common::String &genericByeTopic() const { return _genericByeTopic; }
77  bool executeActionTag(const Common::String &tag, InteractionResult &result,
78  bool allowTransitions = true) const {
79  return _script.executeActionTag(tag, result, allowTransitions, _currentRoomName);
80  }
81 
82  Common::Error playDialogueLineWithVariant(int wavId, const Common::String &speakerId,
83  int headVariant) const {
84  return _callbacks.playDialogueLineWithVariant(wavId, speakerId, headVariant);
85  }
86  Common::Error playDialogueLine(int wavId, const Common::String &speakerId) const {
87  return _callbacks.playDialogueLine(wavId, speakerId);
88  }
89  Common::Error playDialogueEntrySequence(const DialogueLineEntry *lines, uint count) const {
90  return _callbacks.playDialogueEntrySequence(lines, count);
91  }
92  Common::Error playDialogueFst(const Common::String &path) const { return _callbacks.playDialogueFst(path); }
93  Common::Error clearScreenToBlack() const { return _callbacks.clearScreenToBlack(); }
94  Common::Error showCdChangePrompt(int discNumber) const { return _callbacks.showCdChangePrompt(discNumber); }
95  Common::Error runKeywordMenu(const Common::String &topicBuffer, int topicBufferLineIndex,
96  Common::String &selectedTopic) const {
97  _lastKeywordSelection = KeywordMenuSelectionState();
98  return _callbacks.runKeywordMenu(topicBuffer, topicBufferLineIndex, selectedTopic, _lastKeywordSelection);
99  }
100  Common::Error runResponseMenu(int responseLineIndex, int &responseIndex) const {
101  return _callbacks.runResponseMenu(responseLineIndex, responseIndex);
102  }
103  Common::Error runResponseMenuText(const Common::String &responseLine, int &responseIndex) const {
104  return _callbacks.runResponseMenuText(responseLine, responseIndex);
105  }
106  Common::Error runGameOverScreen() const { return _callbacks.runGameOverScreen(); }
107  void assignTopicBuffer(Common::String &topicBuffer, int &topicBufferLineIndex,
108  int responseLineIndex, const char *label) const {
109  _callbacks.assignTopicBuffer(topicBuffer, topicBufferLineIndex, responseLineIndex, label);
110  }
111  bool matchesResponseLine(const Common::String &selectedTopic, int responseLineIndex) const {
112  return _callbacks.matchesResponseLine(selectedTopic, responseLineIndex);
113  }
114  bool matchesAnyResponseLine(const Common::String &selectedTopic,
115  const int *responseLineIndices, uint responseLineCount) const {
116  return _callbacks.matchesAnyResponseLine(selectedTopic, responseLineIndices, responseLineCount);
117  }
118  bool lastKeywordSelectionWasTypedInput() const { return _lastKeywordSelection.fromTypedInput; }
119  bool lastKeywordSelectionWasGenericBye() const { return _lastKeywordSelection.fromGenericBye; }
120  void queueDialogueInteractionIfNeeded(const InteractionResult &interaction) const {
121  _callbacks.queueDialogueInteractionIfNeeded(interaction);
122  }
123  void applyImmediateDialogueInteractionEffects(InteractionResult &interaction) const {
124  _callbacks.applyImmediateDialogueInteractionEffects(interaction);
125  }
126  int getRandomNumber(int maxValue) const { return _callbacks.getRandomNumber(maxValue); }
127  void setActiveSpeakerPortrait(const Common::String &speakerId, int headVariant) const {
128  _callbacks.setActiveSpeakerPortrait(speakerId, headVariant);
129  }
130 
131 private:
132  HarvesterEngine &_engine;
133  Script &_script;
134  Text &_text;
135  Flow &_flow;
136  const Common::String &_currentRoomName;
137  const Common::String &_genericByeTopic;
138  DialogueRuntimeCallbacks &_callbacks;
139  mutable KeywordMenuSelectionState _lastKeywordSelection;
140 };
141 
142 } // End of namespace Harvester
143 
144 #endif // HARVESTER_NPC_DIALOGUE_RUNTIME_H
Definition: dialogue_runtime.h:30
Definition: flow.h:46
Definition: str.h:59
Definition: art.h:31
Definition: error.h:81
Definition: script.h:319
Definition: text.h:47
Definition: dialogue_runtime.h:57
Definition: dialogue_runtime.h:20
Definition: dialogue_runtime.h:14
Definition: harvester.h:47
Definition: script.h:288