From 7f3885d2b179bce6e00ea3d65601bbf4ff80a61d Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 20 Dec 2021 19:46:49 -0500 Subject: [PATCH] GUI: ability to add/del effect cols and EExx value --- src/engine/engine.cpp | 11 +++++++++++ src/engine/engine.h | 10 ++++++++++ src/engine/playback.cpp | 2 ++ src/gui/gui.cpp | 35 ++++++++++++++++++++++++++++++++--- src/gui/gui.h | 3 ++- 5 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 0826edad0..14c3d17a5 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -1408,6 +1408,7 @@ void DivEngine::play() { void DivEngine::stop() { isBusy.lock(); playing=false; + extValuePresent=false; isBusy.unlock(); } @@ -1417,6 +1418,8 @@ void DivEngine::reset() { chan[i].volMax=(dispatch->dispatch(DivCommand(DIV_CMD_GET_VOLMAX,i))<<8)|0xff; chan[i].volume=chan[i].volMax; } + extValue=0; + extValuePresent=0; dispatch->reset(); } @@ -1442,6 +1445,14 @@ int DivEngine::getRow() { return curRow; } +bool DivEngine::hasExtValue() { + return extValuePresent; +} + +unsigned char DivEngine::getExtValue() { + return extValue; +} + bool DivEngine::isPlaying() { return playing; } diff --git a/src/engine/engine.h b/src/engine/engine.h index 96e31db50..3d3c955fb 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -77,8 +77,10 @@ class DivEngine { bool speedAB; bool endOfSong; bool consoleMode; + bool extValuePresent; int ticks, cycles, curRow, curOrder, remainingLoops, nextSpeed, clockDrift; int changeOrd, changePos, totalTicks, totalCmds, lastCmds, cmdsPerSecond; + unsigned char extValue; DivStatusView view; DivChannelState chan[17]; DivAudioEngines audioEngine; @@ -204,6 +206,12 @@ class DivEngine { // get current row int getRow(); + // has ext value + bool hasExtValue(); + + // get ext value + unsigned char getExtValue(); + // is playing bool isPlaying(); @@ -273,6 +281,7 @@ class DivEngine { speedAB(false), endOfSong(false), consoleMode(false), + extValuePresent(false), ticks(0), cycles(0), curRow(0), @@ -286,6 +295,7 @@ class DivEngine { totalCmds(0), lastCmds(0), cmdsPerSecond(0), + extValue(0), view(DIV_STATUS_NOTHING), audioEngine(DIV_AUDIO_SDL), bbInLen(0), diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index 7b5e3dbf9..7b8a47fef 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -516,6 +516,8 @@ void DivEngine::processRow(int i, bool afterDelay) { break; case 0xee: // external command //printf("\x1b[1;36m%d: extern command %d\x1b[m\n",i,effectVal); + extValue=effectVal; + extValuePresent=true; break; } } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 25cba3721..8b9ce222f 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -915,6 +915,7 @@ void FurnaceGUI::drawPattern() { sel1.xFine^=sel2.xFine; sel2.xFine^=sel1.xFine; } + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding,ImVec2(0.0f,0.0f)); if (ImGui::Begin("Pattern",&patternOpen)) { ImGui::SetWindowSize(ImVec2(scrW*dpiScale,scrH*dpiScale)); char id[32]; @@ -922,8 +923,10 @@ void FurnaceGUI::drawPattern() { unsigned char ord=e->getOrder(); int chans=e->getChannelCount(e->song.system); ImGui::PushStyleVar(ImGuiStyleVar_CellPadding,ImVec2(0.0f,0.0f)); - if (ImGui::BeginTable("PatternView",chans+1,ImGuiTableFlags_BordersInnerV|ImGuiTableFlags_ScrollX|ImGuiTableFlags_ScrollY|ImGuiTableFlags_NoPadInnerX)) { + if (ImGui::BeginTable("PatternView",chans+2,ImGuiTableFlags_BordersInnerV|ImGuiTableFlags_ScrollX|ImGuiTableFlags_ScrollY|ImGuiTableFlags_NoPadInnerX)) { ImGui::TableSetupColumn("pos",ImGuiTableColumnFlags_WidthFixed); + char chanID[256]; + float lineHeight=(ImGui::GetTextLineHeight()+2*dpiScale); int curRow=e->getRow(); if (e->isPlaying()) updateScroll(curRow); if (nextScroll>-0.5f) { @@ -936,8 +939,9 @@ void FurnaceGUI::drawPattern() { } ImGui::TableNextRow(); ImGui::TableNextColumn(); - char chanID[256]; - float lineHeight=(ImGui::GetTextLineHeight()+2*dpiScale); + if (ImGui::Selectable(extraChannelButtons?" --##ExtraChannelButtons":" ++##ExtraChannelButtons",false,ImGuiSelectableFlags_NoPadWithHalfSpacing,ImVec2(0.0f,lineHeight+2.0f*dpiScale))) { + extraChannelButtons=!extraChannelButtons; + } for (int i=0; igetChannelName(i),i); @@ -947,6 +951,28 @@ void FurnaceGUI::drawPattern() { if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { e->toggleSolo(i); } + if (extraChannelButtons) { + snprintf(chanID,256,"<##_LCH%d",i); + ImGui::BeginDisabled(e->song.pat[i].effectRows<=1); + ImGui::SetCursorPosX(ImGui::GetCursorPosX()+4.0f*dpiScale); + if (ImGui::SmallButton(chanID)) { + e->song.pat[i].effectRows--; + if (e->song.pat[i].effectRows<1) e->song.pat[i].effectRows=1; + } + ImGui::EndDisabled(); + ImGui::SameLine(); + ImGui::BeginDisabled(e->song.pat[i].effectRows>=4); + snprintf(chanID,256,">##_RCH%d",i); + if (ImGui::SmallButton(chanID)) { + e->song.pat[i].effectRows++; + if (e->song.pat[i].effectRows>4) e->song.pat[i].effectRows=4; + } + ImGui::EndDisabled(); + } + } + ImGui::TableNextColumn(); + if (e->hasExtValue()) { + ImGui::TextColored(uiColors[GUI_COLOR_EE_VALUE]," %.2X",e->getExtValue()); } float oneCharSize=ImGui::CalcTextSize("A").x; ImVec2 threeChars=ImVec2(oneCharSize*3.0f,lineHeight); @@ -1099,6 +1125,7 @@ void FurnaceGUI::drawPattern() { ImGui::PopStyleVar(); ImGui::PopFont(); } + ImGui::PopStyleVar(); if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_PATTERN; ImGui::End(); } @@ -2195,6 +2222,7 @@ FurnaceGUI::FurnaceGUI(): settingsOpen(false), selecting(false), curNibble(false), + extraChannelButtons(false), curWindow(GUI_WINDOW_NOTHING), arpMacroScroll(0), macroDragStart(0,0), @@ -2226,6 +2254,7 @@ FurnaceGUI::FurnaceGUI(): uiColors[GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY]=ImVec4(0.5f,1.0f,0.0f,1.0f); uiColors[GUI_COLOR_PATTERN_EFFECT_SYS_SECONDARY]=ImVec4(0.0f,1.0f,0.5f,1.0f); uiColors[GUI_COLOR_PATTERN_EFFECT_MISC]=ImVec4(0.3f,0.3f,1.0f,1.0f); + uiColors[GUI_COLOR_EE_VALUE]=ImVec4(0.0f,1.0f,1.0f,1.0f); for (int i=0; i<64; i++) { ImVec4 col1=uiColors[GUI_COLOR_PATTERN_VOLUME_MIN]; diff --git a/src/gui/gui.h b/src/gui/gui.h index e839516bb..1d5aac88e 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -30,6 +30,7 @@ enum FurnaceGUIColors { GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY, GUI_COLOR_PATTERN_EFFECT_SYS_SECONDARY, GUI_COLOR_PATTERN_EFFECT_MISC, + GUI_COLOR_EE_VALUE, GUI_COLOR_MAX }; @@ -94,7 +95,7 @@ class FurnaceGUI { bool editControlsOpen, ordersOpen, insListOpen, songInfoOpen, patternOpen, insEditOpen; bool waveListOpen, waveEditOpen, sampleListOpen, sampleEditOpen, aboutOpen, settingsOpen; SelectionPoint selStart, selEnd; - bool selecting, curNibble; + bool selecting, curNibble, extraChannelButtons; FurnaceGUIWindows curWindow; std::map noteKeys;