YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
SelectionTileLayoutHandler.cpp
Go to the documentation of this file.
1
#include "
YAPOG/Graphics/Game/World/Map/SelectionTileLayoutHandler.hpp
"
2
#include "
YAPOG/Graphics/Game/World/Map/Tile.hpp
"
3
#include "
YAPOG/Graphics/Game/World/Map/TileLayer.hpp
"
4
5
namespace
yap
6
{
7
const
uint
SelectionTileLayoutHandler::DEFAULT_WIDTH
= 0;
8
const
uint
SelectionTileLayoutHandler::DEFAULT_HEIGHT
= 0;
9
10
SelectionTileLayoutHandler::SelectionTileLayoutHandler
()
11
:
TileLayoutHandler
()
12
, width_ (DEFAULT_WIDTH)
13
, height_ (DEFAULT_HEIGHT)
14
, defaultTile_ (nullptr)
15
, tiles_ (width_, height_, nullptr)
16
{
17
}
18
19
SelectionTileLayoutHandler::~SelectionTileLayoutHandler
()
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
33
void
SelectionTileLayoutHandler::SetSize
(
uint
width,
uint
height)
34
{
35
width_
= width;
36
height_
= height;
37
38
tiles_
.
Resize
(
width_
,
height_
,
nullptr
);
39
}
40
41
void
SelectionTileLayoutHandler::SetDefaultTile
(
Tile
* defaultTile)
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
50
void
SelectionTileLayoutHandler::SetTile
(
uint
x,
uint
y,
Tile
* tile)
51
{
52
tiles_
(x, y) = tile;
53
}
54
55
void
SelectionTileLayoutHandler::HandleExecute
(
TileLayer
& tileLayer)
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
YAPOG
src
YAPOG
Graphics
Game
World
Map
SelectionTileLayoutHandler.cpp
Generated on Mon Sep 17 2012 22:24:25 for YAPOG by
1.8.1.1