diff options
-rw-r--r-- | src/graphic/graphic.h | 2 | ||||
-rw-r--r-- | src/gui/chargedialog.cpp | 20 | ||||
-rw-r--r-- | src/gui/chargedialog.h | 5 | ||||
-rw-r--r-- | src/net/protocol.cpp | 2 |
4 files changed, 25 insertions, 4 deletions
diff --git a/src/graphic/graphic.h b/src/graphic/graphic.h index 0b653875..413c9d33 100644 --- a/src/graphic/graphic.h +++ b/src/graphic/graphic.h @@ -42,6 +42,7 @@ class Graphics; #include "../gui/newskill.h" #include "../gui/setup.h" #include "../gui/equipment.h" +#include "../gui/chargedialog.h" #include "../resources/resourcemanager.h" #include "../map.h" #include "spriteset.h" @@ -71,6 +72,7 @@ extern NewSkillDialog *newSkillWindow; extern StatsWindow *statsWindow; extern Setup *setupWindow; extern EquipmentWindow *equipmentWindow; +extern ChargeDialog* chargeDialog; char get_x_offset(char, char); char get_y_offset(char, char); diff --git a/src/gui/chargedialog.cpp b/src/gui/chargedialog.cpp index 17c280c2..0d65c6b3 100644 --- a/src/gui/chargedialog.cpp +++ b/src/gui/chargedialog.cpp @@ -29,13 +29,15 @@ #include "scrollarea.h" #include "button.h" #include "../main.h" - +#include <time.h> ChargeDialog::ChargeDialog(): Window("") { - setSize(200,100); - progBar = new ProgressBar(0.0f,50,40,100,15,128,128,128); + + + setSize(180,70); + progBar = new ProgressBar(0.0f,20,40,140,25,128,128,128); add(progBar); } @@ -49,3 +51,15 @@ void ChargeDialog::action(const std::string& eventId) } +// update the dialog +void ChargeDialog::draw(gcn::Graphics *graphics) +{ + // calculate time since the last attack was made + char_info->lastAttackTime += .01; // this a hack until someone explains + // to me how to work the timer + if(char_info->lastAttackTime > 1){char_info->lastAttackTime=1;} + + // reset the progress bar to display accurate time since attack + progBar->setProgress(char_info->lastAttackTime); + Window::draw(graphics); +}
\ No newline at end of file diff --git a/src/gui/chargedialog.h b/src/gui/chargedialog.h index 5bc192fd..7d47a732 100644 --- a/src/gui/chargedialog.h +++ b/src/gui/chargedialog.h @@ -27,6 +27,8 @@ #include "window.h" #include "progressbar.h" +#define CHARGE_TIME 1000 // time in milliseconds it takes to charge up an attack + class ChargeDialog : public Window, public gcn::ActionListener { private: @@ -45,7 +47,8 @@ class ChargeDialog : public Window, public gcn::ActionListener ~ChargeDialog(); // action listener - void action(const std::string&); + void action(const std::string&); + void draw(gcn::Graphics *graphics); }; #endif diff --git a/src/net/protocol.cpp b/src/net/protocol.cpp index 40110144..b59a8c68 100644 --- a/src/net/protocol.cpp +++ b/src/net/protocol.cpp @@ -235,4 +235,6 @@ void attack(unsigned short x, unsigned short y, unsigned char direction) { if (monster_id != 0) action(0, monster_id); } + // implement charging attacks here + char_info->lastAttackTime = 0; } |