summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-06-22 01:03:43 +0300
committerAndrei Karas <akaras@inbox.ru>2011-06-22 01:03:43 +0300
commite1e0f38ec31e38cd168a0892b922ce96ef674c33 (patch)
tree36273389e98ec5a7e0a1d225fc0bb4f99c37cfcf
parent7853eb16365a02969d08730c2688dfbb7811ef82 (diff)
downloadmv-e1e0f38ec31e38cd168a0892b922ce96ef674c33.tar.gz
mv-e1e0f38ec31e38cd168a0892b922ce96ef674c33.tar.bz2
mv-e1e0f38ec31e38cd168a0892b922ce96ef674c33.tar.xz
mv-e1e0f38ec31e38cd168a0892b922ce96ef674c33.zip
Add to skills dialog tools tips with skill name and id.
-rw-r--r--src/gui/skilldialog.cpp43
-rw-r--r--src/gui/skilldialog.h4
2 files changed, 39 insertions, 8 deletions
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 14e245ae1..57f8a4fc8 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -27,7 +27,9 @@
#include "configuration.h"
#include "gui/setup.h"
+#include "gui/textpopup.h"
#include "gui/theme.h"
+#include "gui/viewport.h"
#include "gui/widgets/button.h"
#include "gui/widgets/container.h"
@@ -65,6 +67,7 @@ struct SkillInfo
{
unsigned short id;
std::string name;
+ std::string dispName;
Image *icon;
bool modifiable;
bool visible;
@@ -78,9 +81,9 @@ struct SkillInfo
gcn::Color color;
SkillInfo() :
- id(0), name(""), icon(0), modifiable(false), visible(false),
- model(0), skillLevel(""), skillLevelWidth(0), skillExp(""),
- progress(0.0f)
+ id(0), name(""), dispName(""), icon(0), modifiable(false),
+ visible(false), model(0), skillLevel(""), skillLevelWidth(0),
+ skillExp(""), progress(0.0f)
{
}
@@ -143,12 +146,13 @@ private:
SkillList mVisibleSkills;
};
-class SkillListBox : public ListBox
+class SkillListBox : public ListBox, public gcn::MouseListener
{
public:
SkillListBox(SkillModel *model):
ListBox(model),
- mModel(model)
+ mModel(model),
+ mPopup(new TextPopup())
{
}
@@ -156,6 +160,8 @@ public:
{
delete mModel;
mModel = 0;
+ delete mPopup;
+ mPopup = 0;
}
SkillInfo *getSelectedInfo()
@@ -208,8 +214,31 @@ public:
unsigned int getRowHeight() const
{ return 34; }
+ void mouseMoved(gcn::MouseEvent &event)
+ {
+ ListBox::mouseMoved(event);
+ if (!viewport)
+ return;
+
+ int y = event.getY() / getRowHeight();
+ if (!mModel || y >= mModel->getNumberOfElements())
+ return;
+ SkillInfo *skill = mModel->getSkillAt(y);
+ if (!skill)
+ return;
+
+ mPopup->show(viewport->getMouseX(), viewport->getMouseY(),
+ skill->dispName);
+ }
+
+ void mouseExited(gcn::MouseEvent &event)
+ {
+ mPopup->hide();
+ }
+
private:
SkillModel *mModel;
+ TextPopup *mPopup;
};
class SkillTab : public Tab
@@ -347,6 +376,7 @@ void SkillDialog::loadSkills(const std::string &file)
SkillInfo *skill = new SkillInfo;
skill->id = 1;
skill->name = "basic";
+ skill->dispName = "Skill: basic, Id: 1";
skill->setIcon("");
skill->modifiable = true;
skill->visible = true;
@@ -398,6 +428,8 @@ void SkillDialog::loadSkills(const std::string &file)
SkillInfo *skill = new SkillInfo;
skill->id = static_cast<short unsigned>(id);
skill->name = name;
+ skill->dispName = strprintf("Skill: %s, Id: %d",
+ name.c_str(), skill->id);
skill->setIcon(icon);
skill->modifiable = false;
skill->visible = false;
@@ -452,6 +484,7 @@ void SkillDialog::addSkill(int id, int level, bool modifiable)
SkillInfo *skill = new SkillInfo;
skill->id = static_cast<short unsigned>(id);
skill->name = "Unknown skill Id: " + toString(id);
+ skill->dispName = "Unknown skill Id: " + toString(id);
skill->setIcon("");
skill->modifiable = modifiable;
skill->visible = false;
diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h
index 6897c35ac..af25ec508 100644
--- a/src/gui/skilldialog.h
+++ b/src/gui/skilldialog.h
@@ -27,10 +27,8 @@
#include "gui/widgets/window.h"
-//include "resources/image.h"
-//include "resources/resourcemanager.h"
-
#include <guichan/actionlistener.hpp>
+#include <guichan/mouselistener.hpp>
#include <map>