zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit d2ef3ac36ae840898392e8814e54985eeb689bcd
parent 6a9efbe8f317813b57e21054f9729fad8edf088a
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Thu,  8 Sep 2016 10:25:43 -0400

Config: Add Favorite Directories

Diffstat:
Msrc/Misc/Config.cpp | 47++++++++++++++++++++++++++++++++++++++++++++++-
Msrc/Misc/Config.h | 1+
2 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/src/Misc/Config.cpp b/src/Misc/Config.cpp @@ -19,7 +19,7 @@ #include <rtosc/port-sugar.h> #include "Config.h" -#include "../src/globals.h" +#include "../globals.h" #include "XMLwrapper.h" #define rStdString(name, len, ...) \ @@ -136,6 +136,37 @@ static const rtosc::Ports ports = { c.cfg.OscilSize = val; d.broadcast(d.loc, "i", (int)(log(c.cfg.OscilSize*1.0)/log(2.0))); }}, + {"add-favorite:s", rDoc("Add favorite directory"), 0, + [](const char *msg, rtosc::RtData &d) + { + Config &c = *(Config*)d.obj; + for(int i=0; i<MAX_BANK_ROOT_DIRS; ++i) { + if(c.cfg.favoriteList[i].empty()) { + c.cfg.favoriteList[i] = rtosc_argument(msg, 0).s; + return; + } + } + + }}, + {"favorites:", rProp(parameter), 0, + [](const char *msg, rtosc::RtData &d) + { + Config &c = *(Config*)d.obj; + char *argt = new char[MAX_BANK_ROOT_DIRS+1]; + rtosc_arg_t *args = new rtosc_arg_t[MAX_BANK_ROOT_DIRS]; + memset(argt, 0, MAX_BANK_ROOT_DIRS+1); + int j = 0; + for(int i=0; i<MAX_BANK_ROOT_DIRS; ++i) { + if(!c.cfg.favoriteList[i].empty()) { + argt[j] = 's'; + args[j].s = c.cfg.favoriteList[i].c_str(); + j++; + } + } + d.replyArray(d.loc, argt, args); + delete [] argt; + delete [] args; + }}, }; const rtosc::Ports &Config::ports = ::ports; #endif @@ -319,6 +350,13 @@ void Config::readConfig(const char *filename) cfg.presetsDirList[i] = xmlcfg.getparstr("presets_root", ""); xmlcfg.exitbranch(); } + + //Get favs + for(int i = 0; i < MAX_BANK_ROOT_DIRS; ++i) + if(xmlcfg.enterbranch("FAVSROOT", i)) { + cfg.favoriteList[i] = xmlcfg.getparstr("favoirtes_root", ""); + xmlcfg.exitbranch(); + } //linux stuff xmlcfg.getparstr("linux_oss_wave_out_dev", @@ -380,6 +418,13 @@ void Config::saveConfig(const char *filename) const xmlcfg->addparstr("presets_root", cfg.presetsDirList[i]); xmlcfg->endbranch(); } + + for(int i = 0; i < MAX_BANK_ROOT_DIRS; ++i) + if(!cfg.favoriteList[i].empty()) { + xmlcfg->beginbranch("FAVSROOT", i); + xmlcfg->addparstr("favoirtes_root", cfg.favoriteList[i]); + xmlcfg->endbranch(); + } xmlcfg->addpar("interpolation", cfg.Interpolation); diff --git a/src/Misc/Config.h b/src/Misc/Config.h @@ -46,6 +46,7 @@ class Config int Interpolation; std::string bankRootDirList[MAX_BANK_ROOT_DIRS], currentBankDir; std::string presetsDirList[MAX_BANK_ROOT_DIRS]; + std::string favoriteList[MAX_BANK_ROOT_DIRS]; int CheckPADsynth; int IgnoreProgramChange; int UserInterfaceMode;