~ubuntu-branches/ubuntu/maverick/lordsawar/maverick

« back to all changes in this revision

Viewing changes to src/tilestyleset.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese
  • Date: 2010-04-10 09:29:33 UTC
  • mfrom: (1.1.9 upstream) (5.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100410092933-23uq4dxig30kmtcw
Tags: 0.1.8-1
* New upstream release.
* Add misc:Depends for -data package.
* Bump Standards Version to 3.8.4. (No changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include "GraphicsCache.h"
24
24
#include "xmlhelper.h"
 
25
#include "gui/image-helpers.h"
25
26
 
26
27
std::string TileStyleSet::d_tag = "tilestyleset";
27
28
using namespace std;
44
45
    delete (*this)[i];
45
46
}
46
47
 
47
 
bool TileStyleSet::save(XML_Helper *helper)
 
48
bool TileStyleSet::save(XML_Helper *helper) const
48
49
{
49
50
  bool retval = true;
50
51
 
51
52
  retval &= helper->openTag(TileStyleSet::d_tag);
52
53
  retval &= helper->saveData("name", d_name);
53
 
  for (TileStyleSet::iterator i = begin(); i != end(); ++i)
 
54
  for (TileStyleSet::const_iterator i = begin(); i != end(); ++i)
54
55
    retval &= (*i)->save(helper);
55
56
  retval &= helper->closeTag();
56
57
 
57
58
  return retval;
58
59
}
59
60
 
60
 
void TileStyleSet::getUniqueTileStyleTypes(std::list<TileStyle::Type> &types)
 
61
void TileStyleSet::getUniqueTileStyleTypes(std::list<TileStyle::Type> &types) const
61
62
{
62
 
  for (TileStyleSet::iterator i = begin(); i != end(); ++i)
 
63
  for (TileStyleSet::const_iterator i = begin(); i != end(); ++i)
63
64
    if (find (types.begin(), types.end(), (*i)->getType()) == types.end())
64
65
      types.push_back((*i)->getType());
65
66
}
66
67
 
67
 
bool TileStyleSet::validate()
 
68
bool TileStyleSet::validate() const
68
69
{
 
70
  if (getName().empty() == true)
 
71
    return false;
69
72
  return true;
70
73
}
71
74
 
 
75
void TileStyleSet::uninstantiateImages()
 
76
{
 
77
  for (unsigned int i = 0; i < size(); i++)
 
78
    {
 
79
      if ((*this)[i]->getImage() != NULL)
 
80
        {
 
81
          delete (*this)[i]->getImage();
 
82
          (*this)[i]->setImage(NULL);
 
83
        }
 
84
    }
 
85
}
 
86
void TileStyleSet::instantiateImages(int tilesize, std::string filename)
 
87
{
 
88
  if (filename.empty() == false)
 
89
    {
 
90
      std::vector<PixMask *> styles = disassemble_row(filename, size());
 
91
      for (unsigned int i = 0; i < size(); i++)
 
92
        {
 
93
          PixMask::scale(styles[i], tilesize, tilesize);
 
94
          (*this)[i]->setImage(styles[i]);
 
95
        }
 
96
    }
 
97
}
72
98
// End of file