]> git.localhorst.tv Git - l2e.git/blob - src/graphics/Font.h
a5d7b12d690019f0dfd070cd759cc1591521a94d
[l2e.git] / src / graphics / Font.h
1 /*
2  * Font.h
3  *
4  *  Created on: Aug 8, 2012
5  *      Author: holy
6  */
7
8 #ifndef GRAPHICS_FONT_H_
9 #define GRAPHICS_FONT_H_
10
11 #include "Sprite.h"
12 #include "../geometry/Vector.h"
13
14 #include <SDL.h>
15
16 namespace graphics {
17
18 class Font {
19
20 public:
21         static const int TYPE_ID = 404;
22
23 public:
24         explicit Font(const Sprite *sprite = 0, int colOffset = 0, int rowOffset = 0)
25         : sprite(sprite), colOffset(colOffset), rowOffset(rowOffset) {
26
27         }
28
29 public:
30         int CharWidth() const { return sprite->Width(); }
31         int CharHeight() const { return sprite->Height(); }
32         int StringWidth(const char *) const;
33         int StringHeight(const char *) const;
34
35         void DrawChar(char c, SDL_Surface *dest, const geometry::Vector<int> &position) const;
36         void DrawString(const char *s, SDL_Surface *dest, const geometry::Vector<int> &position, int maxWidth = 0) const;
37         void DrawStringRight(const char *s, SDL_Surface *dest, const geometry::Vector<int> &position, int maxWidth = 0) const;
38         void DrawDigit(int d, SDL_Surface *dest, const geometry::Vector<int> &position) const;
39         void DrawNumber(int n, SDL_Surface *dest, const geometry::Vector<int> &position, int digits = 0) const;
40         void DrawNumberRight(int n, SDL_Surface *dest, const geometry::Vector<int> &position, int digits = 0) const;
41
42 public:
43         void SetSprite(const Sprite *s) { sprite = s; }
44         void SetColOffset(int n) { colOffset = n; }
45         void SetRowOffset(int n) { rowOffset = n; }
46
47         static void CreateTypeDescription();
48         static void Construct(void *);
49
50 private:
51         const Sprite *sprite;
52         int colOffset;
53         int rowOffset;
54
55 };
56
57 }
58
59 #endif /* GRAPHICS_FONT_H_ */