GUI: add "Create instrument from sample" option

This commit is contained in:
tildearrow 2022-04-12 03:00:57 -05:00
parent 3b0be2c42a
commit dae7a9a099
5 changed files with 28 additions and 1 deletions

View file

@ -1083,6 +1083,17 @@ void FurnaceGUI::doAction(int what) {
updateSampleTex=true;
}
break;
case GUI_ACTION_SAMPLE_MAKE_INS: {
if (curSample<0 || curSample>=(int)e->song.sample.size()) break;
DivSample* sample=e->song.sample[curSample];
curIns=e->addInstrument(cursor.xCoarse);
e->song.ins[curIns]->type=DIV_INS_AMIGA;
e->song.ins[curIns]->name=sample->name;
e->song.ins[curIns]->amiga.initSample=curSample;
nextWindow=GUI_WINDOW_INS_EDIT;
MARK_MODIFIED;
break;
}
case GUI_ACTION_ORDERS_UP:
if (e->getOrder()>0) {

View file

@ -436,6 +436,7 @@ enum FurnaceGUIActions {
GUI_ACTION_SAMPLE_ZOOM_IN,
GUI_ACTION_SAMPLE_ZOOM_OUT,
GUI_ACTION_SAMPLE_ZOOM_AUTO,
GUI_ACTION_SAMPLE_MAKE_INS,
GUI_ACTION_SAMPLE_MAX,
GUI_ACTION_ORDERS_MIN,

View file

@ -327,6 +327,7 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={
D("SAMPLE_ZOOM_IN", "Zoom in", FURKMOD_CMD|SDLK_EQUALS),
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_MAX", "", NOT_AN_ACTION),
D("ORDERS_MIN", "---Orders", NOT_AN_ACTION),

View file

@ -29,7 +29,6 @@
#include "util.h"
// TODO:
// - add "create instrument using this sample" option
// - .dmc loading
void FurnaceGUI::drawSampleEdit() {
if (nextWindow==GUI_WINDOW_SAMPLE_EDIT) {
@ -528,6 +527,13 @@ void FurnaceGUI::drawSampleEdit() {
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Stop sample preview");
}
ImGui::SameLine();
if (ImGui::Button(ICON_FA_UPLOAD "##MakeIns")) {
doAction(GUI_ACTION_SAMPLE_MAKE_INS);
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Create instrument from sample");
}
ImGui::SameLine();
double zoomPercent=100.0/sampleZoom;
@ -1040,6 +1046,13 @@ void FurnaceGUI::drawSampleEdit() {
ImGui::SetTooltip("Stop sample preview");
}
ImGui::SameLine();
if (ImGui::Button(ICON_FA_UPLOAD "##MakeIns")) {
doAction(GUI_ACTION_SAMPLE_MAKE_INS);
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Create instrument from sample");
}
ImGui::SameLine();
double zoomPercent=100.0/sampleZoom;
ImGui::Text("Zoom");
ImGui::SameLine();

View file

@ -1427,6 +1427,7 @@ void FurnaceGUI::drawSettings() {
UI_KEYBIND_CONFIG(GUI_ACTION_SAMPLE_ZOOM_IN);
UI_KEYBIND_CONFIG(GUI_ACTION_SAMPLE_ZOOM_OUT);
UI_KEYBIND_CONFIG(GUI_ACTION_SAMPLE_ZOOM_AUTO);
UI_KEYBIND_CONFIG(GUI_ACTION_SAMPLE_MAKE_INS);
KEYBIND_CONFIG_END;
ImGui::TreePop();