diff --git a/TODO.md b/TODO.md index 7634bc9e1..01ce81708 100644 --- a/TODO.md +++ b/TODO.md @@ -3,12 +3,10 @@ - additional YM2612 features - CSM - MSM6258 pitch and clock select -- MSM6295 clock select - the last three compat flags - add OPL drum instrument type - Game Boy envelope macro/sequence - drag-and-drop ins/wave/sample loading -- "set loop" in right click menu of sample editor - sample editor preview in selection - rewrite the system name detection function anyway - unified data view diff --git a/src/gui/doAction.cpp b/src/gui/doAction.cpp index e4f7cd0d1..a83c646da 100644 --- a/src/gui/doAction.cpp +++ b/src/gui/doAction.cpp @@ -1231,6 +1231,22 @@ void FurnaceGUI::doAction(int what) { } break; } + case GUI_ACTION_SAMPLE_SET_LOOP: { + if (curSample<0 || curSample>=(int)e->song.sample.size()) break; + DivSample* sample=e->song.sample[curSample]; + sample->prepareUndo(true); + e->lockEngine([this,sample]() { + SAMPLE_OP_BEGIN; + + sample->trim(0,end); + sample->loopStart=start; + updateSampleTex=true; + + e->renderSamples(); + }); + MARK_MODIFIED; + break; + } case GUI_ACTION_ORDERS_UP: if (curOrder>0) { diff --git a/src/gui/gui.h b/src/gui/gui.h index 93f4835fe..8f1f9d1d5 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -491,6 +491,7 @@ enum FurnaceGUIActions { GUI_ACTION_SAMPLE_ZOOM_OUT, GUI_ACTION_SAMPLE_ZOOM_AUTO, GUI_ACTION_SAMPLE_MAKE_INS, + GUI_ACTION_SAMPLE_SET_LOOP, GUI_ACTION_SAMPLE_MAX, GUI_ACTION_ORDERS_MIN, diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index ffb60c434..4172836d5 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -631,6 +631,7 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={ D("SAMPLE_ZOOM_OUT", "Zoom out", FURKMOD_CMD|SDLK_MINUS), D("SAMPLE_ZOOM_AUTO", "Toggle auto-zoom", FURKMOD_CMD|SDLK_0), D("SAMPLE_MAKE_INS", "Create instrument from sample", 0), + D("SAMPLE_SET_LOOP", "Set loop to selection", FURKMOD_CMD|SDLK_l), D("SAMPLE_MAX", "", NOT_AN_ACTION), D("ORDERS_MIN", "---Orders", NOT_AN_ACTION), diff --git a/src/gui/sampleEdit.cpp b/src/gui/sampleEdit.cpp index 327f93291..19fd75963 100644 --- a/src/gui/sampleEdit.cpp +++ b/src/gui/sampleEdit.cpp @@ -1247,6 +1247,10 @@ void FurnaceGUI::drawSampleEdit() { if (ImGui::MenuItem("select all",BIND_FOR(GUI_ACTION_SAMPLE_SELECT_ALL))) { doAction(GUI_ACTION_SAMPLE_SELECT_ALL); } + ImGui::Separator(); + if (ImGui::MenuItem("set loop to selection",BIND_FOR(GUI_ACTION_SAMPLE_SET_LOOP))) { + doAction(GUI_ACTION_SAMPLE_SET_LOOP); + } ImGui::EndPopup(); } diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 3c71d157e..78c81e2cb 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -1835,6 +1835,7 @@ void FurnaceGUI::drawSettings() { UI_KEYBIND_CONFIG(GUI_ACTION_SAMPLE_ZOOM_OUT); UI_KEYBIND_CONFIG(GUI_ACTION_SAMPLE_ZOOM_AUTO); UI_KEYBIND_CONFIG(GUI_ACTION_SAMPLE_MAKE_INS); + UI_KEYBIND_CONFIG(GUI_ACTION_SAMPLE_SET_LOOP); KEYBIND_CONFIG_END; ImGui::TreePop();