| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
1 |
/* |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
2 |
=========================================================================== |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
3 |
blockattack - Block Attack - Rise of the Blocks |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
4 |
Copyright (C) 2005-2017 Poul Sander |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
5 |
|
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
6 |
This program is free software: you can redistribute it and/or modify |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
7 |
it under the terms of the GNU General Public License as published by |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
8 |
the Free Software Foundation, either version 2 of the License, or |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
9 |
(at your option) any later version. |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
10 |
|
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
11 |
This program is distributed in the hope that it will be useful, |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
14 |
GNU General Public License for more details. |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
15 |
|
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
16 |
You should have received a copy of the GNU General Public License |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
17 |
along with this program. If not, see http://www.gnu.org/licenses/ |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
18 |
|
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
19 |
Source information and contacts persons can be found at |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
20 |
http://www.blockattack.net |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
21 |
=========================================================================== |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
22 |
*/ |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
23 |
|
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
24 |
|
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
25 |
#ifndef FONTWRAPPER_HPP |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
26 |
#define FONTWRAPPER_HPP |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
27 |
|
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
28 |
#include "Libs/NFont.h" |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
29 |
#include "sago/SagoDataHolder.hpp" |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
30 |
|
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
31 |
class FontWrapper { |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
32 |
NFont theFont; |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
33 |
|
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
34 |
public: |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
35 |
void draw(SDL_Renderer* target, int x, int y, const std::string& text) { |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
36 |
theFont.draw(target, x, y, "%s", text.c_str()); |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
37 |
} |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
38 |
|
| 04918657 |
sago007 |
2017-11-27 14:06 |
39 |
void drawCenter(SDL_Renderer* target, int x, int y, const std::string& text) { |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
40 |
theFont.draw(target, x, y, NFont::CENTER, "%s", text.c_str()); |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
41 |
} |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
42 |
|
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
43 |
void drawCenterAlsoHeight(SDL_Renderer* target, int x, int y, const std::string& text) { |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
44 |
theFont.draw(target, x, y-theFont.getHeight()/2, NFont::CENTER, "%s", text.c_str()); |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
45 |
} |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
46 |
|
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
47 |
void drawRight(SDL_Renderer* target, int x, int y, const std::string& text) { |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
48 |
theFont.draw(target, x, y, NFont::RIGHT, "%s", text.c_str()); |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
49 |
} |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
50 |
|
| e1b2e653 |
sago007 |
2017-11-28 18:10 |
51 |
NFont::Rectf drawBox(SDL_Renderer* dest, const NFont::Rectf& box, const std::string& formatted_text) { |
| e1b2e653 |
sago007 |
2017-11-28 18:10 |
52 |
return theFont.drawBox(dest, box, "%s", formatted_text.c_str()); |
| e1b2e653 |
sago007 |
2017-11-28 18:10 |
53 |
} |
| e1b2e653 |
sago007 |
2017-11-28 18:10 |
54 |
|
| e1b2e653 |
sago007 |
2017-11-28 18:10 |
55 |
size_t getWidth(const std::string& text) { |
| e1b2e653 |
sago007 |
2017-11-28 18:10 |
56 |
return theFont.getWidth("%s", text.c_str()); |
| e1b2e653 |
sago007 |
2017-11-28 18:10 |
57 |
} |
| e1b2e653 |
sago007 |
2017-11-28 18:10 |
58 |
|
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
59 |
bool load(SDL_Renderer* target, TTF_Font* font, const NFont::Color& color) { |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
60 |
return theFont.load(target, font, color); |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
61 |
} |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
62 |
}; |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
63 |
|
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
64 |
#endif /* FONTWRAPPER_HPP */ |
| 4c5ca03b |
sago007 |
2017-11-27 13:55 |
65 |
|
|
|
1970-01-01 00:00 |
66 |
|