GUI: more improvements to instrument loading

now with an "instrument load always replace" option
This commit is contained in:
tildearrow 2022-05-04 23:11:51 -05:00
parent 99a313b684
commit c3e55ae117
4 changed files with 12 additions and 4 deletions

View file

@ -45,7 +45,7 @@ void FurnaceGUI::drawInsList() {
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(ICON_FA_FOLDER_OPEN "##InsLoad")) { if (ImGui::Button(ICON_FA_FOLDER_OPEN "##InsLoad")) {
doAction(GUI_ACTION_INS_LIST_OPEN); doAction((settings.insLoadAlwaysReplace && curIns>=0 && curIns<=(int)e->song.ins.size())?GUI_ACTION_INS_LIST_OPEN_REPLACE:GUI_ACTION_INS_LIST_OPEN);
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(ICON_FA_FLOPPY_O "##InsSave")) { if (ImGui::Button(ICON_FA_FLOPPY_O "##InsSave")) {

View file

@ -2930,9 +2930,7 @@ bool FurnaceGUI::loop() {
if ((curFileDialog==GUI_FILE_INS_OPEN || curFileDialog==GUI_FILE_INS_OPEN_REPLACE) && prevIns!=-3) { if ((curFileDialog==GUI_FILE_INS_OPEN || curFileDialog==GUI_FILE_INS_OPEN_REPLACE) && prevIns!=-3) {
if (curFileDialog==GUI_FILE_INS_OPEN_REPLACE) { if (curFileDialog==GUI_FILE_INS_OPEN_REPLACE) {
if (prevInsData!=NULL) { if (prevInsData!=NULL) {
logI("try");
if (prevIns>=0 && prevIns<(int)e->song.ins.size()) { if (prevIns>=0 && prevIns<(int)e->song.ins.size()) {
logI("replace");
*e->song.ins[prevIns]=*prevInsData; *e->song.ins[prevIns]=*prevInsData;
} }
} }
@ -3135,7 +3133,7 @@ bool FurnaceGUI::loop() {
showWarning(e->getWarnings(),GUI_WARN_GENERIC); showWarning(e->getWarnings(),GUI_WARN_GENERIC);
} }
if (curIns>=0 && curIns<(int)e->song.ins.size()) { if (curIns>=0 && curIns<(int)e->song.ins.size()) {
*e->song.ins[0]=*instruments[0]; *e->song.ins[curIns]=*instruments[curIns];
} else { } else {
showError("...but you haven't selected an instrument!"); showError("...but you haven't selected an instrument!");
} }

View file

@ -857,6 +857,7 @@ class FurnaceGUI {
int eventDelay; int eventDelay;
int moveWindowTitle; int moveWindowTitle;
int hiddenSystems; int hiddenSystems;
int insLoadAlwaysReplace;
unsigned int maxUndoSteps; unsigned int maxUndoSteps;
String mainFontPath; String mainFontPath;
String patFontPath; String patFontPath;
@ -939,6 +940,7 @@ class FurnaceGUI {
eventDelay(0), eventDelay(0),
moveWindowTitle(0), moveWindowTitle(0),
hiddenSystems(0), hiddenSystems(0),
insLoadAlwaysReplace(1),
maxUndoSteps(100), maxUndoSteps(100),
mainFontPath(""), mainFontPath(""),
patFontPath(""), patFontPath(""),

View file

@ -419,6 +419,11 @@ void FurnaceGUI::drawSettings() {
settings.restartOnFlagChange=restartOnFlagChangeB; settings.restartOnFlagChange=restartOnFlagChangeB;
} }
bool insLoadAlwaysReplaceB=settings.insLoadAlwaysReplace;
if (ImGui::Checkbox("Always replace currently selected instrument when loading from instrument list",&insLoadAlwaysReplaceB)) {
settings.insLoadAlwaysReplace=insLoadAlwaysReplaceB;
}
bool sysFileDialogB=settings.sysFileDialog; bool sysFileDialogB=settings.sysFileDialog;
if (ImGui::Checkbox("Use system file picker",&sysFileDialogB)) { if (ImGui::Checkbox("Use system file picker",&sysFileDialogB)) {
settings.sysFileDialog=sysFileDialogB; settings.sysFileDialog=sysFileDialogB;
@ -1831,6 +1836,7 @@ void FurnaceGUI::syncSettings() {
settings.eventDelay=e->getConfInt("eventDelay",0); settings.eventDelay=e->getConfInt("eventDelay",0);
settings.moveWindowTitle=e->getConfInt("moveWindowTitle",0); settings.moveWindowTitle=e->getConfInt("moveWindowTitle",0);
settings.hiddenSystems=e->getConfInt("hiddenSystems",0); settings.hiddenSystems=e->getConfInt("hiddenSystems",0);
settings.insLoadAlwaysReplace=e->getConfInt("insLoadAlwaysReplace",1);
clampSetting(settings.mainFontSize,2,96); clampSetting(settings.mainFontSize,2,96);
clampSetting(settings.patFontSize,2,96); clampSetting(settings.patFontSize,2,96);
@ -1901,6 +1907,7 @@ void FurnaceGUI::syncSettings() {
clampSetting(settings.eventDelay,0,1); clampSetting(settings.eventDelay,0,1);
clampSetting(settings.moveWindowTitle,0,1); clampSetting(settings.moveWindowTitle,0,1);
clampSetting(settings.hiddenSystems,0,1); clampSetting(settings.hiddenSystems,0,1);
clampSetting(settings.insLoadAlwaysReplace,0,1);
settings.initialSys=e->decodeSysDesc(e->getConfString("initialSys","")); settings.initialSys=e->decodeSysDesc(e->getConfString("initialSys",""));
if (settings.initialSys.size()<4) { if (settings.initialSys.size()<4) {
@ -2012,6 +2019,7 @@ void FurnaceGUI::commitSettings() {
e->setConf("moveWindowTitle",settings.moveWindowTitle); e->setConf("moveWindowTitle",settings.moveWindowTitle);
e->setConf("hiddenSystems",settings.hiddenSystems); e->setConf("hiddenSystems",settings.hiddenSystems);
e->setConf("initialSys",e->encodeSysDesc(settings.initialSys)); e->setConf("initialSys",e->encodeSysDesc(settings.initialSys));
e->setConf("insLoadAlwaysReplace",settings.insLoadAlwaysReplace);
// colors // colors
for (int i=0; i<GUI_COLOR_MAX; i++) { for (int i=0; i<GUI_COLOR_MAX; i++) {