GUI: add load/save/select to ins/wave editors

TODO: on sample editor
TODO: load replace instead of load insert
This commit is contained in:
tildearrow 2022-04-02 18:22:06 -05:00
parent 6c732a1891
commit 44d72c2106
2 changed files with 69 additions and 7 deletions

View file

@ -1132,14 +1132,59 @@ void FurnaceGUI::drawInsEdit() {
ImGui::Text("no instrument selected");
} else {
DivInstrument* ins=e->song.ins[curIns];
if (ImGui::InputText("Name",&ins->name)) {
MARK_MODIFIED;
}
if (ins->type<0 || ins->type>=DIV_INS_MAX) ins->type=DIV_INS_FM;
int insType=ins->type;
if (ImGui::Combo("Type",&insType,insTypes,DIV_INS_MAX,DIV_INS_MAX)) {
ins->type=(DivInstrumentType)insType;
if (ImGui::BeginTable("InsProp",3)) {
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch);
ImGui::TableNextRow();
ImGui::TableNextColumn();
String insIndex=fmt::sprintf("%.2X",curIns);
if (ImGui::BeginCombo("##InsSelect",insIndex.c_str())) {
String name;
for (size_t i=0; i<e->song.ins.size(); i++) {
name=fmt::sprintf("%.2X: %s##_INSS%d",i,e->song.ins[i]->name,i);
if (ImGui::Selectable(name.c_str(),curIns==(int)i)) {
curIns=i;
ins=e->song.ins[curIns];
}
}
ImGui::EndCombo();
}
ImGui::TableNextColumn();
ImGui::Text("Name");
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
if (ImGui::InputText("##Name",&ins->name)) {
MARK_MODIFIED;
}
ImGui::TableNextRow();
ImGui::TableNextColumn();
// TODO: load replace
if (ImGui::Button(ICON_FA_FOLDER_OPEN "##IELoad")) {
doAction(GUI_ACTION_INS_LIST_OPEN);
}
ImGui::SameLine();
if (ImGui::Button(ICON_FA_FLOPPY_O "##IESave")) {
doAction(GUI_ACTION_INS_LIST_SAVE);
}
ImGui::TableNextColumn();
ImGui::Text("Type");
ImGui::TableNextColumn();
if (ins->type<0 || ins->type>=DIV_INS_MAX) ins->type=DIV_INS_FM;
int insType=ins->type;
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
if (ImGui::Combo("##Type",&insType,insTypes,DIV_INS_MAX,DIV_INS_MAX)) {
ins->type=(DivInstrumentType)insType;
}
ImGui::EndTable();
}
if (ImGui::BeginTabBar("insEditTab")) {
if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL || ins->type==DIV_INS_OPZ) {

View file

@ -19,6 +19,7 @@
#include "gui.h"
#include "plot_nolerp.h"
#include "IconsFontAwesome4.h"
#include "misc/cpp/imgui_stdlib.h"
#include <imgui.h>
@ -35,6 +36,22 @@ void FurnaceGUI::drawWaveEdit() {
if (curWave<0 || curWave>=(int)e->song.wave.size()) {
ImGui::Text("no wavetable selected");
} else {
ImGui::SetNextItemWidth(80.0f*dpiScale);
if (ImGui::InputInt("##CurWave",&curWave,1,1)) {
if (curWave<0) curWave=0;
if (curWave>=(int)e->song.wave.size()) curWave=e->song.wave.size()-1;
}
ImGui::SameLine();
// TODO: load replace
if (ImGui::Button(ICON_FA_FOLDER_OPEN "##WELoad")) {
doAction(GUI_ACTION_WAVE_LIST_OPEN);
}
ImGui::SameLine();
if (ImGui::Button(ICON_FA_FLOPPY_O "##WESave")) {
doAction(GUI_ACTION_WAVE_LIST_SAVE);
}
ImGui::SameLine();
DivWavetable* wave=e->song.wave[curWave];
ImGui::Text("Width");
if (ImGui::IsItemHovered()) {