1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef CRYOMNI3D_DIALOGS_MANAGER_H
#define CRYOMNI3D_DIALOGS_MANAGER_H
#include "common/array.h"
#include "common/hash-str.h"
#include "common/hashmap.h"
#include "common/rect.h"
#include "common/str.h"
#include "common/str-array.h"
namespace CryOmni3D {
class DialogsManager {
public:
struct SubtitlesSettings {
SubtitlesSettings() { }
SubtitlesSettings(int16 textLeft, int16 textTop, int16 textRight, int16 textBottom,
int16 drawLeft, int16 drawTop, int16 drawRight, int16 drawBottom) :
textRect(textLeft, textTop, textRight, textBottom), drawRect(drawLeft, drawTop, drawRight,
drawBottom) { }
Common::Rect textRect;
Common::Rect drawRect;
};
DialogsManager() : _gtoBuffer(nullptr), _gtoEnd(nullptr),
_ignoreNoEndOfConversation(false) { }
virtual ~DialogsManager();
void init(unsigned int size, const Common::String &endOfConversationText) { _dialogsVariables.resize(size); _endOfConversationText = endOfConversationText; }
void loadGTO(const Common::String >oFile);
void setupVariable(unsigned int id, const Common::String &variable) { _dialogsVariables[id] = DialogVariable(variable, 'N'); }
void reinitVariables();
unsigned int size() const { return _dialogsVariables.size(); }
byte &operator[](unsigned int idx) { return _dialogsVariables[idx].value; }
const byte &operator[](unsigned int idx) const { return _dialogsVariables[idx].value; }
byte &operator[](const Common::String &name) { return find(name).value; }
const byte &operator[](const Common::String &name) const { return find(name).value; }
void registerSubtitlesSettings(const Common::String &videoName, const SubtitlesSettings &settings);
bool play(const Common::String &sequence, bool &slowStop);
protected:
virtual void executeShow(const Common::String &show) = 0;
virtual void playDialog(const Common::String &video, const Common::String &sound,
const Common::String &text, const SubtitlesSettings &settings) = 0;
virtual void displayMessage(const Common::String &text) = 0;
virtual unsigned int askPlayerQuestions(const Common::String &video,
const Common::StringArray &questions) = 0;
private:
struct Goto {
Goto() : label(), text(nullptr) {
}
Goto(const Common::String &label_, const char *text_) : label(label_), text(text_) {
}
Common::String label;
const char *text;
};
struct DialogVariable {
DialogVariable() : name(), value(0) {
}
DialogVariable(const Common::String &name_, byte value_) : name(name_), value(value_) {
}
Common::String name;
byte value;
};
const DialogVariable &find(const Common::String &name) const;
DialogVariable &find(const Common::String &name);
Common::Array<DialogVariable> _dialogsVariables;
void populateLabels();
const char *findLabel(const char *label, const char **realLabel = nullptr) const;
Common::String getLabelSound(const char *label) const;
const char *findSequence(const char *sequence) const;
Common::String findVideo(const char *data) const;
Common::String getText(const char *text) const;
Common::Array<Goto> executeAfterPlayAndBuildGotoList(const char *actions);
void buildGotoGoto(const char *gotoLine, Common::Array<Goto> &gotos);
bool buildGotoIf(const char *ifLine, Common::Array<Goto> &gotos);
void executeLet(const char *letLine);
void executeShow(const char *showLine);
const char *executePlayerQuestion(const char *text, bool dryRun, const char **realLabel = nullptr);
const char *parseIf(const char *ifLine);
const char *nextLine(const char *currentPtr) const;
const char *nextChar(const char *currentPtr) const;
const char *previousMatch(const char *currentPtr, const char *str) const;
char *_gtoBuffer;
const char *_gtoEnd;
Common::Array<const char *> _labels;
Common::String _endOfConversationText;
bool _ignoreNoEndOfConversation;
Common::HashMap<Common::String, SubtitlesSettings> _subtitlesSettings;
};
} // End of namespace CryOmni3D
#endif
|