Game Development Community

GUI text doesn't resize with window

by Yujiao Guo · in General Discussion · 11/02/2008 (10:01 pm) · 7 replies

Hi:


I have spent so many hours on getting the text resize with the window.
basically i have a bitmap button control that resize with the window, but the text in it doesn't.....

new GuiBitmapButtonTextCtrl(a) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "1";
Profile = "GuiMainMenuBitmapButtonTextProfile";
HorizSizing = "relative";
VertSizing = "relative";
position = "488 366";
Extent = "120 28";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "quit();";
tooltipprofile = "GuiDefaultProfile";
hovertime = "1000";
text = "Quit";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
bitmap = "scriptsAndAssets/Graphics/UI/Buttons/H_UI_Text_Button_Large.png";
)

and

if(!isObject(GuiMainMenuBitmapButtonTextProfile)) new GuiControlProfile (GuiMainMenuBitmapButtonTextProfile)
{
// font
fontType = "Arial Black";
//fontSize = 19;
fontCharset = ANSI;
fontColor = "255 255 255";
autoSizeWidth = true;
autoSizeHeight = true;
justify = "center";

};

these don't do anything at all.
No matter how bit or small my window is, the text size are always the same.
autoSizeWidth = true;
autoSizeHeight = true;

Thanks a thousand times any could help!
Thanks a thousand times any could help!
Thanks a thousand times any could help!
Thanks a thousand times any could help!
Thanks a thousand times any could help!
Thanks a thousand times any could help!

#1
11/02/2008 (11:10 pm)
Honestly ... my advice is to put the text for your button .. on the bitmap itself that u are using with the button.

What you are trying to do is possible, but as far as i know will take ALOT more work and in my opinion is not really worth doing.
#2
11/02/2008 (11:51 pm)
Check the GUI tutorials on TDN. Amaranth put one there to help resize GUI text when the window is resized. Works beautifully for me.

Problem with putting text ON the button is you then have to have a new image for every button you want to have - a menu with 5 options would require 5 buttons, and that's just on the main screen. THEN you have to create different versions of your image for mouseover, mousedown, inactive, and normal. So multiply your images by the number of buttons with different text, by 4. Too many images for me :)
#3
11/03/2008 (4:25 am)
Thanks a thousand times Shaz!!!
Where exactly is it?


Actually, the idea is from the game Hinterland that I have been playing...
All their texts are resized in response to window size changes. It looks aweful not being able to do this
unless I fix the window size in the first place.
#4
11/03/2008 (5:28 am)
Thanks a thousand times Shaz!!!


Actually, the idea is from the game Hinterland that I have been playing...
All their texts are resized in response to window size changes. It looks aweful not being able to do this
unless I fix the window size in the first place.
#5
11/03/2008 (7:50 pm)
I am not sure if it is possible to do it in script, but looking at the font rendering code, it is possible to apply some scale transformation to the texts according to the parent control's size. Not yet sure exactly how to do it though.
#6
11/03/2008 (8:34 pm)
I am not sure if it is possible to do it in script, but looking at the font rendering code, it is possible to apply some scale transformation to the texts according to the parent control's size. Not yet sure exactly how to do it though.
#7
11/03/2008 (10:12 pm)
I'm sure you could. Would be a lot of mucking around though, and a lot of testing.

Something I thought would be useful would be to change the parent's size based on the font size and the amount of text - for example, work out how many points wide and high the text itself would be, add a border all around, and make the parent's size (parent being a backdrop) that big.