Ejemplo n.º 1
0
void SpritePackerHelper::EnumerateSpritesForParticleEmitter(ParticleEmitter* emitter, Map<String, Sprite *> &sprites)
{
	if (!emitter)
	{
		return;
	}
	
	Vector<ParticleLayer*> & layers = emitter->GetLayers();
	int32 layersCount = layers.size();
	for (int il = 0; il < layersCount; ++il)
	{
		ParticleLayer* curLayer = layers[il];
		Sprite *sprite = curLayer->GetSprite();
		if (sprite)
		{
			sprites[sprite->GetRelativePathname().GetAbsolutePathname()] = sprite;
		}
		
		// Superemitter layers might have inner emitter with its own sprites.
		if (curLayer->GetInnerEmitter())
		{
			EnumerateSpritesForParticleEmitter(curLayer->GetInnerEmitter(), sprites);
		}
	}
}
void TextPropertyGridWidget::UpdatePushButtonWidgetWithFont(QPushButton *pushButtonWidget, Font* font)
{
    if (pushButtonWidget != this->ui->fontSelectButton)
    {
        return; //Not font select button
    }
    
    if (font)
    {
        //Set button text
        Font::eFontType fontType = font->GetFontType();
        QString buttonText;
        
        switch (fontType)
        {
            case Font::TYPE_FT:
            {
                FTFont *ftFont = static_cast<FTFont*>(font);
                //Set pushbutton widget text
				buttonText = QString::fromStdString(ftFont->GetFontPath().GetFrameworkPath());
                break;
            }
            case Font::TYPE_GRAPHICAL:
            {
                GraphicsFont *gFont = static_cast<GraphicsFont*>(font);
                //Put into result string font definition and font sprite path
                Sprite *fontSprite = gFont->GetFontSprite();
                if (!fontSprite) //If no sprite available - quit
                {
                    pushButtonWidget->setText("Graphical font is not available");
                    return;
                }
                //Get font definition and sprite relative path
                QString fontDefinitionName = QString::fromStdString(gFont->GetFontDefinitionName().GetFrameworkPath());
                QString fontSpriteName =QString::fromStdString(fontSprite->GetRelativePathname().GetFrameworkPath());
                //Set push button widget text - for grapics font it contains font definition and sprite names
                buttonText = QString("%1\n%2").arg(fontDefinitionName, fontSpriteName);
                break;
            }
            case Font::TYPE_DISTANCE:
            {
                DFFont *dfFont = static_cast<DFFont*>(font);
                //Set pushbutton widget text
				buttonText = QString::fromStdString(dfFont->GetFontPath().GetFrameworkPath());
                break;
            }
            default:
            {
                //Do nothing if we can't determine font type
                return;
            }
        }
        
        pushButtonWidget->setText(buttonText);
    }
}
QString UIButtonMetadata::GetSpriteNameForState(UIControl::eControlState state) const
{
    Sprite* sprite = GetActiveUIButton()->GetStateSprite(state);
    if (sprite == NULL)
    {
        return "<No sprite is set>";
    }

    return sprite->GetRelativePathname().c_str();
}
Ejemplo n.º 4
0
QString UIButtonMetadata::GetSpriteNameForState(UIControl::eControlState state) const
{
    Sprite* sprite = GetActiveUIButton()->GetStateSprite(state);
    if (sprite == NULL)
    {
        return StringConstants::NO_SPRITE_IS_SET;
    }

    return sprite->GetRelativePathname().c_str();
}
void UITextFieldPropertyGridWidget::UpdatePushButtonWidgetWithPropertyValue(QPushButton *pushButtonWidget, const QMetaProperty &curProperty)
{
    
    if (pushButtonWidget != this->ui->fontSelectButton)
    {
        return; //Not font select button
    }
    
    bool isPropertyValueDiffers = false;
    Font *fontPropertyValue = PropertiesHelper::GetPropertyValue<Font *>(this->activeMetadata,
                                                                         curProperty.name(), isPropertyValueDiffers);
    if (fontPropertyValue)
    {
        //Set button text
        WidgetSignalsBlocker blocker(pushButtonWidget);
        Font::eFontType fontType = fontPropertyValue->GetFontType();
        QString buttonText;
        
        switch (fontType)
        {
            case Font::TYPE_FT:
            {
                FTFont *ftFont = dynamic_cast<FTFont*>(fontPropertyValue);
                //Set pushbutton widget text
				buttonText = QString::fromStdString(ftFont->GetFontPath().GetFrameworkPath());
                break;
            }
            case Font::TYPE_GRAPHICAL:
            {
                GraphicsFont *gFont = dynamic_cast<GraphicsFont*>(fontPropertyValue);
                //Put into result string font definition and font sprite path
                Sprite *fontSprite = gFont->GetFontSprite();
                if (!fontSprite) //If no sprite available - quit
                {
                    pushButtonWidget->setText("Graphical font is not available");
                    return;
                }
                //Get font definition and sprite relative path
                QString fontDefinitionName = QString::fromStdString(gFont->GetFontDefinitionName().GetFrameworkPath());
                QString fontSpriteName =QString::fromStdString(fontSprite->GetRelativePathname().GetFrameworkPath());
                //Set push button widget text - for grapics font it contains font definition and sprite names
                buttonText = QString("%1\n%2").arg(fontDefinitionName, fontSpriteName);
                break;
            }
            default:
            {
                //Do nothing if we can't determine font type
                return;
            }
        }
        
        pushButtonWidget->setText(buttonText);
    }
}
QString ResourcesManageHelper::GetGraphicsFontPath(Font* font)
{
    if (font && (font->GetFontType() == Font::TYPE_GRAPHICAL))
    {
		GraphicsFont *gFont = dynamic_cast<GraphicsFont*>(font);
		// Get graphics font sprite if it's available
        Sprite *fontSprite = gFont->GetFontSprite();
        if (fontSprite)
        {
			// Save graphics font sprite path
        	return QString::fromStdString(fontSprite->GetRelativePathname().GetAbsolutePathname());
    	}
	}

	return QString();
}
Ejemplo n.º 7
0
void SpritePackerHelper::EnumerateSpritesForReloading(SceneData* sceneData, Map<String, Sprite *> &sprites)
{
    List<Entity*> particleEffects;
	sceneData->GetAllParticleEffects(particleEffects);
    
	for (auto it = particleEffects.begin(); it != particleEffects.end(); ++it)
	{
		Entity* curNode = (*it);
	    ParticleEffectComponent * effectComponent = cast_if_equal<ParticleEffectComponent*>(curNode->GetComponent(Component::PARTICLE_EFFECT_COMPONENT));
		
		if (!effectComponent)
		{
			continue;
		}
        
		effectComponent->Stop();
        
		// All the children of this Scene Node must have Emitter components.
		int32 emittersCount = curNode->GetChildrenCount();
		for (int32 i = 0; i < emittersCount; i ++)
		{
			Entity* childNode = curNode->GetChild(i);
			ParticleEmitter * emitter = GetEmitter(childNode);
            
			if (!emitter)
			{
				continue;
			}
			
            Vector<ParticleLayer*> & layers = emitter->GetLayers();
            int32 layersCount = layers.size();
            for (int il = 0; il < layersCount; ++il)
            {
                Sprite *sprite = layers[il]->GetSprite();
                sprites[sprite->GetRelativePathname()] = sprite;
            }
		}
        
		effectComponent->Start();
	}
}
Ejemplo n.º 8
0
EditorFontManager::DefaultFontPath EditorFontManager::GetDefaultFontPath()
{
	FilePath defFontPath;
	FilePath defFontSpritePath;

	if (defaultFont)
	{
		Font::eFontType fontType = defaultFont->GetFontType();		
        switch (fontType)
        {
            case Font::TYPE_FT:
            {
                FTFont *ftFont = dynamic_cast<FTFont*>(defaultFont);
				FilePath ftFontPath = ftFont->GetFontPath();
				// Don't save standart default font
				if (ftFontPath.GetAbsolutePathname().find(DEFAULT_FONT_NAME) == String::npos)
				{
					// Set font path
					defFontPath = ftFontPath;
				}
                break;
            }
            case Font::TYPE_GRAPHICAL:
            {
                GraphicsFont *gFont = dynamic_cast<GraphicsFont*>(defaultFont);
                // Try to get font sprite
                Sprite *fontSprite = gFont->GetFontSprite();
				// Save font only if sprite is available
                if (fontSprite)
                {
					// Set font definition and sprite relative path
					defFontPath = gFont->GetFontDefinitionName();
					defFontSpritePath = fontSprite->GetRelativePathname();
                }
				break;
            }
        }	
	}
	
	return DefaultFontPath(defFontPath, defFontSpritePath);
}
Ejemplo n.º 9
0
YamlNode * GraphicsFont::SaveToYamlNode()
{
    YamlNode *node = Font::SaveToYamlNode();

    //Type
    node->Set("type", "GraphicsFont");
    //horizontalSpacing
    node->Set("horizontalSpacing", this->GetHorizontalSpacing());
    //Sprite
    Sprite *sprite = this->fontSprite;
    if (sprite)
    {
        //Truncate sprite ".txt" extension before save
        FilePath path(sprite->GetRelativePathname());
        path.TruncateExtension();
        node->Set("sprite", path.GetAbsolutePathname());
    }
    //Font Definition
    node->Set("definition", this->GetFontDefinitionName().GetAbsolutePathname());

    return node;
}
Ejemplo n.º 10
0
void SceneSaver::CopyEmitter( ParticleEmitter *emitter, Set<String> &errorLog )
{
	sceneUtils.CopyFile(emitter->GetConfigPath(), errorLog);

	const Vector<ParticleLayer*> &layers = emitter->GetLayers();

	uint32 count = (uint32)layers.size();
	for(uint32 i = 0; i < count; ++i)
	{
		if(layers[i]->type == ParticleLayer::TYPE_SUPEREMITTER_PARTICLES)
		{
			CopyEmitter(layers[i]->GetInnerEmitter(), errorLog);
		}
		else
		{
			Sprite *sprite = layers[i]->GetSprite();
			if(!sprite) continue;

			FilePath psdPath = ReplaceInString(sprite->GetRelativePathname().GetAbsolutePathname(), "/Data/", "/DataSource/");
			psdPath.ReplaceExtension(".psd");
			sceneUtils.CopyFile(psdPath, errorLog);
		}
	}
}
Ejemplo n.º 11
0
	YamlNode * UIButton::SaveToYamlNode(UIYamlLoader * loader)
	{
		YamlNode *node = UIControl::SaveToYamlNode(loader);
		//Temp variable
		VariantType *nodeValue = new VariantType();
		String stringValue;
		
		UIButton *baseControl = new UIButton();
		
		//Control Type
		SetPreferredNodeType(node, "UIButton");
        
		//Remove values of UIControl
		//UIButton has state specific properties
		YamlNode *colorNode = node->Get("color");
		YamlNode *spriteNode = node->Get("sprite");
		YamlNode *drawTypeNode = node->Get("drawType");
		YamlNode *colorInheritNode = node->Get("colorInherit");
		YamlNode *alignNode = node->Get("align");
		YamlNode *leftRightStretchCapNode = node->Get("leftRightStretchCap");
		YamlNode *topBottomStretchCapNode = node->Get("topBottomStretchCap");
		YamlNode *spriteModificationNode = node->Get("spriteModification");
        
		if (colorNode)
		{
			node->RemoveNodeFromMap("color");
		}
		if (spriteNode)
		{
			node->RemoveNodeFromMap("sprite");
		}
		if (drawTypeNode)
		{
			node->RemoveNodeFromMap("drawType");
		}
		if (colorInheritNode)
		{
			node->RemoveNodeFromMap("colorInherit");
		}
		if (alignNode)
		{
			node->RemoveNodeFromMap("align");
		}
		if (leftRightStretchCapNode)
		{
			node->RemoveNodeFromMap("leftRightStretchCap");
		}
		if (topBottomStretchCapNode)
		{
			node->RemoveNodeFromMap("topBottomStretchCap");
		}
		if (spriteModificationNode)
		{
			node->RemoveNodeFromMap("spriteModification");
		}
        
		//States cycle for values
		for (int i = 0; i < STATE_COUNT; ++i)
		{
			//Get sprite and frame for state
			Sprite *stateSprite = this->GetStateSprite(stateArray[i]);
			int32 stateFrame = this->GetStateFrame(stateArray[i]);
			if (stateSprite)
			{
				//Create array yamlnode and add it to map
				YamlNode *spriteNode = new YamlNode(YamlNode::TYPE_ARRAY);
                
                FilePath path(stateSprite->GetRelativePathname());
                path.TruncateExtension();

                String pathname = path.GetFrameworkPath();
				spriteNode->AddValueToArray(pathname);
                
				spriteNode->AddValueToArray(stateFrame);
				int32 modification = stateBacks[BackgroundIndexForState((eButtonDrawState)i)]->GetModification();
				spriteNode->AddValueToArray(modification);
				node->AddNodeToMap(Format("stateSprite%s", statePostfix[i].c_str()), spriteNode);
			}

			//StateDrawType
			UIControlBackground::eDrawType drawType = this->GetStateDrawType(stateArray[i]);
			if (baseControl->GetStateDrawType(stateArray[i]) != drawType)
			{
				node->Set(Format("stateDrawType%s", statePostfix[i].c_str()), loader->GetDrawTypeNodeValue(drawType));
			}
			//leftRightStretchCap
			float32 leftStretchCap = this->GetActualBackground(stateArray[i])->GetLeftRightStretchCap();
			float32 baseLeftStretchCap = baseControl->GetActualBackground(stateArray[i])->GetLeftRightStretchCap();
			if (baseLeftStretchCap != leftStretchCap)
			{
				node->Set(Format("leftRightStretchCap%s", statePostfix[i].c_str()), leftStretchCap);
			}
			//topBottomStretchCap
			float32 topBottomStretchCap = this->GetActualBackground(stateArray[i])->GetTopBottomStretchCap();
			float32 baseTopBottomStretchCap = baseControl->GetActualBackground(stateArray[i])->GetTopBottomStretchCap();
			if (baseTopBottomStretchCap != topBottomStretchCap)
			{
				node->Set(Format("topBottomStretchCap%s", statePostfix[i].c_str()), topBottomStretchCap);
			}
			//State align
			int32 stateAlign = this->GetStateAlign(stateArray[i]);
			int32 baseStateAlign = baseControl->GetStateAlign(stateArray[i]);
			if (baseStateAlign != stateAlign)
			{
				node->AddNodeToMap(Format("stateAlign%s", statePostfix[i].c_str()), loader->GetAlignNodeValue(stateAlign));
			}
			//State font, state text, text color, shadow color and shadow offset
			if (this->GetStateTextControl(stateArray[i]))
			{
				Font *stateFont = this->GetStateTextControl(stateArray[i])->GetFont();
				node->Set(Format("stateFont%s", statePostfix[i].c_str()), FontManager::Instance()->GetFontName(stateFont));

				nodeValue->SetWideString(this->GetStateTextControl(stateArray[i])->GetText());
				node->Set(Format("stateText%s", statePostfix[i].c_str()), nodeValue);
				
				Color textColor = this->GetStateTextControl(stateArray[i])->GetTextColor();
				nodeValue->SetVector4(Vector4(textColor.r, textColor.g, textColor.b, textColor.a));
				node->Set(Format("stateTextcolor%s", statePostfix[i].c_str()), nodeValue);
				
				Color shadowColor = this->GetStateTextControl(stateArray[i])->GetShadowColor();
				nodeValue->SetVector4(Vector4(shadowColor.r, shadowColor.g, shadowColor.b, shadowColor.a));
				node->Set(Format("stateShadowcolor%s", statePostfix[i].c_str()), nodeValue);
				
				Vector2 shadowOffset = this->GetStateTextControl(stateArray[i])->GetShadowOffset();
				nodeValue->SetVector2(shadowOffset);
				node->Set(Format("stateShadowoffset%s", statePostfix[i].c_str()), nodeValue);
			}
			
			// State background color
			Color color = this->GetActualBackground(stateArray[i])->GetColor();
			Color baseColor =  baseControl->GetActualBackground(stateArray[i])->GetColor();
			if (baseColor != color)
			{
				Vector4 colorVector4(color.r, color.g, color.b, color.a);
				nodeValue->SetVector4(colorVector4);
				node->Set(Format("stateColor%s", statePostfix[i].c_str()), nodeValue);
			}
			
 			// State color inherittype
			UIControlBackground::eColorInheritType colorInheritType = this->GetActualBackground(stateArray[i])->GetColorInheritType();
			UIControlBackground::eColorInheritType baseColorInheritType = baseControl->GetActualBackground(stateArray[i])->GetColorInheritType();
			if (baseColorInheritType != colorInheritType)
			{
				node->Set(Format("stateColorInherit%s", statePostfix[i].c_str()), loader->GetColorInheritTypeNodeValue(colorInheritType));
			}
		}
        
		SafeDelete(nodeValue);
		SafeRelease(baseControl);
		      
		return node;
	}
Ejemplo n.º 12
0
void EditFontDialog::UpdatePushButtonWidgetWithPropertyValue(QPushButton *pushButtonWidget)//, const QMetaProperty &curProperty)
{
    Font *fontPropertyValue = NULL;
    if(pushButtonWidget == ui->fontSelectButton)
    {
        fontPropertyValue = dialogResult.font;
    }
    else if(pushButtonWidget == ui->localizedFontSelectButton)
    {
        fontPropertyValue = dialogResult.GetLocalizedFont(currentLocale);
    }
    
    Logger::FrameworkDebug("EditFontDialog::UpdatePushButtonWidgetWithPropertyValue fontPropertyValue=%p fontPresetName=%s", fontPropertyValue, dialogResult.fontPresetName.c_str());
    
    if(fontPropertyValue)
    {
        //Set button text
        Font::eFontType fontType = fontPropertyValue->GetFontType();
        QString buttonText;
        
        switch(fontType)
        {
            case Font::TYPE_FT:
            {
                FTFont *ftFont = static_cast<FTFont*>(fontPropertyValue);
                //Set pushbutton widget text
				buttonText = QString::fromStdString(ftFont->GetFontPath().GetFrameworkPath());
                break;
            }
            case Font::TYPE_GRAPHICAL:
            {
                GraphicsFont *gFont = static_cast<GraphicsFont*>(fontPropertyValue);
                //Put into result string font definition and font sprite path
                Sprite *fontSprite = gFont->GetFontSprite();
                if (!fontSprite) //If no sprite available - quit
                {
                    pushButtonWidget->setText("Graphical font is not available");
                    return;
                }
                //Get font definition and sprite relative path
                QString fontDefinitionName = QString::fromStdString(gFont->GetFontDefinitionName().GetFrameworkPath());
                QString fontSpriteName =QString::fromStdString(fontSprite->GetRelativePathname().GetFrameworkPath());
                //Set push button widget text - for grapics font it contains font definition and sprite names
                buttonText = QString("%1\n%2").arg(fontDefinitionName, fontSpriteName);
                break;
            }
            case Font::TYPE_DISTANCE:
            {
                DFFont *dfFont = static_cast<DFFont*>(fontPropertyValue);
                //Set pushbutton widget text
				buttonText = QString::fromStdString(dfFont->GetFontPath().GetFrameworkPath());
                break;
            }
            default:
            {
                //Do nothing if we can't determine font type
                return;
            }
        }
        
        Logger::FrameworkDebug("EditFontDialog::UpdatePushButtonWidgetWithPropertyValue %s", buttonText.toStdString().c_str());
        
        pushButtonWidget->setText(buttonText);
    }
}