Game Development Community

T2dTextObject: bugs, datablock & 1.1.3 LevelEditor Oddities

by Eric Robinson · in Torque Game Builder · 03/27/2007 (8:23 pm) · 0 replies

--Summary--
1) t2dTextObjects (%t2dTextObj) are not initialized by the editor properly.
1a) Text is ugly [perhaps due to: %t2dTextObj.fontSizes = ""].
1b) %t2dTextObj.addFontSize(%size) does not work properly. The font (at size %size) is processed by the engine but not added to the %t2dTextObj.fontSizes list, making it virtually useless.
1ba) Removing all font sizes from a t2dTextObject will properly make it disappear. Only the first size added by addFontSize() is used for further rendering (unless the fontSizes field is edited directly).

2) t2dTextObjects cannot be configured in the editor using datablocks. Dimensions go all out of whack when a config datablock is set within the editor.

3) [Tested on a Mac] When a datablock is used with a t2dTextObject within the editor, the font cache can become corrupt.

--TestCode--
1) Create a t2dTextObject in the editor. The object will likely appear blocky and nearly illegible. Call dump() on your text object and look for the following: fontSizes = "".

2) Use the following datablock to configure a t2dTextObject within the editor:
new t2dSceneObjectDatablock(testDB)
{
	// Generic settings.
	BlendColor = "0 0 0 1";
	BlendingEnabled = "1";
	CollisionActiveReceive = "0";
	CollisionActiveSend = "0";
	CollisionPhysicsReceive = "0";
	CollisionPhysicsSend = "0";
	Layer = "5";
	Size = "10 10";
	
	// t2dTextObject related settings.
	text = "TESTING";
	font = "Times New Roman";
	wordWrap = "0";
	hideOverflow = "0";
	textAlign = "Center";
	lineHeight = "10";
	aspectRatio = "1";
	lineSpacing = "0";
	characterSpacing = "0";
	autoSize = "1";
	fontSizes = "24 32 48 64 128";
};
Simulate the level and then exit. Look at the bounds of the t2dTextObject box. This gets worse each time you re-enter the editor.

3) [Tested on a Mac] See 2.

--SuggestedFixes--
1) A call to addFontSize() updates mFonts but not mFontSizes. Modify addFontSize() to update mFontSizes. Possibly ensure that the fonts get redrawn by calling setCharactersDirty() at the end of addFontSize.

2) Fix the onTextObjectCreated() function within the levelEditor.ed.cs file.
2b) Figure out what isn't playing nicely below.

3 [Tested on a Mac] See 2. Particularly 2b: that the font cache is getting corrupt is more than slightly unnerving. This more than likely has to do with things not being updated in sync when the protected field accessors are used.

2 and 3 show that t2dTextObject + Datablocks + LevelEditor 1.1.3 = Boom! Not sure about t2dTextObject + Datablocks + scriptInitialization... (= ?).