Game Development Community

GuiTextProfile question

by Jacob · in Game Design and Creative Issues · 01/28/2005 (3:37 pm) · 12 replies

Does anyone know exactly what AutoSizeWidth and AutoSizeHeight do? I mean it would seem self-explanatory but changing it from true to false hasn't produced any changes for me...Thanks.

#1
02/01/2005 (4:44 pm)
Ok, I think I got this one....when set to true, the control will change size when the text does upon resolution change.

Now I have one more: Is there a way to prevent the text from changing size when the resolution is changed - like you can do with any bitmap by setting its sizing to relative?

One of my GUIs has a lot of text and in order for it all to fit into the designated space at 800x600, it has to be quite small at any higher res. Just for info, I need to keep it all at relative sizing. Sure will be grateful for any help.
#2
02/01/2005 (5:21 pm)
I actually just did this a couple of days ago. You don't really want the text to get scaled because it would end up fairly pixely at high resolutions. Instead you want to use a different font size. In the profile for your text, set the fontSize to mFloor(x * (getWord(getRes(), 0) / 640)) where x is the font size you would like for a 640x480 resolution.

This isn't really a perfect solution because it doesn't scale exactly (due to mFloor and the assumption of a 4:3 aspect ratio). Also, if you change the resolution after the profile has been created, you'll have to reload the profile.
#3
02/01/2005 (7:08 pm)
Thanks Adam - I see that this will change the font size based on the resolution but what I actually hope to do is to not have the font change size at all when the res is changed. The position of my text must be very accurate and when I change res, the font size changes (whether using your idea or not), therefore it is no longer in the same relationship to other elements.

Take a look at the following; it is what I am hoping to avoid:

This screen shot is at 1280X1024 - font size=30
img.photobucket.com/albums/v314/gloryiam/Torque%20Screenshots/SP32-34.jpg

This one is at 800X600 - same font size
img.photobucket.com/albums/v314/gloryiam/Torque%20Screenshots/SP32-33.jpg

As you can see, at a higher res, the text looks smaller in relation to the container it is in - as I am sure is well for some or even most people but in my case, if I make it larger for 1280X1024, it will be too large for 800X600. Does this make sense? :)
#4
02/01/2005 (9:47 pm)
Maybe I'm misunderstanding you're problem. I'm assuming you want your text to appear the same size at all resolutions.

Font sizes are resolution independent meaning their pixel height will be the same regardless of the screen resolution. Thus, a size 30 font will appear smaller at higher resolutions but is in fact still size 30. So, to solve this, you need to make the font size dependent on the resolution. This can be done with the technique I described above.
#5
02/02/2005 (6:08 pm)
Hi Adam,

You did understand perfectly, I think maybe I just didn't do something correctly...a couple of questions though: you say that if I change the resolution after the profile has been created, I must reload the profile - how would I do that? Do you mean I need to recompile my .cs file in which it is stored? Also, I did exactly what you suggested and the font still changed size when the resolution changed. Finally, why did you use 640 in this assignment, is it because it's the lowest resolution? Thanks for the patience! :)
#6
02/02/2005 (7:21 pm)
Reloading the profile:
Although I haven't tried it yet, I believe all you would have to do is re-exec the defaultProfiles.cs file like you said, then re-exec the gui files.

Font size still changing:
I don't know what to say here other than it works for me. Keep in mind, though, that this technique only takes into account the width of the screen. At 1280x1024, the font should appear to be the same width as 800x600, but it will be taller. This is because you are changing the aspect ratio.

640:
Exactly right - I chose 640 because it is the lowest resolution I plan on supporting. However, it should work similarly with any number. 640 just made the most sense to me.
#7
02/04/2005 (1:54 pm)
Ok, doing what you said didn't work for me but I was able to get the desired result by creating a funtion that changes my textCtrl's profile to one that has a fontSize best fitted for the current resolution. This function is called in "onWake" for the GUI in question.

I tried to change the fontSize in the profile itself on the fly by doing the following: MyGuiTextProfile.fontSize=n; but it didn't work. Is there a way to do this on the fly?
#8
02/04/2005 (5:24 pm)
I would guess that you can't modify gui profiles on the fly, but I'm not sure. Glad to hear you got it working.
#9
02/05/2005 (12:14 pm)
I sure appreciate you pointing me in the right direction though - I got my idea based on your example.
#10
02/13/2005 (5:59 pm)
Adam I would really like to see your GuiControlProfile if you could post it here. I am trying to get what you said working. This is what I have...
new GuiControlProfile (GuiTextoptionsProfile)
{
   fontColors[1] = "255 255 255";
   fontColors[2] = "0 0 0";
   //fontColor = "0 0 0";
   fontColorLink = "255 96 96";
   fontColorLinkHL = "0 0 255";
   fontSize = mFloor(10 * (getWord(getRes(), 0) / 640));

   //autoSizeWidth = true;
   //autoSizeHeight = true;
};

I am going to mess with the autoSize and see if that makes a difference.
#11
02/13/2005 (7:11 pm)
// At the top of the file
$Gui::resRatio = getWord(getRes(), 0) / 640;

new GuiControlProfile(GuiHeadingTextProfile) {
	fontType = "SpacePatrol";
	fontSize = mFloor(42 * $Gui::resRatio);
	fontColor = "0 0 0";
	fontColorLink = "255 96 96";
	fontColorLinkHL = "0 0 255";
	autoSizeWidth = false;
	autoSizeHeight = false;
	justify = "center";
};

autoSizeWidth and autoSizeHeight, if set to true, take precedence over the extent settings of the gui control and size the text box based on the height and width that the string of text requires to be displayed fully.
#12
11/19/2007 (6:16 am)
@Jacob: can you post your function to change the text profile based on resolution?

Tnx,
JoZ :)