diff --git a/extern/igfd/ImGuiFileDialog.cpp b/extern/igfd/ImGuiFileDialog.cpp index 3980bcd3..98d6c909 100644 --- a/extern/igfd/ImGuiFileDialog.cpp +++ b/extern/igfd/ImGuiFileDialog.cpp @@ -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()); + } } } } diff --git a/extern/igfd/ImGuiFileDialog.h b/extern/igfd/ImGuiFileDialog.h index 2944bfbf..016bd9a1 100644 --- a/extern/igfd/ImGuiFileDialog.h +++ b/extern/igfd/ImGuiFileDialog.h @@ -1080,6 +1080,7 @@ namespace IGFD typedef void* UserDatas; typedef std::function PaneFun; // side pane function binding + typedef std::function 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) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 4821df3a..80fbb5ca 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -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; diff --git a/src/engine/platform/amiga.h b/src/engine/platform/amiga.h index 07c44ee7..a4c1a7a4 100644 --- a/src/engine/platform/amiga.h +++ b/src/engine/platform/amiga.h @@ -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; diff --git a/src/engine/platform/arcade.h b/src/engine/platform/arcade.h index 41af49e3..e051e8ab 100644 --- a/src/engine/platform/arcade.h +++ b/src/engine/platform/arcade.h @@ -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; diff --git a/src/engine/platform/ay.h b/src/engine/platform/ay.h index a78f21bc..ce06fc9f 100644 --- a/src/engine/platform/ay.h +++ b/src/engine/platform/ay.h @@ -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; diff --git a/src/engine/platform/ay8930.h b/src/engine/platform/ay8930.h index adbe0be8..61a186f4 100644 --- a/src/engine/platform/ay8930.h +++ b/src/engine/platform/ay8930.h @@ -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; diff --git a/src/engine/platform/bubsyswsg.h b/src/engine/platform/bubsyswsg.h index 2efcc4d9..0fbb2ac5 100644 --- a/src/engine/platform/bubsyswsg.h +++ b/src/engine/platform/bubsyswsg.h @@ -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 diff --git a/src/engine/platform/c64.h b/src/engine/platform/c64.h index f77e24b9..8df82051 100644 --- a/src/engine/platform/c64.h +++ b/src/engine/platform/c64.h @@ -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; diff --git a/src/engine/platform/fds.h b/src/engine/platform/fds.h index 6d206f3e..bf949272 100644 --- a/src/engine/platform/fds.h +++ b/src/engine/platform/fds.h @@ -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]; diff --git a/src/engine/platform/gb.h b/src/engine/platform/gb.h index df7070ec..c79603ab 100644 --- a/src/engine/platform/gb.h +++ b/src/engine/platform/gb.h @@ -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; diff --git a/src/engine/platform/genesis.h b/src/engine/platform/genesis.h index aa7659fa..31f11d18 100644 --- a/src/engine/platform/genesis.h +++ b/src/engine/platform/genesis.h @@ -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; diff --git a/src/engine/platform/genesisext.h b/src/engine/platform/genesisext.h index 4cdf9fc6..e3604a34 100644 --- a/src/engine/platform/genesisext.h +++ b/src/engine/platform/genesisext.h @@ -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; diff --git a/src/engine/platform/lynx.h b/src/engine/platform/lynx.h index 61f6e67d..f1f974ed 100644 --- a/src/engine/platform/lynx.h +++ b/src/engine/platform/lynx.h @@ -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(): diff --git a/src/engine/platform/mmc5.h b/src/engine/platform/mmc5.h index 02ca06e8..879ebee1 100644 --- a/src/engine/platform/mmc5.h +++ b/src/engine/platform/mmc5.h @@ -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; diff --git a/src/engine/platform/nes.h b/src/engine/platform/nes.h index 2cf2a8a1..7650d39e 100644 --- a/src/engine/platform/nes.h +++ b/src/engine/platform/nes.h @@ -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; diff --git a/src/engine/platform/opl.h b/src/engine/platform/opl.h index 76979a54..ee3bcb36 100644 --- a/src/engine/platform/opl.h +++ b/src/engine/platform/opl.h @@ -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; diff --git a/src/engine/platform/opll.h b/src/engine/platform/opll.h index 04f4f13a..79f905c6 100644 --- a/src/engine/platform/opll.h +++ b/src/engine/platform/opll.h @@ -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; diff --git a/src/engine/platform/pce.h b/src/engine/platform/pce.h index 57a4b033..deb85fbb 100644 --- a/src/engine/platform/pce.h +++ b/src/engine/platform/pce.h @@ -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; diff --git a/src/engine/platform/pcspkr.h b/src/engine/platform/pcspkr.h index 68e6bf1a..f8813f3f 100644 --- a/src/engine/platform/pcspkr.h +++ b/src/engine/platform/pcspkr.h @@ -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; diff --git a/src/engine/platform/pet.h b/src/engine/platform/pet.h index 7647a87f..b4b75316 100644 --- a/src/engine/platform/pet.h +++ b/src/engine/platform/pet.h @@ -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; diff --git a/src/engine/platform/qsound.h b/src/engine/platform/qsound.h index 62b1d647..aa07a3b4 100644 --- a/src/engine/platform/qsound.h +++ b/src/engine/platform/qsound.h @@ -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; diff --git a/src/engine/platform/saa.h b/src/engine/platform/saa.h index 0542ff51..30909293 100644 --- a/src/engine/platform/saa.h +++ b/src/engine/platform/saa.h @@ -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; diff --git a/src/engine/platform/segapcm.h b/src/engine/platform/segapcm.h index 4b05c160..3a68a34b 100644 --- a/src/engine/platform/segapcm.h +++ b/src/engine/platform/segapcm.h @@ -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; diff --git a/src/engine/platform/sms.h b/src/engine/platform/sms.h index 0aeb9e81..66fdda85 100644 --- a/src/engine/platform/sms.h +++ b/src/engine/platform/sms.h @@ -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; diff --git a/src/engine/platform/swan.h b/src/engine/platform/swan.h index 0f1643c5..fdad150b 100644 --- a/src/engine/platform/swan.h +++ b/src/engine/platform/swan.h @@ -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; diff --git a/src/engine/platform/tia.h b/src/engine/platform/tia.h index 3ec3c7f3..602cc6f1 100644 --- a/src/engine/platform/tia.h +++ b/src/engine/platform/tia.h @@ -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; diff --git a/src/engine/platform/tx81z.h b/src/engine/platform/tx81z.h index c61b4bfe..d9261ebd 100644 --- a/src/engine/platform/tx81z.h +++ b/src/engine/platform/tx81z.h @@ -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; diff --git a/src/engine/platform/vera.h b/src/engine/platform/vera.h index ec6dcde1..64dee5c7 100644 --- a/src/engine/platform/vera.h +++ b/src/engine/platform/vera.h @@ -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; diff --git a/src/engine/platform/vic20.h b/src/engine/platform/vic20.h index 7948c5ef..8c15c35d 100644 --- a/src/engine/platform/vic20.h +++ b/src/engine/platform/vic20.h @@ -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; diff --git a/src/engine/platform/vrc6.h b/src/engine/platform/vrc6.h index d28265a4..a44e9d33 100644 --- a/src/engine/platform/vrc6.h +++ b/src/engine/platform/vrc6.h @@ -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; diff --git a/src/engine/platform/ym2610.h b/src/engine/platform/ym2610.h index e75e24d7..af947199 100644 --- a/src/engine/platform/ym2610.h +++ b/src/engine/platform/ym2610.h @@ -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; diff --git a/src/engine/platform/ym2610b.h b/src/engine/platform/ym2610b.h index 6d46ecb2..d2363ed1 100644 --- a/src/engine/platform/ym2610b.h +++ b/src/engine/platform/ym2610b.h @@ -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; diff --git a/src/engine/platform/ym2610bext.h b/src/engine/platform/ym2610bext.h index e908916e..c2cd4fb3 100644 --- a/src/engine/platform/ym2610bext.h +++ b/src/engine/platform/ym2610bext.h @@ -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; diff --git a/src/engine/platform/ym2610ext.h b/src/engine/platform/ym2610ext.h index 9fa44d0b..b8922912 100644 --- a/src/engine/platform/ym2610ext.h +++ b/src/engine/platform/ym2610ext.h @@ -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; diff --git a/src/gui/fileDialog.cpp b/src/gui/fileDialog.cpp index 7bfafb4a..3b8fdd46 100644 --- a/src/gui/fileDialog.cpp +++ b/src/gui/fileDialog.cpp @@ -4,7 +4,7 @@ #include "../../extern/pfd-fixed/portable-file-dialogs.h" -bool FurnaceGUIFileDialog::openLoad(String header, std::vector filter, const char* noSysFilter, String path, double dpiScale) { +bool FurnaceGUIFileDialog::openLoad(String header, std::vector 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 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; diff --git a/src/gui/fileDialog.h b/src/gui/fileDialog.h index 0dcd82a6..6c5f2faa 100644 --- a/src/gui/fileDialog.h +++ b/src/gui/fileDialog.h @@ -7,6 +7,8 @@ namespace pfd { class save_file; } +typedef std::function 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 filter, const char* noSysFilter, String path, double dpiScale); + bool openLoad(String header, std::vector filter, const char* noSysFilter, String path, double dpiScale, FileDialogSelectCallback clickCallback=NULL); bool openSave(String header, std::vector filter, const char* noSysFilter, String path, double dpiScale); bool accepted(); void close(); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 26e414e0..4aa37b81 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -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 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: