view 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
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){

            initPresets();
        }
        
    }
    void initPresets(){

        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 presentNextPreset(){
        
    }
    
    Preset* getPreset(int index){
        
        if (index >= thePresets.size()){
            cout << "ERROR: index " << index << " exceeds number of presets " << thePresets.size() << endl;
            return NULL;
        }else{
            return thePresets[index];
            
        }
    };
protected:
    int filledSlots;
    string presetSlotFilename;
    
    vector<string> categories;
    vector<string> names;
};

#endif /* defined(__riftathon__ExplorePresetManager__) */