Mercurial > hg > tweakathon2ios
view ExplorePresetManager.h @ 16:2da0350a4aa2
expMessageOrganiser and express/explore view setup.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Tue, 21 Oct 2014 18:06:44 +0100 |
parents | f83635861187 |
children | 2a7320a8cbed |
line wrap: on
line source
// // ExplorePresetManager.h // riftathon // // Created by Robert Tubb on 16/10/2014. // // when people explore and find presets save them // record audio // can display images and text // #ifndef __riftathon__ExplorePresetManager__ #define __riftathon__ExplorePresetManager__ #include <iostream> #include "presetManager.h" #define MAX_PRESETS 8 class ExplorePresetManager : public PresetManager { public: void onAppLoad(){ // check for already saved stuff startLoadAll(); if (thePresets.size() != MAX_PRESETS){ initPresetSlots(); } } void initPresetSlots(){ presetSlotFilename = ofFilePath::getAbsolutePath(ofToDataPath("presetSlots.json")); // set up preset slots with names and images Json::Value root; Json::Reader reader; ifstream theFile(presetSlotFilename.c_str()); stringstream fileText; string line; if(!theFile){ cout<<"can't find presetSlot file \n"; return; }else{ while(theFile){ theFile >> line; // cout << line << "\n"; // lots? fileText << line; } theFile.close(); } bool parsingSuccessful = reader.parse( fileText.str(), root ); if ( !parsingSuccessful ) { // report to the user the failure and their locations in the document. std::cout << "Failed to parse preset slot JSON: \n" << reader.getFormattedErrorMessages(); return; } // now put into variables const Json::Value jv = root["presetSlots"]; for ( int index = 0; index < jv.size(); ++index ){ string name = jv[index]["name"].asString(); string imageFileName = jv[index]["imageFileName"].asString(); vector<int> empty; generatePresetSlot(name, imageFileName); } printAll(); filledSlots = 0; } //---------------------------------------------------------------------------- void presentNextPresetSlot(){ } protected: int filledSlots; string presetSlotFilename; vector<string> categories; vector<string> names; }; #endif /* defined(__riftathon__ExplorePresetManager__) */