예제 #1
0
파일: animations.cpp 프로젝트: v3ga/murmur
//--------------------------------------------------------------
void Animation::jsCallSoundChanged()
{
  if (mp_obj)
  {
	  ofxJSValue retVal;
	  ofxJSCallFunctionNameObject_NoArgs_IfExists(mp_obj, "soundsChanged", retVal);
  }
}
예제 #2
0
파일: animations.cpp 프로젝트: v3ga/murmur
//--------------------------------------------------------------
void Animation::VM_exit()
{
	ofxJSValue retVal;
	if (mp_obj){
		ofxJSCallFunctionNameObject_NoArgs_IfExists(mp_obj, "exit", retVal);
	}

	M_deleteScript();	
}
예제 #3
0
파일: animations.cpp 프로젝트: v3ga/murmur
//--------------------------------------------------------------
void Animation::VM_enter()
{
	if (M_reloadScript())
	{
		ofxJSValue retVal;
		if (mp_obj){
			ofxJSCallFunctionNameObject_NoArgs_IfExists(mp_obj, "setup", retVal);
		}
	}
}
예제 #4
0
파일: animations.cpp 프로젝트: v3ga/murmur
//--------------------------------------------------------------
void Animation::createUI()
{
    if (mp_UIcanvas)
    {
        mp_UIcanvas->addWidgetDown(new ofxUILabel(m_name, OFX_UI_FONT_LARGE));
        mp_UIcanvas->addWidgetDown(new ofxUISpacer(ANIM_UI_WIDTH_DEFAULT, 2));
    }
    
    if (mp_UIcanvas && mp_obj)
    {
        ofxJSValue retVal;
        ofxJSCallFunctionNameObject_NoArgs_IfExists(mp_obj,"createUI",retVal);
    }
 
	createUIVolumePitch();
	createUIConfiguration();
	createUIMidi();
	createUISound();
    createUICustom();

    ofAddListener(mp_UIcanvas->newGUIEvent, this, &Animation::guiEvent);
}
예제 #5
0
//--------------------------------------------------------------
void Surface::setup()
{
	OFAPPLOG->begin("Surface::setup");

    // Cpp animations
    ofxXmlSettings surfaceSettings;
	string filename = "Config/surfaces/surface"+m_id+".xml";
	
    if ( surfaceSettings.loadFile(filename.c_str()) )
    {
        surfaceSettings.pushTag("surface");
		
		int nbAnimationsTag = surfaceSettings.getNumTags("animations");
		for (int i=0;i<nbAnimationsTag;i++)
		{
			string type = surfaceSettings.getAttribute("animations", "type", "", i);
			// printf(" - type=%s\n", type.c_str());
			OFAPPLOG->println("type="+type);

			// ----------------------------------------
			// CPP
			// ----------------------------------------
			if (type == "cpp")
			{

				surfaceSettings.pushTag("animations", i);

		        int nbAnimations = surfaceSettings.getNumTags("animation");
        		//printf(" - nbAnimations=%d\n", nbAnimations);
        		OFAPPLOG->println("nbAnimations="+ofToString(nbAnimations));
				for (int j=0;j<nbAnimations;j++)
				{
            		string animName = surfaceSettings.getAttribute("animation", "name", "", j);
		            OFAPPLOG->println("  - "+animName);
			
            		if (animName != "")
					{
                		Animation* pAnimation = AnimationsFactory::create( animName );
                		if (pAnimation)
						{
							surfaceSettings.pushTag("animation", j);
							pAnimation->readSurfaceSettings(surfaceSettings);
                    		m_animationManager.M_addAnimation(pAnimation);
							surfaceSettings.popTag();
						}
					}
        		}
				surfaceSettings.popTag();
			}
			// ----------------------------------------
			// JS
			// ----------------------------------------
			else if (type == "js")
			{
				string strDirNameScripts = surfaceSettings.getAttribute("animations", "folder", "",i);
				m_strDirScripts = "Scripts/"+strDirNameScripts;

				ofDirectory dirScripts(m_strDirScripts.c_str());
				if (dirScripts.exists())
				{
					dirScripts.listDir();
					// printf("    - DIR %s [%d file(s)]\n", dirScripts.path().c_str(),dirScripts.size());
					OFAPPLOG->println("    - DIR "+dirScripts.path()+" ["+ofToString( dirScripts.size() )+" file(s)]");
					
					vector<ofFile> files = dirScripts.getFiles();
					vector<ofFile>::iterator it;
					for (it = files.begin(); it != files.end(); ++it)
					{
						if ((*it).getExtension() == "js")
						{
							Animation* pAnimation = new Animation((*it).getFileName(), (*it).getAbsolutePath());
							
							// Eval script to extract informations from it
							if (pAnimation->M_loadScript( (*it).getAbsolutePath().c_str() ))
							{
								// Theme + autoclear
								ofxJSValue retValAutoClear;
								retValAutoClear = bool_TO_ofxJSValue(true);
								
								if (pAnimation->mp_obj)
								{
									ofxJSCallFunctionNameObject_NoArgs_IfExists(pAnimation->mp_obj,"getAutoClear",	retValAutoClear);
								}
								
								bool isAutoClear = ofxJSValue_TO_bool(retValAutoClear);
								
								// printf("    - js [%s], autoclear=%s\n", (*it).getFileName().c_str(), isAutoClear ? "true" : "false");
								OFAPPLOG->println("    - js ["+(*it).getFileName()+"], autoclear="+(isAutoClear ? "true" : "false"));
								
								pAnimation->m_isAutoClear = isAutoClear;

								m_animationManager.M_addAnimation(pAnimation);
							}
						}
					}
				
				}
				dirScripts.close();
			}
			
		}

        surfaceSettings.popTag();
    }
    else
	{
        // printf("   - cannot load %s\n", "surfaceMain.xml");
		OFAPPLOG->println("cannot load 'surfaceMain.xml'");
    }

	
	// Scripts
	ofDirectory dirScripts("Scripts");
   // m_animationManager.M_readSettings(surfaceSettings);

	
	OFAPPLOG->println("setting animation index 0");
	m_animationManager.M_setAnimationDirect(0);
	
	OFAPPLOG->end();
}