void ChangeComplexOrigin::FixComplex(const std::string& filepath) const
{
	const Item* item = QueryItem(filepath);
	if (!item) {
		return;
	}

	Json::Value value;
	Json::Reader reader;
	std::locale::global(std::locale(""));
	std::ifstream fin(filepath.c_str());
	std::locale::global(std::locale("C"));
	reader.parse(fin, value);
	fin.close();

	for (int i = 0, n = value["sprite"].size(); i < n; ++i) 
	{
		Json::Value& spr_val = value["sprite"][i];
		sm::vec2 pos;
		if (spr_val.isMember("position")) {
			pos.x = spr_val["position"]["x"].asDouble();
			pos.y = spr_val["position"]["y"].asDouble();
		}
		pos -= item->trans;
		spr_val["position"]["x"] = pos.x;
		spr_val["position"]["y"] = pos.y;
	}

	Json::StyledStreamWriter writer;
	std::locale::global(std::locale(""));
	std::ofstream fout(filepath.c_str());
	std::locale::global(std::locale("C"));	
	writer.write(fout, value);
	fout.close();
}
bool ChangeComplexOrigin::FixLRSpr(Json::Value& val) const
{
	std::string filepath = val["filepath"].asString();
	const Item* item = QueryItem(filepath);
	if (!item) {
		return false;
	}

	sm::vec2 pos;
	if (val.isMember("position")) {
		pos.x = val["position"]["x"].asDouble();
		pos.y = val["position"]["y"].asDouble();
	}
	pos += item->trans;
	val["position"]["x"] = pos.x;
	val["position"]["y"] = pos.y;

	return true;
}
示例#3
0
std::string BXAtomReader::GetItemPubDate(int nItem) {
  return QueryItem(nItem, "updated");
}
示例#4
0
std::string BXAtomReader::GetItemTitle(int nItem) {
  return QueryItem(nItem, "title");
}
示例#5
0
std::string BXAtomReader::GetItemDesc(int nItem) {
  return QueryItem(nItem, "summary");
}
示例#6
0
std::string BXRSSReader::GetItemLink(int nItem) {
  return QueryItem(nItem, "link");
}
示例#7
0
std::string BXRSSReader::GetItemPubDate(int nItem) {
  return QueryItem(nItem, "pubDate");
}
示例#8
0
std::string BXRSSReader::GetItemDesc(int nItem) {
  return QueryItem(nItem, "description");
}