annotate ExplorePresetManager.h @ 14:f83635861187

rewrote sequence controller. ticks show relevant UI modes. images show for preset textures (but greenish?)
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Tue, 21 Oct 2014 16:39:39 +0100
parents af71bf84660f
children 2da0350a4aa2
rev   line source
rt300@6 1 //
rt300@6 2 // ExplorePresetManager.h
rt300@6 3 // riftathon
rt300@6 4 //
rt300@6 5 // Created by Robert Tubb on 16/10/2014.
rt300@6 6 //
rt300@6 7 // when people explore and find presets save them
rt300@6 8 // record audio
rt300@6 9 // can display images and text
rt300@6 10
rt300@6 11 //
rt300@6 12
rt300@6 13 #ifndef __riftathon__ExplorePresetManager__
rt300@6 14 #define __riftathon__ExplorePresetManager__
rt300@6 15
rt300@6 16 #include <iostream>
rt300@6 17 #include "presetManager.h"
rt300@6 18
rt300@14 19 #define MAX_PRESETS 8
rt300@6 20
rt300@6 21 class ExplorePresetManager : public PresetManager {
rt300@6 22
rt300@6 23 public:
rt300@6 24 void onAppLoad(){
rt300@6 25 // check for already saved stuff
rt300@6 26 startLoadAll();
rt300@6 27
rt300@14 28 if (thePresets.size() != MAX_PRESETS){
rt300@14 29
rt300@6 30 initPresets();
rt300@6 31 }
rt300@6 32
rt300@6 33 }
rt300@6 34 void initPresets(){
rt300@6 35
rt300@6 36 presetSlotFilename = ofFilePath::getAbsolutePath(ofToDataPath("presetSlots.json"));
rt300@6 37
rt300@14 38 // set up preset slots with names and images
rt300@6 39 Json::Value root;
rt300@6 40 Json::Reader reader;
rt300@6 41
rt300@6 42
rt300@6 43 ifstream theFile(presetSlotFilename.c_str());
rt300@6 44 stringstream fileText;
rt300@6 45 string line;
rt300@6 46 if(!theFile){
rt300@6 47 cout<<"can't find presetSlot file \n";
rt300@6 48 return;
rt300@6 49 }else{
rt300@6 50
rt300@6 51 while(theFile){
rt300@6 52 theFile >> line;
rt300@6 53 // cout << line << "\n"; // lots?
rt300@6 54 fileText << line;
rt300@6 55
rt300@6 56 }
rt300@6 57
rt300@6 58 theFile.close();
rt300@6 59 }
rt300@6 60
rt300@6 61 bool parsingSuccessful = reader.parse( fileText.str(), root );
rt300@6 62
rt300@6 63 if ( !parsingSuccessful )
rt300@6 64 {
rt300@6 65 // report to the user the failure and their locations in the document.
rt300@6 66 std::cout << "Failed to parse preset slot JSON: \n"
rt300@6 67 << reader.getFormattedErrorMessages();
rt300@6 68 return;
rt300@6 69 }
rt300@6 70
rt300@6 71 // now put into variables
rt300@6 72 const Json::Value jv = root["presetSlots"];
rt300@6 73
rt300@6 74 for ( int index = 0; index < jv.size(); ++index ){
rt300@6 75 string name = jv[index]["name"].asString();
rt300@6 76 string imageFileName = jv[index]["imageFileName"].asString();
rt300@6 77 vector<int> empty;
rt300@6 78 generatePresetSlot(name, imageFileName);
rt300@6 79 }
rt300@6 80
rt300@6 81 printAll();
rt300@6 82
rt300@6 83 filledSlots = 0;
rt300@6 84 }
rt300@6 85
rt300@6 86 //----------------------------------------------------------------------------
rt300@6 87 void presentNextPreset(){
rt300@6 88
rt300@6 89 }
rt300@10 90
rt300@10 91 Preset* getPreset(int index){
rt300@10 92
rt300@10 93 if (index >= thePresets.size()){
rt300@12 94 cout << "ERROR: index " << index << " exceeds number of presets " << thePresets.size() << endl;
rt300@10 95 return NULL;
rt300@10 96 }else{
rt300@10 97 return thePresets[index];
rt300@10 98
rt300@10 99 }
rt300@10 100 };
rt300@6 101 protected:
rt300@6 102 int filledSlots;
rt300@6 103 string presetSlotFilename;
rt300@6 104
rt300@6 105 vector<string> categories;
rt300@6 106 vector<string> names;
rt300@6 107 };
rt300@6 108
rt300@6 109 #endif /* defined(__riftathon__ExplorePresetManager__) */