Changeset 42

Show
Ignore:
Timestamp:
01/26/07 00:57:02 (2 years ago)
Author:
baxissimo
Message:

Moved example files to subdirectory.
Added some simple resource path stuff for finding res files.

Files:

Legend:

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

    r33 r42  
    3131import luigi.event; 
    3232import luigi.adapter; 
    33 import gld; 
     33private import gld; 
    3434//import sslot.signal; 
    3535import luigi.signalobj; 
  • trunk/luigi/gui.d

    r37 r42  
    7676import std.ctype : isprint; 
    7777import std.uni : isUniAlpha; 
     78static import std.path; 
     79static import std.file; 
    7880 
    7981// Just for debug? 
    8082import std.stdio : writefln; 
     83 
    8184 
    8285/**  
     
    109112    } 
    110113 
     114    /// Add a location where themes should look for resource files 
     115    /// (e.g. images, textures, etc.  The built-in themes look for some files  
     116    /// relative to the luigi base directory, so you may need to add it to 
     117    /// your path.)  The current directory '.' is the only thing on the resource path 
     118    /// by default. 
     119    void add_resource_location(char[] path) { 
     120        char[] workp = path.dup; 
     121        if (workp[$-1..$] != std.path.sep) { workp ~= std.path.sep; } 
     122        m_resource_path ~= workp; 
     123    } 
     124    /// Get the current resource path.  This is a list of paths where Luigi  
     125    /// should look for resource files like images. 
     126    char[][] resource_path() { 
     127        return m_resource_path; 
     128    } 
     129    /// Finds the specified resource file on the resource path.  This could be  
     130    /// an image or anything else.  Used to find theme textures internally. 
     131    /// 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; 
     139            } 
     140        } 
     141        return null; 
     142    } 
     143 
    111144    /** Add a top level overlay.   
    112145        This is called automatically by Overlay, so typically there is no  
     
    145178    } 
    146179 
     180 
     181 
    147182private: 
    148183 
    149184    this() { 
     185        add_resource_location("."); 
    150186    } 
    151187 
     
    156192    InputAdapter m_inputsys; 
    157193    Theme m_theme; 
     194    char[][] m_resource_path; 
    158195} 
    159196 
  • trunk/luigi/themes/dxut.d

    r39 r42  
    12341234void loadCompressedTexture(char[] filename, inout GLuint texid) 
    12351235{ 
    1236     DDSImageData *pDDSdata = loadDDSTextureFile( filename ); 
     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    } 
    12371246 
    12381247    if( pDDSdata )