summaryrefslogtreecommitdiff
path: root/src/gui/widgets/characterdisplay.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets/characterdisplay.cpp')
-rw-r--r--src/gui/widgets/characterdisplay.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp
index 23a22fbbb..dba6be286 100644
--- a/src/gui/widgets/characterdisplay.cpp
+++ b/src/gui/widgets/characterdisplay.cpp
@@ -23,6 +23,7 @@
#include "gui/widgets/characterdisplay.h"
#include "gui/charselectdialog.h"
+#include "gui/textpopup.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
@@ -32,9 +33,12 @@
CharacterDisplay::CharacterDisplay(const Widget2 *const widget,
CharSelectDialog *const charSelectDialog) :
Container(widget),
+ gcn::MouseListener(),
+ gcn::WidgetListener(),
mCharacter(nullptr),
mPlayerBox(new PlayerBox(nullptr)),
- mName(new Label(this, "wwwwwwwwwwwwwwwwwwwwwwww"))
+ mName(new Label(this, "wwwwwwwwwwwwwwwwwwwwwwww")),
+ mPopup(new TextPopup)
{
mPlayerBox->setActionEventId("select");
mPlayerBox->addActionListener(charSelectDialog);
@@ -55,6 +59,14 @@ CharacterDisplay::CharacterDisplay(const Widget2 *const widget,
else
setWidth(80);
setHeight(120);
+ addMouseListener(this);
+ addWidgetListener(this);
+}
+
+CharacterDisplay::~CharacterDisplay()
+{
+ delete mPopup;
+ mPopup = nullptr;
}
void CharacterDisplay::setCharacter(Net::Character *const character)
@@ -84,3 +96,21 @@ void CharacterDisplay::update()
distributeResizedEvent();
}
+
+void CharacterDisplay::widgetHidden(const gcn::Event &event)
+{
+ mPopup->setVisible(false);
+}
+
+void CharacterDisplay::mouseExited(gcn::MouseEvent &event)
+{
+ mPopup->setVisible(false);
+}
+
+void CharacterDisplay::mouseMoved(gcn::MouseEvent &event)
+{
+ int mouseX = 0;
+ int mouseY = 0;
+ SDL_GetMouseState(&mouseX, &mouseY);
+ mPopup->show(mouseX, mouseY, mName->getCaption());
+}