#include "os/path.h"
#include "stream/stringstream.h"
-
typedef Modules<_QERPlugImageTable> ImageModules;
ImageModules& Textures_getImageModules();
+ImageModules& Textures_getFallbackImageModules();
/// \brief Returns a new image for the first file matching \p name in one of the available texture formats, or 0 if no file is found.
Image* QERApp_LoadImage( void* environment, const char* name ){
Textures_getImageModules().foreachModule( LoadImageVisitor( name, image ) );
+ // Games can provide their own fallback, so only do this when previous
+ // loading attempt did not work.
+ if ( image == 0 && !!string_compare_nocase( name, "textures/radiant" ) )
+ {
+ Textures_getFallbackImageModules().foreachModule( LoadImageVisitor( name, image ) );
+ }
+
return image;
}
public GlobalPreferenceSystemModuleRef
{
ImageModulesRef m_image_modules;
+ImageModulesRef m_fallback_image_modules;
public:
TexturesDependencies() :
- m_image_modules( GlobalRadiant().getRequiredGameDescriptionKeyValue( "texturetypes" ) ){
+ m_image_modules( GlobalRadiant().getRequiredGameDescriptionKeyValue( "texturetypes" ) ),
+ m_fallback_image_modules( "png" ){
}
ImageModules& getImageModules(){
return m_image_modules.get();
}
+ImageModules& getFallbackImageModules(){
+ return m_fallback_image_modules.get();
+}
};
class TexturesAPI
ImageModules& Textures_getImageModules(){
return StaticTexturesModule::instance().getDependencies().getImageModules();
}
+ImageModules& Textures_getFallbackImageModules(){
+ return StaticTexturesModule::instance().getDependencies().getFallbackImageModules();
+}