Browse Source

Add ability to query the sources of all textures loaded. See #131.

Michael Ragazzon 5 years ago
parent
commit
88d1d843c4

+ 2 - 0
Include/RmlUi/Core/Core.h

@@ -142,6 +142,8 @@ RMLUICORE_API void RegisterPlugin(Plugin* plugin);
 /// @return The EventId of the newly created type, or existing type if 'type' is an internal type.
 /// @return The EventId of the newly created type, or existing type if 'type' is an internal type.
 RMLUICORE_API EventId RegisterEventType(const String& type, bool interruptible, bool bubbles, DefaultActionPhase default_action_phase = DefaultActionPhase::None);
 RMLUICORE_API EventId RegisterEventType(const String& type, bool interruptible, bool bubbles, DefaultActionPhase default_action_phase = DefaultActionPhase::None);
 
 
+/// Returns a list of source URLs to textures in all loaded documents.
+RMLUICORE_API StringList GetTextureSourceList();
 /// Forces all texture handles loaded and generated by RmlUi to be released.
 /// Forces all texture handles loaded and generated by RmlUi to be released.
 RMLUICORE_API void ReleaseTextures();
 RMLUICORE_API void ReleaseTextures();
 /// Forces all compiled geometry handles generated by RmlUi to be released.
 /// Forces all compiled geometry handles generated by RmlUi to be released.

+ 5 - 0
Source/Core/Core.cpp

@@ -328,6 +328,11 @@ EventId RegisterEventType(const String& type, bool interruptible, bool bubbles,
 	return EventSpecificationInterface::InsertOrReplaceCustom(type, interruptible, bubbles, default_action_phase);
 	return EventSpecificationInterface::InsertOrReplaceCustom(type, interruptible, bubbles, default_action_phase);
 }
 }
 
 
+StringList GetTextureSourceList()
+{
+	return TextureDatabase::GetSourceList();
+}
+
 void ReleaseTextures()
 void ReleaseTextures()
 {
 {
 	TextureDatabase::ReleaseTextures();
 	TextureDatabase::ReleaseTextures();

+ 1 - 1
Source/Core/Decorator.cpp

@@ -57,7 +57,7 @@ int Decorator::LoadTexture(const String& texture_name, const String& rcss_path)
 	Texture texture;
 	Texture texture;
 	texture.Set(texture_name, rcss_path);
 	texture.Set(texture_name, rcss_path);
 
 
-	additional_textures.push_back(texture);
+	additional_textures.push_back(std::move(texture));
 	return (int)additional_textures.size();
 	return (int)additional_textures.size();
 }
 }
 
 

+ 15 - 0
Source/Core/TextureDatabase.cpp

@@ -111,6 +111,21 @@ void TextureDatabase::RemoveCallbackTexture(TextureResource* texture)
 		texture_database->callback_textures.erase(texture);
 		texture_database->callback_textures.erase(texture);
 }
 }
 
 
+StringList TextureDatabase::GetSourceList()
+{
+	StringList result;
+	
+	if (texture_database)
+	{
+		result.reserve(texture_database->textures.size());
+
+		for (const auto& pair : texture_database->textures)
+			result.push_back(pair.first);
+	}
+
+	return result;
+}
+
 void TextureDatabase::ReleaseTextures(RenderInterface* render_interface)
 void TextureDatabase::ReleaseTextures(RenderInterface* render_interface)
 {
 {
 	if (texture_database)
 	if (texture_database)

+ 3 - 0
Source/Core/TextureDatabase.h

@@ -61,6 +61,9 @@ public:
     /// Removes a callback texture from the database.
     /// Removes a callback texture from the database.
     static void RemoveCallbackTexture(TextureResource* texture);
     static void RemoveCallbackTexture(TextureResource* texture);
 
 
+	/// Return a list of all texture sources currently in the database.
+	static StringList GetSourceList();
+
 private:
 private:
 	TextureDatabase();
 	TextureDatabase();
 	~TextureDatabase();
 	~TextureDatabase();