YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
DrawingContext.cpp
Go to the documentation of this file.
1
#include "
YAPOG/Graphics/DrawingContext.hpp
"
2
3
namespace
yap
4
{
5
const
sf::Color
DrawingContext::DEFAULT_TARGET_CLEAR_COLOR
=
6
sf::Color::Black;
7
8
DrawingContext::DrawingContext
(
const
Vector2
& size,
const
String
& name)
9
: window_ (sf::VideoMode (size.x, size.y), name)
10
, currentMode_ ()
11
, defaultMode_ ()
12
, cameras_ ()
13
, targetClearColor_ (DEFAULT_TARGET_CLEAR_COLOR)
14
{
15
}
16
17
DrawingContext::~DrawingContext
()
18
{
19
for
(
const
auto
it :
cameras_
)
20
delete
it.second;
21
}
22
23
void
DrawingContext::AddCamera
(
const
CameraMode
& mode,
ICamera
* camera)
24
{
25
bool
isEmpty =
cameras_
.
IsEmpty
();
26
27
cameras_
.
Add
(mode, camera);
28
29
if
(!isEmpty)
30
return
;
31
32
SetCurrentMode
(mode);
33
defaultMode_
= mode;
34
}
35
36
void
DrawingContext::RemoveCamera
(
const
CameraMode
& mode)
37
{
38
cameras_
.
Remove
(mode);
39
}
40
41
const
ICamera
&
DrawingContext::GetCamera
()
const
42
{
43
return
GetCamera
(
currentMode_
);
44
}
45
46
ICamera
&
DrawingContext::GetCamera
()
47
{
48
return
GetCamera
(
currentMode_
);
49
}
50
51
const
ICamera
&
DrawingContext::GetCamera
(
const
CameraMode
& mode)
const
52
{
53
return
*
cameras_
[mode];
54
}
55
56
ICamera
&
DrawingContext::GetCamera
(
const
CameraMode
& mode)
57
{
58
return
*
cameras_
[mode];
59
}
60
61
void
DrawingContext::SetMode
(
const
CameraMode
& mode)
62
{
63
SetCurrentMode
(mode);
64
}
65
66
void
DrawingContext::SetDefaultMode
(
const
CameraMode
& mode)
67
{
68
defaultMode_
= mode;
69
}
70
71
void
DrawingContext::SetDefaultCamera
()
72
{
73
SetCurrentMode
(
defaultMode_
);
74
}
75
76
const
sf::RenderTarget&
DrawingContext::GetRenderTarget
()
const
77
{
78
return
window_
;
79
}
80
81
sf::RenderTarget&
DrawingContext::GetRenderTarget
()
82
{
83
return
window_
;
84
}
85
86
void
DrawingContext::Draw
(
const
sf::Drawable& drawable)
87
{
88
Draw
(drawable, sf::RenderStates::Default);
89
}
90
91
void
DrawingContext::Draw
(
92
const
sf::Drawable& drawable,
93
const
sf::RenderStates& states)
94
{
95
HandleDraw
(drawable, states);
96
}
97
98
const
sf::Color&
DrawingContext::GetTargetClearColor
()
const
99
{
100
return
targetClearColor_
;
101
}
102
103
void
DrawingContext::SetTargetClearColor
(
const
sf::Color& color)
104
{
105
targetClearColor_
= color;
106
}
107
108
void
DrawingContext::HandleDraw
(
109
const
sf::Drawable& drawable,
110
const
sf::RenderStates& states)
111
{
112
GetRenderTarget
().draw (drawable, states);
113
}
114
115
void
DrawingContext::SetCurrentMode
(
const
CameraMode
& mode)
116
{
117
currentMode_
= mode;
118
119
GetRenderTarget
().setView (
GetCamera
().GetInnerView ());
120
}
121
122
sf::RenderWindow&
DrawingContext::GetWindow
()
123
{
124
return
window_
;
125
}
126
127
void
DrawingContext::ChangeSize
(
const
Vector2
& size)
128
{
129
for
(
auto
& modeCameraPair :
cameras_
)
130
modeCameraPair.second->SetSize (size);
131
}
132
}
// namespace yap
YAPOG
src
YAPOG
Graphics
DrawingContext.cpp
Generated on Mon Sep 17 2012 22:24:25 for YAPOG by
1.8.1.1