Allow disabling gift boxes and bananas indicators by removing their textures

This commit is contained in:
Benau 2023-02-02 08:01:45 +08:00
parent 90277eebd5
commit 1f8ffccd97
2 changed files with 8 additions and 6 deletions

View File

@ -118,8 +118,9 @@ void ItemManager::loadDefaultItemMeshes()
#endif
m_item_lowres_mesh[i]->grab();
}
m_icon[i] = "icon-" + item_names[(ItemState::ItemType)i] + ".png";
preloadIcon(m_icon[i]);
std::string icon = "icon-" + item_names[(ItemState::ItemType)i] + ".png";
if (preloadIcon(icon))
m_icon[i] = icon;
} // for i
delete root;
preloadIcon("item_spark.png");
@ -128,14 +129,15 @@ void ItemManager::loadDefaultItemMeshes()
//-----------------------------------------------------------------------------
/** Preload icon materials to avoid hangs when firstly insert item
*/
void ItemManager::preloadIcon(const std::string& name)
bool ItemManager::preloadIcon(const std::string& name)
{
// From IrrDriver::addBillboard
Material* m = material_manager->getMaterial(name, false/*full_path*/,
/*make_permanent*/true, /*complain_if_not_found*/true,
/*strip_path*/false, /*install*/false);
m->getTexture(true/*srgb*/, m->getShaderName() == "additive" ||
m->getShaderName() == "alphablend" ? true : false/*premul_alpha*/);
return m->getTexture(true/*srgb*/, m->getShaderName() == "additive" ||
m->getShaderName() == "alphablend" ? true : false/*premul_alpha*/) !=
NULL;
} // preloadIcon
//-----------------------------------------------------------------------------

View File

@ -57,7 +57,7 @@ private:
static uint32_t m_random_seed;
static void preloadIcon(const std::string& name);
static bool preloadIcon(const std::string& name);
public:
static void loadDefaultItemMeshes();
static void removeTextures();