Changeset 43

Show
Ignore:
Timestamp:
01/26/07 01:17:49 (2 years ago)
Author:
baxissimo
Message:

Tweaked the resource path stuff a little. Allow searching for several variants of a filename instead of just one filename.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/luigi/gui.d

    r42 r43  
    129129    /// Finds the specified resource file on the resource path.  This could be  
    130130    /// an image or anything else.  Used to find theme textures internally. 
     131    /// A list of names passed in will treated as alternative names for the same 
     132    /// resource file and searched for in the order provided. 
    131133    /// Returns null if the resource could not be located on the resource path. 
    132     char[] find_resource_location(char[] name) { 
    133         writefln("Looking for file: ", name); 
    134         foreach(char[] p; m_resource_path) { 
    135             char[] fullpath = p ~ name; 
    136             writefln("Trying file: ", fullpath); 
    137             if (std.file.exists(fullpath)) { 
    138                 return fullpath; 
     134    char[] find_resource_location(char[][] name...) { 
     135        foreach(char[] aname; name) { 
     136            foreach(char[] p; m_resource_path) { 
     137                char[] fullpath = p ~ aname; 
     138                if (std.file.exists(fullpath)) { 
     139                    return fullpath; 
     140                } 
    139141            } 
    140142        } 
  • trunk/luigi/themes/dxut.d

    r42 r43  
    5656        try { 
    5757            initialize_compressed_texture_extension(); 
    58             loadCompressedTexture("themes/dxutcontrols.dds", m_texid); 
    59             //loadCompressedTexture("themes/lena.dds", m_texid); 
     58 
     59            char[] filepath = Luigi().find_resource_location( 
     60                "dxutcontrols.dds", 
     61                "themes/dxutcontrols.dds", 
     62                "resource/dxutcontrols.dds" 
     63                ); 
     64            if (filepath) { 
     65                loadCompressedTexture(filepath, m_texid); 
     66            } else { 
     67                char[] str = std.string.format( 
     68                    "couldn't find, or failed to load \"%s\"", filepath); 
     69                report_error(str); 
     70                return; 
     71            } 
     72 
    6073            glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &m_texw); 
    6174            glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &m_texh); 
     
    12341247void loadCompressedTexture(char[] filename, inout GLuint texid) 
    12351248{ 
    1236     char[] filepath = Luigi().find_resource_location(filename); 
    1237     DDSImageData *pDDSdata = null; 
    1238     if (filepath) { 
    1239         pDDSdata = loadDDSTextureFile( filepath ); 
    1240     } else { 
    1241         char[] str = std.string.format( 
    1242             "loadDDSTextureFile couldn't find, or failed to load \"%s\"", filename); 
    1243         report_error(str); 
    1244         return; 
    1245     } 
     1249    DDSImageData *pDDSdata = loadDDSTextureFile( filename ); 
    12461250 
    12471251    if( pDDSdata )