[SOLVED]Problems when resizing layouts

Shamus88

01-04-2009 21:30:37

Right, not very sure how to explain this but I will try my best so please be patient.

I have created for example a nice Introduction screen layout for my game. In my PC (which has native resolution 1680x1050) everything looks fine in non full screen and full screen mode.

However, when I run the game in my mate's PC which has a slightly lower native resolution, the window only shows part of the layout. I tried resizing, changing resolution but it doesn't really help.

The question here is : is it somewhat possible to make the layout resize automatically according to the window size? I have tried the stretch option (HStretch and VStretch) but it seems to distort the widgets in the layout (I only have parent widget at the moment and no child widgets). I am currently using HCenter Top for title and HCenter bottom for the group logo. I also noticed that HCenter bottom will bug out in test mode if I try to resize the window during Test mode. When I return to editor mode the HCenter bottom aligned widget will dissapear.

Am I missing something here?

raygeee

01-04-2009 22:17:42

Maybe there are other solutions but that's what I did:
Add a parent widget with skin "Default", layer "Back" and your default screen resolution as position. Set InheritsPick, NeedMouse and NeedKey to false. Now you just have to set that widget's size each time the resolution changes.

Like that:<Widget type="Widget" skin="Default" position="0 0 800 600" align="ALIGN_STRETCH" layer="Back" name="Background">
<Property key="Widget_NeedMouse" value="false"/>
<Property key="Widget_NeedKey" value="false"/>
<Property key="Widget_InheritsPick" value="true"/>
... your widgets ...
</Widget>

edit: Forget about the align="ALIGN_STRETCH" property, It's not needed.

Shamus88

02-04-2009 17:16:01

Hi,

Thanks for your reply. Correct me if I am wrong, but from what I understand you are suggesting that I create a parent container and put all my child widgets inside it with the Stretch alignment (All the child using VStretch HStretch I guess?). But this will still mean I would have to manually set the "size" of the container. This would be no different for example if I set the resolution of the editor and do the editing of my layouts in that resolution?

Anyway, I will give it a go. Will post any feedback I have once I tested it. Is there no other solution around this problem?

Altren

02-04-2009 17:24:52

This would be no different for example if I set the resolution of the editor and do the editing of my layouts in that resolution?No, in editor you can select only one resolution and make layout for it, and raygeee suggest make parent widget and resize it after loading layout to screen resolution. And you also should put right aligns for your widgets if you want to see your widgets at bottom or right or whatever you want.

Shamus88

02-04-2009 18:06:39

hmm i followed the code suggested earlier but its still not resizing to the window size. My native res is @ 1680x1050 and the program is set to run @ 1280x720. However some widgets are still out of bounds.

This is my code:

<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">

<Widget type="Widget" skin="Default" position="0 0 1280 720" align="ALIGN_STRETCH" layer="Back" name="Background">
<Property key="Widget_NeedMouse" value="false"/>
<Property key="Widget_NeedKey" value="false"/>
<Property key="Widget_InheritsPick" value="true"/>

<Widget type="StaticText" skin="StaticText" position="496 58 688 80" align="HCenter Top" layer="Back">
<Property key="Text_FontName" value="BattleStar"/>
<Property key="Text_FontHeight" value="75"/>
<Property key="Text_TextColour" value="100 100 10"/>
<Property key="Widget_Caption" value="Test"/>
</Widget>
<Widget type="StaticText" skin="StaticText" position="744 154 192 24" align="HCenter Top" layer="Back">
<Property key="Text_FontName" value="DejaVuSans.17"/>
<Property key="Text_FontHeight" value="22"/>
<Property key="Text_TextColour" value="100 0 0"/>
<Property key="Widget_Caption" value="by Team Name"/>
</Widget>
<Widget type="Widget" skin="Panel" position="613 760 453 136" align="HCenter Bottom" layer="Back">
<Property key="Widget_Alpha" value="120"/>
<Widget type="Button" skin="Button" position="22 38 110 42" layer="Back" name="Play">
<Property key="Widget_InheritsAlpha" value="false"/>
<Property key="Widget_Caption" value="Play"/>
</Widget>
<Widget type="Button" skin="Button" position="170 38 112 44" layer="Back" name="Instructions">
<Property key="Widget_InheritsAlpha" value="false"/>
<Property key="Widget_Caption" value="Instructions"/>
</Widget>
<Widget type="Button" skin="Button" position="320 40 114 42" layer="Back" name="Exit">
<Property key="Widget_Caption" value="Exit"/>
<Property key="Widget_InheritsAlpha" value="false"/>
</Widget>
<Widget type="Button" skin="CheckBox" position="148 94 162 30" layer="Back" name="Sound">
<Property key="Widget_Caption" value="Sound"/>
<Property key="Widget_InheritsAlpha" value="false"/>
</Widget>
<Widget type="StaticText" skin="StaticText" position="189 8 112 16" layer="Back">
<Property key="Widget_Caption" value="Main Menu"/>
<Property key="Text_FontName" value="DejaVuSans.17"/>
<Property key="Widget_InheritsAlpha" value="false"/>
</Widget>
</Widget>
<Widget type="StaticText" skin="StaticText" position="714 484 4 2" layer="Back"/>

</Widget>
</MyGUI>


edit: Could it be that the layout was edited in MyGUI @ my native res?

Altren

02-04-2009 18:41:32

You need to resize "Background" widget manually after loading layout. Just one line of code - something like:
mGUI->findWidget<MyGUI::Widget>("Background")->setSize(mGUI->getViewSize());

Shamus88

03-04-2009 18:25:53

Thanks! Great support!