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 std::string& vFileName,
const int& vCountSelectionMax, const int& vCountSelectionMax,
UserDatas vUserDatas, UserDatas vUserDatas,
ImGuiFileDialogFlags vFlags) ImGuiFileDialogFlags vFlags,
SelectFun vSelectFun)
{ {
if (prFileDialogInternal.puShowDialog) // if already opened, quit if (prFileDialogInternal.puShowDialog) // if already opened, quit
return; return;
@ -3306,6 +3307,7 @@ namespace IGFD
prFileDialogInternal.puDLGtitle = vTitle; prFileDialogInternal.puDLGtitle = vTitle;
prFileDialogInternal.puDLGuserDatas = vUserDatas; prFileDialogInternal.puDLGuserDatas = vUserDatas;
prFileDialogInternal.puDLGflags = vFlags; prFileDialogInternal.puDLGflags = vFlags;
prFileDialogInternal.puDLGselFun = vSelectFun;
prFileDialogInternal.puDLGoptionsPane = nullptr; prFileDialogInternal.puDLGoptionsPane = nullptr;
prFileDialogInternal.puDLGoptionsPaneWidth = 0.0f; prFileDialogInternal.puDLGoptionsPaneWidth = 0.0f;
prFileDialogInternal.puDLGmodal = false; prFileDialogInternal.puDLGmodal = false;
@ -3335,7 +3337,8 @@ namespace IGFD
const std::string& vFilePathName, const std::string& vFilePathName,
const int& vCountSelectionMax, const int& vCountSelectionMax,
UserDatas vUserDatas, UserDatas vUserDatas,
ImGuiFileDialogFlags vFlags) ImGuiFileDialogFlags vFlags,
SelectFun vSelectFun)
{ {
if (prFileDialogInternal.puShowDialog) // if already opened, quit if (prFileDialogInternal.puShowDialog) // if already opened, quit
return; return;
@ -3348,6 +3351,7 @@ namespace IGFD
prFileDialogInternal.puDLGoptionsPaneWidth = 0.0f; prFileDialogInternal.puDLGoptionsPaneWidth = 0.0f;
prFileDialogInternal.puDLGuserDatas = vUserDatas; prFileDialogInternal.puDLGuserDatas = vUserDatas;
prFileDialogInternal.puDLGflags = vFlags; prFileDialogInternal.puDLGflags = vFlags;
prFileDialogInternal.puDLGselFun = vSelectFun;
prFileDialogInternal.puDLGmodal = false; prFileDialogInternal.puDLGmodal = false;
auto ps = IGFD::Utils::ParsePathFileName(vFilePathName); auto ps = IGFD::Utils::ParsePathFileName(vFilePathName);
@ -3390,7 +3394,8 @@ namespace IGFD
const float& vSidePaneWidth, const float& vSidePaneWidth,
const int& vCountSelectionMax, const int& vCountSelectionMax,
UserDatas vUserDatas, UserDatas vUserDatas,
ImGuiFileDialogFlags vFlags) ImGuiFileDialogFlags vFlags,
SelectFun vSelectFun)
{ {
if (prFileDialogInternal.puShowDialog) // if already opened, quit if (prFileDialogInternal.puShowDialog) // if already opened, quit
return; return;
@ -3401,6 +3406,7 @@ namespace IGFD
prFileDialogInternal.puDLGtitle = vTitle; prFileDialogInternal.puDLGtitle = vTitle;
prFileDialogInternal.puDLGuserDatas = vUserDatas; prFileDialogInternal.puDLGuserDatas = vUserDatas;
prFileDialogInternal.puDLGflags = vFlags; prFileDialogInternal.puDLGflags = vFlags;
prFileDialogInternal.puDLGselFun = vSelectFun;
prFileDialogInternal.puDLGoptionsPane = vSidePane; prFileDialogInternal.puDLGoptionsPane = vSidePane;
prFileDialogInternal.puDLGoptionsPaneWidth = vSidePaneWidth; prFileDialogInternal.puDLGoptionsPaneWidth = vSidePaneWidth;
prFileDialogInternal.puDLGmodal = false; prFileDialogInternal.puDLGmodal = false;
@ -3435,7 +3441,8 @@ namespace IGFD
const float& vSidePaneWidth, const float& vSidePaneWidth,
const int& vCountSelectionMax, const int& vCountSelectionMax,
UserDatas vUserDatas, UserDatas vUserDatas,
ImGuiFileDialogFlags vFlags) ImGuiFileDialogFlags vFlags,
SelectFun vSelectFun)
{ {
if (prFileDialogInternal.puShowDialog) // if already opened, quit if (prFileDialogInternal.puShowDialog) // if already opened, quit
return; return;
@ -3448,6 +3455,7 @@ namespace IGFD
prFileDialogInternal.puDLGoptionsPaneWidth = vSidePaneWidth; prFileDialogInternal.puDLGoptionsPaneWidth = vSidePaneWidth;
prFileDialogInternal.puDLGuserDatas = vUserDatas; prFileDialogInternal.puDLGuserDatas = vUserDatas;
prFileDialogInternal.puDLGflags = vFlags; prFileDialogInternal.puDLGflags = vFlags;
prFileDialogInternal.puDLGselFun = vSelectFun;
prFileDialogInternal.puDLGmodal = false; prFileDialogInternal.puDLGmodal = false;
auto ps = IGFD::Utils::ParsePathFileName(vFilePathName); auto ps = IGFD::Utils::ParsePathFileName(vFilePathName);
@ -3489,7 +3497,8 @@ namespace IGFD
const std::string& vFileName, const std::string& vFileName,
const int& vCountSelectionMax, const int& vCountSelectionMax,
UserDatas vUserDatas, UserDatas vUserDatas,
ImGuiFileDialogFlags vFlags) ImGuiFileDialogFlags vFlags,
SelectFun vSelectFun)
{ {
if (prFileDialogInternal.puShowDialog) // if already opened, quit if (prFileDialogInternal.puShowDialog) // if already opened, quit
return; return;
@ -3497,7 +3506,7 @@ namespace IGFD
OpenDialog( OpenDialog(
vKey, vTitle, vFilters, vKey, vTitle, vFilters,
vPath, vFileName, vPath, vFileName,
vCountSelectionMax, vUserDatas, vFlags); vCountSelectionMax, vUserDatas, vFlags, vSelectFun);
prFileDialogInternal.puDLGmodal = true; prFileDialogInternal.puDLGmodal = true;
} }
@ -3509,7 +3518,8 @@ namespace IGFD
const std::string& vFilePathName, const std::string& vFilePathName,
const int& vCountSelectionMax, const int& vCountSelectionMax,
UserDatas vUserDatas, UserDatas vUserDatas,
ImGuiFileDialogFlags vFlags) ImGuiFileDialogFlags vFlags,
SelectFun vSelectFun)
{ {
if (prFileDialogInternal.puShowDialog) // if already opened, quit if (prFileDialogInternal.puShowDialog) // if already opened, quit
return; return;
@ -3517,7 +3527,7 @@ namespace IGFD
OpenDialog( OpenDialog(
vKey, vTitle, vFilters, vKey, vTitle, vFilters,
vFilePathName, vFilePathName,
vCountSelectionMax, vUserDatas, vFlags); vCountSelectionMax, vUserDatas, vFlags, vSelectFun);
prFileDialogInternal.puDLGmodal = true; prFileDialogInternal.puDLGmodal = true;
} }
@ -3534,7 +3544,8 @@ namespace IGFD
const float& vSidePaneWidth, const float& vSidePaneWidth,
const int& vCountSelectionMax, const int& vCountSelectionMax,
UserDatas vUserDatas, UserDatas vUserDatas,
ImGuiFileDialogFlags vFlags) ImGuiFileDialogFlags vFlags,
SelectFun vSelectFun)
{ {
if (prFileDialogInternal.puShowDialog) // if already opened, quit if (prFileDialogInternal.puShowDialog) // if already opened, quit
return; return;
@ -3543,7 +3554,7 @@ namespace IGFD
vKey, vTitle, vFilters, vKey, vTitle, vFilters,
vPath, vFileName, vPath, vFileName,
vSidePane, vSidePaneWidth, vSidePane, vSidePaneWidth,
vCountSelectionMax, vUserDatas, vFlags); vCountSelectionMax, vUserDatas, vFlags, vSelectFun);
prFileDialogInternal.puDLGmodal = true; prFileDialogInternal.puDLGmodal = true;
} }
@ -3559,7 +3570,8 @@ namespace IGFD
const float& vSidePaneWidth, const float& vSidePaneWidth,
const int& vCountSelectionMax, const int& vCountSelectionMax,
UserDatas vUserDatas, UserDatas vUserDatas,
ImGuiFileDialogFlags vFlags) ImGuiFileDialogFlags vFlags,
SelectFun vSelectFun)
{ {
if (prFileDialogInternal.puShowDialog) // if already opened, quit if (prFileDialogInternal.puShowDialog) // if already opened, quit
return; return;
@ -3568,7 +3580,7 @@ namespace IGFD
vKey, vTitle, vFilters, vKey, vTitle, vFilters,
vFilePathName, vFilePathName,
vSidePane, vSidePaneWidth, vSidePane, vSidePaneWidth,
vCountSelectionMax, vUserDatas, vFlags); vCountSelectionMax, vUserDatas, vFlags, vSelectFun);
prFileDialogInternal.puDLGmodal = true; prFileDialogInternal.puDLGmodal = true;
} }
@ -3940,6 +3952,9 @@ namespace IGFD
return 2; return 2;
} else { } else {
fdi.SelectFileName(prFileDialogInternal, vInfos); 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 void* UserDatas;
typedef std::function<void(const char*, UserDatas, bool*)> PaneFun; // side pane function binding 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 class FileDialogInternal
{ {
public: public:
@ -1103,6 +1104,7 @@ namespace IGFD
ImGuiFileDialogFlags puDLGflags = ImGuiFileDialogFlags_None; ImGuiFileDialogFlags puDLGflags = ImGuiFileDialogFlags_None;
UserDatas puDLGuserDatas = nullptr; UserDatas puDLGuserDatas = nullptr;
PaneFun puDLGoptionsPane = nullptr; PaneFun puDLGoptionsPane = nullptr;
SelectFun puDLGselFun = nullptr;
float puDLGoptionsPaneWidth = 0.0f; float puDLGoptionsPaneWidth = 0.0f;
bool puDLGmodal = false; bool puDLGmodal = false;
bool puNeedToExitDialog = false; bool puNeedToExitDialog = false;
@ -1155,7 +1157,8 @@ namespace IGFD
const std::string& vFileName, // defaut file name const std::string& vFileName, // defaut file name
const int& vCountSelectionMax = 1, // count selection max const int& vCountSelectionMax = 1, // count selection max
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane) 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) void OpenDialog( // open simple dialog (path and filename are obtained from filePathName)
const std::string& vKey, // key dialog 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 std::string& vFilePathName, // file path name (will be decompsoed in path and fileName)
const int& vCountSelectionMax = 1, // count selection max const int& vCountSelectionMax = 1, // count selection max
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane) 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 // with pane
void OpenDialog( // open dialog with custom right pane (path and fileName can be specified) 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 float& vSidePaneWidth = 250.0f, // side pane width
const int& vCountSelectionMax = 1, // count selection max const int& vCountSelectionMax = 1, // count selection max
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane) 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) void OpenDialog( // open dialog with custom right pane (path and filename are obtained from filePathName)
const std::string& vKey, // key dialog const std::string& vKey, // key dialog
@ -1188,7 +1193,8 @@ namespace IGFD
const float& vSidePaneWidth = 250.0f, // side pane width const float& vSidePaneWidth = 250.0f, // side pane width
const int& vCountSelectionMax = 1, // count selection max const int& vCountSelectionMax = 1, // count selection max
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane) 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 // modal dialog
void OpenModal( // open simple modal (path and fileName can be specified) 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 std::string& vFileName, // defaut file name
const int& vCountSelectionMax = 1, // count selection max const int& vCountSelectionMax = 1, // count selection max
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane) 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) void OpenModal( // open simple modal (path and fielname are obtained from filePathName)
const std::string& vKey, // key dialog 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 std::string& vFilePathName, // file path name (will be decompsoed in path and fileName)
const int& vCountSelectionMax = 1, // count selection max const int& vCountSelectionMax = 1, // count selection max
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane) 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 // with pane
void OpenModal( // open modal with custom right pane (path and filename are obtained from filePathName) 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 float& vSidePaneWidth = 250.0f, // side pane width
const int& vCountSelectionMax = 1, // count selection max const int& vCountSelectionMax = 1, // count selection max
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane) 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) void OpenModal( // open modal with custom right pane (path and fielname are obtained from filePathName)
const std::string& vKey, // key dialog const std::string& vKey, // key dialog
@ -1232,7 +1241,8 @@ namespace IGFD
const float& vSidePaneWidth = 250.0f, // side pane width const float& vSidePaneWidth = 250.0f, // side pane width
const int& vCountSelectionMax = 1, // count selection max const int& vCountSelectionMax = 1, // count selection max
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane) 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 // Display / Close dialog form
bool Display( // Display the dialog. return true if a result was obtained (Ok or not) 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) { 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) { if (index<0 || index>=song.insLen) {
switch (fallbackType) { switch (fallbackType) {
case DIV_INS_OPLL: case DIV_INS_OPLL:
@ -2027,7 +2029,7 @@ void DivEngine::autoNoteOn(int ch, int ins, int note, int vol) {
} }
do { 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; chan[finalChan].midiNote=note;
pendingNotes.push(DivNoteEvent(finalChan,ins,note,vol,true)); pendingNotes.push(DivNoteEvent(finalChan,ins,note,vol,true));
break; break;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1293,7 +1293,15 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
"all files", ".*"}, "all files", ".*"},
"compatible files{.fui,.dmp,.tfi,.vgi,.s3i,.sbi,.opli,.opni,.y12,.bnk,.ff,.opm},.*", "compatible files{.fui,.dmp,.tfi,.vgi,.s3i,.sbi,.opli,.opni,.y12,.bnk,.ff,.opm},.*",
workingDirIns, 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; break;
case GUI_FILE_INS_SAVE: case GUI_FILE_INS_SAVE: