diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-01-20 19:56:38 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-01-20 19:56:38 +0000 |
commit | 47dd86930dcbbe92a989a3f049887b8ae47412d5 (patch) | |
tree | 12abba2e3bd5f8c43e50bc469d192eebeabb0934 /crawl-ref/source/output.cc | |
parent | 58a4fbec35500d744cb966d43885734b4da5f7d9 (diff) | |
download | crawl-ref-47dd86930dcbbe92a989a3f049887b8ae47412d5.tar.gz crawl-ref-47dd86930dcbbe92a989a3f049887b8ae47412d5.zip |
Tiles:
Fix the slooooow update of hp/mp during resting because of the coloured bars.
Now the bars are redrawn only once resting is over or if it's interrupted.
(Hp and mp still grow steadily.)
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3311 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/output.cc')
-rw-r--r-- | crawl-ref/source/output.cc | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index c45522a38a..475ca9db31 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -40,8 +40,10 @@ #include "skills2.h" #include "stuff.h" #include "transfor.h" - -#include "tiles.h" +#ifdef USE_TILE + #include "tiles.h" + #include "travel.h" +#endif static int bad_ench_colour( int lvl, int orange, int red ) { @@ -114,9 +116,13 @@ int draw_colour_bar(int val, int max_val, int old_val, int old_disp, { return -1; } + + // Don't redraw colour bars during running/resting + // *unless* we'll stop doing so after that + if (you.running > 1 && val != max_val) + return -1; const int width = crawl_view.hudsz.x - ox - 1; - int disp = width * val / max_val; gotoxy(ox, oy, GOTO_STAT); @@ -144,9 +150,9 @@ void draw_mp_bar(int val, int max_val) const int oy = 4; const unsigned short default_colour = BLUE; const unsigned short change = LIGHTBLUE; - const unsigned short empty = DARKGRAY; + const unsigned short empty = DARKGRAY; - static int old_val = 0; + static int old_val = 0; static int old_disp = 0; old_disp = draw_colour_bar(val, max_val, old_val, old_disp, ox, oy, @@ -160,15 +166,26 @@ void draw_hp_bar(int val, int max_val) const int oy = 3; const unsigned short default_colour = GREEN; const unsigned short change = RED; - const unsigned short empty = DARKGRAY; + const unsigned short empty = DARKGRAY; - static int old_val = 0; + static int old_val = 0; static int old_disp = 0; old_disp = draw_colour_bar(val, max_val, old_val, old_disp, ox, oy, default_colour, change, empty); old_val = val; } + +static int count_digits(int val) +{ + if (val > 999) + return 4; + else if (val > 99) + return 3; + else if (val > 9) + return 2; + return 1; +} #endif void print_stats(void) @@ -213,11 +230,17 @@ void print_stats(void) if (max_max_hp != you.hp_max) cprintf( " (%d)", max_max_hp ); - clear_to_end_of_line(); you.redraw_hit_points = 0; #ifdef USE_TILE + int col = count_digits(you.hp)+count_digits(you.hp_max) + 1; + if (max_max_hp != you.hp_max) + col += count_digits(max_max_hp) + 3; + for (int i = 15-col; i > 0; i--) + cprintf(" "); draw_hp_bar(you.hp, you.hp_max); +#else + clear_to_end_of_line(); #endif } @@ -244,11 +267,16 @@ void print_stats(void) textcolor(LIGHTGREY); cprintf("/%d", you.max_magic_points ); - clear_to_end_of_line(); you.redraw_magic_points = 0; #ifdef USE_TILE + int col = count_digits(you.magic_points) + + count_digits(you.max_magic_points) + 1; + for (int i = 12-col; i > 0; i--) + cprintf(" "); draw_mp_bar(you.magic_points, you.max_magic_points); +#else + clear_to_end_of_line(); #endif } |