(9.07) I created a second kind of button how to "get" it

christianboutin.com

13-09-2009 00:27:11

I start from the PlayPen example.

Created a new file called uscagui.skinTypes which only contains 1 button definition :

Button usca_bigbutton
{
SkinElement default
{
Border_Bottom 2
Border_Left 2
Border_Right 2
Border_Top 2
Texture uscagui.bigbutton.png
TileBackground false
TileBorders true
}

SkinElement down
{
Border_Bottom 2
Border_Left 2
Border_Right 2
Border_Top 2
Texture uscagui.bigbutton.down.png
TileBackground false
TileBorders true
}

SkinElement over
{
Border_Bottom 2
Border_Left 2
Border_Right 2
Border_Top 2
Texture uscagui.bigbutton.over.png
TileBackground false
TileBorders true
}
}


By tracing through the resource manager/parse script method I know that the script is properly loaded, parsed, a my new button type is added to the mDefinitions of the ScriptReader. So far so good. But now how do I "get" it?

Can't use QuickGUI::DescManager::getSingleton().getDefaultButtonDesc(); that'll give me the default button (as it's supposed to).

I thought of using getDesc in such a way :

QuickGUI::ButtonDesc* bd = QuickGUI::DescManager::getSingleton().getDesc<QuickGUI::ButtonDesc>(Ogre::String("usca_bigbutton"));

It says my desc doesn't exist. Tracing through I find that getDesc parses through mUserCreatedDescs, which is empty.

I'm a bit stomped. There appears to be a step I'm missing.

Any help, as always, much appreciated :-)

kungfoomasta

13-09-2009 05:34:47

You mean how to use the skin?

you can set it in the desc prior to creation of the widget:

myDesc->widget_skinTypeName = "usca_bigbutton";

Or you can set it afterwards:

myButton->setSkinType("usca_bigbutton");

christianboutin.com

13-09-2009 13:55:37

Ah! Thanks. So I was misunderstanding the skin vs desc concept. Quick suggestion, if I may, you could add these lines to the Playpen's MainForm.cpp :

QuickGUI::ButtonDesc* bd = QuickGUI::DescManager::getSingleton().getDefaultButtonDesc();
bd->widget_skinTypeName = "default.vslider"; // By default, a button will be skinned with "Button default" in the skintypes. Alternatively, you can use myButton->setSkinType("default.vslider"); after creation.
bd->widget_name = "MyButton";
bd->widget_dimensions.size = QuickGUI::Size(128,64);
bd->widget_dimensions.position = QuickGUI::Point(0,0);

Ogre::String s("micross.12");
Ogre::UTFString u("I do nothing!");
QuickGUI::TextSegment ts(s,QuickGUI::ColourValue::Red,u);
bd->textDesc.segments.push_back(ts);


That would give hints as to how skinning works. Cheers!

kungfoomasta

13-09-2009 16:34:01

Done, I've added this to PlayPen, it show up in the next release.

I've also updated the wiki tutorial:
http://www.ogre3d.org/wiki/index.php/QuickGUI_Beginner_Tutorial_2