From 496501803ffa53eea2eea860ca8d87650d6e2c99 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Wed, 26 Jan 2022 00:26:15 -0500 Subject: [PATCH] GUI: add advanced VGM export menu does NOT work yet! --- src/engine/engine.cpp | 23 +++++++++++++++++++++++ src/engine/engine.h | 3 +++ src/gui/gui.cpp | 32 ++++++++++++++++++++++++++++++-- src/gui/gui.h | 3 ++- 4 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index c9b42eb91..48f751072 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -625,6 +625,29 @@ DivInstrumentType DivEngine::getPreferInsType(int chan) { return DIV_INS_FM; } +bool DivEngine::isVGMExportable(DivSystem which) { + switch (which) { + case DIV_SYSTEM_GENESIS: + case DIV_SYSTEM_GENESIS_EXT: + case DIV_SYSTEM_SMS: + case DIV_SYSTEM_GB: + case DIV_SYSTEM_PCE: + case DIV_SYSTEM_NES: + case DIV_SYSTEM_ARCADE: + case DIV_SYSTEM_YM2151: + case DIV_SYSTEM_YM2612: + case DIV_SYSTEM_YM2610: + case DIV_SYSTEM_YM2610_EXT: + case DIV_SYSTEM_AY8910: + case DIV_SYSTEM_AY8930: + case DIV_SYSTEM_SAA1099: + return true; + default: + return false; + } + return false; +} + const char* DivEngine::getEffectDesc(unsigned char effect, int chan) { switch (effect) { case 0x00: diff --git a/src/engine/engine.h b/src/engine/engine.h index 3ce39529f..bf2b2b4d9 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -234,6 +234,9 @@ class DivEngine { // notify wavetable change void notifyWaveChange(int wave); + // returns whether a system is VGM compatible + bool isVGMExportable(DivSystem which); + // save config bool saveConf(); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index a50b1ed8a..7cb5a092a 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -4038,8 +4038,33 @@ bool FurnaceGUI::loop() { } ImGui::EndMenu(); } - if (ImGui::MenuItem("export VGM...")) { - openFileDialog(GUI_FILE_EXPORT_VGM); + if (ImGui::BeginMenu("export VGM...")) { + ImGui::Text("settings:"); + ImGui::Checkbox("loop",&vgmExportLoop); + ImGui::Text("systems to export:");; + bool hasOneAtLeast=false; + for (int i=0; isong.systemLen; i++) { + ImGui::BeginDisabled(!e->isVGMExportable(e->song.system[i])); + ImGui::Checkbox(fmt::sprintf("%d. %s##_SYSV%d",i+1,e->getSystemName(e->song.system[i]),i).c_str(),&willExport[i]); + ImGui::EndDisabled(); + if (!e->isVGMExportable(e->song.system[i])) { + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) { + ImGui::SetTooltip("this system is not supported by the VGM format!"); + } + } else { + if (willExport[i]) hasOneAtLeast=true; + } + } + ImGui::Text("select the systems you wish to export,"); + ImGui::Text("but only up to 2 of each type."); + if (hasOneAtLeast) { + if (ImGui::MenuItem("click to export")) { + openFileDialog(GUI_FILE_EXPORT_VGM); + } + } else { + ImGui::Text("nothing to export"); + } + ImGui::EndMenu(); } ImGui::Separator(); if (ImGui::BeginMenu("add system...")) { @@ -4742,6 +4767,7 @@ FurnaceGUI::FurnaceGUI(): modified(false), displayError(false), displayExporting(false), + vgmExportLoop(true), curFileDialog(GUI_FILE_OPEN), warnAction(GUI_WARN_OPEN), scrW(1280), @@ -4869,4 +4895,6 @@ FurnaceGUI::FurnaceGUI(): valueKeys[SDLK_d]=13; valueKeys[SDLK_e]=14; valueKeys[SDLK_f]=15; + + memset(willExport,1,32*sizeof(bool)); } diff --git a/src/gui/gui.h b/src/gui/gui.h index f64956b43..ec0b04590 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -162,7 +162,8 @@ class FurnaceGUI { String workingDir, fileName, clipboard, warnString, errorString, lastError, curFileName; - bool quit, warnQuit, willCommit, edit, modified, displayError, displayExporting; + bool quit, warnQuit, willCommit, edit, modified, displayError, displayExporting, vgmExportLoop; + bool willExport[32]; FurnaceGUIFileDialogs curFileDialog; FurnaceGUIWarnings warnAction;