本文整理汇总了C++中MenuItem::SetPositionAndSize方法的典型用法代码示例。如果您正苦于以下问题:C++ MenuItem::SetPositionAndSize方法的具体用法?C++ MenuItem::SetPositionAndSize怎么用?C++ MenuItem::SetPositionAndSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItem
的用法示例。
在下文中一共展示了MenuItem::SetPositionAndSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImportMenuLayout
void Screen_Base::ImportMenuLayout(const char* layout)
{
if( layout == 0 )
return;
cJSON* menuitemarray = cJSON_Parse( layout );
assert( menuitemarray );
if( menuitemarray )
{
int numitems = cJSON_GetArraySize( menuitemarray );
assert( numitems <= MAX_MENUITEMS );
for( int i=0; i<numitems; i++ )
{
cJSON* menuitem = cJSON_GetArrayItem( menuitemarray, i );
cJSON* objname = cJSON_GetObjectItem( menuitem, "Name" );
int itemindex = -1;
for( itemindex = 0; itemindex < MAX_MENUITEMS; itemindex++ )
{
if( strcmp( objname->valuestring, m_pMenuItems[itemindex]->m_Name ) == 0 )
break;
}
if( itemindex < MAX_MENUITEMS )
{
float x = 0;
float y = 0;
float w = 0;
float h = 0;
float iw = -1;
float ih = -1;
MenuItem* pMenuItem = m_pMenuItems[itemindex];
cJSONExt_GetFloat( menuitem, "X", &x );
cJSONExt_GetFloat( menuitem, "Y", &y );
cJSONExt_GetFloat( menuitem, "Scale", &pMenuItem->m_Scale.x );
cJSONExt_GetFloat( menuitem, "Scale", &pMenuItem->m_Scale.y );
cJSONExt_GetFloat( menuitem, "Scale", &pMenuItem->m_Scale.z );
cJSONExt_GetFloat( menuitem, "SX", &pMenuItem->m_Size.x );
cJSONExt_GetFloat( menuitem, "SY", &pMenuItem->m_Size.y );
cJSONExt_GetFloat( menuitem, "W", &w );
cJSONExt_GetFloat( menuitem, "H", &h );
cJSONExt_GetFloat( menuitem, "IW", &iw );
cJSONExt_GetFloat( menuitem, "IH", &ih );
cJSONExt_GetFloat( menuitem, "OffX", &pMenuItem->m_PositionOffset.x );
cJSONExt_GetFloat( menuitem, "OffY", &pMenuItem->m_PositionOffset.y );
pMenuItem->SetPositionAndSize( x, y, w, h, iw, ih );
switch( pMenuItem->m_MenuItemType )
{
case MIT_Sprite:
{
MenuSprite* pMenuSprite = GetMenuSprite( itemindex );
cJSONExt_GetFloat( menuitem, "BGShadowX", &pMenuSprite->m_DropShadowOffsetBG_X );
cJSONExt_GetFloat( menuitem, "BGShadowY", &pMenuSprite->m_DropShadowOffsetBG_Y );
}
break;
case MIT_Text: // MenuText_SaveLoad
{
MenuText* pMenuText = GetMenuText( itemindex );
cJSONExt_GetFloat( menuitem, "FontHeight", &pMenuText->m_FontHeight );
cJSONExt_GetFloat( menuitem, "TextShadowX", &pMenuText->m_DropShadowOffsetX );
cJSONExt_GetFloat( menuitem, "TextShadowY", &pMenuText->m_DropShadowOffsetY );
cJSONExt_GetUnsignedChar( menuitem, "Justify", &pMenuText->m_Justification );
}
break;
case MIT_Button:
{
MenuButton* pMenuButton = GetMenuButton( itemindex );
cJSONExt_GetFloat( menuitem, "FontHeight", &pMenuButton->m_FontHeight );
cJSONExt_GetFloat( menuitem, "BGShadowX", &pMenuButton->m_DropShadowOffsetBG_X );
cJSONExt_GetFloat( menuitem, "BGShadowY", &pMenuButton->m_DropShadowOffsetBG_Y );
cJSONExt_GetFloat( menuitem, "TextShadowX", &pMenuButton->m_DropShadowOffsetText_X );
cJSONExt_GetFloat( menuitem, "TextShadowY", &pMenuButton->m_DropShadowOffsetText_Y );
}
break;
case MIT_Base:
case MIT_InputBox:
case MIT_ScrollingText:
case MIT_ScrollBox:
case MIT_CheckBox:
case MIT_NumMenuItemTypes:
break;
//.........这里部分代码省略.........