Mercurial > hg > tweakathon2ios
comparison presetManager.h @ 12:af71bf84660f
icon stuff. not working/tested.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Mon, 20 Oct 2014 14:12:23 +0100 |
parents | 92850a2b099c |
children | ab3e0e980c82 |
comparison
equal
deleted
inserted
replaced
11:91c3fba6e5b9 | 12:af71bf84660f |
---|---|
21 #include "ofxiPhone.h" | 21 #include "ofxiPhone.h" |
22 #include "ofxiPhoneExtras.h" | 22 #include "ofxiPhoneExtras.h" |
23 #include "eventLogger.h" | 23 #include "eventLogger.h" |
24 #include "json.h" | 24 #include "json.h" |
25 #include <ctime> | 25 #include <ctime> |
26 | 26 #include "PresetView.h" |
27 | 27 |
28 //--------------------------------------------------------------------------- | 28 //--------------------------------------------------------------------------- |
29 class Preset{ | 29 class Preset{ |
30 public: | 30 public: |
31 // important details - these saved to file (uploaded?) | 31 // important details - these saved to file (uploaded?) |
33 unsigned int creatorDeviceID; // unique user device ID | 33 unsigned int creatorDeviceID; // unique user device ID |
34 string name; // name of preset | 34 string name; // name of preset |
35 unsigned long long creationTime; // datetime that preset was created milliseconds | 35 unsigned long long creationTime; // datetime that preset was created milliseconds |
36 string imageFileName; | 36 string imageFileName; |
37 vector<int> CCValues; // the actual data | 37 vector<int> CCValues; // the actual data |
38 ofImage presetImage; | |
39 bool isFilled; | 38 bool isFilled; |
40 | 39 PresetIconView* iconView; |
41 // from save button press | 40 // from save button press |
42 Preset(vector<int> aCCValues, string aname, int aID, string un, unsigned int uid, string imageFile = ""){ | 41 Preset(vector<int> aCCValues, |
42 string aname, | |
43 int aID, | |
44 string un, | |
45 unsigned int uid, | |
46 string imageFile = ""){ | |
43 CCValues = aCCValues; | 47 CCValues = aCCValues; |
44 if (CCValues.size()){ | 48 if (CCValues.size()){ |
45 isFilled = true; | 49 isFilled = true; |
46 | 50 |
47 }else{ | 51 }else{ |
56 | 60 |
57 cout << "Create preset sys time: " << creationTime << "\n"; | 61 cout << "Create preset sys time: " << creationTime << "\n"; |
58 | 62 |
59 //TODO color / texture? | 63 //TODO color / texture? |
60 imageFileName = imageFile; | 64 imageFileName = imageFile; |
61 if (imageFile != ""){ | 65 if (imageFileName != ""){ |
62 presetImage.loadImage("Images/" + imageFile); | 66 iconView = new PresetIconView(name, imageFileName); |
63 } | 67 } |
64 | 68 |
65 }; | 69 }; |
66 // contruct from json value | 70 // contruct from json value |
67 Preset(Json::Value jval){ | 71 Preset(Json::Value jval){ |
83 { | 87 { |
84 CCValues.push_back(JArray[i].asInt()); | 88 CCValues.push_back(JArray[i].asInt()); |
85 } | 89 } |
86 | 90 |
87 if (imageFileName != ""){ | 91 if (imageFileName != ""){ |
88 presetImage.loadImage(imageFileName); | 92 iconView = new PresetIconView(name, imageFileName); |
89 } | 93 } |
90 | 94 |
95 | |
91 } | 96 } |
92 | 97 |
93 void draw(); | 98 ofImage* getImage(){ |
99 return iconView->getImage(); | |
100 } | |
94 Json::Value presetToJson(); | 101 Json::Value presetToJson(); |
95 | 102 |
96 string displayTextDescription(){ // eg: for grid hover | 103 string displayTextDescription(){ // eg: for grid hover |
97 // objC to C to C++ bleurgh | 104 // objC to C to C++ bleurgh |
98 NSDate *ocdate = [NSDate dateWithTimeIntervalSinceReferenceDate:(NSTimeInterval)(creationTime/1000.0)]; | 105 NSDate *ocdate = [NSDate dateWithTimeIntervalSinceReferenceDate:(NSTimeInterval)(creationTime/1000.0)]; |