Luanti 5.16.0-dev
Loading...
Searching...
No Matches
Hud Class Reference

#include <hud.h>

Collaboration diagram for Hud:

Public Types

enum  BlockBoundsMode { BLOCK_BOUNDS_OFF , BLOCK_BOUNDS_CURRENT , BLOCK_BOUNDS_NEAR }

Public Member Functions

 Hud (Client *client, LocalPlayer *player, Inventory *inventory)
void readScalingSetting ()
 ~Hud ()
enum BlockBoundsMode toggleBlockBounds ()
void disableBlockBounds ()
void drawBlockBounds ()
void drawHotbar (const v2s32 &pos, const v2f &offset, u16 direction, const v2f &align)
void resizeHotbar ()
void drawCrosshair ()
void drawSelectionMesh ()
void updateSelectionMesh (const v3s16 &camera_offset)
std::vector< aabb3f > * getSelectionBoxes ()
void setSelectionPos (const v3f &pos, const v3s16 &camera_offset)
v3f getSelectionPos () const
void setSelectionRotationRadians (v3f rotation)
v3f getSelectionRotationRadians () const
void setSelectionMeshColor (const video::SColor &color)
void setSelectedFaceNormal (const v3f &face_normal)
bool hasElementOfType (HudElementType type)
void drawLuaElements (const v3s16 &camera_offset)

Public Attributes

enum Hud::BlockBoundsMode m_block_bounds_mode = BLOCK_BOUNDS_OFF
video::SColor crosshair_argb
video::SColor selectionbox_argb
bool use_crosshair_image = false
bool use_object_crosshair_image = false
std::string hotbar_image = ""
bool use_hotbar_image = false
std::string hotbar_selected_image = ""
bool use_hotbar_selected_image = false
bool pointing_at_object = false

Private Types

enum  { HIGHLIGHT_BOX , HIGHLIGHT_HALO , HIGHLIGHT_NONE }

Private Member Functions

bool calculateScreenPos (const v3s16 &camera_offset, HudElement *e, v2s32 *pos)
void drawStatbar (v2s32 pos, u16 corner, u16 drawdir, const std::string &texture, const std::string &bgtexture, s32 count, s32 maxcount, v2s32 offset, v2s32 size=v2s32())
void drawItems (v2s32 screen_pos, v2s32 screen_offset, s32 itemcount, v2f alignment, s32 inv_offset, InventoryList *mainlist, u16 selectitem, u16 direction, bool is_hotbar)
void drawItem (const ItemStack &item, const core::rect< s32 > &rect, bool selected)
void drawCompassTranslate (HudElement *e, video::ITexture *texture, const core::rect< s32 > &rect, int way)
void drawCompassRotate (HudElement *e, video::ITexture *texture, const core::rect< s32 > &rect, int way)

Private Attributes

Clientclient = nullptr
video::IVideoDriver * driver = nullptr
LocalPlayerplayer = nullptr
Inventoryinventory = nullptr
ITextureSourcetsrc = nullptr
float m_hud_scaling
float m_scale_factor
v3s16 m_camera_offset
v2u32 m_screensize
v2s32 m_displaycenter
s32 m_hotbar_imagesize
s32 m_padding
video::SColor hbar_colors [4]
std::vector< aabb3fm_selection_boxes
std::vector< aabb3fm_halo_boxes
v3f m_selection_pos
v3f m_selection_pos_with_offset
v3f m_selection_rotation_radians
scene::IMesh * m_selection_mesh = nullptr
video::SColor m_selection_mesh_color
v3f m_selected_face_normal
video::SMaterial m_selection_material
video::SMaterial m_block_bounds_material
irr_ptr< scene::SMeshBuffer > m_rotation_mesh_buffer
enum Hud:: { ... }  m_mode

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
HIGHLIGHT_BOX 
HIGHLIGHT_HALO 
HIGHLIGHT_NONE 

◆ BlockBoundsMode

Enumerator
BLOCK_BOUNDS_OFF 
BLOCK_BOUNDS_CURRENT 
BLOCK_BOUNDS_NEAR 

Constructor & Destructor Documentation

◆ Hud()

◆ ~Hud()

Hud::~Hud ( )

References g_settings, and m_selection_mesh.

Member Function Documentation

◆ calculateScreenPos()

bool Hud::calculateScreenPos ( const v3s16 & camera_offset,
HudElement * e,
v2s32 * pos )
private

References BS, intToFloat(), m_screensize, and HudElement::world_pos.

Referenced by drawLuaElements().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disableBlockBounds()

void Hud::disableBlockBounds ( )

◆ drawBlockBounds()

void Hud::drawBlockBounds ( )

References BLOCK_BOUNDS_NEAR, BLOCK_BOUNDS_OFF, BS, driver, g_settings, getContainerPos(), intToFloat(), m_block_bounds_material, m_block_bounds_mode, MAP_BLOCKSIZE, player, rangelim(), x, and y.

Referenced by Draw3D::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawCompassRotate()

void Hud::drawCompassRotate ( HudElement * e,
video::ITexture * texture,
const core::rect< s32 > & rect,
int way )
private

References driver, and m_rotation_mesh_buffer.

Referenced by drawLuaElements().

Here is the caller graph for this function:

◆ drawCompassTranslate()

void Hud::drawCompassTranslate ( HudElement * e,
video::ITexture * texture,
const core::rect< s32 > & rect,
int way )
private

References draw2DImageFilterScaled(), driver, and HudElement::scale.

Referenced by drawLuaElements().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawCrosshair()

void Hud::drawCrosshair ( )

References crosshair_argb, CROSSHAIR_LINE_SIZE, draw2DImageFilterScaled(), driver, m_displaycenter, m_scale_factor, OBJECT_CROSSHAIR_LINE_SIZE, pointing_at_object, tsrc, use_crosshair_image, and use_object_crosshair_image.

Referenced by DrawHUD::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawHotbar()

void Hud::drawHotbar ( const v2s32 & pos,
const v2f & offset,
u16 direction,
const v2f & align )

References dir(), drawItems(), g_settings, g_touchcontrols, RenderingEngine::getWindowSize(), inventory, m_hotbar_imagesize, m_padding, and player.

Referenced by drawLuaElements().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawItem()

void Hud::drawItem ( const ItemStack & item,
const core::rect< s32 > & rect,
bool selected )
private

References draw2DImageFilterScaled(), drawItemStack(), driver, g_fontengine, hbar_colors, hotbar_selected_image, IT_ROT_NONE, IT_ROT_SELECTED, m_padding, tsrc, use_hotbar_image, and use_hotbar_selected_image.

Referenced by drawItems().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawItems()

void Hud::drawItems ( v2s32 screen_pos,
v2s32 screen_offset,
s32 itemcount,
v2f alignment,
s32 inv_offset,
InventoryList * mainlist,
u16 selectitem,
u16 direction,
bool is_hotbar )
private

References draw2DImageFilterScaled(), drawItem(), driver, g_touchcontrols, InventoryList::getItem(), InventoryList::getSize(), hbar_colors, hotbar_image, hotbar_selected_image, HUD_DIR_BOTTOM_TOP, HUD_DIR_RIGHT_LEFT, HUD_DIR_TOP_BOTTOM, m_hotbar_imagesize, m_padding, m_scale_factor, player, tsrc, use_hotbar_image, and use_hotbar_selected_image.

Referenced by drawHotbar(), and drawLuaElements().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawLuaElements()

◆ drawSelectionMesh()

void Hud::drawSelectionMesh ( )

References driver, HIGHLIGHT_BOX, HIGHLIGHT_HALO, HIGHLIGHT_NONE, m_mode, m_selected_face_normal, m_selection_boxes, m_selection_material, m_selection_mesh, m_selection_mesh_color, m_selection_pos_with_offset, m_selection_rotation_radians, MYMIN, selectionbox_argb, setMeshColor(), and setMeshColorByNormal().

Referenced by Draw3D::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawStatbar()

void Hud::drawStatbar ( v2s32 pos,
u16 corner,
u16 drawdir,
const std::string & texture,
const std::string & bgtexture,
s32 count,
s32 maxcount,
v2s32 offset,
v2s32 size = v2s32() )
private

References draw2DImageFilterScaled(), driver, HUD_CORNER_LOWER, HUD_DIR_BOTTOM_TOP, HUD_DIR_RIGHT_LEFT, HUD_DIR_TOP_BOTTOM, m_scale_factor, p(), and tsrc.

Referenced by drawLuaElements().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSelectionBoxes()

std::vector< aabb3f > * Hud::getSelectionBoxes ( )
inline

References m_selection_boxes.

◆ getSelectionPos()

v3f Hud::getSelectionPos ( ) const
inline

References m_selection_pos.

◆ getSelectionRotationRadians()

v3f Hud::getSelectionRotationRadians ( ) const
inline

◆ hasElementOfType()

bool Hud::hasElementOfType ( HudElementType type)

References player.

◆ readScalingSetting()

void Hud::readScalingSetting ( )

References g_settings, RenderingEngine::getDisplayDensity(), HOTBAR_IMAGE_SIZE, m_hotbar_imagesize, m_hud_scaling, m_padding, and m_scale_factor.

Referenced by Hud().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resizeHotbar()

void Hud::resizeHotbar ( )

References RenderingEngine::getDisplayDensity(), RenderingEngine::getWindowSize(), HOTBAR_IMAGE_SIZE, m_displaycenter, m_hotbar_imagesize, m_hud_scaling, m_padding, and m_screensize.

Referenced by DrawHUD::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSelectedFaceNormal()

void Hud::setSelectedFaceNormal ( const v3f & face_normal)
inline

◆ setSelectionMeshColor()

void Hud::setSelectionMeshColor ( const video::SColor & color)
inline

◆ setSelectionPos()

void Hud::setSelectionPos ( const v3f & pos,
const v3s16 & camera_offset )

References BS, intToFloat(), m_camera_offset, m_selection_pos, and m_selection_pos_with_offset.

Here is the call graph for this function:

◆ setSelectionRotationRadians()

void Hud::setSelectionRotationRadians ( v3f rotation)
inline

◆ toggleBlockBounds()

enum Hud::BlockBoundsMode Hud::toggleBlockBounds ( )

◆ updateSelectionMesh()

void Hud::updateSelectionMesh ( const v3s16 & camera_offset)

References convertNodeboxesToMesh(), HIGHLIGHT_HALO, m_camera_offset, m_halo_boxes, m_mode, m_selection_boxes, and m_selection_mesh.

Here is the call graph for this function:

Member Data Documentation

◆ client

Client* Hud::client = nullptr
private

◆ crosshair_argb

video::SColor Hud::crosshair_argb

Referenced by Hud(), and drawCrosshair().

◆ driver

◆ hbar_colors

video::SColor Hud::hbar_colors[4]
private

Referenced by Hud(), drawItem(), and drawItems().

◆ hotbar_image

std::string Hud::hotbar_image = ""

Referenced by drawItems().

◆ hotbar_selected_image

std::string Hud::hotbar_selected_image = ""

Referenced by drawItem(), and drawItems().

◆ inventory

Inventory* Hud::inventory = nullptr
private

Referenced by Hud(), drawHotbar(), and drawLuaElements().

◆ m_block_bounds_material

video::SMaterial Hud::m_block_bounds_material
private

Referenced by Hud(), and drawBlockBounds().

◆ m_block_bounds_mode

◆ m_camera_offset

v3s16 Hud::m_camera_offset
private

◆ m_displaycenter

v2s32 Hud::m_displaycenter
private

Referenced by drawCrosshair(), and resizeHotbar().

◆ m_halo_boxes

std::vector<aabb3f> Hud::m_halo_boxes
private

Referenced by Hud(), and updateSelectionMesh().

◆ m_hotbar_imagesize

s32 Hud::m_hotbar_imagesize
private

◆ m_hud_scaling

float Hud::m_hud_scaling
private

◆ []

enum { ... } Hud::m_mode

◆ m_padding

s32 Hud::m_padding
private

◆ m_rotation_mesh_buffer

irr_ptr<scene::SMeshBuffer> Hud::m_rotation_mesh_buffer
private

Referenced by Hud(), and drawCompassRotate().

◆ m_scale_factor

float Hud::m_scale_factor
private

◆ m_screensize

v2u32 Hud::m_screensize
private

◆ m_selected_face_normal

v3f Hud::m_selected_face_normal
private

◆ m_selection_boxes

std::vector<aabb3f> Hud::m_selection_boxes
private

◆ m_selection_material

video::SMaterial Hud::m_selection_material
private

Referenced by Hud(), and drawSelectionMesh().

◆ m_selection_mesh

scene::IMesh* Hud::m_selection_mesh = nullptr
private

◆ m_selection_mesh_color

video::SColor Hud::m_selection_mesh_color
private

◆ m_selection_pos

v3f Hud::m_selection_pos
private

Referenced by getSelectionPos(), and setSelectionPos().

◆ m_selection_pos_with_offset

v3f Hud::m_selection_pos_with_offset
private

◆ m_selection_rotation_radians

v3f Hud::m_selection_rotation_radians
private

◆ player

LocalPlayer* Hud::player = nullptr
private

◆ pointing_at_object

bool Hud::pointing_at_object = false

Referenced by drawCrosshair().

◆ selectionbox_argb

video::SColor Hud::selectionbox_argb

Referenced by Hud(), and drawSelectionMesh().

◆ tsrc

ITextureSource* Hud::tsrc = nullptr
private

◆ use_crosshair_image

bool Hud::use_crosshair_image = false

Referenced by Hud(), and drawCrosshair().

◆ use_hotbar_image

bool Hud::use_hotbar_image = false

Referenced by drawItem(), and drawItems().

◆ use_hotbar_selected_image

bool Hud::use_hotbar_selected_image = false

Referenced by drawItem(), and drawItems().

◆ use_object_crosshair_image

bool Hud::use_object_crosshair_image = false

Referenced by Hud(), and drawCrosshair().


The documentation for this class was generated from the following files: