From 5662b7d9ad9eb6927df7ca83713d3b6108f59ddc Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Tue, 7 Jul 2009 11:23:14 -0600 Subject: Use tmw-skills.xml instead of hardcoding --- tmw.cbp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tmw.cbp') diff --git a/tmw.cbp b/tmw.cbp index 8486f3ba..718b51f8 100644 --- a/tmw.cbp +++ b/tmw.cbp @@ -470,6 +470,8 @@ + + -- cgit v1.2.3-70-g09d2 From 6c68287a7a66ba6933bc4dbfe43f6c4761e683c1 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Wed, 8 Jul 2009 17:32:26 -0600 Subject: Have both builds use the same SkillDialog --- src/CMakeLists.txt | 6 +- src/Makefile.am | 6 +- src/game.cpp | 2 +- src/gui/skill.cpp | 300 -------------------------------------- src/gui/skill.h | 85 ----------- src/gui/skilldialog.cpp | 54 ++++++- src/gui/skilldialog.h | 12 +- src/localplayer.cpp | 20 ++- src/localplayer.h | 7 +- src/net/ea/generalhandler.cpp | 6 +- src/net/ea/playerhandler.cpp | 4 +- src/net/ea/protocol.h | 1 + src/net/ea/skillhandler.cpp | 48 +++--- src/net/tmwserv/playerhandler.cpp | 1 - tmw.cbp | 18 +-- 15 files changed, 121 insertions(+), 449 deletions(-) delete mode 100644 src/gui/skill.cpp delete mode 100644 src/gui/skill.h (limited to 'tmw.cbp') 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 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 - -#include - -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& getSkills() const { return mSkillList; } - - private: - GuiTable *mTable; - ScrollArea *skillScrollArea; - SkillGuiTableModel *mTableModel; - gcn::Label *mPointsLabel; - gcn::Button *mIncButton; - gcn::Button *mUseButton; - - std::vector 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(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 #include +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 SkillMap; + SkillMap mSkills; Tab *mCurrentTab; TabbedArea *mTabs; - std::map 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 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 LocalPlayer::getExperience(int skill) @@ -837,8 +845,6 @@ std::pair 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 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 @@ - - - - - - - - + + -- cgit v1.2.3-70-g09d2 From 6d3e53146ba15e4d90670db3067fa7f1a67034e1 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Mon, 13 Jul 2009 21:39:23 -0600 Subject: Rename Net::SkillHandler to Net::SpecialHandler SkillHandler::up moved to PlayerHandler::increaseSkill --- src/CMakeLists.txt | 10 +- src/Makefile.am | 10 +- src/gui/skilldialog.cpp | 4 +- src/localplayer.cpp | 1 - src/net/ea/generalhandler.cpp | 6 +- src/net/ea/generalhandler.h | 2 +- src/net/ea/playerhandler.cpp | 9 ++ src/net/ea/playerhandler.h | 2 + src/net/ea/skillhandler.cpp | 250 ------------------------------------- src/net/ea/skillhandler.h | 49 -------- src/net/ea/specialhandler.cpp | 246 ++++++++++++++++++++++++++++++++++++ src/net/ea/specialhandler.h | 49 ++++++++ src/net/net.cpp | 8 +- src/net/net.h | 4 +- src/net/playerhandler.h | 2 + src/net/skillhandler.h | 41 ------ src/net/specialhandler.h | 41 ++++++ src/net/tmwserv/playerhandler.cpp | 5 + src/net/tmwserv/playerhandler.h | 2 + src/net/tmwserv/skillhandler.cpp | 53 -------- src/net/tmwserv/skillhandler.h | 45 ------- src/net/tmwserv/specialhandler.cpp | 53 ++++++++ src/net/tmwserv/specialhandler.h | 45 +++++++ tmw.cbp | 10 +- 24 files changed, 481 insertions(+), 466 deletions(-) delete mode 100644 src/net/ea/skillhandler.cpp delete mode 100644 src/net/ea/skillhandler.h create mode 100644 src/net/ea/specialhandler.cpp create mode 100644 src/net/ea/specialhandler.h delete mode 100644 src/net/skillhandler.h create mode 100644 src/net/specialhandler.h delete mode 100644 src/net/tmwserv/skillhandler.cpp delete mode 100644 src/net/tmwserv/skillhandler.h create mode 100644 src/net/tmwserv/specialhandler.cpp create mode 100644 src/net/tmwserv/specialhandler.h (limited to 'tmw.cbp') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 33f9e88c..a3c817e1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -262,7 +262,7 @@ SET(SRCS net/partyhandler.h net/playerhandler.h net/serverinfo.h - net/skillhandler.h + net/specialhandler.h net/tradehandler.h resources/action.cpp resources/action.h @@ -457,8 +457,8 @@ SET(SRCS_EA net/ea/playerhandler.cpp net/ea/playerhandler.h net/ea/protocol.h - net/ea/skillhandler.cpp - net/ea/skillhandler.h + net/ea/specialhandler.cpp + net/ea/specialhandler.h net/ea/tradehandler.cpp net/ea/tradehandler.h ) @@ -543,8 +543,8 @@ SET(SRCS_TMW net/tmwserv/playerhandler.cpp net/tmwserv/playerhandler.h net/tmwserv/protocol.h - net/tmwserv/skillhandler.cpp - net/tmwserv/skillhandler.h + net/tmwserv/specialhandler.cpp + net/tmwserv/specialhandler.h net/tmwserv/tradehandler.cpp net/tmwserv/tradehandler.h guild.cpp diff --git a/src/Makefile.am b/src/Makefile.am index bc6d7184..03d37015 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -211,7 +211,7 @@ tmw_SOURCES = gui/widgets/avatar.cpp \ net/partyhandler.h \ net/playerhandler.h \ net/serverinfo.h \ - net/skillhandler.h \ + net/specialhandler.h \ net/tradehandler.h \ resources/action.cpp \ resources/action.h \ @@ -449,8 +449,8 @@ tmw_SOURCES += \ net/tmwserv/playerhandler.cpp \ net/tmwserv/playerhandler.h \ net/tmwserv/protocol.h \ - net/tmwserv/skillhandler.cpp \ - net/tmwserv/skillhandler.h \ + net/tmwserv/specialhandler.cpp \ + net/tmwserv/specialhandler.h \ net/tmwserv/tradehandler.cpp \ net/tmwserv/tradehandler.h \ guild.cpp \ @@ -497,8 +497,8 @@ tmw_SOURCES += \ net/ea/playerhandler.cpp \ net/ea/playerhandler.h \ net/ea/protocol.h \ - net/ea/skillhandler.cpp \ - net/ea/skillhandler.h \ + net/ea/specialhandler.cpp \ + net/ea/specialhandler.h \ net/ea/tradehandler.cpp \ net/ea/tradehandler.h endif diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index 8ed6b097..5e700387 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -38,7 +38,7 @@ #include "log.h" #include "net/net.h" -#include "net/skillhandler.h" +#include "net/playerhandler.h" #include "utils/dtor.h" #include "utils/gettext.h" @@ -112,7 +112,7 @@ void SkillDialog::action(const gcn::ActionEvent &event) SkillEntry *disp = dynamic_cast(event.getSource()->getParent()); if (disp) - Net::getSkillHandler()->up(disp->mInfo->id); + Net::getPlayerHandler()->increaseSkill(disp->mInfo->id); } else if (event.getId() == "close") { diff --git a/src/localplayer.cpp b/src/localplayer.cpp index fd0c0264..fac0d5d0 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -58,7 +58,6 @@ #include "net/tmwserv/chatserver/guild.h" #else #include "net/ea/partyhandler.h" -#include "net/ea/skillhandler.h" #endif #include "resources/animation.h" diff --git a/src/net/ea/generalhandler.cpp b/src/net/ea/generalhandler.cpp index 959e7632..8ff62d37 100644 --- a/src/net/ea/generalhandler.cpp +++ b/src/net/ea/generalhandler.cpp @@ -42,7 +42,7 @@ #include "net/ea/playerhandler.h" #include "net/ea/partyhandler.h" #include "net/ea/tradehandler.h" -#include "net/ea/skillhandler.h" +#include "net/ea/specialhandler.h" #include "net/ea/gui/partytab.h" @@ -78,7 +78,7 @@ GeneralHandler::GeneralHandler(): mNpcHandler(new NpcHandler), mPartyHandler(new PartyHandler), mPlayerHandler(new PlayerHandler), - mSkillHandler(new SkillHandler), + mSpecialHandler(new SpecialHandler), mTradeHandler(new TradeHandler) { static const Uint16 _messages[] = { @@ -158,7 +158,7 @@ void GeneralHandler::load() mNetwork->registerHandler(mMapHandler.get()); mNetwork->registerHandler(mNpcHandler.get()); mNetwork->registerHandler(mPlayerHandler.get()); - mNetwork->registerHandler(mSkillHandler.get()); + mNetwork->registerHandler(mSpecialHandler.get()); mNetwork->registerHandler(mTradeHandler.get()); mNetwork->registerHandler(mPartyHandler.get()); } diff --git a/src/net/ea/generalhandler.h b/src/net/ea/generalhandler.h index ebbc84ca..98364e5d 100644 --- a/src/net/ea/generalhandler.h +++ b/src/net/ea/generalhandler.h @@ -66,7 +66,7 @@ class GeneralHandler : public MessageHandler, public Net::GeneralHandler MessageHandlerPtr mNpcHandler; MessageHandlerPtr mPartyHandler; MessageHandlerPtr mPlayerHandler; - MessageHandlerPtr mSkillHandler; + MessageHandlerPtr mSpecialHandler; MessageHandlerPtr mTradeHandler; }; diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 07b738ee..9eecc445 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -469,6 +469,15 @@ void PlayerHandler::decreaseStat(LocalPlayer::Attribute attr) // Supported by eA? } +void PlayerHandler::increaseSkill(int skillId) +{ + if (player_node->getSkillPoints() <= 0) + return; + + MessageOut outMsg(CMSG_SKILL_LEVELUP_REQUEST); + outMsg.writeInt16(skillId); +} + void PlayerHandler::pickUp(FloorItem *floorItem) { MessageOut outMsg(CMSG_ITEM_PICKUP); diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h index 5dbc171b..dcf53f6f 100644 --- a/src/net/ea/playerhandler.h +++ b/src/net/ea/playerhandler.h @@ -43,6 +43,8 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler void decreaseStat(LocalPlayer::Attribute attr); + void increaseSkill(int skillId); + void pickUp(FloorItem *floorItem); void setDirection(char direction); diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp deleted file mode 100644 index 9fb4e566..00000000 --- a/src/net/ea/skillhandler.cpp +++ /dev/null @@ -1,250 +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 "net/ea/skillhandler.h" - -#include "net/ea/protocol.h" - -#include "net/messagein.h" -#include "net/messageout.h" - -#include "localplayer.h" -#include "log.h" - -#include "gui/skilldialog.h" - -#include "gui/widgets/chattab.h" - -#include "utils/gettext.h" - -/** job dependend identifiers (?) */ -#define SKILL_BASIC 0x0001 -#define SKILL_WARP 0x001b -#define SKILL_STEAL 0x0032 -#define SKILL_ENVENOM 0x0034 - -/** basic skills identifiers */ -#define BSKILL_TRADE 0x0000 -#define BSKILL_EMOTE 0x0001 -#define BSKILL_SIT 0x0002 -#define BSKILL_CREATECHAT 0x0003 -#define BSKILL_JOINPARTY 0x0004 -#define BSKILL_SHOUT 0x0005 -#define BSKILL_PK 0x0006 // ?? -#define BSKILL_SETALLIGN 0x0007 // ?? - -/** reasons why action failed */ -#define RFAIL_SKILLDEP 0x00 -#define RFAIL_INSUFHP 0x01 -#define RFAIL_INSUFSP 0x02 -#define RFAIL_NOMEMO 0x03 -#define RFAIL_SKILLDELAY 0x04 -#define RFAIL_ZENY 0x05 -#define RFAIL_WEAPON 0x06 -#define RFAIL_REDGEM 0x07 -#define RFAIL_BLUEGEM 0x08 -#define RFAIL_OVERWEIGHT 0x09 -#define RFAIL_GENERIC 0x0a - -/** should always be zero if failed */ -#define SKILL_FAILED 0x00 - -Net::SkillHandler *skillHandler; - -namespace EAthena { - -SkillHandler::SkillHandler() -{ - static const Uint16 _messages[] = { - SMSG_PLAYER_SKILLS, - SMSG_SKILL_FAILED, - SMSG_PLAYER_SKILL_UP, - 0 - }; - handledMessages = _messages; - skillHandler = this; -} - -void SkillHandler::handleMessage(MessageIn &msg) -{ - int skillCount; - int skillId; - - switch (msg.getId()) - { - case SMSG_PLAYER_SKILLS: - msg.readInt16(); // length - skillCount = (msg.getLength() - 4) / 37; - - for (int k = 0; k < skillCount; k++) - { - skillId = msg.readInt16(); - msg.readInt16(); // target type - msg.skip(2); // unused - int level = msg.readInt16(); - int sp = msg.readInt16(); - int range = msg.readInt16(); - msg.skip(24); // unused - int up = msg.readInt8(); - - 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); - } - break; - - case SMSG_SKILL_FAILED: - // Action failed (ex. sit because you have not reached the - // right level) - skillId = msg.readInt16(); - short bskill = msg.readInt16(); - msg.readInt16(); // unknown - char success = msg.readInt8(); - char reason = msg.readInt8(); - if (success != SKILL_FAILED && bskill == BSKILL_EMOTE) - { - logger->log("Action: %d/%d", bskill, success); - } - - std::string msg; - if (success == SKILL_FAILED && skillId == SKILL_BASIC) - { - switch (bskill) - { - case BSKILL_TRADE: - msg = _("Trade failed!"); - break; - case BSKILL_EMOTE: - msg = _("Emote failed!"); - break; - case BSKILL_SIT: - msg = _("Sit failed!"); - break; - case BSKILL_CREATECHAT: - msg = _("Chat creating failed!"); - break; - case BSKILL_JOINPARTY: - msg = _("Could not join party!"); - break; - case BSKILL_SHOUT: - msg = _("Cannot shout!"); - break; - } - - msg += " "; - - switch (reason) - { - case RFAIL_SKILLDEP: - msg += _("You have not yet reached a high enough lvl!"); - break; - case RFAIL_INSUFHP: - msg += _("Insufficient HP!"); - break; - case RFAIL_INSUFSP: - msg += _("Insufficient SP!"); - break; - case RFAIL_NOMEMO: - msg += _("You have no memos!"); - break; - case RFAIL_SKILLDELAY: - msg += _("You cannot do that right now!"); - break; - case RFAIL_ZENY: - msg += _("Seems you need more money... ;-)"); - break; - case RFAIL_WEAPON: - msg += _("You cannot use this skill with that kind of weapon!"); - break; - case RFAIL_REDGEM: - msg += _("You need another red gem!"); - break; - case RFAIL_BLUEGEM: - msg += _("You need another blue gem!"); - break; - case RFAIL_OVERWEIGHT: - msg += _("You're carrying to much to do this!"); - break; - default: - msg += _("Huh? What's that?"); - break; - } - } - else - { - switch (skillId) - { - case SKILL_WARP : - msg = _("Warp failed..."); - break; - case SKILL_STEAL : - msg = _("Could not steal anything..."); - break; - case SKILL_ENVENOM : - msg = _("Poison had no effect..."); - break; - } - } - - localChatTab->chatLog(msg); - break; - } -} - -void SkillHandler::up(int skillId) -{ - if (player_node->getSkillPoints() <= 0) - return; - - MessageOut outMsg(CMSG_SKILL_LEVELUP_REQUEST); - outMsg.writeInt16(skillId); -} - -void SkillHandler::use(int skillId, int level, int beingId) -{ - // TODO -} - -void SkillHandler::use(int skillId, int level, int x, int y) -{ - // TODO -} - -void SkillHandler::use(int skillId, const std::string &map) -{ - // TODO -} - -} // namespace EAthena diff --git a/src/net/ea/skillhandler.h b/src/net/ea/skillhandler.h deleted file mode 100644 index c1965213..00000000 --- a/src/net/ea/skillhandler.h +++ /dev/null @@ -1,49 +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 NET_EA_SKILLHANDLER_H -#define NET_EA_SKILLHANDLER_H - -#include "net/messagehandler.h" -#include "net/net.h" -#include "net/skillhandler.h" - -namespace EAthena { - -class SkillHandler : public MessageHandler, public Net::SkillHandler -{ - public: - SkillHandler(); - - void handleMessage(MessageIn &msg); - - void up(int skillId); - - void use(int skillId, int level, int beingId); - - void use(int skillId, int level, int x, int y); - - void use(int skillId, const std::string &map); -}; - -} // namespace EAthena - -#endif // NET_EA_SKILLHANDLER_H diff --git a/src/net/ea/specialhandler.cpp b/src/net/ea/specialhandler.cpp new file mode 100644 index 00000000..e75ed1bb --- /dev/null +++ b/src/net/ea/specialhandler.cpp @@ -0,0 +1,246 @@ +/* + * 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 "net/ea/specialhandler.h" + +#include "net/ea/protocol.h" + +#include "net/messagein.h" +#include "net/messageout.h" + +#include "localplayer.h" +#include "log.h" + +#include "gui/skilldialog.h" + +#include "gui/widgets/chattab.h" + +#include "utils/gettext.h" + +/** job dependend identifiers (?) */ +#define SKILL_BASIC 0x0001 +#define SKILL_WARP 0x001b +#define SKILL_STEAL 0x0032 +#define SKILL_ENVENOM 0x0034 + +/** basic skills identifiers */ +#define BSKILL_TRADE 0x0000 +#define BSKILL_EMOTE 0x0001 +#define BSKILL_SIT 0x0002 +#define BSKILL_CREATECHAT 0x0003 +#define BSKILL_JOINPARTY 0x0004 +#define BSKILL_SHOUT 0x0005 +#define BSKILL_PK 0x0006 // ?? +#define BSKILL_SETALLIGN 0x0007 // ?? + +/** reasons why action failed */ +#define RFAIL_SKILLDEP 0x00 +#define RFAIL_INSUFHP 0x01 +#define RFAIL_INSUFSP 0x02 +#define RFAIL_NOMEMO 0x03 +#define RFAIL_SKILLDELAY 0x04 +#define RFAIL_ZENY 0x05 +#define RFAIL_WEAPON 0x06 +#define RFAIL_REDGEM 0x07 +#define RFAIL_BLUEGEM 0x08 +#define RFAIL_OVERWEIGHT 0x09 +#define RFAIL_GENERIC 0x0a + +/** should always be zero if failed */ +#define SKILL_FAILED 0x00 + +Net::SpecialHandler *specialHandler; + +namespace EAthena { + +SpecialHandler::SpecialHandler() +{ + static const Uint16 _messages[] = { + SMSG_PLAYER_SKILLS, + SMSG_SKILL_FAILED, + SMSG_PLAYER_SKILL_UP, + 0 + }; + handledMessages = _messages; + specialHandler = this; +} + +void SpecialHandler::handleMessage(MessageIn &msg) +{ + int skillCount; + int skillId; + + switch (msg.getId()) + { + case SMSG_PLAYER_SKILLS: + msg.readInt16(); // length + skillCount = (msg.getLength() - 4) / 37; + + for (int k = 0; k < skillCount; k++) + { + skillId = msg.readInt16(); + msg.readInt16(); // target type + msg.skip(2); // unused + int level = msg.readInt16(); + int sp = msg.readInt16(); + int range = msg.readInt16(); + msg.skip(24); // unused + int up = msg.readInt8(); + + 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); + } + break; + + case SMSG_SKILL_FAILED: + // Action failed (ex. sit because you have not reached the + // right level) + skillId = msg.readInt16(); + short bskill = msg.readInt16(); + msg.readInt16(); // unknown + char success = msg.readInt8(); + char reason = msg.readInt8(); + if (success != SKILL_FAILED && bskill == BSKILL_EMOTE) + { + logger->log("Action: %d/%d", bskill, success); + } + + std::string msg; + if (success == SKILL_FAILED && skillId == SKILL_BASIC) + { + switch (bskill) + { + case BSKILL_TRADE: + msg = _("Trade failed!"); + break; + case BSKILL_EMOTE: + msg = _("Emote failed!"); + break; + case BSKILL_SIT: + msg = _("Sit failed!"); + break; + case BSKILL_CREATECHAT: + msg = _("Chat creating failed!"); + break; + case BSKILL_JOINPARTY: + msg = _("Could not join party!"); + break; + case BSKILL_SHOUT: + msg = _("Cannot shout!"); + break; + } + + msg += " "; + + switch (reason) + { + case RFAIL_SKILLDEP: + msg += _("You have not yet reached a high enough lvl!"); + break; + case RFAIL_INSUFHP: + msg += _("Insufficient HP!"); + break; + case RFAIL_INSUFSP: + msg += _("Insufficient SP!"); + break; + case RFAIL_NOMEMO: + msg += _("You have no memos!"); + break; + case RFAIL_SKILLDELAY: + msg += _("You cannot do that right now!"); + break; + case RFAIL_ZENY: + msg += _("Seems you need more money... ;-)"); + break; + case RFAIL_WEAPON: + msg += _("You cannot use this skill with that kind of weapon!"); + break; + case RFAIL_REDGEM: + msg += _("You need another red gem!"); + break; + case RFAIL_BLUEGEM: + msg += _("You need another blue gem!"); + break; + case RFAIL_OVERWEIGHT: + msg += _("You're carrying to much to do this!"); + break; + default: + msg += _("Huh? What's that?"); + break; + } + } + else + { + switch (skillId) + { + case SKILL_WARP : + msg = _("Warp failed..."); + break; + case SKILL_STEAL : + msg = _("Could not steal anything..."); + break; + case SKILL_ENVENOM : + msg = _("Poison had no effect..."); + break; + } + } + + localChatTab->chatLog(msg); + break; + } +} + +void SpecialHandler::use(int id) +{ + // TODO +} + +void SpecialHandler::use(int id, int level, int beingId) +{ + // TODO +} + +void SpecialHandler::use(int id, int level, int x, int y) +{ + // TODO +} + +void SpecialHandler::use(int id, const std::string &map) +{ + // TODO +} + +} // namespace EAthena diff --git a/src/net/ea/specialhandler.h b/src/net/ea/specialhandler.h new file mode 100644 index 00000000..eac53569 --- /dev/null +++ b/src/net/ea/specialhandler.h @@ -0,0 +1,49 @@ +/* + * 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 NET_EA_SKILLHANDLER_H +#define NET_EA_SKILLHANDLER_H + +#include "net/messagehandler.h" +#include "net/net.h" +#include "net/specialhandler.h" + +namespace EAthena { + +class SpecialHandler : public MessageHandler, public Net::SpecialHandler +{ + public: + SpecialHandler(); + + void handleMessage(MessageIn &msg); + + void use(int id); + + void use(int id, int level, int beingId); + + void use(int id, int level, int x, int y); + + void use(int id, const std::string &map); +}; + +} // namespace EAthena + +#endif // NET_EA_SKILLHANDLER_H diff --git a/src/net/net.cpp b/src/net/net.cpp index a329af1a..7df336c6 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -33,7 +33,7 @@ #include "net/npchandler.h" #include "net/partyhandler.h" #include "net/playerhandler.h" -#include "net/skillhandler.h" +#include "net/specialhandler.h" #include "net/tradehandler.h" extern Net::AdminHandler *adminHandler; @@ -47,7 +47,7 @@ extern Net::MapHandler *mapHandler; extern Net::NpcHandler *npcHandler; extern Net::PartyHandler *partyHandler; extern Net::PlayerHandler *playerHandler; -extern Net::SkillHandler *skillHandler; +extern Net::SpecialHandler *specialHandler; extern Net::TradeHandler *tradeHandler; Net::AdminHandler *Net::getAdminHandler() @@ -111,9 +111,9 @@ Net::PlayerHandler *Net::getPlayerHandler() return playerHandler; } -Net::SkillHandler *Net::getSkillHandler() +Net::SpecialHandler *Net::getSpecialHandler() { - return skillHandler; + return specialHandler; } Net::TradeHandler *Net::getTradeHandler() diff --git a/src/net/net.h b/src/net/net.h index 9154c1ef..1d91faa7 100644 --- a/src/net/net.h +++ b/src/net/net.h @@ -36,7 +36,7 @@ class MapHandler; class NpcHandler; class PartyHandler; class PlayerHandler; -class SkillHandler; +class SpecialHandler; class TradeHandler; AdminHandler *getAdminHandler(); @@ -51,7 +51,7 @@ MapHandler *getMapHandler(); NpcHandler *getNpcHandler(); PartyHandler *getPartyHandler(); PlayerHandler *getPlayerHandler(); -SkillHandler *getSkillHandler(); +SpecialHandler *getSpecialHandler(); TradeHandler *getTradeHandler(); } // namespace Net diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h index 163b48f3..9a185d9c 100644 --- a/src/net/playerhandler.h +++ b/src/net/playerhandler.h @@ -39,6 +39,8 @@ class PlayerHandler virtual void decreaseStat(LocalPlayer::Attribute attr) = 0; + virtual void increaseSkill(int skillId) = 0; + virtual void pickUp(FloorItem *floorItem) = 0; virtual void setDirection(char direction) = 0; diff --git a/src/net/skillhandler.h b/src/net/skillhandler.h deleted file mode 100644 index 9db6ac5b..00000000 --- a/src/net/skillhandler.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * The Mana World - * Copyright (C) 2009 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 SKILLHANDLER_H -#define SKILLHANDLER_H - -#include - -namespace Net { -class SkillHandler -{ - public: - virtual void up(int skillId) = 0; - - virtual void use(int skillId, int level, int beingId) = 0; - - virtual void use(int skillId, int level, int x, int y) = 0; - - virtual void use(int skillId, const std::string &map) = 0; -}; -} - -#endif // SKILLHANDLER_H diff --git a/src/net/specialhandler.h b/src/net/specialhandler.h new file mode 100644 index 00000000..602003aa --- /dev/null +++ b/src/net/specialhandler.h @@ -0,0 +1,41 @@ +/* + * The Mana World + * Copyright (C) 2009 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 SPECIALHANDLER_H +#define SPECIALHANDLER_H + +#include + +namespace Net { +class SpecialHandler +{ + public: + virtual void use(int id) = 0; + + virtual void use(int id, int level, int beingId) = 0; + + virtual void use(int id, int level, int x, int y) = 0; + + virtual void use(int id, const std::string &map) = 0; +}; +} + +#endif // SPECIALHANDLER_H diff --git a/src/net/tmwserv/playerhandler.cpp b/src/net/tmwserv/playerhandler.cpp index 6cf81496..fe1b821c 100644 --- a/src/net/tmwserv/playerhandler.cpp +++ b/src/net/tmwserv/playerhandler.cpp @@ -332,6 +332,11 @@ void PlayerHandler::decreaseStat(LocalPlayer::Attribute attr) // TODO } +void PlayerHandler::increaseSkill(int skillId) +{ + // Not used atm +} + void PlayerHandler::pickUp(FloorItem *floorItem) { int id = floorItem->getId(); diff --git a/src/net/tmwserv/playerhandler.h b/src/net/tmwserv/playerhandler.h index 164d30ae..88844a55 100644 --- a/src/net/tmwserv/playerhandler.h +++ b/src/net/tmwserv/playerhandler.h @@ -42,6 +42,8 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler void decreaseStat(LocalPlayer::Attribute attr); + void increaseSkill(int skillId); + void pickUp(FloorItem *floorItem); void setDirection(char direction); diff --git a/src/net/tmwserv/skillhandler.cpp b/src/net/tmwserv/skillhandler.cpp deleted file mode 100644 index e35b896a..00000000 --- a/src/net/tmwserv/skillhandler.cpp +++ /dev/null @@ -1,53 +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 "net/tmwserv/skillhandler.h" - -Net::SkillHandler *skillHandler; - -namespace TmwServ { - -SkillHandler::SkillHandler() -{ - skillHandler = this; -} - -void SkillHandler::up(int skillId) -{ - // TODO -} - -void SkillHandler::use(int skillId, int level, int beingId) -{ - // TODO -} - -void SkillHandler::use(int skillId, int level, int x, int y) -{ - // TODO -} - -void SkillHandler::use(int skillId, const std::string &map) -{ - // TODO -} - -} // namespace TmwServ diff --git a/src/net/tmwserv/skillhandler.h b/src/net/tmwserv/skillhandler.h deleted file mode 100644 index 8c459c4f..00000000 --- a/src/net/tmwserv/skillhandler.h +++ /dev/null @@ -1,45 +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 NET_TMWSERV_SKILLHANDLER_H -#define NET_TMWSERV_SKILLHANDLER_H - -#include "net/skillhandler.h" - -namespace TmwServ { - -class SkillHandler : public Net::SkillHandler -{ - public: - SkillHandler(); - - void up(int skillId); - - void use(int skillId, int level, int beingId); - - void use(int skillId, int level, int x, int y); - - void use(int skillId, const std::string &map); -}; - -} // namespace TmwServ - -#endif diff --git a/src/net/tmwserv/specialhandler.cpp b/src/net/tmwserv/specialhandler.cpp new file mode 100644 index 00000000..5be8272a --- /dev/null +++ b/src/net/tmwserv/specialhandler.cpp @@ -0,0 +1,53 @@ +/* + * 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 "net/tmwserv/specialhandler.h" + +Net::SpecialHandler *specialHandler; + +namespace TmwServ { + +SpecialHandler::SpecialHandler() +{ + specialHandler = this; +} + +void SpecialHandler::use(int id) +{ + // TODO +} + +void SpecialHandler::use(int id, int level, int beingId) +{ + // TODO +} + +void SpecialHandler::use(int id, int level, int x, int y) +{ + // TODO +} + +void SpecialHandler::use(int id, const std::string &map) +{ + // TODO +} + +} // namespace TmwServ diff --git a/src/net/tmwserv/specialhandler.h b/src/net/tmwserv/specialhandler.h new file mode 100644 index 00000000..c7ebd6a2 --- /dev/null +++ b/src/net/tmwserv/specialhandler.h @@ -0,0 +1,45 @@ +/* + * 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 NET_TMWSERV_SKILLHANDLER_H +#define NET_TMWSERV_SKILLHANDLER_H + +#include "net/specialhandler.h" + +namespace TmwServ { + +class SpecialHandler : public Net::SpecialHandler +{ + public: + SpecialHandler(); + + void use(int id); + + void use(int id, int level, int beingId); + + void use(int id, int level, int x, int y); + + void use(int id, const std::string &map); +}; + +} // namespace TmwServ + +#endif diff --git a/tmw.cbp b/tmw.cbp index 0eaf8402..a0616ec0 100644 --- a/tmw.cbp +++ b/tmw.cbp @@ -643,11 +643,11 @@ - + - + @@ -676,7 +676,7 @@ - + - + - + -- cgit v1.2.3-70-g09d2 From 5141dc4a99b74358f2dd0f5f211c5069a630ce1b Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sun, 19 Jul 2009 22:05:41 -0600 Subject: Merge StatusWindows Also some other small merges --- src/CMakeLists.txt | 6 +- src/Makefile.am | 6 +- src/game.cpp | 4 +- src/gui/charselectdialog.cpp | 6 +- src/gui/ministatus.cpp | 2 +- src/gui/status.cpp | 384 ------------------------- src/gui/status.h | 99 ------- src/gui/statuswindow.cpp | 568 +++++++++++++++++++++++++------------ src/gui/statuswindow.h | 79 +++--- src/localplayer.cpp | 97 +++++-- src/localplayer.h | 52 ++-- src/net/ea/charserverhandler.cpp | 15 +- src/net/ea/generalhandler.cpp | 6 +- src/net/ea/maphandler.cpp | 7 +- src/net/ea/playerhandler.cpp | 43 +-- src/net/ea/protocol.h | 9 +- src/net/tmwserv/generalhandler.cpp | 6 +- src/net/tmwserv/playerhandler.cpp | 2 +- tmw.cbp | 18 +- 19 files changed, 583 insertions(+), 826 deletions(-) delete mode 100644 src/gui/status.cpp delete mode 100644 src/gui/status.h (limited to 'tmw.cbp') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a3c817e1..15109185 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -221,6 +221,8 @@ SET(SRCS gui/skin.h gui/speechbubble.cpp gui/speechbubble.h + gui/statuswindow.cpp + gui/statuswindow.h gui/storagewindow.cpp gui/storagewindow.h gui/table.cpp @@ -420,8 +422,6 @@ SET(SRCS ) SET(SRCS_EA - gui/status.cpp - gui/status.h net/ea/gui/partytab.cpp net/ea/gui/partytab.h net/ea/adminhandler.cpp @@ -480,8 +480,6 @@ SET(SRCS_TMW gui/quitdialog.h gui/serverdialog.cpp gui/serverdialog.h - gui/statuswindow.cpp - gui/statuswindow.h gui/unregisterdialog.cpp gui/unregisterdialog.h net/tmwserv/accountserver/account.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 03d37015..ce00c1b9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -170,6 +170,8 @@ tmw_SOURCES = gui/widgets/avatar.cpp \ gui/skin.h \ gui/speechbubble.cpp \ gui/speechbubble.h \ + gui/statuswindow.cpp \ + gui/statuswindow.h \ gui/storagewindow.cpp \ gui/storagewindow.h \ gui/table.cpp \ @@ -386,8 +388,6 @@ tmw_SOURCES += \ gui/quitdialog.h \ gui/serverdialog.cpp \ gui/serverdialog.h \ - gui/statuswindow.cpp \ - gui/statuswindow.h \ gui/unregisterdialog.cpp \ gui/unregisterdialog.h \ net/tmwserv/accountserver/account.cpp \ @@ -460,8 +460,6 @@ endif if SERVER_EATHENA tmw_CXXFLAGS += -DEATHENA_SUPPORT tmw_SOURCES += \ - gui/status.cpp \ - gui/status.h \ net/ea/gui/partytab.cpp \ net/ea/gui/partytab.h \ net/ea/adminhandler.cpp \ diff --git a/src/game.cpp b/src/game.cpp index 306d8812..c7a1d4e7 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -63,7 +63,7 @@ #include "gui/sell.h" #include "gui/setup.h" #include "gui/skilldialog.h" -#include "gui/status.h" +#include "gui/statuswindow.h" #include "gui/trade.h" #include "gui/viewport.h" #include "gui/windowmenu.h" @@ -224,7 +224,7 @@ static void createGuiWindows() npcDialog = new NpcDialog; npcPostDialog = new NpcPostDialog; storageWindow = new StorageWindow; - statusWindow = new StatusWindow(); + statusWindow = new StatusWindow; miniStatusWindow = new MiniStatusWindow; inventoryWindow = new InventoryWindow; skillDialog = new SkillDialog; diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 03371271..1387bce5 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -36,6 +36,8 @@ #include "gui/changeemaildialog.h" #include "net/tmwserv/accountserver/account.h" +#else +#include "net/ea/protocol.h" #endif #include "gui/widgets/button.h" @@ -296,9 +298,9 @@ void CharSelectDialog::updatePlayerInfo() mNameLabel->setCaption(strprintf(_("Name: %s"), pi->getName().c_str())); mLevelLabel->setCaption(strprintf(_("Level: %d"), pi->getLevel())); -#ifndef TMWSERV_SUPPORT +#ifdef EATHENA_SUPPORT mJobLevelLabel->setCaption(strprintf(_("Job Level: %d"), - pi->mJobLevel)); + pi->getAttributeBase(JOB))); #endif mMoneyLabel->setCaption(strprintf(_("Money: %s"), mMoney.c_str())); if (!mCharSelected) diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index 65d2391d..8aaeb580 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -22,7 +22,7 @@ #include "gui/ministatus.h" #include "gui/gui.h" -#include "gui/status.h" +#include "gui/statuswindow.h" #include "gui/widgets/progressbar.h" diff --git a/src/gui/status.cpp b/src/gui/status.cpp deleted file mode 100644 index 02f3de4e..00000000 --- a/src/gui/status.cpp +++ /dev/null @@ -1,384 +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/status.h" -#include "gui/palette.h" - -#include "localplayer.h" -#include "units.h" - -#include "gui/widgets/button.h" -#include "gui/widgets/label.h" -#include "gui/widgets/layout.h" -#include "gui/widgets/progressbar.h" -#include "gui/widgets/windowcontainer.h" - -#include "net/net.h" -#include "net/playerhandler.h" -#include "net/ea/protocol.h" - -#include "utils/gettext.h" -#include "utils/mathutils.h" -#include "utils/stringutils.h" - -StatusWindow::StatusWindow(): - Window(player_node->getName()), - mCurrency(0) -{ - setWindowName("Status"); - setCloseButton(true); - setSaveVisible(true); - setDefaultSize(400, 345, ImageRect::CENTER); - - // ---------------------- - // Status Part - // ---------------------- - - mLvlLabel = new Label(strprintf(_("Level: %d"), 0)); - mJobLvlLabel = new Label(strprintf(_("Job: %d"), 0)); - mGpLabel = new Label(strprintf(_("Money: %s"), - Units::formatCurrency(mCurrency).c_str())); - - mHpLabel = new Label(_("HP:")); - mHpBar = new ProgressBar(0.0f, 80, 15, gcn::Color(0, 171, 34)); - - mXpLabel = new Label(_("Exp:")); - mXpBar = new ProgressBar(0.0f, 80, 15, gcn::Color(143, 192, 211)); - - mMpLabel = new Label(_("MP:")); - mMpBar = new ProgressBar(0.0f, 80, 15, gcn::Color(26, 102, 230)); - - mJobLabel = new Label(_("Job:")); - mJobBar = new ProgressBar(0.0f, 80, 15, gcn::Color(220, 135, 203)); - - // ---------------------- - // Stats Part - // ---------------------- - - // Static Labels - gcn::Label *mStatsTitleLabel = new Label(_("Stats")); - gcn::Label *mStatsTotalLabel = new Label(_("Total")); - gcn::Label *mStatsCostLabel = new Label(_("Cost")); - mStatsTotalLabel->setAlignment(gcn::Graphics::CENTER); - - // Derived Stats - static const char *dAttrNames[7] = { - _("Attack"), - _("Defense"), - _("M.Attack"), - _("M.Defense"), - // Gettext flag for next line: xgettext:no-c-format - _("% Accuracy"), - // Gettext flag for next line: xgettext:no-c-format - _("% Evade"), - // Gettext flag for next line: xgettext:no-c-format - _("% Crit Chance") - }; - - for (int i = 0; i < 7; i++) - { - mDStatsLabel[i] = new Label(dAttrNames[i]); - mDPointsLabel[i] = new Label; - } - - // Stats labels - static const char *attrNames[6] = { - _("Strength"), - _("Agility"), - _("Vitality"), - _("Intelligence"), - _("Dexterity"), - _("Luck") - }; - - for (int i = 0; i < 6; i++) - { - mStatsLabel[i] = new Label(attrNames[i]); - mStatsLabel[i]->setAlignment(gcn::Graphics::CENTER); - mStatsDisplayLabel[i] = new Label; - mPointsLabel[i] = new Label("0"); - mPointsLabel[i]->setAlignment(gcn::Graphics::CENTER); - } - mRemainingStatsPointsLabel = new Label; - - // Set button events Id - mStatsButton[0] = new Button("+", "STR", this); - mStatsButton[1] = new Button("+", "AGI", this); - mStatsButton[2] = new Button("+", "VIT", this); - mStatsButton[3] = new Button("+", "INT", this); - mStatsButton[4] = new Button("+", "DEX", this); - mStatsButton[5] = new Button("+", "LUK", this); - - // Assemble - ContainerPlacer place; - place = getPlacer(0, 0); - - place(0, 0, mLvlLabel, 3); - place(5, 0, mJobLvlLabel, 3); - place(8, 0, mGpLabel, 3); - place(0, 1, mHpLabel).setPadding(3); - place(1, 1, mHpBar, 4); - place(5, 1, mXpLabel).setPadding(3); - place(6, 1, mXpBar, 5); - place(0, 2, mMpLabel).setPadding(3); - place(1, 2, mMpBar, 4); - place(5, 2, mJobLabel).setPadding(3); - place(6, 2, mJobBar, 5); - place.getCell().matchColWidth(0, 1); - place = getPlacer(0, 3); - place(0, 1, mStatsTitleLabel, 5); - place(5, 1, mStatsTotalLabel, 5); - place(12, 1, mStatsCostLabel, 5); - for (int i = 0; i < 6; i++) - { - place(0, 2 + i, mStatsLabel[i], 7).setPadding(5); - place(7, 2 + i, mStatsDisplayLabel[i]).setPadding(5); - place(10, 2 + i, mStatsButton[i]); - place(12, 2 + i, mPointsLabel[i]).setPadding(5); - } - for (int i = 0; i < 7; i++) - { - place(14, 2 + i, mDStatsLabel[i], 7).setPadding(5); - place(21, 2 + i, mDPointsLabel[i], 3).setPadding(5); - } - - place(0, 8, mRemainingStatsPointsLabel, 3).setPadding(5); - - Layout &layout = getLayout(); - layout.setRowHeight(0, Layout::AUTO_SET); - - loadWindowState(); - update(); -} - -void StatusWindow::update() -{ - // Status Part - // ----------- - mLvlLabel->setCaption(strprintf(_("Level: %d"), player_node->getLevel())); - mLvlLabel->adjustSize(); - - mJobLvlLabel->setCaption(strprintf(_("Job: %d"), player_node->mJobLevel)); - mJobLvlLabel->adjustSize(); - - if (mCurrency != player_node->getMoney()) { - mCurrency = player_node->getMoney(); - mGpLabel->setCaption(strprintf(_("Money: %s"), - Units::formatCurrency(mCurrency).c_str())); - mGpLabel->adjustSize(); - } - - updateHPBar(mHpBar, true); - - updateMPBar(mMpBar, true); - - updateXPBar(mXpBar, false); - - updateJobBar(mJobBar, false); - - // Stats Part - // ---------- - int statusPoints = player_node->getCharacterPoints(); - - // Update labels - for (int i = 0; i < 6; i++) - { - int base = player_node->getAttributeBase(i + STR); - int bonus = player_node->getAttributeEffective(i + STR) - base; - std::string value = toString(base); - if (bonus) - value += strprintf(" (%+d)", bonus); - mStatsDisplayLabel[i]->setCaption(value); - mPointsLabel[i]->setCaption(toString(player_node-> - getAttributeBase(i + STR_U))); - - mStatsDisplayLabel[i]->adjustSize(); - mPointsLabel[i]->adjustSize(); - - mStatsButton[i]->setEnabled(player_node->getAttributeBase(i + STR_U) - <= statusPoints); - } - mRemainingStatsPointsLabel->setCaption( - strprintf(_("Remaining Status Points: %d"), statusPoints)); - mRemainingStatsPointsLabel->adjustSize(); - - // Derived Stats Points - for (int i = 0; i < 7; i++) - { - int base = player_node->getAttributeBase(i + ATK); - int bonus = player_node->getAttributeEffective(i + ATK) - base; - std::string value = toString(base); - if (bonus) - value += strprintf(" (%+d)", bonus); - mDPointsLabel[i]->setCaption(value); - mDPointsLabel[i]->adjustSize(); - } -} - -void StatusWindow::action(const gcn::ActionEvent &event) -{ - // Stats Part - // Net::getPlayerHandler()->increaseStat(?); - if (event.getId().length() == 3) - { - if (event.getId() == "STR") - Net::getPlayerHandler()->increaseAttribute(STR); - if (event.getId() == "AGI") - Net::getPlayerHandler()->increaseAttribute(AGI); - if (event.getId() == "VIT") - Net::getPlayerHandler()->increaseAttribute(VIT); - if (event.getId() == "INT") - Net::getPlayerHandler()->increaseAttribute(INT); - if (event.getId() == "DEX") - Net::getPlayerHandler()->increaseAttribute(DEX); - if (event.getId() == "LUK") - Net::getPlayerHandler()->increaseAttribute(LUK); - } -} - -void StatusWindow::updateHPBar(ProgressBar *bar, bool showMax) -{ - if (showMax) - bar->setText(toString(player_node->getHp()) + - "/" + toString(player_node->getMaxHp())); - else - bar->setText(toString(player_node->getHp())); - - // HP Bar coloration - float r1 = 255; - float g1 = 255; - float b1 = 255; - - float r2 = 255; - float g2 = 255; - float b2 = 255; - - float weight = 1.0f; - - int curHP = player_node->getHp(); - int thresholdLevel = player_node->getMaxHp() / 4; - int thresholdProgress = curHP % thresholdLevel; - weight = 1-((float)thresholdProgress) / ((float)thresholdLevel); - - if (curHP < (thresholdLevel)) - { - gcn::Color color1 = guiPalette->getColor(Palette::HPBAR_ONE_HALF); - gcn::Color color2 = guiPalette->getColor(Palette::HPBAR_ONE_QUARTER); - r1 = color1.r; r2 = color2.r; - g1 = color1.g; g2 = color2.g; - b1 = color1.b; b2 = color2.b; - } - else if (curHP < (thresholdLevel*2)) - { - gcn::Color color1 = guiPalette->getColor(Palette::HPBAR_THREE_QUARTERS); - gcn::Color color2 = guiPalette->getColor(Palette::HPBAR_ONE_HALF); - r1 = color1.r; r2 = color2.r; - g1 = color1.g; g2 = color2.g; - b1 = color1.b; b2 = color2.b; - } - else if (curHP < thresholdLevel*3) - { - gcn::Color color1 = guiPalette->getColor(Palette::HPBAR_FULL); - gcn::Color color2 = guiPalette->getColor(Palette::HPBAR_THREE_QUARTERS); - r1 = color1.r; r2 = color2.r; - g1 = color1.g; g2 = color2.g; - b1 = color1.b; b2 = color2.b; - } - else - { - gcn::Color color1 = guiPalette->getColor(Palette::HPBAR_FULL); - gcn::Color color2 = guiPalette->getColor(Palette::HPBAR_FULL); - r1 = color1.r; r2 = color2.r; - g1 = color1.g; g2 = color2.g; - b1 = color1.b; b2 = color2.b; - } - - // Safety checks - if (weight > 1.0f) weight = 1.0f; - if (weight < 0.0f) weight = 0.0f; - - // Do the color blend - r1 = (int) weightedAverage(r1, r2,weight); - g1 = (int) weightedAverage(g1, g2, weight); - b1 = (int) weightedAverage(b1, b2, weight); - - // More safety checks - if (r1 > 255) r1 = 255; - if (g1 > 255) g1 = 255; - if (b1 > 255) b1 = 255; - - bar->setColor(r1, g1, b1); - - bar->setProgress((float) player_node->getHp() / (float) player_node->getMaxHp()); -} - -void StatusWindow::updateMPBar(ProgressBar *bar, bool showMax) -{ - if (showMax) - bar->setText(toString(player_node->mMp) + - "/" + toString(player_node->mMaxMp)); - else - bar->setText(toString(player_node->mMp)); - - if (player_node->getAttributeEffective(MATK) <= 0) - bar->setColor(100, 100, 100); // grey, to indicate that we lack magic - else - bar->setColor(26, 102, 230); // blue, to indicate that we have magic - - bar->setProgress((float) player_node->mMp / (float) player_node->mMaxMp); -} - -static void updateProgressBar(ProgressBar *bar, int value, int max, - bool percent) -{ - if (max == 0) - { - bar->setText(_("Max level")); - bar->setProgress(1.0); - } - else - { - float progress = (float) value / max; - - if (percent) - bar->setText(strprintf("%2.2f", 100 * progress) + "%"); - else - bar->setText(toString(value) + "/" + toString(max)); - - bar->setProgress(progress); - } -} - -void StatusWindow::updateXPBar(ProgressBar *bar, bool percent) -{ - updateProgressBar(bar, - player_node->getLevelProgress(), - player_node->mXpForNextLevel, - percent); -} - -void StatusWindow::updateJobBar(ProgressBar *bar, bool percent) -{ - updateProgressBar(bar, - player_node->mJobXp, - player_node->mJobXpForNextLevel, - percent); -} diff --git a/src/gui/status.h b/src/gui/status.h deleted file mode 100644 index 6e8371c2..00000000 --- a/src/gui/status.h +++ /dev/null @@ -1,99 +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 STATUS_H -#define STATUS_H - -#include "gui/widgets/window.h" - -#include - -class LocalPlayer; -class ProgressBar; - -/** - * The player status dialog. - * - * \ingroup Interface - */ -class StatusWindow : public Window, public gcn::ActionListener -{ - public: - /** - * Constructor. - */ - StatusWindow(); - - /** - * Called when receiving actions from widget. - */ - void action(const gcn::ActionEvent &event); - - /** - * Updates this dialog with values from PLAYER_INFO *char_info - */ - void update(); - - // TODO: only update what changed - std::string update(int id) { update(); return ""; } - - // future use - void addAttribute(int id, const std::string &name, bool modifiable) {} - - static void updateHPBar(ProgressBar *bar, bool showMax = false); - static void updateMPBar(ProgressBar *bar, bool showMax = false); - static void updateXPBar(ProgressBar *bar, bool percent = true); - static void updateJobBar(ProgressBar *bar, bool percent = true); - - private: - /** - * Status Part - */ - gcn::Label *mLvlLabel, *mJobLvlLabel; - gcn::Label *mGpLabel; - int mCurrency; - gcn::Label *mHpLabel, *mMpLabel, *mXpLabel, *mJobLabel; - ProgressBar *mHpBar, *mMpBar; - ProgressBar *mXpBar, *mJobBar; - - /** - * Derived Statistics captions - */ - gcn::Label *mDStatsLabel[7]; - gcn::Label *mDPointsLabel[7]; - - /** - * Stats captions. - */ - gcn::Label *mStatsLabel[6]; - gcn::Label *mPointsLabel[6]; - gcn::Label *mStatsDisplayLabel[6]; - gcn::Label *mRemainingStatsPointsLabel; - - /** - * Stats buttons. - */ - gcn::Button *mStatsButton[6]; -}; - -extern StatusWindow *statusWindow; - -#endif diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 4df474a7..ed073440 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -23,13 +23,62 @@ #include "gui/widgets/button.h" #include "gui/widgets/label.h" +#include "gui/widgets/layouthelper.h" #include "gui/widgets/progressbar.h" +#include "gui/widgets/scrollarea.h" +#include "gui/widgets/vertcontainer.h" #include "gui/widgets/windowcontainer.h" #include "localplayer.h" +#include "units.h" +#include "net/net.h" +#include "net/playerhandler.h" + +#ifdef EATHENA_SUPPORT +#include "net/ea/protocol.h" +#endif + +#include "utils/gettext.h" +#include "utils/mathutils.h" #include "utils/stringutils.h" +class AttrDisplay : public Container { + public: + virtual std::string update(); + + protected: + AttrDisplay(int id, const std::string &name); + + const int mId; + const std::string mName; + + LayoutHelper *mLayout; + Label *mLabel; + Label *mValue; +}; + +class DerDisplay : public AttrDisplay { + public: + DerDisplay(int id, const std::string &name); +}; + +class ChangeDisplay : public AttrDisplay, gcn::ActionListener { + public: + ChangeDisplay(int id, const std::string &name); + std::string update(); + void setPointsNeeded(int needed); + + private: + void action(const gcn::ActionEvent &event); + + int mNeeded; + + Label *mPoints; + Button *mDec; + Button *mInc; +}; + StatusWindow::StatusWindow(): Window(player_node->getName()) { @@ -39,7 +88,6 @@ StatusWindow::StatusWindow(): setSaveVisible(true); setDefaultSize((windowContainer->getWidth() - 365) / 2, (windowContainer->getHeight() - 255) / 2, 365, 275); - loadWindowState(); // ---------------------- // Status Part @@ -50,246 +98,396 @@ StatusWindow::StatusWindow(): mHpLabel = new Label("HP:"); mHpBar = new ProgressBar(0.0f, 80, 15, gcn::Color(0, 171, 34)); - mHpValueLabel = new Label; - - int y = 3; - int x = 5; - - mLvlLabel->setPosition(x, y); - x += mLvlLabel->getWidth() + 40; - mMoneyLabel->setPosition(x, y); - y += mLvlLabel->getHeight() + 5; // Next Row - x = 5; - - mHpLabel->setPosition(x, y); - x += mHpLabel->getWidth() + 5; - mHpBar->setPosition(x, y); - x += mHpBar->getWidth() + 5; - mHpValueLabel->setPosition(x, y); - - y += mHpLabel->getHeight() + 5; // Next Row - x = 5; - - add(mLvlLabel); - add(mMoneyLabel); - add(mHpLabel); - add(mHpValueLabel); - add(mHpBar); + mXpLabel = new Label(_("Exp:")); + mXpBar = new ProgressBar(0.0f, 80, 15, gcn::Color(143, 192, 211)); + + mMpLabel = new Label(_("MP:")); + mMpBar = new ProgressBar(0.0f, 80, 15, gcn::Color(26, 102, 230)); + + place(0, 0, mLvlLabel, 3); + // 5, 0 Job Level + place(8, 0, mMoneyLabel, 3); + place(0, 1, mHpLabel).setPadding(3); + place(1, 1, mHpBar, 4); + place(5, 1, mXpLabel).setPadding(3); + place(6, 1, mXpBar, 5); + place(0, 2, mMpLabel).setPadding(3); + // 5, 2 and 6, 2 Job Progress Bar + place(1, 2, mMpBar, 4); + +#ifdef EATHENA_SUPPORT + mJobLvlLabel = new Label(strprintf(_("Job: %d"), 0)); + mJobLabel = new Label(_("Job:")); + mJobBar = new ProgressBar(0.0f, 80, 15, gcn::Color(220, 135, 203)); + + place(5, 0, mJobLvlLabel, 3); + place(5, 2, mJobLabel).setPadding(3); + place(6, 2, mJobBar, 5); +#endif // ---------------------- // Stats Part // ---------------------- - // Static Labels - gcn::Label *mStatsTitleLabel = new Label("Stats"); - gcn::Label *mStatsTotalLabel = new Label("Total"); + mAttrCont = new VertContainer(32); + mAttrScroll = new ScrollArea(mAttrCont); + mAttrScroll->setOpaque(false); + mAttrScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); + mAttrScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO); + place(0, 3, mAttrScroll, 5, 3); - // New labels - for (int i = 0; i < 6; i++) { - mStatsLabel[i] = new Label; - mStatsDisplayLabel[i] = new Label; - } - mCharacterPointsLabel = new Label; - mCorrectionPointsLabel = new Label; - - // Set button events Id - mStatsPlus[0] = new Button("+", "STR+", this); - mStatsPlus[1] = new Button("+", "AGI+", this); - mStatsPlus[2] = new Button("+", "DEX+", this); - mStatsPlus[3] = new Button("+", "VIT+", this); - mStatsPlus[4] = new Button("+", "INT+", this); - mStatsPlus[5] = new Button("+", "WIL+", this); - - mStatsMinus[0] = new Button("-", "STR-", this); - mStatsMinus[1] = new Button("-", "AGI-", this); - mStatsMinus[2] = new Button("-", "DEX-", this); - mStatsMinus[3] = new Button("-", "VIT-", this); - mStatsMinus[4] = new Button("-", "INT-", this); - mStatsMinus[5] = new Button("-", "WIL-", this); - - // Set position - mStatsTitleLabel->setPosition(mHpLabel->getX(), mHpLabel->getY() + 23 ); - mStatsTotalLabel->setPosition(110, mStatsTitleLabel->getY() + 15); - int totalLabelY = mStatsTotalLabel->getY(); - - for (int i = 0; i < 6; i++) - { - mStatsLabel[i]->setPosition(5, - mStatsTotalLabel->getY() + (i * 23) + 15); - mStatsMinus[i]->setPosition(85, totalLabelY + (i * 23) + 15); - mStatsDisplayLabel[i]->setPosition(125, - totalLabelY + (i * 23) + 15); - mStatsPlus[i]->setPosition(185, totalLabelY + (i * 23) + 15); - } + mDAttrCont = new VertContainer(32); + mDAttrScroll = new ScrollArea(mDAttrCont); + mDAttrScroll->setOpaque(false); + mDAttrScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); + mDAttrScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO); + place(6, 3, mDAttrScroll, 5, 3); - mCharacterPointsLabel->setPosition(5, mStatsDisplayLabel[5]->getY() + 25); - mCorrectionPointsLabel->setPosition(5, mStatsDisplayLabel[5]->getY() + 35); + getLayout().setRowHeight(3, Layout::AUTO_SET); - // Assemble - add(mStatsTitleLabel); - add(mStatsTotalLabel); - for(int i = 0; i < 6; i++) - { - add(mStatsLabel[i]); - add(mStatsDisplayLabel[i]); - add(mStatsPlus[i]); - add(mStatsMinus[i]); - } + mCharacterPointsLabel = new Label("C"); + mCorrectionPointsLabel = new Label("C"); + place(0, 6, mCharacterPointsLabel, 5); + place(0, 7, mCorrectionPointsLabel, 5); - add(mCharacterPointsLabel); - add(mCorrectionPointsLabel); + loadWindowState(); + + update(HP); + update(MP); + update(EXP); + update(MONEY); + update(CHAR_POINTS); // This also updates all attributes (none atm) + update(LEVEL); +#ifdef EATHENA_SUPPORT + update(JOB); +#endif } -void StatusWindow::update() +std::string StatusWindow::update(int id) { - // Status Part - // ----------- - mLvlLabel->setCaption( "Level: " + - toString(player_node->getLevel()) + - " (" + - toString(player_node->getLevelProgress()) + - "%)"); - mLvlLabel->adjustSize(); + if (id == HP) + { + updateHPBar(mHpBar, true); + + return _("HP"); + } + else if (id == MP) + { + updateMPBar(mMpBar, true); - mMoneyLabel->setCaption("Money: " + toString(player_node->getMoney()) + " GP"); - mMoneyLabel->adjustSize(); + return _("MP"); + } + else if (id == EXP) + { + updateXPBar(mXpBar, false); - updateHPBar(mHpBar, true); + return _("Exp"); + } + else if (id == MONEY) + { + int money = player_node->getMoney(); + mMoneyLabel->setCaption(strprintf(_("Money: %s"), + Units::formatCurrency(money).c_str())); + mMoneyLabel->adjustSize(); - // Stats Part - // ---------- - const std::string attrNames[6] = { - "Strength", - "Agility", - "Dexterity", - "Vitality", - "Intelligence", - "Willpower" - }; - int characterPoints = player_node->getCharacterPoints(); - int correctionPoints = player_node->getCorrectionPoints(); - // Update labels - for (int i = 0; i < 6; i++) + return _("Money"); + } +#ifdef EATHENA_SUPPORT + else if (id == JOB) { - mStatsLabel[i]->setCaption(attrNames[i]); - mStatsDisplayLabel[i]->setCaption( - strprintf("%d / %d", - player_node->getAttributeEffective(CHAR_ATTR_BEGIN + i), - player_node->getAttributeBase(CHAR_ATTR_BEGIN + i))); + mJobLvlLabel->setCaption(strprintf(_("Job: %d"), + player_node->getAttributeBase(JOB))); + mJobLvlLabel->adjustSize(); - mStatsLabel[i]->adjustSize(); - mStatsDisplayLabel[i]->adjustSize(); + updateProgressBar(mJobBar, JOB, false); - mStatsPlus[i]->setEnabled(characterPoints); - mStatsMinus[i]->setEnabled(correctionPoints); + return _("Job"); } - mCharacterPointsLabel->setCaption("Character Points: " + - toString(characterPoints)); - mCharacterPointsLabel->adjustSize(); +#endif + else if (id == CHAR_POINTS) + { + mCharacterPointsLabel->setCaption(strprintf(_("Character Points: %d"), + player_node->getCharacterPoints())); + mCharacterPointsLabel->adjustSize(); + + mCorrectionPointsLabel->setCaption(strprintf(_("Correction Points: %d"), + player_node->getCorrectionPoints())); + mCorrectionPointsLabel->adjustSize(); + + for (Attrs::iterator it = mAttrs.begin(); it != mAttrs.end(); it++) + { + it->second->update(); + } + } + else if (id == LEVEL) + { + mLvlLabel->setCaption(strprintf(_("Level: %d"), + player_node->getLevel())); + mLvlLabel->adjustSize(); - mCorrectionPointsLabel->setCaption("Correction Points: " + - toString(correctionPoints)); - mCorrectionPointsLabel->adjustSize(); + return _("Level"); + } + else + { + Attrs::iterator it = mAttrs.find(id); - // Update Second column widgets position - mMoneyLabel->setPosition(mLvlLabel->getX() + mLvlLabel->getWidth() + 20, - mLvlLabel->getY()); + if (it != mAttrs.end()) + { + return it->second->update(); + } + } - update(); + return ""; } -void StatusWindow::update(int id) +void StatusWindow::setPointsNeeded(int id, int needed) { - // TODO: only update what changed - update(); + Attrs::iterator it = mAttrs.find(id); + + if (it != mAttrs.end()) + { + ChangeDisplay *disp = dynamic_cast(it->second); + if (disp) + disp->setPointsNeeded(needed); + } } void StatusWindow::addAttribute(int id, const std::string &name, bool modifiable) { - // future use -} - -void StatusWindow::action(const gcn::ActionEvent &event) -{ - const std::string &eventId = event.getId(); + AttrDisplay *disp; - // Stats Part - if (eventId == "STR+") - { - player_node->raiseAttribute(LocalPlayer::STR); - } - else if (eventId == "AGI+") + if (modifiable) { - player_node->raiseAttribute(LocalPlayer::AGI); + disp = new ChangeDisplay(id, name); + mAttrCont->add(disp); } - else if (eventId == "DEX+") - { - player_node->raiseAttribute(LocalPlayer::DEX); - } - else if (eventId == "VIT+") - { - player_node->raiseAttribute(LocalPlayer::VIT); - } - else if (eventId == "INT+") - { - player_node->raiseAttribute(LocalPlayer::INT); - } - else if (eventId == "WIL+") + else { - player_node->raiseAttribute(LocalPlayer::WIL); + disp = new DerDisplay(id, name); + mDAttrCont->add(disp); } - else if (eventId == "STR-") + mAttrs[id] = disp; +} + +void StatusWindow::updateHPBar(ProgressBar *bar, bool showMax) +{ + if (showMax) + bar->setText(toString(player_node->getHp()) + + "/" + toString(player_node->getMaxHp())); + else + bar->setText(toString(player_node->getHp())); + + // HP Bar coloration + float r1 = 255; + float g1 = 255; + float b1 = 255; + + float r2 = 255; + float g2 = 255; + float b2 = 255; + + float weight = 1.0f; + + int curHP = player_node->getHp(); + int thresholdLevel = player_node->getMaxHp() / 4; + int thresholdProgress = curHP % thresholdLevel; + if (thresholdLevel) + weight = 1 - ((float)thresholdProgress) / ((float)thresholdLevel); + else + weight = 0; + + if (curHP < (thresholdLevel)) { - player_node->lowerAttribute(LocalPlayer::STR); + gcn::Color color1 = guiPalette->getColor(Palette::HPBAR_ONE_HALF); + gcn::Color color2 = guiPalette->getColor(Palette::HPBAR_ONE_QUARTER); + r1 = color1.r; r2 = color2.r; + g1 = color1.g; g2 = color2.g; + b1 = color1.b; b2 = color2.b; } - else if (eventId == "AGI-") + else if (curHP < (thresholdLevel*2)) { - player_node->lowerAttribute(LocalPlayer::AGI); + gcn::Color color1 = guiPalette->getColor(Palette::HPBAR_THREE_QUARTERS); + gcn::Color color2 = guiPalette->getColor(Palette::HPBAR_ONE_HALF); + r1 = color1.r; r2 = color2.r; + g1 = color1.g; g2 = color2.g; + b1 = color1.b; b2 = color2.b; } - else if (eventId == "DEX-") + else if (curHP < thresholdLevel*3) { - player_node->lowerAttribute(LocalPlayer::DEX); + gcn::Color color1 = guiPalette->getColor(Palette::HPBAR_FULL); + gcn::Color color2 = guiPalette->getColor(Palette::HPBAR_THREE_QUARTERS); + r1 = color1.r; r2 = color2.r; + g1 = color1.g; g2 = color2.g; + b1 = color1.b; b2 = color2.b; } - else if (eventId == "VIT-") + else { - player_node->lowerAttribute(LocalPlayer::VIT); + gcn::Color color1 = guiPalette->getColor(Palette::HPBAR_FULL); + gcn::Color color2 = guiPalette->getColor(Palette::HPBAR_FULL); + r1 = color1.r; r2 = color2.r; + g1 = color1.g; g2 = color2.g; + b1 = color1.b; b2 = color2.b; } - else if (eventId == "INT-") + + // Safety checks + if (weight > 1.0f) weight = 1.0f; + if (weight < 0.0f) weight = 0.0f; + + // Do the color blend + r1 = (int) weightedAverage(r1, r2,weight); + g1 = (int) weightedAverage(g1, g2, weight); + b1 = (int) weightedAverage(b1, b2, weight); + + // More safety checks + if (r1 > 255) r1 = 255; + if (g1 > 255) g1 = 255; + if (b1 > 255) b1 = 255; + + bar->setColor(r1, g1, b1); + + bar->setProgress((float) player_node->getHp() / (float) player_node->getMaxHp()); +} + +void StatusWindow::updateMPBar(ProgressBar *bar, bool showMax) +{ + if (showMax) + bar->setText(toString(player_node->getMP()) + + "/" + toString(player_node->getMaxMP())); + else + bar->setText(toString(player_node->getMP())); + +#ifdef EATHENA_SUPPORT + if (player_node->getAttributeEffective(MATK) <= 0) + bar->setColor(100, 100, 100); // grey, to indicate that we lack magic + else +#endif + bar->setColor(26, 102, 230); // blue, to indicate that we have magic + + bar->setProgress((float) player_node->getMP() / + (float) player_node->getMaxMP()); +} + +void StatusWindow::updateProgressBar(ProgressBar *bar, int value, int max, + bool percent) +{ + if (max == 0) { - player_node->lowerAttribute(LocalPlayer::INT); + bar->setText(_("Max")); + bar->setProgress(1.0); } - else if (eventId == "WIL-") + else { - player_node->lowerAttribute(LocalPlayer::WIL); + float progress = (float) value / max; + + if (percent) + bar->setText(strprintf("%2.2f", 100 * progress) + "%"); + else + bar->setText(toString(value) + "/" + toString(max)); + + bar->setProgress(progress); } } -// WARNING: Duplicated method! +void StatusWindow::updateXPBar(ProgressBar *bar, bool percent) +{ + updateProgressBar(bar, player_node->getExp(), player_node->getExpNeeded(), + percent); +} -void StatusWindow::updateHPBar(ProgressBar *bar, bool showMax) +void StatusWindow::updateProgressBar(ProgressBar *bar, int id, bool percent) { - if (showMax) - bar->setText(toString(player_node->getHp()) + - "/" + toString(player_node->getMaxHp())); - else - bar->setText(toString(player_node->getHp())); + std::pair exp = player_node->getExperience(id); + updateProgressBar(bar, exp.first, exp.second, percent); +} - // HP Bar coloration - if (player_node->getHp() < player_node->getMaxHp() / 3) - { - bar->setColor(223, 32, 32); // Red - } - else if (player_node->getHp() < (player_node->getMaxHp() / 3) * 2) +AttrDisplay::AttrDisplay(int id, const std::string &name): + mId(id), + mName(name) +{ + setSize(100, 32); + mLabel = new Label(name); + mValue = new Label("1"); + + mLabel->setAlignment(Graphics::CENTER); + mValue->setAlignment(Graphics::CENTER); + + mLayout = new LayoutHelper(this); +}; + +std::string AttrDisplay::update() +{ + int base = player_node->getAttributeBase(mId); + int bonus = player_node->getAttributeEffective(mId) - base; + std::string value = toString(base); + if (bonus) + value += strprintf(" (%+d)", bonus); + mValue->setCaption(value); + mValue->adjustSize(); + + return mName; +} + +DerDisplay::DerDisplay(int id, const std::string &name): + AttrDisplay(id, name) +{ + // Do the layout + LayoutHelper h(this); + ContainerPlacer place = mLayout->getPlacer(0, 0); + + place(0, 0, mLabel, 3); + place(3, 0, mValue, 2); + + update(); +}; + +ChangeDisplay::ChangeDisplay(int id, const std::string &name): + AttrDisplay(id, name), mNeeded(1) +{ + mPoints = new Label("1"); + mDec = new Button("-", "-", this); + mInc = new Button("+", "+", this); + mDec->setWidth(mInc->getWidth()); + + // Do the layout + ContainerPlacer place = mLayout->getPlacer(0, 0); + + place(0, 0, mLabel, 3); + place(3, 0, mDec); + place(4, 0, mValue, 2); + place(6, 0, mInc); + place(7, 0, mPoints); + + update(); +}; + +std::string ChangeDisplay::update() +{ + mPoints->setCaption(toString(mNeeded)); + + mDec->setEnabled(player_node->getCorrectionPoints()); + mInc->setEnabled(player_node->getCharacterPoints() >= mNeeded); + + return AttrDisplay::update(); +} + +void ChangeDisplay::setPointsNeeded(int needed) +{ + mNeeded = needed; + + update(); +} + +void ChangeDisplay::action(const gcn::ActionEvent &event) +{ + if (event.getSource() == mDec) { - bar->setColor(230, 171, 34); // Orange + Net::getPlayerHandler()->decreaseAttribute(mId); } - else + else if (event.getSource() == mInc) { - bar->setColor(0, 171, 34); // Green + Net::getPlayerHandler()->increaseAttribute(mId); } - - bar->setProgress((float) player_node->getHp() / (float) player_node->getMaxHp()); } diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h index b7623806..79382cd5 100644 --- a/src/gui/statuswindow.h +++ b/src/gui/statuswindow.h @@ -28,72 +28,71 @@ #include -class LocalPlayer; +#include + +class AttrDisplay; class ProgressBar; +class ScrollArea; +class VertContainer; /** * The player status dialog. * * \ingroup Interface */ -class StatusWindow : public Window, public gcn::ActionListener +class StatusWindow : public Window { public: + enum { // Some update constants + HP = -1, + MP = -2, + EXP = -3, + MONEY = -4, + CHAR_POINTS = -5, + LEVEL = -6 + }; + /** * Constructor. */ StatusWindow(); - /** - * Called when receiving actions from widget. - */ - void action(const gcn::ActionEvent &event); - - /** - * Updates this dialog with values from PLAYER_INFO *char_info - */ - void update(); + std::string update(int id); - void update(int id); + void setPointsNeeded(int id, int needed); void addAttribute(int id, const std::string &name, bool modifiable); static void updateHPBar(ProgressBar *bar, bool showMax = false); + static void updateMPBar(ProgressBar *bar, bool showMax = false); + static void updateXPBar(ProgressBar *bar, bool percent = true); + static void updateProgressBar(ProgressBar *bar, int value, int max, + bool percent); + static void updateProgressBar(ProgressBar *bar, int id, + bool percent = true); private: /** * Status Part */ - gcn::Label *mLvlLabel, *mMoneyLabel, *mHpLabel, *mHpValueLabel; - ProgressBar *mHpBar; + gcn::Label *mLvlLabel, *mMoneyLabel; + gcn::Label *mHpLabel, *mMpLabel, *mXpLabel; + ProgressBar *mHpBar, *mMpBar, *mXpBar; - /** - * Derived Statistics captions - */ -/* - gcn::Label *mStatsAttackLabel, *mStatsDefenseLabel; - gcn::Label *mStatsMagicAttackLabel, *mStatsMagicDefenseLabel; - gcn::Label *mStatsAccuracyLabel, *mStatsEvadeLabel; - gcn::Label *mStatsReflexLabel; - - gcn::Label *mStatsAttackPoints, *mStatsDefensePoints; - gcn::Label *mStatsMagicAttackPoints, *mStatsMagicDefensePoints; - gcn::Label *mStatsAccuracyPoints, *mStatsEvadePoints; - gcn::Label *mStatsReflexPoints; -*/ - /** - * Stats captions. - */ - gcn::Label *mStatsLabel[6]; - gcn::Label *mStatsDisplayLabel[6]; - gcn::Label *mCharacterPointsLabel; - gcn::Label *mCorrectionPointsLabel; +#ifdef EATHENA_SUPPORT + gcn::Label *mJobLvlLabel, *mJobLabel; + ProgressBar *mJobBar; +#endif - /** - * Stats buttons. - */ - gcn::Button *mStatsPlus[6]; - gcn::Button *mStatsMinus[6]; + VertContainer *mAttrCont; + ScrollArea *mAttrScroll; + VertContainer *mDAttrCont; + ScrollArea *mDAttrScroll; + + gcn::Label *mCharacterPointsLabel, *mCorrectionPointsLabel; + + typedef std::map Attrs; + Attrs mAttrs; }; extern StatusWindow *statusWindow; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 970204d0..cba27569 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -40,12 +40,8 @@ #include "gui/ministatus.h" #include "gui/palette.h" #include "gui/skilldialog.h" -#include "gui/storagewindow.h" -#ifdef TMWSERV_SUPPORT #include "gui/statuswindow.h" -#else -#include "gui/status.h" -#endif +#include "gui/storagewindow.h" #include "gui/widgets/chattab.h" @@ -83,17 +79,9 @@ const short walkingKeyboardDelay = 40; LocalPlayer *player_node = NULL; -#ifdef TMWSERV_SUPPORT -LocalPlayer::LocalPlayer(): - Player(65535, 0, NULL), -#else LocalPlayer::LocalPlayer(int id, int job, Map *map): Player(id, job, map), - mCharId(0), - mJobXp(0), - mJobLevel(0), - mXpForNextLevel(0), mJobXpForNextLevel(0), - mMp(0), mMaxMp(0), +#ifdef EATHENA_SUPPORT mAttackRange(0), #endif mEquipment(new Equipment), @@ -102,10 +90,11 @@ LocalPlayer::LocalPlayer(int id, int job, Map *map): mTargetTime(-1), #endif mLastTarget(-1), - mCharacterPoints(-1), - mCorrectionPoints(-1), - mLevelProgress(0), + mCharacterPoints(0), + mCorrectionPoints(0), mLevel(1), + mExp(0), mExpNeeded(0), + mMp(0), mMaxMp(0), mMoney(0), mTotalWeight(1), mMaxWeight(1), mHp(1), mMaxHp(1), @@ -816,6 +805,22 @@ void LocalPlayer::setAttributeEffective(int num, int value) statusWindow->update(num); } +void LocalPlayer::setCharacterPoints(int n) +{ + mCharacterPoints = n; + + if (statusWindow) + statusWindow->update(StatusWindow::CHAR_POINTS); +} + +void LocalPlayer::setCorrectionPoints(int n) +{ + mCorrectionPoints = n; + + if (statusWindow) + statusWindow->update(StatusWindow::CHAR_POINTS); +} + void LocalPlayer::setSkillPoints(int points) { mSkillPoints = points; @@ -846,16 +851,64 @@ std::pair LocalPlayer::getExperience(int skill) return mSkillExp[skill]; } -void LocalPlayer::setLevelProgress(int percent) +void LocalPlayer::setHp(int value) +{ + mHp = value; + + if (statusWindow) + statusWindow->update(StatusWindow::HP); +} + +void LocalPlayer::setMaxHp(int value) { - if (mMap && percent > mLevelProgress) + mMaxHp = value; + + if (statusWindow) + statusWindow->update(StatusWindow::HP); +} + +void LocalPlayer::setLevel(int value) +{ + mLevel = value; + + if (statusWindow) + statusWindow->update(StatusWindow::LEVEL); +} + +void LocalPlayer::setExp(int value) +{ + if (mMap && value > mExp) { - addMessageToQueue(toString(percent - mLevelProgress) + " xp"); + addMessageToQueue(toString(value - mExp) + " xp"); } - mLevelProgress = percent; + mExp = value; + + if (statusWindow) + statusWindow->update(StatusWindow::EXP); +} + +void LocalPlayer::setExpNeeded(int value) +{ + mExpNeeded = value; + + if (statusWindow) + statusWindow->update(StatusWindow::EXP); +} + +int LocalPlayer::setMP(int value) +{ + mMp = value; + + if (statusWindow) + statusWindow->update(StatusWindow::MP); +} + +int LocalPlayer::setMaxMP(int value) +{ + mMaxMp = value; if (statusWindow) - statusWindow->update(); + statusWindow->update(StatusWindow::MP); } void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount) diff --git a/src/localplayer.h b/src/localplayer.h index 4bcd43a3..1c57abaf 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -102,11 +102,7 @@ class LocalPlayer : public Player /** * Constructor. */ -#ifdef TMWSERV_SUPPORT - LocalPlayer(); -#else - LocalPlayer(int id, int job, Map *map); -#endif + LocalPlayer(int id= 65535, int job = 0, Map *map = NULL); /** * Destructor. @@ -272,13 +268,6 @@ class LocalPlayer : public Player void setInStorage(bool inStorage); #ifdef EATHENA_SUPPORT - Uint32 mCharId; /**< Used only during character selection. */ - - Uint32 mJobXp; - Uint32 mJobLevel; - Uint32 mXpForNextLevel, mJobXpForNextLevel; - Uint16 mMp, mMaxMp; - Uint16 mAttackRange; #endif @@ -288,22 +277,34 @@ class LocalPlayer : public Player int getMaxHp() const { return mMaxHp; } - void setHp(int value) - { mHp = value; } + void setHp(int value); - void setMaxHp(int value) - { mMaxHp = value; } + void setMaxHp(int value); int getLevel() const { return mLevel; } - void setLevel(int value) - { mLevel = value; } + void setLevel(int value); + + void setExp(int value); + + int getExp() const + { return mExp, mExpNeeded; } + + void setExpNeeded(int value); + + int getExpNeeded() const + { return mExpNeeded; } + + int setMP(int value); + + int getMP() const + { return mMp; } - void setLevelProgress(int percent); + int setMaxMP(int value); - int getLevelProgress() const - { return mLevelProgress; } + int getMaxMP() const + { return mMaxMp; } int getMoney() const { return mMoney; } @@ -336,14 +337,12 @@ class LocalPlayer : public Player int getCharacterPoints() const { return mCharacterPoints; } - void setCharacterPoints(int n) - { mCharacterPoints = n; } + void setCharacterPoints(int n); int getCorrectionPoints() const { return mCorrectionPoints; } - void setCorrectionPoints(int n) - { mCorrectionPoints = n; } + void setCorrectionPoints(int n); int getSkillPoints() const { return mSkillPoints; } @@ -380,8 +379,9 @@ class LocalPlayer : public Player std::map > mSkillExp; int mCharacterPoints; int mCorrectionPoints; - int mLevelProgress; int mLevel; + int mExp, mExpNeeded; + int mMp, mMaxMp; int mMoney; int mTotalWeight; int mMaxWeight; diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index a09f11f9..d8429d5e 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -169,14 +169,13 @@ void CharServerHandler::handleMessage(MessageIn &msg) LocalPlayer *CharServerHandler::readPlayerData(MessageIn &msg, int &slot) { - LocalPlayer *tempPlayer = new LocalPlayer(mLoginData->account_ID, 0, NULL); + LocalPlayer *tempPlayer = new LocalPlayer(msg.readInt32(), 0, NULL); tempPlayer->setGender(mLoginData->sex); - tempPlayer->mCharId = msg.readInt32(); - tempPlayer->setLevelProgress(msg.readInt32()); + tempPlayer->setExp(msg.readInt32()); tempPlayer->setMoney(msg.readInt32()); - tempPlayer->mJobXp = msg.readInt32(); - tempPlayer->mJobLevel = msg.readInt32(); + tempPlayer->setExperience(JOB, msg.readInt32(), 1); + tempPlayer->setAttributeBase(JOB, msg.readInt32()); tempPlayer->setSprite(Being::SHOE_SPRITE, msg.readInt16()); tempPlayer->setSprite(Being::GLOVES_SPRITE, msg.readInt16()); tempPlayer->setSprite(Being::CAPE_SPRITE, msg.readInt16()); @@ -187,8 +186,8 @@ LocalPlayer *CharServerHandler::readPlayerData(MessageIn &msg, int &slot) msg.skip(2); // unknown tempPlayer->setHp(msg.readInt16()); tempPlayer->setMaxHp(msg.readInt16()); - tempPlayer->mMp = msg.readInt16(); - tempPlayer->mMaxMp = msg.readInt16(); + tempPlayer->setMP(msg.readInt16()); + tempPlayer->setMaxMP(msg.readInt16()); msg.readInt16(); // speed msg.readInt16(); // class int hairStyle = msg.readInt16(); @@ -272,7 +271,7 @@ void CharServerHandler::newCharacter(const std::string &name, int slot, void CharServerHandler::deleteCharacter(int slot, LocalPlayer* character) { MessageOut outMsg(CMSG_CHAR_DELETE); - outMsg.writeInt32(character->mCharId); + outMsg.writeInt32(character->getId()); outMsg.writeString("a@a.com", 40); } diff --git a/src/net/ea/generalhandler.cpp b/src/net/ea/generalhandler.cpp index bbadd44f..06481824 100644 --- a/src/net/ea/generalhandler.cpp +++ b/src/net/ea/generalhandler.cpp @@ -23,7 +23,7 @@ #include "gui/inventorywindow.h" #include "gui/skilldialog.h" -#include "gui/status.h" +#include "gui/statuswindow.h" #include "net/ea/network.h" #include "net/ea/protocol.h" @@ -205,7 +205,7 @@ void GeneralHandler::guiWindowsLoaded() inventoryWindow->setSplitAllowed(false); skillDialog->loadSkills("ea-skills.xml"); - /*statusWindow->addAttribute(STR, _("Strength"), true); + statusWindow->addAttribute(STR, _("Strength"), true); statusWindow->addAttribute(AGI, _("Agility"), true); statusWindow->addAttribute(VIT, _("Vitality"), true); statusWindow->addAttribute(INT, _("Intelligence"), true); @@ -217,7 +217,7 @@ void GeneralHandler::guiWindowsLoaded() statusWindow->addAttribute(MATK, _("M.Attack"), false); statusWindow->addAttribute(MDEF, _("M.Defense"), false); statusWindow->addAttribute(HIT, _("% Accuracy"), false); - statusWindow->addAttribute(FLEE, _("% Evade"), false);*/ + statusWindow->addAttribute(FLEE, _("% Evade"), false); } void GeneralHandler::guiWindowsUnloaded() diff --git a/src/net/ea/maphandler.cpp b/src/net/ea/maphandler.cpp index 6f8a9827..a466e022 100644 --- a/src/net/ea/maphandler.cpp +++ b/src/net/ea/maphandler.cpp @@ -82,16 +82,21 @@ void MapHandler::handleMessage(MessageIn &msg) } } +#include + void MapHandler::connect(LoginData *loginData) { // Send login infos MessageOut outMsg(CMSG_MAP_SERVER_CONNECT); outMsg.writeInt32(loginData->account_ID); - outMsg.writeInt32(player_node->mCharId); + outMsg.writeInt32(player_node->getId()); outMsg.writeInt32(loginData->session_ID1); outMsg.writeInt32(loginData->session_ID2); outMsg.writeInt8((loginData->sex == GENDER_MALE) ? 1 : 0); + // Change the player's ID to the account ID to match what eAthena uses + player_node->setId(loginData->account_ID); + // We get 4 useless bytes before the real answer comes in (what are these?) mNetwork->skip(4); } diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index c2a1ecf1..60c7e2c1 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -37,6 +37,7 @@ #include "gui/gui.h" #include "gui/okdialog.h" #include "gui/sell.h" +#include "gui/statuswindow.h" #include "gui/storagewindow.h" #include "gui/viewport.h" @@ -229,8 +230,8 @@ void PlayerHandler::handleMessage(MessageIn &msg) case 0x0004: break; // manner case 0x0005: player_node->setHp(value); break; case 0x0006: player_node->setMaxHp(value); break; - case 0x0007: player_node->mMp = value; break; - case 0x0008: player_node->mMaxMp = value; break; + case 0x0007: player_node->setMP(value); break; + case 0x0008: player_node->setMaxMP(value); break; case 0x0009: player_node->setCharacterPoints(value); break; case 0x000b: player_node->setLevel(value); break; case 0x000c: player_node->setSkillPoints(value); break; @@ -288,7 +289,8 @@ void PlayerHandler::handleMessage(MessageIn &msg) player_node->setAttributeEffective(CRIT, value); break; case 0x0035: player_node->mAttackSpeed = value; break; - case 0x0037: player_node->mJobLevel = value; break; + case 0x0037: + player_node->setAttributeBase(JOB, value); break; case 500: player_node->setGMLevel(value); break; } @@ -305,10 +307,11 @@ void PlayerHandler::handleMessage(MessageIn &msg) case SMSG_PLAYER_STAT_UPDATE_2: switch (msg.readInt16()) { case 0x0001: - player_node->setLevelProgress(msg.readInt32()); + player_node->setExp(msg.readInt32()); break; case 0x0002: - player_node->mJobXp = msg.readInt32(); + player_node->setExperience(JOB, msg.readInt32(), + player_node->getExperience(JOB).second); break; case 0x0014: { int curGp = player_node->getMoney(); @@ -320,10 +323,12 @@ void PlayerHandler::handleMessage(MessageIn &msg) } break; case 0x0016: - player_node->mXpForNextLevel = msg.readInt32(); + player_node->setExpNeeded(msg.readInt32()); break; case 0x0017: - player_node->mJobXpForNextLevel = msg.readInt32(); + player_node->setExperience(JOB, + player_node->getExperience(JOB).first, + msg.readInt32()); break; } break; @@ -363,32 +368,32 @@ void PlayerHandler::handleMessage(MessageIn &msg) int val = msg.readInt8(); player_node->setAttributeEffective(STR, val + ATTR_BONUS(STR)); player_node->setAttributeBase(STR, val); - player_node->setAttributeBase(STR, msg.readInt8()); + statusWindow->setPointsNeeded(STR, msg.readInt8()); val = msg.readInt8(); player_node->setAttributeEffective(AGI, val + ATTR_BONUS(AGI)); player_node->setAttributeBase(AGI, val); - player_node->setAttributeBase(AGI_U, msg.readInt8()); + statusWindow->setPointsNeeded(AGI, msg.readInt8()); val = msg.readInt8(); player_node->setAttributeEffective(VIT, val + ATTR_BONUS(VIT)); player_node->setAttributeBase(VIT, val); - player_node->setAttributeBase(VIT_U, msg.readInt8()); + statusWindow->setPointsNeeded(VIT, msg.readInt8()); val = msg.readInt8(); player_node->setAttributeEffective(INT, val + ATTR_BONUS(INT)); player_node->setAttributeBase(INT, val); - player_node->setAttributeBase(INT_U, msg.readInt8()); + statusWindow->setPointsNeeded(INT, msg.readInt8()); val = msg.readInt8(); player_node->setAttributeEffective(DEX, val + ATTR_BONUS(DEX)); player_node->setAttributeBase(DEX, val); - player_node->setAttributeBase(DEX_U, msg.readInt8()); + statusWindow->setPointsNeeded(DEX, msg.readInt8()); val = msg.readInt8(); player_node->setAttributeEffective(LUK, val + ATTR_BONUS(LUK)); player_node->setAttributeBase(LUK, val); - player_node->setAttributeBase(LUK_U, msg.readInt8()); + statusWindow->setPointsNeeded(LUK, msg.readInt8()); val = msg.readInt16(); // ATK player_node->setAttributeBase(ATK, val); @@ -430,22 +435,22 @@ void PlayerHandler::handleMessage(MessageIn &msg) case SMSG_PLAYER_STAT_UPDATE_6: switch (msg.readInt16()) { case 0x0020: - player_node->setAttributeBase(STR_U, msg.readInt8()); + statusWindow->setPointsNeeded(STR, msg.readInt8()); break; case 0x0021: - player_node->setAttributeBase(AGI_U, msg.readInt8()); + statusWindow->setPointsNeeded(AGI, msg.readInt8()); break; case 0x0022: - player_node->setAttributeBase(VIT_U, msg.readInt8()); + statusWindow->setPointsNeeded(VIT, msg.readInt8()); break; case 0x0023: - player_node->setAttributeBase(INT_U, msg.readInt8()); + statusWindow->setPointsNeeded(INT, msg.readInt8()); break; case 0x0024: - player_node->setAttributeBase(DEX_U, msg.readInt8()); + statusWindow->setPointsNeeded(DEX, msg.readInt8()); break; case 0x0025: - player_node->setAttributeBase(LUK_U, msg.readInt8()); + statusWindow->setPointsNeeded(LUK, msg.readInt8()); break; } break; diff --git a/src/net/ea/protocol.h b/src/net/ea/protocol.h index 268c8c67..279e4c2f 100644 --- a/src/net/ea/protocol.h +++ b/src/net/ea/protocol.h @@ -23,6 +23,8 @@ #define EA_PROTOCOL_H enum { + JOB = 0xa, + STR = 0xd, AGI, VIT, @@ -30,13 +32,6 @@ enum { DEX, LUK, - STR_U, - AGI_U, - VIT_U, - INT_U, - DEX_U, - LUK_U, - ATK, DEF, MATK, diff --git a/src/net/tmwserv/generalhandler.cpp b/src/net/tmwserv/generalhandler.cpp index c04df973..d643586b 100644 --- a/src/net/tmwserv/generalhandler.cpp +++ b/src/net/tmwserv/generalhandler.cpp @@ -150,12 +150,14 @@ void GeneralHandler::guiWindowsLoaded() partyWindow->clearPartyName(); skillDialog->loadSkills("tmw-skills.xml"); - /*statusWindow->addAttribute(16, _("Strength"), true); + player_node->setExpNeeded(100); + + statusWindow->addAttribute(16, _("Strength"), true); statusWindow->addAttribute(17, _("Agility"), true); statusWindow->addAttribute(18, _("Dexterity"), true); statusWindow->addAttribute(19, _("Vitality"), true); statusWindow->addAttribute(20, _("Intelligence"), true); - statusWindow->addAttribute(21, _("Willpower"), true);*/ + statusWindow->addAttribute(21, _("Willpower"), true); } void GeneralHandler::guiWindowsUnloaded() diff --git a/src/net/tmwserv/playerhandler.cpp b/src/net/tmwserv/playerhandler.cpp index 413fbeaf..91b6dd8a 100644 --- a/src/net/tmwserv/playerhandler.cpp +++ b/src/net/tmwserv/playerhandler.cpp @@ -176,7 +176,7 @@ void PlayerHandler::handleMessage(MessageIn &msg) case GPMSG_LEVEL_PROGRESS: { logger->log("Level Progress Update"); - player_node->setLevelProgress(msg.readInt8()); + player_node->setExp(msg.readInt8()); } break; diff --git a/tmw.cbp b/tmw.cbp index a0616ec0..ba1e0dad 100644 --- a/tmw.cbp +++ b/tmw.cbp @@ -355,22 +355,8 @@ - - - - - - - - + + -- cgit v1.2.3-70-g09d2 From 175c5cc84a6abc02fd8eece6f6c90025e428999a Mon Sep 17 00:00:00 2001 From: David Athay Date: Tue, 21 Jul 2009 16:48:40 +0100 Subject: Updated codeblocks file --- tmw.cbp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tmw.cbp') diff --git a/tmw.cbp b/tmw.cbp index ba1e0dad..c41e6f1d 100644 --- a/tmw.cbp +++ b/tmw.cbp @@ -220,8 +220,8 @@ - - + + -- cgit v1.2.3-70-g09d2 From 8d6636e69bc5e579190d2f5fd635e6a44ef1fdca Mon Sep 17 00:00:00 2001 From: Kess Vargavind Date: Sat, 25 Jul 2009 20:27:40 +0200 Subject: Add new files to makefile --- src/Makefile.am | 2 ++ tmw.cbp | 2 ++ 2 files changed, 4 insertions(+) (limited to 'tmw.cbp') diff --git a/src/Makefile.am b/src/Makefile.am index ce00c1b9..75040d02 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -253,6 +253,8 @@ tmw_SOURCES = gui/widgets/avatar.cpp \ resources/resource.h \ resources/resourcemanager.cpp \ resources/resourcemanager.h \ + resources/sdlrescalefacility.h \ + resources/sdlrescalefacility.cpp \ resources/soundeffect.h \ resources/soundeffect.cpp \ resources/spritedef.h \ diff --git a/tmw.cbp b/tmw.cbp index c41e6f1d..46c3aef2 100644 --- a/tmw.cbp +++ b/tmw.cbp @@ -967,6 +967,8 @@ + + -- cgit v1.2.3-70-g09d2