Example #1
0
    UILayout*  UICreator::CreateUILayoutFromFile(const char* file, cocos2d::CCNode *pParent,
                                                     bool bShow )
    {
        // Load plist layout file
        UILayout* pLayer = NULL;    
        NiStream * pkStream = new NiStream();
        pLayer = (UILayout*)(pkStream->CreateControlFromFile(file, pParent));     
        delete pkStream;

		if(NULL == pLayer)
		{
			return NULL;
		}

		// update containers reference object
		std::list<UIControlBase*> childContainers = pLayer->getAllChildEndsWithName("Container");
		for(std::list<UIControlBase*>::iterator it = childContainers.begin();
			it != childContainers.end(); it++)
		{
			if(dynamic_cast<UIContainer*>(*it) != NULL)
			{
				UIContainer *tmp = static_cast<UIContainer*>(*it);

				if(tmp->getRefMode() == OBJECT_REFERENCE)
				{
					std::string refObjName = tmp->getRefObjName();
					UIControlBase *refObj = pLayer->FindChildObjectByName(refObjName);
					if(refObj != NULL && dynamic_cast<UIContainer*>(refObj) != NULL)
					{
						tmp->setRefObj(static_cast<UIContainer*>(refObj));
					}
				}
			}
		}

		// update scroll pages
		std::list<UIControlBase*> childScrollPages = pLayer->getAllChildEndsWithName("ScrollPage");
		for(std::list<UIControlBase*>::iterator it = childScrollPages.begin();
			it != childScrollPages.end(); it++)
		{
			if(dynamic_cast<UIScrollPage*>(*it) != NULL)
			{
				UIScrollPage *tmp = static_cast<UIScrollPage*>(*it);
				tmp->addPagesByChildren();
			}
		}

		float scaleFactor = UIManager::sharedManager()->getScaleFactor();
		//float scaleFactorX = UIManager::sharedManager()->getScaleFactorX();
		//float scaleFactorY = UIManager::sharedManager()->getScaleFactorY();
		pLayer->setScale(scaleFactor);
		//pLayer->setScale(scaleFactorX, scaleFactorY);

        return pLayer;
    }
bool Cmd_SKSETestFunc_Eval(COMMAND_ARGS_EVAL)
{
	NiNode	* node = (*g_thePlayer)->GetNiNode();

	UInt8		niStreamMemory[0x5B4];
	NiStream	* niStream = (NiStream *)niStreamMemory;
	CALL_MEMBER_FN(niStream, ctor)();

	node->IncRef();
	niStream->m_rootObjects.Append(node);

	niStream->SavePath("head.nif");

	CALL_MEMBER_FN(niStream, dtor)();

	return true;	
}
Example #3
0
void SKSETaskExportHead::Run()
{
	if (!m_formId)
		return;

	TESForm * form = LookupFormByID(m_formId);
	Actor * actor = DYNAMIC_CAST(form, TESForm, Actor);
	if (!actor)
		return;

	BSFaceGenNiNode * faceNode = actor->GetFaceGenNiNode();
	TESNPC * actorBase = DYNAMIC_CAST(actor->baseForm, TESForm, TESNPC);
	if (!actorBase || !faceNode)
		return;

	BSFaceGenAnimationData * animationData = actor->GetFaceGenAnimationData();
	if (animationData) {
		FaceGen::GetSingleton()->isReset = 0;
		for (UInt32 t = BSFaceGenAnimationData::kKeyframeType_Expression; t <= BSFaceGenAnimationData::kKeyframeType_Phoneme; t++)
		{
			BSFaceGenKeyframeMultiple * keyframe = &animationData->keyFrames[t];
			for (UInt32 i = 0; i < keyframe->count; i++)
				keyframe->values[i] = 0.0;
			keyframe->isUpdated = 0;
		}
		UpdateModelFace(faceNode);
	}

	IFileStream::MakeAllDirs(m_nifPath.data);

	BSFadeNode * rootNode = BSFadeNode::Create();
	rootNode->IncRef();
	NiNode * skinnedNode = NiNode::Create(0);
	skinnedNode->m_name = BSFixedString("BSFaceGenNiNodeSkinned").data;

	std::map<NiAVObject*, NiAVObject*> boneMap;

	for (UInt32 i = 0; i < faceNode->m_children.m_size; i++)
	{
		NiAVObject * object = faceNode->m_children.m_data[i];
		if (!object)
			continue;

		if (NiGeometry * geometry = object->GetAsNiGeometry()) {
			NiGeometryData * geometryData = niptr_cast<NiGeometryData>(geometry->m_spModelData);
			NiGeometryData * newGeometryData = NULL;
			if (geometryData)
				CALL_MEMBER_FN(geometryData, DeepCopy)((NiObject **)&newGeometryData);

			NiProperty * trishapeEffect = niptr_cast<NiProperty>(geometry->m_spEffectState);
			NiProperty * newTrishapeEffect = NULL;
			if (trishapeEffect)
				CALL_MEMBER_FN(trishapeEffect, DeepCopy)((NiObject **)&newTrishapeEffect);

			NiProperty * trishapeProperty = niptr_cast<NiProperty>(geometry->m_spPropertyState);
			NiProperty * newTrishapeProperty = NULL;
			if (trishapeProperty)
				CALL_MEMBER_FN(trishapeProperty, DeepCopy)((NiObject **)&newTrishapeProperty);

			NiSkinInstance * skinInstance = niptr_cast<NiSkinInstance>(geometry->m_spSkinInstance);
			NiSkinInstance * newSkinInstance = NULL;
			if (skinInstance) {
				newSkinInstance = skinInstance->Clone(false);
				newSkinInstance->m_pkRootParent = skinnedNode;

				UInt32 numBones = 0;
				NiSkinData * skinData = niptr_cast<NiSkinData>(skinInstance->m_spSkinData);
				NiSkinData * newSkinData = NULL;
				if (skinData) {
					numBones = skinData->m_uiBones;
					CALL_MEMBER_FN(skinData, DeepCopy)((NiObject **)&newSkinData);
				}

				NiSkinPartition * skinPartition = niptr_cast<NiSkinPartition>(skinInstance->m_spSkinPartition);
				NiSkinPartition * newSkinPartition = NULL;
				if (skinPartition)
					CALL_MEMBER_FN(skinPartition, DeepCopy)((NiObject **)&newSkinPartition);

				newSkinInstance->m_spSkinData = newSkinData;
				newSkinData->DecRef();

				newSkinInstance->m_spSkinPartition = newSkinPartition;
				newSkinPartition->DecRef();

				// Remap the bones to new NiNode instances
				if (numBones > 0)
				{
					newSkinInstance->m_ppkBones = (NiAVObject**)NiAllocate(numBones * sizeof(NiAVObject*));
					for (UInt32 i = 0; i < numBones; i++)
					{
						NiAVObject * bone = skinInstance->m_ppkBones[i];
						if (bone)
						{
							auto it = boneMap.find(bone);
							if (it == boneMap.end()) {
								NiNode * newBone = NiNode::Create();
								newBone->m_name = bone->m_name;
								newBone->m_flags = bone->m_flags;
								boneMap.insert(std::make_pair(bone, newBone));
								newSkinInstance->m_ppkBones[i] = newBone;
							}
							else
								newSkinInstance->m_ppkBones[i] = it->second;
						}
						else
						{
							newSkinInstance->m_ppkBones[i] = nullptr;
						}
					}
				}
			}

			NiGeometry * newGeometry = NULL;

			if (NiTriShape * trishape = geometry->GetAsNiTriShape()) {
				NiTriShape * newTrishape = NiTriShape::Create(static_cast<NiTriShapeData*>(newGeometryData));
				newGeometryData->DecRef();
				newTrishape->m_localTransform = geometry->m_localTransform;
				newTrishape->m_name = geometry->m_name;
				memcpy(&newTrishape->unk88, &geometry->unk88, 0x1F);
				newTrishape->m_spEffectState = newTrishapeEffect;
				newTrishape->m_spPropertyState = newTrishapeProperty;
				newTrishape->m_spSkinInstance = newSkinInstance;
				newGeometry = newTrishape;
			}
			else if (NiTriStrips * tristrips = geometry->GetAsNiTriStrips()) {
				NiTriStrips * newTristrips = NiTriStrips::Create(static_cast<NiTriStripsData*>(newGeometryData));
				newGeometryData->DecRef();
				newTristrips->m_localTransform = geometry->m_localTransform;
				newTristrips->m_name = geometry->m_name;
				memcpy(&newTristrips->unk88, &geometry->unk88, 0x1F);
				newTristrips->m_spEffectState = newTrishapeEffect;
				newTristrips->m_spPropertyState = newTrishapeProperty;
				newTristrips->m_spSkinInstance = newSkinInstance;
				newGeometry = newTristrips;
			}

			if (newGeometry)
			{
				auto textureData = GetTextureSetForPartByName(actorBase, newGeometry->m_name);
				if (textureData.first && textureData.second) {
					BSShaderProperty * shaderProperty = niptr_cast<BSShaderProperty>(newGeometry->m_spEffectState);
					if (shaderProperty) {
						if (shaderProperty->GetRTTI() == NiRTTI_BSLightingShaderProperty) {
							BSLightingShaderProperty * lightingShader = static_cast<BSLightingShaderProperty *>(shaderProperty);
							BSLightingShaderMaterial * material = static_cast<BSLightingShaderMaterial *>(shaderProperty->material);
							if (material && material->textureSet) {
								for (UInt32 i = 0; i < BGSTextureSet::kNumTextures; i++)
									material->textureSet->SetTexturePath(i, textureData.first->textureSet.GetTexturePath(i));

								if (textureData.second->type == BGSHeadPart::kTypeFace)
									material->textureSet->SetTexturePath(6, m_ddsPath.data);
							}
						}
					}

					// Save the previous tint mask
					BSShaderProperty * originalShaderProperty = niptr_cast<BSShaderProperty>(geometry->m_spEffectState);
					if (originalShaderProperty) {
						if (originalShaderProperty->GetRTTI() == NiRTTI_BSLightingShaderProperty) {
							BSLightingShaderProperty * lightingShader = static_cast<BSLightingShaderProperty *>(originalShaderProperty);
							BSLightingShaderMaterial * material = static_cast<BSLightingShaderMaterial *>(originalShaderProperty->material);
							if (material) {
								if (material->GetShaderType() == BSShaderMaterial::kShaderType_FaceGen) {
									BSMaskedShaderMaterial * maskedMaterial = static_cast<BSMaskedShaderMaterial *>(material);
									SaveRenderedDDS(niptr_cast<NiRenderedTexture>(maskedMaterial->renderedTexture), m_ddsPath.data);
								}
							}
						}
					}
				}

				skinnedNode->AttachChild(newGeometry, true);
			}
		}
	}

	for (auto & bones : boneMap)
		rootNode->AttachChild(bones.second, true);

	rootNode->AttachChild(skinnedNode, true);

	UInt8 niStreamMemory[0x5B4];
	memset(niStreamMemory, 0, 0x5B4);
	NiStream * niStream = (NiStream *)niStreamMemory;
	CALL_MEMBER_FN(niStream, ctor)();
	CALL_MEMBER_FN(niStream, AddObject)(rootNode);
	niStream->SavePath(m_nifPath.data);
	CALL_MEMBER_FN(niStream, dtor)();

	rootNode->DecRef();

	if (animationData) {
		animationData->overrideFlag = 0;
		CALL_MEMBER_FN(animationData, Reset)(1.0, 1, 1, 0, 0);
		FaceGen::GetSingleton()->isReset = 1;
		UpdateModelFace(faceNode);
	}
}
Example #4
0
	void UITextInputField::LoadBinary(NiStream &kStream)
	{
		UIControlBase::LoadBinary(kStream);    

		mutableDic* dic = kStream.GetStreamData();
        
		float contentScale = CCDirector::sharedDirector()->getContentScaleFactor();
		
		uint32_t bLocalizeString = 0;
		kStream.getIntAttributeValue(dic, "bLocalizeString", bLocalizeString);

		std::string strTemp = "";
		kStream.getStringattributeValue(dic, "placeholder", strTemp);
		const char* placeholder = strTemp.c_str();
		if (bLocalizeString > 0)
		{
			placeholder = CCLocalizedString(strTemp.c_str(), strTemp.c_str());
		}

		uint32_t lengthLimit = 0;
		kStream.getIntAttributeValue(dic, "lengthLimit", lengthLimit);

		uint32_t isPassword = 0;
		kStream.getIntAttributeValue(dic, "isPassword", isPassword);

		int priority = kCCMenuHandlerPriority;
		kStream.getSignedIntAttributeValue(dic,"priority",priority);

		uint32_t dimensionWidth = 0;
		uint32_t dimensionHeight = 0;
		kStream.getIntAttributeValue(dic, "dimensionWidth", dimensionWidth);
		kStream.getIntAttributeValue(dic, "dimensionHeight", dimensionHeight);
        
        dimensionWidth /= contentScale;
        dimensionHeight /= contentScale;

		uint32_t alignment = 1;
		kStream.getIntAttributeValue(dic, "alignment", alignment);

		mutableDic *colorDic = static_cast<mutableDic*>(dic->objectForKey("color"));
		uint32_t color[3] = {255, 255, 255};
		if(colorDic)
		{
			kStream.getIntAttributeValue(colorDic, "red", color[0]);
			kStream.getIntAttributeValue(colorDic, "green", color[1]);
			kStream.getIntAttributeValue(colorDic, "blue", color[2]);
		}

		string font = KJLinXin;
		kStream.getStringattributeValue(dic, "font", font);

        float largeFontSize = GameFontManager::largeFontSize();
		uint32_t fontSize = largeFontSize * contentScale;
		kStream.getIntAttributeValue(dic, "fontSize", fontSize);
		fontSize /= contentScale;

		CCSize dimension = CCSizeMake(dimensionWidth, dimensionHeight);
		if(dimensionWidth > 0 && dimensionHeight < fontSize)
		{
			dimension = CCSizeMake(dimensionWidth, fontSize);
		}
        
		CCSize touchSize = CCSizeZero;
		mutableDic *rectDic = static_cast<mutableDic*>(dic->objectForKey("rect"));
		if(rectDic)
		{
			uint32_t useASRect = 0;
			std::string ASRectName = "";
			std::string ASfile = KUI_BIN;
			uint32_t anchorPoint = 0;
			// if use Asprite Rect
			kStream.getIntAttributeValue(rectDic, "useASRect", useASRect);
			kStream.getIntAttributeValue(rectDic, "anchorPoint", anchorPoint);
			if(useASRect == 1)
			{
				kStream.getStringattributeValue(rectDic, "ASRectName", ASRectName);
				if(ASRectName != "")
				{
					mutableDic* dicAsMgr = static_cast<mutableDic*>(rectDic->objectForKey("AspriteManager"));
					// content attributes 
					if (dicAsMgr)
					{
						if (IsIpad())
						{
							kStream.getStringattributeValue(dicAsMgr, "ipad", ASfile); 
						}else
						{
							kStream.getStringattributeValue(dicAsMgr, "iphone", ASfile); 
						}
					}
					int ID = getResourceIDByName(ASRectName.c_str());
					// name not exists, use normal method
					if(ID != -1)
					{
						ASprite *as = AspriteManager::getInstance()->getAsprite(ASfile);
						CCRect asRect = as->getframeRect(ID);
						touchSize = asRect.size;
						switch(anchorPoint)
						{
						case 0:
							{
								CCRect rect = as->getframeRect(ID);
								m_ptWorldPosition = rect.origin;
							}
							break;

						case 1:
							m_ptWorldPosition = as->GetFramePointMiddle(ID);
							break;

						default:
							break;
						}

						CCPoint parentWorldPosition = CCPointZero;
						if(m_pParent != NULL)
						{
							parentWorldPosition = m_pParent->getWorldPosition();
						}

						m_ptLocalPosition.x = m_ptWorldPosition.x - parentWorldPosition.x;
						m_ptLocalPosition.y = m_ptWorldPosition.y - parentWorldPosition.y;
					}
				}
			}
		}

		m_pTextInputField = TextInputField::textFieldWithPlaceHolder(placeholder,
			dimension,
			(CCTextAlignment)alignment,
			font.c_str(),
			(float)fontSize
			);

		m_pTextInputField->setAnchorPoint(ccp(0.5, 0.5));
		m_pTextInputField->setPosition(m_ptLocalPosition);
		m_pTextInputField->setLengthLimit(lengthLimit);
		m_pTextInputField->setIsPassword(isPassword != 0);
		m_pTextInputField->setColor(ccc3(color[0], color[1], color[2]));
		m_pTextInputField->setInitPriority(priority);
		m_pTextInputField->setTouchInputSize(touchSize);
		// make background
		CreateWhiteBack();
		if(m_pWhiteBack != NULL)
		{
			m_pWhiteBack->setPosition(m_ptLocalPosition);
			m_pWhiteBack->setVisible(m_bIsVisible);
		}

		m_pControlNode = m_pTextInputField;
		m_pControlNode->setVisible(m_bIsVisible);
	}
Example #5
0
	void UIScrollPage::LoadBinary(NiStream &kStream)
	{
		UIControlBase::LoadBinary(kStream);

		uint32_t contentWidth = 0;
		uint32_t contentHeight = 0;
		uint32_t direction = 0;
		int priority = kCCScrollTouchPriority;

		mutableDic *dic = kStream.GetStreamData();

		// get button click callback function
		kStream.getStringattributeValue(dic, "itemClickedCallback", m_strItemClickedFun);
		kStream.getStringattributeValue(dic, "itemDoubleClickedCallback", m_strItemDoubleClickedFun);
		kStream.getStringattributeValue(dic, "itemDragReleaseCallback", m_strItemDragReleaseFun);
		kStream.getStringattributeValue(dic, "tappedCallback", m_strTappedFun);
		kStream.getStringattributeValue(dic, "tapCancelCallback", m_strTapCancelFun);

		kStream.getIntAttributeValue(dic, "itemType", m_itemType);
		kStream.getIntAttributeValue(dic, "contentWidth", contentWidth);
		kStream.getIntAttributeValue(dic, "contentHeight", contentHeight);
		kStream.getIntAttributeValue(dic, "direction", direction);
		kStream.getSignedIntAttributeValue(dic, "indicatorOffsetX", m_indicatorOffsetX);
		kStream.getSignedIntAttributeValue(dic, "indicatorOffsetY", m_indicatorOffsetY);
        kStream.getSignedIntAttributeValue(dic,"priority",priority);

        contentWidth /= CC_CONTENT_SCALE_FACTOR();
        contentHeight /= CC_CONTENT_SCALE_FACTOR();
        m_indicatorOffsetX /= CC_CONTENT_SCALE_FACTOR();
        m_indicatorOffsetY /= CC_CONTENT_SCALE_FACTOR();
        
		setDirection((EScrollDirection)direction);

		// query frameRect property
		mutableDic* framedic = static_cast<mutableDic*>(dic->objectForKey("frameRect"));
		if( framedic )
		{
			string rectAsIndex = "";			
			kStream.getStringattributeValue(framedic, "rectAsIndex", rectAsIndex);	
			uint32_t  useAscontentRect = 0;
			kStream.getIntAttributeValue(framedic, "useAscontentRect", useAscontentRect);
			if (useAscontentRect)
			{
				CCPoint pt;
				string ASfile = KUI_BIN;
				kStream.getStringattributeValue(framedic, "binFile", ASfile); 
				ASprite *as = AspriteManager::getInstance()->getAsprite(ASfile);   

				int idx = getResourceIDByName(rectAsIndex.c_str());
				CCRect scrollRect = as->getframeRect(idx);
				CCPoint scrollCenter = as->GetFramePointMiddle(idx);

				// re-calculate the local position 
				CCPoint parentWorldPosition = CCPointZero;
				if(m_pParent != NULL)
				{
					parentWorldPosition = m_pParent->getWorldPosition();
				}

				m_ptLocalPosition.x = scrollCenter.x - parentWorldPosition.x;
				m_ptLocalPosition.y = scrollCenter.y - parentWorldPosition.y;

				setContentSize(scrollRect.size);
			}
		}
		else
		{
			setContentSize(CCSize(contentWidth, contentHeight));
		}

		m_pScrollLayer = UIScrollLayer::nodeWithNoLayer(m_contentSize, m_direction);
		m_pScrollLayer->setPosition(m_ptLocalPosition);
		m_pScrollLayer->setPagesIndicatorPosition(ccp(m_indicatorOffsetX, m_indicatorOffsetY));
		m_pScrollLayer->setPriority(priority);
		m_pScrollLayer->setVisible(m_bIsVisible);
		m_pControlNode = m_pScrollLayer->getBaseLayer();

		// add pages
		mutableDic* pageDic = static_cast<mutableDic*>(dic->objectForKey("page"));
		if( pageDic )
		{
			kStream.getIntAttributeValue(pageDic, "count", m_ipageCount); 
			kStream.getIntAttributeValue(pageDic, "column", m_icolumn); 
			kStream.getIntAttributeValue(pageDic, "row", m_irow); 
			kStream.getIntAttributeValue(pageDic, "cellOffsetX", m_celloffsetX); 
			kStream.getIntAttributeValue(pageDic, "cellOffsetY", m_celloffsetY);
            
            m_celloffsetX /= CC_CONTENT_SCALE_FACTOR();
            m_celloffsetY /= CC_CONTENT_SCALE_FACTOR();
            
			m_bIsConfiged = true;
		}

		m_cellAsfile = "";
		kStream.getStringattributeValue(dic, "cellAsIndex", m_cellAsfile);
		m_cellSelectedAsfile = "";
		kStream.getStringattributeValue(dic, "cellSelectedAsIndex", m_cellSelectedAsfile);
		if (m_cellAsfile.empty() == false)
		{
			CCPoint pt;
			m_cellBinFile = KUI_BIN;
			kStream.getStringattributeValue(dic, "binFile", m_cellBinFile); 
			ASprite *as = AspriteManager::getInstance()->getAsprite(m_cellBinFile);   
			int idx = getResourceIDByName(m_cellAsfile.c_str());
			m_cellRect = as->getframeRect(idx);
		}

		for(int i = 0 ; i < (int) m_ipageCount ; i ++)
		{
			addOneEmptyPage(i);
		}
	}
Example #6
0
	void UIList::LoadBinary(NiStream &kStream)
	{
		UIControlBase::LoadBinary(kStream);
		
		uint32_t viewWidth = 0;
		uint32_t viewHeight = 0;
		uint32_t contentOffsetX = 0;
		uint32_t contentOffsetY = 0;
		uint32_t contentWidth = 0;
		uint32_t contentHeight = 0;
		uint32_t direction = 0;
		uint32_t startX = 0;
		uint32_t startY = 0;

		mutableDic *dic = kStream.GetStreamData();
		
		kStream.getIntAttributeValue(dic, "viewWidth", viewWidth);
		kStream.getIntAttributeValue(dic, "viewHeight", viewHeight);
		kStream.getIntAttributeValue(dic, "contentOffsetX", contentOffsetX);
		kStream.getIntAttributeValue(dic, "contentOffsetY", contentOffsetY);
		kStream.getIntAttributeValue(dic, "contentWidth", contentWidth);
		kStream.getIntAttributeValue(dic, "contentHeight", contentHeight);
		kStream.getIntAttributeValue(dic, "direction", direction);
		kStream.getIntAttributeValue(dic, "startX", startX);
		kStream.getIntAttributeValue(dic, "startY", startY);
        
        viewWidth /= CC_CONTENT_SCALE_FACTOR();
        viewHeight /= CC_CONTENT_SCALE_FACTOR();
        contentWidth /= CC_CONTENT_SCALE_FACTOR();
        contentHeight /= CC_CONTENT_SCALE_FACTOR();
		m_ptLocalPosition = CCPointZero;
		mutableDic *bgDic = (mutableDic*)dic->objectForKey("background");
		if(bgDic)
		{
			// load ASpriteManger resource file
			ASprite* as = GetASpriteCfg(kStream, bgDic);               
			m_pBackground = GetASprite(kStream, bgDic, as, "name", m_ptWorldPosition);

			uint32_t useASposition = 0;
			if(kStream.getIntAttributeValue(bgDic, "useASposition", useASposition) && useASposition == 1)
			{
				CCPoint parentWorldPosition = CCPointZero;
				if(m_pParent != NULL)
				{
					parentWorldPosition = m_pParent->getWorldPosition();
				}

				m_ptLocalPosition.x = m_ptWorldPosition.x - parentWorldPosition.x;
				m_ptLocalPosition.y = m_ptWorldPosition.y - parentWorldPosition.y;
				viewWidth = m_pBackground->getContentSize().width / CC_CONTENT_SCALE_FACTOR();
				viewHeight = m_pBackground->getContentSize().height / CC_CONTENT_SCALE_FACTOR();
			}
			else
			{
				// we modified it, so reset it
				UIControlBase::CalWorldPos();
			}

			m_pBackground->setPosition(CCPointZero);
			m_pBackground->setVisible(m_bIsVisible);
		}
		
		setDirection((SWUIScrollViewDirection)direction);
		m_ptStartOffset = ccp((int)startX / CC_CONTENT_SCALE_FACTOR(), (int)startY / CC_CONTENT_SCALE_FACTOR());
        
		m_pScrollView = UIScrollView::viewWithViewSize(CCSize(viewWidth, viewHeight));
		m_pScrollView->setDirection(m_direction);
		m_pScrollView->setPosition(m_ptLocalPosition);
		m_pScrollView->setContentOffset(ccp((int)contentOffsetX / CC_CONTENT_SCALE_FACTOR(),
                                            (int)contentOffsetY / CC_CONTENT_SCALE_FACTOR()));
		m_pScrollView->setContentSize(CCSize(contentWidth, contentHeight));

		m_pControlNode = m_pScrollView;
		m_pControlNode->setVisible(m_bIsVisible);
		
		/// init list items template
		mutableDic *listDic = (mutableDic*)dic->objectForKey("ListItem");
		if (listDic)
		{
			// load ASpriteManger resource file
			ASprite *as =  GetASpriteCfg(kStream, listDic);		
			uint32_t nCount = 0;  kStream.getIntAttributeValue(listDic, "count", nCount);
			for(size_t i = 0; i < nCount; i++)
			{
				CCSprite* pSptNormal = GetASprite(kStream, listDic, as, "normal");
				CCSprite* pSptSel = GetASprite(kStream, listDic, as, "select");
				ListItemButton* item = AddItem(pSptNormal, pSptSel);
				item->setTag(i);
			}
		}
	}
//---------------------------------------------------------------------------
bool NIF_Files::CreateScene()
{
    // Because our scene will have some billboards with alpha, we use 
    // a NiAlphaAccumulator in order that our alpha gets sorted and drawn
    // correctly.
    NiAlphaAccumulator* pkAccum = NiNew NiAlphaAccumulator;
    m_spRenderer->SetSorter(pkAccum);
	
    // NiStreams are used to load a NIF file from disk. Once a stream is 
    // loaded, it will contain one or more "top-level" objects. These objects
    // could be NiNodes, NiTextures, or any other Gamebryo class. The Max and 
    // Maya exporters both place the scene graph as the first element in the
    // NIF file.

    NiStream kStream;

    // Load in the scenegraph for our world...
    bool bSuccess = kStream.Load(
        NiApplication::ConvertMediaFilename("GameScene.nif"));

    if (!bSuccess)
    {
        NiMessageBox("WORLD.NIF file could not be loaded!", "NIF Error");
        return false;
    }

    m_spScene = (NiNode*) kStream.GetObjectAt(0);
    NIASSERT(NiIsKindOf(NiNode, m_spScene));

    // We expect the world to have been exported with a camera, so we 
    // look for it here.
    // In order to render the scene graph, we need a camera. We're now going
    // to recurse the scene graph looking for a camera.
    if (!FindSceneCamera())
    {
        NiMessageBox("The NIF file has no camera!", "Camera Error");
        return false;
    }


	NiTObjectArray<NiCameraPtr> kCameras;
	NiTObjectArray<NiLightPtr> kLights;
	NiTObjectArray<NiNodePtr> kScenes;
	//NiStream kStream;
	//bool bSuccess = kStream.Load(
 //       NiApplication::ConvertMediaFilename("GameScene.nif"));

 //   if (!bSuccess)
 //   {
 //       NiMessageBox("WORLD.NIF file could not be loaded!", "NIF Error");
 //       return false;
 //   }

	for (unsigned int i = 0; i < kStream.GetObjectCount(); i++)
	{
		NiObject* pkObject = kStream.GetObjectAt(i);
		if (NiIsKindOf(NiCamera, pkObject))
			kCameras.Add((NiCamera*) pkObject);
		else if (NiIsKindOf(NiLight, pkObject))
			kLights.Add((NiLight*) pkObject);
		else if (NiIsKindOf(NiNode, pkObject))
			kScenes.Add((NiNode*) pkObject);
		else
		{
			// unknown object, handle it somehow
		}
	}

	//m_spScene = (NiNode*) kStream.GetObjectAt(0);
 //   NIASSERT(NiIsKindOf(NiNode, m_spScene));

    return bSuccess;
}