YAPOG  0.0.1
Yet Another Pokemon Online Game
MenuItem.cpp
Go to the documentation of this file.
1 #include <SFML/Graphics/Text.hpp>
2 
7 
8 namespace yap
9 {
11  : label_ ("")
12  , isScalable_ (false)
13  {
15  }
16 
17  MenuItem::MenuItem (bool isScalable)
18  : label_ ("")
19  , isScalable_ (isScalable)
20  {
22  }
23 
25  {
26  }
27 
29  {
30  /* if (!isScalable_)
31  label_.SetPosition (GetPosition ()
32  + Vector2 (GetUserSize ().x / 2 - label_.GetSize ().x / 2 + 7,
33  GetUserSize ().y / 2
34  - label_.GetSize ().y / 2 + label_.GetCharHeight ()));
35  else
36  {*/
38  ((border_ != nullptr) ? border_->GetSize () : Vector2 ()));
39  // }
41  }
42 
43  void MenuItem::Do ()
44  {
45 
46  }
47 
49  {
50  return label_.GetText ();
51  }
52 
54  {
55  label_.SetText (content);
56  Refresh ();
57  }
58 
59  bool MenuItem::IsFocusable () const
60  {
61  return false;
62  }
63 
65  {
66  Vector2 result;
67  if (!isScalable_)
68  result = GetUserSize ()
69  + ((border_ != nullptr) ? border_->GetSize () : Vector2 ());
70  else
71  result = label_.GetSize ()
72  + ((border_ != nullptr) ? border_->GetSize () : Vector2 ());
73  return result;
74  }
75 
77  {
78  label_.Draw (context);
79  }
80 
81  void MenuItem::HandleShow (bool isVisible)
82  {
83  }
84 
85  void MenuItem::HandleMove (const Vector2& offset)
86  {
87  label_.Move (offset);
88  }
89 
90  void MenuItem::HandleScale (const Vector2& factor)
91  {
92  label_.Scale (factor);
93  }
94 
95  void MenuItem::HandleUpdate (const Time& dt)
96  {
97  label_.Update (dt);
98  }
99 
100  void MenuItem::HandleChangeColor (const sf::Color& color)
101  {
102  label_.ChangeColor (color);
103  }
104 } // namespace yap