コード例 #1
0
void ofxFlashXFLBuilder :: setupStrokeForShape ( ofxFlashShape* shape )
{
	if( tagExists( "stroke", 0 ) )
	{
		pushTag( "stroke", 0 );
		
		int solidStrokeWeight;
		solidStrokeWeight = getAttribute( "SolidStroke", "weight",  0, 0 );
		
		pushTag( "SolidStroke", 0 );
		pushTag( "fill", 0 );
		
		string fillSolidColor;
		fillSolidColor = getAttribute( "SolidColor", "color", "#000000", 0 );
		fillSolidColor = cleanHexString( fillSolidColor );
		
		float fillAlpha;
		fillAlpha = getAttribute( "SolidColor", "alpha",  1.0, 0 );
		
		shape->setStroke( true );
		shape->setStrokeWeight( solidStrokeWeight );
		shape->setStrokeColor( stringToHex( fillSolidColor ) );
		shape->setStrokeAlpha( fillAlpha );
		
		ofColor c;
		
		popTag();
		popTag();
		popTag();
	}
}
コード例 #2
0
void ofxFlashXFLBuilder :: buildTimelines ()
{
	int numOfTimelines;
	numOfTimelines = getNumTags( "DOMTimeline" );
	
	for( int i=0; i<numOfTimelines; i++ )
	{
		DOMTimeline dom;
		dom.name			= getAttribute( "DOMTimeline", "name",			"", i );
		dom.currentFrame	= getAttribute( "DOMTimeline", "currentFrame",	1,  i );
		domTimeline			= dom;
		
		pushTag( "DOMTimeline", i );
		pushTag( "layers", 0 );
		
		buildLayers();
		
		popTag();
		popTag();
		
		return;		// SUPPORT ONLY ONE TIMELINE.
	}
	
	popTag();
}
コード例 #3
0
void ofxFlashXFLBuilder :: buildLayers ()
{
	int numOfLayers;
	numOfLayers = getNumTags( "DOMLayer" );
	
	for( int i=numOfLayers-1; i>=0; i-- )	// work backwards through layers. so when adding to stage, objects sit in right order.
	{
		DOMLayer dom;
		dom.name		= getAttribute( "DOMLayer", "name",			"",		i );
		dom.color		= getAttribute( "DOMLayer", "color",		0,		i );
		dom.locked		= getAttribute( "DOMLayer", "locked",		false,  i );
		dom.current		= getAttribute( "DOMLayer", "current",		false,  i );
		dom.isSelected	= getAttribute( "DOMLayer", "isSelected",	false,  i );
		dom.autoNamed	= getAttribute( "DOMLayer", "autoNamed",	false,  i );
		dom.layerType	= getAttribute( "DOMLayer", "layerType",	"",		i );
		domLayer		= dom;
		
		if( domLayer.layerType == "guide" )		// skip guide layers.
			continue;
		
		pushTag( "DOMLayer", i );
		pushTag( "frames", 0 );
		
		buildFrames();
		
		popTag();
		popTag();
	}
}
コード例 #4
0
void ofxXmlSettings::deserialize(ofAbstractParameter & parameter){
	if(!parameter.isSerializable()) return;
	string name = parameter.getEscapedName();
	if(parameter.type()==typeid(ofParameterGroup).name()){
		ofParameterGroup & group = static_cast<ofParameterGroup&>(parameter);
		if(tagExists(name)){
			pushTag(name);
			for(int i=0;i<group.size();i++){
				deserialize(group.get(i));
			}
			popTag();
		}
	}else{
		if(tagExists(name)){
			if(parameter.type()==typeid(ofParameter<int>).name()){
				parameter.cast<int>() = getValue(name,0);
			}else if(parameter.type()==typeid(ofParameter<float>).name()){
				parameter.cast<float>() = getValue(name,0.0f);
			}else if(parameter.type()==typeid(ofParameter<bool>).name()){
				parameter.cast<bool>() = getValue(name,false);
			}else if(parameter.type()==typeid(ofParameter<string>).name()){
				parameter.cast<string>() = getValue(name,"");
			}else{
				parameter.fromString(getValue(name,""));
			}
		}
	}

}
コード例 #5
0
int ofXML::getNumTags(string fullPath, ...)
{
	bool found=false;
	int ret=0;
	bool isRelative=true;
	if (fullPath[0]==';') {
		isRelative=false;
		while (prevLevel.size()>0) {
			popTag();
		}
		fullPath=string(fullPath,1,fullPath.length()-1);
	}
	vector<string> tags=ofSplitString(fullPath, ":");
	int which;
	va_list vl;
	int tagSize=tags.size();
	va_start(vl,tagSize);
	for (unsigned int i=0; i<tags.size()-1; i++) {
		which=va_arg(vl,int);
		found=pushTag(tags[i], which);
	}
	va_end(vl);
	if(found) ret=currentLevel->getNumTags(tags[tags.size()-1]);
	else ret=0;
	return ret;
}
コード例 #6
0
void ofxFlashXFLBuilder :: build ( const string& root, const string& file, ofxFlashDisplayObjectContainer* container )
{
    xflRoot = root;
	xflFile	= file;
    string xflFilePath = xflRoot + xflFile;
    
	this->container = container;
	
    bool success = loadFile( xflFilePath );
    
    if( bVerbose )
    {
        if( success )
            cout << "[ ofxFlashXFLBuilder :: build ] - loading movieclip xml - SUCCESS :: " << xflFilePath << endl;
        else
            cout << "[ ofxFlashXFLBuilder :: build ] - loading movieclip xml - FAILED  :: " << xflFilePath << endl;
    }
    
	if( success )
	{
		TiXmlElement* child = ( storedHandle.FirstChild() ).ToElement();
		domType = child->Value();
		
		pushTag( domType, 0 );
		
		if( domType == DOM_DOCUMENT_TYPE )
		{
			pushTag( "timelines", 0 );
		}
		else if( domType == DOM_SYMBOL_ITEM_TYPE )
		{
			pushTag( "timeline", 0 );
		}
		
		countTotalFrames();
		
		ofxFlashMovieClip* mc;
		mc = (ofxFlashMovieClip*)container;
		mc->setTotalFrames( totalFrames );
		
		buildTimelines();
		
		popTag();
		popTag();
	}
}
コード例 #7
0
void ofxFlashXFLBuilder :: countTotalFrames ()
{
	pushTag( "DOMTimeline", 0 );
	pushTag( "layers", 0 );
	
	int numOfLayers;
	numOfLayers = getNumTags( "DOMLayer" );
	
	for( int i=0; i<numOfLayers; i++ )
	{
		string layerType;
		layerType = getAttribute( "DOMLayer", "layerType", "", i );
		
		if( layerType == "guide" )		// skip guide layers.
			continue;
		
		pushTag( "DOMLayer", i );
		pushTag( "frames", 0 );
		
		int numOfFrames;
		numOfFrames = getNumTags( "DOMFrame" );
		
		for( int j=0; j<numOfFrames; j++ )
		{
			int frameIndex		= getAttribute( "DOMFrame", "index",	0, j );
			int frameDuration	= getAttribute( "DOMFrame", "duration",	1, j );
			int frameEnd		= frameIndex + frameDuration;
			
			if( frameEnd > totalFrames )
			{
				totalFrames = frameEnd;
			}
		}
		
		popTag();
		popTag();
	}
	
	popTag();
	popTag();
}
コード例 #8
0
void ofxFlashXFLBuilder :: buildRectangleShape ()
{
	ofxFlashShape* shape;
	shape = new ofxFlashShape();
	
	//-- position & transform.
	
	float cx = domRectangleObject.x + domRectangleObject.objectWidth  * 0.5;		// center point.
	float cy = domRectangleObject.y + domRectangleObject.objectHeight * 0.5;		// center point.
	
	float transformationPointX = cx;												// default transformation point is center.
	float transformationPointY = cy;												// default transformation point is center.
	
	if( tagExists( "transformationPoint", 0 ) )
	{
		pushTag( "transformationPoint", 0 );
		
		transformationPointX = getAttribute( "Point", "x", cx, 0 );
		transformationPointY = getAttribute( "Point", "y", cy, 0 );
		
		popTag();
	}
	
	setupMatrixForDisplayObject( shape );
	
	float shiftX = transformationPointX - cx;
	float shiftY = transformationPointY - cy;
	
	ofxFlashMatrix matrix;
	matrix = shape->matrix();				// get matrix.
	
	float tx = matrix.getTx() + shiftX;
	float ty = matrix.getTy() + shiftY;
	
	matrix.setTx( tx );						// adjust matrix.
	matrix.setTy( ty );
	
	shape->matrix( matrix );				// set matrix.
	
	ofRectangle shapeRect;
	shapeRect.x			= domRectangleObject.x + shiftX;
	shapeRect.y			= domRectangleObject.y + shiftY;
	shapeRect.width		= domRectangleObject.objectWidth;
	shapeRect.height	= domRectangleObject.objectHeight;
	
	shape->setRectangle( shapeRect.x, shapeRect.y, shapeRect.width, shapeRect.height );
	
	setupFillForShape( shape );
	setupStrokeForShape( shape );
	
	addDisplayObjectToFrames( shape );
}
コード例 #9
0
void ofxFlashXFLBuilder :: setupColorForDisplayObject ( ofxFlashDisplayObject* displayObject )
{
	if( tagExists( "color", 0 ) )
	{
		pushTag( "color", 0 );
		
		float alphaMultiplier = getAttribute( "Color", "alphaMultiplier",  1.0, 0 );
		
		displayObject->alpha( alphaMultiplier );
		
		popTag();
	}
}
コード例 #10
0
void ofxFlashXFLBuilder :: buildFrames ()
{
	int numOfFrames;
	numOfFrames = getNumTags( "DOMFrame" );
	
	for( int i=0; i<numOfFrames; i++ )
	{
		DOMFrame dom;
		dom.index			= getAttribute( "DOMFrame", "index",			0,		i );
		dom.duration		= getAttribute( "DOMFrame", "duration",			1,		i );
		dom.tweenType		= getAttribute( "DOMFrame", "tweenType",		"",		i );
		dom.motionTweenSnap	= getAttribute( "DOMFrame", "motionTweenSnap",	false,	i );
		dom.keyMode			= getAttribute( "DOMFrame", "keyMode",			0,		i );
		domFrame			= dom;
		
		pushTag( "DOMFrame", i );
		pushTag( "elements", 0 );
		
		buildElements();
		
		popTag();
		popTag();
	}
}
コード例 #11
0
void ofXML::pushToTag(ofTag * tagToFind)
{
	vector<int> ret;
	while (prevLevel.size()>0) {
		popTag();
	}
	for (unsigned int i=0; i<nodes.size(); i++) {
		if (tagToFind==&nodes[i]) pushTag(i);
		else if(nodes[i].findTag(tagToFind).size()){
			ret=nodes[i].findTag(tagToFind);
			while (ret.size()) {
				pushTag(ret[ret.size()-1]);
				ret.pop_back();
			}
		}
	}
}
コード例 #12
0
void ofxFlashXFLBuilder :: setupFillForShape ( ofxFlashShape* shape )
{
	if( tagExists( "fill", 0 ) )
	{
		pushTag( "fill", 0 );
		
		string fillSolidColor;
		fillSolidColor = getAttribute( "SolidColor", "color", "#000000", 0 );
		fillSolidColor = cleanHexString( fillSolidColor );
		
		float fillAlpha;
		fillAlpha = getAttribute( "SolidColor", "alpha",  1.0, 0 );
		
		shape->setFill( true );
		shape->setFillColor( stringToHex( fillSolidColor ) );
		shape->setFillAlpha( fillAlpha );
		
		popTag();
	}
}
コード例 #13
0
void ofxXmlSettings::serialize(const ofAbstractParameter & parameter){
	if(!parameter.isSerializable()) return;
	string name = parameter.getEscapedName();
	if(name=="") name="UnknownName";
	if(parameter.type()==typeid(ofParameterGroup).name()){
		const ofParameterGroup & group = static_cast<const ofParameterGroup&>(parameter);
		if(!tagExists(name)) addTag(name);
		pushTag(name);
		for(int i=0;i<group.size();i++){
			serialize(group.get(i));
		}
		popTag();
	}else{
		string value = parameter.toString();
		if(!tagExists(name))
			addValue(name,value);
		else
			setValue(name,value);
	}
}
コード例 #14
0
void ofxFlashXFLBuilder :: setupMatrixForDisplayObject ( ofxFlashDisplayObject* displayObject )
{
	if( tagExists( "matrix", 0 ) )
	{
		pushTag( "matrix", 0 );
		
		float a		= getAttribute( "Matrix", "a",  1.0, 0 );
		float b		= getAttribute( "Matrix", "b",  0.0, 0 );
		float c		= getAttribute( "Matrix", "c",  0.0, 0 );
		float d		= getAttribute( "Matrix", "d",  1.0, 0 );
		float tx	= getAttribute( "Matrix", "tx", 0.0, 0 );
		float ty	= getAttribute( "Matrix", "ty", 0.0, 0 );
		
		ofxFlashMatrix matrix;
		matrix.set( a, b, c, d, tx, ty );
		
		displayObject->matrix( matrix );
		
		popTag();
	}
}
コード例 #15
0
void ofXML::addValue(string label,string value)
{
	newCurrentTag(label);
	currentLevel->setValue(value);
	popTag();
}
コード例 #16
0
void ofXML::loadFile(string file)
{
	nodes.clear();
	while (prevLevel.size()) prevLevel.pop();
	currentLevel=0;
	filename=file;
	ifstream input(ofToDataPath(file).c_str());
	string buffer;
	bool tagOpen=false;
	while (input.peek()!=EOF) {
		getline(input, buffer);
		for (unsigned int i=0; i<buffer.length(); i++) {
      if(buffer[0]=='#') i=buffer.length();
			else if(!tagOpen&&buffer[i]=='<'){
				tagOpen=true;
				i++;
				try {
					if(buffer[i]=='/'){
						i++;
						string close=getWord(buffer, i, " >");
						if(!currentTag().compare(close)){
							popTag();
							i--;
						}
						else ofLog(OF_LOG_WARNING, "Tags don't match: "+close+" and " +currentTag());
					}
					else {
						string newLabel=getWord(buffer, i, " >");
						i--;
						int n=addTag(newLabel);
						pushTag(newLabel, n);
					}

				}
				catch (string except) {
					ofLog(OF_LOG_WARNING, except);
				}
			}
			else if(tagOpen){
				i=buffer.find_first_not_of(" ",i);
				if(buffer[i]=='>'){
					//writeOut();
					tagOpen=false;
				}
				else if(buffer[i]=='/'&&i<buffer.length()-1&&buffer[i+1]=='>'){
					popTag();
				}
				else {
					string aName=getWord(buffer, i, " =");
					i=buffer.find_first_not_of("=\"",i);
					string aValue=getWord(buffer, i, "\"");
					addAttribute(aName,aValue);
				}
			}
			else if(!tagOpen&&buffer[i]!='\t'&&buffer[i]!='\r'&&buffer[i]!='\n'){
				string val=getWord(buffer,i,"<");
				i--;
				currentLevel->setValue(val);
			}
		}
	}
}
コード例 #17
0
ファイル: wyBox2DPELoader.cpp プロジェクト: Adoni/WiEngine
void wyBox2DPELoader::endElement(void* ctx, const xmlChar *name) {
	wyBox2DPELoader* thiz = (wyBox2DPELoader*)ctx;
	wyParseState* state = (wyParseState*)thiz->m_parseState;

	switch(topTag(state)) {
		case TAG_DICT:
			if(state->lastKey == NULL)
				break;

			switch(state->state) {
				case State_ready:
                    state->state = State_finish;
					break;

                case State_parsingMetadata:
                case State_parsingBodies:
					state->state = State_ready;
					break;

                case State_parsingBody:
					state->state = State_parsingBodies;
					break;

                case State_parsingFixture:
					state->state = State_parsingFixtures;
                    break;
                
                case State_parsingCircle:
                    thiz->createFixturesInfo();
                    state->state = State_parsingFixture;
                    break;
                    
                default:
                    break;
			}
			break;

        case TAG_ARRAY:
            switch(state->state) {
				case State_parsingFixtures:
                    state->state = State_parsingBody;                        
					break;
                    
				case State_parsingShapes:
                    state->state = State_parsingFixture;
					break;
                    
				case State_parsingShape:
                    thiz->createFixturesInfo(); 
                    state->state = State_parsingShapes;
					break;
                default:
                    break;
			}

            break;
            
		case TAG_TRUE:
		case TAG_FALSE:

			break;
	}

	popTag(state);
}
コード例 #18
0
ファイル: html5_parser.c プロジェクト: samuellb/wwweditor
/**
 * Closes an element by tag id/name or by type. If the tag has child elements
 * the child tag at the bottom of the tree is closed.
 *
 * @returns  TRUE if a new token has been emitted.
 */
static gboolean closeOne(const gchar **html, Token *token, ParserState *state,
                         const gchar *previousPoint,
                         TokenTag tag, const gchar *tagName,
                         TagType tagType,
                         TagFilterFunction canAutoClose) {
    if (state->level == 0) return FALSE;
    
    // Check that the tag (if any) is open in the current scope
    gboolean found = FALSE;
    for (size_t level = state->level; level-- > 0; ) {
        Token *current = &state->openTags[level];
        
        // Matching tag?
        if (compareTag(tag, tagName, tagType, current)) {
            found = TRUE;
            break;
        }
        
        // Check for block or scope tags and stop there
        TagType currentType = tokenizer_getTagType(current);
        if (!canAutoClose(current->tag, currentType)) return FALSE;
    } 
    
    if (!found) return FALSE;
    
    
    // Close the tag
    Token *current = &state->openTags[state->level-1];
    
    // Matching tag?
    //fprintf(stderr, "tag %d(%s) == %d(%s)? tt:%d --> ", tag, tokenizer_tagName[tag], current->tag, tokenizer_tagName[current->tag], tagType);
    if (compareTag(tag, tagName, tagType, current)) {
        fprintf(stderr, "emit end tag (%d %d %d)\n",
            tagType & tokenizer_getTagType(current),
            (tag != Tag_None && current->tag == tag),
            (tagName &&
                g_ascii_strncasecmp(current->data, tagName, current->dataLength) &&
                current->dataLength == strlen(tagName)));
        // Not exactly what the spec says, as I understand the spec
        // it shouldn't make any difference as long as formatting
        // information is unimportant.
        
        // Emit end tag
        token->type = Token_EndTag;
        token->tag = current->tag;
        
        popTag(state);
        return TRUE;
    }
    
    /*// Check for block or scope tags and stop there
    TagType currentType = tokenizer_getTagType(current);
    fprintf(stderr, "can auto close?\n");
    if (!canAutoClose(current->tag, currentType)) return FALSE;*/
    
    // Emit end tag (will repeat until there are no more tags to close)
    token->type = Token_EndTag;
    token->tag = current->tag;
    *html = previousPoint;
    fprintf(stderr, "emit end tag (implicit)\n");
    
    popTag(state);
    return TRUE;
}
コード例 #19
0
void ofxFlashXFLBuilder :: buildElements ()
{
	int numOfElements = 0;
	TiXmlElement* child = ( storedHandle.FirstChildElement() ).ToElement();
	for( numOfElements = 0; child; child = child->NextSiblingElement(), ++numOfElements ) {}
	
	for( int i=0; i<numOfElements; i++ )
	{
		TiXmlElement* child = ( storedHandle.ChildElement( i ) ).ToElement();
		string elementTag = child->Value();
		
		if( elementTag == "DOMGroup" )
		{
			pushTagAt( i );
			pushTag( "members", 0 );
			
			buildElements();
			
			popTag();
			popTag();
			
		}
		else if( elementTag == "DOMBitmapInstance" )
		{
			DOMBitmapInstance dom;
			dom.libraryItemName = child->Attribute( "libraryItemName" );
			dom.name            = child->Attribute( "name" );
			dom.referenceID		= "";
			domBitmapInstance	= dom;
			
			pushTagAt( i );
			
			buildBitmap();
			
			popTag();
		}
		else if( elementTag == "DOMSymbolInstance" )
		{
			DOMSymbolInstance dom;
			dom.libraryItemName	= child->Attribute( "libraryItemName" );
			dom.name			= child->Attribute( "name" );
			dom.centerPoint3DX	= 0.0;
			dom.centerPoint3DY	= 0.0; 
			domSymbolInstance	= dom;
			
			pushTagAt( i );
			
			buildMovieClip();
			
			popTag();
		}
		else if( elementTag == "DOMRectangleObject" )
		{
			DOMRectangleObject dom;
			child->QueryFloatAttribute( "x",			&dom.x );
			child->QueryFloatAttribute( "y",			&dom.y );
			child->QueryFloatAttribute( "objectWidth",	&dom.objectWidth );
			child->QueryFloatAttribute( "objectHeight",	&dom.objectHeight );
			domRectangleObject = dom;
			
			pushTagAt( i );
			
			buildRectangleShape();
			
			popTag();
		}
		else if( elementTag == "DOMOvalObject" )
		{
			DOMOvalObject dom;
			child->QueryFloatAttribute( "x",			&dom.x );
			child->QueryFloatAttribute( "y",			&dom.y );
			child->QueryFloatAttribute( "objectWidth",	&dom.objectWidth );
			child->QueryFloatAttribute( "objectHeight",	&dom.objectHeight );
			child->QueryFloatAttribute( "endAngle",		&dom.endAngle );
			domOvalObject = dom;
			
			pushTagAt( i );
			
			buildOvalShape();
			
			popTag();
		}
		else if( elementTag == "DOMShape" )
		{
			continue;	// NOT SUPPORTED AT THE MOMENT.
		}
		else if( elementTag == "DOMStaticText" )
		{
			continue;	// NOT SUPPORTED AT THE MOMENT.
		}
		else if( elementTag == "DOMDynamicText" )
		{
			continue;	// NOT SUPPORTED AT THE MOMENT.
		}
		else if( elementTag == "DOMInputText" )
		{
			continue;	// NOT SUPPORTED AT THE MOMENT.
		}
	}
}