FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
image_location.cpp
1 /***************************************************************************
2  * Copyright (C) 2005-2008 by the FIFE team *
3  * http://www.fifengine.de *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 // Standard C++ library includes
23 
24 // 3rd party library includes
25 
26 // FIFE includes
27 // These includes are split up in two parts, separated by one empty line
28 // First block: files included from the FIFE root src directory
29 // Second block: files included from the same folder
30 #include "image_location.h"
31 
32 namespace FIFE {
33  ImageLocation::ImageLocation(const std::string& filename):
34  ResourceLocation(filename),
35  m_xshift(0),
36  m_yshift(0),
37  m_width(0),
38  m_height(0),
39  m_parent_image(NULL) {
40  m_type = RES_TYPE_IMAGE;
41  }
42 
44  if( m_type != loc.getType() )
45  return false;
46 
47  const ImageLocation* r = dynamic_cast<const ImageLocation*>(&loc);
48  if (!r) {
49  return false;
50  }
51 
52  if (m_xshift != r->m_xshift) {
53  return false;
54  }
55  if (m_yshift != r->m_yshift) {
56  return false;
57  }
58  if (m_width != r->m_width) {
59  return false;
60  }
61  if (m_height != r->m_height) {
62  return false;
63  }
64  if (m_parent_image != r->m_parent_image) {
65  return false;
66  }
67  if( getFilename() != loc.getFilename() )
68  return false;
69  return true;
70  }
71 
73  if( m_type < loc.getType() )
74  return true;
75  if( m_type > loc.getType() )
76  return false;
77 
78  const ImageLocation* r = dynamic_cast<const ImageLocation*>(&loc);
79  if (!r) {
80  return false;
81  }
82 
83  if(m_xshift < r->m_xshift)
84  return true;
85  if(m_xshift > r->m_xshift)
86  return false;
87 
88  if(m_yshift < r->m_yshift)
89  return true;
90  if(m_yshift > r->m_yshift)
91  return false;
92 
93  if(m_width < r->m_width)
94  return true;
95  if(m_width > r->m_width)
96  return false;
97 
98  if(m_height < r->m_height)
99  return true;
100  if(m_height > r->m_height)
101  return false;
102 
103 
104  if( m_parent_image < r->m_parent_image )
105  return true;
106  if( m_parent_image > r->m_parent_image )
107  return false;
108 
109  return m_filename < loc.getFilename();
110  }
111 
114  l->m_xshift = m_xshift;
115  l->m_yshift = m_yshift;
116  l->m_width = m_width;
117  l->m_height = m_height;
118  l->m_parent_image = m_parent_image;
119  return l;
120  }
121 
122 };//FIFE
123 /* vim: set noexpandtab: set shiftwidth=2: set tabstop=2: */