diff options
author | pauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-04-02 11:52:31 +0000 |
---|---|---|
committer | pauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-04-02 11:52:31 +0000 |
commit | b5f22d6caac43d3384229512064fab6df622d3e5 (patch) | |
tree | 91fbeaf8d0b91b320763454c5b4850575064b84c /crawl-ref/source | |
parent | f36915f1cabb3547931cdc206e8b575dc2d18944 (diff) | |
download | crawl-ref-b5f22d6caac43d3384229512064fab6df622d3e5.tar.gz crawl-ref-b5f22d6caac43d3384229512064fab6df622d3e5.zip |
+ Implement most of the suggestions for HUD compression.
Didn't do anything with exp as there didn't seem to be consensus.
+ Enable the HP/Magic bars in non-tile builds; move them a little bit.
I stumbled across these while looking into making HP/MP draw on
a single line. I think it's a nice feature; worth at least an
option, if they're not on all the time.
+ Fix bar-drawing bug (the "reduced" part was not drawing properly)
+ Reduce size of hud by 2, expand mlist by 2. Non-tile only; tile
doesn't need the extra space and it uses GOTO_STAT for other things.
I don't want to risk making it too small.
Not implemented:
- Monster list renders from the bottom up (tricky)
- Use only 2 lines for warning lights
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4043 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/misc.cc | 13 | ||||
-rw-r--r-- | crawl-ref/source/output.cc | 218 | ||||
-rw-r--r-- | crawl-ref/source/output.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/view.cc | 68 | ||||
-rw-r--r-- | crawl-ref/source/view.h | 6 |
5 files changed, 166 insertions, 141 deletions
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 489b507f6a..cc760a32ee 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -60,6 +60,7 @@ #include "mon-util.h" #include "monstuff.h" #include "ouch.h" +#include "output.h" #include "overmap.h" #include "place.h" #include "player.h" @@ -1577,18 +1578,8 @@ std::string level_description_string() void new_level(void) { - textcolor(LIGHTGREY); - - cgotoxy(7, 12, GOTO_STAT); - -#if DEBUG_DIAGNOSTICS - cprintf( "(%d) ", you.your_level + 1 ); -#endif - take_note(Note(NOTE_DUNGEON_LEVEL_CHANGE)); - cprintf("%s", level_description_string().c_str()); - - clear_to_end_of_line(); + print_stats_level(level_description_string()); #ifdef DGL_WHEREIS whereis_record(); #endif diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index d20fadacbb..36e9db2e5d 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -47,8 +47,8 @@ #include "transfor.h" #ifdef USE_TILE #include "tiles.h" - #include "travel.h" #endif +#include "travel.h" #include "view.h" static int _bad_ench_colour( int lvl, int orange, int red ) @@ -112,7 +112,6 @@ void update_turn_count() cprintf("%ld", you.num_turns); } -#ifdef USE_TILE static int _draw_colour_bar(int val, int max_val, int old_val, int old_disp, int ox, int oy, unsigned short default_colour, unsigned short change_colour, @@ -133,30 +132,40 @@ static int _draw_colour_bar(int val, int max_val, int old_val, int old_disp, cgotoxy(ox, oy, GOTO_STAT); + textcolor(BLACK); for (int cx=0; cx < width; cx++) { +#ifdef USE_TILE + // maybe this should use textbackground too? textcolor(BLACK + empty_colour * 16); if (cx < disp) textcolor(BLACK + default_colour * 16); - else if (old_val > val && old_disp > disp && cx < old_disp && cx >= val) + else if (old_val > val && old_disp > disp && cx < old_disp) textcolor(BLACK + change_colour * 16); +#else + textbackground(empty_colour); + if (cx < disp) + textbackground(default_colour); + else if (old_val > val && old_disp > disp && cx < old_disp) + textbackground(change_colour); +#endif putch(' '); } textcolor(LIGHTGREY); + textbackground(BLACK); return disp; } -void draw_mp_bar(int val, int max_val) +void draw_mp_bar(int ox, int oy, int val, int max_val) { - const int ox = 20; - const int oy = 4; const unsigned short default_colour = BLUE; - const unsigned short change = LIGHTBLUE; - const unsigned short empty = DARKGRAY; + // DARKGRAY and LIGHTBLUE don't show up for me... :-( --pld + const unsigned short change = CYAN; + const unsigned short empty = LIGHTGRAY; static int old_val = 0; static int old_disp = 0; @@ -166,13 +175,12 @@ void draw_mp_bar(int val, int max_val) old_val = val; } -void draw_hp_bar(int val, int max_val) +void draw_hp_bar(int ox, int oy, int val, int max_val) { - const int ox = 20; - const int oy = 3; const unsigned short default_colour = GREEN; const unsigned short change = RED; - const unsigned short empty = DARKGRAY; + // DARKGRAY doesn't show up for me... :-( --pld + const unsigned short empty = LIGHTGRAY; static int old_val = 0; static int old_disp = 0; @@ -192,7 +200,6 @@ static int _count_digits(int val) return 2; return 1; } -#endif static std::string _describe_hunger() { @@ -220,7 +227,7 @@ static std::string _describe_hunger() } } -static void _print_stats_mp() +static void _print_stats_mp(int x, int y) { int mp_percent; if ( you.max_magic_points ) @@ -236,26 +243,22 @@ static void _print_stats_mp() break; } } - cgotoxy(8, 4, GOTO_STAT); + cgotoxy(x+7, y, GOTO_STAT); cprintf( "%d", you.magic_points); textcolor(LIGHTGREY); cprintf("/%d", you.max_magic_points ); -#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--) + for (int i = 11-col; i > 0; i--) cprintf(" "); - draw_mp_bar(you.magic_points, you.max_magic_points); -#else - clear_to_end_of_line(); -#endif + draw_mp_bar(19, y, you.magic_points, you.max_magic_points); } // Helper for print_stats -static void _print_stats_hp() +static void _print_stats_hp(int x, int y) { const int max_max_hp = you.hp_max + player_rotted(); int hp_percent; @@ -274,8 +277,8 @@ static void _print_stats_hp() } } - cgotoxy(5, 3, GOTO_STAT); - + cgotoxy(x+4, y, GOTO_STAT); + // int col = -wherex(); cprintf( "%d", you.hp ); textcolor(LIGHTGREY); @@ -284,19 +287,17 @@ static void _print_stats_hp() if (max_max_hp != you.hp_max) cprintf( " (%d)", max_max_hp ); -#ifdef USE_TILE + // col += wherex(); 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--) + for (int i = 14-col; i > 0; i--) cprintf(" "); - draw_hp_bar(you.hp, you.hp_max); -#else - clear_to_end_of_line(); -#endif + draw_hp_bar(19, y, you.hp, you.hp_max); } -static void _print_stats_str() +// XXX: alters state! Does more than just print! +static void _print_stats_str(int x, int y) { if (you.strength < 0) you.strength = 0; @@ -306,7 +307,7 @@ static void _print_stats_str() if (you.max_strength > 72) you.max_strength = 72; - cgotoxy(6, 7, GOTO_STAT); + cgotoxy(x+5, y, GOTO_STAT); if (you.duration[DUR_MIGHT]) textcolor(LIGHTBLUE); // no end of effect warning @@ -324,7 +325,7 @@ static void _print_stats_str() burden_change(); } -static void _print_stats_int() +static void _print_stats_int(int x, int y) { if (you.intel < 0) you.intel = 0; @@ -334,7 +335,7 @@ static void _print_stats_int() if (you.max_intel > 72) you.max_intel = 72; - cgotoxy(6, 8, GOTO_STAT); + cgotoxy(x+5, y, GOTO_STAT); if (you.intel < you.max_intel) textcolor(YELLOW); @@ -348,7 +349,7 @@ static void _print_stats_int() cprintf( " " ); } -static void _print_stats_dex() +static void _print_stats_dex(int x, int y) { if (you.dex < 0) you.dex = 0; @@ -358,7 +359,7 @@ static void _print_stats_dex() if (you.max_dex > 72) you.max_dex = 72; - cgotoxy(6, 9, GOTO_STAT); + cgotoxy(x+5, y, GOTO_STAT); if (you.dex < you.max_dex) textcolor(YELLOW); @@ -372,32 +373,49 @@ static void _print_stats_dex() cprintf( " " ); } -static void _print_stats_ac() +static void _print_stats_ac(int x, int y) { - cgotoxy(5, 5, GOTO_STAT); + cgotoxy(x+4, y, GOTO_STAT); if (you.duration[DUR_STONEMAIL]) _dur_colour( BLUE, (you.duration[DUR_STONEMAIL] <= 6) ); else if (you.duration[DUR_ICY_ARMOUR] || you.duration[DUR_STONESKIN]) textcolor( LIGHTBLUE ); // no end of effect warning - cprintf( "%d ", player_AC() ); + cprintf( "%2d ", player_AC() ); textcolor( LIGHTGREY ); - cgotoxy(11, 5, GOTO_STAT); + cgotoxy(x+4, y+1, GOTO_STAT); if (you.duration[DUR_CONDENSATION_SHIELD] || you.duration[DUR_DIVINE_SHIELD]) { textcolor( LIGHTBLUE ); // no end of effect warning } - cprintf( "(%d) ", player_shield_class() ); + if (you.equip[EQ_SHIELD] == -1) + { + textcolor( DARKGREY ); + cprintf( " - " ); + } + else + { + cprintf( "%2d ", player_shield_class() ); + } textcolor( LIGHTGREY ); } -static void _print_stats_wp() +static void _print_stats_ev(int x, int y) { - cgotoxy(1, 13, GOTO_STAT); + cgotoxy(x+4, y, GOTO_STAT); + if (you.duration[DUR_FORESCRY]) + textcolor(LIGHTBLUE); // no end of effect warning + cprintf( "%2d ", player_evasion() ); + textcolor(LIGHTGREY); +} + +static void _print_stats_wp(int y) +{ + cgotoxy(1, y, GOTO_STAT); textcolor(Options.status_caption_colour); cprintf("Wp: "); if (you.weapon()) @@ -432,9 +450,9 @@ static void _print_stats_wp() clear_to_end_of_line(); } -static void _print_stats_qv() +static void _print_stats_qv(int y) { - cgotoxy(1, 14, GOTO_STAT); + cgotoxy(1, y, GOTO_STAT); textcolor(Options.status_caption_colour); cprintf("Qv: "); @@ -472,11 +490,11 @@ static void _print_stats_qv() // // Prints burden, hunger // Max length: "Encumbered Near Starving (NNN:NNN)" = 34 -static void _print_stats_line1() +static void _print_stats_line1(int y) { - cgotoxy(1, 15, GOTO_STAT); + cgotoxy(1, y, GOTO_STAT); clear_to_end_of_line(); - cgotoxy(1, 15, GOTO_STAT); + cgotoxy(1, y, GOTO_STAT); switch (you.burden_state) { @@ -531,11 +549,11 @@ static void _print_stats_line1() // For colors, see comment at _print_stats_line1 // Prints: pray, holy, teleport, regen, insulation, fly/lev, invis, silence, // conf. touch, bargain, sage -static void _print_stats_line2() +static void _print_stats_line2(int y) { - cgotoxy(1, 16, GOTO_STAT); + cgotoxy(1, y, GOTO_STAT); clear_to_end_of_line(); - cgotoxy(1, 16, GOTO_STAT); + cgotoxy(1, y, GOTO_STAT); // Max length of this line = 8 * 5 - 1 = 39 if (you.duration[DUR_PRAYER]) @@ -638,11 +656,11 @@ static void _print_stats_line2() // For colors, see comment at _print_stats_line1 // Prints confused, beheld, fire, poison, disease, rot, held, glow, // swift, fast, slow, breath -static void _print_stats_line3() +static void _print_stats_line3(int y) { - cgotoxy(1, 17, GOTO_STAT); + cgotoxy(1, y, GOTO_STAT); clear_to_end_of_line(); - cgotoxy(1, 17, GOTO_STAT); + cgotoxy(1, y, GOTO_STAT); // Max length of this line = 7 * 5 + 3 - 1 = 37 // Note the usage of bad_ench_colour() correspond to levels that @@ -749,33 +767,35 @@ void print_stats(void) if (you.redraw_dexterity) you.redraw_evasion = true; - if (you.redraw_hit_points) { you.redraw_hit_points = false; _print_stats_hp(); } - if (you.redraw_magic_points) { you.redraw_magic_points = false; _print_stats_mp(); } - if (you.redraw_strength) { you.redraw_strength = false; _print_stats_str(); } - if (you.redraw_intelligence) { you.redraw_intelligence = false; _print_stats_int(); } - if (you.redraw_dexterity) { you.redraw_dexterity = false; _print_stats_dex(); } - if (you.redraw_armour_class) { you.redraw_armour_class = false; _print_stats_ac(); } - if (you.redraw_evasion) - { - cgotoxy(5, 6, GOTO_STAT); - if (you.duration[DUR_FORESCRY]) - textcolor(LIGHTBLUE); // no end of effect warning - cprintf( "%d ", player_evasion() ); - textcolor(LIGHTGREY); - you.redraw_evasion = 0; - } + // HP: 910/932 (999) + // Magic: 7/7 + // Str: 13 AC: 3 + // Int: 15 Sh: - + // Dex: 14 Ev: 12 + // Gold: 30 + // Level 1 of the Dungeon + + if (you.redraw_hit_points) { you.redraw_hit_points = false; _print_stats_hp ( 1, 3); } + if (you.redraw_magic_points) { you.redraw_magic_points = false; _print_stats_mp ( 1, 4); } + if (you.redraw_strength) { you.redraw_strength = false; _print_stats_str( 1, 5); } + if (you.redraw_intelligence) { you.redraw_intelligence = false; _print_stats_int( 1, 6); } + if (you.redraw_dexterity) { you.redraw_dexterity = false; _print_stats_dex( 1, 7); } + + if (you.redraw_armour_class) { you.redraw_armour_class = false; _print_stats_ac (19, 5); } + // (you.redraw_armour_class) { you.redraw_armour_class = false; _print_stats_sh (19, 6); } + if (you.redraw_evasion) { you.redraw_evasion = false; _print_stats_ev (19, 7); } if (you.redraw_gold) { - cgotoxy(7, 10, GOTO_STAT); + cgotoxy(1+6, 8, GOTO_STAT); cprintf( "%-8d", you.gold ); - you.redraw_gold = 0; + you.redraw_gold = false; } if (you.redraw_experience) { - cgotoxy(13, 11, GOTO_STAT); + cgotoxy(1+12, 9, GOTO_STAT); #if DEBUG_DIAGNOSTICS cprintf( "%d/%lu (%d/%d)", @@ -790,18 +810,18 @@ void print_stats(void) you.redraw_experience = 0; } - if (you.wield_change) { you.wield_change = false; _print_stats_wp(); } - if (you.quiver_change) { you.quiver_change = false; _print_stats_qv(); } + if (you.wield_change) { you.wield_change = false; _print_stats_wp(11); } + if (you.quiver_change) { you.quiver_change = false; _print_stats_qv(12); } if (you.redraw_status_flags & REDRAW_LINE_1_MASK) - _print_stats_line1(); + _print_stats_line1(13); if (you.redraw_status_flags & REDRAW_LINE_2_MASK) - _print_stats_line2(); + _print_stats_line2(14); if (you.redraw_status_flags & REDRAW_LINE_3_MASK) - _print_stats_line3(); + _print_stats_line3(15); you.redraw_status_flags = 0; @@ -809,6 +829,50 @@ void print_stats(void) update_screen(); } // end print_stats() +// For some odd reason, only redrawn on level change. +void print_stats_level(const std::string& description) +{ + cgotoxy(7, 10, GOTO_STAT); + textcolor(LIGHTGREY); +#if DEBUG_DIAGNOSTICS + cprintf( "(%d) ", you.your_level + 1 ); +#endif + cprintf("%s", description.c_str()); + clear_to_end_of_line(); +} + +void draw_border(void) +{ + textcolor( BORDER_COLOR ); + clrscr(); + redraw_skill( you.your_name, player_title() ); + + cgotoxy(1, 2, GOTO_STAT); + cprintf( "%s %s", + species_name( you.species, you.experience_level ).c_str(), + (you.wizard ? "*WIZARD*" : "" ) ); + + textcolor(Options.status_caption_colour); + + cgotoxy( 1, 3, GOTO_STAT); cprintf("HP:"); + cgotoxy( 1, 4, GOTO_STAT); cprintf("Magic:"); + cgotoxy( 1, 5, GOTO_STAT); cprintf("Str:"); + cgotoxy( 1, 6, GOTO_STAT); cprintf("Int:"); + cgotoxy( 1, 7, GOTO_STAT); cprintf("Dex:"); + cgotoxy( 1, 8, GOTO_STAT); cprintf("Gold:"); + cgotoxy( 1, 9, GOTO_STAT); cprintf("Experience:"); + + cgotoxy(19, 5, GOTO_STAT); cprintf("AC:"); + cgotoxy(19, 6, GOTO_STAT); cprintf("Sh:"); + cgotoxy(19, 7, GOTO_STAT); cprintf("Ev:"); + if (Options.show_turns) + { + cgotoxy(19, 8, GOTO_STAT); cprintf("Turn:"); + } + textcolor(LIGHTGREY); + cgotoxy( 1,10, GOTO_STAT); cprintf("Level"); +} // end draw_border() + // ---------------------------------------------------------------------- // Monster pane // ---------------------------------------------------------------------- diff --git a/crawl-ref/source/output.h b/crawl-ref/source/output.h index e3f78f6c31..18a120ca0c 100644 --- a/crawl-ref/source/output.h +++ b/crawl-ref/source/output.h @@ -54,6 +54,8 @@ void draw_mp_bar(int val, int max_val); #endif void print_stats(); +void print_stats_level(const std::string& description); +void draw_border(); void update_monster_pane(); std::vector<formatted_string> get_full_detail(bool calc_unid, long score = -1); diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 2a79c9fd4c..623f27ac10 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -2631,36 +2631,6 @@ void losight(env_show_grid &sh, } -void draw_border(void) -{ - textcolor( BORDER_COLOR ); - clrscr(); - redraw_skill( you.your_name, player_title() ); - - cgotoxy(1, 2, GOTO_STAT); - cprintf( "%s %s", - species_name( you.species, you.experience_level ).c_str(), - (you.wizard ? "*WIZARD*" : "" ) ); - - textcolor(Options.status_caption_colour); - cgotoxy(1, 3, GOTO_STAT); cprintf("HP:"); - cgotoxy(1, 4, GOTO_STAT); cprintf("Magic:"); - cgotoxy(1, 5, GOTO_STAT); cprintf("AC:"); - cgotoxy(1, 6, GOTO_STAT); cprintf("EV:"); - cgotoxy(1, 7, GOTO_STAT); cprintf("Str:"); - cgotoxy(1, 8, GOTO_STAT); cprintf("Int:"); - cgotoxy(1, 9, GOTO_STAT); cprintf("Dex:"); - cgotoxy(1, 10, GOTO_STAT); cprintf("Gold:"); - if (Options.show_turns) - { - cgotoxy(1 + 15, 10, GOTO_STAT); - cprintf("Turn:"); - } - cgotoxy(1, 11, GOTO_STAT); cprintf("Experience:"); - textcolor(LIGHTGREY); - cgotoxy(1, 12, GOTO_STAT); cprintf("Level"); -} // end draw_border() - // Determines if the given feature is present at (x, y) in _grid_ coordinates. // If you have map coords, add (1, 1) to get grid coords. // Use one of @@ -4919,8 +4889,15 @@ void crawl_view_buffer::size(const coord_def &sz) // define VIEW_MIN_WIDTH defined elsewhere // define VIEW_MAX_WIDTH use Options.view_max_width #define HUD_WIDTH 39 -#define HUD_HEIGHT 17 +#ifdef USE_TILE +// Tile mode doesn't need to compress the HUD, and uses this area for +// other things. I don't want to risk breaking tiles, so leaving alone --pld +# define HUD_HEIGHT 17 +#else +# define HUD_HEIGHT 15 +#endif #define MSG_MIN_HEIGHT 6 +#define MSG_MAX_HEIGHT 10 // #define MLIST_MIN_HEIGHT use Options.mlist_min_height #define MLIST_MIN_WIDTH 25 /* non-inline layout only */ #define MLIST_MAX_WIDTH 42 @@ -4999,20 +4976,17 @@ class _inline_layout : public _layout _increment(mlistsz.x, leftover_x(), INT_MAX); msgsz.x = termsz.x-1; // Can't use last character - // y: View gets leftover; then mlist; then message - // mlist might be left with less than MLIST_MIN_HEIGHT, but - // that's the breaks. + // y: View gets as much as it wants + // mlist tries to get at least its minimum + // msg expands as much as it wants + // mlist gets any leftovers if (leftover_y() < 0) { return false; } - { - const int saved_leftover_y = leftover_y(); - _increment(viewsz.y, saved_leftover_y, Options.view_max_height); - if ((viewsz.y % 2) != 1) --viewsz.y; - if (mlistsz.y < Options.mlist_min_height) - { - _increment(mlistsz.y, saved_leftover_y, Options.mlist_min_height); - } - } - _increment(msgsz.y, leftover_y(), INT_MAX); + _increment(viewsz.y, leftover_leftcol_y(), Options.view_max_height); + if ((viewsz.y % 2) != 1) --viewsz.y; + if (mlistsz.y < Options.mlist_min_height) + _increment(mlistsz.y, leftover_rightcol_y(), Options.mlist_min_height); + _increment(msgsz.y, leftover_y(), MSG_MAX_HEIGHT); + _increment(mlistsz.y, leftover_rightcol_y(), INT_MAX); // Finish off by doing the positions viewp = termp; @@ -5029,11 +5003,11 @@ class _inline_layout : public _layout int width = (viewsz.x + hud_gutter + std::max(hudsz.x, mlistsz.x)); return (termsz.x - width); } + int leftover_rightcol_y() const { return termsz.y-hudsz.y-mlistsz.y-msgsz.y; } + int leftover_leftcol_y() const { return termsz.y-viewsz.y-msgsz.y; } int leftover_y() const { - // hud+mlist can grow longer than the view, believe it or not - int height = std::max(viewsz.y, hudsz.y+mlistsz.y) + msgsz.y; - return (termsz.y - height); + return std::min(leftover_rightcol_y(), leftover_leftcol_y()); } }; diff --git a/crawl-ref/source/view.h b/crawl-ref/source/view.h index f8bf7f3e0b..bc7cc13f8f 100644 --- a/crawl-ref/source/view.h +++ b/crawl-ref/source/view.h @@ -83,12 +83,6 @@ bool mons_near(const monsters *monster, unsigned int foe = MHITYOU); // last updated 12may2000 {dlb} /* *********************************************************************** - * called from: acr - player - stuff - * *********************************************************************** */ -void draw_border(void); - -// last updated 12may2000 {dlb} -/* *********************************************************************** * called from: acr - view * *********************************************************************** */ void item(void); |