aboutsummaryrefslogtreecommitdiff
path: root/src/object_properties.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/object_properties.cpp')
-rw-r--r--src/object_properties.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/object_properties.cpp b/src/object_properties.cpp
index f31773060..2eebc27d6 100644
--- a/src/object_properties.cpp
+++ b/src/object_properties.cpp
@@ -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) {}
}