rt300@6: // rt300@6: // ExplorePresetManager.h rt300@6: // riftathon rt300@6: // rt300@6: // Created by Robert Tubb on 16/10/2014. rt300@6: // rt300@6: // when people explore and find presets save them rt300@6: // record audio rt300@6: // can display images and text rt300@6: rt300@6: // rt300@6: rt300@6: #ifndef __riftathon__ExplorePresetManager__ rt300@6: #define __riftathon__ExplorePresetManager__ rt300@6: rt300@6: #include rt300@6: #include "presetManager.h" rt300@6: rt300@6: rt300@6: rt300@6: class ExplorePresetManager : public PresetManager { rt300@6: rt300@6: public: rt300@6: void onAppLoad(){ rt300@6: // check for already saved stuff rt300@6: startLoadAll(); rt300@6: rt300@6: if (thePresets.size() != 16){ rt300@6: // if numpresets != 16 rt300@6: initPresets(); rt300@6: } rt300@6: rt300@6: } rt300@6: void initPresets(){ rt300@6: rt300@6: presetSlotFilename = ofFilePath::getAbsolutePath(ofToDataPath("presetSlots.json")); rt300@6: rt300@6: // set up 16 preset slots with names and images rt300@6: Json::Value root; rt300@6: Json::Reader reader; rt300@6: rt300@6: rt300@6: ifstream theFile(presetSlotFilename.c_str()); rt300@6: stringstream fileText; rt300@6: string line; rt300@6: if(!theFile){ rt300@6: cout<<"can't find presetSlot file \n"; rt300@6: return; rt300@6: }else{ rt300@6: rt300@6: while(theFile){ rt300@6: theFile >> line; rt300@6: // cout << line << "\n"; // lots? rt300@6: fileText << line; rt300@6: rt300@6: } rt300@6: rt300@6: theFile.close(); rt300@6: } rt300@6: rt300@6: bool parsingSuccessful = reader.parse( fileText.str(), root ); rt300@6: rt300@6: if ( !parsingSuccessful ) rt300@6: { rt300@6: // report to the user the failure and their locations in the document. rt300@6: std::cout << "Failed to parse preset slot JSON: \n" rt300@6: << reader.getFormattedErrorMessages(); rt300@6: return; rt300@6: } rt300@6: rt300@6: // now put into variables rt300@6: const Json::Value jv = root["presetSlots"]; rt300@6: rt300@6: for ( int index = 0; index < jv.size(); ++index ){ rt300@6: string name = jv[index]["name"].asString(); rt300@6: string imageFileName = jv[index]["imageFileName"].asString(); rt300@6: vector empty; rt300@6: generatePresetSlot(name, imageFileName); rt300@6: } rt300@6: rt300@6: printAll(); rt300@6: rt300@6: filledSlots = 0; rt300@6: } rt300@6: rt300@6: //---------------------------------------------------------------------------- rt300@6: void presentNextPreset(){ rt300@6: rt300@6: } rt300@6: protected: rt300@6: int filledSlots; rt300@6: string presetSlotFilename; rt300@6: rt300@6: vector categories; rt300@6: vector names; rt300@6: }; rt300@6: rt300@6: #endif /* defined(__riftathon__ExplorePresetManager__) */