From 1a6236d61bcee1288e94595c4217920b339445b4 Mon Sep 17 00:00:00 2001 From: haranp Date: Sun, 7 Jan 2007 22:00:13 +0000 Subject: Implemented some of David's ideas: Improved the help browser somewhat and added some hotkeys. The 'm' screen now lets you see your aptitudes with '!' (if you're allowed to know them, that is.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@798 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/command.cc | 117 ++++++++++++++++++++++++++++---------------- crawl-ref/source/files.cc | 3 ++ crawl-ref/source/menu.cc | 13 +++-- crawl-ref/source/menu.h | 5 +- crawl-ref/source/skills2.cc | 28 +++++++++-- 5 files changed, 114 insertions(+), 52 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 555f0ec203..d1c260f218 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -23,6 +23,8 @@ #include "externs.h" #include "abl-show.h" +#include "chardump.h" +#include "files.h" #include "invent.h" #include "itemname.h" #include "item_use.h" @@ -637,7 +639,33 @@ static void add_file_to_scroller(FILE* fp, formatted_scroller& m, } } - + +struct help_file +{ + const char* name; + int hotkey; + bool auto_hotkey; +}; + +help_file help_files[] = { + { "crawl_manual.txt", '*', true }, + { "tables.txt", '%', false }, + { "readme.txt", '^', false }, + { NULL, 0, false } +}; + +static int keyhelp_keyfilter(int ch) +{ + switch (ch) + { + case ':': + display_notes(); + return -1; + default: + return ch; + } +} + static void show_keyhelp_menu(const std::vector &lines, bool with_manual) { @@ -645,61 +673,63 @@ static void show_keyhelp_menu(const std::vector &lines, // Set flags, and don't use easy exit. cmd_help.set_flags(MF_NOSELECT | MF_ALWAYS_SHOW_MORE | MF_NOWRAP, false); - + // FIXME: Allow for hiding Page down when at the end of the listing, ditto // for page up at start of listing. + cmd_help.set_more( formatted_string::parse_string( + "[ + : Page down. - : Page up." + " Esc exits.]")); + if ( with_manual ) - cmd_help.set_more( formatted_string::parse_string( - "[ + : Page down. - : Page up." - " ? or letter for manual. Esc exits.]")); - else - cmd_help.set_more( formatted_string::parse_string( - "[ + : Page down. - : Page up." - " Esc exits.]")); + { + cmd_help.f_keyfilter = keyhelp_keyfilter; + column_composer cols(1); + + cols.add_formatted( + 0, + "Dungeon Crawl Help\n" + "\n" + "Press one of the following keys to obtain more information on a certain\n" + "aspect of Dungeon Crawl.\n" + + "?: Key Help Screens\n" + "*: Read the manual\n" + "^: Quickstart Guide\n" + ":: Browse Notes\n" + "%: Table of Aptitudes\n", + true, true, cmdhelp_textfilter); + std::vector blines = cols.formatted_lines(); + unsigned i; + for (i = 0; i < blines.size(); ++i ) + cmd_help.add_item_formatted_string(blines[i]); + + while ( static_cast(++i) < get_number_of_lines() ) + cmd_help.add_item_string(""); + } for (unsigned i = 0; i < lines.size(); ++i ) - cmd_help.add_item_formatted_string(lines[i]); + cmd_help.add_item_formatted_string(lines[i], (i == 0 ? '?' : 0) ); if ( with_manual ) { - FILE* fp; -#ifdef DATA_DIR_PATH - fp = fopen(DATA_DIR_PATH "/crawl_manual.txt", "r"); -#else - fp = fopen("../docs/crawl_manual.txt", "r"); - if ( !fp ) - fp = fopen("./docs/crawl_manual.txt", "r"); -#endif - if ( fp ) + for ( int i = 0; help_files[i].name != NULL; ++i ) { + FILE* fp=fopen(datafile_path(std::string(help_files[i].name)).c_str(),"r"); + if ( !fp ) + continue; + // put in a separator cmd_help.add_item_string(""); - cmd_help.add_item_string(std::string(get_number_of_cols()-1,'-')); - add_file_to_scroller(fp, cmd_help, '?', true); - fclose(fp); - } + cmd_help.add_item_string(std::string(get_number_of_cols()-1,'=')); + cmd_help.add_item_string(""); -#ifdef DATA_DIR_PATH - fp = fopen(DATA_DIR_PATH "/tables.txt", "r"); -#else - fp = fopen("../docs/tables.txt", "r"); - if ( !fp ) - fp = fopen("./docs/tables.txt", "r"); -#endif - if ( fp ) - { - // put in a separator - for ( int i = 0; i < get_number_of_lines() - 5; ++i ) - cmd_help.add_item_string(""); - MenuEntry* me = new MenuEntry("Tables"); - me->level = MEL_TITLE; - me->colour = WHITE; - me->add_hotkey('s'); - cmd_help.add_entry(me); - add_file_to_scroller(fp, cmd_help, 0, false); + // and the file itself + add_file_to_scroller(fp, cmd_help, help_files[i].hotkey, + help_files[i].auto_hotkey); + + // done with this file fclose(fp); } - } cmd_help.show(); } @@ -723,9 +753,10 @@ void list_commands(bool wizard) list_wizard_commands(); return; } - + // 2 columns, split at column 40. column_composer cols(2, 41); + // Page size is number of lines - one line for --more-- prompt. cols.set_pagesize(get_number_of_lines() - 1); diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index cb71f6161c..78db7bf7d5 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -367,6 +367,9 @@ std::string datafile_path(const std::string &basename) std::string("dat") + FILE_SEPARATOR, std::string("data") + FILE_SEPARATOR, std::string("crawl-data") + FILE_SEPARATOR, + std::string("..")+FILE_SEPARATOR+std::string("docs")+FILE_SEPARATOR, + std::string("..") + FILE_SEPARATOR, + std::string(".") + FILE_SEPARATOR, "", }; diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc index 2f417f5179..28e5973ef8 100644 --- a/crawl-ref/source/menu.cc +++ b/crawl-ref/source/menu.cc @@ -1317,16 +1317,22 @@ void formatted_scroller::add_text(const std::string& s) } } -void formatted_scroller::add_item_formatted_string(const formatted_string& fs) +void formatted_scroller::add_item_formatted_string(const formatted_string& fs, + int hotkey) { MenuEntry* me = new MenuEntry; me->data = new formatted_string(fs); + if ( hotkey ) + me->add_hotkey(hotkey); add_entry(me); } -void formatted_scroller::add_item_string(const std::string& s) +void formatted_scroller::add_item_string(const std::string& s, int hotkey) { - add_entry( new MenuEntry(s) ); + MenuEntry* me = new MenuEntry(s); + if ( hotkey ) + me->add_hotkey(hotkey); + add_entry(me); } void formatted_scroller::draw_index_item(int index, const MenuEntry *me) const @@ -1419,6 +1425,7 @@ bool formatted_scroller::process_key( int keyin ) { case 0: return true; + case -1: case CK_ESCAPE: return false; case ' ': case '+': case '=': case CK_PGDN: case '>': case '\'': diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h index a67cca68e9..19fb8d4370 100644 --- a/crawl-ref/source/menu.h +++ b/crawl-ref/source/menu.h @@ -423,8 +423,9 @@ class formatted_scroller : public Menu public: formatted_scroller() {} formatted_scroller(int flags, const std::string& s); - virtual void add_item_formatted_string(const formatted_string& s); - virtual void add_item_string(const std::string& s); + virtual void add_item_formatted_string(const formatted_string& s, + int hotkey = 0); + virtual void add_item_string(const std::string& s, int hotkey = 0); virtual void add_text(const std::string& s); virtual ~formatted_scroller(); protected: diff --git a/crawl-ref/source/skills2.cc b/crawl-ref/source/skills2.cc index 42f42a1f85..0ae4458987 100644 --- a/crawl-ref/source/skills2.cc +++ b/crawl-ref/source/skills2.cc @@ -1820,6 +1820,7 @@ void show_skills(void) int i; int x; menu_letter lcount; + bool show_aptitudes = false; const int num_lines = get_number_of_lines(); @@ -1919,10 +1920,17 @@ void show_skills(void) if ( percent_done == 0 ) ++percent_done; - if ( !Options.increasing_skill_progress ) - cprintf( " (%d)", (100 - percent_done) / 10 ); + if ( !show_aptitudes ) + { + if ( !Options.increasing_skill_progress ) + cprintf( " (%d)", (100 - percent_done) / 10 ); + else + cprintf( " (%2d%%)", (percent_done / 5) * 5 ); + } else - cprintf( " (%2d%%)", (percent_done / 5) * 5 ); + { + cprintf(" %3d ", spec_abil); + } } scrln++; @@ -1930,10 +1938,16 @@ void show_skills(void) } // if any more skills added, must adapt letters to go into caps - gotoxy(1, bottom_line); + gotoxy(1, bottom_line-1); textcolor(LIGHTGREY); cprintf("Press the letter of a skill to choose whether you want to practise it."); + if (!player_genus(GENPC_DRACONIAN) || you.max_level >= 7) + { + gotoxy(1, bottom_line); + cprintf("Press '!' to toggle between aptitude and progress display."); + } + char get_thing; get_thing = getch(); @@ -1942,6 +1956,12 @@ void show_skills(void) getch(); else { + if (get_thing == '!' && (!player_genus(GENPC_DRACONIAN) || + you.max_level >= 7)) + { + show_aptitudes = !show_aptitudes; + goto reprint_stuff; + } if ((get_thing >= 'a' && get_thing <= 'z') || (get_thing >= 'A' && get_thing <= 'Z')) { -- cgit v1.2.3-54-g00ecf