GuiMLTextCtrl
by Kevin James · in Torque Game Builder · 06/29/2010 (10:04 am) · 7 replies
I'm working on getting the tutorial in-game. I want the tutorial to be readable so I'm trying something different by using a GuiMLTextCtrl. Here's what I have so far:
I put this in \common\gui\profiles.cs:
When I run the game, I don't get any errors, but I also see no text where it should be. tutBack is a plain black box (t2dStaticSprite).
Any idea what I'm doing wrong here?
function showTutorial(%page)
{
new GuiMLTextCtrl(tutText) {
profile = "GuiTutorialProfile";
horizSizing = "width";
vertSizing = "height";
position = "0 0";
extent = "400 400";
minExtent = "8 8";
visible = true;
canSave = "0";
lineSpacing = "2";
allowColorChars = "0";
maxChars = "-1";
};
tutBack.attachGui(tutText, menusWindow, true);
tutText.text="test";
}I put this in \common\gui\profiles.cs:
if(!isObject(GuiTutorialProfile)) new GuiControlProfile( GuiTutorialProfile )
{
fontColor = "255 255 255";
autoSizeWidth = true;
autoSizeHeight = true;
fonttype = "Arial";
fontsize = "18";
border = false;
};When I run the game, I don't get any errors, but I also see no text where it should be. tutBack is a plain black box (t2dStaticSprite).
Any idea what I'm doing wrong here?
About the author
Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/
#2
But not outside of the block?
06/29/2010 (10:54 am)
I've made some progress, but I don't understand it. It works when I assign the text in the object creation block:new GuiMLTextCtrl(tutText) {
profile = "GuiTutorialProfile";
horizSizing = "width";
vertSizing = "height";
position = "10 10";
extent = "400 400";
minExtent = "8 8";
visible = true;
canSave = "0";
lineSpacing = "2";
allowColorChars = "0";
text = "testing testing...";
};But not outside of the block?
new GuiMLTextCtrl(tutText) {
profile = "GuiTutorialProfile";
horizSizing = "width";
vertSizing = "height";
position = "10 10";
extent = "400 400";
minExtent = "8 8";
visible = true;
canSave = "0";
lineSpacing = "2";
allowColorChars = "0";
};
tutText.text="testing testing";//does not work!
#3
Edit: as a side note, the text using this method looks EXCELLENT! It will be well worth the effort to convert all of my text to show in the GuiMLTextCtrl. Even if I have to delete and recreate it for each instance.
06/29/2010 (11:00 am)
I echoed tutText and saw "testing testing" show up in the console. At the same time "testing testing..." shows up on the screen. Its as if tutText is referencing a different object. Weird.Edit: as a side note, the text using this method looks EXCELLENT! It will be well worth the effort to convert all of my text to show in the GuiMLTextCtrl. Even if I have to delete and recreate it for each instance.
#4
06/29/2010 (12:46 pm)
Try using "tutText.setText( "testing testing" );" to see if that helps. I also call "tutText.forceReflow();" after setting my text, too.
#5
06/29/2010 (12:47 pm)
And yeah, I agree about the look. Plus, you can easily create drop shadows, different font sizes, and images within the text. If you haven't looked at tdn.garagegames.com/wiki/GUI/TorqueML, you should definitely give it a quick look over.
#6
06/29/2010 (4:34 pm)
setText and forceReflow() work nicely!
#7
06/30/2010 (12:03 am)
Great! Good to hear that!
Associate William Lee Sims
Machine Code Games
Finally, just as a sanity check, after you call "showTutorial()", type "echo( tutText.text );" into the console to make sure it got set.