1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-27 13:55:19 +01:00

Allow to scale nametag by distance and set font size (#16267)

This commit is contained in:
sfan5
2025-09-23 21:07:17 +02:00
committed by GitHub
parent ec790a3884
commit db8cd2121c
8 changed files with 154 additions and 81 deletions

View File

@@ -23,28 +23,17 @@ class WieldMeshSceneNode;
struct Nametag
{
scene::ISceneNode *parent_node;
scene::ISceneNode *parent_node = nullptr;
std::string text;
video::SColor textcolor;
std::optional<video::SColor> bgcolor;
v3f pos;
Nametag(scene::ISceneNode *a_parent_node,
const std::string &text,
const video::SColor &textcolor,
const std::optional<video::SColor> &bgcolor,
const v3f &pos):
parent_node(a_parent_node),
text(text),
textcolor(textcolor),
bgcolor(bgcolor),
pos(pos)
{
}
std::optional<u32> textsize;
v3f pos; // offset from parent node
bool scale_z;
video::SColor getBgColor(bool use_fallback) const
{
if (bgcolor)
if (bgcolor.has_value())
return bgcolor.value();
else if (!use_fallback)
return video::SColor(0, 0, 0, 0);
@@ -189,9 +178,7 @@ public:
return m_camera_mode;
}
Nametag *addNametag(scene::ISceneNode *parent_node,
const std::string &text, video::SColor textcolor,
std::optional<video::SColor> bgcolor, const v3f &pos);
Nametag *addNametag(const Nametag &params);
void removeNametag(Nametag *nametag);