summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-20 12:19:31 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-20 12:19:31 +0000
commit9ff31d52f2dad36c684c3458c35f0666a0fb28e4 (patch)
treed74cb4ba9591eb4e904d7940c6405d6cc8321fd9 /crawl-ref
parent1c9f524503622db5774b18a6fca37b71739a5946 (diff)
downloadcrawl-ref-9ff31d52f2dad36c684c3458c35f0666a0fb28e4.tar.gz
crawl-ref-9ff31d52f2dad36c684c3458c35f0666a0fb28e4.zip
Fall back to ASCII if Unicode locale is unavailable (Guus). Also queue up startup error messages and display them before the newgame screen instead of emitting them to stderr.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2882 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/externs.h2
-rw-r--r--crawl-ref/source/initfile.cc38
-rw-r--r--crawl-ref/source/newgame.cc8
-rw-r--r--crawl-ref/source/state.cc22
-rw-r--r--crawl-ref/source/state.h6
-rw-r--r--crawl-ref/source/stuff.cc8
6 files changed, 70 insertions, 14 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index eefc257348..d114228678 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -1476,6 +1476,8 @@ public:
bool messaging; // Check for messages.
#endif
+ bool suppress_startup_errors;
+
bool mouse_input;
int view_max_width;
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 31a3aff78a..4bc4c05ecf 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -372,12 +372,14 @@ static unsigned curses_attribute(const std::string &field)
int col = field.find(":");
int colour = str_to_colour(field.substr(col + 1));
if (colour == -1)
- fprintf(stderr, "Bad highlight string -- %s\n", field.c_str());
+ crawl_state.add_startup_error(
+ make_stringf("Bad highlight string -- %s\n", field.c_str()));
else
return CHATTR_HILITE | (colour << 8);
}
else if (field != "none")
- fprintf( stderr, "Bad colour -- %s\n", field.c_str() );
+ crawl_state.add_startup_error(
+ make_stringf( "Bad colour -- %s\n", field.c_str() ) );
return CHATTR_NORMAL;
}
@@ -467,7 +469,8 @@ void game_options::set_activity_interrupt(
delay_type delay = get_delay(delay_name);
if (delay == NUM_DELAYS)
{
- fprintf(stderr, "Unknown delay: %s\n", delay_name.c_str());
+ crawl_state.add_startup_error(
+ make_stringf("Unknown delay: %s\n", delay_name.c_str()));
return;
}
@@ -484,8 +487,9 @@ void game_options::set_activity_interrupt(
activity_interrupt_type ai = get_activity_interrupt(interrupt);
if (ai == NUM_AINTERRUPTS)
{
- fprintf(stderr, "Delay interrupt name \"%s\" not recognised.\n",
- interrupt.c_str());
+ crawl_state.add_startup_error(
+ make_stringf("Delay interrupt name \"%s\" not recognised.\n",
+ interrupt.c_str()));
return;
}
@@ -500,7 +504,8 @@ void game_options::set_activity_interrupt(const std::string &activity_name,
const delay_type delay = get_delay(activity_name);
if (delay == NUM_DELAYS)
{
- fprintf(stderr, "Unknown delay: %s\n", activity_name.c_str());
+ crawl_state.add_startup_error(
+ make_stringf("Unknown delay: %s\n", activity_name.c_str()));
return;
}
@@ -598,6 +603,9 @@ void game_options::reset_options()
(1L << 7) | // jewellery
(1L << 3) | // wands
(1L << 4)); // food
+
+ suppress_startup_errors = false;
+
show_inventory_weights = false;
colour_map = true;
clean_map = false;
@@ -1635,6 +1643,10 @@ void game_options::read_option_line(const std::string &str, bool runscript)
// should weights be shown on inventory items?
show_inventory_weights = read_bool( field, show_inventory_weights );
}
+ else if (key == "suppress_startup_errors")
+ {
+ suppress_startup_errors = read_bool( field, suppress_startup_errors );
+ }
else if (key == "clean_map")
{
// removes monsters/clouds from map
@@ -2099,7 +2111,8 @@ void game_options::read_option_line(const std::string &str, bool runscript)
else if (field == "yes")
wiz_mode = WIZ_YES;
else
- fprintf(stderr, "Unknown wiz_mode option: %s\n", field.c_str());
+ crawl_state.add_startup_error(
+ make_stringf("Unknown wiz_mode option: %s\n", field.c_str()));
#endif
}
else if (key == "ban_pickup")
@@ -2150,7 +2163,8 @@ void game_options::read_option_line(const std::string &str, bool runscript)
if ( insplit.size() == 0 || insplit.size() > 2 ||
(insplit.size() == 1 && i != 0) )
{
- fprintf(stderr, "Bad hp_colour string: %s\n", field.c_str());
+ crawl_state.add_startup_error(
+ make_stringf("Bad hp_colour string: %s\n", field.c_str()));
break;
}
@@ -2173,7 +2187,8 @@ void game_options::read_option_line(const std::string &str, bool runscript)
if ( insplit.size() == 0 || insplit.size() > 2 ||
(insplit.size() == 1 && i != 0) )
{
- fprintf(stderr, "Bad mp_colour string: %s\n", field.c_str());
+ crawl_state.add_startup_error(
+ make_stringf("Bad mp_colour string: %s\n", field.c_str()));
break;
}
@@ -2194,8 +2209,9 @@ void game_options::read_option_line(const std::string &str, bool runscript)
note_skill_levels.push_back(num);
else
{
- fprintf(stderr, "Bad skill level to note -- %s\n",
- thesplit[i].c_str());
+ crawl_state.add_startup_error(
+ make_stringf("Bad skill level to note -- %s\n",
+ thesplit[i].c_str()));
continue;
}
}
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc
index bb95262009..2dfcd5c528 100644
--- a/crawl-ref/source/newgame.cc
+++ b/crawl-ref/source/newgame.cc
@@ -93,6 +93,7 @@
#include "skills2.h"
#include "spl-book.h"
#include "spl-util.h"
+#include "state.h"
#include "stuff.h"
#include "tutorial.h"
#include "version.h"
@@ -725,6 +726,13 @@ bool new_game(void)
init_player();
+ if (!crawl_state.startup_errors.empty()
+ && !Options.suppress_startup_errors)
+ {
+ crawl_state.show_startup_errors();
+ clrscr();
+ }
+
if (!Options.player_name.empty())
{
strncpy(you.your_name, Options.player_name.c_str(), kNameLen);
diff --git a/crawl-ref/source/state.cc b/crawl-ref/source/state.cc
index ea89679f12..1d86dc1862 100644
--- a/crawl-ref/source/state.cc
+++ b/crawl-ref/source/state.cc
@@ -40,6 +40,28 @@ game_state::game_state()
reset_cmd_again();
}
+void game_state::add_startup_error(const std::string &err)
+{
+ startup_errors.push_back(err);
+}
+
+void game_state::show_startup_errors()
+{
+ formatted_scroller error_menu;
+ error_menu.set_flags(MF_NOSELECT | MF_ALWAYS_SHOW_MORE | MF_NOWRAP
+ | MF_EASY_EXIT);
+ error_menu.set_more(
+ formatted_string::parse_string(
+ "<cyan>[ + : Page down. - : Page up."
+ " Esc or Enter to continue.]"));
+ error_menu.set_title(
+ new MenuEntry("Warning: Crawl encountered errors during startup:",
+ MEL_TITLE));
+ for (int i = 0, size = startup_errors.size(); i < size; ++i)
+ error_menu.add_entry(new MenuEntry(startup_errors[i]));
+ error_menu.show();
+}
+
///////////////////////////////////////////////////////////////////////////
// Repeating commands and doing the previous command over again.
diff --git a/crawl-ref/source/state.h b/crawl-ref/source/state.h
index 8347cd0470..cd572ed865 100644
--- a/crawl-ref/source/state.h
+++ b/crawl-ref/source/state.h
@@ -14,6 +14,7 @@
#define STATE_H
#include "enum.h"
+#include <vector>
struct god_act_state
{
@@ -65,6 +66,8 @@ struct game_state
int prev_repetition_turn;
bool cmd_repeat_started_unsafe;
+ std::vector<std::string> startup_errors;
+
std::vector<std::string> input_line_strs;
unsigned int input_line_curr;
@@ -80,6 +83,9 @@ protected:
public:
game_state();
+ void add_startup_error(const std::string &error);
+ void show_startup_errors();
+
bool is_replaying_keys() const;
bool is_repeating_cmd() const;
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index b957f96a93..9e7f2a0b3e 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -444,9 +444,11 @@ void cio_init()
crawl_view.init_geometry();
if (Options.char_set == CSET_UNICODE && !crawl_state.unicode_ok)
- end(1, false,
- "Unicode glyphs are not available, please change your "
- "char_set option");
+ {
+ crawl_state.add_startup_error(
+ "Unicode glyphs are not available, falling back to ASCII.");
+ Options.char_set = CSET_ASCII;
+ }
}
void cio_cleanup()