From 1f8ffccd97e189602bbaaef0515e62749f90fec8 Mon Sep 17 00:00:00 2001 From: Benau Date: Thu, 2 Feb 2023 08:01:45 +0800 Subject: [PATCH] Allow disabling gift boxes and bananas indicators by removing their textures --- src/items/item_manager.cpp | 12 +++++++----- src/items/item_manager.hpp | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/items/item_manager.cpp b/src/items/item_manager.cpp index 1b4698f11..f192e33ce 100644 --- a/src/items/item_manager.cpp +++ b/src/items/item_manager.cpp @@ -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 //----------------------------------------------------------------------------- diff --git a/src/items/item_manager.hpp b/src/items/item_manager.hpp index 23a38f668..e87de3294 100644 --- a/src/items/item_manager.hpp +++ b/src/items/item_manager.hpp @@ -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();