XML file - not seing the text on screen
by Arden · in Torque X 2D · 10/29/2010 (10:18 pm) · 10 replies
Hiya guys, I've created the following XML file, and everything works fine apart from the text. Any idea on what I might be doing wrong?
<?xml version="1.0" encoding="utf-8" ?>
<TorqueSceneData>
<Version>1.0</Version>
<SceneData>
<GUIBitmapStyle name="gbs">
<SizeToBitmap>false</SizeToBitmap>
</GUIBitmapStyle>
<GUITextStyle name="gts">
<FontType>Arial22</FontType>
<TextColors>
<Color>
<X>0</X>
<Y>0</Y>
<Z>0</Z>
<W>0</W>
</Color>
</TextColors>
<SizeToText>true</SizeToText>
</GUITextStyle>
<GUIBitmap name="gb1">
<Style nameRef="gbs"/>
<Bitmap>dataimagesGuiblue</Bitmap>
<ChildControls>
<GUIText name="gt1">
<Style nameRef="gts"/>
<Text>Hello, World!</Text>
<Position>
<X>10</X>
<Y>20</Y>
</Position>
</GUIText>
<GUIBitmap name="gb2">
<Style nameRef="gbs"/>
<Bitmap>dataimagesGuiblack</Bitmap>
<Position>
<X>1180</X>
<Y>620</Y>
</Position>
<Size>
<X>100</X>
<Y>100</Y>
</Size>
</GUIBitmap>
</ChildControls>
</GUIBitmap>
</SceneData>
</TorqueSceneData>
#2
Any other ideas?
10/30/2010 (12:10 am)
The 0 coordonates are a four dimension vector representing Red, Green, Blue and alpha, so unless I'm mistaken, the text should appear black. As for the position, the resolution is set at 1280 x 720 and since camera doesn't apply for a GUIcanvas, the text should be visible... Any other ideas?
#3
Thanks anyways.
10/30/2010 (6:32 pm)
Well I guess not a lot of ppl are using XML for UI. Too bad, it's way more practical. I guess I'll just revert to code then.Thanks anyways.
#4
10/30/2010 (6:41 pm)
I wouldn't scap that right away. I use guitexts in my xml GUI all the time. When I get home I'll double check that to my code and see what's up.
#5
Your 4th vector value is the alpha. You've set alpha to 0 which is totally transparent.
Put a 1 in there and see if it works.
PS:
Also, I'm not sure if this was ever fixed but way back I had to make this change to my GUITextStyle.
Your onloaded method should look something like this for the XML values to read colour values between 0 and 1.
Stick with the XML GUI. It saves a ton of time for HUD's I even use it for my menu system, loading and unloading XML gui's as I go through the buttons.
10/30/2010 (6:49 pm)
Bingo... I just looked at it again.Your 4th vector value is the alpha. You've set alpha to 0 which is totally transparent.
Put a 1 in there and see if it works.
PS:
Also, I'm not sure if this was ever fixed but way back I had to make this change to my GUITextStyle.
Your onloaded method should look something like this for the XML values to read colour values between 0 and 1.
public override void OnLoaded()
{
base.OnLoaded();
for(int i = 0; i < _textColorAsVector4.Count; i++) {
TextColor[(CustomColor)i] = new Color(_textColorAsVector4[i] * 255);
}
}Stick with the XML GUI. It saves a ton of time for HUD's I even use it for my menu system, loading and unloading XML gui's as I go through the buttons.
#6
<Color>
<X>1</X>
<Y>1</Y>
<Z>0</Z>
<W>0.5</W>
</Color>
I was thinking the same thing as you however, so I've tried all possibilities. Doesn't seem to be the problem.
I agree with your last comment, that's why I really want this to work, but it's incredibly hard to find any information on coding XML UI for Torque X. Do you know if coding XML is the same for XNA? Could I look into these forums as well?
I will try your OnLoaded() recommendation and post back to let you know how it went.
Thanks a lot for your help, I was starting to despair :)
10/30/2010 (7:45 pm)
According to the pdf, the text color is specified as a Vector4 with <X>, <Y>, <Z>, and <W> as floating point values between 0 and 1 (0 = darkest, 1 = lightest). These values map respectively to R, G, B, and Alpha. To make a 50% transparent yellow, for example, I'm supposed to change the values about to:<Color>
<X>1</X>
<Y>1</Y>
<Z>0</Z>
<W>0.5</W>
</Color>
I was thinking the same thing as you however, so I've tried all possibilities. Doesn't seem to be the problem.
I agree with your last comment, that's why I really want this to work, but it's incredibly hard to find any information on coding XML UI for Torque X. Do you know if coding XML is the same for XNA? Could I look into these forums as well?
I will try your OnLoaded() recommendation and post back to let you know how it went.
Thanks a lot for your help, I was starting to despair :)
#7
As for the XML, if I create a GUIBitmap child control, it works as well. The problem really seems to be related to GUIText and XML. It's supposed to be a really straighforward ''Hello World'' tutorial in the PDF.
If you have any part of XML code handling code you could share with me, it would really be appreciated.
Thanks
10/30/2010 (8:26 pm)
Cosmic, I've added your code to GuiButton.cs, but that doesn't fix it either. Was kind of hoping it did. I really hope I can find the solution. It's really weird, because if I manage the main menu through code and creating a text object, it works! As for the XML, if I create a GUIBitmap child control, it works as well. The problem really seems to be related to GUIText and XML. It's supposed to be a really straighforward ''Hello World'' tutorial in the PDF.
If you have any part of XML code handling code you could share with me, it would really be appreciated.
Thanks
#8
I feel stupid.
Colors are rgba and go from 0 to 255, with a color of 0,0,0,1 it was black and almost transparent.
I fixed it by inputing a higher value.
Thanks for your time.
10/31/2010 (3:17 am)
Never mind, I found the solution. I feel stupid.
Colors are rgba and go from 0 to 255, with a color of 0,0,0,1 it was black and almost transparent.
I fixed it by inputing a higher value.
Thanks for your time.
#9
You will have to test the button as well as borer colors as well, but I think some are based off of 0-255 and some are based off of a float of 0-1. I had a big problem with that some time ago, not sure if it ever got fixed and unified.
I've got my source set to use 0 - 1 :)
10/31/2010 (4:32 am)
No problem. I'm glad I could help. You will have to test the button as well as borer colors as well, but I think some are based off of 0-255 and some are based off of a float of 0-1. I had a big problem with that some time ago, not sure if it ever got fixed and unified.
I've got my source set to use 0 - 1 :)
#10
10/31/2010 (1:41 pm)
I'll watch out for that. Thanks!
Torque Owner jon quil
I have not built gui's components via xml's so not sure on this one but, if I were going to guess from afar.....
<TextColors>
<Color>
<X>0</X>
<Y>0</Y>
<Z>0</Z>
<W>0</W>
</Color>
</TextColors>
Might be an issue? Also depending on your gui canvas render size and TV type
<Position>
<X>10</X>
<Y>20</Y>
</Position>
Might be rendering off the viewable area of the screen?