summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chatwindow.cpp3
-rw-r--r--src/gui/skilldialog.cpp63
-rw-r--r--src/gui/skilldialog.h5
-rw-r--r--src/gui/statuswindow.cpp38
4 files changed, 66 insertions, 43 deletions
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 705ef6e61..78ffde880 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -998,8 +998,7 @@ void ChatWindow::processEvent(Channels channel, const DepricatedEvent &event)
if (id == Net::getPlayerHandler()->getJobLocation())
{
const std::pair<int, int> exp
- = PlayerInfo::getStatExperience(
- static_cast<PlayerInfo::Attribute>(id));
+ = PlayerInfo::getStatExperience(id);
if (event.getInt("oldValue1") > exp.first
|| !event.getInt("oldValue2"))
{
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 053bcbd1b..ee248562a 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -277,6 +277,7 @@ SkillDialog::SkillDialog() :
setupWindow->registerWindowForReset(this);
mUseButton->setEnabled(false);
+ mIncreaseButton->setEnabled(false);
place(0, 0, mTabs, 5, 5);
place(0, 5, mPointsLabel, 4);
@@ -316,7 +317,7 @@ void SkillDialog::action(const gcn::ActionEvent &event)
if (const SkillInfo *const info = tab->getSelectedInfo())
{
mUseButton->setEnabled(info->range > 0);
-
+ mIncreaseButton->setEnabled(info->id < SKILL_VAR_MIN_ID);
const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < static_cast<int>(SHORTCUT_TABS)
&& itemShortcut[num])
@@ -328,6 +329,7 @@ void SkillDialog::action(const gcn::ActionEvent &event)
else
{
mUseButton->setEnabled(false);
+ mIncreaseButton->setEnabled(false);
}
}
}
@@ -471,14 +473,20 @@ void SkillDialog::loadSkills()
{
if (xmlNameEqual(node, "skill"))
{
- const int id = atoi(XML::getProperty(
- node, "id", "-1").c_str());
+ int id = XML::getIntProperty(node, "id", -1, -1, 1000000);
+ if (id == -1)
+ {
+ id = XML::getIntProperty(node, "var", -1, -1, 100000);
+ if (id == -1)
+ continue;
+ id += SKILL_VAR_MIN_ID;
+ }
SkillInfo *skill = getSkill(id);
if (!skill)
{
skill = new SkillInfo;
- skill->id = static_cast<short unsigned>(id);
+ skill->id = static_cast<unsigned int>(id);
skill->modifiable = false;
skill->visible = false;
skill->model = model;
@@ -497,8 +505,16 @@ void SkillDialog::loadSkills()
data->name = name;
data->setIcon(icon);
- data->dispName = strprintf("%s, %d",
- name.c_str(), skill->id);
+ if (skill->id < SKILL_VAR_MIN_ID)
+ {
+ data->dispName = strprintf("%s, %d",
+ name.c_str(), skill->id);
+ }
+ else
+ {
+ data->dispName = strprintf("%s, (%d)",
+ name.c_str(), skill->id - SKILL_VAR_MIN_ID);
+ }
data->shortName = XML::langProperty(node,
"shortName", name.substr(0, 3));
data->description = XML::langProperty(
@@ -558,7 +574,7 @@ void SkillDialog::addSkill(const int id, const int level, const int range,
if (mDefaultModel)
{
SkillInfo *const skill = new SkillInfo;
- skill->id = static_cast<short unsigned>(id);
+ skill->id = static_cast<unsigned int>(id);
skill->data->name = "Unknown skill Id: " + toString(id);
skill->data->dispName = "Unknown skill Id: " + toString(id);
skill->data->description.clear();
@@ -624,9 +640,31 @@ void SkillDialog::updateTabSelection()
if (tab)
{
if (const SkillInfo *const info = tab->getSelectedInfo())
+ {
mUseButton->setEnabled(info->range > 0);
+ mIncreaseButton->setEnabled(info->id < SKILL_VAR_MIN_ID);
+ }
else
+ {
mUseButton->setEnabled(false);
+ }
+ }
+}
+
+void SkillDialog::updateQuest(const int var, const int val)
+{
+ const int id = var + SKILL_VAR_MIN_ID;
+ const SkillMap::const_iterator it = mSkills.find(id);
+
+ if (it != mSkills.end())
+ {
+ SkillInfo *const info = it->second;
+ if (info)
+ {
+ PlayerInfo::setStatBase(id, val);
+ info->level = val;
+ info->update();
+ }
}
}
@@ -647,13 +685,9 @@ SkillInfo::~SkillInfo()
void SkillInfo::update()
{
- const int baseLevel = PlayerInfo::getStatBase(
- static_cast<PlayerInfo::Attribute>(id));
- const int effLevel = PlayerInfo::getStatEffective(
- static_cast<PlayerInfo::Attribute>(id));
-
- const std::pair<int, int> exp = PlayerInfo::getStatExperience(
- static_cast<PlayerInfo::Attribute>(id));
+ const int baseLevel = PlayerInfo::getStatBase(id);
+ const int effLevel = PlayerInfo::getStatEffective(id);
+ const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
if (!modifiable && baseLevel == 0 && effLevel == 0 && exp.second == 0)
{
@@ -663,7 +697,6 @@ void SkillInfo::update()
if (model)
model->updateVisibilities();
}
-
return;
}
diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h
index 396718310..cf2b518e2 100644
--- a/src/gui/skilldialog.h
+++ b/src/gui/skilldialog.h
@@ -32,6 +32,7 @@
#include <vector>
const int SKILL_MIN_ID = 200000;
+const int SKILL_VAR_MIN_ID = 1000000;
class Button;
class Label;
@@ -68,7 +69,7 @@ struct SkillInfo final
int level;
std::string skillLevel;
int skillLevelWidth;
- unsigned short id;
+ unsigned int id;
bool modifiable;
bool visible;
SkillModel *model;
@@ -145,6 +146,8 @@ class SkillDialog final : public Window, public gcn::ActionListener
void updateTabSelection();
+ void updateQuest(const int var, const int val);
+
private:
typedef std::map<int, SkillInfo*> SkillMap;
SkillMap mSkills;
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index 019d136d4..3e34b088d 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -373,12 +373,10 @@ void StatusWindow::processEvent(Channels channel A_UNUSED,
{
if (mJobLvlLabel)
{
- int lvl = PlayerInfo::getStatBase(
- static_cast<PlayerInfo::Attribute>(id));
-
+ int lvl = PlayerInfo::getStatBase(id);
const int oldExp = event.getInt("oldValue1");
- const std::pair<int, int> exp = PlayerInfo::getStatExperience(
- static_cast<PlayerInfo::Attribute>(id));
+ const std::pair<int, int> exp
+ = PlayerInfo::getStatExperience(id);
if (!lvl)
{
@@ -392,8 +390,7 @@ void StatusWindow::processEvent(Channels channel A_UNUSED,
{
lvl = (exp.second - 20000) / 150;
blocked = true;
- PlayerInfo::setStatBase(
- static_cast<PlayerInfo::Attribute>(id), lvl);
+ PlayerInfo::setStatBase(id, lvl);
blocked = false;
}
}
@@ -404,10 +401,8 @@ void StatusWindow::processEvent(Channels channel A_UNUSED,
lvl ++;
blocked = true;
PlayerInfo::setStatExperience(
- static_cast<PlayerInfo::Attribute>(id),
- exp.first, 20000 + lvl * 150);
- PlayerInfo::setStatBase(
- static_cast<PlayerInfo::Attribute>(id), lvl);
+ id, exp.first, 20000 + lvl * 150);
+ PlayerInfo::setStatBase(id, lvl);
blocked = false;
}
@@ -589,8 +584,7 @@ void StatusWindow::updateJobBar(ProgressBar *const bar, const bool percent)
void StatusWindow::updateProgressBar(ProgressBar *const bar, const int id,
const bool percent) const
{
- const std::pair<int, int> exp = PlayerInfo::getStatExperience(
- static_cast<PlayerInfo::Attribute>(id));
+ const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
updateProgressBar(bar, exp.first, exp.second, percent);
}
@@ -783,10 +777,8 @@ AttrDisplay::~AttrDisplay()
std::string AttrDisplay::update()
{
- const int base = PlayerInfo::getStatBase(
- static_cast<PlayerInfo::Attribute>(mId));
- const int bonus = PlayerInfo::getStatMod(
- static_cast<PlayerInfo::Attribute>(mId));
+ const int base = PlayerInfo::getStatBase(mId);
+ const int bonus = PlayerInfo::getStatMod(mId);
std::string value = toString(base + bonus);
if (bonus)
value += strprintf("=%d%+d", base, bonus);
@@ -872,10 +864,8 @@ void ChangeDisplay::action(const gcn::ActionEvent &event)
PlayerInfo::CHAR_POINTS) + 1;
PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, newpoints);
- const int newbase = PlayerInfo::getStatBase(
- static_cast<PlayerInfo::Attribute>(mId)) - 1;
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
- mId), newbase);
+ const int newbase = PlayerInfo::getStatBase(mId) - 1;
+ PlayerInfo::setStatBase(mId, newbase);
Net::getPlayerHandler()->decreaseAttribute(mId);
}
@@ -893,10 +883,8 @@ void ChangeDisplay::action(const gcn::ActionEvent &event)
PlayerInfo::CHAR_POINTS) - cnt;
PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, newpoints);
- const int newbase = PlayerInfo::getStatBase(
- static_cast<PlayerInfo::Attribute>(mId)) + cnt;
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
- mId), newbase);
+ const int newbase = PlayerInfo::getStatBase(mId) + cnt;
+ PlayerInfo::setStatBase(mId, newbase);
for (unsigned f = 0; f < mInc->getClickCount(); f ++)
{