summaryrefslogtreecommitdiff
path: root/src/gui/skilldialog.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-03-10 03:06:27 +0300
committerAndrei Karas <akaras@inbox.ru>2012-03-10 03:08:05 +0300
commit46cc993b30fe9a4da9175beb2795de91162c39fa (patch)
treebb50f135d38cda0188fb27648ec622fd4f157de6 /src/gui/skilldialog.cpp
parent9b80af87b10412a9732001979b76575b49ad4552 (diff)
downloadmv-46cc993b30fe9a4da9175beb2795de91162c39fa.tar.gz
mv-46cc993b30fe9a4da9175beb2795de91162c39fa.tar.bz2
mv-46cc993b30fe9a4da9175beb2795de91162c39fa.tar.xz
mv-46cc993b30fe9a4da9175beb2795de91162c39fa.zip
Add basic skill action use on target.
Diffstat (limited to 'src/gui/skilldialog.cpp')
-rw-r--r--src/gui/skilldialog.cpp44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 3cd3c7a16..d5af42aae 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -22,6 +22,7 @@
#include "gui/skilldialog.h"
+#include "localplayer.h"
#include "logger.h"
#include "playerinfo.h"
#include "configuration.h"
@@ -44,6 +45,7 @@
#include "net/net.h"
#include "net/playerhandler.h"
+#include "net/specialhandler.h"
#include "resources/image.h"
#include "resources/resourcemanager.h"
@@ -73,6 +75,7 @@ struct SkillInfo
bool visible;
SkillModel *model;
+ int level;
std::string skillLevel;
int skillLevelWidth;
@@ -83,8 +86,8 @@ struct SkillInfo
SkillInfo() :
id(0), name(""), dispName(""), icon(nullptr), modifiable(false),
- visible(false), model(nullptr), skillLevel(""), skillLevelWidth(0),
- skillExp(""), progress(0.0f), range(0)
+ visible(false), model(nullptr), level(0), skillLevel(""),
+ skillLevelWidth(0), skillExp(""), progress(0.0f), range(0)
{
}
@@ -286,11 +289,14 @@ SkillDialog::SkillDialog():
mTabs = new TabbedArea();
mPointsLabel = new Label("0");
+ mUseButton = new Button(_("Use"), "use", this);
+ mUseButton->setEnabled(false);
mIncreaseButton = new Button(_("Up"), "inc", this);
mDefaultModel = nullptr;
place(0, 0, mTabs, 5, 5);
place(0, 5, mPointsLabel, 4);
+ place(3, 5, mUseButton);
place(4, 5, mIncreaseButton);
setLocationRelativeTo(getParent());
@@ -314,6 +320,34 @@ void SkillDialog::action(const gcn::ActionEvent &event)
Net::getPlayerHandler()->increaseSkill(info->id);
}
}
+ else if (event.getId() == "sel")
+ {
+ SkillTab *tab = static_cast<SkillTab*>(mTabs->getSelectedTab());
+ if (tab)
+ {
+ if (SkillInfo *info = tab->getSelectedInfo())
+ mUseButton->setEnabled(info->range > 0);
+ else
+ mUseButton->setEnabled(false);
+ }
+ }
+ else if (event.getId() == "use")
+ {
+ SkillTab *tab = static_cast<SkillTab*>(mTabs->getSelectedTab());
+ if (tab)
+ {
+ const SkillInfo *info = tab->getSelectedInfo();
+ if (info && player_node && player_node->getTarget())
+ {
+ const Being *being = player_node->getTarget();
+ if (being)
+ {
+ Net::getSpecialHandler()->useBeing(info->level,
+ info->id, being->getId());
+ }
+ }
+ }
+ }
else if (event.getId() == "close")
{
setVisible(false);
@@ -397,6 +431,8 @@ void SkillDialog::loadSkills(const std::string &file)
model->updateVisibilities();
listbox = new SkillListBox(model);
+ listbox->setActionEventId("sel");
+ listbox->addActionListener(this);
scroll = new ScrollArea(listbox);
scroll->setOpaque(false);
scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
@@ -454,6 +490,8 @@ void SkillDialog::loadSkills(const std::string &file)
// possible leak listbox, scroll
listbox = new SkillListBox(model);
+ listbox->setActionEventId("sel");
+ listbox->addActionListener(this);
scroll = new ScrollArea(listbox);
scroll->setOpaque(false);
scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
@@ -498,6 +536,7 @@ void SkillDialog::addSkill(int id, int level, int range, bool modifiable)
skill->modifiable = modifiable;
skill->visible = false;
skill->model = mDefaultModel;
+ skill->level = level;
skill->skillLevel = strprintf(_("Lvl: %d"), level);
skill->range = range;
skill->update();
@@ -556,6 +595,7 @@ void SkillInfo::update()
else
skillLevel = strprintf(_("Lvl: %d"), baseLevel);
}
+ level = baseLevel;
skillLevelWidth = -1;
if (exp.second)