From: <cn...@us...> - 2009-06-30 02:59:33
|
Revision: 394 http://hgengine.svn.sourceforge.net/hgengine/?rev=394&view=rev Author: cnlohr Date: 2009-06-30 02:59:32 +0000 (Tue, 30 Jun 2009) Log Message: ----------- add basis for Mercury Theme Modified Paths: -------------- Mercury2/adv_set.c Mercury2/src/MercuryPrefs.cpp Added Paths: ----------- Mercury2/src/MercuryTheme.cpp Mercury2/src/MercuryTheme.h Modified: Mercury2/adv_set.c =================================================================== --- Mercury2/adv_set.c 2009-06-30 02:07:41 UTC (rev 393) +++ Mercury2/adv_set.c 2009-06-30 02:59:32 UTC (rev 394) @@ -12,7 +12,8 @@ src/MercuryFile.cpp src/MercuryTimer.cpp src/MercuryMessageManager.cpp src/MercuryVertex.cpp \ src/MercuryPlane.cpp src/BoundingBox.cpp src/Shader.cpp src/RenderGraph.cpp src/Frustum.cpp \ src/Camera.cpp src/MercuryInput.cpp src/MQuaternion.cpp src/ModuleManager.cpp src/MercuryFBO.cpp \ - src/GLHelpers.cpp src/FullscreenQuad.cpp src/MercuryNamedResource.cpp src/MercuryPrefs.cpp" + src/GLHelpers.cpp src/FullscreenQuad.cpp src/MercuryNamedResource.cpp src/MercuryPrefs.cpp \ + src/MercuryTheme.cpp" SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \ src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp" Modified: Mercury2/src/MercuryPrefs.cpp =================================================================== --- Mercury2/src/MercuryPrefs.cpp 2009-06-30 02:07:41 UTC (rev 393) +++ Mercury2/src/MercuryPrefs.cpp 2009-06-30 02:59:32 UTC (rev 394) @@ -31,6 +31,7 @@ MercuryPreferences::~MercuryPreferences() { delete m_PrefsDoc; + delete m_PrefsNode; } bool MercuryPreferences::GetValue( const MString & sDataPointer, MString & sReturn ) Added: Mercury2/src/MercuryTheme.cpp =================================================================== --- Mercury2/src/MercuryTheme.cpp (rev 0) +++ Mercury2/src/MercuryTheme.cpp 2009-06-30 02:59:32 UTC (rev 394) @@ -0,0 +1,124 @@ +#include <MercuryTheme.h> +#include <MercuryPrefs.h> +#include <XMLParser.h> + +#define MAX_THEMES 100 + +MercuryThemeManager & MercuryThemeManager::GetInstance() +{ + static MercuryThemeManager * m_gTheme = 0; + if( !m_gTheme ) + m_gTheme = new MercuryThemeManager(); + return *m_gTheme; +} + +MercuryThemeManager::MercuryThemeManager() +{ + int i; + + m_vThemes.resize( 0 ); + + for( i = 0; i < MAX_THEMES; i++ ) + { + MString ThemeName = PREFSMAN.GetValueS( ssprintf( "Themes.Theme%d", i ) ); + if( !ThemeName.length() ) + break; + + m_vThemes.resize( m_vThemes.size() + 1 ); + if( !m_vThemes[m_vThemes.size()-1].Setup( ThemeName ) ) + m_vThemes.resize( m_vThemes.size() - 1 ); + } + if( m_vThemes.size() == 0 ) + { + FAIL( "Zero themes loaded. This may be due to a misconfiguration in your preferences.ini" ); + } +} + +MercuryThemeManager::~MercuryThemeManager() +{ + //no code +} + +bool MercuryThemeManager::GetValue( const MString & sDataPointer, MString & sReturn ) +{ + //XXX: Incomplete + //This code needs to be filled out. + return true; +} + +MercuryThemeManager::Theme::Theme() +{ + m_xDoc = 0; + m_xNode = 0; +} + +MercuryThemeManager::Theme::~Theme() +{ + SAFE_DELETE( m_xDoc ); + SAFE_DELETE( m_xNode ); +} + +bool MercuryThemeManager::Theme::Setup( const MString & sThemeName ) +{ + sTheme = sThemeName; + m_xDoc = XMLDocument::Load(ssprintf("Themes/%s/metrics.xml",sTheme.c_str())); + if( !m_xDoc ) + { + printf( "Could not open: Themes/%s/metrics.xml\n",sTheme.c_str()); + return false; + } + + m_xNode = new XMLNode(); + + *m_xNode = m_xDoc->GetRootNode(); + + if( !m_xNode->IsValid() ) + { + printf( "Could not get root node in: Themes/%s/metrics.xml\n",sTheme.c_str()); + return false; + } + + *m_xNode = m_xNode->Child(); + + if( !m_xNode->IsValid() ) + { + printf( "Could not get sub node in: Themes/%s/metrics.xml\n",sTheme.c_str()); + return false; + } + + return true; +} + + +/**************************************************************************** + * Copyright (C) 2009 by Charles Lohr * + * * + * * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * Redistributions of source code must retain the above copyright * + * notice, this list of conditions and the following disclaimer. * + * * Redistributions in binary form must reproduce the above * + * copyright notice, this list of conditions and the following * + * disclaimer in the documentation and/or other materials provided * + * with the distribution. * + * * Neither the name of the Mercury Engine nor the names of its * + * contributors may be used to endorse or promote products derived * + * from this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + ***************************************************************************/ + Added: Mercury2/src/MercuryTheme.h =================================================================== --- Mercury2/src/MercuryTheme.h (rev 0) +++ Mercury2/src/MercuryTheme.h 2009-06-30 02:59:32 UTC (rev 394) @@ -0,0 +1,71 @@ +#ifndef _MERCURY_THEME_H +#define _MERCURY_THEME_H + +#include <MercuryNamedResource.h> +#include <MercuryUtil.h> //huh? +#include <MercuryVector.h> + +class XMLNode; +class XMLDocument; + +class MercuryThemeManager : public MercuryNamedResource +{ +public: + MercuryThemeManager(); + ~MercuryThemeManager(); + + static MercuryThemeManager& GetInstance(); + + virtual bool GetValue( const MString & sDataPointer, MString & sReturn ); +private: + class Theme + { + public: + Theme( ); + bool Setup( const MString & sThemeName ); + ~Theme(); + MString sTheme; + XMLNode * m_xNode; + XMLDocument * m_xDoc; + }; + MVector< Theme > m_vThemes; +}; + +static InstanceCounter<MercuryThemeManager> MFMcounter("MercuryThemeManager"); + +#define THEME MercuryFileManager::GetInstance() + + +#endif + +/**************************************************************************** + * Copyright (C) 2009 by Charles Lohr * + * * + * * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * Redistributions of source code must retain the above copyright * + * notice, this list of conditions and the following disclaimer. * + * * Redistributions in binary form must reproduce the above * + * copyright notice, this list of conditions and the following * + * disclaimer in the documentation and/or other materials provided * + * with the distribution. * + * * Neither the name of the Mercury Engine nor the names of its * + * contributors may be used to endorse or promote products derived * + * from this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + ***************************************************************************/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |