summaryrefslogtreecommitdiff
path: root/muse2/muse/instruments
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-12-14 15:08:02 +0000
committerFlorian Jung <flo@windfisch.org>2011-12-14 15:08:02 +0000
commitc36a5508aa42e596b005425208054af9a60734b4 (patch)
treefde0504e0c25b8f39ed6f5f7f7332943e4a95c7f /muse2/muse/instruments
parent42126f3b398802eb24c8d9acd2591ef4dbe7257d (diff)
pulled fixes from release into trunk
Diffstat (limited to 'muse2/muse/instruments')
-rw-r--r--muse2/muse/instruments/editinstrument.cpp50
-rw-r--r--muse2/muse/instruments/minstrument.cpp62
-rw-r--r--muse2/muse/instruments/minstrument.h8
3 files changed, 74 insertions, 46 deletions
diff --git a/muse2/muse/instruments/editinstrument.cpp b/muse2/muse/instruments/editinstrument.cpp
index 742e0626..b90b872e 100644
--- a/muse2/muse/instruments/editinstrument.cpp
+++ b/muse2/muse/instruments/editinstrument.cpp
@@ -407,27 +407,10 @@ void EditInstrument::saveAs()
if(!QDir(MusEGlobal::museUserInstruments).exists())
{
- if(QMessageBox::question(this,
- tr("MusE:"),
- tr("The user instrument directory\n%1\ndoes not exist yet. Create it now?\n").arg(MusEGlobal::museUserInstruments) +
- tr("(You can change the user instruments directory at Settings->Global Settings->Midi)"),
- QMessageBox::Ok | QMessageBox::Default,
- QMessageBox::Cancel | QMessageBox::Escape,
- Qt::NoButton) == QMessageBox::Ok)
- {
- if(QDir().mkdir(MusEGlobal::museUserInstruments))
- printf("Created user instrument directory: %s\n", MusEGlobal::museUserInstruments.toLatin1().constData());
- else
- {
- printf("Unable to create user instrument directory: %s\n", MusEGlobal::museUserInstruments.toLatin1().constData());
- QMessageBox::critical(this, tr("MusE:"), tr("Unable to create user instrument directory '%1'").arg(MusEGlobal::museUserInstruments));
- //return;
- path = MusEGlobal::museUser;
- }
- }
- else
- // return;
- path = MusEGlobal::museUser;
+ printf("MusE Error! User instrument directory: %s does not exist. Should be created at startup!\n", MusEGlobal::museUserInstruments.toLatin1().constData());
+
+ //path = MusEGlobal::museUser;
+ //path = MusEGlobal::configPath;
}
//if (instrument->filePath().isEmpty())
@@ -699,27 +682,10 @@ void EditInstrument::fileSaveAs()
if(!QDir(MusEGlobal::museUserInstruments).exists())
{
- if(QMessageBox::question(this,
- tr("MusE:"),
- tr("The user instrument directory\n%1\ndoes not exist yet. Create it now?\n").arg(MusEGlobal::museUserInstruments) +
- tr("(You can change the user instruments directory at Settings->Global Settings->Midi)"),
- QMessageBox::Ok | QMessageBox::Default,
- QMessageBox::Cancel | QMessageBox::Escape,
- Qt::NoButton) == QMessageBox::Ok)
- {
- if(QDir().mkdir(MusEGlobal::museUserInstruments))
- printf("Created user instrument directory: %s\n", MusEGlobal::museUserInstruments.toLatin1().constData());
- else
- {
- printf("Unable to create user instrument directory: %s\n", MusEGlobal::museUserInstruments.toLatin1().constData());
- QMessageBox::critical(this, tr("MusE:"), tr("Unable to create user instrument directory '%1'").arg(MusEGlobal::museUserInstruments));
- //return;
- path = MusEGlobal::museUser;
- }
- }
- else
- // return;
- path = MusEGlobal::museUser;
+ printf("MusE Error! User instrument directory: %s does not exist. Should be created at startup!\n", MusEGlobal::museUserInstruments.toLatin1().constData());
+
+ //path = MusEGlobal::museUser;
+ //path = MusEGlobal::configPath;
}
path += QString("/%1.idf").arg(so);
diff --git a/muse2/muse/instruments/minstrument.cpp b/muse2/muse/instruments/minstrument.cpp
index 8e8bb6c3..22ed3737 100644
--- a/muse2/muse/instruments/minstrument.cpp
+++ b/muse2/muse/instruments/minstrument.cpp
@@ -936,8 +936,69 @@ QString MidiInstrument::getPatchName(int channel, int prog, MType mode, bool dru
// populatePatchPopup
//---------------------------------------------------------
+void MidiInstrument::populatePatchPopup(MusEGui::PopupMenu* menu, int chan, MType songType, bool drum)
+ {
+ menu->clear();
+ int mask = 0;
+ bool drumchan = chan == 9;
+ switch (songType) {
+ case MT_XG: mask = 4; break;
+ case MT_GS: mask = 2; break;
+ case MT_GM:
+ if(drumchan)
+ {
+ int id = (0xff << 16) + (0xff << 8) + 0x00; // First patch
+ QAction* act = menu->addAction(gmdrumname);
+ //act->setCheckable(true);
+ act->setData(id);
+ return;
+ }
+ mask = 1;
+ break;
+ case MT_UNKNOWN: mask = 7; break;
+ }
+ if (pg.size() > 1) {
+ for (ciPatchGroup i = pg.begin(); i != pg.end(); ++i) {
+ PatchGroup* pgp = *i;
+ //QMenu* pm = menu->addMenu(pgp->name);
+ MusEGui::PopupMenu* pm = new MusEGui::PopupMenu(pgp->name, menu, menu->stayOpen()); // Use the parent stayOpen here.
+ menu->addMenu(pm);
+ pm->setFont(MusEGlobal::config.fonts[0]);
+ const PatchList& pl = pgp->patches;
+ for (ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) {
+ const Patch* mp = *ipl;
+ if ((mp->typ & mask) &&
+ ((drum && songType != MT_GM) ||
+ (mp->drum == drumchan)) )
+ {
+ int id = ((mp->hbank & 0xff) << 16)
+ + ((mp->lbank & 0xff) << 8) + (mp->prog & 0xff);
+ QAction* act = pm->addAction(mp->name);
+ //act->setCheckable(true);
+ act->setData(id);
+ }
+
+ }
+ }
+ }
+ else if (pg.size() == 1 ){
+ // no groups
+ const PatchList& pl = pg.front()->patches;
+ for (ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) {
+ const Patch* mp = *ipl;
+ if (mp->typ & mask) {
+ int id = ((mp->hbank & 0xff) << 16)
+ + ((mp->lbank & 0xff) << 8) + (mp->prog & 0xff);
+ QAction* act = menu->addAction(mp->name);
+ //act->setCheckable(true);
+ act->setData(id);
+ }
+ }
+ }
+
} // namespace MusECore
+/*
namespace MusEGui {
void populatePatchPopup(MusECore::MidiInstrument* midiInstrument, PopupMenu* menu, int chan, MType songType, bool drum)
@@ -1000,5 +1061,6 @@ void populatePatchPopup(MusECore::MidiInstrument* midiInstrument, PopupMenu* men
}
}
}
+*/
} // namespace MusEGui
diff --git a/muse2/muse/instruments/minstrument.h b/muse2/muse/instruments/minstrument.h
index 3a645d7f..385e67b4 100644
--- a/muse2/muse/instruments/minstrument.h
+++ b/muse2/muse/instruments/minstrument.h
@@ -143,7 +143,7 @@ class MidiInstrument {
virtual void reset(int, MType);
virtual QString getPatchName(int,int,MType,bool);
//virtual void populatePatchPopup(QMenu*, int, MType, bool);
- //virtual void populatePatchPopup(MusEGui::PopupMenu*, int, MType, bool);
+ virtual void populatePatchPopup(MusEGui::PopupMenu*, int, MType, bool);
void read(Xml&);
void write(int level, Xml&);
@@ -171,8 +171,8 @@ extern void removeMidiInstrument(const MidiInstrument* instr);
} // namespace MusECore
-namespace MusEGui {
-extern void populatePatchPopup(MusECore::MidiInstrument*, PopupMenu*, int, MType, bool);
-}
+//namespace MusEGui {
+//extern void populatePatchPopup(MusECore::MidiInstrument*, PopupMenu*, int, MType, bool);
+//}
#endif