GUI: preliminary "select instrument" dialog
This commit is contained in:
parent
2932a7281d
commit
eb71c27ad9
|
|
@ -3330,8 +3330,16 @@ bool FurnaceGUI::loop() {
|
||||||
if (!e->getWarnings().empty()) {
|
if (!e->getWarnings().empty()) {
|
||||||
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
||||||
}
|
}
|
||||||
for (DivInstrument* i: instruments) {
|
if (instruments.size()>1) { // ask which instruments to load
|
||||||
e->addInstrumentPtr(i);
|
for (DivInstrument* i: instruments) {
|
||||||
|
pendingIns.push_back(std::make_pair(i,false));
|
||||||
|
}
|
||||||
|
displayPendingIns=true;
|
||||||
|
pendingInsSingle=false;
|
||||||
|
} else { // load the only instrument
|
||||||
|
for (DivInstrument* i: instruments) {
|
||||||
|
e->addInstrumentPtr(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showError("cannot load instrument! ("+e->getLastError()+")");
|
showError("cannot load instrument! ("+e->getLastError()+")");
|
||||||
|
|
@ -3344,13 +3352,21 @@ bool FurnaceGUI::loop() {
|
||||||
if (!e->getWarnings().empty()) {
|
if (!e->getWarnings().empty()) {
|
||||||
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
||||||
}
|
}
|
||||||
if (curIns>=0 && curIns<(int)e->song.ins.size()) {
|
if (instruments.size()>1) { // ask which instrument
|
||||||
*e->song.ins[curIns]=*instruments[0];
|
for (DivInstrument* i: instruments) {
|
||||||
} else {
|
pendingIns.push_back(std::make_pair(i,false));
|
||||||
showError("...but you haven't selected an instrument!");
|
}
|
||||||
}
|
displayPendingIns=true;
|
||||||
for (DivInstrument* i: instruments) {
|
pendingInsSingle=true;
|
||||||
delete i;
|
} else { // replace with the only instrument
|
||||||
|
if (curIns>=0 && curIns<(int)e->song.ins.size()) {
|
||||||
|
*e->song.ins[curIns]=*instruments[0];
|
||||||
|
} else {
|
||||||
|
showError("...but you haven't selected an instrument!");
|
||||||
|
}
|
||||||
|
for (DivInstrument* i: instruments) {
|
||||||
|
delete i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showError("cannot load instrument! ("+e->getLastError()+")");
|
showError("cannot load instrument! ("+e->getLastError()+")");
|
||||||
|
|
@ -3442,6 +3458,11 @@ bool FurnaceGUI::loop() {
|
||||||
ImGui::OpenPopup("Error");
|
ImGui::OpenPopup("Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (displayPendingIns) {
|
||||||
|
displayPendingIns=false;
|
||||||
|
ImGui::OpenPopup("Select Instrument");
|
||||||
|
}
|
||||||
|
|
||||||
if (displayExporting) {
|
if (displayExporting) {
|
||||||
displayExporting=false;
|
displayExporting=false;
|
||||||
ImGui::OpenPopup("Rendering...");
|
ImGui::OpenPopup("Rendering...");
|
||||||
|
|
@ -3792,6 +3813,36 @@ bool FurnaceGUI::loop() {
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// - multiple selection
|
||||||
|
// - replace instrument
|
||||||
|
if (ImGui::BeginPopupModal("Select Instrument",NULL,ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
|
bool quitPlease=false;
|
||||||
|
if (pendingInsSingle) {
|
||||||
|
ImGui::Text("this is an instrument bank! select which one to use:");
|
||||||
|
} else {
|
||||||
|
ImGui::Text("this is an instrument bank! select which ones to load:");
|
||||||
|
}
|
||||||
|
for (size_t i=0; i<pendingIns.size(); i++) {
|
||||||
|
String id=fmt::sprintf("%d: %s",(int)i,pendingIns[i].first->name);
|
||||||
|
if (ImGui::Selectable(id.c_str())) {
|
||||||
|
pendingIns[i].second=true;
|
||||||
|
e->addInstrumentPtr(pendingIns[i].first);
|
||||||
|
quitPlease=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (quitPlease) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
for (std::pair<DivInstrument*,bool> i: pendingIns) {
|
||||||
|
if (!i.second) {
|
||||||
|
delete i.first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pendingIns.clear();
|
||||||
|
}
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
|
||||||
layoutTimeEnd=SDL_GetPerformanceCounter();
|
layoutTimeEnd=SDL_GetPerformanceCounter();
|
||||||
|
|
||||||
// backup trigger
|
// backup trigger
|
||||||
|
|
@ -4198,6 +4249,8 @@ FurnaceGUI::FurnaceGUI():
|
||||||
preserveChanPos(false),
|
preserveChanPos(false),
|
||||||
wantScrollList(false),
|
wantScrollList(false),
|
||||||
noteInputPoly(true),
|
noteInputPoly(true),
|
||||||
|
displayPendingIns(false),
|
||||||
|
pendingInsSingle(false),
|
||||||
vgmExportVersion(0x171),
|
vgmExportVersion(0x171),
|
||||||
drawHalt(10),
|
drawHalt(10),
|
||||||
macroPointSize(16),
|
macroPointSize(16),
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <future>
|
#include <future>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "fileDialog.h"
|
#include "fileDialog.h"
|
||||||
|
|
@ -816,6 +817,7 @@ class FurnaceGUI {
|
||||||
|
|
||||||
bool quit, warnQuit, willCommit, edit, modified, displayError, displayExporting, vgmExportLoop, wantCaptureKeyboard, oldWantCaptureKeyboard, displayMacroMenu;
|
bool quit, warnQuit, willCommit, edit, modified, displayError, displayExporting, vgmExportLoop, wantCaptureKeyboard, oldWantCaptureKeyboard, displayMacroMenu;
|
||||||
bool displayNew, fullScreen, preserveChanPos, wantScrollList, noteInputPoly;
|
bool displayNew, fullScreen, preserveChanPos, wantScrollList, noteInputPoly;
|
||||||
|
bool displayPendingIns, pendingInsSingle;
|
||||||
bool willExport[32];
|
bool willExport[32];
|
||||||
int vgmExportVersion;
|
int vgmExportVersion;
|
||||||
int drawHalt;
|
int drawHalt;
|
||||||
|
|
@ -1130,7 +1132,7 @@ class FurnaceGUI {
|
||||||
std::vector<ActiveNote> activeNotes;
|
std::vector<ActiveNote> activeNotes;
|
||||||
std::vector<DivCommand> cmdStream;
|
std::vector<DivCommand> cmdStream;
|
||||||
std::vector<Particle> particles;
|
std::vector<Particle> particles;
|
||||||
std::vector<DivInstrument*> pendingIns;
|
std::vector<std::pair<DivInstrument*,bool>> pendingIns;
|
||||||
|
|
||||||
std::vector<FurnaceGUISysCategory> sysCategories;
|
std::vector<FurnaceGUISysCategory> sysCategories;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue