From e94375e1a0ecdbfa3032609c29a42eb071d3682a Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Tue, 8 Jul 2008 00:51:16 +0000 Subject: Apply tutorial fixes as well as the macro/wininit path to 0.4. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.4@6448 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/docs/options_guide.txt | 12 +++++-- crawl-ref/settings/init.txt | 1 + crawl-ref/source/files.cc | 4 +-- crawl-ref/source/initfile.cc | 14 ++++++--- crawl-ref/source/libgui.cc | 18 ++++++++++- crawl-ref/source/macro.cc | 11 +++---- crawl-ref/source/newgame.cc | 1 - crawl-ref/source/tutorial.cc | 68 +++++++++++++++++++++------------------- 8 files changed, 78 insertions(+), 51 deletions(-) diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt index 9e708949d5..421fdc9d90 100644 --- a/crawl-ref/docs/options_guide.txt +++ b/crawl-ref/docs/options_guide.txt @@ -17,7 +17,7 @@ The contents of this text are: weapon, book, chaos_knight, death_knight, priest, race, class, random_pick, good_random 2- File System and Sound. - crawl_dir, morgue_dir, save_dir, sound + crawl_dir, morgue_dir, save_dir, macro_dir, sound 3- Lua files. stash.lua, wield.lua, kills.lua, runrest.lua, gearset.lua, eat.lua, pickup.lua, trapwalk.lua @@ -280,8 +280,9 @@ good_random = true ================ crawl_dir = - Directory for reading macro.txt. - It should end with the path delimiter. + The path used for the relative paths when looking for other + files. Defaults to the directory that contains the Crawl + executable. morgue_dir = morgue Directory where morgue dumps files (morgue*.txt and @@ -292,6 +293,11 @@ save_dir = saves ignored depending on the settings used to compile Crawl, but should be honoured for the official Crawl binaries. +macro_dir = settings/ + Directory for reading macro.txt. + For tile games, wininit.txt will also be stored here. + It should end with the path delimiter. + sound = : Plays the sound file if a message contains regex. The regex should not include commas or colons. For example diff --git a/crawl-ref/settings/init.txt b/crawl-ref/settings/init.txt index cd1f75f9bb..0354100b66 100644 --- a/crawl-ref/settings/init.txt +++ b/crawl-ref/settings/init.txt @@ -71,6 +71,7 @@ # crawl_dir = # morgue_dir = morgue # save_dir = saves +macro_dir = settings/ # sound = : ##### 3- Lua Files ################################################# diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index c906a36123..f00a8cf58a 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -527,19 +527,19 @@ std::string datafile_path(std::string basename, #endif for (unsigned b = 0, size = bases.size(); b < size; ++b) - { for (unsigned p = 0; p < sizeof(prefixes) / sizeof(*prefixes); ++p) { std::string name = bases[b] + prefixes[p] + basename; if (file_exists(name)) return (name); } - } // Die horribly. if (croak_on_fail) + { end(1, false, "Cannot find data file '%s' anywhere, aborting\n", basename.c_str()); + } return (""); } diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 098db26920..08ca799cb2 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -1134,10 +1134,10 @@ static std::string _find_crawlrc() } // Check all possibilities for init.txt - for ( int i = 0; locations_data[i][1] != NULL; ++i ) + for (int i = 0; locations_data[i][1] != NULL; ++i) { // Don't look at unset options - if ( locations_data[i][0] != NULL ) + if (locations_data[i][0] != NULL) { const std::string rc = catpath(locations_data[i][0], locations_data[i][1]); @@ -1808,7 +1808,7 @@ void game_options::read_option_line(const std::string &str, bool runscript) // Keep unlowercased field around const std::string orig_field = field; - if (key != "name" && key != "crawl_dir" + if (key != "name" && key != "crawl_dir" && key != "macro_dir" && key != "race" && key != "class" && key != "ban_pickup" && key != "autopickup_exceptions" && key != "stop_travel" && key != "sound" @@ -2174,6 +2174,10 @@ void game_options::read_option_line(const std::string &str, bool runscript) // if the user puts two crawl_dir lines in the init file. SysEnv.crawl_dir = field; } + else if (key == "macro_dir") + { + macro_dir = field; + } #endif else if (key == "race") { @@ -3039,10 +3043,10 @@ void get_system_environment(void) } #endif - // The full path to the init file -- this over-rides CRAWL_DIR + // The full path to the init file -- this overrides CRAWL_DIR. SysEnv.crawl_rc = check_string( getenv("CRAWL_RC") ); - // rename giant and giant spiked clubs + // Rename giant and giant spiked clubs. SysEnv.board_with_nail = (getenv("BOARD_WITH_NAIL") != NULL); #ifdef MULTIUSER diff --git a/crawl-ref/source/libgui.cc b/crawl-ref/source/libgui.cc index 8b5ae1db7f..6fb7c56f7e 100644 --- a/crawl-ref/source/libgui.cc +++ b/crawl-ref/source/libgui.cc @@ -28,6 +28,7 @@ #include "it_use2.h" #include "externs.h" #include "guic.h" +#include "initfile.h" #include "message.h" #include "misc.h" #include "mon-util.h" @@ -804,8 +805,23 @@ static void _libgui_save_prefs() strncpy(dummy_str[pref_mode][idx], (char *)p->ptr, MAX_PREF_CHAR); } + // Use the same directory as for macros. + // (Yes, this is an arbitrary decision.) + std::string dir = !Options.macro_dir.empty() ? Options.macro_dir : + !SysEnv.crawl_dir.empty() ? SysEnv.crawl_dir : ""; + + if (!dir.empty()) + { +#ifndef DGL_MACRO_ABSOLUTE_PATH + if (dir[dir.length() - 1] != FILE_SEPARATOR) + dir += FILE_SEPARATOR; +#endif + } + const char *baseTxt = "wininit.txt"; - std::string winTxtString = datafile_path(baseTxt, false, true); + std::string winTxtString = dir + baseTxt; + if ( (fp = fopen(winTxtString.c_str(), "w")) == NULL ) + winTxtString = datafile_path(baseTxt, false, true); const char *winTxt = winTxtString.c_str()[0] == 0 ? baseTxt : winTxtString.c_str(); diff --git a/crawl-ref/source/macro.cc b/crawl-ref/source/macro.cc index 5f2542bf39..712cd8c39d 100644 --- a/crawl-ref/source/macro.cc +++ b/crawl-ref/source/macro.cc @@ -158,7 +158,7 @@ static int userfunc_getindex(const std::string &fname) return (i); } - // Pass 2 to hunt for gaps + // Pass 2 to hunt for gaps. for (int i = 0, count = userfunctions.size(); i < count; ++i) { if (userfunctions[i].empty()) @@ -172,14 +172,11 @@ static int userfunc_getindex(const std::string &fname) return (userfunctions.size() - 1); } -/* - * Returns the name of the file that contains macros. - */ +// Returns the name of the file that contains macros. static std::string get_macro_file() { - std::string dir = - !Options.macro_dir.empty()? Options.macro_dir : - !SysEnv.crawl_dir.empty()? SysEnv.crawl_dir : ""; + std::string dir = !Options.macro_dir.empty() ? Options.macro_dir : + !SysEnv.crawl_dir.empty() ? SysEnv.crawl_dir : ""; if (!dir.empty()) { diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index da04c61468..b1611fa5c9 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -2451,7 +2451,6 @@ static bool _necromancy_okay() case SP_OGRE_MAGE: case SP_DEMONSPAWN: case SP_MUMMY: - case SP_GHOUL: case SP_VAMPIRE: return (true); diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc index 5e2398e238..d817947e01 100644 --- a/crawl-ref/source/tutorial.cc +++ b/crawl-ref/source/tutorial.cc @@ -139,7 +139,7 @@ bool pick_tutorial() { char keyn = c_getch(); - if (keyn == '*') + if (keyn == '*' || keyn == '+') keyn = 'a' + random2(TUT_TYPES_NUM); // Choose character for tutorial game and set starting values. @@ -225,12 +225,12 @@ void print_tutorial_menu(unsigned int type) cprintf("%c - %s %s %s" EOL, letter, species_name(_get_tutorial_species(type), 1).c_str(), - get_class_name(_get_tutorial_job(type)), desc); + get_class_name(_get_tutorial_job(type)), desc); } static species_type _get_tutorial_species(unsigned int type) { - switch(type) + switch (type) { case TUT_BERSERK_CHAR: return SP_MINOTAUR; @@ -511,7 +511,8 @@ static formatted_string _tutorial_map_intro() result += "" EOL; - result += " --more-- Press Escape to skip the basics."; + result += " --more-- " + "Press Escape to skip the basics."; linebreak_string2(result, _get_tutorial_cols()); return formatted_string::parse_block(result, false); @@ -542,7 +543,8 @@ static formatted_string _tutorial_stats_intro() "Don't worry about the rest for now. \n" << "" " \n" - " --more-- Press Escape to skip the basics\n" + " --more-- " + "Press Escape to skip the basics.\n" " \n" " \n"; @@ -562,7 +564,8 @@ static void _tutorial_message_intro() " or by clicking into the message area" #endif "." EOL; - result += " --more-- Press Escape to skip the basics"; + result += " --more-- " + "Press Escape to skip the basics."; mesclr(); formatted_message_history(result, MSGCH_TUTORIAL, 0, _get_tutorial_cols()); @@ -820,7 +823,7 @@ void tutorial_finished() text = "The game keeps an automated logbook for your characters. " "Use ?: to read it. You can enter notes manually " "with the : command. Once your character perishes, " - "two morgue files are left in the /morgue " + "two morgue files are left in the morgue/ " "directory. The one ending in .txt contains a copy of " "your logbook. During play, you can create a dump file " "with #."; @@ -1033,9 +1036,12 @@ void tut_gained_new_skill(int skill) case SK_SHIELDS: case SK_THROWING: case SK_SPELLCASTING: - mpr(get_skill_description(skill).c_str(), MSGCH_TUTORIAL); + { + formatted_message_history(get_skill_description(skill), MSGCH_TUTORIAL, + 0, _get_tutorial_cols()); + stop_running(); break; - + } // Only one message for all magic skills (except Spellcasting). case SK_CONJURATIONS: case SK_ENCHANTMENTS: @@ -1381,9 +1387,9 @@ static void _new_god_conduct() text.str(""); text << "\nYou can check your god's likes and dislikes, as well as your " - "current standing and divine abilites, by typing ^ " + "current standing and divine abilites, by typing ^" #ifdef USE_TILE - "(alternatively press Shift while " + " (alternatively press Shift while " "right-clicking on your avatar)" #endif "."; @@ -1426,7 +1432,7 @@ void learned_something_new(tutorial_event_type seen_what, int x, int y) Options.tutorial_events[seen_what] = 0; Options.tutorial_left--; - switch(seen_what) + switch (seen_what) { case TUT_SEEN_POTION: text << "You have picked up your first potion" @@ -1503,7 +1509,7 @@ void learned_something_new(tutorial_event_type seen_what, int x, int y) case TUT_SEEN_WEAPON: text << "This is the first weapon " #ifndef USE_TILE - "('(') " + "(')') " #endif "you've picked up. Use w " #ifdef USE_TILE @@ -1527,7 +1533,7 @@ void learned_something_new(tutorial_event_type seen_what, int x, int y) case TUT_SEEN_MISSILES: text << "This is the first stack of missiles " #ifndef USE_TILE - "(')') " + "('(') " #endif "you've picked up. Darts can be thrown by hand, but other " "missile types like arrows and needles require a launcher " @@ -1577,7 +1583,8 @@ void learned_something_new(tutorial_event_type seen_what, int x, int y) { text << "\nNote that as a " << species_name(you.species, 1) << " you will be unable to wear " - << (you.species == SP_CENTAUR ? "boots" : "helmets"); + << (you.species == SP_CENTAUR ? "boots" : "helmets") + << "."; } break; @@ -2035,15 +2042,14 @@ void learned_something_new(tutorial_event_type seen_what, int x, int y) case TUT_CHOOSE_STAT: text << "Every third level you may choose what stat to invest in, " - "Strength, Dexterity, or Intelligence.\n" - "Strength influences the amount you can carry, and " - "increases the damage you deal in melee.\n" - "Dexterity increases your evasion and thus influences " - "your chance of dodging attacks or traps.\n" + "Strength, Dexterity, or Intelligence. Strength " + "influences the amount you can carry, and increases the damage " + "you deal in melee. Dexterity increases your evasion " + "and thus influences your chance of dodging attacks or traps. " "Intelligence increases your success in casting spells " - "and decreases the amount by which you hunger when you do so." - "\nNote that it is generally recommended to raise all your " - "stats to a minimum of 7, so as to prevent death by stat loss."; + "and decreases the amount by which you hunger when you do so.\n" + "Note that it is generally recommended to raise all your " + "stats to a minimum of 8, so as to prevent death by stat loss."; break; case TUT_YOU_ENCHANTED: @@ -2714,7 +2720,7 @@ void learned_something_new(tutorial_event_type seen_what, int x, int y) text << "\nAlternatively, you can dump all information pertaining to " "your character into a text file with the # command. " - "You can then find said file in the /morgue folder (" + "You can then find said file in the morgue/ folder (" << you.your_name << ".txt) and read it at your leasure. Also, " "such a file will automatically be created upon death (the " "filename will then also contain the date) but that won't be " @@ -2727,12 +2733,10 @@ void learned_something_new(tutorial_event_type seen_what, int x, int y) if (!text.str().empty()) { - std::string s = text.str(); - formatted_message_history(s, MSGCH_TUTORIAL, 0, _get_tutorial_cols()); - } - - if (is_resting()) + formatted_message_history(text.str(), MSGCH_TUTORIAL, 0, + _get_tutorial_cols()); stop_running(); + } } formatted_string tut_abilities_info() @@ -2857,7 +2861,7 @@ void tutorial_describe_item(const item_def &item) { // You can activate it. ostr << "When wielded, some weapons (such as this one) " - "offer abilities that can be evoked. "; + "offer certain abilities you can activate. "; ostr << _tut_abilities(); break; } @@ -3078,7 +3082,7 @@ void tutorial_describe_item(const item_def &item) if (is_artefact(item) && gives_ability(item)) { ostr << "\nWhen worn, some types of armour (such as this " - "one) offer abilities that can be evoked. "; + "one) offer certain abilities you can activate. "; ostr << _tut_abilities(); } } @@ -3156,7 +3160,7 @@ void tutorial_describe_item(const item_def &item) if (gives_ability(item)) { ostr << "\n\nWhen worn, some types of jewellery (such as this " - "one) offer abilities that can be evoked. "; + "one) offer certain abilities you can activate. "; ostr << _tut_abilities(); } Options.tutorial_events[TUT_SEEN_JEWELLERY] = 0; -- cgit v1.2.3-54-g00ecf