YAPOG  0.0.1
Yet Another Pokemon Online Game
SelectionTileLayoutHandler.cpp
Go to the documentation of this file.
4 
5 namespace yap
6 {
9 
12  , width_ (DEFAULT_WIDTH)
13  , height_ (DEFAULT_HEIGHT)
14  , defaultTile_ (nullptr)
15  , tiles_ (width_, height_, nullptr)
16  {
17  }
18 
20  {
21  for (uint y = 0; y < height_; ++y)
22  for (uint x = 0; x < width_; ++x)
23  if (tiles_ (x, y) != defaultTile_)
24  {
25  delete tiles_ (x, y);
26  tiles_ (x, y) = nullptr;
27  }
28 
29  delete defaultTile_;
30  defaultTile_ = nullptr;
31  }
32 
34  {
35  width_ = width;
36  height_ = height;
37 
38  tiles_.Resize (width_, height_, nullptr);
39  }
40 
42  {
43  defaultTile_ = defaultTile;
44 
45  for (uint y = 0; y < height_; ++y)
46  for (uint x = 0; x < width_; ++x)
47  tiles_ (x, y) = defaultTile_;
48  }
49 
51  {
52  tiles_ (x, y) = tile;
53  }
54 
56  {
57  for (uint y = 0; y < height_; ++y)
58  for (uint x = 0; x < width_; ++x)
59  tileLayer.SetTile (x, y, tiles_ (x, y)->Clone ());
60  }
61 } // namespace yap