当前位置: 首页>>代码示例>>C++>>正文


C++ MenuItem::SetPositionAndSize方法代码示例

本文整理汇总了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;
//.........这里部分代码省略.........
开发者ID:pmeneguzzi,项目名称:SharedGameCode,代码行数:101,代码来源:Screen_Base.cpp


注:本文中的MenuItem::SetPositionAndSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。