From ac1d878aacf3bc82eae1137fa79497c7185ea8c6 Mon Sep 17 00:00:00 2001 From: cutealien Date: Thu, 2 Dec 2010 22:14:44 +0000 Subject: [PATCH] Add IGUIEnvironment::removeFont (requested regularly). Note: Currently we still will have the font-texture for CGUIFont's in the cache afterward. But that needs a more general mechanims that allows cleaning up textures easier when the last one has been removed. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3465 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 2 ++ include/IGUIEnvironment.h | 3 +++ source/Irrlicht/CGUIEnvironment.cpp | 15 +++++++++++++++ source/Irrlicht/CGUIEnvironment.h | 3 +++ 4 files changed, 23 insertions(+) diff --git a/changes.txt b/changes.txt index 293087a5..4aa3c4ee 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,7 @@ Changes in 1.8 (??.0?.2010) + - Add function IGUIEnvironment::removeFont + - Functions in IMeshCache expecting IAnimatedMesh* parameters removed as similar functions with IMesh* can be used since a while. Fixes also problems when IAnimatedMesh* got upcasted to IMesh*. (thx @ Greenya for reporting) - The following functions will now use a "ISceneNode *" instead of a "const ISceneNode *": diff --git a/include/IGUIEnvironment.h b/include/IGUIEnvironment.h index 16dcd00f..20c7680b 100644 --- a/include/IGUIEnvironment.h +++ b/include/IGUIEnvironment.h @@ -174,6 +174,9 @@ public: \return Pointer to the font stored. This can differ from given parameter if the name previously existed. */ virtual IGUIFont* addFont(const io::path& name, IGUIFont* font) = 0; + //! remove loaded font + virtual void removeFont(IGUIFont* font) = 0; + //! Returns the default built-in font. /** \return Pointer to the default built-in font. This pointer should not be dropped. See IReferenceCounted::drop() for diff --git a/source/Irrlicht/CGUIEnvironment.cpp b/source/Irrlicht/CGUIEnvironment.cpp index af7f0701..631fa2a7 100644 --- a/source/Irrlicht/CGUIEnvironment.cpp +++ b/source/Irrlicht/CGUIEnvironment.cpp @@ -1481,6 +1481,21 @@ IGUIFont* CGUIEnvironment::addFont(const io::path& name, IGUIFont* font) return font; } +//! remove loaded font +void CGUIEnvironment::removeFont(IGUIFont* font) +{ + if ( !font ) + return; + for ( u32 i=0; idrop(); + Fonts.erase(i); + return; + } + } +} //! returns default font IGUIFont* CGUIEnvironment::getBuiltInFont() const diff --git a/source/Irrlicht/CGUIEnvironment.h b/source/Irrlicht/CGUIEnvironment.h index 16ca8ea6..b9dcc94f 100644 --- a/source/Irrlicht/CGUIEnvironment.h +++ b/source/Irrlicht/CGUIEnvironment.h @@ -80,6 +80,9 @@ public: //! add an externally loaded font virtual IGUIFont* addFont(const io::path& name, IGUIFont* font); + //! remove loaded font + virtual void removeFont(IGUIFont* font); + //! returns default font virtual IGUIFont* getBuiltInFont() const;