summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/ministatus.cpp54
-rw-r--r--src/gui/ministatus.h13
-rw-r--r--src/gui/statuswindow.cpp16
-rw-r--r--src/net/ea/playerhandler.cpp15
-rw-r--r--src/net/ea/playerhandler.h2
-rw-r--r--src/net/playerhandler.h2
-rw-r--r--src/net/tmwserv/playerhandler.cpp5
-rw-r--r--src/net/tmwserv/playerhandler.h2
8 files changed, 70 insertions, 39 deletions
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index ab5560da..4cb0e1ac 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -33,6 +33,8 @@
#include "utils/stringutils.h"
+extern volatile int tick_time;
+
MiniStatusWindow::MiniStatusWindow():
Popup("MiniStatus")
{
@@ -75,13 +77,37 @@ void MiniStatusWindow::eraseIcon(int index)
mIcons.erase(mIcons.begin() + index);
}
-extern volatile int tick_time;
+void MiniStatusWindow::drawIcons(Graphics *graphics)
+{
+ // Draw icons
+ int icon_x = mXpBar->getX() + mXpBar->getWidth() + 4;
+ for (unsigned int i = 0; i < mIcons.size(); i++) {
+ if (mIcons[i]) {
+ mIcons[i]->draw(graphics, icon_x, 3);
+ icon_x += 2 + mIcons[i]->getWidth();
+ }
+ }
+}
+
+void MiniStatusWindow::update(int id)
+{
+ if (id == StatusWindow::HP)
+ {
+ StatusWindow::updateHPBar(mHpBar);
+ }
+ else if (id == StatusWindow::MP)
+ {
+ StatusWindow::updateMPBar(mMpBar);
+ }
+ else if (id == StatusWindow::EXP)
+ {
+ StatusWindow::updateXPBar(mXpBar);
+ }
+}
-void MiniStatusWindow::update()
+void MiniStatusWindow::logic()
{
- StatusWindow::updateHPBar(mHpBar);
- StatusWindow::updateMPBar(mMpBar);
- StatusWindow::updateXPBar(mXpBar);
+ Popup::logic();
// Displays the number of monsters to next lvl
// (disabled for now but interesting idea)
@@ -100,21 +126,3 @@ void MiniStatusWindow::update()
if (mIcons[i])
mIcons[i]->update(tick_time * 10);
}
-
-void MiniStatusWindow::draw(gcn::Graphics *graphics)
-{
- update();
- drawChildren(graphics);
-}
-
-void MiniStatusWindow::drawIcons(Graphics *graphics)
-{
- // Draw icons
- int icon_x = mXpBar->getX() + mXpBar->getWidth() + 4;
- for (unsigned int i = 0; i < mIcons.size(); i++) {
- if (mIcons[i]) {
- mIcons[i]->draw(graphics, icon_x, 3);
- icon_x += 2 + mIcons[i]->getWidth();
- }
- }
-}
diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h
index f5604486..de07e12d 100644
--- a/src/gui/ministatus.h
+++ b/src/gui/ministatus.h
@@ -40,8 +40,6 @@ class MiniStatusWindow : public Popup
public:
MiniStatusWindow();
- void draw(gcn::Graphics *graphics);
-
/**
* Sets one of the icons.
*/
@@ -51,12 +49,11 @@ class MiniStatusWindow : public Popup
void drawIcons(Graphics *graphics);
- private:
- /**
- * Updates this dialog with values from player_node.
- */
- void update();
+ void update(int id); // Same types as status window
+ void logic(); // Updates icons
+
+ private:
/*
* Mini Status Bars
*/
@@ -67,4 +64,6 @@ class MiniStatusWindow : public Popup
std::vector<AnimatedSprite *> mIcons;
};
+extern MiniStatusWindow *miniStatusWindow;
+
#endif
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index 1b764615..5d4ad8c4 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -28,6 +28,8 @@
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/vertcontainer.h"
#include "gui/widgets/windowcontainer.h"
+
+#include "gui/ministatus.h"
#include "gui/setup.h"
#include "localplayer.h"
@@ -181,18 +183,24 @@ std::string StatusWindow::update(int id)
{
updateHPBar(mHpBar, true);
+ miniStatusWindow->update(HP);
+
return _("HP");
}
else if (id == MP)
{
updateMPBar(mMpBar, true);
+ miniStatusWindow->update(MP);
+
return _("MP");
}
else if (id == EXP)
{
updateXPBar(mXpBar, false);
+ miniStatusWindow->update(EXP);
+
return _("Exp");
}
else if (id == MONEY)
@@ -370,12 +378,10 @@ void StatusWindow::updateMPBar(ProgressBar *bar, bool showMax)
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
+ if (Net::getPlayerHandler()->canUseMagic())
bar->setColor(26, 102, 230); // blue, to indicate that we have magic
+ else
+ bar->setColor(100, 100, 100); // grey, to indicate that we lack magic
bar->setProgress((float) player_node->getMP() /
(float) player_node->getMaxMP());
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index ea3f40d5..3528eeee 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -260,10 +260,11 @@ void PlayerHandler::handleMessage(MessageIn &msg)
case 0x002b: player_node->setAttributeEffective(MATK, value
+ ATTR_BONUS(MATK));
- player_node->setAttributeBase(MATK, value); break;
+ player_node->setAttributeBase(MATK, value);
+ statusWindow->update(StatusWindow::MP); break;
case 0x002c: value += player_node->getAttributeBase(MATK);
- player_node->setAttributeEffective(MATK, value); break;
-
+ player_node->setAttributeEffective(MATK, value);
+ statusWindow->update(StatusWindow::MP); break;
case 0x002d: player_node->setAttributeEffective(DEF, value
+ ATTR_BONUS(DEF));
player_node->setAttributeBase(DEF, value); break;
@@ -333,7 +334,7 @@ void PlayerHandler::handleMessage(MessageIn &msg)
}
break;
- case SMSG_PLAYER_STAT_UPDATE_3:
+ case SMSG_PLAYER_STAT_UPDATE_3: // Update a base attribute
{
int type = msg.readInt32();
int base = msg.readInt32();
@@ -404,6 +405,7 @@ void PlayerHandler::handleMessage(MessageIn &msg)
player_node->setAttributeBase(MATK, val);
val += msg.readInt16(); // MATK bonus
player_node->setAttributeEffective(MATK, val);
+ statusWindow->update(StatusWindow::MP);
val = msg.readInt16(); // DEF
player_node->setAttributeBase(DEF, val);
@@ -560,4 +562,9 @@ void PlayerHandler::ignoreAll(bool ignore)
// TODO
}
+bool PlayerHandler::canUseMagic()
+{
+ return player_node->getAttributeEffective(MATK) > 0;
+}
+
} // namespace EAthena
diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h
index 7312dacf..78e64a88 100644
--- a/src/net/ea/playerhandler.h
+++ b/src/net/ea/playerhandler.h
@@ -58,6 +58,8 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
void ignorePlayer(const std::string &player, bool ignore);
void ignoreAll(bool ignore);
+
+ bool canUseMagic();
};
} // namespace EAthena
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index 910424b3..a0fd8bac 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -54,6 +54,8 @@ class PlayerHandler
virtual void ignorePlayer(const std::string &player, bool ignore) = 0;
virtual void ignoreAll(bool ignore) = 0;
+
+ virtual bool canUseMagic() = 0;
};
} // namespace Net
diff --git a/src/net/tmwserv/playerhandler.cpp b/src/net/tmwserv/playerhandler.cpp
index 91b6dd8a..656befdf 100644
--- a/src/net/tmwserv/playerhandler.cpp
+++ b/src/net/tmwserv/playerhandler.cpp
@@ -390,4 +390,9 @@ void PlayerHandler::ignoreAll(bool ignore)
// TODO
}
+bool PlayerHandler::canUseMagic()
+{
+ return true;
+}
+
} // namespace TmwServ
diff --git a/src/net/tmwserv/playerhandler.h b/src/net/tmwserv/playerhandler.h
index 1c94b4e4..287baa3d 100644
--- a/src/net/tmwserv/playerhandler.h
+++ b/src/net/tmwserv/playerhandler.h
@@ -58,6 +58,8 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
void ignoreAll(bool ignore);
+ bool canUseMagic();
+
private:
void handleMapChangeMessage(MessageIn &msg);
};