GUI: and here is the new chip selector

This commit is contained in:
tildearrow 2022-08-26 23:35:16 -05:00
parent daf176e197
commit 73f88c7635
6 changed files with 181 additions and 32 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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();
}

View File

@ -23,52 +23,75 @@
#include "guiConst.h"
#include <imgui.h>
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;
}