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 
23 #ifndef KYRA_TEXT_H
24 #define KYRA_TEXT_H
25 
26 #include "common/scummsys.h"
27 
28 #include "kyra/graphics/screen.h"
29 
30 namespace Kyra {
31 class KyraEngine_v1;
32 
33 class TextDisplayer {
34 public:
35 	TextDisplayer(KyraEngine_v1 *vm, Screen *screen);
~TextDisplayer()36 	virtual ~TextDisplayer() {}
37 
maxSubstringLen()38 	int maxSubstringLen() const { return TALK_SUBSTRING_LEN; }
39 
40 	void setTalkCoords(uint16 y);
41 	int getCenterStringX(const Common::String &str, int x1, int x2);
42 	int getCharLength(const char *str, int len);
43 	int dropCRIntoString(char *str, int offs);
44 	virtual char *preprocessString(const char *str);
45 	int buildMessageSubstrings(const char *str);
46 	int getWidestLineWidth(int linesCount);
47 	virtual void calcWidestLineBounds(int &x1, int &x2, int w, int cx);
48 	virtual void restoreTalkTextMessageBkgd(int srcPage, int dstPage);
49 	void printTalkTextMessage(const char *text, int x, int y, uint8 color, int srcPage, int dstPage);
50 	virtual void printText(const Common::String &str, int x, int y, uint8 c0, uint8 c1, uint8 c2);
51 	void printCharacterText(const char *text, int8 charNum, int charX);
52 
53 	uint16 _talkMessageY;
54 	uint16 _talkMessageH;
printed()55 	bool printed() const { return _talkMessagePrinted; }
56 
57 protected:
58 	Screen *_screen;
59 	KyraEngine_v1 *_vm;
60 
61 	struct TalkCoords {
62 		uint16 y, x, w;
63 	};
64 
65 	// TODO: AMIGA and LoK specific, move to a better location
66 	void setTextColor(uint8 color);
67 
68 	enum {
69 		TALK_SUBSTRING_LEN = 80,
70 		TALK_SUBSTRING_NUM = 6
71 	};
72 
73 	char _talkBuffer[1040];
74 	char _talkSubstrings[TALK_SUBSTRING_LEN * TALK_SUBSTRING_NUM];
75 	TalkCoords _talkCoords;
76 	bool _talkMessagePrinted;
77 };
78 
79 } // End of namespace Kyra
80 
81 #endif
82