GUI: implement instrument load replace
This commit is contained in:
parent
6aefd392ff
commit
99a313b684
|
@ -518,6 +518,9 @@ void FurnaceGUI::doAction(int what) {
|
||||||
case GUI_ACTION_INS_LIST_OPEN:
|
case GUI_ACTION_INS_LIST_OPEN:
|
||||||
openFileDialog(GUI_FILE_INS_OPEN);
|
openFileDialog(GUI_FILE_INS_OPEN);
|
||||||
break;
|
break;
|
||||||
|
case GUI_ACTION_INS_LIST_OPEN_REPLACE:
|
||||||
|
openFileDialog(GUI_FILE_INS_OPEN_REPLACE);
|
||||||
|
break;
|
||||||
case GUI_ACTION_INS_LIST_SAVE:
|
case GUI_ACTION_INS_LIST_SAVE:
|
||||||
if (curIns>=0 && curIns<(int)e->song.ins.size()) openFileDialog(GUI_FILE_INS_SAVE);
|
if (curIns>=0 && curIns<(int)e->song.ins.size()) openFileDialog(GUI_FILE_INS_SAVE);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1288,7 +1288,14 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case GUI_FILE_INS_OPEN:
|
case GUI_FILE_INS_OPEN:
|
||||||
|
case GUI_FILE_INS_OPEN_REPLACE:
|
||||||
prevIns=-3;
|
prevIns=-3;
|
||||||
|
if (prevInsData!=NULL) {
|
||||||
|
delete prevInsData;
|
||||||
|
prevInsData=NULL;
|
||||||
|
}
|
||||||
|
prevInsData=new DivInstrument;
|
||||||
|
*prevInsData=*e->getIns(curIns);
|
||||||
if (!dirExists(workingDirIns)) workingDirIns=getHomeDir();
|
if (!dirExists(workingDirIns)) workingDirIns=getHomeDir();
|
||||||
hasOpened=fileDialog->openLoad(
|
hasOpened=fileDialog->openLoad(
|
||||||
"Load Instrument",
|
"Load Instrument",
|
||||||
|
@ -1300,12 +1307,21 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
|
||||||
[this](const char* path) {
|
[this](const char* path) {
|
||||||
std::vector<DivInstrument*> instruments=e->instrumentFromFile(path);
|
std::vector<DivInstrument*> instruments=e->instrumentFromFile(path);
|
||||||
if (!instruments.empty()) {
|
if (!instruments.empty()) {
|
||||||
|
if (curFileDialog==GUI_FILE_INS_OPEN_REPLACE) {
|
||||||
|
if (prevIns==-3) {
|
||||||
|
prevIns=curIns;
|
||||||
|
}
|
||||||
|
if (prevIns>=0 && prevIns<=(int)e->song.ins.size()) {
|
||||||
|
*e->song.ins[prevIns]=*instruments[0];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
e->loadTempIns(instruments[0]);
|
e->loadTempIns(instruments[0]);
|
||||||
if (curIns!=-2) {
|
if (curIns!=-2) {
|
||||||
prevIns=curIns;
|
prevIns=curIns;
|
||||||
}
|
}
|
||||||
curIns=-2;
|
curIns=-2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (DivInstrument* i: instruments) delete i;
|
for (DivInstrument* i: instruments) delete i;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -2911,8 +2927,18 @@ bool FurnaceGUI::loop() {
|
||||||
if (fileDialog->render(ImVec2(600.0f*dpiScale,400.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale))) {
|
if (fileDialog->render(ImVec2(600.0f*dpiScale,400.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale))) {
|
||||||
bool openOpen=false;
|
bool openOpen=false;
|
||||||
//ImGui::GetIO().ConfigFlags&=~ImGuiConfigFlags_NavEnableKeyboard;
|
//ImGui::GetIO().ConfigFlags&=~ImGuiConfigFlags_NavEnableKeyboard;
|
||||||
if (curFileDialog==GUI_FILE_INS_OPEN && prevIns!=-3) {
|
if ((curFileDialog==GUI_FILE_INS_OPEN || curFileDialog==GUI_FILE_INS_OPEN_REPLACE) && prevIns!=-3) {
|
||||||
|
if (curFileDialog==GUI_FILE_INS_OPEN_REPLACE) {
|
||||||
|
if (prevInsData!=NULL) {
|
||||||
|
logI("try");
|
||||||
|
if (prevIns>=0 && prevIns<(int)e->song.ins.size()) {
|
||||||
|
logI("replace");
|
||||||
|
*e->song.ins[prevIns]=*prevInsData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
curIns=prevIns;
|
curIns=prevIns;
|
||||||
|
}
|
||||||
prevIns=-3;
|
prevIns=-3;
|
||||||
}
|
}
|
||||||
switch (curFileDialog) {
|
switch (curFileDialog) {
|
||||||
|
@ -2922,6 +2948,7 @@ bool FurnaceGUI::loop() {
|
||||||
workingDirSong=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
workingDirSong=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
||||||
break;
|
break;
|
||||||
case GUI_FILE_INS_OPEN:
|
case GUI_FILE_INS_OPEN:
|
||||||
|
case GUI_FILE_INS_OPEN_REPLACE:
|
||||||
case GUI_FILE_INS_SAVE:
|
case GUI_FILE_INS_SAVE:
|
||||||
workingDirIns=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
workingDirIns=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
||||||
break;
|
break;
|
||||||
|
@ -3101,6 +3128,25 @@ bool FurnaceGUI::loop() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case GUI_FILE_INS_OPEN_REPLACE: {
|
||||||
|
std::vector<DivInstrument*> instruments=e->instrumentFromFile(copyOfName.c_str());
|
||||||
|
if (!instruments.empty()) {
|
||||||
|
if (!e->getWarnings().empty()) {
|
||||||
|
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
||||||
|
}
|
||||||
|
if (curIns>=0 && curIns<(int)e->song.ins.size()) {
|
||||||
|
*e->song.ins[0]=*instruments[0];
|
||||||
|
} else {
|
||||||
|
showError("...but you haven't selected an instrument!");
|
||||||
|
}
|
||||||
|
for (DivInstrument* i: instruments) {
|
||||||
|
delete i;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
showError("cannot load instrument! ("+e->getLastError()+")");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case GUI_FILE_WAVE_OPEN:
|
case GUI_FILE_WAVE_OPEN:
|
||||||
e->addWaveFromFile(copyOfName.c_str());
|
e->addWaveFromFile(copyOfName.c_str());
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
|
@ -3816,6 +3862,7 @@ FurnaceGUI::FurnaceGUI():
|
||||||
patFont(NULL),
|
patFont(NULL),
|
||||||
bigFont(NULL),
|
bigFont(NULL),
|
||||||
fontRange(NULL),
|
fontRange(NULL),
|
||||||
|
prevInsData(NULL),
|
||||||
curIns(0),
|
curIns(0),
|
||||||
curWave(0),
|
curWave(0),
|
||||||
curSample(0),
|
curSample(0),
|
||||||
|
|
|
@ -239,6 +239,7 @@ enum FurnaceGUIFileDialogs {
|
||||||
GUI_FILE_SAVE,
|
GUI_FILE_SAVE,
|
||||||
GUI_FILE_SAVE_DMF_LEGACY,
|
GUI_FILE_SAVE_DMF_LEGACY,
|
||||||
GUI_FILE_INS_OPEN,
|
GUI_FILE_INS_OPEN,
|
||||||
|
GUI_FILE_INS_OPEN_REPLACE,
|
||||||
GUI_FILE_INS_SAVE,
|
GUI_FILE_INS_SAVE,
|
||||||
GUI_FILE_WAVE_OPEN,
|
GUI_FILE_WAVE_OPEN,
|
||||||
GUI_FILE_WAVE_SAVE,
|
GUI_FILE_WAVE_SAVE,
|
||||||
|
@ -406,6 +407,7 @@ enum FurnaceGUIActions {
|
||||||
GUI_ACTION_INS_LIST_ADD,
|
GUI_ACTION_INS_LIST_ADD,
|
||||||
GUI_ACTION_INS_LIST_DUPLICATE,
|
GUI_ACTION_INS_LIST_DUPLICATE,
|
||||||
GUI_ACTION_INS_LIST_OPEN,
|
GUI_ACTION_INS_LIST_OPEN,
|
||||||
|
GUI_ACTION_INS_LIST_OPEN_REPLACE,
|
||||||
GUI_ACTION_INS_LIST_SAVE,
|
GUI_ACTION_INS_LIST_SAVE,
|
||||||
GUI_ACTION_INS_LIST_MOVE_UP,
|
GUI_ACTION_INS_LIST_MOVE_UP,
|
||||||
GUI_ACTION_INS_LIST_MOVE_DOWN,
|
GUI_ACTION_INS_LIST_MOVE_DOWN,
|
||||||
|
@ -947,6 +949,8 @@ class FurnaceGUI {
|
||||||
|
|
||||||
char finalLayoutPath[4096];
|
char finalLayoutPath[4096];
|
||||||
|
|
||||||
|
DivInstrument* prevInsData;
|
||||||
|
|
||||||
int curIns, curWave, curSample, curOctave, curOrder, prevIns, oldRow, oldOrder, oldOrder1, editStep, exportLoops, soloChan, soloTimeout, orderEditMode, orderCursor;
|
int curIns, curWave, curSample, curOctave, curOrder, prevIns, oldRow, oldOrder, oldOrder1, editStep, exportLoops, soloChan, soloTimeout, orderEditMode, orderCursor;
|
||||||
int loopOrder, loopRow, loopEnd, isClipping, extraChannelButtons, patNameTarget, newSongCategory, latchTarget;
|
int loopOrder, loopRow, loopEnd, isClipping, extraChannelButtons, patNameTarget, newSongCategory, latchTarget;
|
||||||
int wheelX, wheelY;
|
int wheelX, wheelY;
|
||||||
|
|
|
@ -560,6 +560,7 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={
|
||||||
D("INS_LIST_ADD", "Add", SDLK_INSERT),
|
D("INS_LIST_ADD", "Add", SDLK_INSERT),
|
||||||
D("INS_LIST_DUPLICATE", "Duplicate", FURKMOD_CMD|SDLK_d),
|
D("INS_LIST_DUPLICATE", "Duplicate", FURKMOD_CMD|SDLK_d),
|
||||||
D("INS_LIST_OPEN", "Open", 0),
|
D("INS_LIST_OPEN", "Open", 0),
|
||||||
|
D("INS_LIST_OPEN_REPLACE", "Open (replace current)", 0),
|
||||||
D("INS_LIST_SAVE", "Save", 0),
|
D("INS_LIST_SAVE", "Save", 0),
|
||||||
D("INS_LIST_MOVE_UP", "Move up", FURKMOD_SHIFT|SDLK_UP),
|
D("INS_LIST_MOVE_UP", "Move up", FURKMOD_SHIFT|SDLK_UP),
|
||||||
D("INS_LIST_MOVE_DOWN", "Move down", FURKMOD_SHIFT|SDLK_DOWN),
|
D("INS_LIST_MOVE_DOWN", "Move down", FURKMOD_SHIFT|SDLK_DOWN),
|
||||||
|
|
|
@ -1378,7 +1378,7 @@ void FurnaceGUI::drawInsEdit() {
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
// TODO: load replace
|
// TODO: load replace
|
||||||
if (ImGui::Button(ICON_FA_FOLDER_OPEN "##IELoad")) {
|
if (ImGui::Button(ICON_FA_FOLDER_OPEN "##IELoad")) {
|
||||||
doAction(GUI_ACTION_INS_LIST_OPEN);
|
doAction(GUI_ACTION_INS_LIST_OPEN_REPLACE);
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button(ICON_FA_FLOPPY_O "##IESave")) {
|
if (ImGui::Button(ICON_FA_FLOPPY_O "##IESave")) {
|
||||||
|
|
|
@ -1616,6 +1616,7 @@ void FurnaceGUI::drawSettings() {
|
||||||
UI_KEYBIND_CONFIG(GUI_ACTION_INS_LIST_ADD);
|
UI_KEYBIND_CONFIG(GUI_ACTION_INS_LIST_ADD);
|
||||||
UI_KEYBIND_CONFIG(GUI_ACTION_INS_LIST_DUPLICATE);
|
UI_KEYBIND_CONFIG(GUI_ACTION_INS_LIST_DUPLICATE);
|
||||||
UI_KEYBIND_CONFIG(GUI_ACTION_INS_LIST_OPEN);
|
UI_KEYBIND_CONFIG(GUI_ACTION_INS_LIST_OPEN);
|
||||||
|
UI_KEYBIND_CONFIG(GUI_ACTION_INS_LIST_OPEN_REPLACE);
|
||||||
UI_KEYBIND_CONFIG(GUI_ACTION_INS_LIST_SAVE);
|
UI_KEYBIND_CONFIG(GUI_ACTION_INS_LIST_SAVE);
|
||||||
UI_KEYBIND_CONFIG(GUI_ACTION_INS_LIST_MOVE_UP);
|
UI_KEYBIND_CONFIG(GUI_ACTION_INS_LIST_MOVE_UP);
|
||||||
UI_KEYBIND_CONFIG(GUI_ACTION_INS_LIST_MOVE_DOWN);
|
UI_KEYBIND_CONFIG(GUI_ACTION_INS_LIST_MOVE_DOWN);
|
||||||
|
|
Loading…
Reference in New Issue