summaryrefslogtreecommitdiff
path: root/src/gui/skill.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-02-20 20:56:59 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-02-20 20:56:59 +0000
commit7ce021a8e4fce72af6e79cad22243bdd50bb8656 (patch)
tree06f9eadde06667d640f94e8ecc8b526a45af402d /src/gui/skill.cpp
parent368c9002365118212d9ef9b6bb00f9148522770f (diff)
downloadmana-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/skill.cpp')
-rw-r--r--src/gui/skill.cpp102
1 files changed, 87 insertions, 15 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;
+ }
+ }
+}