diff --git a/src/gui/doAction.cpp b/src/gui/doAction.cpp index 4db68d93b..77fc7b7f7 100644 --- a/src/gui/doAction.cpp +++ b/src/gui/doAction.cpp @@ -717,16 +717,45 @@ void FurnaceGUI::doAction(int what) { insListDir=!insListDir; break; - case GUI_ACTION_WAVE_LIST_ADD: + case GUI_ACTION_WAVE_LIST_ADD: { + waveSizeList.clear(); + for (int i=0; isong.systemLen; i++) { + const DivSysDef* sysDef=e->getSystemDef(e->song.system[i]); + if (sysDef==NULL) continue; + + if (sysDef->waveHeight==0) continue; + if (sysDef->waveWidth==0) { + // add three preset sizes + waveSizeList.push_back(FurnaceGUIWaveSizeEntry(32,sysDef->waveHeight,sysDef->name)); + waveSizeList.push_back(FurnaceGUIWaveSizeEntry(64,sysDef->waveHeight,sysDef->name)); + waveSizeList.push_back(FurnaceGUIWaveSizeEntry(128,sysDef->waveHeight,sysDef->name)); + } else { + waveSizeList.push_back(FurnaceGUIWaveSizeEntry(sysDef->waveWidth,sysDef->waveHeight,sysDef->name)); + } + } + + int finalWidth=32; + int finalHeight=32; + if (waveSizeList.size()==1) { + finalWidth=waveSizeList[0].width; + finalHeight=waveSizeList[0].height; + } else if (waveSizeList.size()>1) { + displayWaveSizeList=true; + break; + } + curWave=e->addWave(); if (curWave==-1) { showError("too many wavetables!"); } else { wantScrollList=true; + e->song.wave[curWave]->len=finalWidth; + e->song.wave[curWave]->max=finalHeight-1; MARK_MODIFIED; RESET_WAVE_MACRO_ZOOM; } break; + } case GUI_ACTION_WAVE_LIST_DUPLICATE: if (curWave>=0 && curWave<(int)e->song.wave.size()) { int prevWave=curWave; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index ccb307fd6..79dba811c 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -5451,6 +5451,11 @@ bool FurnaceGUI::loop() { ImGui::OpenPopup("InsTypeList"); } + if (displayWaveSizeList) { + displayWaveSizeList=false; + ImGui::OpenPopup("WaveSizeList"); + } + if (displayExporting) { displayExporting=false; ImGui::OpenPopup("Rendering..."); @@ -5960,6 +5965,26 @@ bool FurnaceGUI::loop() { ImGui::EndPopup(); } + if (ImGui::BeginPopup("WaveSizeList",ImGuiWindowFlags_NoMove|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings)) { + char temp[1024]; + for (FurnaceGUIWaveSizeEntry i: waveSizeList) { + snprintf(temp,1023,"%d×%d (%s)",i.width,i.height,i.sys); + if (ImGui::MenuItem(temp)) { + // create wave + curWave=e->addWave(); + if (curWave==-1) { + showError("too many wavetables!"); + } else { + e->song.wave[curWave]->len=i.width; + e->song.wave[curWave]->max=i.height-1; + MARK_MODIFIED; + RESET_WAVE_MACRO_ZOOM; + } + } + } + ImGui::EndPopup(); + } + // TODO: // - multiple selection // - replace instrument diff --git a/src/gui/gui.h b/src/gui/gui.h index fa8e0ef4f..b379ee743 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1275,6 +1275,20 @@ struct FurnaceGUIQueryResult { } }; +struct FurnaceGUIWaveSizeEntry { + short width, height; + const char* sys; + + FurnaceGUIWaveSizeEntry(short w, short h, const char* s): + width(w), + height(h), + sys(s) {} + FurnaceGUIWaveSizeEntry(): + width(-1), + height(-1), + sys(NULL) {} +}; + class FurnaceGUITexture { }; @@ -1365,11 +1379,12 @@ class FurnaceGUI { std::vector newSongSearchResults; FixedQueue recentFile; std::vector makeInsTypeList; + std::vector waveSizeList; std::vector availRenderDrivers; std::vector availAudioDrivers; bool quit, warnQuit, willCommit, edit, editClone, isPatUnique, modified, displayError, displayExporting, vgmExportLoop, zsmExportLoop, zsmExportOptimize, vgmExportPatternHints; - bool vgmExportDirectStream, displayInsTypeList; + bool vgmExportDirectStream, displayInsTypeList, displayWaveSizeList; bool portrait, injectBackUp, mobileMenuOpen, warnColorPushed; bool wantCaptureKeyboard, oldWantCaptureKeyboard, displayMacroMenu; bool displayNew, fullScreen, preserveChanPos, wantScrollList, noteInputPoly, notifyWaveChange;