void ActionManagerEx::initWithBinary(const char* file,
                                      cocos2d::Ref *root,
                                      CocoLoader* cocoLoader,
                                      stExpCocoNode*	pCocoNode)
 {
     std::string path = file;
     ssize_t pos = path.find_last_of("/");
     std::string fileName = path.substr(pos+1,path.length());
     cocos2d::Vector<ActionObject*> actionList;
     
     stExpCocoNode *stChildArray = pCocoNode->GetChildArray(cocoLoader);
     stExpCocoNode *actionNode = nullptr;
     for (int i=0; i < pCocoNode->GetChildNum(); ++i) {
         std::string key = stChildArray[i].GetName(cocoLoader);
         if (key == "actionlist") {
             actionNode = &stChildArray[i];
             break;
         }
     }
     if (nullptr != actionNode)
     {
         int actionCount = actionNode->GetChildNum();
         for (int i = 0; i < actionCount; ++i) {
             ActionObject* action = new (std::nothrow) ActionObject();
             action->autorelease();
             
             action->initWithBinary(cocoLoader, &actionNode->GetChildArray(cocoLoader)[i], root);
             
             actionList.pushBack(action);
         }
     }
     _actionDic[fileName] = actionList;
     
 }
ActionObject* ActionManagerEx::playActionByName(const char* jsonName,const char* actionName, CallFunc* func)
{
	ActionObject* action = getActionByName(jsonName,actionName);
	if (action)
	{
		action->play(func);
	}
	return action;
}
ActionObject* ActionManagerEx::stopActionByName(const char* jsonName,const char* actionName)
{
	ActionObject* action = getActionByName(jsonName,actionName);
	if (action)
	{
		action->stop();
	}
	return action;
}
Example #4
0
BOOL CCalculator::CompareDocs(CMCPforNTDoc* pDoc1,CMCPforNTDoc* pDoc2)
{
	BOOL EQUAL = TRUE;
	CString TheObject1[100];
	CString TheObject2[100];
	USHORT	Channels1[100];
	USHORT	Channels2[100];
	USHORT i,j;

	POSITION pos;


	if(!pDoc1->ActionObjList.IsEmpty())
	{
		i=0;
		ActionObject* pActionObj = (ActionObject*)pDoc1->ActionObjList.GetHead();
		pos = pDoc1->ActionObjList.GetHeadPosition();
		do
		{
			pActionObj = (ActionObject*)pDoc1->ActionObjList.GetNext(pos);
			if (pActionObj!=NULL)
			{
				TheObject1[i]	= pActionObj->GetName();
				Channels1[i]	= pActionObj->pTrack->Channels;
				i++;
			}
		}
		while (pos!=NULL);
	}


	if(!pDoc2->ActionObjList.IsEmpty())
	{
		i=0;
		ActionObject* pActionObj = (ActionObject*)pDoc2->ActionObjList.GetHead();
		pos = pDoc2->ActionObjList.GetHeadPosition();
		do
		{
			pActionObj = (ActionObject*)pDoc2->ActionObjList.GetNext(pos);
			if (pActionObj!=NULL)
			{
				TheObject2[i]	= pActionObj->GetName();
				Channels2[i]	= pActionObj->pTrack->Channels;
				i++;
			}
		}
		while (pos!=NULL);
	}

	for(j=0;j<i;j++)
	{
		if((TheObject2[j]!=TheObject1[j])||
			(Channels2[j]!=Channels1[j]))
			EQUAL = FALSE;
	}
	return EQUAL;
}
ActionObject* ActionManager::playActionByName(const char* jsonName,const char* actionName)
{
	ActionObject* action = getActionByName(jsonName,actionName);
	if (action)
	{
		action->play();
	}
	return action;
}
void AheadChapter::delayAnimation()
{
    ActionObject  *action = ActionManager::shareManager()->getActionByName("AheadChapterUI.ExportJson", "map_animation");
    
    if (action != NULL)
    {
        EffectSoundPlayController *effectSound = EffectSoundPlayController::create();
        effectSound->setEffect(PULL_EFFECT, 0, 0, 0.5);
        this->addChild(effectSound);
        action->play();
    }
}
void AheadChapter::onEnterTransitionDidFinish()
{
    //播放动作
    ActionObject *action = ActionManager::shareManager()->getActionByName("AheadChapterUI.ExportJson", "title_panel_animation");
    
    if (action != NULL)
    {
        EffectSoundPlayController *effectSound = EffectSoundPlayController::create();
        effectSound->setEffect(DU_EFFECT, 1, 0.9, 0.1);
        this->addChild(effectSound);
        action->play();
        
    }
    
    this->scheduleOnce(schedule_selector(AheadChapter::delayAnimation), 1.2);
}
void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::Value &dic, Ref* root)
{
	std::string path = jsonName;
	ssize_t pos = path.find_last_of("/");
	std::string fileName = path.substr(pos+1,path.length());
	cocos2d::Vector<ActionObject*> actionList;
	int actionCount = DICTOOL->getArrayCount_json(dic, "actionlist");
	for (int i=0; i<actionCount; i++) {
		ActionObject* action = new (std::nothrow) ActionObject();
		action->autorelease();
		const rapidjson::Value &actionDic = DICTOOL->getDictionaryFromArray_json(dic, "actionlist", i);
		action->initWithDictionary(actionDic,root);
		actionList.pushBack(action);
	}
	_actionDic[fileName] = actionList;
}
Example #9
0
void ActionManagerEx::releaseActions()
{
    for (auto& iter : _actionDic)
    {
        cocos2d::Vector<ActionObject*> objList = iter.second;
        ssize_t listCount = objList.size();
        for (ssize_t i = 0; i < listCount; i++) {
            ActionObject* action = objList.at(i);
            if (action != nullptr) {
                action->stop();
            }
        }
        objList.clear();
    }

    _actionDic.clear();
}
ActionObject* ActionManager::getActionByName(const char* jsonName,const char* actionName)
{
	CCArray* actionList = (CCArray*)(m_pActionDic->objectForKey(jsonName));
	if (!actionList)
	{
		return NULL;
	}
	for (unsigned int i=0; i<actionList->count(); i++)
	{
		ActionObject* action = dynamic_cast<ActionObject*>(actionList->objectAtIndex(i));
		if (strcmp(actionName, action->getName()) == 0)
		{
			return action;
		}
	}
	return NULL;
}
void ActionManagerEx::releaseActions()
{
    std::unordered_map<std::string, cocos2d::Vector<ActionObject*>>::iterator iter;
    for (iter = _actionDic.begin(); iter != _actionDic.end(); iter++)
    {
        cocos2d::Vector<ActionObject*> objList = iter->second;
        ssize_t listCount = objList.size();
        for (ssize_t i = 0; i < listCount; i++) {
            ActionObject* action = objList.at(i);
            if (action != nullptr) {
                action->stop();
            }
        }
        objList.clear();
    }
    
    _actionDic.clear();
}
Example #12
0
ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char* actionName)
{
	auto iterator = _actionDic.find(jsonName);
	if (iterator == _actionDic.end())
	{
		return nullptr;
	}
	auto actionList = iterator->second;
	for (int i = 0; i < actionList.size(); i++)
	{
		ActionObject* action = actionList.at(i);
		if (strcmp(actionName, action->getName()) == 0)
		{
			return action;
		}
	}
	return nullptr;
}
void ActionManager::initWithDictionary(const char* jsonName,cs::CSJsonDictionary *dic,CCObject* root)
{
	std::string path = jsonName;
	int pos = path.find_last_of("/");
	std::string fileName = path.substr(pos+1,path.length());
	CCLOG("filename == %s",fileName.c_str());
	CCArray* actionList = CCArray::create();
	int actionCount = DICTOOL->getArrayCount_json(dic, "actionlist");
    for (int i=0; i<actionCount; i++) {
        ActionObject* action = new ActionObject();
		action->autorelease();
        cs::CSJsonDictionary* actionDic = DICTOOL->getDictionaryFromArray_json(dic, "actionlist", i);
        action->initWithDictionary(actionDic,root);
        actionList->addObject(action);
		CC_SAFE_DELETE(actionDic);
    }
	m_pActionDic->setObject(actionList, fileName);
}
ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char* actionName)
{
	std::string path = jsonName;
	ssize_t pos = path.find_last_of("/");
	std::string fileName = path.substr(pos+1,path.length());
	auto iterator = _actionDic.find(fileName);
	if (iterator == _actionDic.end())
	{
		return nullptr;
	}
	auto actionList = iterator->second;
	for (int i = 0; i < actionList.size(); i++)
	{
		ActionObject* action = actionList.at(i);
		if (strcmp(actionName, action->getName()) == 0)
		{
			return action;
		}
	}
	return nullptr;
}
Example #15
0
void CCalculator::ReCalcSum()
{
	POSITION		pos1;
	POSITION		pos2;
	POSITION		pos3;
	CMCPforNTDoc*	pDocument;
	ActionObject* pActionObj;
	ActionObject* pSummingObj;

	if(!pDoc.IsEmpty())
	{
		pos1 = pDoc.GetHeadPosition();
		do
		{
			pDocument = (CMCPforNTDoc*)pDoc.GetNext(pos1);
			if(!pDocument->ActionObjList.IsEmpty())
			{
				pActionObj = (ActionObject*)pDocument->ActionObjList.GetHead();
				pos2 = pDocument->ActionObjList.GetHeadPosition();
				pos3 = SumDoc->ActionObjList.GetHeadPosition();
				do
				{
					pActionObj	= (ActionObject*)pDocument->ActionObjList.GetNext(pos2);
					pSummingObj = (ActionObject*)SumDoc->ActionObjList.GetNext(pos3);
					pActionObj->DoSummingAction(pSummingObj);	
				}
				while (pos2!=NULL&&pos3!=NULL);
			}
		}
		while (pos1!=NULL);
	}

	pos3 = SumDoc->ActionObjList.GetHeadPosition();
	do
	{
		pSummingObj = (ActionObject*)SumDoc->ActionObjList.GetNext(pos3);
		pSummingObj->UpdateDisplay();
	}
	while (pos3!=NULL);
}
Example #16
0
double _scal( double x,... )
{
	POSITION pos;
	CString TheObject;
	double data = 0;
	BOOL FOUND = FALSE;
	double Track;
	CString TrackStr;
	va_list arg_ptr;
	va_start(arg_ptr,x);
	Track	= va_arg(arg_ptr,double);

	if(!pDocument->ActionObjList.IsEmpty())
	{
		ActionObject* pActionObj = (ActionObject*)pDocument->ActionObjList.GetHead();
		pos = pDocument->ActionObjList.GetHeadPosition();
		do
		{
			pActionObj = (ActionObject*)pDocument->ActionObjList.GetNext(pos);
			if (pActionObj!=NULL)
			{
				TheObject = pActionObj->GetName();
				if (TheObject.Find(__PM_SpectrumObj)!=-1)
				{
					PM_SpectrumObj* pScalerObj = (PM_SpectrumObj*)pActionObj;
					if ((pScalerObj->SubRegNo==(int)x)&&
						(pScalerObj->pTrack->MyPosition==(int)Track))
					{
						if(!EVALUATENEXT)data = pScalerObj->y[index];
						else data = pScalerObj->y[index]*(TheScan)/(TheScan-1);
						FOUND = TRUE;
					}
				}
			}
		}
		while ((pos!=NULL)&&(!FOUND));
	}
	return(data);
} 
Example #17
0
BOOL CCalculator::PreTranslateMessage(MSG* pMsg) 
{
	{
		if (pMsg->message == WM_LBUTTONDBLCLK)
		{
			if(pDoc.GetCount()!=0)
			{
				CMCPforNTDoc* pHeadDoc = (CMCPforNTDoc*)pDoc.GetHead();
				if (!pHeadDoc->ActionObjList.IsEmpty())
				{
					ActionObject* pActionObj = 
						(ActionObject*)m_templview.GetItemData(GetSelectedItem());
					if ((pActionObj!= NULL)&&(pActionObj->SCALER))
					{
						pActionObj->DoDoubleClickAction();
					}
				}
			}
			return TRUE;
		}
	}
	return CDialog::PreTranslateMessage(pMsg);
}
void HelloWorld::menuCloseCallback(CCObject* pSender)
{
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
//	CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
//#else
//    CCDirector::sharedDirector()->end();
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
//    exit(0);
//#endif
//#endif

	int t = g_layoutcnt%2;
	if( t == 0)
	{
		m_pLayout = dynamic_cast<UILayout *>(GUIReader::shareReader()->widgetFromJsonFile("level_select_1.json"));
		if(m_pLayout)
		{
			m_pLayout->setPosition(ccp(-200,0));
			this->addChild(m_pLayout);

			ActionObject* act = NULL;
			act = ActionManager::shareManager()->getActionByName("level_select_1.json","texiao");
			if(NULL != act)
				act->play();
			act = ActionManager::shareManager()->getActionByName("level_select_1.json","shuibodonghua");
			if(NULL != act)
				act->play();
		}
	}
	else
	{
		//ActionManager::shareManager()->stopAllActionByJson("level_select_1.json");
		//ActionManager::shareManager()->stopAllActionByJson("level_select.json");

		ActionObject* act = NULL;
		act = ActionManager::shareManager()->getActionByName("level_select_1.json","texiao");
		if(NULL != act)
			act->stop();
		act = ActionManager::shareManager()->getActionByName("level_select_1.json","shuibodonghua");
		if(NULL != act)
			act->stop();

		ActionManager::shareManager()->releaseActions();

		if(m_pLayout)
		{
			m_pLayout->removeFromParent();
			m_pLayout = NULL;
		}

		//CCTextureCache::sharedTextureCache()->removeUnusedTextures();
	}

	g_layoutcnt++;
}
Example #19
0
void CCalculator::UpdateTree(CMCPforNTDoc* pDocument)
{
	int Image;
	int	Position = 0;
	CString TheObject;
	int Track=0;
	char TheString[50];
	POSITION pos;
	m_templview.DeleteAllItems();

	if(!pDocument->ActionObjList.IsEmpty())
	{
		ActionObject* pActionObj = (ActionObject*)pDocument->ActionObjList.GetHead();
		pos = pDocument->ActionObjList.GetHeadPosition();
		do
		{
			pActionObj = (ActionObject*)pDocument->ActionObjList.GetNext(pos);
			if (pActionObj!=NULL)
			{
				if (pActionObj->GetName().Find(_TrackObj)!=-1)
				{	
					++Track;
					m_templview.InsertItem(LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM,Position,pActionObj->GetName(),0,0,2,(LPARAM)pActionObj);
					m_templview.SetItem(Position,1,LVIF_TEXT, pActionObj->GetInfo(),0,0,0,NULL);
				}
				else
				{
					if (pActionObj->TestHardware()) Image=0;
						else Image = 1;
	
					strcpy(TheString,(LPCSTR)TheObject);
					m_templview.InsertItem(LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM,Position,pActionObj->GetName(),0,0,Image,(LPARAM)pActionObj);
					m_templview.SetItem(Position,1,LVIF_TEXT, pActionObj->GetInfo(),0,0,0,NULL);
				}
				
			}
			Position++;
		}
		while (pos!=NULL);
	}
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
	m_pLayout = NULL;
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback));
    
	pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
                                origin.y + pCloseItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label
    
    //CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", TITLE_FONT_SIZE);
    //
    //// position the label on the center of the screen
    //pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
    //                        origin.y + visibleSize.height - pLabel->getContentSize().height));

    //// add the label as a child to this layer
    //this->addChild(pLabel, 1);

    //// add "HelloWorld" splash screen"
    //CCSprite* pSprite = CCSprite::create("HelloWorld.png");

    //// position the sprite on the center of the screen
    //pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

    //// add the sprite as a child to this layer
    //this->addChild(pSprite, 0);

	Layout *pLayout = dynamic_cast<UILayout *>(GUIReader::shareReader()->widgetFromJsonFile("level_select.json"));
	if(pLayout)
	{
		pLayout->setPosition(ccp(-200,0));
		this->addChild(pLayout);

		ActionObject* act = NULL;
		act = ActionManager::shareManager()->getActionByName("level_select.json","texiao");
		if(NULL != act)
			act->play();
		act = ActionManager::shareManager()->getActionByName("level_select.json","shuibodonghua");
		if(NULL != act)
			act->play();
	}
    
    return true;
}