YAPOG  0.0.1
Yet Another Pokemon Online Game
WidgetBackground.cpp
Go to the documentation of this file.
3 
4 namespace yap
5 {
7  : background_ ()
8  , tm_ (nullptr)
9  , resize_ (true)
10  , isInit (false)
11  , fixed_ (false)
12  {
13  }
14 
16  : background_ ()
17  , tm_ (nullptr)
18  , resize_ (resize)
19  , isInit (false)
20  , fixed_ (false)
21  {
23  }
24 
26  {
27  return false;
28  }
29 
31  {
32  return background_.GetSize ();
33  }
34  void WidgetBackground::SetFixed (bool state)
35  {
36  fixed_ = state;
37  }
38 
39 
41  {
42  }
43 
45  {
46  if (isInit)
47  {
48  if (resize_)
49  background_.Draw (context);
50  else
51  tm_->Draw (context);
52  }
53  }
54 
55  void WidgetBackground::HandleShow (bool isVisible)
56  {
57  }
58 
60  {
61  if (isInit)
62  {
63  if (resize_)
64  background_.Move (offset);
65  else
66  tm_->Move (offset);
67  }
68  }
69 
71  {
72  Vector2 base = background_.GetSize ();
73  Vector2 neo (base.x * factor.x, base.y * factor.y);
74 
75  if (isInit)
76  {
77  if (resize_)
78  background_.SetSize (neo);
79  else
80  tm_->SetSize (neo);
81  }
82  }
83 
85  {
86  }
87 
88  void WidgetBackground::HandleChangeColor (const sf::Color& color)
89  {
90  if (isInit)
91  {
92  if (resize_)
93  background_.ChangeColor (color);
94  else
95  tm_->ChangeColor (color);
96  }
97  }
98 
100  {
101  return fixed_;
102  }
103 
105  {
106  return background_;
107  }
108 
110  {
112  if (resize_)
113  background_.SetSize (size);
114  else
115  {
116  tm_ = new TextureManager (background_, size.x, size.y);
118  tm_->Init ();
119  }
121  isInit = true;
122  }
123 
125  , uint width
126  , uint height
127  , bool resize)
128  {
129  resize_ = resize;
130  background_.LoadFromFile (file);
132  if (resize)
133  background_.SetSize (Vector2 (width, height));
134  else
135  {
136  tm_ = new TextureManager (background_, width, height);
138  tm_->Init ();
139  }
141  isInit = true;
142  }
143 } //namespace yap