mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-05 12:25:05 +00:00
GUI: preliminary "select instrument" dialog
This commit is contained in:
parent
2932a7281d
commit
eb71c27ad9
2 changed files with 65 additions and 10 deletions
|
@ -3330,8 +3330,16 @@ bool FurnaceGUI::loop() {
|
|||
if (!e->getWarnings().empty()) {
|
||||
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
||||
}
|
||||
for (DivInstrument* i: instruments) {
|
||||
e->addInstrumentPtr(i);
|
||||
if (instruments.size()>1) { // ask which instruments to load
|
||||
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 {
|
||||
showError("cannot load instrument! ("+e->getLastError()+")");
|
||||
|
@ -3344,13 +3352,21 @@ bool FurnaceGUI::loop() {
|
|||
if (!e->getWarnings().empty()) {
|
||||
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
||||
}
|
||||
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;
|
||||
if (instruments.size()>1) { // ask which instrument
|
||||
for (DivInstrument* i: instruments) {
|
||||
pendingIns.push_back(std::make_pair(i,false));
|
||||
}
|
||||
displayPendingIns=true;
|
||||
pendingInsSingle=true;
|
||||
} 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 {
|
||||
showError("cannot load instrument! ("+e->getLastError()+")");
|
||||
|
@ -3442,6 +3458,11 @@ bool FurnaceGUI::loop() {
|
|||
ImGui::OpenPopup("Error");
|
||||
}
|
||||
|
||||
if (displayPendingIns) {
|
||||
displayPendingIns=false;
|
||||
ImGui::OpenPopup("Select Instrument");
|
||||
}
|
||||
|
||||
if (displayExporting) {
|
||||
displayExporting=false;
|
||||
ImGui::OpenPopup("Rendering...");
|
||||
|
@ -3792,6 +3813,36 @@ bool FurnaceGUI::loop() {
|
|||
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();
|
||||
|
||||
// backup trigger
|
||||
|
@ -4198,6 +4249,8 @@ FurnaceGUI::FurnaceGUI():
|
|||
preserveChanPos(false),
|
||||
wantScrollList(false),
|
||||
noteInputPoly(true),
|
||||
displayPendingIns(false),
|
||||
pendingInsSingle(false),
|
||||
vgmExportVersion(0x171),
|
||||
drawHalt(10),
|
||||
macroPointSize(16),
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <map>
|
||||
#include <future>
|
||||
#include <mutex>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include "fileDialog.h"
|
||||
|
@ -816,6 +817,7 @@ class FurnaceGUI {
|
|||
|
||||
bool quit, warnQuit, willCommit, edit, modified, displayError, displayExporting, vgmExportLoop, wantCaptureKeyboard, oldWantCaptureKeyboard, displayMacroMenu;
|
||||
bool displayNew, fullScreen, preserveChanPos, wantScrollList, noteInputPoly;
|
||||
bool displayPendingIns, pendingInsSingle;
|
||||
bool willExport[32];
|
||||
int vgmExportVersion;
|
||||
int drawHalt;
|
||||
|
@ -1130,7 +1132,7 @@ class FurnaceGUI {
|
|||
std::vector<ActiveNote> activeNotes;
|
||||
std::vector<DivCommand> cmdStream;
|
||||
std::vector<Particle> particles;
|
||||
std::vector<DivInstrument*> pendingIns;
|
||||
std::vector<std::pair<DivInstrument*,bool>> pendingIns;
|
||||
|
||||
std::vector<FurnaceGUISysCategory> sysCategories;
|
||||
|
||||
|
|
Loading…
Reference in a new issue