Mercurial > hg > tweakathon2ios
view ExplorePresetManager.h @ 17:2a7320a8cbed
explore mode shows stuff, can go thru saving various presets.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Tue, 21 Oct 2014 18:58:25 +0100 |
parents | 2da0350a4aa2 |
children | 36cdb73691da |
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 goToFirstEmptySlot(){ currentPresetSlot = filledSlots + 1; } bool writeValuesToSlot(vector<int> values){ getPresetAtIndex(currentPresetSlot)->setValues(values); getPresetAtIndex(currentPresetSlot)->isFilled = true; filledSlots++; currentPresetSlot++; if(filledSlots == MAX_PRESETS){ cout << "FINISHED EXP STAGE!" << endl; return true; } return false; } Preset* getCurrentPresetSlot(){ return getPresetAtIndex(currentPresetSlot); } protected: int filledSlots; int currentPresetSlot; string presetSlotFilename; vector<string> categories; vector<string> names; }; #endif /* defined(__riftathon__ExplorePresetManager__) */