From f83cdd076f9f2642fb8a044af7d6b316d89056a0 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Wed, 9 May 2007 15:42:10 +0000 Subject: Added help for interlevel travel prompts. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1440 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/command.cc | 134 +++++++++++++++++++++++++++----------------- crawl-ref/source/command.h | 2 + crawl-ref/source/travel.cc | 76 ++++++++++++++----------- 3 files changed, 128 insertions(+), 84 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 8b17d088bd..429790f7cd 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -516,54 +516,73 @@ static bool cmdhelp_textfilter(const std::string &tag) } static const char *level_map_help = - "Level Map ('X' in main screen):\n" - "Esc : leave level map (also Space)\n" - "Dir.: move cursor\n" - "/ Dir., Shift-Dir.: move cursor far\n" - "-/+ : scroll level map up/down\n" - ". : travel (also Enter and , and ;)\n" - " (moves cursor to last travel\n" - " destination if still on @)\n" - "<</> : cycle through up/down stairs\n" - "^ : cycle through traps\n" - "Tab : cycle through shops and portals\n" - "X : cycle through travel eXclusions\n" - "W : cycle through waypoints\n" - "* : cycle forward through stashes\n" - "/ : cycle backward through stashes\n" - "_ : cycle through altars\n" - "Ctrl-X : set travel eXclusion\n" - "Ctrl-E : Erase all travel exclusions\n" - "Ctrl-W : set Waypoint\n" - "Ctrl-C : Clear level and main maps\n" - " \n" - " \n" - " \n"; + "Level Map ('X' in main screen):\n" + "Esc : leave level map (also Space)\n" + "Dir.: move cursor\n" + "/ Dir., Shift-Dir.: move cursor far\n" + "-/+ : scroll level map up/down\n" + ". : travel (also Enter and , and ;)\n" + " (moves cursor to last travel\n" + " destination if still on @)\n" + "<</> : cycle through up/down stairs\n" + "^ : cycle through traps\n" + "Tab : cycle through shops and portals\n" + "X : cycle through travel eXclusions\n" + "W : cycle through waypoints\n" + "* : cycle forward through stashes\n" + "/ : cycle backward through stashes\n" + "_ : cycle through altars\n" + "Ctrl-X : set travel eXclusion\n" + "Ctrl-E : Erase all travel exclusions\n" + "Ctrl-W : set Waypoint\n" + "Ctrl-C : Clear level and main maps\n" + " \n" + " \n" + " \n"; static const char *targeting_help = - "Examine surroundings ('x in main):\n" - "Esc : cancel (also Space)\n" - "Dir.: move cursor in that direction\n" - ". : move to cursor (also Enter, Del)\n" - "v : describe monster under cursor\n" - "+ : cycle monsters forward (also =)\n" - "- : cycle monsters backward\n" - "* : cycle objects forward\n" - "/ : cycle objects backward (also ;)\n" - "^ : cycle through traps\n" - "_ : cycle through altars\n" - "<</> : cycle through up/down stairs\n" - "Tab : cycle through shops and portals\n" - "Ctrl-F : cycle monster cycle mode\n" - " \n" - "Targeting (like zapping wands/spells):\n" - "The keys from examining surroundings\n" - "work here, too. Additional keys are\n" - ". : fire at target (Enter, Del, Space)\n" - "! : fire at target and stop there\n" - "p : fire at Previous target (also t, f)\n" - ": : hide beam\n" - "Shift-Dir : shoot straight-line beam\n"; + "Examine surroundings ('x in main):\n" + "Esc : cancel (also Space)\n" + "Dir.: move cursor in that direction\n" + ". : move to cursor (also Enter, Del)\n" + "v : describe monster under cursor\n" + "+ : cycle monsters forward (also =)\n" + "- : cycle monsters backward\n" + "* : cycle objects forward\n" + "/ : cycle objects backward (also ;)\n" + "^ : cycle through traps\n" + "_ : cycle through altars\n" + "<</> : cycle through up/down stairs\n" + "Tab : cycle through shops and portals\n" + "Ctrl-F : cycle monster cycle mode\n" + " \n" + "Targeting (like zapping wands/spells):\n" + "The keys from examining surroundings\n" + "work here, too. Additional keys are\n" + ". : fire at target (Enter, Del, Space)\n" + "! : fire at target and stop there\n" + "p : fire at Previous target (also t, f)\n" + ": : hide beam\n" + "Shift-Dir : shoot straight-line beam\n"; + +static const char *interlevel_travel_branch_help = + "Interlevel Travel (choose a branch):\n" + " Use the shortcut letter for a branch to select the branch for travel.\n" + " Enter : Repeat last interlevel travel.\n" + " . : Travel to a level in the current branch.\n" + " << : Go up the nearest stairs.\n" + " > : Go down the nearest stairs.\n" + " Ctrl-P : Travel to a level in the branch above this one.\n" + " * : Show available waypoints (if any are set).\n" + " 0-9 : Go to the numbered waypoint.\n"; + +static const char *interlevel_travel_depth_help = + "Interlevel Travel (go to a specific level in the selected branch)\n" + " Type in the level number you want to go to and hit Enter, or use:\n" + " Enter : Go to the default level.\n" + " << : Change the default to one level above the current.\n" + " > : Change default to one level below the current.\n" + " -/p : Change default to the branch above this one.\n"; // Add the contents of the file fp to the scroller menu m. // If first_hotkey is nonzero, that will be the hotkey for the @@ -647,12 +666,16 @@ static int keyhelp_keyfilter(int ch) } static void show_keyhelp_menu(const std::vector &lines, - bool with_manual, int hotkey = 0) + bool with_manual, bool easy_exit = false, + int hotkey = 0) { formatted_scroller cmd_help; - // Set flags, and don't use easy exit. - cmd_help.set_flags(MF_NOSELECT | MF_ALWAYS_SHOW_MORE | MF_NOWRAP, false); + // Set flags, and use easy exit if necessary. + int flags = MF_NOSELECT | MF_ALWAYS_SHOW_MORE | MF_NOWRAP; + if (easy_exit) + flags |= MF_EASY_EXIT; + cmd_help.set_flags(flags, false); // FIXME: Allow for hiding Page down when at the end of the listing, ditto // for page up at start of listing. @@ -758,7 +781,7 @@ void show_specific_help( const char* help ) formatted_lines.push_back( formatted_string::parse_string( lines[i], true, cmdhelp_textfilter)); - show_keyhelp_menu(formatted_lines, false); + show_keyhelp_menu(formatted_lines, false, true); } void show_levelmap_help() @@ -771,6 +794,15 @@ void show_targeting_help() show_specific_help( targeting_help ); } +void show_interlevel_travel_branch_help() +{ + show_specific_help( interlevel_travel_branch_help ); +} + +void show_interlevel_travel_depth_help() +{ + show_specific_help( interlevel_travel_depth_help ); +} void list_commands(bool wizard, int hotkey) { @@ -994,7 +1026,7 @@ void list_commands(bool wizard, int hotkey) "stashes, and Ctrl-E to erase them.\n", true, true, cmdhelp_textfilter); - show_keyhelp_menu(cols.formatted_lines(), true, hotkey); + show_keyhelp_menu(cols.formatted_lines(), true, false, hotkey); } void list_tutorial_help() diff --git a/crawl-ref/source/command.h b/crawl-ref/source/command.h index d1155b7f4f..338ef6489c 100644 --- a/crawl-ref/source/command.h +++ b/crawl-ref/source/command.h @@ -61,6 +61,8 @@ void swap_inv_slots(int slot1, int slot2, bool verbose); void show_levelmap_help(); void show_targeting_help(); +void show_interlevel_travel_branch_help(); +void show_interlevel_travel_depth_help(); void list_commands(bool wizard, int hotkey = 0); void list_tutorial_help(void); diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index cb620c2460..f8f4cc5336 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -13,6 +13,7 @@ #include "files.h" #include "FixAry.h" #include "branch.h" +#include "command.h" #include "clua.h" #include "delay.h" #include "describe.h" @@ -1852,33 +1853,38 @@ static int prompt_travel_branch(int prompt_flags) mpr(line.c_str()); } - std::string shortcuts; - if ((*trans_travel_dest && remember_targ) - || (allow_waypoints && (waycount || waypoint_list))) + std::string shortcuts = "("; { - shortcuts = "("; - if (waypoint_list) - shortcuts += "[*] lists branches"; - else if (waycount) - shortcuts += "[*] lists waypoints"; + std::vector segs; + if (allow_waypoints) + { + if (waypoint_list) + segs.push_back("[*] lists branches"); + else if (waycount) + segs.push_back("[*] lists waypoints"); + } if (*trans_travel_dest && remember_targ) - { - if (waypoint_list || waycount) - shortcuts += ", "; + segs.push_back( + make_stringf("[Enter] for %s", trans_travel_dest) ); - shortcuts += make_stringf("[Enter] for %s", - trans_travel_dest); - } + segs.push_back("[?] for help"); + + shortcuts += comma_separated_line(segs.begin(), segs.end(), + ", ", ", "); shortcuts += ") "; } - mprf(MSGCH_PROMPT, "Where do you want to go? %s", shortcuts.c_str()); + mprf(MSGCH_PROMPT, "Where to? %s", shortcuts.c_str()); int keyin = get_ch(); switch (keyin) { case ESCAPE: return (ID_CANCEL); + case '?': + show_interlevel_travel_branch_help(); + redraw_screen(); + break; case '\n': case '\r': return (ID_REPEAT); case '<': @@ -1910,21 +1916,6 @@ static int prompt_travel_branch(int prompt_flags) } } -static int travel_depth_keyfilter(int &c) -{ - switch (c) - { - case '<': case '>': - return (-1); - case '-': - case CONTROL('P'): case 'p': - c = '-'; // Make uniform. - return (-1); - default: - return (1); - } -} - static bool is_easy_exiting_branch(int branch) { return branches[branch].any_upstair_exits; @@ -1976,11 +1967,30 @@ static level_id find_down_level() return (find_down_level(level_id::current())); } +static int travel_depth_keyfilter(int &c) +{ + switch (c) + { + case '<': case '>': case '?': + return (-1); + case '-': + case CONTROL('P'): case 'p': + c = '-'; // Make uniform. + return (-1); + default: + return (1); + } +} + static void travel_depth_munge(int munge_method, branch_type *br, int *depth) { level_id lid(*br, *depth); switch (munge_method) { + case '?': + show_interlevel_travel_depth_help(); + redraw_screen(); + return; case '<': lid = find_up_level(lid); break; @@ -2009,7 +2019,7 @@ static level_id prompt_travel_depth(const level_id &id) { mesclr(true); mprf(MSGCH_PROMPT, "What level of %s? " - "(default %d) ", branches[branch].longname, depth); + "(default %d, [?] for help) ", branches[branch].longname, depth); char buf[100]; const int response = @@ -2046,7 +2056,7 @@ level_pos prompt_translevel_target(int prompt_flags) if (branch == ID_UP) { target = find_up_level(); - if (target.id.depth > -1 && remember_targ) + if (target.id.depth > 0 && remember_targ) set_trans_travel_dest(trans_travel_dest, sizeof trans_travel_dest, target); return (target); @@ -2055,7 +2065,7 @@ level_pos prompt_translevel_target(int prompt_flags) if (branch == ID_DOWN) { target = find_down_level(); - if (target.id.depth > -1 && remember_targ) + if (target.id.depth > 0 && remember_targ) set_trans_travel_dest(trans_travel_dest, sizeof trans_travel_dest, target); return (target); -- cgit v1.2.3-54-g00ecf