forked from Mirrorlandia_minetest/minetest
Decouple entity minimap markers from nametags replacing with show_on_minimap property (#10443)
This commit is contained in:
parent
b826e39730
commit
660115c1ab
@ -6880,6 +6880,10 @@ Player properties need to be saved manually.
|
|||||||
|
|
||||||
shaded = true,
|
shaded = true,
|
||||||
-- Setting this to 'false' disables diffuse lighting of entity
|
-- Setting this to 'false' disables diffuse lighting of entity
|
||||||
|
|
||||||
|
show_on_minimap = false,
|
||||||
|
-- Defaults to true for players, false for other entities.
|
||||||
|
-- If set to true the entity will show as a marker on the minimap.
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity definition
|
Entity definition
|
||||||
|
@ -169,8 +169,6 @@ public:
|
|||||||
|
|
||||||
void removeNametag(Nametag *nametag);
|
void removeNametag(Nametag *nametag);
|
||||||
|
|
||||||
const std::list<Nametag *> &getNametags() { return m_nametags; }
|
|
||||||
|
|
||||||
void drawNametags();
|
void drawNametags();
|
||||||
|
|
||||||
inline void addArmInertia(f32 player_yaw);
|
inline void addArmInertia(f32 player_yaw);
|
||||||
|
@ -326,6 +326,8 @@ Client::~Client()
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete m_minimap;
|
delete m_minimap;
|
||||||
|
m_minimap = nullptr;
|
||||||
|
|
||||||
delete m_media_downloader;
|
delete m_media_downloader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "client/shader.h"
|
#include "client/shader.h"
|
||||||
|
#include "client/minimap.h"
|
||||||
|
|
||||||
class Settings;
|
class Settings;
|
||||||
struct ToolCapabilities;
|
struct ToolCapabilities;
|
||||||
@ -566,6 +567,9 @@ void GenericCAO::removeFromScene(bool permanent)
|
|||||||
m_client->getCamera()->removeNametag(m_nametag);
|
m_client->getCamera()->removeNametag(m_nametag);
|
||||||
m_nametag = nullptr;
|
m_nametag = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_marker && m_client->getMinimap())
|
||||||
|
m_client->getMinimap()->removeMarker(&m_marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericCAO::addToScene(ITextureSource *tsrc)
|
void GenericCAO::addToScene(ITextureSource *tsrc)
|
||||||
@ -794,6 +798,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
|
|||||||
node->setParent(m_matrixnode);
|
node->setParent(m_matrixnode);
|
||||||
|
|
||||||
updateNametag();
|
updateNametag();
|
||||||
|
updateMarker();
|
||||||
updateNodePos();
|
updateNodePos();
|
||||||
updateAnimation();
|
updateAnimation();
|
||||||
updateBonePosition();
|
updateBonePosition();
|
||||||
@ -885,6 +890,23 @@ u16 GenericCAO::getLightPosition(v3s16 *pos)
|
|||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GenericCAO::updateMarker()
|
||||||
|
{
|
||||||
|
if (!m_prop.show_on_minimap) {
|
||||||
|
if (m_marker)
|
||||||
|
m_client->getMinimap()->removeMarker(&m_marker);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_marker)
|
||||||
|
return;
|
||||||
|
|
||||||
|
scene::ISceneNode *node = getSceneNode();
|
||||||
|
if (!node)
|
||||||
|
return;
|
||||||
|
m_marker = m_client->getMinimap()->addMarker(node);
|
||||||
|
}
|
||||||
|
|
||||||
void GenericCAO::updateNametag()
|
void GenericCAO::updateNametag()
|
||||||
{
|
{
|
||||||
if (m_is_local_player) // No nametag for local player
|
if (m_is_local_player) // No nametag for local player
|
||||||
@ -1576,6 +1598,8 @@ void GenericCAO::processMessage(const std::string &data)
|
|||||||
u8 cmd = readU8(is);
|
u8 cmd = readU8(is);
|
||||||
if (cmd == AO_CMD_SET_PROPERTIES) {
|
if (cmd == AO_CMD_SET_PROPERTIES) {
|
||||||
ObjectProperties newprops;
|
ObjectProperties newprops;
|
||||||
|
newprops.show_on_minimap = m_is_player; // default
|
||||||
|
|
||||||
newprops.deSerialize(is);
|
newprops.deSerialize(is);
|
||||||
|
|
||||||
// Check what exactly changed
|
// Check what exactly changed
|
||||||
@ -1609,6 +1633,8 @@ void GenericCAO::processMessage(const std::string &data)
|
|||||||
|
|
||||||
if ((m_is_player && !m_is_local_player) && m_prop.nametag.empty())
|
if ((m_is_player && !m_is_local_player) && m_prop.nametag.empty())
|
||||||
m_prop.nametag = m_name;
|
m_prop.nametag = m_name;
|
||||||
|
if (m_is_local_player)
|
||||||
|
m_prop.show_on_minimap = false;
|
||||||
|
|
||||||
if (expire_visuals) {
|
if (expire_visuals) {
|
||||||
expireVisuals();
|
expireVisuals();
|
||||||
@ -1621,6 +1647,7 @@ void GenericCAO::processMessage(const std::string &data)
|
|||||||
updateTextures(m_current_texture_modifier);
|
updateTextures(m_current_texture_modifier);
|
||||||
}
|
}
|
||||||
updateNametag();
|
updateNametag();
|
||||||
|
updateMarker();
|
||||||
}
|
}
|
||||||
} else if (cmd == AO_CMD_UPDATE_POSITION) {
|
} else if (cmd == AO_CMD_UPDATE_POSITION) {
|
||||||
// Not sent by the server if this object is an attachment.
|
// Not sent by the server if this object is an attachment.
|
||||||
|
@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
class Camera;
|
class Camera;
|
||||||
class Client;
|
class Client;
|
||||||
struct Nametag;
|
struct Nametag;
|
||||||
|
struct MinimapMarker;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SmoothTranslator
|
SmoothTranslator
|
||||||
@ -84,6 +85,7 @@ private:
|
|||||||
scene::IBillboardSceneNode *m_spritenode = nullptr;
|
scene::IBillboardSceneNode *m_spritenode = nullptr;
|
||||||
scene::IDummyTransformationSceneNode *m_matrixnode = nullptr;
|
scene::IDummyTransformationSceneNode *m_matrixnode = nullptr;
|
||||||
Nametag *m_nametag = nullptr;
|
Nametag *m_nametag = nullptr;
|
||||||
|
MinimapMarker *m_marker = nullptr;
|
||||||
v3f m_position = v3f(0.0f, 10.0f * BS, 0);
|
v3f m_position = v3f(0.0f, 10.0f * BS, 0);
|
||||||
v3f m_velocity;
|
v3f m_velocity;
|
||||||
v3f m_acceleration;
|
v3f m_acceleration;
|
||||||
@ -254,6 +256,8 @@ public:
|
|||||||
|
|
||||||
void updateNametag();
|
void updateNametag();
|
||||||
|
|
||||||
|
void updateMarker();
|
||||||
|
|
||||||
void updateNodePos();
|
void updateNodePos();
|
||||||
|
|
||||||
void step(float dtime, ClientEnvironment *env);
|
void step(float dtime, ClientEnvironment *env);
|
||||||
|
@ -252,6 +252,10 @@ Minimap::~Minimap()
|
|||||||
driver->removeTexture(data->minimap_overlay_square);
|
driver->removeTexture(data->minimap_overlay_square);
|
||||||
driver->removeTexture(data->object_marker_red);
|
driver->removeTexture(data->object_marker_red);
|
||||||
|
|
||||||
|
for (MinimapMarker *m : m_markers)
|
||||||
|
delete m;
|
||||||
|
m_markers.clear();
|
||||||
|
|
||||||
delete data;
|
delete data;
|
||||||
delete m_minimap_update_thread;
|
delete m_minimap_update_thread;
|
||||||
}
|
}
|
||||||
@ -678,21 +682,34 @@ void Minimap::drawMinimap(core::rect<s32> rect) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MinimapMarker* Minimap::addMarker(scene::ISceneNode *parent_node)
|
||||||
|
{
|
||||||
|
MinimapMarker *m = new MinimapMarker(parent_node);
|
||||||
|
m_markers.push_back(m);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Minimap::removeMarker(MinimapMarker **m)
|
||||||
|
{
|
||||||
|
m_markers.remove(*m);
|
||||||
|
delete *m;
|
||||||
|
*m = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void Minimap::updateActiveMarkers()
|
void Minimap::updateActiveMarkers()
|
||||||
{
|
{
|
||||||
video::IImage *minimap_mask = data->minimap_shape_round ?
|
video::IImage *minimap_mask = data->minimap_shape_round ?
|
||||||
data->minimap_mask_round : data->minimap_mask_square;
|
data->minimap_mask_round : data->minimap_mask_square;
|
||||||
|
|
||||||
const std::list<Nametag *> &nametags = client->getCamera()->getNametags();
|
|
||||||
|
|
||||||
m_active_markers.clear();
|
m_active_markers.clear();
|
||||||
|
v3f cam_offset = intToFloat(client->getCamera()->getOffset(), BS);
|
||||||
for (Nametag *nametag : nametags) {
|
v3s16 pos_offset = data->pos - v3s16(data->mode.map_size / 2,
|
||||||
v3s16 pos = floatToInt(nametag->parent_node->getAbsolutePosition() +
|
|
||||||
intToFloat(client->getCamera()->getOffset(), BS), BS);
|
|
||||||
pos -= data->pos - v3s16(data->mode.map_size / 2,
|
|
||||||
data->mode.scan_height / 2,
|
data->mode.scan_height / 2,
|
||||||
data->mode.map_size / 2);
|
data->mode.map_size / 2);
|
||||||
|
|
||||||
|
for (MinimapMarker *marker : m_markers) {
|
||||||
|
v3s16 pos = floatToInt(marker->parent_node->getAbsolutePosition() +
|
||||||
|
cam_offset, BS) - pos_offset;
|
||||||
if (pos.X < 0 || pos.X > data->mode.map_size ||
|
if (pos.X < 0 || pos.X > data->mode.map_size ||
|
||||||
pos.Y < 0 || pos.Y > data->mode.scan_height ||
|
pos.Y < 0 || pos.Y > data->mode.scan_height ||
|
||||||
pos.Z < 0 || pos.Z > data->mode.map_size) {
|
pos.Z < 0 || pos.Z > data->mode.map_size) {
|
||||||
|
@ -48,6 +48,13 @@ struct MinimapModeDef {
|
|||||||
u16 scale;
|
u16 scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MinimapMarker {
|
||||||
|
MinimapMarker(scene::ISceneNode *parent_node):
|
||||||
|
parent_node(parent_node)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
scene::ISceneNode *parent_node;
|
||||||
|
};
|
||||||
struct MinimapPixel {
|
struct MinimapPixel {
|
||||||
//! The topmost node that the minimap displays.
|
//! The topmost node that the minimap displays.
|
||||||
MapNode n;
|
MapNode n;
|
||||||
@ -142,6 +149,9 @@ public:
|
|||||||
|
|
||||||
scene::SMeshBuffer *getMinimapMeshBuffer();
|
scene::SMeshBuffer *getMinimapMeshBuffer();
|
||||||
|
|
||||||
|
MinimapMarker* addMarker(scene::ISceneNode *parent_node);
|
||||||
|
void removeMarker(MinimapMarker **marker);
|
||||||
|
|
||||||
void updateActiveMarkers();
|
void updateActiveMarkers();
|
||||||
void drawMinimap();
|
void drawMinimap();
|
||||||
void drawMinimap(core::rect<s32> rect);
|
void drawMinimap(core::rect<s32> rect);
|
||||||
@ -162,5 +172,6 @@ private:
|
|||||||
u16 m_surface_mode_scan_height;
|
u16 m_surface_mode_scan_height;
|
||||||
f32 m_angle;
|
f32 m_angle;
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
|
std::list<MinimapMarker*> m_markers;
|
||||||
std::list<v2f> m_active_markers;
|
std::list<v2f> m_active_markers;
|
||||||
};
|
};
|
||||||
|
@ -70,6 +70,7 @@ std::string ObjectProperties::dump()
|
|||||||
os << ", use_texture_alpha=" << use_texture_alpha;
|
os << ", use_texture_alpha=" << use_texture_alpha;
|
||||||
os << ", damage_texture_modifier=" << damage_texture_modifier;
|
os << ", damage_texture_modifier=" << damage_texture_modifier;
|
||||||
os << ", shaded=" << shaded;
|
os << ", shaded=" << shaded;
|
||||||
|
os << ", show_on_minimap=" << show_on_minimap;
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,6 +119,7 @@ void ObjectProperties::serialize(std::ostream &os) const
|
|||||||
writeU8(os, use_texture_alpha);
|
writeU8(os, use_texture_alpha);
|
||||||
os << serializeString16(damage_texture_modifier);
|
os << serializeString16(damage_texture_modifier);
|
||||||
writeU8(os, shaded);
|
writeU8(os, shaded);
|
||||||
|
writeU8(os, show_on_minimap);
|
||||||
|
|
||||||
// Add stuff only at the bottom.
|
// Add stuff only at the bottom.
|
||||||
// Never remove anything, because we don't want new versions of this
|
// Never remove anything, because we don't want new versions of this
|
||||||
@ -174,7 +176,11 @@ void ObjectProperties::deSerialize(std::istream &is)
|
|||||||
damage_texture_modifier = deSerializeString16(is);
|
damage_texture_modifier = deSerializeString16(is);
|
||||||
u8 tmp = readU8(is);
|
u8 tmp = readU8(is);
|
||||||
if (is.eof())
|
if (is.eof())
|
||||||
throw SerializationError("");
|
return;
|
||||||
shaded = tmp;
|
shaded = tmp;
|
||||||
|
tmp = readU8(is);
|
||||||
|
if (is.eof())
|
||||||
|
return;
|
||||||
|
show_on_minimap = tmp;
|
||||||
} catch (SerializationError &e) {}
|
} catch (SerializationError &e) {}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ struct ObjectProperties
|
|||||||
float zoom_fov = 0.0f;
|
float zoom_fov = 0.0f;
|
||||||
bool use_texture_alpha = false;
|
bool use_texture_alpha = false;
|
||||||
bool shaded = true;
|
bool shaded = true;
|
||||||
|
bool show_on_minimap = false;
|
||||||
|
|
||||||
ObjectProperties();
|
ObjectProperties();
|
||||||
std::string dump();
|
std::string dump();
|
||||||
|
@ -331,6 +331,7 @@ void read_object_properties(lua_State *L, int index,
|
|||||||
getfloatfield(L, -1, "zoom_fov", prop->zoom_fov);
|
getfloatfield(L, -1, "zoom_fov", prop->zoom_fov);
|
||||||
getboolfield(L, -1, "use_texture_alpha", prop->use_texture_alpha);
|
getboolfield(L, -1, "use_texture_alpha", prop->use_texture_alpha);
|
||||||
getboolfield(L, -1, "shaded", prop->shaded);
|
getboolfield(L, -1, "shaded", prop->shaded);
|
||||||
|
getboolfield(L, -1, "show_on_minimap", prop->show_on_minimap);
|
||||||
|
|
||||||
getstringfield(L, -1, "damage_texture_modifier", prop->damage_texture_modifier);
|
getstringfield(L, -1, "damage_texture_modifier", prop->damage_texture_modifier);
|
||||||
}
|
}
|
||||||
@ -419,6 +420,8 @@ void push_object_properties(lua_State *L, ObjectProperties *prop)
|
|||||||
lua_setfield(L, -2, "shaded");
|
lua_setfield(L, -2, "shaded");
|
||||||
lua_pushlstring(L, prop->damage_texture_modifier.c_str(), prop->damage_texture_modifier.size());
|
lua_pushlstring(L, prop->damage_texture_modifier.c_str(), prop->damage_texture_modifier.size());
|
||||||
lua_setfield(L, -2, "damage_texture_modifier");
|
lua_setfield(L, -2, "damage_texture_modifier");
|
||||||
|
lua_pushboolean(L, prop->show_on_minimap);
|
||||||
|
lua_setfield(L, -2, "show_on_minimap");
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -55,6 +55,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, session_t p
|
|||||||
m_prop.backface_culling = false;
|
m_prop.backface_culling = false;
|
||||||
m_prop.makes_footstep_sound = true;
|
m_prop.makes_footstep_sound = true;
|
||||||
m_prop.stepheight = PLAYER_DEFAULT_STEPHEIGHT * BS;
|
m_prop.stepheight = PLAYER_DEFAULT_STEPHEIGHT * BS;
|
||||||
|
m_prop.show_on_minimap = true;
|
||||||
m_hp = m_prop.hp_max;
|
m_hp = m_prop.hp_max;
|
||||||
m_breath = m_prop.breath_max;
|
m_breath = m_prop.breath_max;
|
||||||
// Disable zoom in survival mode using a value of 0
|
// Disable zoom in survival mode using a value of 0
|
||||||
|
Loading…
Reference in New Issue
Block a user