GUI: implement instrument preview in file dialog

SADLY it's just for the built-in file dialog
but i'll think of a solution for the external one
This commit is contained in:
tildearrow 2022-04-25 18:58:17 -05:00
parent 663e724111
commit e8c9b645c5
38 changed files with 113 additions and 85 deletions

View File

@ -3295,7 +3295,8 @@ namespace IGFD
const std::string& vFileName,
const int& vCountSelectionMax,
UserDatas vUserDatas,
ImGuiFileDialogFlags vFlags)
ImGuiFileDialogFlags vFlags,
SelectFun vSelectFun)
{
if (prFileDialogInternal.puShowDialog) // if already opened, quit
return;
@ -3306,6 +3307,7 @@ namespace IGFD
prFileDialogInternal.puDLGtitle = vTitle;
prFileDialogInternal.puDLGuserDatas = vUserDatas;
prFileDialogInternal.puDLGflags = vFlags;
prFileDialogInternal.puDLGselFun = vSelectFun;
prFileDialogInternal.puDLGoptionsPane = nullptr;
prFileDialogInternal.puDLGoptionsPaneWidth = 0.0f;
prFileDialogInternal.puDLGmodal = false;
@ -3335,7 +3337,8 @@ namespace IGFD
const std::string& vFilePathName,
const int& vCountSelectionMax,
UserDatas vUserDatas,
ImGuiFileDialogFlags vFlags)
ImGuiFileDialogFlags vFlags,
SelectFun vSelectFun)
{
if (prFileDialogInternal.puShowDialog) // if already opened, quit
return;
@ -3348,6 +3351,7 @@ namespace IGFD
prFileDialogInternal.puDLGoptionsPaneWidth = 0.0f;
prFileDialogInternal.puDLGuserDatas = vUserDatas;
prFileDialogInternal.puDLGflags = vFlags;
prFileDialogInternal.puDLGselFun = vSelectFun;
prFileDialogInternal.puDLGmodal = false;
auto ps = IGFD::Utils::ParsePathFileName(vFilePathName);
@ -3390,7 +3394,8 @@ namespace IGFD
const float& vSidePaneWidth,
const int& vCountSelectionMax,
UserDatas vUserDatas,
ImGuiFileDialogFlags vFlags)
ImGuiFileDialogFlags vFlags,
SelectFun vSelectFun)
{
if (prFileDialogInternal.puShowDialog) // if already opened, quit
return;
@ -3401,6 +3406,7 @@ namespace IGFD
prFileDialogInternal.puDLGtitle = vTitle;
prFileDialogInternal.puDLGuserDatas = vUserDatas;
prFileDialogInternal.puDLGflags = vFlags;
prFileDialogInternal.puDLGselFun = vSelectFun;
prFileDialogInternal.puDLGoptionsPane = vSidePane;
prFileDialogInternal.puDLGoptionsPaneWidth = vSidePaneWidth;
prFileDialogInternal.puDLGmodal = false;
@ -3435,7 +3441,8 @@ namespace IGFD
const float& vSidePaneWidth,
const int& vCountSelectionMax,
UserDatas vUserDatas,
ImGuiFileDialogFlags vFlags)
ImGuiFileDialogFlags vFlags,
SelectFun vSelectFun)
{
if (prFileDialogInternal.puShowDialog) // if already opened, quit
return;
@ -3448,6 +3455,7 @@ namespace IGFD
prFileDialogInternal.puDLGoptionsPaneWidth = vSidePaneWidth;
prFileDialogInternal.puDLGuserDatas = vUserDatas;
prFileDialogInternal.puDLGflags = vFlags;
prFileDialogInternal.puDLGselFun = vSelectFun;
prFileDialogInternal.puDLGmodal = false;
auto ps = IGFD::Utils::ParsePathFileName(vFilePathName);
@ -3489,7 +3497,8 @@ namespace IGFD
const std::string& vFileName,
const int& vCountSelectionMax,
UserDatas vUserDatas,
ImGuiFileDialogFlags vFlags)
ImGuiFileDialogFlags vFlags,
SelectFun vSelectFun)
{
if (prFileDialogInternal.puShowDialog) // if already opened, quit
return;
@ -3497,7 +3506,7 @@ namespace IGFD
OpenDialog(
vKey, vTitle, vFilters,
vPath, vFileName,
vCountSelectionMax, vUserDatas, vFlags);
vCountSelectionMax, vUserDatas, vFlags, vSelectFun);
prFileDialogInternal.puDLGmodal = true;
}
@ -3509,7 +3518,8 @@ namespace IGFD
const std::string& vFilePathName,
const int& vCountSelectionMax,
UserDatas vUserDatas,
ImGuiFileDialogFlags vFlags)
ImGuiFileDialogFlags vFlags,
SelectFun vSelectFun)
{
if (prFileDialogInternal.puShowDialog) // if already opened, quit
return;
@ -3517,7 +3527,7 @@ namespace IGFD
OpenDialog(
vKey, vTitle, vFilters,
vFilePathName,
vCountSelectionMax, vUserDatas, vFlags);
vCountSelectionMax, vUserDatas, vFlags, vSelectFun);
prFileDialogInternal.puDLGmodal = true;
}
@ -3534,7 +3544,8 @@ namespace IGFD
const float& vSidePaneWidth,
const int& vCountSelectionMax,
UserDatas vUserDatas,
ImGuiFileDialogFlags vFlags)
ImGuiFileDialogFlags vFlags,
SelectFun vSelectFun)
{
if (prFileDialogInternal.puShowDialog) // if already opened, quit
return;
@ -3543,7 +3554,7 @@ namespace IGFD
vKey, vTitle, vFilters,
vPath, vFileName,
vSidePane, vSidePaneWidth,
vCountSelectionMax, vUserDatas, vFlags);
vCountSelectionMax, vUserDatas, vFlags, vSelectFun);
prFileDialogInternal.puDLGmodal = true;
}
@ -3559,7 +3570,8 @@ namespace IGFD
const float& vSidePaneWidth,
const int& vCountSelectionMax,
UserDatas vUserDatas,
ImGuiFileDialogFlags vFlags)
ImGuiFileDialogFlags vFlags,
SelectFun vSelectFun)
{
if (prFileDialogInternal.puShowDialog) // if already opened, quit
return;
@ -3568,7 +3580,7 @@ namespace IGFD
vKey, vTitle, vFilters,
vFilePathName,
vSidePane, vSidePaneWidth,
vCountSelectionMax, vUserDatas, vFlags);
vCountSelectionMax, vUserDatas, vFlags, vSelectFun);
prFileDialogInternal.puDLGmodal = true;
}
@ -3940,6 +3952,9 @@ namespace IGFD
return 2;
} else {
fdi.SelectFileName(prFileDialogInternal, vInfos);
if (prFileDialogInternal.puDLGselFun!=NULL) {
prFileDialogInternal.puDLGselFun(GetFilePathName().c_str());
}
}
}
}

View File

@ -1080,6 +1080,7 @@ namespace IGFD
typedef void* UserDatas;
typedef std::function<void(const char*, UserDatas, bool*)> PaneFun; // side pane function binding
typedef std::function<void(const char*)> SelectFun; // click on file function binding
class FileDialogInternal
{
public:
@ -1103,6 +1104,7 @@ namespace IGFD
ImGuiFileDialogFlags puDLGflags = ImGuiFileDialogFlags_None;
UserDatas puDLGuserDatas = nullptr;
PaneFun puDLGoptionsPane = nullptr;
SelectFun puDLGselFun = nullptr;
float puDLGoptionsPaneWidth = 0.0f;
bool puDLGmodal = false;
bool puNeedToExitDialog = false;
@ -1155,7 +1157,8 @@ namespace IGFD
const std::string& vFileName, // defaut file name
const int& vCountSelectionMax = 1, // count selection max
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane)
ImGuiFileDialogFlags vFlags = 0); // ImGuiFileDialogFlags
ImGuiFileDialogFlags vFlags = 0, // ImGuiFileDialogFlags
SelectFun vSelectFun = nullptr); // function to be called on file click
void OpenDialog( // open simple dialog (path and filename are obtained from filePathName)
const std::string& vKey, // key dialog
@ -1164,7 +1167,8 @@ namespace IGFD
const std::string& vFilePathName, // file path name (will be decompsoed in path and fileName)
const int& vCountSelectionMax = 1, // count selection max
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane)
ImGuiFileDialogFlags vFlags = 0); // ImGuiFileDialogFlags
ImGuiFileDialogFlags vFlags = 0, // ImGuiFileDialogFlags
SelectFun vSelectFun = nullptr); // function to be called on file click
// with pane
void OpenDialog( // open dialog with custom right pane (path and fileName can be specified)
@ -1177,7 +1181,8 @@ namespace IGFD
const float& vSidePaneWidth = 250.0f, // side pane width
const int& vCountSelectionMax = 1, // count selection max
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane)
ImGuiFileDialogFlags vFlags = 0); // ImGuiFileDialogFlags
ImGuiFileDialogFlags vFlags = 0, // ImGuiFileDialogFlags
SelectFun vSelectFun = nullptr); // function to be called on file click
void OpenDialog( // open dialog with custom right pane (path and filename are obtained from filePathName)
const std::string& vKey, // key dialog
@ -1188,7 +1193,8 @@ namespace IGFD
const float& vSidePaneWidth = 250.0f, // side pane width
const int& vCountSelectionMax = 1, // count selection max
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane)
ImGuiFileDialogFlags vFlags = 0); // ImGuiFileDialogFlags
ImGuiFileDialogFlags vFlags = 0, // ImGuiFileDialogFlags
SelectFun vSelectFun = nullptr); // function to be called on file click
// modal dialog
void OpenModal( // open simple modal (path and fileName can be specified)
@ -1199,7 +1205,8 @@ namespace IGFD
const std::string& vFileName, // defaut file name
const int& vCountSelectionMax = 1, // count selection max
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane)
ImGuiFileDialogFlags vFlags = 0); // ImGuiFileDialogFlags
ImGuiFileDialogFlags vFlags = 0, // ImGuiFileDialogFlags
SelectFun vSelectFun = nullptr); // function to be called on file click
void OpenModal( // open simple modal (path and fielname are obtained from filePathName)
const std::string& vKey, // key dialog
@ -1208,7 +1215,8 @@ namespace IGFD
const std::string& vFilePathName, // file path name (will be decompsoed in path and fileName)
const int& vCountSelectionMax = 1, // count selection max
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane)
ImGuiFileDialogFlags vFlags = 0); // ImGuiFileDialogFlags
ImGuiFileDialogFlags vFlags = 0, // ImGuiFileDialogFlags
SelectFun vSelectFun = nullptr); // function to be called on file click
// with pane
void OpenModal( // open modal with custom right pane (path and filename are obtained from filePathName)
@ -1221,7 +1229,8 @@ namespace IGFD
const float& vSidePaneWidth = 250.0f, // side pane width
const int& vCountSelectionMax = 1, // count selection max
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane)
ImGuiFileDialogFlags vFlags = 0); // ImGuiFileDialogFlags
ImGuiFileDialogFlags vFlags = 0, // ImGuiFileDialogFlags
SelectFun vSelectFun = nullptr); // function to be called on file click
void OpenModal( // open modal with custom right pane (path and fielname are obtained from filePathName)
const std::string& vKey, // key dialog
@ -1232,7 +1241,8 @@ namespace IGFD
const float& vSidePaneWidth = 250.0f, // side pane width
const int& vCountSelectionMax = 1, // count selection max
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane)
ImGuiFileDialogFlags vFlags = 0); // ImGuiFileDialogFlags
ImGuiFileDialogFlags vFlags = 0, // ImGuiFileDialogFlags
SelectFun vSelectFun = nullptr); // function to be called on file click
// Display / Close dialog form
bool Display( // Display the dialog. return true if a result was obtained (Ok or not)

View File

@ -739,7 +739,9 @@ String DivEngine::getWarnings() {
}
DivInstrument* DivEngine::getIns(int index, DivInstrumentType fallbackType) {
if (index==-2 && tempIns!=NULL) return tempIns;
if (index==-2 && tempIns!=NULL) {
return tempIns;
}
if (index<0 || index>=song.insLen) {
switch (fallbackType) {
case DIV_INS_OPLL:
@ -2027,7 +2029,7 @@ void DivEngine::autoNoteOn(int ch, int ins, int note, int vol) {
}
do {
if ((ins<0 || ins>=song.insLen || getChannelType(finalChan)==4 || getPreferInsType(finalChan)==getIns(ins)->type || getIns(ins)->type==DIV_INS_AMIGA) && chan[finalChan].midiNote==-1) {
if ((ins==-1 || ins>=song.insLen || getChannelType(finalChan)==4 || getPreferInsType(finalChan)==getIns(ins)->type || getIns(ins)->type==DIV_INS_AMIGA) && chan[finalChan].midiNote==-1) {
chan[finalChan].midiNote=note;
pendingNotes.push(DivNoteEvent(finalChan,ins,note,vol,true));
break;

View File

@ -34,7 +34,7 @@ class DivPlatformAmiga: public DivDispatch {
int audSub;
signed char audDat;
int sample, wave;
unsigned char ins;
int ins;
int busClock;
int note;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, useWave, setPos, useV, useP;

View File

@ -37,7 +37,7 @@ class DivPlatformArcade: public DivDispatch {
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins;
int ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, portaPause, furnacePCM, hardReset;
int vol, outVol;

View File

@ -33,7 +33,8 @@ class DivPlatformAY8910: public DivDispatch {
struct Channel {
unsigned char freqH, freqL;
int freq, baseFreq, note, pitch;
unsigned char ins, psgMode, autoEnvNum, autoEnvDen;
int ins;
unsigned char psgMode, autoEnvNum, autoEnvDen;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
int vol, outVol;

View File

@ -29,7 +29,8 @@ class DivPlatformAY8930: public DivDispatch {
struct Channel {
unsigned char freqH, freqL;
int freq, baseFreq, note, pitch;
unsigned char ins, psgMode, autoEnvNum, autoEnvDen, duty;
int ins;
unsigned char psgMode, autoEnvNum, autoEnvDen, duty;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
int vol, outVol;

View File

@ -28,8 +28,7 @@
class DivPlatformBubSysWSG: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins;
int freq, baseFreq, pitch, note, ins;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
signed char vol, outVol, wave;
signed char waveROM[32] = {0}; // 4 bit PROM per channel on bubble system

View File

@ -26,8 +26,8 @@
class DivPlatformC64: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, prevFreq, testWhen, note;
unsigned char ins, sweep, wave, attack, decay, sustain, release;
int freq, baseFreq, pitch, prevFreq, testWhen, note, ins;
unsigned char sweep, wave, attack, decay, sustain, release;
short duty;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, filter;
bool resetMask, resetFilter, resetDuty, ring, sync;

View File

@ -26,8 +26,8 @@
class DivPlatformFDS: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, prevFreq, note, modFreq;
unsigned char ins, duty, sweep, modDepth, modPos;
int freq, baseFreq, pitch, prevFreq, note, modFreq, ins;
unsigned char duty, sweep, modDepth, modPos;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, modOn;
signed char vol, outVol, wave;
signed char modTable[32];

View File

@ -27,8 +27,8 @@
class DivPlatformGB: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins, duty, sweep;
int freq, baseFreq, pitch, note, ins;
unsigned char duty, sweep;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta;
signed char vol, outVol, wave;
DivMacroInt std;

View File

@ -37,7 +37,7 @@ class DivPlatformGenesis: public DivDispatch {
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, portaPauseFreq, note;
unsigned char ins;
int ins;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnaceDac, inPorta, hardReset;
int vol, outVol;
unsigned char pan;

View File

@ -25,8 +25,7 @@ class DivPlatformGenesisExt: public DivPlatformGenesis {
struct OpChannel {
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, portaPauseFreq;
unsigned char ins;
int freq, baseFreq, pitch, portaPauseFreq, ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause;
int vol;

View File

@ -44,8 +44,8 @@ class DivPlatformLynx: public DivDispatch {
DivMacroInt std;
MikeyFreqDiv fd;
MikeyDuty duty;
int baseFreq, pitch, note, actualNote, lfsr;
unsigned char ins, pan;
int baseFreq, pitch, note, actualNote, lfsr, ins;
unsigned char pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
signed char vol, outVol;
Channel():

View File

@ -25,8 +25,8 @@
class DivPlatformMMC5: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, prevFreq, note;
unsigned char ins, duty, sweep;
int freq, baseFreq, pitch, prevFreq, note, ins;
unsigned char duty, sweep;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, furnaceDac;
signed char vol, outVol, wave;
DivMacroInt std;

View File

@ -25,8 +25,8 @@
class DivPlatformNES: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, prevFreq, note;
unsigned char ins, duty, sweep;
int freq, baseFreq, pitch, prevFreq, note, ins;
unsigned char duty, sweep;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, furnaceDac;
signed char vol, outVol, wave;
DivMacroInt std;

View File

@ -30,8 +30,7 @@ class DivPlatformOPL: public DivDispatch {
DivInstrumentFM state;
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins;
int freq, baseFreq, pitch, note, ins;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnaceDac, inPorta, fourOp;
int vol, outVol;
unsigned char pan;

View File

@ -33,8 +33,7 @@ class DivPlatformOPLL: public DivDispatch {
DivInstrumentFM state;
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins;
int freq, baseFreq, pitch, note, ins;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnaceDac, inPorta;
int vol, outVol;
unsigned char pan;

View File

@ -31,8 +31,8 @@ class DivPlatformPCE: public DivDispatch {
int freq, baseFreq, pitch, note;
int dacPeriod, dacRate;
unsigned int dacPos;
int dacSample;
unsigned char ins, pan;
int dacSample, ins;
unsigned char pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, noise, pcm, furnaceDac;
signed char vol, outVol, wave;
DivMacroInt std;

View File

@ -25,8 +25,8 @@
class DivPlatformPCSpeaker: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins, duty, sweep;
int freq, baseFreq, pitch, note, ins;
unsigned char duty, sweep;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, furnaceDac;
signed char vol, outVol, wave;
DivMacroInt std;

View File

@ -25,8 +25,7 @@
class DivPlatformPET: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins;
int freq, baseFreq, pitch, note, ins;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
int vol, outVol, wave;
unsigned char sreg;

View File

@ -30,8 +30,7 @@ class DivPlatformQSound: public DivDispatch {
int freq, baseFreq, pitch;
unsigned short audLen;
unsigned int audPos;
int sample, wave;
unsigned char ins;
int sample, wave, ins;
int note;
int panning;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, useWave;

View File

@ -35,8 +35,8 @@ class DivPlatformSAA1099: public DivDispatch {
protected:
struct Channel {
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins, psgMode;
int freq, baseFreq, pitch, note, ins;
unsigned char psgMode;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
int vol, outVol;

View File

@ -29,8 +29,7 @@ class DivPlatformSegaPCM: public DivDispatch {
struct Channel {
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins;
int freq, baseFreq, pitch, note, ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, portaPause, furnacePCM;
int vol, outVol;

View File

@ -26,8 +26,7 @@
class DivPlatformSMS: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, note, actualNote;
unsigned char ins;
int freq, baseFreq, pitch, note, actualNote, ins;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
signed char vol, outVol;
DivMacroInt std;

View File

@ -28,8 +28,8 @@
class DivPlatformSwan: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins, pan;
int freq, baseFreq, pitch, note, ins;
unsigned char pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
int vol, outVol, wave;
DivMacroInt std;

View File

@ -27,8 +27,8 @@
class DivPlatformTIA: public DivDispatch {
protected:
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins, shape;
int freq, baseFreq, pitch, note, ins;
unsigned char shape;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
int vol, outVol;

View File

@ -35,8 +35,7 @@ class DivPlatformTX81Z: public DivDispatch {
DivInstrumentFM state;
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins;
int freq, baseFreq, pitch, note, ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, portaPause, furnacePCM, hardReset;
int vol, outVol;

View File

@ -29,8 +29,8 @@ struct VERA_PCM;
class DivPlatformVERA: public DivDispatch {
protected:
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins, pan;
int freq, baseFreq, pitch, note, ins;
unsigned char pan;
bool active, freqChanged, inPorta;
int vol, outVol;
unsigned accum;

View File

@ -27,8 +27,8 @@
class DivPlatformVIC20: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins, pan;
int freq, baseFreq, pitch, note, ins;
unsigned char pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
int vol, outVol, wave, waveWriteCycle;
DivMacroInt std;

View File

@ -31,8 +31,8 @@ class DivPlatformVRC6: public DivDispatch {
int freq, baseFreq, pitch, note;
int dacPeriod, dacRate, dacOut;
unsigned int dacPos;
int dacSample;
unsigned char ins, duty;
int dacSample, ins;
unsigned char duty;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, pcm, furnaceDac;
signed char vol, outVol;
DivMacroInt std;

View File

@ -43,8 +43,8 @@ class DivPlatformYM2610: public DivDispatch {
struct Channel {
DivInstrumentFM state;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins, psgMode, autoEnvNum, autoEnvDen;
int freq, baseFreq, pitch, note, ins;
unsigned char psgMode, autoEnvNum, autoEnvDen;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta, furnacePCM, hardReset;
int vol, outVol;

View File

@ -35,8 +35,8 @@ class DivPlatformYM2610B: public DivDispatch {
struct Channel {
DivInstrumentFM state;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins, psgMode, autoEnvNum, autoEnvDen;
int freq, baseFreq, pitch, note, ins;
unsigned char psgMode, autoEnvNum, autoEnvDen;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta, furnacePCM, hardReset;
int vol, outVol;

View File

@ -25,8 +25,7 @@ class DivPlatformYM2610BExt: public DivPlatformYM2610B {
struct OpChannel {
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch;
unsigned char ins;
int freq, baseFreq, pitch, ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause;
int vol;

View File

@ -25,8 +25,7 @@ class DivPlatformYM2610Ext: public DivPlatformYM2610 {
struct OpChannel {
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch;
unsigned char ins;
int freq, baseFreq, pitch, ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause;
int vol;

View File

@ -4,7 +4,7 @@
#include "../../extern/pfd-fixed/portable-file-dialogs.h"
bool FurnaceGUIFileDialog::openLoad(String header, std::vector<String> filter, const char* noSysFilter, String path, double dpiScale) {
bool FurnaceGUIFileDialog::openLoad(String header, std::vector<String> filter, const char* noSysFilter, String path, double dpiScale, FileDialogSelectCallback clickCallback) {
if (opened) return false;
saving=false;
curPath=path;
@ -13,7 +13,7 @@ bool FurnaceGUIFileDialog::openLoad(String header, std::vector<String> filter, c
dialogO=new pfd::open_file(header,path,filter);
} else {
ImGuiFileDialog::Instance()->DpiScale=dpiScale;
ImGuiFileDialog::Instance()->OpenModal("FileDialog",header,noSysFilter,path);
ImGuiFileDialog::Instance()->OpenModal("FileDialog",header,noSysFilter,path,1,nullptr,0,clickCallback);
}
opened=true;
return true;

View File

@ -7,6 +7,8 @@ namespace pfd {
class save_file;
}
typedef std::function<void(const char*)> FileDialogSelectCallback;
class FurnaceGUIFileDialog {
bool sysDialog;
bool opened;
@ -16,7 +18,7 @@ class FurnaceGUIFileDialog {
pfd::open_file* dialogO;
pfd::save_file* dialogS;
public:
bool openLoad(String header, std::vector<String> filter, const char* noSysFilter, String path, double dpiScale);
bool openLoad(String header, std::vector<String> filter, const char* noSysFilter, String path, double dpiScale, FileDialogSelectCallback clickCallback=NULL);
bool openSave(String header, std::vector<String> filter, const char* noSysFilter, String path, double dpiScale);
bool accepted();
void close();

View File

@ -1293,7 +1293,15 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
"all files", ".*"},
"compatible files{.fui,.dmp,.tfi,.vgi,.s3i,.sbi,.opli,.opni,.y12,.bnk,.ff,.opm},.*",
workingDirIns,
dpiScale
dpiScale,
[this](const char* path) {
std::vector<DivInstrument*> instruments=e->instrumentFromFile(path);
if (!instruments.empty()) {
e->loadTempIns(instruments[0]);
curIns=-2;
}
for (DivInstrument* i: instruments) delete i;
}
);
break;
case GUI_FILE_INS_SAVE: