diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-02-20 20:56:59 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-02-20 20:56:59 +0000 |
commit | 7ce021a8e4fce72af6e79cad22243bdd50bb8656 (patch) | |
tree | 06f9eadde06667d640f94e8ecc8b526a45af402d /src/gui | |
parent | 368c9002365118212d9ef9b6bb00f9148522770f (diff) | |
download | mana-7ce021a8e4fce72af6e79cad22243bdd50bb8656.tar.gz mana-7ce021a8e4fce72af6e79cad22243bdd50bb8656.tar.bz2 mana-7ce021a8e4fce72af6e79cad22243bdd50bb8656.tar.xz mana-7ce021a8e4fce72af6e79cad22243bdd50bb8656.zip |
Reverted changes to skill dialog, a new one will be developed alongside it so
that the current one remains working for now. Also XML maps now can load but
not the base64 or gzip kind yet.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/skill.cpp | 102 | ||||
-rw-r--r-- | src/gui/skill.h | 34 | ||||
-rw-r--r-- | src/gui/window.cpp | 2 |
3 files changed, 108 insertions, 30 deletions
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 3d6d7768..4c3feedf 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -29,22 +29,22 @@ char *skill_db[] = { // 0-99 - /* weapons 0-9 */ "Short Blades", "Long Blades", "Hammers", "Archery", "Exotic", "Throwing", "Piercing", "Hand to Hand", "", "", - /* magic 10-19 */ "Djin (Fire)", "Niksa (Water)", "Kerub (Earth)", "Ariel (Air)", "Paradin (Light)", "Tharsis (Dark)", "Crono (Time)", "Astra (Space)", "Gen (Mana)", "", - /* craft 20-29 */ "Smithy", "Jeweler", "Alchemist", "Cook", "Tailor", "Artisan", "", "", "", "", - /* general 30-39 */ "Running", "Searching", "Sneak", "Trading", "Intimidate", "", "", "", "", "", + "", "Basic", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", - // 100-199 "", "", "", "", "", "", "", "", "", "", + // 100-199 "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "First aid", "Play as dead", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", @@ -52,15 +52,11 @@ char *skill_db[] = { "", "", "", "", "", "", "", "", "", "", }; -// pointer to the info struct the -// dialog is concerned with (to insure future flexibility) -PLAYER_INFO** SkillList = &char_info; - SkillDialog::SkillDialog(): Window("Skills") { - /*skillListBox = new ListBox(this); + skillListBox = new ListBox(this); skillScrollArea = new ScrollArea(skillListBox); pointsLabel = new gcn::Label("Skill Points:"); incButton = new Button(" Up "); @@ -83,23 +79,99 @@ SkillDialog::SkillDialog(): incButton->addActionListener(this); closeButton->addActionListener(this); - setLocationRelativeTo(getParent());*/ - + setLocationRelativeTo(getParent()); } SkillDialog::~SkillDialog() { - /* delete skillListBox; + delete skillListBox; delete skillScrollArea; delete pointsLabel; delete incButton; - delete closeButton;*/ + delete closeButton; + for (int i = skillList.size() - 1; i >= 0; i--) + { + delete skillList[i]; + skillList.pop_back(); + } } void SkillDialog::action(const std::string& eventId) { - // GUI design + if (eventId == "inc") + { + // Increment skill + int selectedSkill = skillListBox->getSelected(); + std::cout << "SkillDialog::action(" << selectedSkill << ")\n"; + if (char_info->skill_point > 0 && selectedSkill >= 0) { + std::cout << "Sending upgrade of id " << skillList[selectedSkill]->id << "\n"; + WFIFOW(0) = net_w_value(0x0112); + WFIFOW(2) = net_w_value( + skillList[selectedSkill]->id); + WFIFOSET(4); + } + } + else if (eventId == "close") + { + setVisible(false); + } +} + +void SkillDialog::setPoints(int i) +{ + char tmp[128]; + sprintf(tmp, "Skill points: %i", i); + if (pointsLabel != NULL) { + pointsLabel->setCaption(tmp); + } +} + +int SkillDialog::getNumberOfElements() +{ + return skillList.size(); } +std::string SkillDialog::getElementAt(int i) +{ + if (i >= 0 && i < (int)skillList.size()) + { + char tmp[128]; + sprintf(tmp, "%s Lv: %i Sp: %i", + skill_db[skillList[i]->id], + skillList[i]->lv, + skillList[i]->sp); + return tmp; + } + return ""; +} + +bool SkillDialog::hasSkill(int id) +{ + for (unsigned int i = 0; i < skillList.size(); i++) { + if (skillList[i]->id == id) { + return true; + } + } + return false; +} + +void SkillDialog::addSkill(int id, int lv, int sp) +{ + SKILL *tmp = new SKILL(); + tmp->id = id; + tmp->lv = lv; + tmp->sp = sp; + skillList.push_back(tmp); +} + +void SkillDialog::setSkill(int id, int lv, int sp) +{ + for (unsigned int i = 0; i < skillList.size(); i++) { + if (skillList[i]->id == id) { + skillList[i]->lv = lv; + skillList[i]->sp = sp; + } + } +} diff --git a/src/gui/skill.h b/src/gui/skill.h index 6ee511cc..5db90f04 100644 --- a/src/gui/skill.h +++ b/src/gui/skill.h @@ -24,28 +24,21 @@ #ifndef _TMW_SKILL_H #define _TMW_SKILL_H - #include <guichan.hpp> #include "window.h" -#include <vector> + +struct SKILL { + short id; /**< Index into "skill_db" array */ + short lv, sp; +}; + /** * The skill dialog. * * \ingroup GUI */ - -// skill struct, by Kyokai -// skill names are stored in a table elsewhere. (SkillDialog.cpp) -typedef struct { - short level; // level of the skill - short exp; // exp value - double mod; // value of the modifier (0,0.5,1,2,4) - // next value can be calculated when needed by the function: - // 20 * level^1.2 - } SKILL; - -class SkillDialog : public Window, public gcn::ActionListener -// public gcn::ListModel +class SkillDialog : public Window, public gcn::ActionListener, + public gcn::ListModel { private: gcn::ListBox *skillListBox; @@ -54,6 +47,8 @@ class SkillDialog : public Window, public gcn::ActionListener gcn::Button *incButton; gcn::Button *closeButton; + std::vector<SKILL*> skillList; + public: /** * Constructor. @@ -66,6 +61,15 @@ class SkillDialog : public Window, public gcn::ActionListener ~SkillDialog(); void action(const std::string&); + + void setPoints(int i); + + int getNumberOfElements(); + std::string getElementAt(int); + + bool hasSkill(int id); + void addSkill(int id, int lv, int sp); + void setSkill(int id, int lv, int sp); }; #endif diff --git a/src/gui/window.cpp b/src/gui/window.cpp index c17e4c76..399cb73f 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -227,10 +227,12 @@ void Window::mouseMotion(int mx, int my) if (y + winHeight > screen->h) y = screen->h - winHeight; // Snap window to edges + /* if (x < snapSize) x = 0; if (y < snapSize) y = 0; if (x + winWidth + snapSize > screen->w) x = screen->w - winWidth; if (y + winHeight + snapSize > screen->h) y = screen->h - winHeight; + */ this->setPosition(x, y); } |