sources/interface.cpp

changeset 83
08bfc3d9d2ae
parent 82
895088452014
child 84
3bd32eec3d57
child 86
3c02a728a681
--- a/sources/interface.cpp	Tue May 26 18:19:27 2015 +0300
+++ b/sources/interface.cpp	Tue May 26 18:46:24 2015 +0300
@@ -158,7 +158,7 @@
 	InputHistory << "";
 	OutputLines.clear();
 	OutputLines << ColoredLine();
-	Title = format (APPNAME " %1 (%2)", full_version_string(), changeset_date_string());
+	Title.sprintf (APPNAME " %s (%d)", full_version_string(), changeset_date_string());
 
 	if (::has_colors())
 	{
@@ -177,7 +177,7 @@
 			int bg = (j == DEFAULT) ? defaultBg : j;
 
 			if (::init_pair (pairnum, fg, bg) == ERR)
-				print ("Unable to initialize color pair %1 (%2, %3)\n", pairnum, fg, bg);
+				print ("Unable to initialize color pair %d (%d, %d)\n", pairnum, fg, bg);
 		}
 	}
 	else
@@ -514,12 +514,17 @@
 			String adminText;
 
 			if (Session.num_admins() == 0)
+			{
 				adminText = "No other admins";
+			}
 			else
-				adminText = format ("%1 other admin%s1", Session.num_admins());
+			{
+				adminText.sprintf ("%d other admin%s", Session.num_admins(),
+					Session.num_admins() != 1 ? "s" : "");
+			}
 
-			text = format ("%1 | %2 | %3", Session.address().to_string (IP_WITH_PORT),
-				Session.level(), adminText);
+			text.sprintf ("%s | %s | %s", Session.address().to_string (IP_WITH_PORT).chars(),
+				Session.level().chars(), adminText.chars());
 		}
 		break;
 	}
@@ -805,7 +810,7 @@
 			}
 			catch (std::exception& e)
 			{
-				print ("%1\n", e.what());
+				print ("%s\n", e.what());
 				return;
 			}
 
@@ -902,6 +907,49 @@
 
 // -------------------------------------------------------------------------------------------------
 //
+void Interface::vprint (const char* fmtstr, va_list args)
+{
+	String message;
+	message.vsprintf (fmtstr, args);
+	print_to_console (message);
+}
+
+// -------------------------------------------------------------------------------------------------
+//
+void __cdecl Interface::print (const char* fmtstr, ...)
+{
+	va_list args;
+	va_start (args, fmtstr);
+	vprint (fmtstr, args);
+	va_end (args);
+}
+
+// -------------------------------------------------------------------------------------------------
+//
+void __cdecl Interface::print_warning (const char* fmtstr, ...)
+{
+	va_list args;
+	va_start (args, fmtstr);
+	print_to_console (TEXTCOLOR_BrightYellow "-!- ");
+	vprint (fmtstr, args);
+	print_to_console (TEXTCOLOR_Reset);
+	va_end (args);
+}
+
+// -------------------------------------------------------------------------------------------------
+//
+void __cdecl Interface::print_error (const char* fmtstr, ...)
+{
+	va_list args;
+	va_start (args, fmtstr);
+	print_to_console (TEXTCOLOR_BrightRed "!!! ");
+	vprint (fmtstr, args);
+	print_to_console (TEXTCOLOR_Reset);
+	va_end (args);
+}
+
+// -------------------------------------------------------------------------------------------------
+//
 void Interface::print_to_console (String a)
 {
 	// Zandronum sometimes sends color codes as "\\c" and sometimes as "\x1C".
@@ -944,7 +992,7 @@
 	}
 	catch (std::exception& e)
 	{
-		print ("%1\n", e.what());
+		print ("%s\n", e.what());
 		return;
 	}
 

mercurial