GUI: highlight loop

This commit is contained in:
tildearrow 2022-01-27 01:04:26 -05:00
parent 8edcbc8d39
commit c47851e7c7
4 changed files with 27 additions and 7 deletions

View file

@ -2360,9 +2360,10 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
} }
} }
void DivEngine::walkSong(int& loopOrder, int& loopRow) { void DivEngine::walkSong(int& loopOrder, int& loopRow, int& loopEnd) {
loopOrder=0; loopOrder=0;
loopRow=0; loopRow=0;
loopEnd=-1;
int nextOrder=-1; int nextOrder=-1;
int nextRow=0; int nextRow=0;
int effectVal=0; int effectVal=0;
@ -2378,11 +2379,15 @@ void DivEngine::walkSong(int& loopOrder, int& loopRow) {
effectVal=pat[k]->data[j][5+(l<<1)]; effectVal=pat[k]->data[j][5+(l<<1)];
if (effectVal<0) effectVal=0; if (effectVal<0) effectVal=0;
if (pat[k]->data[j][4+(l<<1)]==0x0d) { if (pat[k]->data[j][4+(l<<1)]==0x0d) {
nextOrder=i+1; if (nextOrder==-1 && i<song.ordersLen-1) {
nextRow=effectVal; nextOrder=i+1;
nextRow=effectVal;
}
} else if (pat[k]->data[j][4+(l<<1)]==0x0b) { } else if (pat[k]->data[j][4+(l<<1)]==0x0b) {
nextOrder=effectVal; if (nextOrder==-1) {
nextRow=0; nextOrder=effectVal;
nextRow=0;
}
} }
} }
} }
@ -2390,6 +2395,7 @@ void DivEngine::walkSong(int& loopOrder, int& loopRow) {
if (nextOrder<=i) { if (nextOrder<=i) {
loopOrder=nextOrder; loopOrder=nextOrder;
loopRow=nextRow; loopRow=nextRow;
loopEnd=i;
return; return;
} }
i=nextOrder-1; i=nextOrder-1;
@ -2407,7 +2413,8 @@ SafeWriter* DivEngine::saveVGM() {
// determine loop point // determine loop point
int loopOrder=0; int loopOrder=0;
int loopRow=0; int loopRow=0;
walkSong(loopOrder,loopRow); int loopEnd=0;
walkSong(loopOrder,loopRow,loopEnd);
logI("loop point: %d %d\n",loopOrder,loopRow); logI("loop point: %d %d\n",loopOrder,loopRow);
curOrder=0; curOrder=0;

View file

@ -262,7 +262,7 @@ class DivEngine {
int calcFreq(int base, int pitch, bool period=false); int calcFreq(int base, int pitch, bool period=false);
// find song loop position // find song loop position
void walkSong(int& loopOrder, int& loopRow); void walkSong(int& loopOrder, int& loopRow, int& loopEnd);
// play // play
void play(); void play();

View file

@ -608,6 +608,8 @@ void FurnaceGUI::drawOrders() {
if (oldOrder1==i) ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0,0x40ffffff); if (oldOrder1==i) ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0,0x40ffffff);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_ROW_INDEX]); ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_ROW_INDEX]);
bool highlightLoop=(i>=loopOrder && i<=loopEnd);
if (highlightLoop) ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg,ImGui::GetColorU32(uiColors[GUI_COLOR_SONG_LOOP]));
if (settings.orderRowsBase==1) { if (settings.orderRowsBase==1) {
snprintf(selID,64,"%.2x##O_S%.2x",i,i); snprintf(selID,64,"%.2x##O_S%.2x",i,i);
} else { } else {
@ -633,6 +635,7 @@ void FurnaceGUI::drawOrders() {
} else { } else {
if (e->song.orders.ord[j][i]<0x7f) e->song.orders.ord[j][i]++; if (e->song.orders.ord[j][i]<0x7f) e->song.orders.ord[j][i]++;
} }
e->walkSong(loopOrder,loopRow,loopEnd);
makeUndo(GUI_ACTION_CHANGE_ORDER); makeUndo(GUI_ACTION_CHANGE_ORDER);
} else { } else {
orderCursor=j; orderCursor=j;
@ -640,6 +643,7 @@ void FurnaceGUI::drawOrders() {
} }
} else { } else {
e->setOrder(i); e->setOrder(i);
e->walkSong(loopOrder,loopRow,loopEnd);
if (orderEditMode!=0) { if (orderEditMode!=0) {
orderCursor=j; orderCursor=j;
curNibble=false; curNibble=false;
@ -657,6 +661,7 @@ void FurnaceGUI::drawOrders() {
} else { } else {
if (e->song.orders.ord[j][i]>0) e->song.orders.ord[j][i]--; if (e->song.orders.ord[j][i]>0) e->song.orders.ord[j][i]--;
} }
e->walkSong(loopOrder,loopRow,loopEnd);
makeUndo(GUI_ACTION_CHANGE_ORDER); makeUndo(GUI_ACTION_CHANGE_ORDER);
} else { } else {
orderCursor=j; orderCursor=j;
@ -664,6 +669,7 @@ void FurnaceGUI::drawOrders() {
} }
} else { } else {
e->setOrder(i); e->setOrder(i);
e->walkSong(loopOrder,loopRow,loopEnd);
if (orderEditMode!=0) { if (orderEditMode!=0) {
orderCursor=j; orderCursor=j;
curNibble=false; curNibble=false;
@ -2583,6 +2589,7 @@ void FurnaceGUI::drawSettings() {
UI_COLOR_CONFIG(GUI_COLOR_ACCENT_PRIMARY,"Primary"); UI_COLOR_CONFIG(GUI_COLOR_ACCENT_PRIMARY,"Primary");
UI_COLOR_CONFIG(GUI_COLOR_ACCENT_SECONDARY,"Secondary"); UI_COLOR_CONFIG(GUI_COLOR_ACCENT_SECONDARY,"Secondary");
UI_COLOR_CONFIG(GUI_COLOR_EDITING,"Editing"); UI_COLOR_CONFIG(GUI_COLOR_EDITING,"Editing");
UI_COLOR_CONFIG(GUI_COLOR_SONG_LOOP,"Song loop");
UI_COLOR_CONFIG(GUI_COLOR_PLAYBACK_STAT,"Playback status"); UI_COLOR_CONFIG(GUI_COLOR_PLAYBACK_STAT,"Playback status");
ImGui::TreePop(); ImGui::TreePop();
} }
@ -2719,6 +2726,7 @@ void FurnaceGUI::commitSettings() {
PUT_UI_COLOR(GUI_COLOR_ACCENT_PRIMARY); PUT_UI_COLOR(GUI_COLOR_ACCENT_PRIMARY);
PUT_UI_COLOR(GUI_COLOR_ACCENT_SECONDARY); PUT_UI_COLOR(GUI_COLOR_ACCENT_SECONDARY);
PUT_UI_COLOR(GUI_COLOR_EDITING); PUT_UI_COLOR(GUI_COLOR_EDITING);
PUT_UI_COLOR(GUI_COLOR_SONG_LOOP);
PUT_UI_COLOR(GUI_COLOR_MACRO_VOLUME); PUT_UI_COLOR(GUI_COLOR_MACRO_VOLUME);
PUT_UI_COLOR(GUI_COLOR_MACRO_PITCH); PUT_UI_COLOR(GUI_COLOR_MACRO_PITCH);
PUT_UI_COLOR(GUI_COLOR_MACRO_OTHER); PUT_UI_COLOR(GUI_COLOR_MACRO_OTHER);
@ -3562,6 +3570,7 @@ void FurnaceGUI::doRedo() {
} }
void FurnaceGUI::play() { void FurnaceGUI::play() {
e->walkSong(loopOrder,loopRow,loopEnd);
e->play(); e->play();
curNibble=false; curNibble=false;
orderNibble=false; orderNibble=false;
@ -3569,6 +3578,7 @@ void FurnaceGUI::play() {
} }
void FurnaceGUI::stop() { void FurnaceGUI::stop() {
e->walkSong(loopOrder,loopRow,loopEnd);
e->stop(); e->stop();
curNibble=false; curNibble=false;
orderNibble=false; orderNibble=false;
@ -3680,6 +3690,7 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
} }
} }
} }
e->walkSong(loopOrder,loopRow,loopEnd);
} }
} catch (std::out_of_range& e) { } catch (std::out_of_range& e) {
} }
@ -4825,6 +4836,7 @@ void FurnaceGUI::applyUISettings() {
GET_UI_COLOR(GUI_COLOR_ACCENT_PRIMARY,ImVec4(0.06f,0.53f,0.98f,1.0f)); GET_UI_COLOR(GUI_COLOR_ACCENT_PRIMARY,ImVec4(0.06f,0.53f,0.98f,1.0f));
GET_UI_COLOR(GUI_COLOR_ACCENT_SECONDARY,ImVec4(0.26f,0.59f,0.98f,1.0f)); GET_UI_COLOR(GUI_COLOR_ACCENT_SECONDARY,ImVec4(0.26f,0.59f,0.98f,1.0f));
GET_UI_COLOR(GUI_COLOR_EDITING,ImVec4(0.2f,0.1f,0.1f,1.0f)); GET_UI_COLOR(GUI_COLOR_EDITING,ImVec4(0.2f,0.1f,0.1f,1.0f));
GET_UI_COLOR(GUI_COLOR_SONG_LOOP,ImVec4(0.3f,0.5f,0.8f,0.4f));
GET_UI_COLOR(GUI_COLOR_MACRO_VOLUME,ImVec4(0.2f,1.0f,0.0f,1.0f)); GET_UI_COLOR(GUI_COLOR_MACRO_VOLUME,ImVec4(0.2f,1.0f,0.0f,1.0f));
GET_UI_COLOR(GUI_COLOR_MACRO_PITCH,ImVec4(1.0f,0.8f,0.0f,1.0f)); GET_UI_COLOR(GUI_COLOR_MACRO_PITCH,ImVec4(1.0f,0.8f,0.0f,1.0f));
GET_UI_COLOR(GUI_COLOR_MACRO_OTHER,ImVec4(0.0f,0.9f,1.0f,1.0f)); GET_UI_COLOR(GUI_COLOR_MACRO_OTHER,ImVec4(0.0f,0.9f,1.0f,1.0f));

View file

@ -15,6 +15,7 @@ enum FurnaceGUIColors {
GUI_COLOR_ACCENT_PRIMARY, GUI_COLOR_ACCENT_PRIMARY,
GUI_COLOR_ACCENT_SECONDARY, GUI_COLOR_ACCENT_SECONDARY,
GUI_COLOR_EDITING, GUI_COLOR_EDITING,
GUI_COLOR_SONG_LOOP,
GUI_COLOR_MACRO_VOLUME, GUI_COLOR_MACRO_VOLUME,
GUI_COLOR_MACRO_PITCH, GUI_COLOR_MACRO_PITCH,
GUI_COLOR_MACRO_OTHER, GUI_COLOR_MACRO_OTHER,