YAPOG  0.0.1
Yet Another Pokemon Online Game
UpdateScreen.cpp
Go to the documentation of this file.
9 
11 
12 namespace ycl
13 {
15 
17  : BaseScreen (DEFAULT_NAME, context)
18  , lastlength_ (0)
19  , fc_ (nullptr)
20  , fileName_ ()
21  , backgroundbox_ (new yap::PictureBox ())
22  , foregroundbox_ (new yap::PictureBox ())
23  , filePercentage_ ()
24  , fileDownloaded_ ()
25  , totalFile_ ()
26  , firstLayout_ (new yap::HorizontalLayout (yap::Padding (5, 5, 5, 5),
27  yap::Padding (5, 5, 5, 5), false))
28  , secondLayout_ (new yap::HorizontalLayout (yap::Padding (5, 5, 5, 5),
29  yap::Padding (5, 10, 5, 5), false))
30  , bigLayout_ (new yap::VerticalLayout (yap::Padding (0, 0, 0, 0),
31  yap::Padding (0, 0, 0, 0), false))
32  {
33  firstLayout_->SetSize (yap::Vector2 (300, 75));
34  secondLayout_->SetSize (yap::Vector2 (300, 75));
35  bigLayout_->SetSize (yap::Vector2 (300, 150));
38  new yap::Sprite ("WindowSkins/BasicSkin/Global/BarContent.png"));
40  new yap::Sprite ("WindowSkins/BasicSkin/Global/Bar.png"));
41  }
42 
44  {
46 
47  yap::WidgetBackground* updaterBground =
49  "WindowSkins/BasicSkin/Global/WindowBackgroundTexture.png",
50  true);
51  yap::Texture* t = new yap::Texture ();
52  t->LoadFromFile ("WindowSkins/BasicSkin/Global/TopBorder.png");
53  yap::Texture* tr = new yap::Texture ();
54  tr->LoadFromFile ("WindowSkins/BasicSkin/Global/TopRightCorner.png");
55  yap::Texture* r = new yap::Texture ();
56  r->LoadFromFile ("WindowSkins/BasicSkin/Global/RightBorder.png");
57  yap::Texture* br = new yap::Texture ();
58  br->LoadFromFile ("WindowSkins/BasicSkin/Global/BottomRightCorner.png");
59  yap::Texture* b = new yap::Texture ();
60  b->LoadFromFile ("WindowSkins/BasicSkin/Global/BottomBorder.png");
61  yap::Texture* bl = new yap::Texture ();
62  bl->LoadFromFile ("WindowSkins/BasicSkin/Global/BottomLeftCorner.png");
63  yap::Texture* l = new yap::Texture ();
64  l->LoadFromFile ("WindowSkins/BasicSkin/Global/LeftBorder.png");
65  yap::Texture* tl = new yap::Texture ();
66  tl->LoadFromFile ("WindowSkins/BasicSkin/Global/TopLeftCorner.png");
67 
68  yap::WidgetBorder* updaterBorder =
69  new yap::WidgetBorder (*t, *tr, *r, *br, *b, *bl, *l, *tl, true);
70 
72  157,
73  21));
74  foregroundbox_->ChangeColor (sf::Color::Green);
76  foregroundbox_->Move (yap::Vector2 (7.f, 6.f));
77 
85  bigLayout_->SetBackground (*updaterBground);
86  bigLayout_->SetBorder (*updaterBorder);
88  }
89 
91  {
92  delete (foregroundbox_);
93  foregroundbox_ = nullptr;
94  delete (backgroundbox_);
95  backgroundbox_ = nullptr;
96  delete (firstLayout_);
97  firstLayout_ = nullptr;
98  delete (secondLayout_);
99  secondLayout_ = nullptr;
100  delete (bigLayout_);
101  bigLayout_ = nullptr;
102  }
103 
105  {
106  context_.SetTargetClearColor (sf::Color::White);
107 
108  boost::filesystem::path client (boost::filesystem::current_path());
109 
110  fc_ = new yap::FileChecker (client);
111 
112  boost::filesystem::path serv (boost::filesystem::current_path().string () + "/FileServer");
113  yap::FileChecker fs (serv);
114 
115  // List of name file needed to be download by the client
117 
118  // Network test
119  fc_->Launch (boost::filesystem::current_path().string () + "/FileServer");
120  }
121 
123  const yap::Time& dt,
124  yap::IDrawingContext& context)
125  {
126  Update ();
127 
128  BaseScreen::HandleRun (dt, context);
129  }
130 
132  {
133  float size = 144 * ((float)value / 100);
134 
136  size != 0 ? size : 1,
137  9.5f));
138  }
139 
141  {
143  if (!vf.IsEmpty ())
144  {
145  yap::UInt32 totalFile = vf.Count ();
146  yap::UInt32 size = fc_->GetSizeDownloaded ();
147  yap::String filesize = yap::StringHelper::ToString (size);
148  yap::UInt16 length = filesize.length ();
149 
150  if (!fc_->GetDlEnd ())
151  {
154  filePercentage_.SetText (filesize);
157  totalFile_.SetText ("/" +
158  yap::StringHelper::ToString (totalFile));
159  UpdateContentSize (size);
160  if (lastlength_ != length)
161  {
162  lastlength_ = length;
164  }
165  }
166  else
167  nextScreen_ = "Splash";
168  }
169  else
170  nextScreen_ = "Splash";
171  }
172 } // namespace ycl