From 73fd97218337e3a0603c2496ed9beb5f2a4c71a4 Mon Sep 17 00:00:00 2001 From: Johanna Ploog Date: Sat, 16 Jan 2010 13:37:04 +0100 Subject: More dynamic command display in the command help, including vi movement. --- crawl-ref/source/command.cc | 78 +++++++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 24 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index d1fff9f24c..5260e89e19 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -2147,6 +2147,7 @@ static void _add_command(column_composer &cols, const int column, static void _insert_commands(std::string &desc, std::vector cmds) { + desc = replace_all(desc, "%%", "percent_sign"); for (unsigned int i = 0; i < cmds.size(); ++i) { const std::string::size_type found = desc.find("%"); @@ -2160,6 +2161,7 @@ static void _insert_commands(std::string &desc, std::vector cmds) desc.replace(found, 1, command_name); } desc += "\n"; + desc = replace_all(desc, "percent_sign", "%"); } static void _insert_commands(std::string &desc, const int first, ...) @@ -2248,14 +2250,25 @@ static void _add_formatted_keyhelp(column_composer &cols) "Movement:\n" "To move in a direction or to attack, \n" "use the numpad (try Numlock off and \n" - "on) or vi keys:\n" + "on) or vi keys:\n", + true, true, _cmdhelp_textfilter); + + _insert_commands(cols, 0, " 1 2 3 % % %", + CMD_MOVE_UP_LEFT, CMD_MOVE_UP, CMD_MOVE_UP_RIGHT, 0); + _insert_commands(cols, 0, " \\|/ \\|/", 0); + _insert_commands(cols, 0, " 4-5-6 %-%-%", + CMD_MOVE_LEFT, CMD_MOVE_NOWHERE, CMD_MOVE_RIGHT, 0); + _insert_commands(cols, 0, " /|\\ /|\\", 0); + _insert_commands(cols, 0, " 7 8 9 % % %", + CMD_MOVE_DOWN_LEFT, CMD_MOVE_DOWN, CMD_MOVE_DOWN_RIGHT, 0); +/* " 1 2 3 y k u\n" " \\|/ \\|/\n" " 4-5-6" " h-.-l\n" " /|\\ /|\\\n" - " 7 8 9 b j n\n", - true, true, _cmdhelp_textfilter); + " 7 8 9 b j n\n" +*/ cols.add_formatted( 0, @@ -2294,30 +2307,47 @@ static void _add_formatted_keyhelp(column_composer &cols) " untrap, attack without move\n", false, true, _cmdhelp_textfilter); - std::string item_types = - "\n" - "Item types (and common commands)\n" - ") : hand weapons (wield)\n" - "( : missiles (Quiver, fire, () cycle)\n" - "[ : armour (Wear and Take off)\n" - "% : corpses and food (chop up and eat)\n" - "? : scrolls (read)\n" - "! : potions (quaff)\n" - "= : rings (Put on and Remove)\n" - "\" : amulets (Put on and Remove)\n" - "/ : wands (eVoke)\n" - ""; - - item_types += static_cast(get_item_symbol(SHOW_ITEM_BOOK)); - item_types += - " : books (read, Memorise, zap, Zap)\n" - "\\ : staves and rods (wield and evoke)\n" - "} : miscellaneous items (evoke)\n"; - cols.add_formatted( - 0, item_types, + 0, + "\n" + "Item types (and common commands)\n", true, true, _cmdhelp_textfilter); + _add_insert_commands(cols, 0, 2, "use special Ability (%! for help)", + CMD_USE_ABILITY, CMD_USE_ABILITY, 0); + + _insert_commands(cols, 0, ") : hand weapons (%ield)", + CMD_WIELD_WEAPON, 0); + _insert_commands(cols, 0, "( : missiles (%uiver, " + "%ire, %/% cycle)", + CMD_QUIVER_ITEM, CMD_FIRE, CMD_CYCLE_QUIVER_FORWARD, + CMD_CYCLE_QUIVER_BACKWARD, 0); + _insert_commands(cols, 0, "[ : armour (%ear and %ake off)", + CMD_WEAR_ARMOUR, CMD_REMOVE_ARMOUR, 0); + _insert_commands(cols, 0, "%% : corpses and food (%hop up and %at)", + CMD_BUTCHER, CMD_EAT, 0); + _insert_commands(cols, 0, "? : scrolls (%ead)", + CMD_READ, 0); + _insert_commands(cols, 0, "! : potions (%uaff)", + CMD_QUAFF, 0); + _insert_commands(cols, 0, "= : rings (%ut on and %emove)", + CMD_WEAR_JEWELLERY, CMD_REMOVE_JEWELLERY, 0); + _insert_commands(cols, 0, "\" : amulets (%ut on and %emove)", + CMD_WEAR_JEWELLERY, CMD_REMOVE_JEWELLERY, 0); + _insert_commands(cols, 0, "/ : wands (e%oke)", + CMD_EVOKE, 0); + + std::string item_types = ""; + item_types += static_cast(get_item_symbol(SHOW_ITEM_BOOK)); + item_types += + " : books (%ead, %emorise, %ap, %ap)"; + _insert_commands(cols, 0, item_types, + CMD_READ, CMD_MEMORISE_SPELL, CMD_CAST_SPELL, + CMD_FORCE_CAST_SPELL, 0); + _insert_commands(cols, 0, "\\ : staves and rods (%ield and e%oke)", + CMD_WIELD_WEAPON, CMD_EVOKE_WIELDED, 0); + _insert_commands(cols, 0, "} : miscellaneous items (e%oke)", + CMD_EVOKE, 0); _insert_commands(cols, 0, "$ : gold (% counts gold)", CMD_LIST_GOLD, 0); -- cgit v1.2.3