3 Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
4 Copyright (C) 2017 red-001 <red-001@outlook.ie>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "irr_aabb3d.h"
38 video::SColor crosshair_argb;
39 video::SColor selectionbox_argb;
41 bool use_crosshair_image = false;
42 bool use_object_crosshair_image = false;
43 std::string hotbar_image = "";
44 bool use_hotbar_image = false;
45 std::string hotbar_selected_image = "";
46 bool use_hotbar_selected_image = false;
48 bool pointing_at_object = false;
50 Hud(Client *client, LocalPlayer *player,
51 Inventory *inventory);
54 void toggleBlockBounds();
55 void disableBlockBounds();
56 void drawBlockBounds();
58 void drawHotbar(u16 playeritem);
61 void drawSelectionMesh();
62 void updateSelectionMesh(const v3s16 &camera_offset);
64 std::vector<aabb3f> *getSelectionBoxes() { return &m_selection_boxes; }
66 void setSelectionPos(const v3f &pos, const v3s16 &camera_offset);
68 v3f getSelectionPos() const { return m_selection_pos; }
70 void setSelectionMeshColor(const video::SColor &color)
72 m_selection_mesh_color = color;
75 void setSelectedFaceNormal(const v3f &face_normal)
77 m_selected_face_normal = face_normal;
80 bool hasElementOfType(HudElementType type);
82 void drawLuaElements(const v3s16 &camera_offset);
85 bool calculateScreenPos(const v3s16 &camera_offset, HudElement *e, v2s32 *pos);
86 void drawStatbar(v2s32 pos, u16 corner, u16 drawdir,
87 const std::string &texture, const std::string& bgtexture,
88 s32 count, s32 maxcount, v2s32 offset, v2s32 size = v2s32());
90 void drawItems(v2s32 upperleftpos, v2s32 screen_offset, s32 itemcount,
91 s32 inv_offset, InventoryList *mainlist, u16 selectitem,
94 void drawItem(const ItemStack &item, const core::rect<s32> &rect, bool selected);
96 void drawCompassTranslate(HudElement *e, video::ITexture *texture,
97 const core::rect<s32> &rect, int way);
99 void drawCompassRotate(HudElement *e, video::ITexture *texture,
100 const core::rect<s32> &rect, int way);
102 Client *client = nullptr;
103 video::IVideoDriver *driver = nullptr;
104 LocalPlayer *player = nullptr;
105 Inventory *inventory = nullptr;
106 ITextureSource *tsrc = nullptr;
108 float m_hud_scaling; // cached minetest setting
109 float m_scale_factor;
110 v3s16 m_camera_offset;
112 v2s32 m_displaycenter;
113 s32 m_hotbar_imagesize; // Takes hud_scaling into account, updated by resizeHotbar()
114 s32 m_padding; // Takes hud_scaling into account, updated by resizeHotbar()
115 video::SColor hbar_colors[4];
117 std::vector<aabb3f> m_selection_boxes;
118 std::vector<aabb3f> m_halo_boxes;
120 v3f m_selection_pos_with_offset;
122 scene::IMesh *m_selection_mesh = nullptr;
123 video::SColor m_selection_mesh_color;
124 v3f m_selected_face_normal;
126 video::SMaterial m_selection_material;
128 scene::SMeshBuffer m_rotation_mesh_buffer;
133 BLOCK_BOUNDS_CURRENT,
136 } m_block_bounds_mode = BLOCK_BOUNDS_OFF;
146 enum ItemRotationKind
152 IT_ROT_NONE, // Must be last, also serves as number
155 void drawItemStack(video::IVideoDriver *driver,
157 const ItemStack &item,
158 const core::rect<s32> &rect,
159 const core::rect<s32> *clip,
161 ItemRotationKind rotation_kind);
164 video::IVideoDriver *driver,
166 const ItemStack &item,
167 const core::rect<s32> &rect,
168 const core::rect<s32> *clip,
170 ItemRotationKind rotation_kind,
172 const v3s16 &rotation_speed);