| 220 | } |
| 221 | |
| 222 | void GetRecentPlugins(std::vector<PluginDescription>& recentPlugins, int num) |
| 223 | { |
| 224 | recentPlugins.clear(); |
| 225 | juce::PluginDescription pluginDesc{}; |
| 226 | std::map<double, std::string> lastUsedTimes; |
| 227 | int i = 0; |
| 228 | |
| 229 | if (juce::File(ofToDataPath("vst/recent_plugins.json")).existsAsFile()) |
| 230 | { |
| 231 | ofxJSONElement root; |
| 232 | root.open(ofToDataPath("vst/recent_plugins.json")); |
| 233 | ofxJSONElement jsonList = root["vsts"]; |
| 234 | |
| 235 | for (auto it = jsonList.begin(); it != jsonList.end(); ++it) |
| 236 | { |
| 237 | try |
| 238 | { |
| 239 | std::string id = it.key().asString(); |
| 240 | double time = jsonList[id].asDouble(); |
| 241 | lastUsedTimes.insert(std::make_pair(time, id)); |
| 242 | } |
| 243 | catch (Json::LogicError& e) |
| 244 | { |
| 245 | TheSynth->LogEvent(__PRETTY_FUNCTION__ + std::string(" json error: ") + e.what(), kLogEventType_Error); |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | std::map<double, std::string>::reverse_iterator rit; |
| 250 | rit = lastUsedTimes.rbegin(); |
| 251 | while (rit != lastUsedTimes.rend() && ++i <= num) |
| 252 | { |
| 253 | if (GetPluginDesc(pluginDesc, juce::String(rit->second))) |
| 254 | { |
| 255 | recentPlugins.push_back(pluginDesc); |
| 256 | } |
| 257 | ++rit; |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | void SortByLastUsed(std::vector<juce::PluginDescription>& vsts) |
| 262 | { |
no test coverage detected