From 6c343fd8e3a09865c8ee23ffeb5da6dc07379cfe Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Sun, 19 Apr 2009 16:06:29 +0000 Subject: Enable menu colour for the 'V' item sub-menu. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9657 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/directn.cc | 2 +- crawl-ref/source/format.cc | 5 +++-- crawl-ref/source/format.h | 3 ++- crawl-ref/source/menu.cc | 5 +++-- crawl-ref/source/xom.cc | 29 ++++++++++++++++++----------- 5 files changed, 27 insertions(+), 17 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 6013f609ff..62af5d962a 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -522,7 +522,7 @@ void full_describe_view() InvMenu desc_menu(MF_SINGLESELECT | MF_ANYPRINTABLE | MF_ALLOW_FORMATTING | MF_SELECT_BY_PAGE); - desc_menu.set_highlighter(NULL); +// desc_menu.set_highlighter(NULL); // FIXME: Need different title for the opposite toggle: // "Visible Monsters/Items (select for more detail, '!' to examine):" std::string title = ""; diff --git a/crawl-ref/source/format.cc b/crawl-ref/source/format.cc index 8ceea8ed91..4dd398cb0c 100644 --- a/crawl-ref/source/format.cc +++ b/crawl-ref/source/format.cc @@ -86,11 +86,12 @@ formatted_string formatted_string::parse_block( formatted_string formatted_string::parse_string( const std::string &s, bool eot_ends_format, - bool (*process)(const std::string &tag)) + bool (*process)(const std::string &tag), + int main_colour) { // Safe assumption, that incoming color is LIGHTGREY std::vector colour_stack; - colour_stack.push_back(LIGHTGREY); + colour_stack.push_back(main_colour); formatted_string fs; diff --git a/crawl-ref/source/format.h b/crawl-ref/source/format.h index 297e793106..bb07698fa3 100644 --- a/crawl-ref/source/format.h +++ b/crawl-ref/source/format.h @@ -57,7 +57,8 @@ public: static formatted_string parse_string( const std::string &s, bool eot_ends_format = true, - bool (*process_tag)(const std::string &tag) = NULL ); + bool (*process_tag)(const std::string &tag) = NULL, + int main_colour = LIGHTGREY ); static void parse_string_to_multiple( const std::string &s, diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc index 62146b0038..46958288b6 100644 --- a/crawl-ref/source/menu.cc +++ b/crawl-ref/source/menu.cc @@ -40,9 +40,10 @@ MenuDisplayText::MenuDisplayText(Menu *menu) : MenuDisplay(menu), m_starty(1) void MenuDisplayText::draw_stock_item(int index, const MenuEntry *me) { - textattr(m_menu->item_colour(index, me)); + const int col = m_menu->item_colour(index, me); + textattr(col); if (m_menu->get_flags() & MF_ALLOW_FORMATTING) - formatted_string::parse_string(me->get_text()).display(); + formatted_string::parse_string(me->get_text(), true, NULL, col).display(); else { std::string text = me->get_text(); diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc index 1c0012ac01..9e0dba7e50 100644 --- a/crawl-ref/source/xom.cc +++ b/crawl-ref/source/xom.cc @@ -179,13 +179,17 @@ bool xom_is_nice(int tension) : std::min((MAX_PIETY - you.piety) / 2, random2(tension))); + const int effective_piety = you.piety + tension_bonus; + ASSERT(effective_piety >= 0 && effective_piety <= MAX_PIETY); + #ifdef DEBUG_XOM mprf(MSGCH_DIAGNOSTICS, - "Xom: tension: %d, piety: %d -> tension bonus = %d", - tension, you.piety, tension_bonus); + "Xom: tension: %d, piety: %d -> tension bonus = %d, eff. piety: %d", + tension, you.piety, tension_bonus, effective_piety); #endif + // Whether Xom is nice depends largely on his mood (== piety). - return (x_chance_in_y(you.piety + tension_bonus, MAX_PIETY)); + return (x_chance_in_y(effective_piety, MAX_PIETY)); } else // CARD_XOM return coinflip(); @@ -482,6 +486,8 @@ static bool _xom_makes_you_cast_random_spell(int sever, int tension) else { const int nxomspells = ARRAYSZ(_xom_nontension_spells); + // spellenum will be at least 3, so we don't run into infinite loops + // for Detect Creatures/Magic Mapping in fully explored levels. spellenum = std::min(nxomspells, std::max(3 + coinflip(), spellenum)); spell = _xom_nontension_spells[random2(spellenum)]; @@ -1463,12 +1469,14 @@ static bool _xom_give_mutations(bool good) const int num_tries = random2(4) + 1; static char mut_buf[80]; - snprintf(mut_buf, sizeof(mut_buf), "give %smutations", + snprintf(mut_buf, sizeof(mut_buf), "give %smutation%s", #ifdef NOTE_DEBUG_XOM - good ? "good " : "random "); + good ? "good " : "random ", #else - ""); + "", #endif + num_tries > 1 ? "s" : ""); + take_note(Note(NOTE_XOM_EFFECT, you.piety, -1, mut_buf), true); mpr("Your body is suffused with distortional energy."); @@ -2943,7 +2951,7 @@ void xom_acts(bool niceness, int sever, int tension) const FixedVector orig_mutation = you.mutation; -#ifdef DEBUG_XOM +#ifdef NOTE_DEBUG_XOM static char xom_buf[100]; snprintf(xom_buf, sizeof(xom_buf), "xom_acts(%s, %d, %d), mood: %d", (niceness ? "true" : "false"), sever, tension, you.piety); @@ -2961,7 +2969,7 @@ void xom_acts(bool niceness, int sever, int tension) { if (was_bored && Options.note_xom_effects) take_note(Note(NOTE_MESSAGE, 0, 0, "XOM is BORED!"), true); -#ifdef DEBUG_XOM +#ifdef NOTE_DEBUG_XOM else if (niceness) { take_note(Note(NOTE_MESSAGE, 0, 0, "good act randomly turned bad"), @@ -2997,9 +3005,8 @@ void xom_acts(bool niceness, int sever, int tension) const std::string msg = "You are now " + new_xom_favour; god_speaks(you.religion, msg.c_str()); } -#ifdef DEBUG_XOM - snprintf(info, INFO_SIZE, "xom_acts(): reroll piety(1/5), piety: %d", - you.piety); +#ifdef NOTE_DEBUG_XOM + snprintf(info, INFO_SIZE, "reroll piety: %d", you.piety); take_note(Note(NOTE_MESSAGE, 0, 0, info), true); #endif } -- cgit v1.2.3-54-g00ecf