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; } } } cJSON_Delete( menuitemarray ); } }