GUI: use best wave size when adding wave

or display a menu

TODO: fix non-32×32 wave being messed up
This commit is contained in:
tildearrow 2023-12-09 20:01:33 -05:00
parent 0daf52ffe0
commit bd7e57cea8
3 changed files with 71 additions and 2 deletions

View file

@ -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; i<e->song.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;

View file

@ -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

View file

@ -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<FurnaceGUISysDef> newSongSearchResults;
FixedQueue<String,32> recentFile;
std::vector<DivInstrumentType> makeInsTypeList;
std::vector<FurnaceGUIWaveSizeEntry> waveSizeList;
std::vector<String> availRenderDrivers;
std::vector<String> 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;