YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
MapPlayerInfoPanel.cpp
Go to the documentation of this file.
1
#include "
Gui/MapPlayerInfoPanel.hpp
"
2
3
#include "
YAPOG/Graphics/Gui/Label.hpp
"
4
#include "
YAPOG/Graphics/Gui/Game/World/GameWorldGuiManager.hpp
"
5
#include "
YAPOG/Graphics/ICamera.hpp
"
6
7
#include "World/Map/Player.hpp"
8
9
namespace
ycl
10
{
11
MapPlayerInfoPanel::MapPlayerInfoPanel
()
12
: yap::GameWorldWidget ()
13
, player_ (nullptr)
14
, playerNameLabel_ (nullptr)
15
{
16
}
17
18
MapPlayerInfoPanel::~MapPlayerInfoPanel
()
19
{
20
}
21
22
void
MapPlayerInfoPanel::Init
(
Player
& player)
23
{
24
player_
= &player;
25
26
playerNameLabel_
=
new
yap::Label
(player.
GetName
());
27
playerNameLabel_
->
SetTextSize
(12);
28
AddChild
(*
playerNameLabel_
);
29
30
player.
OnMoved
+= [
this
] (
31
yap::DynamicWorldObject
& sender,
32
const
yap::Vector2
& args)
33
{
34
UpdateLabel
(sender.
GetPosition
());
35
};
36
}
37
38
void
MapPlayerInfoPanel::HandleSetGameWorldParent
(
39
const
GameWorldWidget& gameWorldParent)
40
{
41
GameWorldWidget::HandleSetGameWorldParent
(gameWorldParent);
42
43
GetGameWorldRoot
().
GetWorldCamera
().
OnMovedEvent
() += [
this
] (
44
yap::ICamera
& sender,
45
const
yap::Vector2
& args)
46
{
47
UpdateLabel
(
player_
->
GetPosition
());
48
};
49
}
50
52
void
MapPlayerInfoPanel::UpdateLabel
(
const
yap::Vector2
& position)
53
{
54
playerNameLabel_
->
SetPosition
(
55
GetGameWorldRoot
().WorldPointToGuiPoint (
56
yap::Vector3
(
57
position.x -
playerNameLabel_
->
GetSize
().x / 2.0f + 16.0f,
58
position.y - 24.0f,
59
0.0f)));
60
}
61
}
// namespace ycl
YAPOG.Client
src
Gui
MapPlayerInfoPanel.cpp
Generated on Mon Sep 17 2012 22:24:22 for YAPOG by
1.8.1.1