Mercurial > hg > tweakathon2ios
view ExplorePresetManager.h @ 8:d59de9fd3496
Refactored messageController, ready for instroduction of other stages and tests.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Fri, 17 Oct 2014 16:35:22 +0100 |
parents | 92850a2b099c |
children | e25d2b1b185e |
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" class ExplorePresetManager : public PresetManager { public: void onAppLoad(){ // check for already saved stuff startLoadAll(); if (thePresets.size() != 16){ // if numpresets != 16 initPresets(); } } void initPresets(){ presetSlotFilename = ofFilePath::getAbsolutePath(ofToDataPath("presetSlots.json")); // set up 16 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 presentNextPreset(){ } protected: int filledSlots; string presetSlotFilename; vector<string> categories; vector<string> names; }; #endif /* defined(__riftathon__ExplorePresetManager__) */