From e40fc849149dd97c248866a4a1d026dda5e57b62 Mon Sep 17 00:00:00 2001 From: Robert Jonsson Date: Mon, 7 Mar 2011 19:01:11 +0000 Subject: clean3 --- .../synti/zynaddsubfx/Params/PresetsStore.C | 181 +++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PresetsStore.C (limited to 'attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PresetsStore.C') diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PresetsStore.C b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PresetsStore.C new file mode 100644 index 00000000..8bbb2bec --- /dev/null +++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PresetsStore.C @@ -0,0 +1,181 @@ +/* + ZynAddSubFX - a software synthesizer + + PresetsStore.C - Presets and Clipboard store + Copyright (C) 2002-2005 Nasca Octavian Paul + Author: Nasca Octavian Paul + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License + as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License (version 2) for more details. + + You should have received a copy of the GNU General Public License (version 2) + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ +#include +#include +#include +#include + +#include "PresetsStore.h" +#include "../Misc/Util.h" + +PresetsStore presetsstore; + +PresetsStore::PresetsStore(){ + clipboard.data=NULL; + clipboard.type[0]=0; + + for (int i=0;igetXMLdata(); +}; + +bool PresetsStore::pasteclipboard(XMLwrapper *xml){ + if (clipboard.data!=NULL) xml->putXMLdata(clipboard.data); + else return(false); + return(true); +}; + +bool PresetsStore::checkclipboardtype(char *type){ + //makes LFO's compatible + if ((strstr(type,"Plfo")!=NULL)&&(strstr(clipboard.type,"Plfo")!=NULL)) return(true); + return(strcmp(type,clipboard.type)==0); +}; + +//Presets management +void PresetsStore::clearpresets(){ + for (int i=0;iname)==NULL)||((p2->name)==NULL)) return(0); + + return(strcasecmp(p1->name,p2->name)<0); +}; + + +void PresetsStore::rescanforpresets(char *type){ + clearpresets(); + int presetk=0; + char ftype[MAX_STRING_SIZE]; + snprintf(ftype,MAX_STRING_SIZE,".%s.xpz",type); + + for (int i=0;id_name; + if (strstr(filename,ftype)==NULL) continue; + + + presets[presetk].file=new char [MAX_STRING_SIZE]; + presets[presetk].name=new char [MAX_STRING_SIZE]; + char tmpc=dirname[strlen(dirname)-1]; + char *tmps="/"; + if ((tmpc=='/')||(tmpc=='\\')) tmps=""; + snprintf(presets[presetk].file,MAX_STRING_SIZE,"%s%s%s",dirname,tmps,filename); + snprintf(presets[presetk].name,MAX_STRING_SIZE,"%s",filename); + + char *tmp=strstr(presets[presetk].name,ftype); + if (tmp!=NULL) tmp[0]='\0'; + presetk++; if (presetk>=MAX_PRESETS) return; + }; + + closedir(dir); + }; + + //sort the presets + for (int j=0;j='0')&&(c<='9')) continue; + if ((c>='A')&&(c<='Z')) continue; + if ((c>='a')&&(c<='z')) continue; + if ((c=='-')||(c==' ')) continue; + tmpfilename[i]='_'; + }; + + char *dirname=config.cfg.presetsDirList[0]; + char tmpc=dirname[strlen(dirname)-1]; + char *tmps="/"; + if ((tmpc=='/')||(tmpc=='\\')) tmps=""; + + snprintf(filename,MAX_STRING_SIZE,"%s%s%s.%s.xpz",dirname,tmps,name,type); + + xml->saveXMLfile(filename); +}; + +bool PresetsStore::pastepreset(XMLwrapper *xml, int npreset){ + npreset--; + if (npreset>=MAX_PRESETS) return(false); + char *filename=presets[npreset].file; + if (filename==NULL) return(false); + bool result=(xml->loadXMLfile(filename)>=0); + return(result); +}; + +void PresetsStore::deletepreset(int npreset){ + npreset--; + if (npreset>=MAX_PRESETS) return; + char *filename=presets[npreset].file; + if (filename==NULL) return; + remove(filename); +}; + -- cgit v1.2.3