Hack the console - green!
by Shaderman · 07/18/2008 (12:46 pm) · 1 comments
I print a lot of things to the console while testing things and was sick of searching my own output in all the other console text. That's why I made these changes to have a different output :) Here are the needed code changes that work with TGEA 1.7.1:
In GuiConsole::onRenderCell() around line 89 of engine\source\gui\controls\guiConsole.cpp:
engine\source\console\consoleLogger.cpp around line 39
engine\source\console\console.h areound line 43
same file around line 485:
and around line 502 add this:
Open engine/source/console/consoleFunctions.cpp and add this code at line 620
Add this code in engine/source/console/console.cpp around line 661:
and in the same file add this code around line 685 then:
Now in engine/source/platformWin32/winConsole.cpp change line 80
That should be all. Now hack the console green!
In GuiConsole::onRenderCell() around line 89 of engine\source\gui\controls\guiConsole.cpp:
switch (entry.mLevel)
{
case ConsoleLogEntry::Normal: GFX->getDrawUtil()->setBitmapModulation(mProfile->mFontColor); break;
case ConsoleLogEntry::Warning: GFX->getDrawUtil()->setBitmapModulation(mProfile->mFontColorHL); break;
case ConsoleLogEntry::Error: GFX->getDrawUtil()->setBitmapModulation(mProfile->mFontColorNA); break;
[b]case ConsoleLogEntry::Hack: GFX->getDrawUtil()->setBitmapModulation(ColorI(0, 255, 0, 255)); break;[/b]
}engine\source\console\consoleLogger.cpp around line 39
static const EnumTable::Enums logLevelEnums[] =
{
{ ConsoleLogEntry::Normal, "normal" },
{ ConsoleLogEntry::Warning, "warning" },
{ ConsoleLogEntry::Error, "error" },
[b]{ ConsoleLogEntry::Hack, "hack" },[/b]
};engine\source\console\console.h areound line 43
enum Level
{
Normal = 0,
Warning,
Error,
[b]Hack,[/b]
NUM_CLASS
} mLevel;same file around line 485:
/// @note The console window colors warning text as RED. /// @param _format A stdlib printf style formatted out put string /// @param ... Variables to be written void errorf(const char *_format, ...); [b] /// @note The console window colors warning text as GREEN. /// @param _format A stdlib printf style formatted out put string /// @param ... Variables to be written void hackf(const char *_format, ...);[/b]
and around line 502 add this:
/// @note The console window colors warning text as RED. /// @param type Allows you to associate the warning message with an internal module. /// @param _format A stdlib printf style formatted out put string /// @param ... Variables to be written /// @see Con::errorf() void errorf(ConsoleLogEntry::Type type, const char *_format, ...); [b] /// @note The console window colors warning text as GREEN. /// @param type Allows you to associate the warning message with an internal module. /// @param _format A stdlib printf style formatted out put string /// @param ... Variables to be written /// @see Con::hackf() void hackf(ConsoleLogEntry::Type type, const char *_format, ...);[/b]
Open engine/source/console/consoleFunctions.cpp and add this code at line 620
ConsoleFunction(hack, void, 2, 0, "hack(text [, ... ])")
{
U32 len = 0;
S32 i;
for(i = 1; i < argc; i++)
len += dStrlen(argv[i]);
char *ret = Con::getReturnBuffer(len + 1);
ret[0] = 0;
for(i = 1; i < argc; i++)
dStrcat(ret, argv[i]);
Con::hackf(ConsoleLogEntry::General, "%s", ret);
ret[0] = 0;
}Add this code in engine/source/console/console.cpp around line 661:
void hackf(ConsoleLogEntry::Type type, const char* fmt,...)
{
va_list argptr;
va_start(argptr, fmt);
_printf(ConsoleLogEntry::Hack, type, fmt, argptr);
va_end(argptr);
}and in the same file add this code around line 685 then:
void hackf(const char* fmt,...)
{
va_list argptr;
va_start(argptr, fmt);
_printf(ConsoleLogEntry::Hack, ConsoleLogEntry::General, fmt, argptr);
va_end(argptr);
}Now in engine/source/platformWin32/winConsole.cpp change line 80
if( level == ConsoleLogEntry::Error || Con::alwaysUseDebugOutput)to
if( level == ConsoleLogEntry::Error || ConsoleLogEntry::Hack || Con::alwaysUseDebugOutput)
That should be all. Now hack the console green!
Torque 3D Owner Morrock