A Movable and Resizeable Console
by Tom Spilman · 05/08/2005 (3:30 pm) · 15 comments
I think it was F.A.K.K. 2 when i first saw a movable and resizable console window. It's amazing to me that it isn't part of Torque yet. So here is my little resource which gives you much nicer console window:

Note that this is a drop in replacement for the current console and works with TSE, TGE 1.3, and Torque2D. Download ConsoleDlg.gui now.
----
GuiScrollCtrl
The GuiScrollCtrl class is the one that provides the scrollbars for the console window. Scrolling the console you've probably had it snap back on you if you move your cursor just a bit away from the bar. This distance is actually based on the width of the scrollbar and is very small... too small. In the normal windows environment this distance is around 70 pixels or so. To fix this properly we'll make a simple code change to GuiScrollCtrl and add a new script $pref:: .
In GuiScrollCtrl::onMouseDragged() make the following change:
Now right after this in this same function change all instances of mScrollBarThickness for snapDist. It should look like this:
Now let's add the default into the script. Open the client/defaults.cs file in your mod folder and add the following line at the bottom:
You can change that value to whatever you feel works best for your mousing style, but the code will never let it get smaller than the scrollbar width.
----
Change Log:
5/6/2005
* Initial resource posting.
5/7/2005
* It now stores it's last position and size into the client prefs.
* Removed $ConsoleActive and replaced it with isAwake() which fixed missed "toggle on" bug when console is forced off during mission load and after the splash screens.
* Changed default position and size to something more reasonable.
5/9/2005
* Added notes above for fixing scrollbars snap distance.
* Increased the borders on the window a bit to make it easier to resize.
* Minor formatting changes.
----
If you have any suggestions or bug reports please drop me a comment.

Note that this is a drop in replacement for the current console and works with TSE, TGE 1.3, and Torque2D. Download ConsoleDlg.gui now.
----
GuiScrollCtrl
The GuiScrollCtrl class is the one that provides the scrollbars for the console window. Scrolling the console you've probably had it snap back on you if you move your cursor just a bit away from the bar. This distance is actually based on the width of the scrollbar and is very small... too small. In the normal windows environment this distance is around 70 pixels or so. To fix this properly we'll make a simple code change to GuiScrollCtrl and add a new script $pref:: .
In GuiScrollCtrl::onMouseDragged() make the following change:
// ok... if the mouse is 'near' the scroll bar, scroll with it
// otherwise, snap back to the previous position.
// ADDED CODE
const S32 snapDist = getMax( dAtoi( Con::getVariable( "$Pref::Gui::ScrollSnapDist" ) ), mScrollBarThickness );
// ADDED CODE
if (curHitRegion == VertThumb)
{Now right after this in this same function change all instances of mScrollBarThickness for snapDist. It should look like this:
if (curHitRegion == VertThumb)
{
if (curMousePos.x >= mVTrackRect.point.x - snapDist &&
curMousePos.x <= mVTrackRect.point.x + mVTrackRect.extent.x - 1 + snapDist &&
curMousePos.y >= mVTrackRect.point.y - snapDist &&
curMousePos.y <= mVTrackRect.point.y + mVTrackRect.extent.y - 1 + snapDist)
{
S32 newVThumbPos = curMousePos.y - mThumbMouseDelta;
if(newVThumbPos != mVThumbPos)
{
S32 newVPos = (newVThumbPos - mVTrackRect.point.y) *
(mChildExt.y - mContentExt.y) /
(mVTrackRect.extent.y - mVThumbSize);
scrollTo(mChildRelPosAnchor.x, newVPos);
}
}
else
scrollTo(mChildRelPosAnchor.x, mChildRelPosAnchor.y);
}
else if (curHitRegion == HorizThumb)
{
if (curMousePos.x >= mHTrackRect.point.x - snapDist &&
curMousePos.x <= mHTrackRect.point.x + mHTrackRect.extent.x - 1 + snapDist &&
curMousePos.y >= mHTrackRect.point.y - snapDist &&
curMousePos.y <= mHTrackRect.point.y + mHTrackRect.extent.y - 1 + snapDist)
{Now let's add the default into the script. Open the client/defaults.cs file in your mod folder and add the following line at the bottom:
$Pref::Gui::ScrollSnapDist = 70;
You can change that value to whatever you feel works best for your mousing style, but the code will never let it get smaller than the scrollbar width.
----
Change Log:
5/6/2005
* Initial resource posting.
5/7/2005
* It now stores it's last position and size into the client prefs.
* Removed $ConsoleActive and replaced it with isAwake() which fixed missed "toggle on" bug when console is forced off during mission load and after the splash screens.
* Changed default position and size to something more reasonable.
5/9/2005
* Added notes above for fixing scrollbars snap distance.
* Increased the borders on the window a bit to make it easier to resize.
* Minor formatting changes.
----
If you have any suggestions or bug reports please drop me a comment.
About the author
Tom is a programmer and co-owner of Sickhead Games, LLC.
#2
05/06/2005 (6:43 pm)
I was thinking of revamping my MiniConsole sometime, when development of K
#3
05/06/2005 (6:51 pm)
@Robert - Ahh... sorry to steal your direction if i did. Yea by all means continue yours!
#4
I haven't checked this resource out yet (I will within the hour), but mind if I merge any changes with this into Miniature Console 2.0 when I choose to work on it (I will soon, since it is the weekend)? There would be proper credit of course, :)
Robert
05/06/2005 (7:04 pm)
@Tom:I haven't checked this resource out yet (I will within the hour), but mind if I merge any changes with this into Miniature Console 2.0 when I choose to work on it (I will soon, since it is the weekend)? There would be proper credit of course, :)
Robert
#5
05/06/2005 (7:35 pm)
@Robert - Sure. No problem. My changes are a very minor alteration to the default ConsoleDlg.
#6
05/08/2005 (3:38 pm)
Sweet Tom, thanks. We'll likely put this in Torque 1.4 :)
#7
05/08/2005 (3:41 pm)
@Josh - By all means do so!
#9
05/08/2005 (5:57 pm)
@Tom: You should merge your changes with the 1.4 console, it's kinda different, it defaults to full size and it uses different gui controls, which includes having error reports on the bottom of the console.
#10
05/08/2005 (6:07 pm)
@Xavier: oh... i'll check that out later tonight!
#11
Thanx.
05/09/2005 (2:19 am)
Hi Tom, Great resource. I m sure, this will definitely go into the Torque 1.4. Thanx.
#12
05/09/2005 (3:36 pm)
@Xavier - I took a look at the console in 1.4 and i can't say i like it better. IMO it just cluttered up the console for a feature that could be better served by other means. I'll think about an alternate method to implement the same thing.
#13
05/09/2005 (5:49 pm)
FYI it also works with Torque2D 1.0.2. Makes sense I guess, T2D shares it's GUI system with TGE.
#14
Automatically add () and ; to anything typed in the console
07/23/2005 (3:35 pm)
Tom Bampton posted cool addition that works great with this console resource...Automatically add () and ; to anything typed in the console
#15
08/09/2008 (5:13 am)
It works good...
Associate Tom Spilman
Sickhead Games