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; }
std::string BXAtomReader::GetItemPubDate(int nItem) { return QueryItem(nItem, "updated"); }
std::string BXAtomReader::GetItemTitle(int nItem) { return QueryItem(nItem, "title"); }
std::string BXAtomReader::GetItemDesc(int nItem) { return QueryItem(nItem, "summary"); }
std::string BXRSSReader::GetItemLink(int nItem) { return QueryItem(nItem, "link"); }
std::string BXRSSReader::GetItemPubDate(int nItem) { return QueryItem(nItem, "pubDate"); }
std::string BXRSSReader::GetItemDesc(int nItem) { return QueryItem(nItem, "description"); }