FIFE
2008.0
|
00001 /*************************************************************************** 00002 * Copyright (C) 2005-2008 by the FIFE team * 00003 * http://www.fifengine.de * 00004 * This file is part of FIFE. * 00005 * * 00006 * FIFE is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Lesser General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2.1 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the * 00018 * Free Software Foundation, Inc., * 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 00020 ***************************************************************************/ 00021 00022 // Standard C++ library includes 00023 00024 // 3rd party library includes 00025 00026 // FIFE includes 00027 // These includes are split up in two parts, separated by one empty line 00028 // First block: files included from the FIFE root src directory 00029 // Second block: files included from the same folder 00030 #include "image_location.h" 00031 00032 namespace FIFE { 00033 ImageLocation::ImageLocation(const std::string& filename): 00034 ResourceLocation(filename), 00035 m_xshift(0), 00036 m_yshift(0), 00037 m_width(0), 00038 m_height(0), 00039 m_parent_image(NULL) { 00040 m_type = RES_TYPE_IMAGE; 00041 } 00042 00043 bool ImageLocation::operator ==(const ResourceLocation& loc) const { 00044 if( m_type != loc.getType() ) 00045 return false; 00046 00047 const ImageLocation* r = dynamic_cast<const ImageLocation*>(&loc); 00048 if (!r) { 00049 return false; 00050 } 00051 00052 if (m_xshift != r->m_xshift) { 00053 return false; 00054 } 00055 if (m_yshift != r->m_yshift) { 00056 return false; 00057 } 00058 if (m_width != r->m_width) { 00059 return false; 00060 } 00061 if (m_height != r->m_height) { 00062 return false; 00063 } 00064 if (m_parent_image != r->m_parent_image) { 00065 return false; 00066 } 00067 if( getFilename() != loc.getFilename() ) 00068 return false; 00069 return true; 00070 } 00071 00072 bool ImageLocation::operator <(const ResourceLocation& loc) const { 00073 if( m_type < loc.getType() ) 00074 return true; 00075 if( m_type > loc.getType() ) 00076 return false; 00077 00078 const ImageLocation* r = dynamic_cast<const ImageLocation*>(&loc); 00079 if (!r) { 00080 return false; 00081 } 00082 00083 if(m_xshift < r->m_xshift) 00084 return true; 00085 if(m_xshift > r->m_xshift) 00086 return false; 00087 00088 if(m_yshift < r->m_yshift) 00089 return true; 00090 if(m_yshift > r->m_yshift) 00091 return false; 00092 00093 if(m_width < r->m_width) 00094 return true; 00095 if(m_width > r->m_width) 00096 return false; 00097 00098 if(m_height < r->m_height) 00099 return true; 00100 if(m_height > r->m_height) 00101 return false; 00102 00103 00104 if( m_parent_image < r->m_parent_image ) 00105 return true; 00106 if( m_parent_image > r->m_parent_image ) 00107 return false; 00108 00109 return m_filename < loc.getFilename(); 00110 } 00111 00112 ResourceLocation* ImageLocation::clone() const { 00113 ImageLocation* l = new ImageLocation(getFilename()); 00114 l->m_xshift = m_xshift; 00115 l->m_yshift = m_yshift; 00116 l->m_width = m_width; 00117 l->m_height = m_height; 00118 l->m_parent_image = m_parent_image; 00119 return l; 00120 } 00121 00122 };//FIFE 00123 /* vim: set noexpandtab: set shiftwidth=2: set tabstop=2: */