MercuryTheme.h

Go to the documentation of this file.
00001 #ifndef _MERCURYTHEME_H
00002 #define _MERCURYTHEME_H
00003 
00004 #include "MercuryINI.h"
00005 
00007 
00010 class MercuryTheme
00011 {
00012 public:
00014     bool    Load( const MString & sThemeName );
00015 
00017     inline bool GetMetricS( const MString & sKey, const MString & sValue, MString & sData ) { return Metrics.GetValue( sKey, sValue, sData ); }
00018 
00020     MString GetName() { return m_sName; }
00021 private:
00022     MercuryINI  Metrics;
00023     MString     m_sName;
00024 };
00025 
00026 
00030 class MercuryThemeManager
00031 {
00032 public:
00033     ~MercuryThemeManager() { SAFE_DELETE( m_vThemes ); }
00035     void    ReloadAllThemes( );
00036 
00038     bool    GetMetric( const MString & sKey, const MString & sValue, MString & sData, int ttl = 100 );
00039 
00041     MString GetMetricS( const MString & sKey, const MString & sValue, const MString & Default = "" );
00043     int     GetMetricI( const MString & sKey, const MString & sValue, int Default = 0 );
00045     float   GetMetricF( const MString & sKey, const MString & sValue, float Default = 0 );
00047     bool    GetMetricB( const MString & sKey, const MString & sValue, bool Default = false );
00048 
00050     bool    GetPathToFile( const MString & File, MString & Path );
00051 
00053     MString GetPathToFile( const MString &Name );
00055     MString GetPathToGraphic( const MString &Name );
00057     MString GetPathToModel( const MString &Name );
00058 
00059 private:
00060     MVector < MercuryTheme > *m_vThemes;
00061 };
00062 
00063 extern MercuryThemeManager THEME;
00064 
00066 #define GET_GRAPHIC_BY_NAME( x ) THEME.GetPathToGraphic( THEME.GetMetricS( GetName(), x ) )
00067 #define GET_MODEL_BY_NAME( x ) THEME.GetPathToModel( THEME.GetMetricS( GetName(), x ) )
00068 #define GET_FILE_BY_NAME( x ) THEME.GetPathToFile( THEME.GetMetricS( GetName(), x ) )
00069 
00070 #endif
00071 
00072 /* 
00073  * Copyright (c) 2005-2006, Charles Lohr
00074  * All rights reserved.
00075  *
00076  * Redistribution and use in source and binary forms, with or
00077  * without modification, are permitted provided that the following
00078  * conditions are met:
00079  *  -   Redistributions of source code must retain the above
00080  *      copyright notice, this list of conditions and the following disclaimer.
00081  *  -   Redistributions in binary form must reproduce the above copyright
00082  *      notice, this list of conditions and the following disclaimer in
00083  *      the documentation and/or other materials provided with the distribution.
00084  *  -   Neither the name of the Mercury Engine nor the names of its
00085  *      contributors may be used to endorse or promote products derived from
00086  *      this software without specific prior written permission.
00087  *
00088  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00089  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00090  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00091  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
00092  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00093  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00094  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00095  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00096  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00097  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00098  */
00099 

Hosted by SourceForge.net Logo