Example #1
0
void TableStyle::getNamedResources(ResourceCollection& lists) const
{
	for (const BaseStyle* style = parentStyle(); style != nullptr; style = style->parentStyle())
		lists.collectCellStyle(style->name());
	lists.collectColor(fillColor());
	// TODO: Collect colors of borders.
}
Example #2
0
void CharStyle::getNamedResources(ResourceCollection& lists) const
{
	for (const Style* sty = parentStyle(); sty != NULL; sty = sty->parentStyle())
		lists.collectCharStyle(sty->name());
	lists.collectColor(fillColor());
	lists.collectColor(strokeColor());
	lists.collectFont(font().scName());
}
Example #3
0
void TableStyle::replaceNamedResources(ResourceCollection& newNames)
{
	QMap<QString, QString>::ConstIterator it;

	if (!isInhFillColor() && (it = newNames.colors().find(fillColor())) != newNames.colors().end())
		setFillColor(it.value());

	// TODO: Do we need to do something else? E.g. CharStyle calls its updateFeatures().
}
Example #4
0
void LineStyle::getNamedResources(ResourceCollection& lists) const
{
	QList<LineStyle>::const_iterator it, itend = m_Sublines.constEnd();

	lists.collectColor(color());
	for (const Style* sty = parentStyle(); sty != NULL; sty = sty->parentStyle())
		lists.collectLineStyle(sty->name());
	for (it = m_Sublines.begin(); it != itend; ++it)
		(*it).getNamedResources(lists);
}
Example #5
0
void ParagraphStyle::replaceNamedResources(ResourceCollection& newNames)
{
	QMap<QString,QString>::ConstIterator it;
	
	if (hasParent() && (it = (newNames.styles().find(parent()))) != newNames.styles().end())
	{
		setParent(it.value());
		repairImplicitCharStyleInheritance();
	}
	cstyle.replaceNamedResources(newNames);
}
Example #6
0
void LineStyle::replaceNamedResources(ResourceCollection& newNames)
{
	QMap<QString,QString>::ConstIterator it;
	QList<LineStyle>::iterator itl, itle = m_Sublines.end();

	if (!inh_Color && (it = newNames.colors().find(color())) != newNames.colors().end())
		setColor(it.value());
	if (hasParent() && (it = newNames.lineStyles().find(parent())) != newNames.lineStyles().end())
		setParent(it.value());
	for (itl = m_Sublines.begin(); itl != itle; ++itl)
		(*itl).replaceNamedResources(newNames);
}
Example #7
0
void PageItem_Group::replaceNamedResources(ResourceCollection& newNames)
{
	QMap<QString,QString>::ConstIterator it;
	
	it = newNames.colors().find(softShadowColor());
	if (it != newNames.colors().end())
		setSoftShadowColor(*it);
	
	for (int em = 0; em < groupItemList.count(); ++em)
	{
		PageItem* embedded = groupItemList.at(em);
		embedded->replaceNamedResources(newNames);
	}
}
void ParagraphStyle::getNamedResources(ResourceCollection& lists) const
{
	for (const Style *sty = parentStyle(); sty != NULL; sty = sty->parentStyle())
		lists.collectStyle(sty->name());
	charStyle().getNamedResources(lists);

	QString parEffectStyle = peCharStyleName();
	if (parEffectStyle.length() > 0)
	{
		const CharStyle *peCharStyle = dynamic_cast<const CharStyle*>(m_cstyleContext.resolve(parEffectStyle));
		if (peCharStyle)
			peCharStyle->getNamedResources(lists);
		lists.collectCharStyle(parEffectStyle);
	}
}
Example #9
0
void PageItem_Group::getNamedResources(ResourceCollection& lists) const
{
	if (hasSoftShadow())
		lists.collectColor(softShadowColor());
	
	for (int em = 0; em < groupItemList.count(); ++em)
	{
		PageItem* embedded = groupItemList.at(em);
		embedded->getNamedResources(lists);
	}
}
Example #10
0
MainMenuDebug::MainMenuDebug(int id, ResourceCollection& resources, const MainMenuState* state):
	Menu(id, resources, false),
	mState(const_cast<MainMenuState*>(state))
{
	sf::Vector2f width = sf::Vector2f((float)baseWidth, 0.0f);
	sf::Vector2f height = sf::Vector2f(0.0f, (float)baseHeight);

	sf::Texture& buttonTexture = resources.getTexture("Assets/Menu/Button.png");
	sf::Font& font = resources.getFont("Assets/Menu/24Janvier.otf");
	
	sf::Text start("PlatformState", font, 30U);
	addButton(Button(START, width / 2.0f + height / 4.0f, buttonTexture, resources, start));
	
	sf::Text puzzle("PuzzleState", font, 30U);
	addButton(Button(PUZZLE, width / 2.0f + height * (1/4.0f + 1/6.0f), buttonTexture, resources, puzzle));
	
	sf::Text settings("Toggle Fullscreen", font, 30U);
	addButton(Button(FULLSCREEN, width / 2.0f + height * (1/4.0f + 2/6.0f), buttonTexture, resources, settings));
		
	sf::Text exit("Exit", font, 30U);
	addButton(Button(EXIT, width / 2.0f + height * (1/4.0f + 3/6.0f), buttonTexture, resources, exit));
}
Example #11
0
void CharStyle::replaceNamedResources(ResourceCollection& newNames)
{
	QMap<QString,QString>::ConstIterator it;
	
	if (!inh_FillColor && (it = newNames.colors().find(fillColor())) != newNames.colors().end())
		setFillColor(it.value());
								  
	if (!inh_StrokeColor && (it = newNames.colors().find(strokeColor())) != newNames.colors().end())
		setStrokeColor(it.value());

	if (hasParent() && (it = newNames.charStyles().find(parent())) != newNames.charStyles().end())
		setParent(it.value());
	
	if (!inh_Font && (it = newNames.fonts().find(font().scName())) != newNames.fonts().end())
		setFont(newNames.availableFonts->findFont(it.value(), NULL));
	updateFeatures();
}
Example #12
0
Button::Button(int id, sf::Vector2f position, sf::Texture& texture, ResourceCollection& resources, sf::Text text, bool enabled, float textOffset, sf::IntRect textureRect):
	mText(text),
	mPosition(position),
	mSprite(texture),
	mHighlightShader(resources.getShader("Assets/Shader/Highlight.frag", sf::Shader::Type::Fragment)),
	mHighlighted(false),
	mEnabled(enabled),
	mID(id)
{
	if(textureRect != sf::IntRect()) mSprite.setTextureRect(textureRect);
	
	sf::FloatRect spriteBounds = mSprite.getLocalBounds();
	mSprite.setPosition(position - sf::Vector2f(spriteBounds.width, spriteBounds.height) / 2.0f);
	
	sf::FloatRect textBounds = mText.getLocalBounds();
	mText.setPosition(position - sf::Vector2f(textBounds.width + spriteBounds.width * textOffset, textBounds.height) / 2.0f);
}
Example #13
0
Player::Player(PlatformState& platformState, BoxWorld* world, sf::Vector2f& size, sf::Vector2f& position, ResourceCollection& resource, LightSolver* lightSolver, StatManager& stats)
: Entity(world, size, position)
, mPlatformState(platformState)
, groundCallBack(nullptr)
, leftButton(false)
, rightButton(false)
, downButton(false)
, mResource(resource)
, flashLight(lightSolver->createLight(FLASHLIGHT_SIZE.x, FLASHLIGHT_SIZE.y))
, maskRight(&resource.getTexture("Assets/Shader/mask.png"))
, maskLeft(flipTexture(maskRight))
, activeStreetLight(nullptr)
, collisionFixture(body->GetFixtureList())
, mStats(stats)
, flashLightBody(world->createEntityBody(sf::Vector2f(0.0f, 0.0f), static_cast<sf::Vector2f>(FLASHLIGHT_SIZE), false))
{
	flashLight->setColor(sf::Color(255, 255, 0, 150));
	int group = flashLight->getFilterGroup();
	group |= (1 << 8);
	flashLight->setFilterGroup(group);
	setFilterGroup(getFilterGroup() | (1 << 8));

	setState(PLAYER_STATE::NORMAL);

	/* Walking/run animation */
	auto &walking = mResource.getTexture("Assets/Characters/Stella Left.png");
	sf::Vector2i walkingSize = static_cast<sf::Vector2i>(walking.getSize());
	sf::Vector2i frameSize(256, 256);
	SpriteSheet spritesheet1(frameSize, walkingSize);
	std::vector<sf::IntRect> frames = spritesheet1.getAllFrames();
	mWalking = new Animation(frames,walking);
	
	/* Idle animation */
	auto &idle = mResource.getTexture("Assets/Characters/Stella idle.png");
	sf::Vector2i idleSize = static_cast<sf::Vector2i>(idle.getSize());
	SpriteSheet idleSheet(frameSize,idleSize);
	std::vector<sf::IntRect> idleFrames = idleSheet.getAllFrames();
	mIdle = new Animation(idleFrames,idle);
	
	/* Jump animation */
	auto &jump = mResource.getTexture("Assets/Characters/Stella jump.png");
	sf::Vector2i jumpSize = static_cast<sf::Vector2i>(jump.getSize());
	SpriteSheet jumpSheet(frameSize,jumpSize);
	std::vector<sf::IntRect> jumpFrames = jumpSheet.getAllFrames();
	mJump = new Animation(jumpFrames,jump);

	/* Grab animation */
	auto &grab = mResource.getTexture("Assets/Characters/Stella grab.png");
	sf::Vector2i grabSize = static_cast<sf::Vector2i>(grab.getSize());
	SpriteSheet grabSheet (frameSize, grabSize);
	std::vector<sf::IntRect> grabFrames = grabSheet.getAllFrames();
	mGrab = new Animation(grabFrames,grab);

	/* Fall Animation*/
	auto &fall = mResource.getTexture("Assets/Characters/Stella fall.png");
	sf::Vector2i fallSize = static_cast<sf::Vector2i>(fall.getSize());
	SpriteSheet fallSheet(frameSize, fallSize);
	std::vector<sf::IntRect> fallFrames = jumpSheet.getAllFrames();
	mFall = new Animation(fallFrames,fall);

	/* Hit Animation*/
	auto &hit = mResource.getTexture("Assets/Characters/Stella hit.png");
	sf::Vector2i hitSize = static_cast<sf::Vector2i>(hit.getSize());
	SpriteSheet hitSheet(frameSize, hitSize);
	std::vector<sf::IntRect> hitFrames = hitSheet.getAllFrames();
	mHit = new Animation(hitFrames,hit);

	anime.setAnimation(*mIdle);
	
	updateSpriteOrigin();

	mJumpSound = new sf::Sound;
	mJumpSound->setBuffer(*mResource.getSound("Assets/Sound/Jump.wav"));

	mWalkSound = new sf::Sound;
	mWalkSound->setBuffer(*mResource.getSound("Assets/Sound/Stella_Run_Loop_1.wav"));
	mWalkSound->setVolume(40);

	mHurtSound = new sf::Sound;
	mHurtSound->setBuffer(*mResource.getSound("Assets/Sound/Stella get hurt.wav"));

	setupSensors(position, size);
	body->SetLinearDamping(1.0f);
	/* Set filter for collisions */
	b2Filter filter = collisionFixture->GetFilterData();
	filter.categoryBits = PLAYER;
	//filter.maskBits =ALL, ENEMY_CHASE, ENEMY_ATTACK;
	filter.groupIndex = ALL, ENEMY_CHASE, ENEMY_ATTACK;
	collisionFixture->SetFilterData(filter);
	knockForce = 35;
	toggle = false;
}
Example #14
0
void ParagraphStyle::getNamedResources(ResourceCollection& lists) const
{
	for (const Style *sty = parentStyle(); sty != NULL; sty = sty->parentStyle())
		lists.collectStyle(sty->name());
	charStyle().getNamedResources(lists);
}
Example #15
0
void Serializer::serializeObjects(const Selection& selection, SaxHandler& outputhandler)
{
	Xml_attr attr;
	UniqueID handler( & outputhandler );
	handler.beginDoc();
	handler.begin("SCRIBUSFRAGMENT", attr);
	ScribusDoc* doc = selection.itemAt(0)->doc();
	
	
	QMap<QString,int>::Iterator itf;
	for (itf = doc->UsedFonts.begin(); itf != doc->UsedFonts.end(); ++itf)
	{
		attr["name"] = itf.key();
		handler.beginEnd("font", attr);
	}
	
	ColorList usedColors;
	doc->getUsedColors(usedColors, false);
	ColorList::Iterator itc;
	for (itc = usedColors.begin(); itc != usedColors.end(); ++itc)
	{
		Xml_attr cattr;
		cattr["name"] = itc.key();
		if (doc->PageColors[itc.key()].getColorModel() == colorModelRGB)
			cattr["RGB"] = doc->PageColors[itc.key()].nameRGB();
		else
			cattr["CMYK"] = doc->PageColors[itc.key()].nameCMYK();
		cattr["Spot"] = toXMLString(doc->PageColors[itc.key()].isSpotColor());
		cattr["Register"] = toXMLString(doc->PageColors[itc.key()].isRegistrationColor());
		handler.beginEnd("color", cattr);
	}
	
	ResourceCollection lists;
	for (int i=0; i < doc->Items->count(); ++i)
		doc->Items->at(i)->getNamedResources(lists);
	
	QList<QString>::Iterator it;
	QList<QString> names = lists.styleNames();
	for (it = names.begin(); it != names.end(); ++it)
		doc->paragraphStyles().get(*it).saxx(handler);

	names = lists.charStyleNames();
	for (it = names.begin(); it != names.end(); ++it)
		doc->charStyles().get(*it).saxx(handler);
	
	names = lists.lineStyleNames();
	for (it = names.begin(); it != names.end(); ++it)
	{
		Xml_attr multiattr;
		multiattr["Name"] = *it;
		handler.begin("MultiLine", multiattr);		
		multiLine ml = doc->MLineStyles[*it];
		
		multiLine::Iterator itMU2;
		for (itMU2 = ml.begin(); itMU2 != ml.end(); ++itMU2)
		{
			Xml_attr lineattr;
			lineattr["Color"] = (*itMU2).Color;
			lineattr["Shade"] = toXMLString((*itMU2).Shade);
			lineattr["Dash"] = toXMLString((*itMU2).Dash);
			lineattr["LineEnd"] = toXMLString((*itMU2).LineEnd);
			lineattr["LineJoin"] = toXMLString((*itMU2).LineJoin);
			lineattr["Width"] = toXMLString((*itMU2).Width);
			handler.beginEnd("SubLine", lineattr);
		}
		handler.end("MultiLine");
	}

	/*	names = lists.patterns();
	for (it = names.begin(); it != names.end(); ++it)
		doc->patterns[*it].saxx(handler);
*/
/*
	QStringList patterns = doc->getUsedPatternsSelection((Selection*)&selection);
	for (int c = 0; c < patterns.count(); ++c)
	{
		ScPattern& pa = doc->docPatterns[patterns[c]];
		Xml_attr cattr;
		cattr["Name"] = patterns[c];
		cattr["scaleX"] = toXMLString(pa.scaleX);
		cattr["scaleY"] = toXMLString(pa.scaleY);
		cattr["width"] = toXMLString(pa.width);
		cattr["height"] = toXMLString(pa.height);
		cattr["xoffset"] = toXMLString(pa.xoffset);
		cattr["yoffset"] = toXMLString(pa.yoffset);
		handler.begin("Pattern", cattr);
		for (int o = 0; o < pa.items.count(); o++)
		{
			pa.items.at(o)->saxx(handler);
		}
		handler.end("Pattern");
	}
*/
	for (int i=0; i < doc->Items->count(); ++i)
	{
		int k = selection.findItem(doc->Items->at(i));
		if (k >=0)
			doc->Items->at(i)->saxx(handler);
	}

	handler.end("SCRIBUSFRAGMENT");
	handler.endDoc();
}
void PageItem_Table::getNamedResources(ResourceCollection& lists) const
{
	TableBorder lborder = leftBorder();
	foreach (const TableBorderLine& line, lborder.borderLines())
	{
		if (line.color() == CommonStrings::None)
			continue;
		lists.collectColor(line.color());
	}

	TableBorder rborder = rightBorder();
	foreach (const TableBorderLine& line, rborder.borderLines())
	{
		if (line.color() == CommonStrings::None)
			continue;
		lists.collectColor(line.color());
	}

	TableBorder bborder = bottomBorder();
	foreach (const TableBorderLine& line, bborder.borderLines())
	{
		if (line.color() == CommonStrings::None)
			continue;
		lists.collectColor(line.color());
	}

	TableBorder tborder = topBorder();
	foreach (const TableBorderLine& line, tborder.borderLines())
	{
		if (line.color() == CommonStrings::None)
			continue;
		lists.collectColor(line.color());
	}

	QString tableStyleName = this->styleName();
	if (!tableStyleName.isEmpty())
		lists.collectTableStyle(tableStyleName);

	for (int row = 0; row < rows(); ++row)
	{
		int colSpan = 0;
		for (int col = 0; col < columns(); col += colSpan)
		{
			TableCell cell = cellAt(row, col);
			PageItem_TextFrame* textFrame = cell.textFrame();
			textFrame->getNamedResources(lists);

			QString cellStyle = cell.styleName();
			if (!cellStyle.isEmpty())
				lists.collectCellStyle(cellStyle);

			QString cellFill = cell.fillColor();
			if (cellFill != CommonStrings::None)
				lists.collectColor(cellFill);

			lborder = cell.leftBorder();
			foreach (const TableBorderLine& line, lborder.borderLines())
			{
				if (line.color() == CommonStrings::None)
					continue;
				lists.collectColor(line.color());
			}

			rborder = cell.rightBorder();
			foreach (const TableBorderLine& line, rborder.borderLines())
			{
				if (line.color() == CommonStrings::None)
					continue;
				lists.collectColor(line.color());
			}

			bborder = cell.bottomBorder();
			foreach (const TableBorderLine& line, bborder.borderLines())
			{
				if (line.color() == CommonStrings::None)
					continue;
				lists.collectColor(line.color());
			}

			tborder = cell.topBorder();
			foreach (const TableBorderLine& line, tborder.borderLines())
			{
				if (line.color() == CommonStrings::None)
					continue;
				lists.collectColor(line.color());
			}

			colSpan = cell.columnSpan();
		}
	}

	PageItem::getNamedResources(lists);
}