Best way to hide/disable the console window for shipped titles?
by Kalle Wik · in Torque Game Builder · 03/28/2007 (12:58 pm) · 3 replies
What's the best way to disable or hide the console window for a shipped game, in TGB?
I figure that changing the binding for the ~ key would work. But it seems this would still leave the console window active. At least in development mode, dumping anything to the console causes the framerate to hitch noticeably.
Seems simple, but I couldn't find any information by searching Forums with such strings as...
disable console window
hide console
remove console window
Any insight into this solution is appreciated.
Thanks,
K.
I figure that changing the binding for the ~ key would work. But it seems this would still leave the console window active. At least in development mode, dumping anything to the console causes the framerate to hitch noticeably.
Seems simple, but I couldn't find any information by searching Forums with such strings as...
disable console window
hide console
remove console window
Any insight into this solution is appreciated.
Thanks,
K.
#2
-K.
03/29/2007 (11:09 am)
David, this is a great bit of info, thank you! I think my approach will be to disable via key binds and removing the ConsoleDlg.gui, plus not using "echo" commands in the release build. That oughta do it, though it's great to know how to juice the engine for even more performance.-K.
#3
Then, you could still use echo statements in your torquescript files for debugging, just use a TGB_DEBUG.EXE when doing so ... you could also make the $DEBUG a simple flag in your /main.cs that is hard-coded ... and toggle it before a release build ...
You could do this, without having to do much work on your scripts ... simple "Find All Instances and Replace" like so ...
Find All: "echo("
Replace: "if($DEBUG) echo("
And your done ... then just strip out the ConsoleDlg and the Key-binding in a release build ... which you could also have the key-binding done with the if($DEBUG) moveMap.bindCmd(...) as well ...
03/29/2007 (11:25 am)
@Kalle -- you could, if you wanted too, use the getBuildVersion() function like so:$DEBUG = getBuildVersion() $= "Debug" ? true : false;
function someFunc()
{
if($DEBUG) echo("Debug text for Function");
}Then, you could still use echo statements in your torquescript files for debugging, just use a TGB_DEBUG.EXE when doing so ... you could also make the $DEBUG a simple flag in your /main.cs that is hard-coded ... and toggle it before a release build ...
You could do this, without having to do much work on your scripts ... simple "Find All Instances and Replace" like so ...
Find All: "echo("
Replace: "if($DEBUG) echo("
And your done ... then just strip out the ConsoleDlg and the Key-binding in a release build ... which you could also have the key-binding done with the if($DEBUG) moveMap.bindCmd(...) as well ...
Associate David Higgins
DPHCoders.com
Should be all you have to do ... also, there's the "enableWinConsole(true)" call in the main.cs or gameScripts/game.cs ... comment that out, thats what creates your console.log file in Windows -- if you want to remove that ...
If your looking at increasing performance, by not actually sending anything to the console, you'd have to comment out the code in the C++ that attaches the console ... I don't recall off hand where this code is ... but basically, there's multiple listeners that get attached ... the console.log listener, the telnet listener and the in-game console listener ... may even be more ...
You could also do a complete code scan, and then comment out and "Con::printf", "Con::warnf", and "Con::errorf" statements in the C++ ... this would prevent the code from even looking for listeners ... thereby adding a bit more performance ...
Though, what I would probably do, is add something like #ifdef TORQUE_DEBUG #endif around the Con::* calls and the listener creations ... that way, you can use a debug build to see the console, but a release build does not show the console ...
You could then use something like "if(getBuildVersion() $= "Debug") enableWinConsole(true);" in your main.cs to enable/disable the console.log ... and also maybe wrap the same logical getBuildVersion() check around the exec call for the ConsoleDlg ... then when you package the game, just delete the ConsoleDlg files from the common folder before throwing everything into the installer ...
Quite a bit of work involved ... mostly all tedious ... a simple "Find in Files" can show you where all your "Con::printf" statements are ... with a nice grep/awk/sed script combo, you could probably have it perform the #ifdef TORQUE_DEBUG replacements for you.... hehe :)