diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 09ecad39..5cb4d520 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -3042,6 +3042,7 @@ bool FurnaceGUI::loop() { if (!e->addSystem(picked)) { showError("cannot add chip! ("+e->getLastError()+")"); } + ImGui::CloseCurrentPopup(); updateWindowTitle(); } ImGui::EndMenu(); @@ -3063,6 +3064,7 @@ bool FurnaceGUI::loop() { if (picked!=DIV_SYSTEM_NULL) { e->changeSystem(i,picked,preserveChanPos); updateWindowTitle(); + ImGui::CloseCurrentPopup(); } ImGui::EndMenu(); } @@ -4756,6 +4758,7 @@ FurnaceGUI::FurnaceGUI(): drawHalt(10), macroPointSize(16), waveEditStyle(0), + curSysSection(NULL), pendingRawSampleDepth(8), pendingRawSampleChannels(1), pendingRawSampleUnsigned(false), diff --git a/src/gui/gui.h b/src/gui/gui.h index 283edc82..b47784d2 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -987,6 +987,7 @@ class FurnaceGUI { int drawHalt; int macroPointSize; int waveEditStyle; + const int* curSysSection; String pendingRawSample; int pendingRawSampleDepth, pendingRawSampleChannels; @@ -1669,7 +1670,6 @@ class FurnaceGUI { void doDrag(); void editOptions(bool topMenu); DivSystem systemPicker(); - bool systemPickerOption(DivSystem sys); void noteInput(int num, int key, int vol=-1); void valueInput(int num, bool direct=false, int target=-1); diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index 1940946d..d1ef835c 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -839,7 +839,9 @@ const FurnaceGUIColorDef guiColors[GUI_COLOR_MAX]={ }; #undef D -// define systems. +// define chips here + +// all chips const int availableSystems[]={ DIV_SYSTEM_YM2612, DIV_SYSTEM_YM2612_EXT, @@ -911,3 +913,115 @@ const int availableSystems[]={ 0 // don't remove this last one! }; +// FM +const int chipsFM[]={ + DIV_SYSTEM_YM2612, + DIV_SYSTEM_YM2612_EXT, + DIV_SYSTEM_YM2612_FRAC, + DIV_SYSTEM_YM2612_FRAC_EXT, + DIV_SYSTEM_YM2151, + DIV_SYSTEM_YM2610, + DIV_SYSTEM_YM2610_EXT, + DIV_SYSTEM_YM2610_FULL, + DIV_SYSTEM_YM2610_FULL_EXT, + DIV_SYSTEM_YM2610B, + DIV_SYSTEM_YM2610B_EXT, + DIV_SYSTEM_YMU759, + DIV_SYSTEM_OPN, + DIV_SYSTEM_OPN_EXT, + DIV_SYSTEM_PC98, + DIV_SYSTEM_PC98_EXT, + DIV_SYSTEM_OPLL, + DIV_SYSTEM_OPLL_DRUMS, + DIV_SYSTEM_VRC7, + DIV_SYSTEM_OPL, + DIV_SYSTEM_OPL_DRUMS, + DIV_SYSTEM_Y8950, + DIV_SYSTEM_Y8950_DRUMS, + DIV_SYSTEM_OPL2, + DIV_SYSTEM_OPL2_DRUMS, + DIV_SYSTEM_OPL3, + DIV_SYSTEM_OPL3_DRUMS, + DIV_SYSTEM_OPZ, + 0 // don't remove this last one! +}; + +// square +const int chipsSquare[]={ + DIV_SYSTEM_SMS, + DIV_SYSTEM_AY8910, + DIV_SYSTEM_PCSPKR, + DIV_SYSTEM_SAA1099, + DIV_SYSTEM_VIC20, + 0 // don't remove this last one! +}; + +// wavetable +const int chipsWave[]={ + DIV_SYSTEM_PCE, + DIV_SYSTEM_X1_010, + DIV_SYSTEM_SWAN, + DIV_SYSTEM_BUBSYS_WSG, + DIV_SYSTEM_N163, + DIV_SYSTEM_FDS, + DIV_SYSTEM_SCC, + DIV_SYSTEM_SCC_PLUS, + DIV_SYSTEM_NAMCO, + DIV_SYSTEM_NAMCO_15XX, + DIV_SYSTEM_NAMCO_CUS30, + 0 // don't remove this last one! +}; + +// specialized +const int chipsSpecial[]={ + DIV_SYSTEM_GB, + DIV_SYSTEM_NES, + DIV_SYSTEM_C64_8580, + DIV_SYSTEM_C64_6581, + DIV_SYSTEM_SFX_BEEPER, + DIV_SYSTEM_DUMMY, + DIV_SYSTEM_SOUND_UNIT, + DIV_SYSTEM_TIA, + DIV_SYSTEM_AY8930, + DIV_SYSTEM_LYNX, + DIV_SYSTEM_VERA, + DIV_SYSTEM_PET, + DIV_SYSTEM_VRC6, + DIV_SYSTEM_MMC5, + 0 // don't remove this last one! +}; + +// sample +const int chipsSample[]={ + DIV_SYSTEM_SEGAPCM, + DIV_SYSTEM_SEGAPCM_COMPAT, + DIV_SYSTEM_AMIGA, + DIV_SYSTEM_QSOUND, + DIV_SYSTEM_X1_010, + DIV_SYSTEM_YMZ280B, + DIV_SYSTEM_MSM6258, + DIV_SYSTEM_MSM6295, + DIV_SYSTEM_RF5C68, + DIV_SYSTEM_PCM_DAC, + 0 // don't remove this last one! +}; + +const int* chipCategories[]={ + availableSystems, + chipsFM, + chipsSquare, + chipsWave, + chipsSpecial, + chipsSample, + NULL +}; + +const char* chipCategoryNames[]={ + "All chips", + "FM", + "Square", + "Wavetable", + "Special", + "Sample", + NULL +}; \ No newline at end of file diff --git a/src/gui/guiConst.h b/src/gui/guiConst.h index a6df68f6..24bdac47 100644 --- a/src/gui/guiConst.h +++ b/src/gui/guiConst.h @@ -42,7 +42,14 @@ extern const char* pitchLabel[11]; extern const char* insTypes[]; extern const char* sampleDepths[]; extern const char* resampleStrats[]; +extern const char* chipCategoryNames[]; extern const int availableSystems[]; +extern const int chipsFM[]; +extern const int chipsSquare[]; +extern const int chipsWavetable[]; +extern const int chipsSpecial[]; +extern const int chipsSample[]; +extern const int* chipCategories[]; extern const FurnaceGUIActionDef guiActions[]; extern const FurnaceGUIColorDef guiColors[]; extern const int altValues[24]; diff --git a/src/gui/sysManager.cpp b/src/gui/sysManager.cpp index bab348e3..98f939d0 100644 --- a/src/gui/sysManager.cpp +++ b/src/gui/sysManager.cpp @@ -83,6 +83,7 @@ void FurnaceGUI::drawSysManager() { if (picked!=DIV_SYSTEM_NULL) { e->changeSystem(i,picked,preserveChanPos); updateWindowTitle(); + ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } @@ -110,6 +111,7 @@ void FurnaceGUI::drawSysManager() { showError("cannot add chip! ("+e->getLastError()+")"); } updateWindowTitle(); + ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } diff --git a/src/gui/sysPicker.cpp b/src/gui/sysPicker.cpp index bcfc95ae..f59e547a 100644 --- a/src/gui/sysPicker.cpp +++ b/src/gui/sysPicker.cpp @@ -23,52 +23,75 @@ #include "guiConst.h" #include -bool FurnaceGUI::systemPickerOption(DivSystem sys) { - const DivSysDef* sysDef=e->getSystemDef(sys); - if (sysDef==NULL) return false; - bool ret=ImGui::Selectable(sysDef->name); - if (ImGui::IsItemHovered()) { - ImGui::BeginTooltip(); - ImGui::TextUnformatted(sysDef->description); - ImGui::EndTooltip(); - } - return ret; -} - DivSystem FurnaceGUI::systemPicker() { DivSystem ret=DIV_SYSTEM_NULL; - /* - for (int j=0; availableSystems[j]; j++) { - if (!settings.hiddenSystems && (availableSystems[j]==DIV_SYSTEM_YMU759 || availableSystems[j]==DIV_SYSTEM_DUMMY)) continue; - sysAddOption((DivSystem)availableSystems[j]); - } - */ - if (ImGui::InputTextWithHint("##SysSearch","Search...",&sysSearchQuery)) { + DivSystem hoveredSys=DIV_SYSTEM_NULL; + bool reissueSearch=false; + if (curSysSection==NULL) { + curSysSection=availableSystems; + } + + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (ImGui::InputTextWithHint("##SysSearch","Search...",&sysSearchQuery)) reissueSearch=true; + if (ImGui::BeginTabBar("SysCats")) { + for (int i=0; chipCategories[i]; i++) { + if (ImGui::BeginTabItem(chipCategoryNames[i])) { + if (ImGui::IsItemActive()) { + reissueSearch=true; + } + curSysSection=chipCategories[i]; + ImGui::EndTabItem(); + } + } + ImGui::EndTabBar(); + } + if (reissueSearch) { String lowerCase=sysSearchQuery; for (char& i: lowerCase) { if (i>='A' && i<='Z') i+='a'-'A'; } sysSearchResults.clear(); - for (int j=0; availableSystems[j]; j++) { - String lowerCase1=e->getSystemName((DivSystem)availableSystems[j]); + for (int j=0; curSysSection[j]; j++) { + String lowerCase1=e->getSystemName((DivSystem)curSysSection[j]); for (char& i: lowerCase1) { if (i>='A' && i<='Z') i+='a'-'A'; } if (lowerCase1.find(lowerCase)!=String::npos) { - sysSearchResults.push_back((DivSystem)availableSystems[j]); + sysSearchResults.push_back((DivSystem)curSysSection[j]); } } } - if (sysSearchQuery.empty()) { - // display chip list - for (int j=0; availableSystems[j]; j++) { - if (systemPickerOption((DivSystem)availableSystems[j])) ret=(DivSystem)availableSystems[j]; + if (ImGui::BeginTable("SysList",1,ImGuiTableFlags_ScrollY,ImVec2(500.0f*dpiScale,200.0*dpiScale))) { + if (sysSearchQuery.empty()) { + // display chip list + for (int j=0; curSysSection[j]; j++) { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + if (ImGui::Selectable(e->getSystemName((DivSystem)curSysSection[j]),false,0,ImVec2(500.0f*dpiScale,0.0f))) ret=(DivSystem)curSysSection[j]; + if (ImGui::IsItemHovered()) { + hoveredSys=(DivSystem)curSysSection[j]; + } + } + } else { + // display search results + for (DivSystem i: sysSearchResults) { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + if (ImGui::Selectable(e->getSystemName(i),false,0,ImVec2(500.0f*dpiScale,0.0f))) ret=i; + if (ImGui::IsItemHovered()) { + hoveredSys=i; + } + } } - } else { - // display search results - for (DivSystem i: sysSearchResults) { - if (systemPickerOption(i)) ret=i; + ImGui::EndTable(); + } + ImGui::Separator(); + if (ImGui::BeginChild("SysDesc",ImVec2(0.0f,150.0f*dpiScale),false,ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoScrollWithMouse)) { + if (hoveredSys!=DIV_SYSTEM_NULL) { + const DivSysDef* sysDef=e->getSystemDef(hoveredSys); + ImGui::TextWrapped("%s",sysDef->description); } } + ImGui::EndChild(); return ret; } \ No newline at end of file