GUI: prepare a better new song thingy

This commit is contained in:
tildearrow 2022-03-02 02:22:51 -05:00
parent 8843315256
commit d94e0ec3e7
4 changed files with 489 additions and 46 deletions

View file

@ -534,7 +534,7 @@ void DivEngine::renderSamples() {
qsoundMemLen=memPos+256; qsoundMemLen=memPos+256;
} }
void DivEngine::createNew(int* description) { void DivEngine::createNew(const int* description) {
quitDispatch(); quitDispatch();
isBusy.lock(); isBusy.lock();
song.unload(); song.unload();

View file

@ -262,7 +262,7 @@ class DivEngine {
DivWavetable* getWave(int index); DivWavetable* getWave(int index);
DivSample* getSample(int index); DivSample* getSample(int index);
// start fresh // start fresh
void createNew(int* description); void createNew(const int* description);
// load a file. // load a file.
bool load(unsigned char* f, size_t length); bool load(unsigned char* f, size_t length);
// save as .dmf. // save as .dmf.

View file

@ -1910,11 +1910,6 @@ void FurnaceGUI::drawDebug() {
ImGui::End(); ImGui::End();
} }
#define NEWSONG_CATEGORY(x) \
if (ImGui::Selectable(x,false,ImGuiSelectableFlags_DontClosePopups)) { \
printf("selected a category\n"); \
}
void FurnaceGUI::drawNewSong() { void FurnaceGUI::drawNewSong() {
bool accepted=false; bool accepted=false;
@ -1923,7 +1918,7 @@ void FurnaceGUI::drawNewSong() {
ImGui::Text("Choose a System!"); ImGui::Text("Choose a System!");
ImGui::PopFont(); ImGui::PopFont();
if (ImGui::BeginTable("sysPicker",2,ImGuiTableFlags_Borders)) { if (ImGui::BeginTable("sysPicker",2)) {
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed,0.0f); ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed,0.0f);
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.0f); ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.0f);
@ -1937,30 +1932,36 @@ void FurnaceGUI::drawNewSong() {
// CATEGORIES // CATEGORIES
ImGui::TableNextColumn(); ImGui::TableNextColumn();
NEWSONG_CATEGORY("All chips"); int index=0;
NEWSONG_CATEGORY("FM"); for (FurnaceGUISysCategory& i: sysCategories) {
NEWSONG_CATEGORY("Square"); if (ImGui::Selectable(i.name,newSongCategory==index,ImGuiSelectableFlags_DontClosePopups)) { \
NEWSONG_CATEGORY("Sample"); newSongCategory=index;
NEWSONG_CATEGORY("Wavetable"); }
NEWSONG_CATEGORY("Other/Special"); index++;
NEWSONG_CATEGORY("Game consoles"); }
NEWSONG_CATEGORY("Computers");
NEWSONG_CATEGORY("Arcade systems");
NEWSONG_CATEGORY("DefleMask-compatible");
// SYSTEMS // SYSTEMS
ImGui::TableNextColumn(); ImGui::TableNextColumn();
if (ImGui::BeginTable("Systems",1,ImGuiTableFlags_BordersInnerV|ImGuiTableFlags_ScrollY)) { if (ImGui::BeginTable("Systems",1,ImGuiTableFlags_BordersInnerV|ImGuiTableFlags_ScrollY)) {
for (FurnaceGUISysDef& i: sysCategories[newSongCategory].systems) {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Selectable("System system",false,ImGuiSelectableFlags_DontClosePopups); if (ImGui::Selectable(i.name,false,ImGuiSelectableFlags_DontClosePopups)) {
nextDesc=i.definition.data();
accepted=true;
}
}
ImGui::EndTable(); ImGui::EndTable();
} }
ImGui::EndTable(); ImGui::EndTable();
} }
if (ImGui::Button("Go ahead") || accepted) { if (ImGui::Button("Cancel")) {
ImGui::CloseCurrentPopup();
}
if (accepted) {
e->createNew(nextDesc); e->createNew(nextDesc);
undoHist.clear(); undoHist.clear();
redoHist.clear(); redoHist.clear();
@ -5286,7 +5287,7 @@ bool FurnaceGUI::loop() {
} }
ImGui::SetNextWindowSizeConstraints(ImVec2(400.0f*dpiScale,200.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale)); ImGui::SetNextWindowSizeConstraints(ImVec2(400.0f*dpiScale,200.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale));
if (ImGui::BeginPopupModal("New Song",NULL)) { if (ImGui::BeginPopupModal("New Song",NULL,ImGuiWindowFlags_NoMove)) {
ImGui::SetWindowPos(ImVec2(((scrW*dpiScale)-ImGui::GetWindowSize().x)*0.5,((scrH*dpiScale)-ImGui::GetWindowSize().y)*0.5)); ImGui::SetWindowPos(ImVec2(((scrW*dpiScale)-ImGui::GetWindowSize().x)*0.5,((scrH*dpiScale)-ImGui::GetWindowSize().y)*0.5));
drawNewSong(); drawNewSong();
ImGui::EndPopup(); ImGui::EndPopup();
@ -5949,6 +5950,7 @@ FurnaceGUI::FurnaceGUI():
isClipping(0), isClipping(0),
extraChannelButtons(0), extraChannelButtons(0),
patNameTarget(-1), patNameTarget(-1),
newSongCategory(0),
editControlsOpen(true), editControlsOpen(true),
ordersOpen(true), ordersOpen(true),
insListOpen(true), insListOpen(true),
@ -6104,29 +6106,468 @@ FurnaceGUI::FurnaceGUI():
valueKeys[SDLK_KP_8]=8; valueKeys[SDLK_KP_8]=8;
valueKeys[SDLK_KP_9]=9; valueKeys[SDLK_KP_9]=9;
/*
const char* sysCategories[]={
"All chips",
"FM",
"Square",
"Sample",
"Wavetable",
"Other/Special",
"Game consoles",
"Computers",
"Arcade systems",
"DefleMask-compatible"
};
*/
FurnaceGUISysCategory cat; FurnaceGUISysCategory cat;
cat=FurnaceGUISysCategory("All chips"); cat=FurnaceGUISysCategory("FM");
cat.systems.push_back(FurnaceGUISysDef( cat.systems.push_back(FurnaceGUISysDef(
"Yamaha YM2612", NULL /*{ "Yamaha YM2612", {
DIV_SYSTEM_YM2612, 64, 0, 0, DIV_SYSTEM_YM2612, 64, 0, 0,
0 0
}*/ }
));
cat.systems.push_back(FurnaceGUISysDef(
"Yamaha YM2612 (extended channel 3)", {
DIV_SYSTEM_YM2612_EXT, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Yamaha YM2151", {
DIV_SYSTEM_YM2151, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Yamaha YM2610", {
DIV_SYSTEM_YM2610_FULL, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Yamaha YM2610 (extended channel 2)", {
DIV_SYSTEM_YM2610_FULL_EXT, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Yamaha YM2610B", {
DIV_SYSTEM_YM2610, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Yamaha YM2610B (extended channel 3)", {
DIV_SYSTEM_YM2610B_EXT, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Yamaha YM2413", {
DIV_SYSTEM_OPLL, 64, 0, 0,
0
}
));
sysCategories.push_back(cat);
cat=FurnaceGUISysCategory("Square");
cat.systems.push_back(FurnaceGUISysDef(
"TI SN76489", {
DIV_SYSTEM_SMS, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"AY-3-8910", {
DIV_SYSTEM_AY8910, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Philips SAA1099", {
DIV_SYSTEM_SAA1099, 64, 0, 0,
0
}
));
sysCategories.push_back(cat);
cat=FurnaceGUISysCategory("Sample");
cat.systems.push_back(FurnaceGUISysDef(
"Amiga", {
DIV_SYSTEM_AMIGA, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"SegaPCM", {
DIV_SYSTEM_SEGAPCM, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Capcom QSound", {
DIV_SYSTEM_QSOUND, 64, 0, 0,
0
}
));
sysCategories.push_back(cat);
cat=FurnaceGUISysCategory("Game consoles");
cat.systems.push_back(FurnaceGUISysDef(
"Sega Genesis", {
DIV_SYSTEM_YM2612, 64, 0, 0,
DIV_SYSTEM_SMS, 24, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Sega Genesis (extended channel 3)", {
DIV_SYSTEM_YM2612_EXT, 64, 0, 0,
DIV_SYSTEM_SMS, 24, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Sega Master System", {
DIV_SYSTEM_SMS, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Sega Master System (with FM expansion)", {
DIV_SYSTEM_SMS, 64, 0, 0,
DIV_SYSTEM_OPLL, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Sega Master System (with FM expansion in drums mode)", {
DIV_SYSTEM_SMS, 64, 0, 0,
DIV_SYSTEM_OPLL_DRUMS, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Game Boy", {
DIV_SYSTEM_GB, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"NEC PC Engine/TurboGrafx-16", {
DIV_SYSTEM_PCE, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"NES", {
DIV_SYSTEM_NES, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"NES with Konami VRC7", {
DIV_SYSTEM_NES, 64, 0, 0,
DIV_SYSTEM_VRC7, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"NES with Sunsoft 5B", {
DIV_SYSTEM_NES, 64, 0, 0,
DIV_SYSTEM_AY8910, 64, 0, 38,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Mattel Intellivision", {
DIV_SYSTEM_AY8910, 64, 0, 6,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Vectrex", {
DIV_SYSTEM_AY8910, 64, 0, 4,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Neo Geo AES", {
DIV_SYSTEM_YM2610_FULL, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Neo Geo AES (extended channel 2)", {
DIV_SYSTEM_YM2610_FULL_EXT, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Atari 2600/7800", {
DIV_SYSTEM_TIA, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Atari Lynx", {
DIV_SYSTEM_LYNX, 64, 0, 0,
0
}
));
sysCategories.push_back(cat);
cat=FurnaceGUISysCategory("Computers");
cat.systems.push_back(FurnaceGUISysDef(
"Commodore PET", {
DIV_SYSTEM_PET, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Commodore VIC-20", {
DIV_SYSTEM_VIC20, 64, 0, 1,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Commodore 64 (6581 SID)", {
DIV_SYSTEM_C64_6581, 64, 0, 1,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Commodore 64 (8580 SID)", {
DIV_SYSTEM_C64_8580, 64, 0, 1,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Amiga", {
DIV_SYSTEM_AMIGA, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"MSX", {
DIV_SYSTEM_AY8910, 64, 0, 16,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"ZX Spectrum (48K)", {
DIV_SYSTEM_AY8910, 64, 0, 2,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"ZX Spectrum (128K)", {
DIV_SYSTEM_AY8910, 64, 0, 1,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Amstrad CPC", {
DIV_SYSTEM_AY8910, 64, 0, 5,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"SAM Coupé", {
DIV_SYSTEM_SAA1099, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"BBC Micro", {
DIV_SYSTEM_SMS, 64, 0, 6,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"PC (barebones)", {
DIV_SYSTEM_PCSPKR, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"PC + Covox Sound Master", {
DIV_SYSTEM_AY8930, 64, 0, 3,
DIV_SYSTEM_PCSPKR, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"PC + Game Blaster", {
DIV_SYSTEM_SAA1099, 64, -127, 1,
DIV_SYSTEM_SAA1099, 64, 127, 1,
DIV_SYSTEM_PCSPKR, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"PC + AdLib/Sound Blaster", {
DIV_SYSTEM_OPL2, 64, 0, 0,
DIV_SYSTEM_PCSPKR, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"PC + AdLib/Sound Blaster (drums mode)", {
DIV_SYSTEM_OPL2_DRUMS, 64, 0, 0,
DIV_SYSTEM_PCSPKR, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"PC + Sound Blaster Pro 2", {
DIV_SYSTEM_OPL3, 64, 0, 0,
DIV_SYSTEM_PCSPKR, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"PC + Sound Blaster Pro 2 (drums mode)", {
DIV_SYSTEM_OPL3_DRUMS, 64, 0, 0,
DIV_SYSTEM_PCSPKR, 64, 0, 0,
0
}
));
/*
cat.systems.push_back(FurnaceGUISysDef(
"Sharp X68000", {
DIV_SYSTEM_AY8910, 64, 0, 16,
0
}
));*/
sysCategories.push_back(cat);
cat=FurnaceGUISysCategory("Arcade systems");
cat.systems.push_back(FurnaceGUISysDef(
"Bally Midway MCR", {
DIV_SYSTEM_AY8910, 64, 0, 0,
DIV_SYSTEM_AY8910, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Sega Kyugo", {
DIV_SYSTEM_AY8910, 64, 0, 4,
DIV_SYSTEM_AY8910, 64, 0, 4,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Sega OutRun/X Board", {
DIV_SYSTEM_YM2151, 64, 0, 0,
DIV_SYSTEM_SEGAPCM, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Neo Geo MVS", {
DIV_SYSTEM_YM2610_FULL, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Neo Geo MVS (extended channel 2)", {
DIV_SYSTEM_YM2610_FULL_EXT, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Taito Arcade", {
DIV_SYSTEM_YM2610B, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Taito Arcade (extended channel 3)", {
DIV_SYSTEM_YM2610B_EXT, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Capcom CPS-2 (QSound)", {
DIV_SYSTEM_QSOUND, 64, 0, 0,
0
}
));
sysCategories.push_back(cat);
cat=FurnaceGUISysCategory("DefleMask-compatible");
cat.systems.push_back(FurnaceGUISysDef(
"Sega Genesis", {
DIV_SYSTEM_YM2612, 64, 0, 0,
DIV_SYSTEM_SMS, 24, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Sega Genesis (extended channel 3)", {
DIV_SYSTEM_YM2612_EXT, 64, 0, 0,
DIV_SYSTEM_SMS, 24, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Sega Master System", {
DIV_SYSTEM_SMS, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Sega Master System (with FM expansion)", {
DIV_SYSTEM_SMS, 64, 0, 0,
DIV_SYSTEM_OPLL, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Game Boy", {
DIV_SYSTEM_GB, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"NEC PC Engine/TurboGrafx-16", {
DIV_SYSTEM_PCE, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"NES", {
DIV_SYSTEM_NES, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"NES with Konami VRC7", {
DIV_SYSTEM_NES, 64, 0, 0,
DIV_SYSTEM_VRC7, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Commodore 64 (6581 SID)", {
DIV_SYSTEM_C64_6581, 64, 0, 1,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Commodore 64 (8580 SID)", {
DIV_SYSTEM_C64_8580, 64, 0, 1,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Arcade (YM2151 and SegaPCM)", {
DIV_SYSTEM_YM2151, 64, 0, 0,
DIV_SYSTEM_SEGAPCM_COMPAT, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Neo Geo CD", {
DIV_SYSTEM_YM2610, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"Neo Geo CD (extended channel 2)", {
DIV_SYSTEM_YM2610_EXT, 64, 0, 0,
0
}
)); ));
sysCategories.push_back(cat); sysCategories.push_back(cat);

View file

@ -23,6 +23,7 @@
#include "imgui_impl_sdlrenderer.h" #include "imgui_impl_sdlrenderer.h"
#include <SDL.h> #include <SDL.h>
#include <deque> #include <deque>
#include <initializer_list>
#include <map> #include <map>
#include <vector> #include <vector>
@ -405,9 +406,10 @@ struct Particle {
struct FurnaceGUISysDef { struct FurnaceGUISysDef {
const char* name; const char* name;
const int* definition; std::vector<int> definition;
FurnaceGUISysDef(const char* n, const int* def): FurnaceGUISysDef(const char* n, std::initializer_list<int> def):
name(n), definition(def) {} name(n), definition(def) {
}
}; };
struct FurnaceGUISysCategory { struct FurnaceGUISysCategory {
@ -540,7 +542,7 @@ class FurnaceGUI {
char finalLayoutPath[4096]; char finalLayoutPath[4096];
int curIns, curWave, curSample, curOctave, oldRow, oldOrder, oldOrder1, editStep, exportLoops, soloChan, soloTimeout, orderEditMode, orderCursor; int curIns, curWave, curSample, curOctave, oldRow, oldOrder, oldOrder1, editStep, exportLoops, soloChan, soloTimeout, orderEditMode, orderCursor;
int loopOrder, loopRow, loopEnd, isClipping, extraChannelButtons, patNameTarget; int loopOrder, loopRow, loopEnd, isClipping, extraChannelButtons, patNameTarget, newSongCategory;
bool editControlsOpen, ordersOpen, insListOpen, songInfoOpen, patternOpen, insEditOpen; bool editControlsOpen, ordersOpen, insListOpen, songInfoOpen, patternOpen, insEditOpen;
bool waveListOpen, waveEditOpen, sampleListOpen, sampleEditOpen, aboutOpen, settingsOpen; bool waveListOpen, waveEditOpen, sampleListOpen, sampleEditOpen, aboutOpen, settingsOpen;
bool mixerOpen, debugOpen, oscOpen, volMeterOpen, statsOpen, compatFlagsOpen; bool mixerOpen, debugOpen, oscOpen, volMeterOpen, statsOpen, compatFlagsOpen;
@ -552,7 +554,7 @@ class FurnaceGUI {
float peak[2]; float peak[2];
float patChanX[DIV_MAX_CHANS+1]; float patChanX[DIV_MAX_CHANS+1];
float patChanSlideY[DIV_MAX_CHANS+1]; float patChanSlideY[DIV_MAX_CHANS+1];
int* nextDesc; const int* nextDesc;
// bit 31: ctrl // bit 31: ctrl
// bit 30: reserved for SDL scancode mask // bit 30: reserved for SDL scancode mask