#include <tConsole.h>
Public Member Functions | |
typedef bool | MessageCallback (const tOutput &message, const tOutput &interpretation, REAL timeout) |
typedef bool | IdleCallback () |
virtual | ~tConsole () |
tConsole & | Print (tString s) |
template<class T> | |
tConsole & | operator<< (const T &x) |
void | CenterDisplay (tString s, REAL timeout=5, REAL r=1, REAL g=1, REAL b=1) |
virtual tString | ColorString (REAL r, REAL g, REAL b) const |
Static Public Member Functions | |
static bool | Message (const tOutput &message, const tOutput &interpetation, REAL timeout=-1) |
static bool | Idle () |
static void | RegisterMessageCallback (MessageCallback *callback) |
static void | RegisterIdleCallback (IdleCallback *callback) |
Static Protected Member Functions | |
static void | RegisterBetterConsole (tConsole *better) |
Private Member Functions | |
virtual tConsole & | DoPrint (const tString &s) |
virtual void | DoCenterDisplay (const tString &s, REAL timeout=5, REAL r=1, REAL g=1, REAL b=1) |
Static Private Attributes | |
static tConsole * | s_betterConsole = NULL |
Definition at line 69 of file tConsole.h.
tConsole::~tConsole | ( | ) | [virtual] |
Definition at line 158 of file tConsole.cpp.
References NULL, and s_betterConsole.
00158 { 00159 if (s_betterConsole == this) 00160 s_betterConsole = NULL; 00161 }
typedef bool tConsole::MessageCallback | ( | const tOutput & | message, | |
const tOutput & | interpretation, | |||
REAL | timeout | |||
) |
typedef bool tConsole::IdleCallback | ( | ) |
Definition at line 166 of file tConsole.cpp.
References DoPrint(), FilterLine(), line_, s_betterConsole, and tString::Size().
Referenced by operator<<().
00167 { 00168 // append to line 00169 line_ += s; 00170 00171 // determine if a newline was received 00172 bool newline = false; 00173 for ( int i = s.Size()-1; i>=0; --i ) 00174 if ( s(i) == '\n' ) 00175 newline = true; 00176 00177 if ( newline ) 00178 { 00179 // filter 00180 FilterLine( line_ ); 00181 00182 // print 00183 if (s_betterConsole) 00184 s_betterConsole->DoPrint( line_ ); 00185 else 00186 DoPrint( line_ ); 00187 00188 line_ = ""; 00189 } 00190 00191 return *this; 00192 }
tConsole& tConsole::operator<< | ( | const T & | x | ) | [inline] |
Definition at line 83 of file tConsole.h.
References Print().
00083 { 00084 tColoredString s; 00085 s << x; 00086 return Print(s); 00087 }
Definition at line 194 of file tConsole.cpp.
References DoCenterDisplay(), FilterLine(), and s_betterConsole.
Referenced by gGame::GameLoop().
00195 { 00196 FilterLine(s); 00197 00198 if (s_betterConsole) 00199 s_betterConsole->DoCenterDisplay(s,timeout,r,g,b); 00200 else 00201 DoCenterDisplay(s,timeout,r,g,b); 00202 }
bool tConsole::Message | ( | const tOutput & | message, | |
const tOutput & | interpetation, | |||
REAL | timeout = -1 | |||
) | [static] |
Definition at line 233 of file tConsole.cpp.
References con, and s_messageCallback.
Referenced by nServerInfo::GetFromMaster(), uMenu::HandleEvent(), main(), se_DeletePasswords(), and sg_NetworkError().
00233 { 00234 if (s_messageCallback) 00235 return (*s_messageCallback)(message, interpretation, timeout); 00236 else 00237 { 00238 con << tString(message) << ":\n"; 00239 con << tString(interpretation) << '\n'; 00240 return true; 00241 } 00242 }
bool tConsole::Idle | ( | ) | [static] |
Definition at line 250 of file tConsole.cpp.
References s_idleCallback.
00250 { 00251 if (s_idleCallback) 00252 { 00253 return (*s_idleCallback)(); 00254 } 00255 else 00256 { 00257 return false; 00258 } 00259 }
Reimplemented in rConsole.
Definition at line 219 of file tConsole.cpp.
References ColorString(), and s_betterConsole.
Referenced by ColorString(), and nConfItem< tString >::NetReadVal().
00219 { 00220 if (s_betterConsole) 00221 return s_betterConsole->ColorString(r,g,b); 00222 else 00223 return tString(""); 00224 }
void tConsole::RegisterMessageCallback | ( | MessageCallback * | callback | ) | [static] |
Definition at line 228 of file tConsole.cpp.
References s_messageCallback.
Referenced by main().
00229 { 00230 s_messageCallback = a_callback; 00231 }
void tConsole::RegisterIdleCallback | ( | IdleCallback * | callback | ) | [static] |
Definition at line 245 of file tConsole.cpp.
References s_idleCallback.
Referenced by main().
00246 { 00247 s_idleCallback = a_callback; 00248 }
void tConsole::RegisterBetterConsole | ( | tConsole * | better | ) | [static, protected] |
Definition at line 215 of file tConsole.cpp.
References s_betterConsole.
Referenced by nCon::nCon(), and rConsole::rConsole().
00215 { 00216 s_betterConsole = better; 00217 }
Reimplemented in rConsole.
Definition at line 204 of file tConsole.cpp.
Referenced by Print().
void tConsole::DoCenterDisplay | ( | const tString & | s, | |
REAL | timeout = 5 , |
|||
REAL | r = 1 , |
|||
REAL | g = 1 , |
|||
REAL | b = 1 | |||
) | [private, virtual] |
Reimplemented in rConsole.
Definition at line 210 of file tConsole.cpp.
Referenced by CenterDisplay().
tConsole * tConsole::s_betterConsole = NULL [static, private] |
Definition at line 106 of file tConsole.h.
Referenced by CenterDisplay(), ColorString(), Print(), RegisterBetterConsole(), and ~tConsole().