From 98165f5ed273e7e65ffcd97c1613caf5cb7927ed Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 30 Oct 2025 04:35:44 -0500 Subject: [PATCH] ugly cue position editor --- src/gui/refPlayer.cpp | 45 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/gui/refPlayer.cpp b/src/gui/refPlayer.cpp index 716a3cfc3..d3ddd1303 100644 --- a/src/gui/refPlayer.cpp +++ b/src/gui/refPlayer.cpp @@ -124,7 +124,27 @@ void FurnaceGUI::drawRefPlayer() { fp->setPos(0); } if (ImGui::BeginPopupContextItem("Edit Cue Position",ImGuiPopupFlags_MouseButtonRight)) { - ImGui::Text("Edit me"); + ImGui::Text("Set cue position at first order:"); + int cueSeconds=0; + int cueMicros=0; + bool altered=false; + e->getFilePlayerCue(cueSeconds,cueMicros); + // TODO: improve this... + ImGui::SetNextItemWidth(240.0f*dpiScale); + if (ImGui::InputInt(_("Seconds##CuePosS"),&cueSeconds)) { + if (cueSeconds<-3600) cueSeconds=-3600; + if (cueSeconds>3600) cueSeconds=3600; + altered=true; + } + ImGui::SetNextItemWidth(240.0f*dpiScale); + if (ImGui::InputInt(_("Microseconds##CuePosM"),&cueMicros,1000,10000)) { + if (cueMicros<0) cueMicros=0; + if (cueMicros>999999) cueMicros=999999; + altered=true; + } + if (altered) { + e->setFilePlayerCue(cueSeconds,cueMicros); + } if (ImGui::Button("OK")) { ImGui::CloseCurrentPopup(); } @@ -143,7 +163,27 @@ void FurnaceGUI::drawRefPlayer() { if (ImGui::Button(ICON_FA_PAUSE "##Pause")) { fp->stop(); } - ImGui::SetItemTooltip(_("pause")); + if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { + // try setting cue pos + ssize_t curSeconds=0; + unsigned int curMicros=0; + fp->getPosSeconds(curSeconds,curMicros); + DivSongTimestamps::Timestamp rowTS=e->curSubSong->ts.getTimes(curOrder,0); + if (rowTS.seconds==-1) { + showError("the first row of this order isn't going to play."); + } else { + // calculate difference and set cue pos + curSeconds-=rowTS.seconds; + int curMicrosI=curMicros-rowTS.micros; + while (curMicrosI<0) { + curMicrosI+=1000000; + curSeconds--; + } + e->setFilePlayerCue(curSeconds,curMicrosI); + fp->stop(); + } + } + ImGui::SetItemTooltip(_("pause\n(right click to set cue position and pause)")); popToggleColors(); } else { if (ImGui::Button(ICON_FA_PLAY "##Play")) { @@ -175,6 +215,7 @@ void FurnaceGUI::drawRefPlayer() { if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { fp->setVolume(0.0f); } + ImGui::SetItemTooltip(_("right click to reset")); //ImGui::Text("Memory usage: %" PRIu64 "K",fp->getMemUsage()>>10); }