From 7baf1d471f69e770a5792e9364376d0514711fdf Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 29 May 2022 00:04:33 -0500 Subject: [PATCH 01/10] fire! --- extern/backward/backward.hpp | 30 ++++++++++++++++++++++++++++-- src/main.cpp | 8 +++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/extern/backward/backward.hpp b/extern/backward/backward.hpp index e778d58f3..b92a7b7f7 100644 --- a/extern/backward/backward.hpp +++ b/extern/backward/backward.hpp @@ -4253,7 +4253,7 @@ public: } #ifdef _WIN32 - MessageBox(NULL,"Error","Furnace has crashed! please report this to the issue tracker immediately:\r\nhttps://github.com/tildearrow/furnace/issues/new\r\n\r\na file called furnace_crash.txt will be created in your user directory.\r\nthis will be important for locating the origin of the crash.",MB_OK|MB_ICONERROR); + MessageBox(NULL,"Furnace has crashed! please report this to the issue tracker immediately:\r\nhttps://github.com/tildearrow/furnace/issues/new\r\n\r\na file called furnace_crash.txt will be created in your user directory.\r\nthis will be important for locating the origin of the crash.","Error",MB_OK|MB_ICONERROR); std::string crashLocation; char* userProfile=getenv("USERPROFILE"); if (userProfile==NULL) { @@ -4284,7 +4284,7 @@ public: failedPrinter.print(st, str); str+="\r\ncould not open furnace_crash.txt!\r\nplease take a screenshot of this error message box!"; fprintf(stderr,"NOTICE: could not open furnace_crash.txt!\n"); - MessageBox(NULL,"Error",str.c_str(),MB_OK|MB_ICONERROR); + MessageBox(NULL,str.c_str(),"Error",MB_OK|MB_ICONERROR); #endif } @@ -4490,6 +4490,32 @@ private: printer.address = true; printer.print(st, std::cerr); + +#ifdef _WIN32 + MessageBox(NULL,"Furnace has crashed! please report this to the issue tracker immediately:\r\nhttps://github.com/tildearrow/furnace/issues/new\r\n\r\na file called furnace_crash.txt will be created in your user directory.\r\nthis will be important for locating the origin of the crash.","Error",MB_OK|MB_ICONERROR); + std::string crashLocation; + char* userProfile=getenv("USERPROFILE"); + if (userProfile==NULL) { + crashLocation="C:\\furnace_crash.txt"; + } else { + crashLocation=userProfile; + crashLocation+="\\furnace_crash.txt"; + } + FILE* crashDump=fopen(crashLocation.c_str(),"w"); +#else + FILE* crashDump=fopen("/tmp/furnace_crash.txt","w"); +#endif + + if (crashDump!=NULL) { + Printer printer; + printer.address = true; + printer.print(st, crashDump); + fclose(crashDump); + } else { +#ifdef _WIN32 + MessageBox(NULL,"could not do a crash dump!! :<","Error",MB_OK|MB_ICONERROR); +#endif + } } }; diff --git a/src/main.cpp b/src/main.cpp index 995fa6f04..8cc01aa2a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -306,11 +306,13 @@ int main(int argc, char** argv) { } } - if (!sh.loaded()) { #ifdef _WIN32 - MessageBox(NULL,"Warning","crash backtrace not available!",MB_OK|MB_ICONWARNING); -#endif + if (!sh.loaded()) { + MessageBox(NULL,"crash backtrace not available!","Warning",MB_OK|MB_ICONWARNING); + } else { + MessageBox(NULL,"it will work","Notice",MB_OK|MB_ICONINFORMATION); } +#endif e.setConsoleMode(consoleMode); From f49f5e8171fbb9b15c08e20ab0dfaf36e9e64cb6 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 29 May 2022 00:15:49 -0500 Subject: [PATCH 02/10] temporarily kill MSVC --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8fd08833b..ff6a1b132 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,8 +18,6 @@ jobs: strategy: matrix: config: - - { name: 'Windows MSVC x86', os: windows-latest, compiler: msvc, arch: x86 } - - { name: 'Windows MSVC x86_64', os: windows-latest, compiler: msvc, arch: x86_64 } - { name: 'Windows MinGW x86', os: ubuntu-20.04, compiler: mingw, arch: x86 } - { name: 'Windows MinGW x86_64', os: ubuntu-20.04, compiler: mingw, arch: x86_64 } - { name: 'macOS', os: macos-latest } From 81aa803f014933515d0e7e6d41a87b8a466c7ad6 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 29 May 2022 00:22:29 -0500 Subject: [PATCH 03/10] MSVC: ughh, f**k you, you d**khead. --- .github/workflows/build.yml | 2 ++ src/main.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ff6a1b132..8fd08833b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,6 +18,8 @@ jobs: strategy: matrix: config: + - { name: 'Windows MSVC x86', os: windows-latest, compiler: msvc, arch: x86 } + - { name: 'Windows MSVC x86_64', os: windows-latest, compiler: msvc, arch: x86_64 } - { name: 'Windows MinGW x86', os: ubuntu-20.04, compiler: mingw, arch: x86 } - { name: 'Windows MinGW x86_64', os: ubuntu-20.04, compiler: mingw, arch: x86_64 } - { name: 'macOS', os: macos-latest } diff --git a/src/main.cpp b/src/main.cpp index 8cc01aa2a..870ee6a44 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,6 +17,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifdef HAVE_BACKWARD +#include "../extern/backward/backward.hpp" +#endif + #include #include #include @@ -39,10 +43,6 @@ #include "gui/gui.h" #endif -#ifdef HAVE_BACKWARD -#include "../extern/backward/backward.hpp" -#endif - DivEngine e; #ifdef HAVE_GUI From 6d487afb49f6bd27b1fc00ecd2acc58d7b73f559 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 29 May 2022 00:43:44 -0500 Subject: [PATCH 04/10] Revert "MSVC: ughh, f**k you, you d**khead." This reverts commit 81aa803f014933515d0e7e6d41a87b8a466c7ad6. --- .github/workflows/build.yml | 2 -- src/main.cpp | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8fd08833b..ff6a1b132 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,8 +18,6 @@ jobs: strategy: matrix: config: - - { name: 'Windows MSVC x86', os: windows-latest, compiler: msvc, arch: x86 } - - { name: 'Windows MSVC x86_64', os: windows-latest, compiler: msvc, arch: x86_64 } - { name: 'Windows MinGW x86', os: ubuntu-20.04, compiler: mingw, arch: x86 } - { name: 'Windows MinGW x86_64', os: ubuntu-20.04, compiler: mingw, arch: x86_64 } - { name: 'macOS', os: macos-latest } diff --git a/src/main.cpp b/src/main.cpp index 870ee6a44..8cc01aa2a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,10 +17,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifdef HAVE_BACKWARD -#include "../extern/backward/backward.hpp" -#endif - #include #include #include @@ -43,6 +39,10 @@ #include "gui/gui.h" #endif +#ifdef HAVE_BACKWARD +#include "../extern/backward/backward.hpp" +#endif + DivEngine e; #ifdef HAVE_GUI From c12c723091497d0075bd7fda4ef9f16e85f43e7e Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 29 May 2022 00:43:46 -0500 Subject: [PATCH 05/10] Revert "temporarily kill MSVC" This reverts commit f49f5e8171fbb9b15c08e20ab0dfaf36e9e64cb6. --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ff6a1b132..8fd08833b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,6 +18,8 @@ jobs: strategy: matrix: config: + - { name: 'Windows MSVC x86', os: windows-latest, compiler: msvc, arch: x86 } + - { name: 'Windows MSVC x86_64', os: windows-latest, compiler: msvc, arch: x86_64 } - { name: 'Windows MinGW x86', os: ubuntu-20.04, compiler: mingw, arch: x86 } - { name: 'Windows MinGW x86_64', os: ubuntu-20.04, compiler: mingw, arch: x86_64 } - { name: 'macOS', os: macos-latest } From 7687a640008d3eeeda736882ff5693cfa8f9e5b2 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 29 May 2022 00:44:17 -0500 Subject: [PATCH 06/10] Revert "fire!" This reverts commit 7baf1d471f69e770a5792e9364376d0514711fdf. --- extern/backward/backward.hpp | 30 ++---------------------------- src/main.cpp | 8 +++----- 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/extern/backward/backward.hpp b/extern/backward/backward.hpp index b92a7b7f7..e778d58f3 100644 --- a/extern/backward/backward.hpp +++ b/extern/backward/backward.hpp @@ -4253,7 +4253,7 @@ public: } #ifdef _WIN32 - MessageBox(NULL,"Furnace has crashed! please report this to the issue tracker immediately:\r\nhttps://github.com/tildearrow/furnace/issues/new\r\n\r\na file called furnace_crash.txt will be created in your user directory.\r\nthis will be important for locating the origin of the crash.","Error",MB_OK|MB_ICONERROR); + MessageBox(NULL,"Error","Furnace has crashed! please report this to the issue tracker immediately:\r\nhttps://github.com/tildearrow/furnace/issues/new\r\n\r\na file called furnace_crash.txt will be created in your user directory.\r\nthis will be important for locating the origin of the crash.",MB_OK|MB_ICONERROR); std::string crashLocation; char* userProfile=getenv("USERPROFILE"); if (userProfile==NULL) { @@ -4284,7 +4284,7 @@ public: failedPrinter.print(st, str); str+="\r\ncould not open furnace_crash.txt!\r\nplease take a screenshot of this error message box!"; fprintf(stderr,"NOTICE: could not open furnace_crash.txt!\n"); - MessageBox(NULL,str.c_str(),"Error",MB_OK|MB_ICONERROR); + MessageBox(NULL,"Error",str.c_str(),MB_OK|MB_ICONERROR); #endif } @@ -4490,32 +4490,6 @@ private: printer.address = true; printer.print(st, std::cerr); - -#ifdef _WIN32 - MessageBox(NULL,"Furnace has crashed! please report this to the issue tracker immediately:\r\nhttps://github.com/tildearrow/furnace/issues/new\r\n\r\na file called furnace_crash.txt will be created in your user directory.\r\nthis will be important for locating the origin of the crash.","Error",MB_OK|MB_ICONERROR); - std::string crashLocation; - char* userProfile=getenv("USERPROFILE"); - if (userProfile==NULL) { - crashLocation="C:\\furnace_crash.txt"; - } else { - crashLocation=userProfile; - crashLocation+="\\furnace_crash.txt"; - } - FILE* crashDump=fopen(crashLocation.c_str(),"w"); -#else - FILE* crashDump=fopen("/tmp/furnace_crash.txt","w"); -#endif - - if (crashDump!=NULL) { - Printer printer; - printer.address = true; - printer.print(st, crashDump); - fclose(crashDump); - } else { -#ifdef _WIN32 - MessageBox(NULL,"could not do a crash dump!! :<","Error",MB_OK|MB_ICONERROR); -#endif - } } }; diff --git a/src/main.cpp b/src/main.cpp index 8cc01aa2a..995fa6f04 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -306,13 +306,11 @@ int main(int argc, char** argv) { } } -#ifdef _WIN32 if (!sh.loaded()) { - MessageBox(NULL,"crash backtrace not available!","Warning",MB_OK|MB_ICONWARNING); - } else { - MessageBox(NULL,"it will work","Notice",MB_OK|MB_ICONINFORMATION); - } +#ifdef _WIN32 + MessageBox(NULL,"Warning","crash backtrace not available!",MB_OK|MB_ICONWARNING); #endif + } e.setConsoleMode(consoleMode); From cdcf87c773d330f2a3191c2b3edc29790f125b1a Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 29 May 2022 00:44:21 -0500 Subject: [PATCH 07/10] Revert "fudge and bread" This reverts commit 6afe29682d0d3687e6188b5562b9cec1df9fd148. --- CMakeLists.txt | 2 +- src/backtrace.cpp | 8 -------- src/main.cpp | 11 ----------- 3 files changed, 1 insertion(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 347cc872c..b23a99706 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -509,7 +509,7 @@ endif() set(USED_SOURCES ${ENGINE_SOURCES} ${AUDIO_SOURCES} src/main.cpp) if (USE_BACKWARD) - list(APPEND DEPENDENCIES_DEFINES HAVE_BACKWARD) + list(APPEND USED_SOURCES src/backtrace.cpp) if (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") list(APPEND DEPENDENCIES_LIBRARIES dbghelp psapi) endif() diff --git a/src/backtrace.cpp b/src/backtrace.cpp index 402cb647b..68a648ff9 100644 --- a/src/backtrace.cpp +++ b/src/backtrace.cpp @@ -39,12 +39,4 @@ namespace backward { backward::SignalHandling sh; -void checkInitialized() { - if (!sh.loaded()) { -#ifdef _WIN32 - MessageBox(NULL,"Warning","crash backtrace not available!",MB_OK|MB_ICONWARNING); -#endif - } -} - } // namespace backward diff --git a/src/main.cpp b/src/main.cpp index 995fa6f04..079058528 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,10 +39,6 @@ #include "gui/gui.h" #endif -#ifdef HAVE_BACKWARD -#include "../extern/backward/backward.hpp" -#endif - DivEngine e; #ifdef HAVE_GUI @@ -246,7 +242,6 @@ void initParams() { // TODO: CoInitializeEx on Windows? // TODO: add crash log int main(int argc, char** argv) { - backward::SignalHandling sh; initLog(); #if !(defined(__APPLE__) || defined(_WIN32) || defined(ANDROID)) // workaround for Wayland HiDPI issue @@ -306,12 +301,6 @@ int main(int argc, char** argv) { } } - if (!sh.loaded()) { -#ifdef _WIN32 - MessageBox(NULL,"Warning","crash backtrace not available!",MB_OK|MB_ICONWARNING); -#endif - } - e.setConsoleMode(consoleMode); #ifdef _WIN32 From 957e35af0b43cd88c311a49cdf8cf7e81f3fa407 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 29 May 2022 00:48:19 -0500 Subject: [PATCH 08/10] finally --- extern/backward/backward.hpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/extern/backward/backward.hpp b/extern/backward/backward.hpp index e778d58f3..5edda65ad 100644 --- a/extern/backward/backward.hpp +++ b/extern/backward/backward.hpp @@ -4490,6 +4490,38 @@ private: printer.address = true; printer.print(st, std::cerr); + +#ifdef _WIN32 + MessageBox(NULL,"Furnace has crashed! please report this to the issue tracker immediately:\r\nhttps://github.com/tildearrow/furnace/issues/new\r\n\r\na file called furnace_crash.txt will be created in your user directory.\r\nthis will be important for locating the origin of the crash.","Error",MB_OK|MB_ICONERROR); + std::string crashLocation; + char* userProfile=getenv("USERPROFILE"); + if (userProfile==NULL) { + crashLocation="furnace_crash.txt"; + } else { + crashLocation=userProfile; + crashLocation+="\\furnace_crash.txt"; + } + FILE* crashDump=fopen(crashLocation.c_str(),"w"); +#else + FILE* crashDump=fopen("/tmp/furnace_crash.txt","w"); +#endif + + if (crashDump!=NULL) { + Printer printer; + printer.address = true; + printer.print(st, crashDump); + fclose(crashDump); + } else { +#ifdef _WIN32 + std::string str; + //Printer failedPrinter; + //failedPrinter.address = true; + //failedPrinter.print(st, str); + str+="\r\ncould not open furnace_crash.txt!\r\nplease take a screenshot of this error message box!"; + fprintf(stderr,"NOTICE: could not open furnace_crash.txt!\n"); + MessageBox(NULL,str.c_str(),"Error",MB_OK|MB_ICONERROR); +#endif + } } }; From 84d4ca63c2e92407c30aee78a915f0978ec2ed39 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 29 May 2022 02:13:08 -0500 Subject: [PATCH 09/10] GUI: sample editor preview in selection --- TODO.md | 1 - src/engine/engine.cpp | 6 ++++-- src/engine/engine.h | 7 +++++-- src/engine/playback.cpp | 10 +++++----- src/gui/gui.cpp | 15 ++++++++++++++- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/TODO.md b/TODO.md index c8d7684ab..bb039549d 100644 --- a/TODO.md +++ b/TODO.md @@ -6,7 +6,6 @@ - the last three compat flags - add OPL drum instrument type - Game Boy envelope macro/sequence -- sample editor preview in selection - rewrite the system name detection function anyway - unified data view - volume commands should work on Game Boy diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 146944150..812159e78 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -1471,8 +1471,10 @@ int DivEngine::getEffectiveSampleRate(int rate) { return rate; } -void DivEngine::previewSample(int sample, int note) { +void DivEngine::previewSample(int sample, int note, int pStart, int pEnd) { BUSY_BEGIN; + sPreview.pBegin=pStart; + sPreview.pEnd=pEnd; if (sample<0 || sample>=(int)song.sample.size()) { sPreview.sample=-1; sPreview.pos=0; @@ -1488,7 +1490,7 @@ void DivEngine::previewSample(int sample, int note) { if (rate<100) rate=100; blip_set_rates(samp_bb,rate,got.rate); samp_prevSample=0; - sPreview.pos=0; + sPreview.pos=(sPreview.pBegin>=0)?sPreview.pBegin:0; sPreview.sample=sample; sPreview.wave=-1; BUSY_END; diff --git a/src/engine/engine.h b/src/engine/engine.h index ceb786a78..1ad8eb2e1 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -339,10 +339,13 @@ class DivEngine { int sample; int wave; unsigned int pos; + int pBegin, pEnd; SamplePreview(): sample(-1), wave(-1), - pos(0) {} + pos(0), + pBegin(-1), + pEnd(-1) {} } sPreview; short vibTable[64]; @@ -525,7 +528,7 @@ class DivEngine { void syncReset(); // trigger sample preview - void previewSample(int sample, int note=-1); + void previewSample(int sample, int note=-1, int pStart=-1, int pEnd=-1); void stopSamplePreview(); // trigger wave preview diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index 3b11ab494..73e122383 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -1159,7 +1159,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi DivSample* s=song.sample[sPreview.sample]; for (size_t i=0; i=s->samples) { + if (sPreview.pos>=s->samples || (sPreview.pEnd>=0 && (int)sPreview.pos>=sPreview.pEnd)) { samp_temp=0; } else { samp_temp=s->data16[sPreview.pos++]; @@ -1167,15 +1167,15 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi blip_add_delta(samp_bb,i,samp_temp-samp_prevSample); samp_prevSample=samp_temp; - if (sPreview.pos>=s->samples) { - if (s->loopStart>=0 && s->loopStart<(int)s->samples) { + if (sPreview.pos>=s->samples || (sPreview.pEnd>=0 && (int)sPreview.pos>=sPreview.pEnd)) { + if (s->loopStart>=0 && s->loopStart<(int)s->samples && (int)sPreview.pos>=s->loopStart) { sPreview.pos=s->loopStart; } } } - if (sPreview.pos>=s->samples) { - if (s->loopStart>=0 && s->loopStart<(int)s->samples) { + if (sPreview.pos>=s->samples || (sPreview.pEnd>=0 && (int)sPreview.pos>=sPreview.pEnd)) { + if (s->loopStart>=0 && s->loopStart<(int)s->samples && (int)sPreview.pos>=s->loopStart) { sPreview.pos=s->loopStart; } else { sPreview.sample=-1; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 2bf6888fa..d4c56deda 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -2243,7 +2243,20 @@ int FurnaceGUI::processEvent(SDL_Event* ev) { int key=noteKeys.at(ev->key.keysym.scancode); int num=12*curOctave+key; if (key!=100 && key!=101 && key!=102) { - e->previewSample(curSample,num); + int pStart=-1; + int pEnd=-1; + if (curWindow==GUI_WINDOW_SAMPLE_EDIT) { + if (sampleSelStart!=sampleSelEnd) { + pStart=sampleSelStart; + pEnd=sampleSelEnd; + if (pStart>pEnd) { + pStart^=pEnd; + pEnd^=pStart; + pStart^=pEnd; + } + } + } + e->previewSample(curSample,num,pStart,pEnd); samplePreviewOn=true; samplePreviewKey=ev->key.keysym.scancode; samplePreviewNote=num; From 5f4db8ca0bf8ca26571d50e4ffeceaa370de6b8b Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 29 May 2022 02:59:11 -0500 Subject: [PATCH 10/10] GUI: improve unified data view --- TODO.md | 2 - src/gui/dataList.cpp | 155 ++++++++++++++++++++++++++++++++++++------- src/gui/gui.cpp | 10 ++- 3 files changed, 138 insertions(+), 29 deletions(-) diff --git a/TODO.md b/TODO.md index bb039549d..172cc8179 100644 --- a/TODO.md +++ b/TODO.md @@ -7,10 +7,8 @@ - add OPL drum instrument type - Game Boy envelope macro/sequence - rewrite the system name detection function anyway -- unified data view - volume commands should work on Game Boy - add another FM editor layout -- try to find out why does VSlider not accept keyboard input - if macros have release, note off should release them - add ability to select a column by double clicking - add ability to move selection by dragging diff --git a/src/gui/dataList.cpp b/src/gui/dataList.cpp index 0c0457ea3..4e0979972 100644 --- a/src/gui/dataList.cpp +++ b/src/gui/dataList.cpp @@ -39,44 +39,124 @@ void FurnaceGUI::drawInsList() { if (ImGui::Begin("Instruments",&insListOpen,globalWinFlags)) { if (settings.unifiedDataView) settings.horizontalDataView=0; if (ImGui::Button(ICON_FA_PLUS "##InsAdd")) { - doAction(GUI_ACTION_INS_LIST_ADD); + if (!settings.unifiedDataView) doAction(GUI_ACTION_INS_LIST_ADD); + } + if (settings.unifiedDataView) { + if (ImGui::BeginPopupContextItem("UnifiedAdd",ImGuiMouseButton_Left)) { + if (ImGui::MenuItem("instrument")) { + doAction(GUI_ACTION_INS_LIST_ADD); + } + if (ImGui::MenuItem("wavetable")) { + doAction(GUI_ACTION_WAVE_LIST_ADD); + } + if (ImGui::MenuItem("sample (create)")) { + doAction(GUI_ACTION_SAMPLE_LIST_ADD); + } + ImGui::EndPopup(); + } } ImGui::SameLine(); if (ImGui::Button(ICON_FA_FILES_O "##InsClone")) { - doAction(GUI_ACTION_INS_LIST_DUPLICATE); + if (!settings.unifiedDataView) doAction(GUI_ACTION_INS_LIST_DUPLICATE); + } + if (settings.unifiedDataView) { + if (ImGui::BeginPopupContextItem("UnifiedClone",ImGuiMouseButton_Left)) { + if (ImGui::MenuItem("instrument")) { + doAction(GUI_ACTION_INS_LIST_DUPLICATE); + } + if (ImGui::MenuItem("wavetable")) { + doAction(GUI_ACTION_WAVE_LIST_DUPLICATE); + } + if (ImGui::MenuItem("sample")) { + doAction(GUI_ACTION_SAMPLE_LIST_DUPLICATE); + } + ImGui::EndPopup(); + } } ImGui::SameLine(); if (ImGui::Button(ICON_FA_FOLDER_OPEN "##InsLoad")) { - doAction(GUI_ACTION_INS_LIST_OPEN); + if (!settings.unifiedDataView) doAction(GUI_ACTION_INS_LIST_OPEN); } - if (ImGui::BeginPopupContextItem("InsOpenOpt")) { - if (ImGui::MenuItem("replace...")) { - doAction((curIns>=0 && curIns<(int)e->song.ins.size())?GUI_ACTION_INS_LIST_OPEN_REPLACE:GUI_ACTION_INS_LIST_OPEN); + if (settings.unifiedDataView) { + if (ImGui::BeginPopupContextItem("UnifiedLoad",ImGuiMouseButton_Left)) { + if (ImGui::MenuItem("instrument")) { + doAction(GUI_ACTION_INS_LIST_OPEN); + } + if (ImGui::MenuItem("instrument (replace...)")) { + doAction((curIns>=0 && curIns<(int)e->song.ins.size())?GUI_ACTION_INS_LIST_OPEN_REPLACE:GUI_ACTION_INS_LIST_OPEN); + } + if (ImGui::MenuItem("wavetable")) { + doAction(GUI_ACTION_WAVE_LIST_OPEN); + } + if (ImGui::MenuItem("sample")) { + doAction(GUI_ACTION_SAMPLE_LIST_OPEN); + } + ImGui::Separator(); + if (ImGui::MenuItem("instrument from TX81Z")) { + doAction(GUI_ACTION_TX81Z_REQUEST); + } + ImGui::EndPopup(); } - ImGui::Separator(); - if (ImGui::MenuItem("load from TX81Z")) { - doAction(GUI_ACTION_TX81Z_REQUEST); + } else { + if (ImGui::BeginPopupContextItem("InsOpenOpt")) { + if (ImGui::MenuItem("replace...")) { + doAction((curIns>=0 && curIns<(int)e->song.ins.size())?GUI_ACTION_INS_LIST_OPEN_REPLACE:GUI_ACTION_INS_LIST_OPEN); + } + ImGui::Separator(); + if (ImGui::MenuItem("load from TX81Z")) { + doAction(GUI_ACTION_TX81Z_REQUEST); + } + ImGui::EndPopup(); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Open (insert; right-click to replace)"); } - ImGui::EndPopup(); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Open (insert; right-click to replace)"); } ImGui::SameLine(); if (ImGui::Button(ICON_FA_FLOPPY_O "##InsSave")) { - doAction(GUI_ACTION_INS_LIST_SAVE); + if (!settings.unifiedDataView) doAction(GUI_ACTION_INS_LIST_SAVE); } - ImGui::SameLine(); - if (ImGui::ArrowButton("InsUp",ImGuiDir_Up)) { - doAction(GUI_ACTION_INS_LIST_MOVE_UP); + if (settings.unifiedDataView) { + if (ImGui::BeginPopupContextItem("UnifiedSave",ImGuiMouseButton_Left)) { + if (ImGui::MenuItem("instrument")) { + doAction(GUI_ACTION_INS_LIST_SAVE); + } + if (ImGui::MenuItem("wavetable")) { + doAction(GUI_ACTION_WAVE_LIST_SAVE); + } + if (ImGui::MenuItem("sample")) { + doAction(GUI_ACTION_SAMPLE_LIST_SAVE); + } + ImGui::EndPopup(); + } } - ImGui::SameLine(); - if (ImGui::ArrowButton("InsDown",ImGuiDir_Down)) { - doAction(GUI_ACTION_INS_LIST_MOVE_DOWN); + if (!settings.unifiedDataView) { + ImGui::SameLine(); + if (ImGui::ArrowButton("InsUp",ImGuiDir_Up)) { + doAction(GUI_ACTION_INS_LIST_MOVE_UP); + } + ImGui::SameLine(); + if (ImGui::ArrowButton("InsDown",ImGuiDir_Down)) { + doAction(GUI_ACTION_INS_LIST_MOVE_DOWN); + } } ImGui::SameLine(); if (ImGui::Button(ICON_FA_TIMES "##InsDelete")) { - doAction(GUI_ACTION_INS_LIST_DELETE); + if (!settings.unifiedDataView) doAction(GUI_ACTION_INS_LIST_DELETE); + } + if (settings.unifiedDataView) { + if (ImGui::BeginPopupContextItem("UnifiedDelete",ImGuiMouseButton_Left)) { + if (ImGui::MenuItem("instrument")) { + doAction(GUI_ACTION_INS_LIST_DELETE); + } + if (ImGui::MenuItem("wavetable")) { + doAction(GUI_ACTION_WAVE_LIST_DELETE); + } + if (ImGui::MenuItem("sample")) { + doAction(GUI_ACTION_SAMPLE_LIST_DELETE); + } + ImGui::EndPopup(); + } } ImGui::Separator(); int availableRows=ImGui::GetContentRegionAvail().y/ImGui::GetFrameHeight(); @@ -98,6 +178,7 @@ void FurnaceGUI::drawInsList() { int curRow=0; for (int i=-1; i<(int)e->song.ins.size(); i++) { + ImGui::PushID(i); String name=ICON_FA_CIRCLE_O " - None -"; const char* insType="Bug!"; if (i>=0) { @@ -250,13 +331,13 @@ void FurnaceGUI::drawInsList() { curIns=i; wavePreviewInit=true; } + ImGui::PopStyleColor(); if (wantScrollList && curIns==i) ImGui::SetScrollHereY(); if (settings.insFocusesPattern && patternOpen && ImGui::IsItemActivated()) { nextWindow=GUI_WINDOW_PATTERN; curIns=i; wavePreviewInit=true; } - ImGui::PopStyleColor(); if (ImGui::IsItemHovered() && i>=0) { ImGui::SetTooltip("%s",insType); if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { @@ -264,9 +345,25 @@ void FurnaceGUI::drawInsList() { nextWindow=GUI_WINDOW_INS_EDIT; } } + if (i>=0) { + if (ImGui::BeginPopupContextItem("InsRightMenu")) { + curIns=i; + if (ImGui::MenuItem("replace...")) { + doAction((curIns>=0 && curIns<(int)e->song.ins.size())?GUI_ACTION_INS_LIST_OPEN_REPLACE:GUI_ACTION_INS_LIST_OPEN); + } + if (ImGui::MenuItem("save")) { + doAction(GUI_ACTION_INS_LIST_SAVE); + } + if (ImGui::MenuItem("delete")) { + doAction(GUI_ACTION_INS_LIST_DELETE); + } + ImGui::EndPopup(); + } + } if (settings.horizontalDataView) { if (++curRow>=availableRows) curRow=0; } + ImGui::PopID(); } if (settings.unifiedDataView) { @@ -297,9 +394,14 @@ void FurnaceGUI::drawInsList() { void FurnaceGUI::drawWaveList() { if (nextWindow==GUI_WINDOW_WAVE_LIST) { waveListOpen=true; - ImGui::SetNextWindowFocus(); + if (settings.unifiedDataView) { + ImGui::SetWindowFocus("Instruments"); + } else { + ImGui::SetNextWindowFocus(); + } nextWindow=GUI_WINDOW_NOTHING; } + if (settings.unifiedDataView) return; if (!waveListOpen) return; if (ImGui::Begin("Wavetables",&waveListOpen,globalWinFlags)) { if (ImGui::Button(ICON_FA_PLUS "##WaveAdd")) { @@ -342,9 +444,14 @@ void FurnaceGUI::drawWaveList() { void FurnaceGUI::drawSampleList() { if (nextWindow==GUI_WINDOW_SAMPLE_LIST) { sampleListOpen=true; - ImGui::SetNextWindowFocus(); + if (settings.unifiedDataView) { + ImGui::SetWindowFocus("Instruments"); + } else { + ImGui::SetNextWindowFocus(); + } nextWindow=GUI_WINDOW_NOTHING; } + if (settings.unifiedDataView) return; if (!sampleListOpen) return; if (ImGui::Begin("Samples",&sampleListOpen,globalWinFlags)) { if (ImGui::Button(ICON_FA_FILE "##SampleAdd")) { diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index d4c56deda..40f00e91e 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -2960,9 +2960,13 @@ bool FurnaceGUI::loop() { if (ImGui::BeginMenu("window")) { if (ImGui::MenuItem("song information",BIND_FOR(GUI_ACTION_WINDOW_SONG_INFO),songInfoOpen)) songInfoOpen=!songInfoOpen; if (ImGui::MenuItem("subsongs",BIND_FOR(GUI_ACTION_WINDOW_SUBSONGS),subSongsOpen)) subSongsOpen=!subSongsOpen; - if (ImGui::MenuItem("instruments",BIND_FOR(GUI_ACTION_WINDOW_INS_LIST),insListOpen)) insListOpen=!insListOpen; - if (ImGui::MenuItem("wavetables",BIND_FOR(GUI_ACTION_WINDOW_WAVE_LIST),waveListOpen)) waveListOpen=!waveListOpen; - if (ImGui::MenuItem("samples",BIND_FOR(GUI_ACTION_WINDOW_SAMPLE_LIST),sampleListOpen)) sampleListOpen=!sampleListOpen; + if (settings.unifiedDataView) { + if (ImGui::MenuItem("assets",BIND_FOR(GUI_ACTION_WINDOW_INS_LIST),insListOpen)) insListOpen=!insListOpen; + } else { + if (ImGui::MenuItem("instruments",BIND_FOR(GUI_ACTION_WINDOW_INS_LIST),insListOpen)) insListOpen=!insListOpen; + if (ImGui::MenuItem("wavetables",BIND_FOR(GUI_ACTION_WINDOW_WAVE_LIST),waveListOpen)) waveListOpen=!waveListOpen; + if (ImGui::MenuItem("samples",BIND_FOR(GUI_ACTION_WINDOW_SAMPLE_LIST),sampleListOpen)) sampleListOpen=!sampleListOpen; + } if (ImGui::MenuItem("orders",BIND_FOR(GUI_ACTION_WINDOW_ORDERS),ordersOpen)) ordersOpen=!ordersOpen; if (ImGui::MenuItem("pattern",BIND_FOR(GUI_ACTION_WINDOW_PATTERN),patternOpen)) patternOpen=!patternOpen; if (ImGui::MenuItem("mixer",BIND_FOR(GUI_ACTION_WINDOW_MIXER),mixerOpen)) mixerOpen=!mixerOpen;