| 265 | } |
| 266 | |
| 267 | void Prefab::SavePrefab(std::string savePath) |
| 268 | { |
| 269 | ofxJSONElement root; |
| 270 | |
| 271 | root["modules"] = mModuleContainer.WriteModules(); |
| 272 | |
| 273 | std::stringstream ss(root.getRawString(true)); |
| 274 | std::string line; |
| 275 | std::string lines; |
| 276 | while (getline(ss, line, '\n')) |
| 277 | { |
| 278 | const char* pos = strstr(line.c_str(), " : \"$"); |
| 279 | if (pos != nullptr) |
| 280 | { |
| 281 | bool endsWithComma = line[line.length() - 1] == ','; |
| 282 | ofStringReplace(line, pos, " : \"\""); |
| 283 | if (endsWithComma) |
| 284 | line += ","; |
| 285 | } |
| 286 | lines += line + '\n'; |
| 287 | } |
| 288 | |
| 289 | UpdatePrefabName(savePath); |
| 290 | |
| 291 | FileStreamOut out(ofToDataPath(savePath)); |
| 292 | |
| 293 | out << lines; |
| 294 | mModuleContainer.SaveState(out); |
| 295 | } |
| 296 | |
| 297 | void Prefab::LoadPrefab(std::string loadPath) |
| 298 | { |
nothing calls this directly
no test coverage detected