From 202a528477a41697ec2e158d25a00426c547c7fc Mon Sep 17 00:00:00 2001 From: tildearrow Date: Wed, 4 May 2022 23:36:03 -0500 Subject: [PATCH] dev92 - GUI: customizable channel collapsing! --- src/engine/engine.h | 4 ++-- src/engine/fileOps.cpp | 6 ++++++ src/engine/song.h | 4 ++-- src/gui/cursor.cpp | 10 +++++----- src/gui/pattern.cpp | 12 ++++++++++-- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/engine/engine.h b/src/engine/engine.h index 5d6d066c0..87174d974 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -45,8 +45,8 @@ #define BUSY_BEGIN_SOFT softLocked=true; isBusy.lock(); #define BUSY_END isBusy.unlock(); softLocked=false; -#define DIV_VERSION "dev91" -#define DIV_ENGINE_VERSION 91 +#define DIV_VERSION "dev92" +#define DIV_ENGINE_VERSION 92 // for imports #define DIV_VERSION_MOD 0xff01 diff --git a/src/engine/fileOps.cpp b/src/engine/fileOps.cpp index b45baa7ab..7b09ca7d3 100644 --- a/src/engine/fileOps.cpp +++ b/src/engine/fileOps.cpp @@ -1315,6 +1315,12 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) { ds.chanCollapse[i]=reader.readC(); } + if (ds.version<92) { + for (int i=0; i0) ds.chanCollapse[i]=3; + } + } + for (int i=0; i sample; bool chanShow[DIV_MAX_CHANS]; - bool chanCollapse[DIV_MAX_CHANS]; + unsigned char chanCollapse[DIV_MAX_CHANS]; DivInstrument nullIns, nullInsOPLL, nullInsOPL, nullInsQSound; DivWavetable nullWave; @@ -452,7 +452,7 @@ struct DivSong { } for (int i=0; i=e->song.patLen) cursor.y=e->song.patLen-1; - if (e->song.chanCollapse[selEnd.xCoarse]) { + if (e->song.chanCollapse[selStart.xCoarse]==3) { selStart.xFine=0; } - if (e->song.chanCollapse[selEnd.xCoarse]) { + if (e->song.chanCollapse[selEnd.xCoarse] && selEnd.xFine>=(3-e->song.chanCollapse[selEnd.xCoarse])) { selEnd.xFine=2+e->song.pat[cursor.xCoarse].effectCols*2; } @@ -105,7 +105,7 @@ void FurnaceGUI::moveCursor(int x, int y, bool select) { demandScrollX=true; if (x>0) { for (int i=0; i=(e->song.chanCollapse[cursor.xCoarse]?1:(3+e->song.pat[cursor.xCoarse].effectCols*2))) { + if (++cursor.xFine>=(e->song.chanCollapse[cursor.xCoarse]?(4-e->song.chanCollapse[cursor.xCoarse]):(3+e->song.pat[cursor.xCoarse].effectCols*2))) { cursor.xFine=0; if (++cursor.xCoarse>=lastChannel) { if (settings.wrapHorizontal!=0 && !select) { @@ -113,7 +113,7 @@ void FurnaceGUI::moveCursor(int x, int y, bool select) { if (settings.wrapHorizontal==2) y++; } else { cursor.xCoarse=lastChannel-1; - cursor.xFine=e->song.chanCollapse[cursor.xCoarse]?0:(2+e->song.pat[cursor.xCoarse].effectCols*2); + cursor.xFine=e->song.chanCollapse[cursor.xCoarse]?(3-e->song.chanCollapse[cursor.xCoarse]):(2+e->song.pat[cursor.xCoarse].effectCols*2); } } else { while (!e->song.chanShow[cursor.xCoarse]) { @@ -141,7 +141,7 @@ void FurnaceGUI::moveCursor(int x, int y, bool select) { if (cursor.xCoarse<0) break; } if (e->song.chanCollapse[cursor.xCoarse]) { - cursor.xFine=0; + cursor.xFine=3-e->song.chanCollapse[cursor.xCoarse]; } else { cursor.xFine=2+e->song.pat[cursor.xCoarse].effectCols*2; } diff --git a/src/gui/pattern.cpp b/src/gui/pattern.cpp index e171eedff..d284b08fc 100644 --- a/src/gui/pattern.cpp +++ b/src/gui/pattern.cpp @@ -145,7 +145,7 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int ImGui::PopStyleColor(); // the following is only visible when the channel is not collapsed - if (!e->song.chanCollapse[j]) { + if (e->song.chanCollapse[j]<3) { // instrument if (pat->data[i][2]==-1) { ImGui::PushStyleColor(ImGuiCol_Text,inactiveColor); @@ -183,7 +183,9 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int updateSelection(j,1,i); } ImGui::PopStyleColor(); + } + if (e->song.chanCollapse[j]<2) { // volume if (pat->data[i][3]==-1) { sprintf(id,"..##PV_%d_%d",i,j); @@ -215,7 +217,9 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int updateSelection(j,2,i); } ImGui::PopStyleColor(); + } + if (e->song.chanCollapse[j]<1) { // effects for (int k=0; ksong.pat[j].effectCols; k++) { int index=4+(k<<1); @@ -499,7 +503,11 @@ void FurnaceGUI::drawPattern() { snprintf(chanID,2048,"%c##_HCH%d",e->song.chanCollapse[i]?'+':'-',i); ImGui::SetCursorPosX(ImGui::GetCursorPosX()+4.0f*dpiScale); if (ImGui::SmallButton(chanID)) { - e->song.chanCollapse[i]=!e->song.chanCollapse[i]; + if (e->song.chanCollapse[i]==0) { + e->song.chanCollapse[i]=3; + } else if (e->song.chanCollapse[i]>0) { + e->song.chanCollapse[i]--; + } } if (!e->song.chanCollapse[i]) { ImGui::SameLine();