#include "exceptions.h"
#include "debug.h"
#include "gamedef.h"
+#include <fstream> // Used in applyTextureOverrides()
/*
NodeBox
#ifndef SERVER
for(u32 i = 0; i < 24; i++)
mesh_ptr[i] = NULL;
+ minimap_color = video::SColor(0, 0, 0, 0);
#endif
visual_scale = 1.0;
for(u32 i = 0; i < 6; i++)
virtual content_t set(const std::string &name, const ContentFeatures &def);
virtual content_t allocateDummy(const std::string &name);
virtual void updateAliases(IItemDefManager *idef);
+ virtual void applyTextureOverrides(const std::string &override_filepath);
virtual void updateTextures(IGameDef *gamedef,
void (*progress_cbk)(void *progress_args, u32 progress, u32 max_progress),
void *progress_cbk_args);
inline virtual bool getNodeRegistrationStatus() const;
inline virtual void setNodeRegistrationStatus(bool completed);
- virtual void pendNodeResolve(NodeResolver *nr, NodeResolveMethod how);
+ virtual void pendNodeResolve(NodeResolver *nr);
virtual bool cancelNodeResolveCallback(NodeResolver *nr);
virtual void runNodeResolveCallbacks();
virtual void resetNodeResolveState();
j = m_group_to_items.find(group_name);
if (j == m_group_to_items.end()) {
m_group_to_items[group_name].push_back(
- std::make_pair(id, i->second));
+ std::make_pair(id, i->second));
} else {
GroupItems &items = j->second;
items.push_back(std::make_pair(id, i->second));
content_t id;
if (m_name_id_mapping.getId(convert_to, id)) {
m_name_id_mapping_with_aliases.insert(
- std::make_pair(name, id));
+ std::make_pair(name, id));
}
}
}
+void CNodeDefManager::applyTextureOverrides(const std::string &override_filepath)
+{
+ infostream << "CNodeDefManager::applyTextureOverrides(): Applying "
+ "overrides to textures from " << override_filepath << std::endl;
+
+ std::ifstream infile(override_filepath.c_str());
+ std::string line;
+ int line_c = 0;
+ while (std::getline(infile, line)) {
+ line_c++;
+ if (trim(line) == "")
+ continue;
+ std::vector<std::string> splitted = str_split(line, ' ');
+ if (splitted.size() != 3) {
+ errorstream << override_filepath
+ << ":" << line_c << " Could not apply texture override \""
+ << line << "\": Syntax error" << std::endl;
+ continue;
+ }
+
+ content_t id;
+ if (!getId(splitted[0], id)) {
+ errorstream << override_filepath
+ << ":" << line_c << " Could not apply texture override \""
+ << line << "\": Unknown node \""
+ << splitted[0] << "\"" << std::endl;
+ continue;
+ }
+
+ ContentFeatures &nodedef = m_content_features[id];
+
+ if (splitted[1] == "top")
+ nodedef.tiledef[0].name = splitted[2];
+ else if (splitted[1] == "bottom")
+ nodedef.tiledef[1].name = splitted[2];
+ else if (splitted[1] == "right")
+ nodedef.tiledef[2].name = splitted[2];
+ else if (splitted[1] == "left")
+ nodedef.tiledef[3].name = splitted[2];
+ else if (splitted[1] == "back")
+ nodedef.tiledef[4].name = splitted[2];
+ else if (splitted[1] == "front")
+ nodedef.tiledef[5].name = splitted[2];
+ else if (splitted[1] == "all" || splitted[1] == "*")
+ for (int i = 0; i < 6; i++)
+ nodedef.tiledef[i].name = splitted[2];
+ else if (splitted[1] == "sides")
+ for (int i = 2; i < 6; i++)
+ nodedef.tiledef[i].name = splitted[2];
+ else {
+ errorstream << override_filepath
+ << ":" << line_c << " Could not apply texture override \""
+ << line << "\": Unknown node side \""
+ << splitted[1] << "\"" << std::endl;
+ continue;
+ }
+ }
+}
void CNodeDefManager::updateTextures(IGameDef *gamedef,
void (*progress_callback)(void *progress_args, u32 progress, u32 max_progress),
#ifndef SERVER
infostream << "CNodeDefManager::updateTextures(): Updating "
"textures in node definitions" << std::endl;
-
ITextureSource *tsrc = gamedef->tsrc();
IShaderSource *shdsrc = gamedef->getShaderSource();
scene::ISceneManager* smgr = gamedef->getSceneManager();
bool enable_bumpmapping = g_settings->getBool("enable_bumpmapping");
bool enable_parallax_occlusion = g_settings->getBool("enable_parallax_occlusion");
bool enable_mesh_cache = g_settings->getBool("enable_mesh_cache");
+ bool enable_minimap = g_settings->getBool("enable_minimap");
bool use_normal_texture = enable_shaders &&
(enable_bumpmapping || enable_parallax_occlusion);
for (u32 i = 0; i < size; i++) {
ContentFeatures *f = &m_content_features[i];
+ // minimap pixel color - the average color of a texture
+ if (enable_minimap && f->tiledef[0].name != "")
+ f->minimap_color = tsrc->getTextureAverageColor(f->tiledef[0].name);
+
// Figure out the actual tiles to use
TileDef tiledef[6];
for (u32 j = 0; j < 6; j++) {
}
-void CNodeDefManager::pendNodeResolve(NodeResolver *nr, NodeResolveMethod how)
+void CNodeDefManager::pendNodeResolve(NodeResolver *nr)
{
nr->m_ndef = this;
-
- switch (how) {
- case NODE_RESOLVE_NONE:
- break;
- case NODE_RESOLVE_DIRECT:
+ if (m_node_registration_complete)
nr->nodeResolveInternal();
- break;
- case NODE_RESOLVE_DEFERRED:
- if (m_node_registration_complete)
- nr->nodeResolveInternal();
- else
- m_pending_resolve_callbacks.push_back(nr);
- break;
- }
+ else
+ m_pending_resolve_callbacks.push_back(nr);
}
}
-const std::string &NodeResolver::getNodeName(content_t c) const
-{
- if (c < m_nodenames.size())
- return m_nodenames[c];
-
- if (m_ndef)
- return m_ndef->get(c).name;
-
- static const std::string unknown_str("unknown");
- return unknown_str;
-}
-
-
bool NodeResolver::getIdFromNrBacklog(content_t *result_out,
const std::string &node_alt, content_t c_fallback)
{