summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-07-08 17:32:26 -0600
committerJared Adams <jaxad0127@gmail.com>2009-07-08 17:37:52 -0600
commit6c68287a7a66ba6933bc4dbfe43f6c4761e683c1 (patch)
tree203960dfdebe15cffff9abd7089441ecbf1965cf
parent8963ef3e6d0ede6a3e22687642bbc39c24f21dad (diff)
downloadmana-6c68287a7a66ba6933bc4dbfe43f6c4761e683c1.tar.gz
mana-6c68287a7a66ba6933bc4dbfe43f6c4761e683c1.tar.bz2
mana-6c68287a7a66ba6933bc4dbfe43f6c4761e683c1.tar.xz
mana-6c68287a7a66ba6933bc4dbfe43f6c4761e683c1.zip
Have both builds use the same SkillDialog
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/Makefile.am6
-rw-r--r--src/game.cpp2
-rw-r--r--src/gui/skill.cpp300
-rw-r--r--src/gui/skill.h85
-rw-r--r--src/gui/skilldialog.cpp54
-rw-r--r--src/gui/skilldialog.h12
-rw-r--r--src/localplayer.cpp20
-rw-r--r--src/localplayer.h7
-rw-r--r--src/net/ea/generalhandler.cpp6
-rw-r--r--src/net/ea/playerhandler.cpp4
-rw-r--r--src/net/ea/protocol.h1
-rw-r--r--src/net/ea/skillhandler.cpp48
-rw-r--r--src/net/tmwserv/playerhandler.cpp1
-rw-r--r--tmw.cbp18
15 files changed, 121 insertions, 449 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a4594281..33f9e88c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -215,6 +215,8 @@ SET(SRCS
gui/shortcutcontainer.h
gui/shortcutwindow.cpp
gui/shortcutwindow.h
+ gui/skilldialog.cpp
+ gui/skilldialog.h
gui/skin.cpp
gui/skin.h
gui/speechbubble.cpp
@@ -418,8 +420,6 @@ SET(SRCS
)
SET(SRCS_EA
- gui/skill.cpp
- gui/skill.h
gui/status.cpp
gui/status.h
net/ea/gui/partytab.cpp
@@ -480,8 +480,6 @@ SET(SRCS_TMW
gui/quitdialog.h
gui/serverdialog.cpp
gui/serverdialog.h
- gui/skilldialog.cpp
- gui/skilldialog.h
gui/statuswindow.cpp
gui/statuswindow.h
gui/unregisterdialog.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 3637dc9f..bc6d7184 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -164,6 +164,8 @@ tmw_SOURCES = gui/widgets/avatar.cpp \
gui/shortcutcontainer.h \
gui/shortcutwindow.cpp \
gui/shortcutwindow.h \
+ gui/skilldialog.cpp \
+ gui/skilldialog.h \
gui/skin.cpp \
gui/skin.h \
gui/speechbubble.cpp \
@@ -384,8 +386,6 @@ tmw_SOURCES += \
gui/quitdialog.h \
gui/serverdialog.cpp \
gui/serverdialog.h \
- gui/skilldialog.cpp \
- gui/skilldialog.h \
gui/statuswindow.cpp \
gui/statuswindow.h \
gui/unregisterdialog.cpp \
@@ -460,8 +460,6 @@ endif
if SERVER_EATHENA
tmw_CXXFLAGS += -DEATHENA_SUPPORT
tmw_SOURCES += \
- gui/skill.cpp \
- gui/skill.h \
gui/status.cpp \
gui/status.h \
net/ea/gui/partytab.cpp \
diff --git a/src/game.cpp b/src/game.cpp
index 5d15c779..306d8812 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -62,7 +62,7 @@
#include "gui/sdlinput.h"
#include "gui/sell.h"
#include "gui/setup.h"
-#include "gui/skill.h"
+#include "gui/skilldialog.h"
#include "gui/status.h"
#include "gui/trade.h"
#include "gui/viewport.h"
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp
deleted file mode 100644
index 7698098c..00000000
--- a/src/gui/skill.cpp
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "gui/skill.h"
-
-#include "gui/table.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/listbox.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/windowcontainer.h"
-
-#include "localplayer.h"
-#include "log.h"
-
-#include "net/net.h"
-#include "net/skillhandler.h"
-
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-#include "utils/xml.h"
-
-static const char *SKILLS_FILE = "skills.xml";
-
-struct SkillInfo
-{
- std::string name;
- bool modifiable;
-};
-
-static const SkillInfo fakeSkillInfo = {
- _("Mystery Skill"),
- false
-};
-
-std::vector<SkillInfo> skill_db;
-
-static void initSkillinfo();
-
-class SkillGuiTableModel : public StaticTableModel
-{
-public:
- SkillGuiTableModel(SkillDialog *dialog) :
- StaticTableModel(0, 3)
- {
- mEntriesNr = 0;
- mDialog = dialog;
- update();
- }
-
- virtual int getRows() const
- {
- return mEntriesNr;
- }
-
- virtual int getColumnWidth(int index) const
- {
- if (index == 0)
- return 160;
-
- return 35;
- }
-
- virtual int getRowHeight() const
- {
- return 12;
- }
-
- virtual void update()
- {
- mEntriesNr = mDialog->getSkills().size();
- resize();
-
- for (int i = 0; i < mEntriesNr; i++)
- {
- SKILL *skill = mDialog->getSkills()[i];
- SkillInfo const *info;
- char tmp[128];
-
- if (skill->id >= 0
- && (unsigned int) skill->id < skill_db.size())
- info = &skill_db[skill->id];
- else
- info = &fakeSkillInfo;
-
- sprintf(tmp, "%c%s", info->modifiable? ' ' : '*', info->name.c_str());
- gcn::Label *name_label = new Label(tmp);
-
- sprintf(tmp, "Lv:%i", skill->lv);
- gcn::Label *lv_label = new Label(tmp);
-
- sprintf(tmp, "Sp:%i", skill->sp);
- gcn::Label *sp_label = new Label(tmp);
-
- set(i, 0, name_label);
- set(i, 1, lv_label);
- set(i, 2, sp_label);
- }
- }
-
-private:
- SkillDialog *mDialog;
- int mEntriesNr;
-};
-
-
-SkillDialog::SkillDialog():
- Window(_("Skills"))
-{
- initSkillinfo();
- mTableModel = new SkillGuiTableModel(this);
- mTable = new GuiTable(mTableModel);
- mTable->setOpaque(false);
- mTable->setLinewiseSelection(true);
- mTable->setWrappingEnabled(true);
- mTable->setActionEventId("skill");
- mTable->addActionListener(this);
-
- setWindowName("Skills");
- setCloseButton(true);
- setDefaultSize(255, 260, ImageRect::CENTER);
-
- setMinHeight(50 + mTableModel->getHeight());
- setMinWidth(200);
-
- ScrollArea *skillScrollArea = new ScrollArea(mTable);
- mPointsLabel = new Label(strprintf(_("Skill points: %d"), 0));
- mIncButton = new Button(_("Up"), "inc", this);
- mUseButton = new Button(_("Use"), "use", this);
- mUseButton->setEnabled(false);
-
- skillScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
-
- place(0, 0, skillScrollArea, 5).setPadding(3);
- place(0, 1, mPointsLabel, 4);
- place(3, 2, mIncButton);
- place(4, 2, mUseButton);
-
- Layout &layout = getLayout();
- layout.setRowHeight(0, Layout::AUTO_SET);
-
- center();
- loadWindowState();
-}
-
-SkillDialog::~SkillDialog()
-{
- delete_all(mSkillList);
-}
-
-void SkillDialog::action(const gcn::ActionEvent &event)
-{
- if (event.getId() == "inc")
- {
- // Increment skill
- int selectedSkill = mTable->getSelectedRow();
- if (selectedSkill >= 0)
- Net::getSkillHandler()->up(mSkillList[selectedSkill]->id);
- }
- else if (event.getId() == "skill" && mTable->getSelectedRow() > -1)
- {
- SKILL *skill = mSkillList[mTable->getSelectedRow()];
- SkillInfo const *info;
-
- if (skill->id >= 0 && (unsigned int) skill->id < skill_db.size())
- info = &skill_db[skill->id];
- else
- info = &fakeSkillInfo;
-
- mIncButton->setEnabled(player_node->mSkillPoint > 0 &&
- info->modifiable);
- }
- else if (event.getId() == "close")
- setVisible(false);
-}
-
-void SkillDialog::update()
-{
- mPointsLabel->setCaption(strprintf(_("Skill points: %d"),
- player_node->mSkillPoint));
-
- int selectedSkill = mTable->getSelectedRow();
-
- if (selectedSkill >= 0)
- {
- int skillId = mSkillList[selectedSkill]->id;
- bool modifiable;
-
- if (skillId >= 0 && (unsigned int) skillId < skill_db.size())
- modifiable = skill_db[skillId].modifiable;
- else
- modifiable = false;
-
- mIncButton->setEnabled(modifiable
- && player_node->mSkillPoint > 0);
- }
- else
- mIncButton->setEnabled(false);
-
- mTableModel->update();
- setMinHeight(50 + mTableModel->getHeight());
-}
-
-int SkillDialog::getNumberOfElements()
-{
- return mSkillList.size();
-}
-
-bool SkillDialog::hasSkill(int id)
-{
- for (unsigned int i = 0; i < mSkillList.size(); i++)
- {
- if (mSkillList[i]->id == id)
- return true;
- }
- return false;
-}
-
-void SkillDialog::addSkill(int id, int lvl, int mp)
-{
- SKILL *tmp = new SKILL;
- tmp->id = id;
- tmp->lv = lvl;
- tmp->sp = mp;
- mSkillList.push_back(tmp);
-}
-
-void SkillDialog::setSkill(int id, int lvl, int mp)
-{
- for (unsigned int i = 0; i < mSkillList.size(); i++)
- {
- if (mSkillList[i]->id == id)
- {
- mSkillList[i]->lv = lvl;
- mSkillList[i]->sp = mp;
- }
- }
-}
-
-void SkillDialog::cleanList()
-{
- delete_all(mSkillList);
- mSkillList.clear();
-}
-
-static void initSkillinfo()
-{
- SkillInfo emptySkillInfo = { "", false };
-
- XML::Document doc(SKILLS_FILE);
- xmlNodePtr root = doc.rootNode();
-
- if (!root || !xmlStrEqual(root->name, BAD_CAST "skills"))
- {
- logger->log("Error loading skills file: %s", SKILLS_FILE);
- skill_db.resize(2, emptySkillInfo);
- skill_db[1].name = "Basic";
- skill_db[1].modifiable = true;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlStrEqual(node->name, BAD_CAST "skill"))
- {
- int index = atoi(XML::getProperty(node, "id", "-1").c_str());
- std::string name = XML::getProperty(node, "name", "");
- bool modifiable = !atoi(XML::getProperty(node, "fixed", "0").c_str());
-
- if (index >= 0)
- {
- skill_db.resize(index + 1, emptySkillInfo);
- skill_db[index].name = name;
- skill_db[index].modifiable = modifiable;
- }
- }
- }
-}
-
diff --git a/src/gui/skill.h b/src/gui/skill.h
deleted file mode 100644
index 0879f7e1..00000000
--- a/src/gui/skill.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef SKILL_H
-#define SKILL_H
-
-#include "gui/widgets/window.h"
-
-#include <guichan/actionlistener.hpp>
-
-#include <vector>
-
-struct SKILL
-{
- short id; /**< Index into "skill_db" array */
- short lv, sp;
-};
-
-class GuiTable;
-class ScrollArea;
-class SkillGuiTableModel;
-
-/**
- * The skill dialog.
- *
- * \ingroup Interface
- */
-class SkillDialog : public Window, public gcn::ActionListener
-{
- public:
- /**
- * Constructor.
- */
- SkillDialog();
-
- /**
- * Destructor.
- */
- ~SkillDialog();
-
- void action(const gcn::ActionEvent &event);
-
- void update();
-
- int getNumberOfElements();
-
- bool hasSkill(int id);
- void addSkill(int id, int lv, int sp);
- void setSkill(int id, int lv, int sp);
- void cleanList();
-
- const std::vector<SKILL*>& getSkills() const { return mSkillList; }
-
- private:
- GuiTable *mTable;
- ScrollArea *skillScrollArea;
- SkillGuiTableModel *mTableModel;
- gcn::Label *mPointsLabel;
- gcn::Button *mIncButton;
- gcn::Button *mUseButton;
-
- std::vector<SKILL*> mSkillList;
-};
-
-extern SkillDialog *skillDialog;
-
-#endif
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index d9e2c5bb..3f5c8ca0 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -37,6 +37,9 @@
#include "localplayer.h"
#include "log.h"
+#include "net/net.h"
+#include "net/skillhandler.h"
+
#include "utils/dtor.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -65,12 +68,16 @@ class SkillEntry : public Container, gcn::WidgetListener
void update();
- private:
+ protected:
+ friend class SkillDialog;
struct SkillInfo *mInfo;
+
+ private:
Icon *mIcon;
Label *mNameLabel;
Label *mLevelLabel;
Label *mExpLabel;
+ Button *mIncrease;
ProgressBar *mProgress;
};
@@ -84,9 +91,10 @@ SkillDialog::SkillDialog():
setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425);
mTabs = new TabbedArea();
+ mPointsLabel = new Label("0");
place(0, 0, mTabs, 5, 5);
- place(0, 5, new Label("TODO"));
+ place(0, 5, mPointsLabel);
setLocationRelativeTo(getParent());
loadWindowState();
@@ -99,8 +107,12 @@ SkillDialog::~SkillDialog()
void SkillDialog::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "skill")
+ if (event.getId() == "inc")
{
+ SkillEntry *disp = dynamic_cast<SkillEntry*>(event.getSource()->getParent());
+
+ if (disp)
+ Net::getSkillHandler()->up(disp->mInfo->id);
}
else if (event.getId() == "close")
{
@@ -151,6 +163,19 @@ std::string SkillDialog::update(int id)
return "";
}
+void SkillDialog::update()
+{
+ mPointsLabel->setCaption(strprintf(_("Skill points available: %d"),
+ player_node->getSkillPoints()));
+ mPointsLabel->adjustSize();
+
+ for (SkillMap::iterator it = mSkills.begin(); it != mSkills.end(); it++)
+ {
+ if ((*it).second->modifiable)
+ (*it).second->display->update();
+ }
+}
+
void SkillDialog::loadSkills(const std::string &file, bool fixed)
{
// TODO: mTabs->clear();
@@ -211,12 +236,25 @@ void SkillDialog::loadSkills(const std::string &file, bool fixed)
}
adjustTabSize();
+ update();
+}
+
+void SkillDialog::setModifiable(int id, bool modifiable)
+{
+ SkillInfo *info = mSkills[id];
+
+ if (info)
+ {
+ info->modifiable = modifiable;
+ info->display->update();
+ }
}
SkillEntry::SkillEntry(struct SkillInfo *info) : mInfo(info),
mIcon(NULL),
mNameLabel(new Label(info->name)),
mProgress(new ProgressBar(0.0f, 200, 20, gcn::Color(150, 150, 150))),
+ mIncrease(new Button("+", "inc", skillDialog)),
mLevelLabel(new Label("999"))
{
setFrameSize(1);
@@ -242,6 +280,9 @@ SkillEntry::SkillEntry(struct SkillInfo *info) : mInfo(info),
mProgress->setPosition(35, 13);
add(mProgress);
+ mIncrease->setPosition(getWidth() - mIncrease->getWidth(), 13);
+ add(mIncrease);
+
update();
}
@@ -250,7 +291,8 @@ void SkillEntry::widgetResized(const gcn::Event &event)
gcn::Rectangle size = getChildrenArea();
mLevelLabel->setPosition(size.width - mLevelLabel->getWidth(), 0);
- mProgress->setWidth(size.width - 35);
+ mProgress->setWidth(size.width - mIncrease->getWidth() - 39);
+ mIncrease->setPosition(getWidth() - mIncrease->getWidth() - 2, 13);
}
void SkillEntry::update()
@@ -288,4 +330,8 @@ void SkillEntry::update()
int color = 150 - (int)(150 * ((float) exp.first / exp.second));
mProgress->setColor(244, color, color);
mProgress->setProgress((float) exp.first / exp.second);
+
+ mIncrease->setEnabled(mInfo->modifiable && player_node->getSkillPoints());
+
+ widgetResized(NULL);
}
diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h
index fbd3c26d..4a3f4f56 100644
--- a/src/gui/skilldialog.h
+++ b/src/gui/skilldialog.h
@@ -31,6 +31,7 @@
#include <list>
#include <map>
+class Label;
class ScrollArea;
class Tab;
class TabbedArea;
@@ -67,14 +68,23 @@ class SkillDialog : public Window, public gcn::ActionListener
*/
std::string update(int id);
+ /**
+ * Update other parts of the display
+ */
+ void update();
+
void loadSkills(const std::string &file, bool fixed = true);
+ void setModifiable(int id, bool modifiable);
+
private:
void adjustTabSize();
+ typedef std::map<int, SkillInfo*> SkillMap;
+ SkillMap mSkills;
Tab *mCurrentTab;
TabbedArea *mTabs;
- std::map<int, SkillInfo*> mSkills;
+ Label *mPointsLabel;
};
extern SkillDialog *skillDialog;
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 1c7f7a5a..5fdd29cd 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -39,11 +39,8 @@
#include "gui/gui.h"
#include "gui/ministatus.h"
#include "gui/palette.h"
-#ifdef EATHENA_SUPPORT
-#include "gui/storagewindow.h"
-#else
#include "gui/skilldialog.h"
-#endif
+#include "gui/storagewindow.h"
#include "net/inventoryhandler.h"
#include "net/net.h"
@@ -93,10 +90,10 @@ LocalPlayer::LocalPlayer(int id, int job, Map *map):
mJobLevel(0),
mXpForNextLevel(0), mJobXpForNextLevel(0),
mMp(0), mMaxMp(0),
+ mSkillPoints(0),
mAttackRange(0),
ATK(0), MATK(0), DEF(0), MDEF(0), HIT(0), FLEE(0),
ATK_BONUS(0), MATK_BONUS(0), DEF_BONUS(0), MDEF_BONUS(0), FLEE_BONUS(0),
- mSkillPoint(0),
mEquipment(new Equipment),
#endif
mInStorage(false),
@@ -791,6 +788,8 @@ void LocalPlayer::lowerAttribute(size_t attr)
Net::GameServer::Player::lowerAttribute(attr + CHAR_ATTR_BEGIN);
}
+#endif
+
void LocalPlayer::setAttributeBase(int num, int value)
{
int old = mAttributeBase[num];
@@ -813,6 +812,13 @@ void LocalPlayer::setAttributeEffective(int num, int value)
skillDialog->update(num);
}
+void LocalPlayer::setSkillPoints(int points)
+{
+ mSkillPoints = points;
+ if (skillDialog)
+ skillDialog->update();
+}
+
void LocalPlayer::setExperience(int skill, int current, int next)
{
std::pair<int, int> cur = getExperience(skill);
@@ -825,11 +831,13 @@ void LocalPlayer::setExperience(int skill, int current, int next)
if (skillDialog)
name = skillDialog->update(skill);
+#ifdef TMWSERV_SUPPORT
if (mMap && cur.first != -1 && diff > 0 && !name.empty())
{
const std::string text = strprintf("%d %s xp", diff, name.c_str());
mExpMessages.push_back(text);
}
+#endif
}
std::pair<int, int> LocalPlayer::getExperience(int skill)
@@ -837,8 +845,6 @@ std::pair<int, int> LocalPlayer::getExperience(int skill)
return mSkillExp[skill];
}
-#endif
-
void LocalPlayer::setLevelProgress(int percent)
{
if (mMap && percent > percent)
diff --git a/src/localplayer.h b/src/localplayer.h
index 50dfbc98..c1ceaf37 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -295,7 +295,6 @@ class LocalPlayer : public Player
int ATK, MATK, DEF, MDEF, HIT, FLEE;
int ATK_BONUS, MATK_BONUS, DEF_BONUS, MDEF_BONUS, FLEE_BONUS;
- Uint16 mSkillPoint;
#endif
int getHp() const
@@ -361,6 +360,11 @@ class LocalPlayer : public Player
void setCorrectionPoints(int n)
{ mCorrectionPoints = n; }
+ int getSkillPoints() const
+ { return mSkillPoints; }
+
+ void setSkillPoints(int points);
+
void setExperience(int skill, int current, int next);
std::pair<int, int> getExperience(int skill);
@@ -395,6 +399,7 @@ class LocalPlayer : public Player
int mMaxWeight;
int mHp;
int mMaxHp;
+ int mSkillPoints;
int mGMLevel;
diff --git a/src/net/ea/generalhandler.cpp b/src/net/ea/generalhandler.cpp
index 404bff69..959e7632 100644
--- a/src/net/ea/generalhandler.cpp
+++ b/src/net/ea/generalhandler.cpp
@@ -19,10 +19,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "gui/inventorywindow.h"
-
#include "net/ea/generalhandler.h"
+#include "gui/inventorywindow.h"
+#include "gui/skilldialog.h"
+
#include "net/ea/network.h"
#include "net/ea/protocol.h"
@@ -201,6 +202,7 @@ void GeneralHandler::guiWindowsLoaded()
{
partyTab = new PartyTab;
inventoryWindow->setSplitAllowed(false);
+ skillDialog->loadSkills("ea-skills.xml");
}
void GeneralHandler::guiWindowsUnloaded()
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 40cfc71c..07b738ee 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -37,7 +37,6 @@
#include "gui/gui.h"
#include "gui/okdialog.h"
#include "gui/sell.h"
-#include "gui/skill.h"
#include "gui/storagewindow.h"
#include "gui/viewport.h"
@@ -233,8 +232,7 @@ void PlayerHandler::handleMessage(MessageIn &msg)
break;
case 0x000b: player_node->setLevel(value); break;
case 0x000c:
- player_node->mSkillPoint = value;
- skillDialog->update();
+ player_node->setSkillPoints(value);
break;
case 0x0018:
if (value >= player_node->getMaxWeight() / 2 &&
diff --git a/src/net/ea/protocol.h b/src/net/ea/protocol.h
index b3759946..ce8417bf 100644
--- a/src/net/ea/protocol.h
+++ b/src/net/ea/protocol.h
@@ -69,6 +69,7 @@ static const int STORAGE_OFFSET = 1;
#define SMSG_PLAYER_ARROW_EQUIP 0x013c
#define SMSG_PLAYER_ARROW_MESSAGE 0x013b
#define SMSG_PLAYER_SKILLS 0x010f
+#define SMSG_PLAYER_SKILL_UP 0x010e
#define SMSG_SKILL_FAILED 0x0110
#define SMSG_ITEM_USE_RESPONSE 0x00a8
#define SMSG_ITEM_VISIBLE 0x009d /**< An item is on the floor */
diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp
index 69b0fd65..9fb4e566 100644
--- a/src/net/ea/skillhandler.cpp
+++ b/src/net/ea/skillhandler.cpp
@@ -29,7 +29,7 @@
#include "localplayer.h"
#include "log.h"
-#include "gui/skill.h"
+#include "gui/skilldialog.h"
#include "gui/widgets/chattab.h"
@@ -76,6 +76,7 @@ SkillHandler::SkillHandler()
static const Uint16 _messages[] = {
SMSG_PLAYER_SKILLS,
SMSG_SKILL_FAILED,
+ SMSG_PLAYER_SKILL_UP,
0
};
handledMessages = _messages;
@@ -85,42 +86,49 @@ SkillHandler::SkillHandler()
void SkillHandler::handleMessage(MessageIn &msg)
{
int skillCount;
+ int skillId;
switch (msg.getId())
{
case SMSG_PLAYER_SKILLS:
msg.readInt16(); // length
skillCount = (msg.getLength() - 4) / 37;
- skillDialog->cleanList();
for (int k = 0; k < skillCount; k++)
{
- int skillId = msg.readInt16();
+ skillId = msg.readInt16();
msg.readInt16(); // target type
- msg.readInt16(); // unknown
+ msg.skip(2); // unused
int level = msg.readInt16();
int sp = msg.readInt16();
- msg.readInt16(); // range
- std::string skillName = msg.readString(24);
+ int range = msg.readInt16();
+ msg.skip(24); // unused
int up = msg.readInt8();
- if (level != 0 || up != 0)
- {
- if (skillDialog->hasSkill(skillId)) {
- skillDialog->setSkill(skillId, level, sp);
- }
- else {
- skillDialog->addSkill(skillId, level, sp);
- }
- }
+ player_node->setAttributeBase(skillId, level);
+ player_node->setAttributeEffective(skillId, level);
+ skillDialog->setModifiable(skillId, up);
+ }
+ break;
+
+ case SMSG_PLAYER_SKILL_UP:
+ {
+ skillId = msg.readInt16();
+ int level = msg.readInt16();
+ int sp = msg.readInt16();
+ int range = msg.readInt16();
+ int up = msg.readInt8();
+
+ player_node->setAttributeBase(skillId, level);
+ player_node->setAttributeEffective(skillId, level);
+ skillDialog->setModifiable(skillId, up);
}
- skillDialog->update();
break;
case SMSG_SKILL_FAILED:
// Action failed (ex. sit because you have not reached the
// right level)
- short skill = msg.readInt16();
+ skillId = msg.readInt16();
short bskill = msg.readInt16();
msg.readInt16(); // unknown
char success = msg.readInt8();
@@ -131,7 +139,7 @@ void SkillHandler::handleMessage(MessageIn &msg)
}
std::string msg;
- if (success == SKILL_FAILED && skill == SKILL_BASIC)
+ if (success == SKILL_FAILED && skillId == SKILL_BASIC)
{
switch (bskill)
{
@@ -196,7 +204,7 @@ void SkillHandler::handleMessage(MessageIn &msg)
}
else
{
- switch (skill)
+ switch (skillId)
{
case SKILL_WARP :
msg = _("Warp failed...");
@@ -217,7 +225,7 @@ void SkillHandler::handleMessage(MessageIn &msg)
void SkillHandler::up(int skillId)
{
- if (player_node->mSkillPoint <= 0)
+ if (player_node->getSkillPoints() <= 0)
return;
MessageOut outMsg(CMSG_SKILL_LEVELUP_REQUEST);
diff --git a/src/net/tmwserv/playerhandler.cpp b/src/net/tmwserv/playerhandler.cpp
index bbce3ae1..825da8a4 100644
--- a/src/net/tmwserv/playerhandler.cpp
+++ b/src/net/tmwserv/playerhandler.cpp
@@ -43,7 +43,6 @@
#include "gui/gui.h"
#include "gui/okdialog.h"
#include "gui/sell.h"
-#include "gui/skill.h"
#include "gui/viewport.h"
// TODO Move somewhere else
diff --git a/tmw.cbp b/tmw.cbp
index 718b51f8..0eaf8402 100644
--- a/tmw.cbp
+++ b/tmw.cbp
@@ -349,22 +349,8 @@
<Unit filename="src/gui/shortcutcontainer.h" />
<Unit filename="src/gui/shortcutwindow.cpp" />
<Unit filename="src/gui/shortcutwindow.h" />
- <Unit filename="src/gui/skill.cpp">
- <Option target="eAthena" />
- <Option target="UNIX eAthena" />
- </Unit>
- <Unit filename="src/gui/skill.h">
- <Option target="eAthena" />
- <Option target="UNIX eAthena" />
- </Unit>
- <Unit filename="src/gui/skilldialog.cpp">
- <Option target="TMWServ" />
- <Option target="Unix TMWSERV" />
- </Unit>
- <Unit filename="src/gui/skilldialog.h">
- <Option target="TMWServ" />
- <Option target="Unix TMWSERV" />
- </Unit>
+ <Unit filename="src/gui/skilldialog.cpp" />
+ <Unit filename="src/gui/skilldialog.h" />
<Unit filename="src/gui/skin.cpp" />
<Unit filename="src/gui/skin.h" />
<Unit filename="src/gui/speechbubble.cpp" />