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_FONTTEXT_H
23 #define SLUDGE_FONTTEXT_H
24 
25 #include "common/hashmap.h"
26 #include "common/ustr.h"
27 
28 #include "sludge/sprites.h"
29 
30 namespace Common {
31 class SeekableReadStream;
32 class WriteStream;
33 }
34 
35 namespace Sludge {
36 
37 struct SpriteBank;
38 class SpritePalette;
39 
40 class TextManager {
41 public:
42 	TextManager();
43 	virtual ~TextManager();
44 
45 	void init();
46 	void kill();
47 
48 	int stringWidth(const Common::String &theText);
49 	int stringLength(const Common::String &theText);
50 
51 	bool loadFont(int filenum, const Common::String &charOrder, int);
52 	void pasteString(const Common::String &theText, int, int, SpritePalette &);
53 	void pasteStringToBackdrop(const Common::String &theText, int xOff, int y);
54 	void burnStringToBackdrop(const Common::String &theText, int xOff, int y);
55 	bool isInFont(const Common::String &theText);
56 
57 	// setter & getter
setFontSpace(int fontSpace)58 	void setFontSpace(int fontSpace) { _fontSpace = fontSpace; }
getFontHeight()59 	int getFontHeight() const { return _fontHeight; }
setPasterColor(byte r,byte g,byte b)60 	void setPasterColor(byte r, byte g, byte b) { _pastePalette.setColor(r, g, b); }
61 
62 	// load & save
63 	void saveFont(Common::WriteStream *stream);
64 	void loadFont(int ssgVersion, Common::SeekableReadStream *stream);
65 
66 private:
67 	SpriteBank _theFont;
68 	int _fontHeight, _numFontColours, _loadedFontNum;
69 	Common::U32String _fontOrder;
70 	int16 _fontSpace;
71 	SpritePalette _pastePalette;
72 
73 	Common::HashMap<uint32, uint32> _fontTable;
74 
fontInTable(uint32 x)75 	inline uint32 fontInTable(uint32 x) { return _fontTable[x]; }
76 
77 };
78 
79 } // End of namespace Sludge
80 
81 #endif
82