Mercurial > hg > tweakathon2ios
diff presetManager.h @ 5:213df0baed47
presets file is updated when one is saved.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Thu, 16 Oct 2014 15:52:53 +0100 |
parents | 60b54ba87f6a |
children | 92850a2b099c |
line wrap: on
line diff
--- a/presetManager.h Thu Oct 16 14:34:14 2014 +0100 +++ b/presetManager.h Thu Oct 16 15:52:53 2014 +0100 @@ -33,11 +33,12 @@ unsigned int creatorDeviceID; // unique user device ID string name; // name of preset unsigned long long creationTime; // datetime that preset was created milliseconds - + string imageFileName; vector<int> CCValues; // the actual data + ofImage presetImage; // from save button press - Preset(vector<int> aCCValues, string aname, int aID, string un, unsigned int uid){ + Preset(vector<int> aCCValues, string aname, int aID, string un, unsigned int uid, string imageFile = ""){ CCValues = aCCValues; name = aname; @@ -49,6 +50,10 @@ cout << "Create preset sys time: " << creationTime << "\n"; //TODO color / texture? + imageFileName = imageFile; + if (imageFile != ""){ + presetImage.loadImage(imageFile); + } }; // contruct from json value Preset(Json::Value jval){ @@ -59,9 +64,10 @@ creationTime = jval["creationTime"].asLargestInt(); // dodgy? - + imageFileName = jval["imageFileName"].asString(); Json::Value JArray = jval["CCValues"]; + if(JArray.size() < 1){ cout << "No Presets"; } @@ -69,7 +75,10 @@ { CCValues.push_back(JArray[i].asInt()); } - + + if (imageFileName != ""){ + presetImage.loadImage(imageFileName); + } } @@ -98,28 +107,28 @@ //--------------------------------------------------------------------------- class PresetManager{ public: + PresetManager(); + void savePreset(string name, vector<int> stuff); + vector<int> recallPreset(int presetID); + vector<int> recallPreset(string name); + void startLoadAll(); // load everything from the json file + void exitAndSaveAll(); // save stuff to the json file + void printAll(); + void clearAll(); +protected: + string presetFileName; int nextID; int timesOpened; bool presetAlertShowing; vector<Preset *> thePresets; + + Json::Value allPresetsToJson(); + void loadPresetsFromJsonFile(const string &jsonFile); + void updatePresetFile(); + void showNameDialog(); - int savePreset(string name, vector<int> stuff); - - vector<int> recallPreset(int presetID); // by name ? id? - vector<int> recallPreset(string name); // by name ? id? - - void printAll(); - - void startLoadAll(); // load everything from the json file - void exitAndSaveAll(); // save stuff to the json file - void clearAll(); - Json::Value allPresetsToJson(); - void readJsonToPresets(const string &jsonFile); - void showNameDialog(); - PresetManager(); }; - #endif /* defined(__oscSenderExample__presetManager__) */