image_location.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
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 };
00123