1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 #ifndef SLUDGE_TALK_H
23 #define SLUDGE_TALK_H
24 
25 #include "sludge/sprites.h"
26 
27 namespace Sludge {
28 
29 struct ObjectType;
30 
31 struct SpeechLine {
32 	Common::String textLine;
33 	int x;
34 };
35 
36 typedef Common::List<SpeechLine *> SpeechLineList;
37 
38 struct SpeechStruct {
39 	OnScreenPerson *currentTalker;
40 	SpeechLineList allSpeech;
41 	int speechY, lastFile, lookWhosTalking;
42 	SpritePalette talkCol;
43 };
44 
45 class SpeechManager {
46 public:
SpeechManager(SludgeEngine * vm)47 	SpeechManager(SludgeEngine *vm) : _vm(vm) { init(); }
~SpeechManager()48 	~SpeechManager() { kill(); }
49 
50 	void init();
51 	void kill();
52 
53 	int wrapSpeech(const Common::String &theText, int objT, int sampleFile, bool);
54 	void display();
55 
56 	int isThereAnySpeechGoingOn();
isCurrentTalker(OnScreenPerson * person)57 	bool isCurrentTalker(OnScreenPerson *person) { return person == _speech->currentTalker; }
58 	int getLastSpeechSound();
59 
60 	// setters & getters
61 	void setObjFontColour(ObjectType *t);
setSpeechSpeed(float speed)62 	void setSpeechSpeed(float speed) { _speechSpeed = speed; }
getSpeechSpeed()63 	float getSpeechSpeed() { return _speechSpeed; }
setSpeechMode(int speechMode)64 	void setSpeechMode(int speechMode) { _speechMode = speechMode; }
65 
66 	// load & save
67 	void save(Common::WriteStream *stream);
68 	bool load(Common::SeekableReadStream *stream);
69 
70 	// freeze & restore
71 	void freeze(FrozenStuffStruct *frozenStuff);
72 	void restore(FrozenStuffStruct *frozenStuff);
73 
74 private:
75 	SludgeEngine *_vm;
76 	int _speechMode;
77 	SpeechStruct *_speech;
78 	float _speechSpeed;
79 
80 	void addSpeechLine(const Common::String &theLine, int x, int &offset);
81 	int wrapSpeechXY(const Common::String &theText, int x, int y, int wrap, int sampleFile);
82 	int wrapSpeechPerson(const Common::String &theText, OnScreenPerson &thePerson, int sampleFile, bool animPerson);
83 };
84 
85 } // End of namespace Sludge
86 
87 #endif
88