From 4572c0dac4d6cfc04f3b4d92f6d2e6e5a2472b4e Mon Sep 17 00:00:00 2001 From: smatz Date: Wed, 24 Feb 2010 14:50:04 +0000 Subject: [PATCH] (svn r19225) -Feature: show warnings and errors in console as well, not only in a message box --- src/misc_gui.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 0e9a751623..d5d4d5490d 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -697,13 +697,27 @@ public: */ void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x, int y) { - DeleteWindowById(WC_ERRMSG, 0); + if (summary_msg == STR_NULL) summary_msg = STR_EMPTY; + + if (wl != WL_INFO) { + /* Print message to console */ + char buf[DRAW_STRING_BUFFER]; + char *b = GetString(buf, summary_msg, lastof(buf)); + if (detailed_msg != INVALID_STRING_ID) { + b += seprintf(b, lastof(buf), " "); + GetString(b, detailed_msg, lastof(buf)); + } + switch (wl) { + case WL_WARNING: IConsolePrint(CC_WARNING, buf); break; + default: IConsoleError(buf); break; + }; + } bool no_timeout = wl == WL_CRITICAL; if (_settings_client.gui.errmsg_duration == 0 && !no_timeout) return; - if (summary_msg == STR_NULL) summary_msg = STR_EMPTY; + DeleteWindowById(WC_ERRMSG, 0); Point pt = {x, y}; const WindowDesc *desc = (detailed_msg != STR_ERROR_OWNED_BY || GetDParam(2) >= MAX_COMPANIES) ? &_errmsg_desc : &_errmsg_face_desc;