Add dutch translation
[oweals/minetest.git] / src / hud.h
1 /*
2 Minetest
3 Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef HUD_HEADER
21 #define HUD_HEADER
22
23 #include "irrlichttypes_extrabloated.h"
24
25 #define HUD_DIR_LEFT_RIGHT 0
26 #define HUD_DIR_RIGHT_LEFT 1
27 #define HUD_DIR_TOP_BOTTOM 2
28 #define HUD_DIR_BOTTOM_TOP 3
29
30 class Player;
31
32 enum HudElementType {
33         HUD_ELEM_IMAGE     = 0,
34         HUD_ELEM_TEXT      = 1,
35         HUD_ELEM_STATBAR   = 2,
36         HUD_ELEM_INVENTORY = 3
37 };
38
39 enum HudElementStat {
40         HUD_STAT_POS,
41         HUD_STAT_NAME,
42         HUD_STAT_SCALE,
43         HUD_STAT_TEXT,
44         HUD_STAT_NUMBER,
45         HUD_STAT_ITEM,
46         HUD_STAT_DIR
47 };
48
49 struct HudElement {
50         HudElementType type;
51         v2f pos;
52         std::string name;
53         v2f scale;
54         std::string text;
55         u32 number;
56         u32 item;
57         u32 dir;
58 };
59
60
61 inline u32 hud_get_free_id(Player *player) {
62         size_t size = player->hud.size();
63         for (size_t i = 0; i != size; i++) {
64                 if (!player->hud[i])
65                         return i;
66         }
67         return size;
68 }
69
70 #ifndef SERVER
71
72 #include <deque>
73
74 #include <IGUIFont.h>
75
76 #include "gamedef.h"
77 #include "inventory.h"
78 #include "localplayer.h"
79
80 class Hud {
81 public:
82         video::IVideoDriver *driver;
83         gui::IGUIEnvironment *guienv;
84         gui::IGUIFont *font;
85         u32 text_height;
86         IGameDef *gamedef;
87         LocalPlayer *player;
88         Inventory *inventory;
89         
90         v2u32 screensize;
91         v2s32 displaycenter;
92         s32 hotbar_imagesize;
93         s32 hotbar_itemcount;
94         
95         video::SColor crosshair_argb;
96         video::SColor selectionbox_argb;
97         
98         Hud(video::IVideoDriver *driver, gui::IGUIEnvironment* guienv,
99                 gui::IGUIFont *font, u32 text_height, IGameDef *gamedef,
100                 LocalPlayer *player, Inventory *inventory);
101         
102         void drawItem(v2s32 upperleftpos, s32 imgsize, s32 itemcount,
103                 InventoryList *mainlist, u16 selectitem, u16 direction);
104         void drawLuaElements();
105         void drawStatbar(v2s32 upperleftpos, std::string texture, s32 count);
106         
107         void drawHotbar(v2s32 centerlowerpos, s32 halfheartcount, u16 playeritem);
108         void resizeHotbar();
109         
110         void drawCrosshair();
111         void drawSelectionBoxes(std::vector<aabb3f> &hilightboxes);
112 };
113
114 #endif
115
116 #endif