const char* GiCoreView::getContent() { const char* content = ""; if (saveShapes(impl->defaultStorage.storageForWrite())) { content = impl->defaultStorage.stringify(); } return content; // has't free defaultStorage's string buffer }
//-------------------------------------------------------------- void ofApp::keyPressed(int key){ switch (key){ case ' ': bLearnBakground = true; break; case '+': Settings::sWhiteThreshold ++; if (Settings::sWhiteThreshold > 255) Settings::sWhiteThreshold = 255; break; case '-': Settings::sWhiteThreshold --; if (Settings::sWhiteThreshold < 0) Settings::sWhiteThreshold = 0; break; case 's': saveShapes(); break; case 'd': mDraw = !mDraw; break; case 'g': mXmlManager.SaveSettings(); break; case OF_KEY_DOWN: mIndexShapeSelected++; mIndexShapeSelected = mIndexShapeSelected % mRecordObjects.size(); break; case OF_KEY_UP: mIndexShapeSelected--; if(mIndexShapeSelected < 0) { mIndexShapeSelected = mRecordObjects.size() - 1; } break; case OF_KEY_RIGHT: mRecordObjects[mIndexShapeSelected]->pushSoundIndex(1); break; case OF_KEY_LEFT: mRecordObjects[mIndexShapeSelected]->pushSoundIndex(-1); break; } }
bool GiCoreView::saveToFile(const char* vgfile, bool pretty) { #if defined(_MSC_VER) && _MSC_VER >= 1400 // VC8 FILE *fp = NULL; fopen_s(&fp, vgfile, "wt"); #else FILE *fp = fopen(vgfile, "wt"); #endif MgJsonStorage s; bool ret = (fp != NULL && saveShapes(s.storageForWrite()) && s.save(fp, pretty)); if (fp) { fclose(fp); } else { LOGE("Fail to open file: %s", vgfile); } return ret; }