implement channel hiding, names and song comment

This commit is contained in:
tildearrow 2022-02-05 01:48:35 -05:00
parent 2e157d7b22
commit 088e49a3f4
5 changed files with 103 additions and 5 deletions

View file

@ -844,6 +844,7 @@ const DivInstrumentType chanPrefType[42][24]={
const char* DivEngine::getChannelName(int chan) { const char* DivEngine::getChannelName(int chan) {
if (chan<0 || chan>chans) return "??"; if (chan<0 || chan>chans) return "??";
if (!song.chanName[chan].empty()) return song.chanName[chan].c_str();
switch (sysOfChan[chan]) { switch (sysOfChan[chan]) {
case DIV_SYSTEM_NULL: case DIV_SYSTEM_YMU759: case DIV_SYSTEM_NULL: case DIV_SYSTEM_YMU759:
return chanNames[0][dispatchChanOfChan[chan]]; return chanNames[0][dispatchChanOfChan[chan]];
@ -974,6 +975,7 @@ const char* DivEngine::getChannelName(int chan) {
const char* DivEngine::getChannelShortName(int chan) { const char* DivEngine::getChannelShortName(int chan) {
if (chan<0 || chan>chans) return "??"; if (chan<0 || chan>chans) return "??";
if (!song.chanShortName[chan].empty()) return song.chanShortName[chan].c_str();
switch (sysOfChan[chan]) { switch (sysOfChan[chan]) {
case DIV_SYSTEM_NULL: case DIV_SYSTEM_YMU759: case DIV_SYSTEM_NULL: case DIV_SYSTEM_YMU759:
return chanShortNames[0][dispatchChanOfChan[chan]]; return chanShortNames[0][dispatchChanOfChan[chan]];
@ -2167,6 +2169,26 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
ds.pat[i].effectRows=reader.readC(); ds.pat[i].effectRows=reader.readC();
} }
if (ds.version>=39) {
for (int i=0; i<tchans; i++) {
song.chanShow[i]=reader.readC();
}
for (int i=0; i<tchans; i++) {
song.chanCollapse[i]=reader.readC();
}
for (int i=0; i<tchans; i++) {
song.chanName[i]=reader.readString();
}
for (int i=0; i<tchans; i++) {
song.chanShortName[i]=reader.readString();
}
song.notes=reader.readString();
}
// read instruments // read instruments
for (int i=0; i<ds.insLen; i++) { for (int i=0; i<ds.insLen; i++) {
DivInstrument* ins=new DivInstrument; DivInstrument* ins=new DivInstrument;
@ -2535,6 +2557,24 @@ SafeWriter* DivEngine::saveFur() {
w->writeC(song.pat[i].effectRows); w->writeC(song.pat[i].effectRows);
} }
for (int i=0; i<chans; i++) {
w->writeC(song.chanShow[i]);
}
for (int i=0; i<chans; i++) {
w->writeC(song.chanCollapse[i]);
}
for (int i=0; i<chans; i++) {
w->writeString(song.chanName[i],false);
}
for (int i=0; i<chans; i++) {
w->writeString(song.chanShortName[i],false);
}
w->writeString(song.notes,false);
/// INSTRUMENT /// INSTRUMENT
for (int i=0; i<song.insLen; i++) { for (int i=0; i<song.insLen; i++) {
DivInstrument* ins=song.ins[i]; DivInstrument* ins=song.ins[i];

View file

@ -11,8 +11,8 @@
#include <map> #include <map>
#include <queue> #include <queue>
#define DIV_VERSION "0.5.2pre2" #define DIV_VERSION "0.5.2pre3"
#define DIV_ENGINE_VERSION 38 #define DIV_ENGINE_VERSION 39
enum DivStatusView { enum DivStatusView {
DIV_STATUS_NOTHING=0, DIV_STATUS_NOTHING=0,

View file

@ -192,6 +192,11 @@ struct DivSong {
// legacy song information // legacy song information
String carrier, composer, vendor, category, writer, arranger, copyright, manGroup, manInfo, createdDate, revisionDate; String carrier, composer, vendor, category, writer, arranger, copyright, manGroup, manInfo, createdDate, revisionDate;
// other things
String chanName[DIV_MAX_CHANS];
String chanShortName[DIV_MAX_CHANS];
String notes;
// highlight // highlight
unsigned char hilightA, hilightB; unsigned char hilightA, hilightB;
@ -217,6 +222,9 @@ struct DivSong {
std::vector<DivWavetable*> wave; std::vector<DivWavetable*> wave;
std::vector<DivSample*> sample; std::vector<DivSample*> sample;
bool chanShow[DIV_MAX_CHANS];
bool chanCollapse[DIV_MAX_CHANS];
DivInstrument nullIns; DivInstrument nullIns;
DivWavetable nullWave; DivWavetable nullWave;
@ -262,6 +270,10 @@ struct DivSong {
systemPan[i]=0; systemPan[i]=0;
systemFlags[i]=0; systemFlags[i]=0;
} }
for (int i=0; i<DIV_MAX_CHANS; i++) {
chanShow[i]=true;
chanCollapse[i]=false;
}
system[0]=DIV_SYSTEM_GENESIS; system[0]=DIV_SYSTEM_GENESIS;
} }
}; };

View file

@ -995,7 +995,11 @@ void FurnaceGUI::drawOrders() {
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,ImVec2(1.0f*dpiScale,1.0f*dpiScale)); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,ImVec2(1.0f*dpiScale,1.0f*dpiScale));
ImGui::Columns(2,NULL,false); ImGui::Columns(2,NULL,false);
ImGui::SetColumnWidth(-1,regionX-24.0f*dpiScale); ImGui::SetColumnWidth(-1,regionX-24.0f*dpiScale);
if (ImGui::BeginTable("OrdersTable",1+e->getTotalChannelCount(),ImGuiTableFlags_SizingStretchSame|ImGuiTableFlags_ScrollX|ImGuiTableFlags_ScrollY)) { int displayChans=0;
for (int i=0; i<e->getTotalChannelCount(); i++) {
if (e->song.chanShow[i]) displayChans++;
}
if (ImGui::BeginTable("OrdersTable",1+displayChans,ImGuiTableFlags_SizingStretchSame|ImGuiTableFlags_ScrollX|ImGuiTableFlags_ScrollY)) {
ImGui::PushFont(patFont); ImGui::PushFont(patFont);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,prevSpacing); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,prevSpacing);
ImGui::TableSetupScrollFreeze(1,1); ImGui::TableSetupScrollFreeze(1,1);
@ -1010,6 +1014,7 @@ void FurnaceGUI::drawOrders() {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_ROW_INDEX]); ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_ROW_INDEX]);
for (int i=0; i<e->getTotalChannelCount(); i++) { for (int i=0; i<e->getTotalChannelCount(); i++) {
if (!e->song.chanShow[i]) continue;
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text("%s",e->getChannelShortName(i)); ImGui::Text("%s",e->getChannelShortName(i));
} }
@ -1033,6 +1038,7 @@ void FurnaceGUI::drawOrders() {
} }
ImGui::PopStyleColor(); ImGui::PopStyleColor();
for (int j=0; j<e->getTotalChannelCount(); j++) { for (int j=0; j<e->getTotalChannelCount(); j++) {
if (!e->song.chanShow[j]) continue;
ImGui::TableNextColumn(); ImGui::TableNextColumn();
snprintf(selID,64,"%.2X##O_%.2x_%.2x",e->song.orders.ord[j][i],j,i); snprintf(selID,64,"%.2X##O_%.2x_%.2x",e->song.orders.ord[j][i],j,i);
if (ImGui::Selectable(selID,(orderEditMode!=0 && curOrder==i && orderCursor==j))) { if (ImGui::Selectable(selID,(orderEditMode!=0 && curOrder==i && orderCursor==j))) {
@ -2581,11 +2587,15 @@ void FurnaceGUI::drawPattern() {
unsigned char ord=e->isPlaying()?oldOrder:e->getOrder(); unsigned char ord=e->isPlaying()?oldOrder:e->getOrder();
oldOrder=e->getOrder(); oldOrder=e->getOrder();
int chans=e->getTotalChannelCount(); int chans=e->getTotalChannelCount();
int displayChans=0;
for (int i=0; i<chans; i++) {
if (e->song.chanShow[i]) displayChans++;
}
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding,ImVec2(0.0f,0.0f)); ImGui::PushStyleVar(ImGuiStyleVar_CellPadding,ImVec2(0.0f,0.0f));
ImGui::PushStyleColor(ImGuiCol_Header,uiColors[GUI_COLOR_PATTERN_SELECTION]); ImGui::PushStyleColor(ImGuiCol_Header,uiColors[GUI_COLOR_PATTERN_SELECTION]);
ImGui::PushStyleColor(ImGuiCol_HeaderHovered,uiColors[GUI_COLOR_PATTERN_SELECTION_HOVER]); ImGui::PushStyleColor(ImGuiCol_HeaderHovered,uiColors[GUI_COLOR_PATTERN_SELECTION_HOVER]);
ImGui::PushStyleColor(ImGuiCol_HeaderActive,uiColors[GUI_COLOR_PATTERN_SELECTION_ACTIVE]); ImGui::PushStyleColor(ImGuiCol_HeaderActive,uiColors[GUI_COLOR_PATTERN_SELECTION_ACTIVE]);
if (ImGui::BeginTable("PatternView",chans+2,ImGuiTableFlags_BordersInnerV|ImGuiTableFlags_ScrollX|ImGuiTableFlags_ScrollY|ImGuiTableFlags_NoPadInnerX)) { if (ImGui::BeginTable("PatternView",displayChans+2,ImGuiTableFlags_BordersInnerV|ImGuiTableFlags_ScrollX|ImGuiTableFlags_ScrollY|ImGuiTableFlags_NoPadInnerX)) {
ImGui::TableSetupColumn("pos",ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("pos",ImGuiTableColumnFlags_WidthFixed);
char chanID[256]; char chanID[256];
float lineHeight=(ImGui::GetTextLineHeight()+2*dpiScale); float lineHeight=(ImGui::GetTextLineHeight()+2*dpiScale);
@ -2603,6 +2613,7 @@ void FurnaceGUI::drawPattern() {
} }
ImGui::TableSetupScrollFreeze(1,1); ImGui::TableSetupScrollFreeze(1,1);
for (int i=0; i<chans; i++) { for (int i=0; i<chans; i++) {
if (!e->song.chanShow[i]) continue;
ImGui::TableSetupColumn(fmt::sprintf("c%d",i).c_str(),ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn(fmt::sprintf("c%d",i).c_str(),ImGuiTableColumnFlags_WidthFixed);
} }
ImGui::TableNextRow(); ImGui::TableNextRow();
@ -2611,6 +2622,7 @@ void FurnaceGUI::drawPattern() {
extraChannelButtons=!extraChannelButtons; extraChannelButtons=!extraChannelButtons;
} }
for (int i=0; i<chans; i++) { for (int i=0; i<chans; i++) {
if (!e->song.chanShow[i]) continue;
ImGui::TableNextColumn(); ImGui::TableNextColumn();
snprintf(chanID,256," %s##_CH%d",e->getChannelName(i),i); snprintf(chanID,256," %s##_CH%d",e->getChannelName(i),i);
bool muted=e->isChannelMuted(i); bool muted=e->isChannelMuted(i);
@ -2701,6 +2713,7 @@ void FurnaceGUI::drawPattern() {
ImGui::TextColored(uiColors[GUI_COLOR_PATTERN_ROW_INDEX],"%3d ",i); ImGui::TextColored(uiColors[GUI_COLOR_PATTERN_ROW_INDEX],"%3d ",i);
} }
for (int j=0; j<chans; j++) { for (int j=0; j<chans; j++) {
if (!e->song.chanShow[j]) continue;
int chanVolMax=e->getMaxVolumeChan(j); int chanVolMax=e->getMaxVolumeChan(j);
DivPattern* pat=e->song.pat[j].getPattern(e->song.orders.ord[j][ord],true); DivPattern* pat=e->song.pat[j].getPattern(e->song.orders.ord[j][ord],true);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
@ -3811,6 +3824,33 @@ void FurnaceGUI::drawPiano() {
void FurnaceGUI::drawNotes() { void FurnaceGUI::drawNotes() {
if (!notesOpen) return; if (!notesOpen) return;
if (ImGui::Begin("Song Comments",&notesOpen)) { if (ImGui::Begin("Song Comments",&notesOpen)) {
ImGui::InputTextMultiline("##SongNotes",&e->song.notes,ImGui::GetContentRegionAvail());
}
ImGui::End();
}
void FurnaceGUI::drawChannels() {
if (!channelsOpen) return;
if (ImGui::Begin("Channels",&channelsOpen)) {
if (ImGui::BeginTable("ChannelList",3)) {
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed,0.0);
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.0);
ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthFixed,48.0f*dpiScale);
for (int i=0; i<e->getTotalChannelCount(); i++) {
ImGui::PushID(i);
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Checkbox("##Visible",&e->song.chanShow[i]);
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
ImGui::InputTextWithHint("##ChanName",e->getChannelName(i),&e->song.chanName[i]);
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
ImGui::InputTextWithHint("##ChanShortName",e->getChannelShortName(i),&e->song.chanShortName[i]);
ImGui::PopID();
}
ImGui::EndTable();
}
} }
ImGui::End(); ImGui::End();
} }
@ -5665,6 +5705,7 @@ bool FurnaceGUI::loop() {
if (ImGui::MenuItem("oscilloscope")) oscOpen=!oscOpen; if (ImGui::MenuItem("oscilloscope")) oscOpen=!oscOpen;
if (ImGui::MenuItem("volume meter")) volMeterOpen=!volMeterOpen; if (ImGui::MenuItem("volume meter")) volMeterOpen=!volMeterOpen;
if (ImGui::MenuItem("statistics")) statsOpen=!statsOpen; if (ImGui::MenuItem("statistics")) statsOpen=!statsOpen;
if (ImGui::MenuItem("channels")) channelsOpen=!channelsOpen;
if (ImGui::MenuItem("compatibility flags")) compatFlagsOpen=!compatFlagsOpen; if (ImGui::MenuItem("compatibility flags")) compatFlagsOpen=!compatFlagsOpen;
if (ImGui::MenuItem("piano/input pad")) pianoOpen=!pianoOpen; if (ImGui::MenuItem("piano/input pad")) pianoOpen=!pianoOpen;
if (ImGui::MenuItem("song comments")) notesOpen=!notesOpen; if (ImGui::MenuItem("song comments")) notesOpen=!notesOpen;
@ -5714,6 +5755,7 @@ bool FurnaceGUI::loop() {
drawCompatFlags(); drawCompatFlags();
drawPiano(); drawPiano();
drawNotes(); drawNotes();
drawChannels();
if (ImGuiFileDialog::Instance()->Display("FileDialog",ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove,ImVec2(600.0f*dpiScale,400.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale))) { if (ImGuiFileDialog::Instance()->Display("FileDialog",ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove,ImVec2(600.0f*dpiScale,400.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale))) {
//ImGui::GetIO().ConfigFlags&=~ImGuiConfigFlags_NavEnableKeyboard; //ImGui::GetIO().ConfigFlags&=~ImGuiConfigFlags_NavEnableKeyboard;
@ -6226,6 +6268,7 @@ bool FurnaceGUI::init() {
compatFlagsOpen=e->getConfBool("compatFlagsOpen",false); compatFlagsOpen=e->getConfBool("compatFlagsOpen",false);
pianoOpen=e->getConfBool("pianoOpen",false); pianoOpen=e->getConfBool("pianoOpen",false);
notesOpen=e->getConfBool("notesOpen",false); notesOpen=e->getConfBool("notesOpen",false);
channelsOpen=e->getConfBool("channelsOpen",false);
syncSettings(); syncSettings();
@ -6335,6 +6378,7 @@ bool FurnaceGUI::finish() {
e->setConf("compatFlagsOpen",compatFlagsOpen); e->setConf("compatFlagsOpen",compatFlagsOpen);
e->setConf("pianoOpen",pianoOpen); e->setConf("pianoOpen",pianoOpen);
e->setConf("notesOpen",notesOpen); e->setConf("notesOpen",notesOpen);
e->setConf("channelsOpen",channelsOpen);
// commit last window size // commit last window size
e->setConf("lastWindowWidth",scrW); e->setConf("lastWindowWidth",scrW);
@ -6401,6 +6445,7 @@ FurnaceGUI::FurnaceGUI():
compatFlagsOpen(false), compatFlagsOpen(false),
pianoOpen(false), pianoOpen(false),
notesOpen(false), notesOpen(false),
channelsOpen(false),
selecting(false), selecting(false),
curNibble(false), curNibble(false),
orderNibble(false), orderNibble(false),

View file

@ -265,7 +265,7 @@ class FurnaceGUI {
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;
bool pianoOpen, notesOpen; bool pianoOpen, notesOpen, channelsOpen;
SelectionPoint selStart, selEnd, cursor; SelectionPoint selStart, selEnd, cursor;
bool selecting, curNibble, orderNibble, extraChannelButtons, followOrders, followPattern, changeAllOrders; bool selecting, curNibble, orderNibble, extraChannelButtons, followOrders, followPattern, changeAllOrders;
FurnaceGUIWindows curWindow; FurnaceGUIWindows curWindow;
@ -354,6 +354,7 @@ class FurnaceGUI {
void drawCompatFlags(); void drawCompatFlags();
void drawPiano(); void drawPiano();
void drawNotes(); void drawNotes();
void drawChannels();
void drawAbout(); void drawAbout();
void drawSettings(); void drawSettings();
void drawDebug(); void drawDebug();