mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add nametag background setting and object property (#10937)
This commit is contained in:
parent
a8f6befd39
commit
f85e9ab925
17 changed files with 254 additions and 58 deletions
|
@ -24,6 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "util/basic_macros.h"
|
||||
#include <sstream>
|
||||
|
||||
static const video::SColor NULL_BGCOLOR{0, 1, 1, 1};
|
||||
|
||||
ObjectProperties::ObjectProperties()
|
||||
{
|
||||
textures.emplace_back("unknown_object.png");
|
||||
|
@ -62,6 +64,13 @@ std::string ObjectProperties::dump()
|
|||
os << ", nametag=" << nametag;
|
||||
os << ", nametag_color=" << "\"" << nametag_color.getAlpha() << "," << nametag_color.getRed()
|
||||
<< "," << nametag_color.getGreen() << "," << nametag_color.getBlue() << "\" ";
|
||||
|
||||
if (nametag_bgcolor)
|
||||
os << ", nametag_bgcolor=" << "\"" << nametag_color.getAlpha() << "," << nametag_color.getRed()
|
||||
<< "," << nametag_color.getGreen() << "," << nametag_color.getBlue() << "\" ";
|
||||
else
|
||||
os << ", nametag_bgcolor=null ";
|
||||
|
||||
os << ", selectionbox=" << PP(selectionbox.MinEdge) << "," << PP(selectionbox.MaxEdge);
|
||||
os << ", pointable=" << pointable;
|
||||
os << ", static_save=" << static_save;
|
||||
|
@ -121,6 +130,13 @@ void ObjectProperties::serialize(std::ostream &os) const
|
|||
writeU8(os, shaded);
|
||||
writeU8(os, show_on_minimap);
|
||||
|
||||
if (!nametag_bgcolor)
|
||||
writeARGB8(os, NULL_BGCOLOR);
|
||||
else if (nametag_bgcolor.value().getAlpha() == 0)
|
||||
writeARGB8(os, video::SColor(0, 0, 0, 0));
|
||||
else
|
||||
writeARGB8(os, nametag_bgcolor.value());
|
||||
|
||||
// Add stuff only at the bottom.
|
||||
// Never remove anything, because we don't want new versions of this
|
||||
}
|
||||
|
@ -182,5 +198,11 @@ void ObjectProperties::deSerialize(std::istream &is)
|
|||
if (is.eof())
|
||||
return;
|
||||
show_on_minimap = tmp;
|
||||
|
||||
auto bgcolor = readARGB8(is);
|
||||
if (bgcolor != NULL_BGCOLOR)
|
||||
nametag_bgcolor = bgcolor;
|
||||
else
|
||||
nametag_bgcolor = nullopt;
|
||||
} catch (SerializationError &e) {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue