GUI: ability to add/del effect cols and EExx value

This commit is contained in:
tildearrow 2021-12-20 19:46:49 -05:00
parent 969d673e0e
commit 7f3885d2b1
5 changed files with 57 additions and 4 deletions

View file

@ -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;
}

View file

@ -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),

View file

@ -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;
}
}

View file

@ -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; i<chans; i++) {
ImGui::TableNextColumn();
snprintf(chanID,256," %s##_CH%d",e->getChannelName(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];

View file

@ -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<SDL_Keycode,int> noteKeys;