summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAaron Marks <nymacro@gmail.com>2005-01-04 04:46:02 +0000
committerAaron Marks <nymacro@gmail.com>2005-01-04 04:46:02 +0000
commit52b6be101b78990d5b4523dd5c6523dc5c7c6709 (patch)
tree0990d5d596a0910d037bcab6853ecf9b073939ff /src
parent2be6f298a1c39dff04070588f75a3bed0c495b8b (diff)
downloadmana-client-52b6be101b78990d5b4523dd5c6523dc5c7c6709.tar.gz
mana-client-52b6be101b78990d5b4523dd5c6523dc5c7c6709.tar.bz2
mana-client-52b6be101b78990d5b4523dd5c6523dc5c7c6709.tar.xz
mana-client-52b6be101b78990d5b4523dd5c6523dc5c7c6709.zip
Converted Skills dialog from old gui to Guichan. Files modified: graphics.cpp, graphics.h, game.cpp, main.cpp, skills.h, skills.cpp. Other files are unmodified (timestamp error)
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp24
-rw-r--r--src/graphic/graphic.cpp19
-rw-r--r--src/graphic/graphic.h1
-rw-r--r--src/gui/skill.cpp224
-rw-r--r--src/gui/skill.h49
5 files changed, 171 insertions, 146 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 82973850..78cc7552 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -345,7 +345,8 @@ bool handle_key(int unicode, int scancode)
}
return true;
case KEY_K:
- show_skill_list_dialog = !show_skill_dialog;
+ //show_skill_list_dialog = !show_skill_dialog;
+ skillDialog->setVisible(!skillDialog->isVisible());
return true;
}
}
@@ -656,7 +657,7 @@ void do_parse() {
break;
case 0x000c:
char_info->skill_point = RFIFOW(4);
- sprintf(skill_points, "Skill points: %i", char_info->skill_point);
+ skillDialog->setPoints(char_info->skill_point);
break;
case 0x0037:
char_info->job_lv = RFIFOW(4);
@@ -857,25 +858,22 @@ void do_parse() {
sprintf(pkt_nfo, "%i %i %i %i", RFIFOL(2), RFIFOW(6), RFIFOW(8), RFIFOW(10));
//alert(pkt_nfo,"","","","",0,0);
break;
- // Skill list
+ // Skill list TAG
case 0x010f:
- //n_skills = 0;
+ {
+ int n_skills = (len - 4) / 37;
//SKILL *temp_skill = NULL;
- //n_skills = (len-4)/37;
for(int k=0;k<(len-4)/37;k++) {
if(RFIFOW(4+k*37+6)!=0 || RFIFOB(4+k*37+36)!=0) {
- SKILL *temp_skill = is_skill(RFIFOW(4+k*37));
- if(temp_skill) {
- temp_skill->lv = RFIFOW(4+k*37+6);
- temp_skill->sp = RFIFOW(4+k*37+36);
- if(temp_skill->sp<0)temp_skill->sp = 0;
+ int skillId = RFIFOW(4+k*37);
+ if(skillDialog->getModel()->hasSkill(skillId)) {
+ skillDialog->getModel()->setSkill(skillId, RFIFOW(4+k*37+6), RFIFOW(4+k*37+36));
} else {
- n_skills++;
- add_skill(RFIFOW(4+k*37), RFIFOW(4+k*37+6), RFIFOW(4+k*37+8));
+ skillDialog->getModel()->addSkill(RFIFOW(4+k*37), RFIFOW(4+k*37+6), RFIFOW(4+k*37+8));
}
}
}
- break;
+ } break;
// MVP experience
case 0x010b:
break;
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp
index 3640bde0..f4affd67 100644
--- a/src/graphic/graphic.cpp
+++ b/src/graphic/graphic.cpp
@@ -48,6 +48,7 @@ BuySellDialog *buySellDialog;
InventoryWindow *inventoryWindow;
NpcListDialog *npcListDialog;
NpcTextDialog *npcTextDialog;
+SkillDialog *skillDialog;
void ChatListener::action(const std::string& eventId)
{
@@ -82,8 +83,9 @@ void BuySellListener::action(const std::string& eventId)
buySellDialog->setVisible(false);
}
+/*
DIALOG skill_list_dialog[] = {
- /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
+ // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
{ tmw_dialog_proc, 300, 200, 260, 200, 0, 0, 0, 0, 0, 0, (char *)"Stats", NULL, NULL },
{ tmw_button_proc, 450, 376, 50, 20, 255, 0, 'u', D_EXIT, 0, 0, (char *)"&Up", NULL, NULL },
{ tmw_button_proc, 508, 376, 50, 20, 255, 0, 'c', D_EXIT, 0, 0, (char *)"&Close", NULL, NULL },
@@ -91,6 +93,7 @@ DIALOG skill_list_dialog[] = {
{ tmw_text_proc, 304, 326, 40, 20, 0, 0, 0, 0, 0, 0, (char *)skill_points, NULL, NULL },
{ NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
};
+*/
char hairtable[14][4][2] = {
// S(x,y) W(x,y) N(x,y) E(x,y)
@@ -189,8 +192,11 @@ GraphicEngine::GraphicEngine() {
npcListDialog = new NpcListDialog(guiTop);
npcListDialog->setVisible(false);
- skill_player = init_dialog(skill_dialog, -1);
- skill_list_player = init_dialog(skill_list_dialog, -1);
+ skillDialog = new SkillDialog(guiTop);
+ skillDialog->setVisible(false);
+
+ //skill_player = init_dialog(skill_dialog, -1);
+ //skill_list_player = init_dialog(skill_list_dialog, -1);
// Give focus to the chat input
chatInput->requestFocus();
@@ -220,10 +226,11 @@ GraphicEngine::~GraphicEngine() {
delete buySellDialog;
delete npcListDialog;
delete npcTextDialog;
+ delete skillDialog;
//delete tileset;
- shutdown_dialog(skill_player);
+ //shutdown_dialog(skill_player);
}
void GraphicEngine::refresh() {
@@ -458,13 +465,16 @@ void GraphicEngine::refresh() {
chatlog.chat_draw(buffer, 8, font);
+ /*
if (show_skill_dialog) {
update_skill_dialog();
if (gui_update(skill_player) == 0) {
show_skill_dialog = false;
}
}
+ */
+ /*
if (show_skill_list_dialog) {
if (gui_update(skill_list_player) == 0) {
int ret = shutdown_dialog(skill_list_player);
@@ -481,6 +491,7 @@ void GraphicEngine::refresh() {
skill_list_player = init_dialog(skill_list_dialog, -1);
}
}
+ */
// Update character status display
statusWindow->update();
diff --git a/src/graphic/graphic.h b/src/graphic/graphic.h
index 0f6710f8..ea9b71f0 100644
--- a/src/graphic/graphic.h
+++ b/src/graphic/graphic.h
@@ -63,6 +63,7 @@ extern BuySellDialog *buySellDialog;
extern InventoryWindow *inventoryWindow;
extern NpcListDialog *npcListDialog;
extern NpcTextDialog *npcTextDialog;
+extern SkillDialog *skillDialog;
/**
* The action listener for the chat field.
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp
index 455036ef..d3308aa5 100644
--- a/src/gui/skill.cpp
+++ b/src/gui/skill.cpp
@@ -25,16 +25,6 @@
extern PLAYER_INFO *char_info;
-int n_skills = 0;
-SKILL *skill_head = NULL;
-
-char str_string[8];
-char agi_string[8];
-char vit_string[8];
-char int_string[8];
-char dex_string[8];
-char luk_string[8];
-
char *skill_db[] = {
// 0-99
"", "Basic", "", "", "", "", "", "", "", "",
@@ -60,119 +50,125 @@ char *skill_db[] = {
"", "", "", "", "", "", "", "", "", "",
};
-DIALOG skill_dialog[] = {
- /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
- { tmw_dialog_proc, 300, 200, 150, 60, 0, 0, 0, 0, 0, 0, (char *)"Skills", NULL, NULL },
- { tmw_text_proc, 304, 224, 252, 100, 0, 0, 0, 0, 0, 0, str_string, NULL, NULL },
- { tmw_plus_proc, 354, 224, 16, 16, 0, 0, '0', 0, 0, 1, (void*)increaseStatus,NULL, NULL },
- { tmw_text_proc, 304, 234, 252, 100, 0, 0, 0, 0, 0, 0, agi_string, NULL, NULL },
- { tmw_plus_proc, 354, 234, 16, 16, 0, 0, '0', 0, 1, 1, (void*)increaseStatus,NULL, NULL },
- { tmw_text_proc, 304, 244, 252, 100, 0, 0, 0, 0, 0, 0, vit_string, NULL, NULL },
- { tmw_plus_proc, 354, 244, 16, 16, 0, 0, '0', 0, 2, 1, (void*)increaseStatus,NULL, NULL },
- { tmw_text_proc, 374, 224, 252, 100, 0, 0, 0, 0, 0, 0, int_string, NULL, NULL },
- { tmw_plus_proc, 424, 224, 16, 16, 0, 0, '0', 0, 3, 1, (void*)increaseStatus,NULL, NULL },
- { tmw_text_proc, 374, 234, 252, 100, 0, 0, 0, 0, 0, 0, dex_string, NULL, NULL },
- { tmw_plus_proc, 424, 234, 16, 16, 0, 0, '0', 0, 4, 1, (void*)increaseStatus,NULL, NULL },
- { tmw_text_proc, 374, 244, 252, 100, 0, 0, 0, 0, 0, 0, luk_string, NULL, NULL },
- { tmw_plus_proc, 424, 244, 16, 16, 0, 0, '0', 0, 5, 1, (void*)increaseStatus,NULL, NULL },
- { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
-};
-void update_skill_dialog() {
- int skillTemp = 0;
- for(int loop = 0; loop<=char_info->lv;loop++)
- skillTemp += int( (float)loop / (float)5.0 ) + (int)2;
- sprintf(str_string, "STR: %i", char_info->STR);
- sprintf(agi_string, "AGI: %i", char_info->AGI);
- sprintf(vit_string, "VIT: %i", char_info->VIT);
- sprintf(int_string, "INT: %i", char_info->INT);
- sprintf(dex_string, "DEX: %i", char_info->DEX);
- sprintf(luk_string, "LUK: %i", char_info->LUK);
- if(char_info->STR+char_info->AGI+char_info->VIT+char_info->INT+char_info->DEX+char_info->LUK == skillTemp)
- {
- skill_dialog[2].d2 = skill_dialog[4].d2 = skill_dialog[6].d2 =skill_dialog[8].d2 =skill_dialog[10].d2 = 0;
- } else {
- skill_dialog[2].d2 = skill_dialog[4].d2 = skill_dialog[6].d2 =skill_dialog[8].d2 =skill_dialog[10].d2 = 1;
- }
+SkillListModel::SkillListModel()
+{
+ //
}
-void add_skill(short id, short lv, short sp) {
- SKILL *skill = skill_head;
- SKILL *temp = (SKILL *)malloc(sizeof(SKILL));
- temp->id = id;
- temp->lv = lv;
- temp->sp = sp;
- temp->next = NULL;
- if(!skill_head)
- skill_head = temp;
- else {
- while(skill->next)
- skill = skill->next;
- skill->next = temp;
- }
+SkillListModel::~SkillListModel()
+{
+ for (int i = skillList.size() - 1; i >= 0; i--)
+ {
+ delete skillList[i];
+ skillList.pop_back();
+ }
}
-char *skill_list(int index, int *list_size) {
- if(index<0) {
- *list_size = n_skills;
- return NULL;
- } else {
- int iterator = 0;
- SKILL *temp = skill_head;
- while(iterator<index) {
- temp = temp->next;
- iterator++;
- }
- char *name = (char *)malloc(30);
- sprintf(name, "%s lv:%i %i SP", skill_db[temp->id], temp->lv, temp->sp);
- return name;
- // need to clean allocated memory
- }
+int SkillListModel::getNumberOfElements()
+{
+ return skillList.size();
}
-int get_skill_id(int index) {
- int iterator = 0;
- SKILL *temp = skill_head;
- while(iterator<index) {
- temp = temp->next;
- iterator++;
- }
- return temp->id;
+std::string SkillListModel::getElementAt(int i)
+{
+ //
+ if (i >= 0 && i < skillList.size())
+ {
+ //return skill_db[skillList[i]->id];
+ char tmp[128];
+ sprintf(tmp, "%s Lv: %i Sp: %i", skill_db[skillList[i]->id], skillList[i]->lv, skillList[i]->sp);
+ return tmp;
+ }
+ return "";
}
-SKILL *is_skill(int id) {
- SKILL *temp = skill_head;
- while(temp) {
- if(temp->id==id)return temp;
- temp = temp->next;
- }
- return NULL;
+bool SkillListModel::hasSkill(int id)
+{
+ for (int i = 0; i < skillList.size(); i++)
+ if (skillList[i]->id == id)
+ return true;
+ return false;
}
-void increaseStatus(void *dp3, int d1) {
- WFIFOW(0) = net_w_value(0x00bb);
- switch(d1) {
- case 0:
- WFIFOW(2) = net_w_value(0x000d);
- break;
- case 1:
- WFIFOW(2) = net_w_value(0x000e);
- break;
- case 2:
- WFIFOW(2) = net_w_value(0x000f);
- break;
- case 3:
- WFIFOW(2) = net_w_value(0x0010);
- break;
- case 4:
- WFIFOW(2) = net_w_value(0x0011);
- break;
- case 5:
- WFIFOW(2) = net_w_value(0x0012);
- break;
- }
- WFIFOW(4) = net_b_value(1);
- WFIFOSET(5);
- while((out_size>0))flush();
- skill_dialog[2].d2 = skill_dialog[4].d2 = skill_dialog[6].d2 = skill_dialog[8].d2 = skill_dialog[10].d2 = 0;
+void SkillListModel::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 SkillListModel::setSkill(int id, int lv, int sp)
+{
+ if (!hasSkill(id))
+ return;
+ skillList[id]->lv = lv;
+ skillList[id]->sp = sp;
+}
+
+//
+
+SkillDialog::SkillDialog(gcn::Container *parent)
+ : Window(parent, "Skills")
+{
+ skills = new SkillListModel;
+
+ skillListBox = new gcn::ListBox(skills);
+ pointsLabel = new gcn::Label("Skill Points:");
+ incButton = new Button(" Up ");
+ closeButton = new Button("Close");
+
+ incButton->setEventId("inc");
+ closeButton->setEventId("close");
+
+ skillListBox->setDimension(gcn::Rectangle(0, 0, 200, 180));
+ pointsLabel->setDimension(gcn::Rectangle(0, 0, 200, 16));
+
+ skillListBox->setPosition(8, 4);
+ pointsLabel->setPosition(8, 190);
+ incButton->setPosition(64, 210);
+ closeButton->setPosition(160, 210);
+
+ add(skillListBox);
+ add(pointsLabel);
+ add(incButton);
+ add(closeButton);
+
+ incButton->addActionListener(this);
+ closeButton->addActionListener(this);
+
+ setSize(240, 240);
+ setLocationRelativeTo(getParent());
+}
+
+SkillDialog::~SkillDialog()
+{
+ delete skillListBox;
+ delete pointsLabel;
+ delete incButton;
+ delete closeButton;
+
+ delete skills;
+}
+
+void SkillDialog::action(const std::string& eventId)
+{
+ if (eventId == "inc")
+ {
+ //increment skill
+ } 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);
+}
+
diff --git a/src/gui/skill.h b/src/gui/skill.h
index 33e94a18..21f76212 100644
--- a/src/gui/skill.h
+++ b/src/gui/skill.h
@@ -21,30 +21,49 @@
* $Id$
*/
-#ifdef WIN32
- #pragma warning (disable:4312)
-#endif
-
#ifndef _SKILL_H
#define _SKILL_H
#include <allegro.h>
+#include "button.h"
#include "../main.h"
-//DIALOG skill_dialog[];
+struct SKILL {
+ short id; //index into "skill_db" array
+ short lv, sp;
+};
-extern int n_skills;
+class SkillListModel : public gcn::ListModel
+{
+ std::vector<SKILL*> skillList;
+ public:
+ SkillListModel();
+ ~SkillListModel();
-struct SKILL {
- short id, lv, sp;
- SKILL *next;
+ 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);
};
+class SkillDialog : public Window, public gcn::ActionListener
+{
+ gcn::ListBox *skillListBox;
+ SkillListModel *skills;
+ gcn::Label *pointsLabel;
+
+ Button *incButton;
+ Button *closeButton;
+ public:
+ SkillDialog(gcn::Container *);
+ ~SkillDialog();
+
+ void action(const std::string&);
+ SkillListModel* getModel() { return skills; }
+
+ void setPoints(int i);
+};
-void update_skill_dialog();
-void add_skill(short id, short lv, short sp);
-char *skill_list(int index, int *list_size);
-int get_skill_id(int index);
-SKILL *is_skill(int id);
-void increaseStatus(void *dp3, int d1);
#endif