![[]](/images/special/trans.gif)
LibN2L-4 Library Code ReferenceClassesCompounds Files Members Method Index Full Reference cGuiSprite.cppGo to the documentation of this file.00001 /************************************************************************ 00002 Nova-2 Library (libN2L, or simply n2l) Game development C++ Library 00003 Copyright (C) 2003 Aaron Cameron 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 A copy of the GNU Lesser General Public License has been provided with 00020 this library in the file 'COPYING'. 00021 00022 Contact information for the author of this library has been provided 00023 with this library in the file 'AUTHOR'. 00024 ************************************************************************/ 00025 #include "gui/cGuiSprite.h" 00026 00027 #include "n2l/dynVars.h" 00028 #include "n2l/resourceManagement.h" 00029 00030 namespace n2l 00031 { 00032 /**************************************************************************/ 00033 cGuiSprite::cGuiSprite() : 00034 cGuiElement( tGuiPos(0,0), tGuiPos(1,1) ) 00035 { 00036 } 00037 00038 /**************************************************************************/ 00039 cGuiSprite::~cGuiSprite() 00040 { 00041 } 00042 00043 /**************************************************************************/ 00044 cGuiSprite::cGuiSprite( const cVfsNodeInterface & iNode ) : 00045 cGuiElement( tGuiPos(0,0), tGuiPos(1,1) ) 00046 { 00047 load( iNode ); 00048 } 00049 00050 /**************************************************************************/ 00051 cGuiSprite::cGuiSprite( const cDynVar & iDefinition ) : 00052 cGuiElement( tGuiPos(0,0), tGuiPos(1,1) ) 00053 { 00054 load( iDefinition ); 00055 } 00056 00057 /**************************************************************************/ 00058 void cGuiSprite::load( const cVfsNodeInterface & iNode ) 00059 { 00060 cDynVar def; 00061 validateAndDecode( def, iNode, "n2l::cGuiSprite" ); 00062 load( def ); 00063 } 00064 00065 00066 /**************************************************************************/ 00067 void cGuiSprite::load( const cDynVar & iDefinition ) 00068 { 00069 // Load parent properties 00070 cGuiElement::load( iDefinition ); 00071 00072 // Now my properties 00073 if (iDefinition["fill"]) { 00074 if (iDefinition["fill"].isArray()) 00075 fill( cGuiFill( iDefinition["fill"] ) ); 00076 else fill( *cResourceManager::get<cGuiFill>(iDefinition["fill"]) ); 00077 } 00078 } 00079 00080 /**************************************************************************/ 00081 void cGuiSprite::draw() const 00082 { 00083 mFill.draw( innerPos(), innerSize() ); 00084 } 00085 00086 /**************************************************************************/ 00087 void cGuiSprite::fill( const cGuiFill & iFill ) 00088 { 00089 mFill = iFill; 00090 } 00091 00092 /**************************************************************************/ 00093 const cAutoPtr<cGuiElement> cGuiSprite::clone() const 00094 { 00095 cAutoPtr<cGuiElement> newElement( new cGuiSprite ); 00096 cloneInto( newElement ); 00097 return newElement; 00098 } 00099 00100 /**************************************************************************/ 00101 void cGuiSprite::cloneInto( const cAutoPtr<cGuiSprite> &i_ioElement ) const 00102 { 00103 // Parent Properties first 00104 cGuiElement::cloneInto( i_ioElement ); 00105 00106 // Now our properties. 00107 i_ioElement->fill(mFill); 00108 } 00109 00110 /**************************************************************************/ 00111 const cAutoPtr<cGuiElement> cGuiSprite::loadNew( const cDynVar &iDef ) 00112 { 00113 return new cGuiSprite(iDef); 00114 } 00115 00116 /**************************************************************************/ 00117 void cGuiSprite::prop( const tString &iName, const cDynVar &iVal, 00118 const tString &iInnerKey ) 00119 { 00120 if (iName == "fill") { 00121 if (iInnerKey.empty()) { 00122 if (iVal.isArray()) 00123 fill( iVal ); 00124 else 00125 fill( *cResourceManager::get<cGuiFill>(iVal) ); 00126 } else 00127 mFill.prop( iInnerKey, iVal ); 00128 00129 } else 00130 cGuiElement::prop( iName, iVal ); 00131 } 00132 00133 /**************************************************************************/ 00134 const cDynVar cGuiSprite::prop( const tString &iName, 00135 const tString &iInnerKey ) const 00136 { 00137 if (iName == "fill") 00138 return mFill.prop( iInnerKey ); 00139 00140 return cGuiElement::prop( iName ); 00141 } 00142 00143 } // namespace n2l |