Game Development Community

Gui text too far left

by Travis Womack · in Torque Game Builder · 08/08/2005 (10:40 am) · 10 replies

Hi I am perplexed by something I am seeing with some GUI elements I have.
Here is a pic of what I am seeing.

members.iglou.com/travw/font_issue.jpg
The text is starting too much to the left side of the GUI element so it hits the left border.
I played with justification and textoffset in the control's GUIControlProfile with no real result.
Here is the profile and GUI code:
if(!isObject(GuiPlayerInfo)) new GuiControlProfile (GuiPlayerInfo)
{
   opaque = true;
   border = 1;
   fillColor = "192 192 192";
   fillColorHL = "64 150 150";
   fillColorNA = "150 150 150";
   fontColor = "0 0 0";
   fontColorHL = "0 0 0";
   textoffset="8 8";
	
   
   
};

   new GuiTextCtrl(HP_label) {
      profile = "GuiPlayerInfo";
      horizSizing = "right";
      vertSizing = "bottom";
      position = "595 72";
      extent = "53 18";
      minExtent = "8 2";
      visible = "1";
      text = "Hit Points:";
      maxLength = "255";
   };
   new GuiMLTextCtrl(HP_value) {
      profile = "GuiPlayerInfo";
      horizSizing = "right";
      vertSizing = "bottom";
      position = "652 75";
      extent = "53 14";
      minExtent = "8 2";
      visible = "1";
      lineSpacing = "2";
      allowColorChars = "1";
      maxChars = "-1";
      text = "0";
   };

Any ideas?

#1
08/08/2005 (11:46 am)
I added

justify = "center";

and it centered the text in the middle of the box.. :)

might work for yours.. :)
#2
08/08/2005 (12:18 pm)
That is what is so perplexing. I added justify="center"; and it does not change the text placement in the GUI.
Any other ideas?
#3
08/08/2005 (12:28 pm)
I added it to the default guis

like in

if(!isObject(GuiBigTextProfile)) new GuiControlProfile (GuiBigTextProfile)
{
fontType = "sydnie";
fontSize = 32;
fontColor = "0 0 0";
justify = "center";
};


so that any profile that used guibigtextprofile will have the justify = center..

now this is fine for me but if you have other uses for that profile I would make a new guiprofile and change it to fit your needs...
that way you can add many new profiles for your needs specifically.. :)
#4
08/08/2005 (12:29 pm)
So for yours it would be in guiplayerinfo..
and add the justify there....

liek in here..
home.comcast.net/~berkingstock/pinball02.jpg

*dont need alot fo pics floating around.. :)
#5
08/08/2005 (12:51 pm)
I did, that is what is weird I changed guiplayerinfo to be this:
if(!isObject(GuiPlayerInfo)) new GuiControlProfile (GuiPlayerInfo)
{
   opaque = true;
   border = 1;
   fillColor = "192 192 192";
   fillColorHL = "64 150 150";
   fillColorNA = "150 150 150";
   fontColor = "0 0 0";
   fontColorHL = "0 0 0";
   justify = "center";	
	
 };
And no change from above picture.
#6
08/08/2005 (3:41 pm)
Did you delete the dso so it recompiles..
that way you can find an error if one exists.. it may ahve a error and so its reverting to the dso...
which would be your last good compile...

hence why it may not be changing.. :)
#7
08/08/2005 (3:48 pm)
I did that...now I am starting to question my sanity (again).

Console showed it compiled ok:
Compiling RPG/client/mainScreenGui.gui...
Loading compiled script RPG/client/mainScreenGui.gui.
#8
08/16/2005 (12:59 pm)
Are you using a GuiTextEditCtrl? Those particular ctrls don't support the justify functionality. What you'll want to use is the GuiTextCtrl instead. Also, if you want to move the text from the edge of the left border without centering the text (which to me looks akward with columns of numbers), use the textOffset = "x y" member in the datablock. And again, remember you must use a GuiTextCtrl, not a GuiTextEditCtrl for the textOffset functionality.

But, you're not done yet. GuiTextCtrls have a bug which keeps them from drawing a border like the GuiTextEditCtrl does. So what you want to do is go into the engine and fix that bug right quick (NOTE - this bug has already been reported, so it should show up in head eventually).

The bug is that GuiTextCtrl's ::onRender function does not call the Parent::onRender function. It is the Parent::onRender function that draws the borders and shading and all that. So simply add this code to the very beginning of the function -
Parent::onRender(offset, updateRect); /// CIB BRYAN EDDS - Bordered GuiTextCtrl
And since the Parent call already calls the ::renderChildControls function, go ahead and comment it out on the last line of the GuiTextCtrl::onRender function's code.

Now finally define a datablock that the GuiTextEditCtrl can use to draw the borders how you like them. Here's an example -
if(!isObject(GuiTextRightProfile))
new GuiControlProfile(GuiTextRightProfile : GuiDefaultProfile)
{
   justify = "right";
   opaque = true;
   fillColor = "192 192 192";
   fillColorHL = "128 128 128";
   border = 3;
   borderThickness = 2;
   borderColor = "0 0 0";
   fontColor = "0 0 0";
   fontColorHL = "255 255 255";
   fontColorNA = "128 128 128";
   textOffset = "2 2";
   autoSizeWidth = false;
   autoSizeHeight = true;
};

I know this is a lot of stuff to do, but the only alternative is more complex because it requires defining justifications and offsetting functionality in the GuiTextEditCtrl - which might be useful if you'd like to take that on.

Anyhow, good luck.
#9
08/16/2005 (1:30 pm)
Thanks a bunch Bryan, I will give that a try. It is really cool to know that there are people that can help out and so well in this community.
#10
08/22/2005 (1:09 pm)
Having faced a similar problem, I would mention that you should be careful of autoSizeWidth being set to true. If it's true, a "center" or "right" justification may appear to be broken since the textCtrl will keep growing to the right.