diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-12-03 08:49:53 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-12-03 08:49:53 +0000 |
commit | f5b7f9f83ba80c0e512b886fca3821290a949f79 (patch) | |
tree | c9f0604369bcb6b7dcccf4d1edc394fd7f0b0af9 /crawl-ref/source | |
parent | 00033a21e5e9bce12e82e37cbfccd78a58cd8b4e (diff) | |
download | crawl-ref-f5b7f9f83ba80c0e512b886fca3821290a949f79.tar.gz crawl-ref-f5b7f9f83ba80c0e512b886fca3821290a949f79.zip |
Added hp_colour and mp_colour per 1606160. Removed hp_attention.
hp_warning is still there for the * * * LOW HITPOINT WARNING * * * message.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@543 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/externs.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 77 | ||||
-rw-r--r-- | crawl-ref/source/output.cc | 35 |
3 files changed, 88 insertions, 27 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index f003ea590b..e310410274 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -774,7 +774,6 @@ public: int priest; // choice of god for priests (Zin/Yred) bool random_pick; // randomly generate character int hp_warning; // percentage hp for danger warning - int hp_attention; // percentage hp for danger attention char race; // preselected race char cls; // preselected class bool terse_hand; // use terse description for wielded item @@ -805,6 +804,8 @@ public: int sc_entries; // # of score entries int sc_format; // Format for score entries + std::vector<std::pair<int, int> > hp_colour; + std::vector<std::pair<int, int> > mp_colour; std::string map_file_name; // name of mapping file to use std::vector<text_pattern> banned_objects; // Objects we'll never pick up diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index e340d4c83c..ee6dc4fcd5 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -569,7 +569,6 @@ void game_options::reset_options() easy_confirm = CONFIRM_SAFE_EASY; easy_quit_item_prompts = true; hp_warning = 10; - hp_attention = 25; confirm_self_target = true; safe_autopickup = true; use_notes = true; @@ -706,6 +705,14 @@ void game_options::reset_options() "spells,,overview,mutations,messages,screenshot," "kills,notes"); + hp_colour.clear(); + hp_colour.push_back(std::pair<int,int>(100, LIGHTGREY)); + hp_colour.push_back(std::pair<int,int>(50, YELLOW)); + hp_colour.push_back(std::pair<int,int>(25, RED)); + mp_colour.clear(); + mp_colour.push_back(std::pair<int, int>(100, LIGHTGREY)); + mp_colour.push_back(std::pair<int, int>(50, YELLOW)); + mp_colour.push_back(std::pair<int, int>(25, RED)); banned_objects.clear(); note_monsters.clear(); note_messages.clear(); @@ -1630,16 +1637,6 @@ void game_options::read_option_line(const std::string &str, bool runscript) field.c_str() ); } } - else if (key == "hp_attention") - { - hp_attention = atoi( field.c_str() ); - if (hp_attention < 0 || hp_attention > 100) - { - hp_attention = 0; - fprintf( stderr, "Bad HP attention percentage -- %s\n", - field.c_str() ); - } - } else if (key == "crawl_dir") { // We shouldn't bother to allocate this a second time @@ -1755,8 +1752,7 @@ void game_options::read_option_line(const std::string &str, bool runscript) } else if (key == "autoinscribe") { - std::vector<std::string> thesplit = - split_string(":", field); + std::vector<std::string> thesplit = split_string(":", field); autoinscriptions.push_back( std::pair<text_pattern,std::string>(thesplit[0], thesplit[1])); @@ -1765,15 +1761,62 @@ void game_options::read_option_line(const std::string &str, bool runscript) { map_file_name = field; } + else if (key == "hp_colour" || key == "hp_color") + { + hp_colour.clear(); + std::vector<std::string> thesplit = split_string(",", field); + for ( unsigned i = 0; i < thesplit.size(); ++i ) + { + std::vector<std::string> insplit = split_string(":", thesplit[i]); + int hp_percent = 100; + + if ( insplit.size() == 0 || insplit.size() > 2 || + (insplit.size() == 1 && i != 0) ) + { + fprintf(stderr, "Bad hp_colour string: %s\n", field.c_str()); + break; + } + + if ( insplit.size() == 2 ) + hp_percent = atoi(insplit[0].c_str()); + + int scolour = str_to_colour(insplit[(insplit.size()==1) ? 0 : 1]); + hp_colour.push_back(std::pair<int, int>(hp_percent, scolour)); + } + } + else if (key == "mp_color" || key == "mp_colour") + { + mp_colour.clear(); + std::vector<std::string> thesplit = split_string(",", field); + for ( unsigned i = 0; i < thesplit.size(); ++i ) + { + std::vector<std::string> insplit = split_string(":", thesplit[i]); + int mp_percent = 100; + + if ( insplit.size() == 0 || insplit.size() > 2 || + (insplit.size() == 1 && i != 0) ) + { + fprintf(stderr, "Bad mp_colour string: %s\n", field.c_str()); + break; + } + + if ( insplit.size() == 2 ) + mp_percent = atoi(insplit[0].c_str()); + + int scolour = str_to_colour(insplit[(insplit.size()==1) ? 0 : 1]); + mp_colour.push_back(std::pair<int, int>(mp_percent, scolour)); + } + } else if (key == "note_skill_levels") { std::vector<std::string> thesplit = split_string(",", field); - for ( unsigned i = 0; i < thesplit.size(); ++i ) { + for ( unsigned i = 0; i < thesplit.size(); ++i ) + { int num = atoi(thesplit[i].c_str()); - if ( num > 0 && num <= 27 ) { + if ( num > 0 && num <= 27 ) note_skill_levels.push_back(num); - } - else { + else + { fprintf(stderr, "Bad skill level to note -- %s\n", thesplit[i].c_str()); continue; diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index d63d2f9344..d10f59bf13 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -65,16 +65,19 @@ void print_stats(void) if (you.redraw_hit_points) { const int max_max_hp = you.hp_max + player_rotted(); - const int hp_warn = MAXIMUM( 25, Options.hp_warning ); - const int hp_attent = MAXIMUM( 10, Options.hp_attention ); - + const int hp_percent = (you.hp * 100) / max_max_hp; + for ( unsigned int i = 0; i < Options.hp_colour.size(); ++i ) + { + if ( i+1 == Options.hp_colour.size() || + hp_percent > Options.hp_colour[i+1].first ) + { + textcolor(Options.hp_colour[i].second); + break; + } + } + gotoxy(44, 3); - if (you.hp <= (you.hp_max * hp_warn) / 100) - textcolor(RED); - else if (you.hp <= (you.hp_max * hp_attent) / 100) - textcolor(YELLOW); - cprintf( "%d", you.hp ); textcolor(LIGHTGREY); @@ -94,9 +97,23 @@ void print_stats(void) if (you.redraw_magic_points) { + + const int mp_percent = (you.magic_points * 100) / you.max_magic_points; + for ( unsigned int i = 0; i < Options.mp_colour.size(); ++i ) + { + if ( i+1 == Options.mp_colour.size() || + mp_percent > Options.mp_colour[i+1].first ) + { + textcolor(Options.mp_colour[i].second); + break; + } + } gotoxy(47, 4); - cprintf( "%d/%d", you.magic_points, you.max_magic_points ); + cprintf( "%d", you.magic_points); + + textcolor(LIGHTGREY); + cprintf("/%d", you.max_magic_points ); #ifdef UNIX clear_to_end_of_line(); |