Permalink
Browse files

Made the damage display size depends on the amount itself.

  • Loading branch information...
1 parent ddbf7e7 commit 1df57cdf8dd3891f5044998304bdb9180682e590 Yohann Ferreira committed Sep 16, 2012
Showing with 52 additions and 22 deletions.
  1. +30 −16 src/main.cpp
  2. +22 −6 src/modes/battle/battle_indicators.cpp
View
@@ -271,31 +271,45 @@ void InitializeEngine() throw (Exception) {
GUIManager->DEBUG_EnableGUIOutlines(false);
// Load all standard font sets used across the game
- if (VideoManager->Text()->LoadFont("img/fonts/LinLibertine_aBS.ttf", "title20", 18) == false) {
+ if (!VideoManager->Text()->LoadFont("img/fonts/LinLibertine_aBS.ttf", "title20", 18))
throw Exception("Failed to load libertine_capitals.ttf font at size 18", __FILE__, __LINE__, __FUNCTION__);
- }
- if (VideoManager->Text()->LoadFont("img/fonts/LinLibertine_aBS.ttf", "title22", 20) == false) {
+
+ if (!VideoManager->Text()->LoadFont("img/fonts/LinLibertine_aBS.ttf", "title22", 20))
throw Exception("Failed to load 'img/fonts/LinLibertine_aBS.ttf' font at size 20", __FILE__, __LINE__, __FUNCTION__);
- }
- if (VideoManager->Text()->LoadFont("img/fonts/LinLibertine_aBS.ttf", "title24", 22) == false) {
+
+ if (!VideoManager->Text()->LoadFont("img/fonts/LinLibertine_aBS.ttf", "title24", 22))
throw Exception("Failed to load 'img/fonts/LinLibertine_aBS.ttf' font at size 22", __FILE__, __LINE__, __FUNCTION__);
- }
- if (VideoManager->Text()->LoadFont("img/fonts/LinLibertine_aBS.ttf", "title28", 24) == false) {
+
+ if (!VideoManager->Text()->LoadFont("img/fonts/LinLibertine_aBS.ttf", "title28", 24))
throw Exception("Failed to load 'img/fonts/LinLibertine_aBS.ttf' font at size 24", __FILE__, __LINE__, __FUNCTION__);
- }
- if (VideoManager->Text()->LoadFont("img/fonts/LinBiolinum_RBah.ttf", "text18", 16) == false) {
+
+ if (!VideoManager->Text()->LoadFont("img/fonts/LinBiolinum_RBah.ttf", "text18", 16))
throw Exception("Failed to load 'img/fonts/LinBiolinum_RBah.ttf' font at size 16", __FILE__, __LINE__, __FUNCTION__);
- }
- if (VideoManager->Text()->LoadFont("img/fonts/LinBiolinum_RBah.ttf", "text20", 18) == false) {
+
+ if (!VideoManager->Text()->LoadFont("img/fonts/LinBiolinum_RBah.ttf", "text20", 18))
throw Exception("Failed to load 'img/fonts/LinBiolinum_RBah.ttf' font at size 18", __FILE__, __LINE__, __FUNCTION__);
- }
- if (VideoManager->Text()->LoadFont("img/fonts/LinBiolinum_RBah.ttf", "text22", 20) == false) {
+
+ if (!VideoManager->Text()->LoadFont("img/fonts/LinBiolinum_RBah.ttf", "text22", 20))
throw Exception("Failed to load 'img/fonts/LinBiolinum_RBah.ttf' font at size 20", __FILE__, __LINE__, __FUNCTION__);
- }
- if (VideoManager->Text()->LoadFont("img/fonts/LinBiolinum_RBah.ttf", "text24", 22) == false) {
+
+ if (!VideoManager->Text()->LoadFont("img/fonts/LinBiolinum_RBah.ttf", "text24", 22))
throw Exception("Failed to load 'img/fonts/LinBiolinum_RBah.ttf' font at size 22", __FILE__, __LINE__, __FUNCTION__);
- }
+
+ if (!VideoManager->Text()->LoadFont("img/fonts/LinBiolinum_RBah.ttf", "text24.2", 24))
+ throw Exception("Failed to load 'img/fonts/LinBiolinum_RBah.ttf' font at size 24", __FILE__, __LINE__, __FUNCTION__);
+
+ if (!VideoManager->Text()->LoadFont("img/fonts/LinBiolinum_RBah.ttf", "text26", 26))
+ throw Exception("Failed to load 'img/fonts/LinBiolinum_RBah.ttf' font at size 26", __FILE__, __LINE__, __FUNCTION__);
+
+ if (!VideoManager->Text()->LoadFont("img/fonts/LinBiolinum_RBah.ttf", "text28", 28))
+ throw Exception("Failed to load 'img/fonts/LinBiolinum_RBah.ttf' font at size 28", __FILE__, __LINE__, __FUNCTION__);
+
+ if (!VideoManager->Text()->LoadFont("img/fonts/LinBiolinum_RBah.ttf", "text36", 36))
+ throw Exception("Failed to load 'img/fonts/LinBiolinum_RBah.ttf' font at size 36", __FILE__, __LINE__, __FUNCTION__);
+
+ if (!VideoManager->Text()->LoadFont("img/fonts/LinBiolinum_RBah.ttf", "text48", 48))
+ throw Exception("Failed to load 'img/fonts/LinBiolinum_RBah.ttf' font at size 48", __FILE__, __LINE__, __FUNCTION__);
VideoManager->Text()->SetDefaultStyle(TextStyle("text22", Color::white, VIDEO_TEXT_SHADOW_BLACK, 1, -2));
@@ -382,30 +382,47 @@ void IndicatorSupervisor::AddDamageIndicator(uint32 amount) {
}
std::string text = NumberToString(amount);
+
TextStyle style;
float damage_percent = static_cast<float>(amount) / static_cast<float>(_actor->GetMaxHitPoints());
if (damage_percent < 0.10f) {
- style.font = "text24";
style.color = low_red;
style.shadow_style = VIDEO_TEXT_SHADOW_BLACK;
}
else if (damage_percent < 0.20f) {
- style.font = "text24";
style.color = mid_red;
style.shadow_style = VIDEO_TEXT_SHADOW_BLACK;
}
else if (damage_percent < 0.30f) {
- style.font = "text24";
style.color = high_red;
style.shadow_style = VIDEO_TEXT_SHADOW_BLACK;
}
else { // (damage_percent >= 0.30f)
- style.font = "text24";
style.color = full_red;
style.shadow_style = VIDEO_TEXT_SHADOW_BLACK;
}
+ // Set the text size depending on the amount of pure damage.
+ if (amount < 50) {
+ style.font = "text24"; // text24
+ }
+ else if (amount < 100) {
+ style.font = "text24.2";
+ }
+ else if (amount < 250) {
+ style.font = "text26";
+ }
+ else if (amount < 500) {
+ style.font = "text28";
+ }
+ else if (amount < 1000) {
+ style.font = "text36";
+ }
+ else {
+ style.font = "text48";
+ }
+
_wait_queue.push_back(new IndicatorText(_actor, text, style, DAMAGE_INDICATOR));
}
@@ -428,8 +445,7 @@ void IndicatorSupervisor::AddHealingIndicator(uint32 amount, bool hit_points) {
std::string text = NumberToString(amount);
TextStyle style;
- // TODO: use different colors/shades of green for different degrees of damage. There's a
- // bug in rendering colored text that needs to be addressed first.
+ // Use different colors/shades of green/blue for different degrees of healing
float healing_percent = static_cast<float>(amount / _actor->GetMaxHitPoints());
if (healing_percent < 0.10f) {
style.font = "text24";

0 comments on commit 1df57cd

Please sign in to comment.