GUI: a rough FM ins editor

This commit is contained in:
tildearrow 2021-12-11 17:41:32 -05:00
parent 93c88a093f
commit 1d2c129c01
2 changed files with 79 additions and 0 deletions

View file

@ -112,6 +112,7 @@ extern/imgui/imgui_tables.cpp
extern/imgui/imgui_widgets.cpp
extern/imgui/backends/imgui_impl_sdlrenderer.cpp
extern/imgui/backends/imgui_impl_sdl.cpp
extern/imgui/misc/cpp/imgui_stdlib.cpp
extern/igfd/ImGuiFileDialog.cpp
src/gui/font_main.cpp

View file

@ -2,8 +2,20 @@
#include "fonts.h"
#include "../ta-log.h"
#include "imgui.h"
#include "misc/cpp/imgui_stdlib.h"
#include <fmt/printf.h>
const int _ZERO=0;
const int _THREE=3;
const int _SEVEN=7;
const int _FIFTEEN=15;;
const int _THIRTY_ONE=31;
const int _ONE_HUNDRED_TWENTY_SEVEN=127;
const int opOrder[4]={
0, 2, 1, 3
};
void FurnaceGUI::bindEngine(DivEngine* eng) {
e=eng;
}
@ -25,6 +37,21 @@ bool FurnaceGUI::loop() {
ImGui_ImplSDL2_NewFrame(sdlWin);
ImGui::NewFrame();
ImGui::BeginMainMenuBar();
if (ImGui::BeginMenu("file")) {
ImGui::MenuItem("new");
ImGui::MenuItem("open...");
ImGui::Separator();
ImGui::MenuItem("save");
ImGui::MenuItem("save as...");
ImGui::Separator();
if (ImGui::MenuItem("exit")) {
quit=true;
}
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
if (ImGui::Begin("Debug")) {
ImGui::Text("Hello world!\n");
ImGui::InputScalar("Speed 1",ImGuiDataType_U8,&e->song.speed1);
@ -52,6 +79,57 @@ bool FurnaceGUI::loop() {
}
ImGui::End();
if (ImGui::Begin("Instrument Editor")) {
if (curIns>=e->song.ins.size()) {
ImGui::Text("no instrument selected");
} else {
DivInstrument* ins=e->song.ins[curIns];
ImGui::InputText("Name",&ins->name);
ImGui::Checkbox("FM",&ins->mode);
if (ins->mode) { // FM
ImGui::SliderScalar("Algorithm",ImGuiDataType_U8,&ins->fm.alg,&_ZERO,&_SEVEN);
ImGui::SliderScalar("Feedback",ImGuiDataType_U8,&ins->fm.fb,&_ZERO,&_SEVEN);
ImGui::SliderScalar("LFO > Frequency",ImGuiDataType_U8,&ins->fm.fms,&_ZERO,&_SEVEN);
ImGui::SliderScalar("LFO > Amplitude",ImGuiDataType_U8,&ins->fm.ams,&_ZERO,&_THREE);
for (int i=0; i<4; i++) {
DivInstrumentFM::Operator& op=ins->fm.op[opOrder[i]];
ImGui::Separator();
ImGui::PushID(fmt::sprintf("op%d",i).c_str());
ImGui::Text("Operator %d",i+1);
ImGui::SliderScalar("Level",ImGuiDataType_U8,&op.tl,&_ZERO,&_ONE_HUNDRED_TWENTY_SEVEN);
ImGui::SliderScalar("Attack",ImGuiDataType_U8,&op.ar,&_ZERO,&_THIRTY_ONE);
ImGui::SliderScalar("Decay",ImGuiDataType_U8,&op.dr,&_ZERO,&_THIRTY_ONE);
ImGui::SliderScalar("Sustain",ImGuiDataType_U8,&op.sl,&_ZERO,&_FIFTEEN);
ImGui::SliderScalar("Decay 2",ImGuiDataType_U8,&op.d2r,&_ZERO,&_THIRTY_ONE);
ImGui::SliderScalar("Release",ImGuiDataType_U8,&op.rr,&_ZERO,&_FIFTEEN);
ImGui::SliderScalar("Multiplier",ImGuiDataType_U8,&op.mult,&_ZERO,&_FIFTEEN);
ImGui::SliderScalar("EnvScale",ImGuiDataType_U8,&op.rs,&_ZERO,&_THREE);
ImGui::SliderScalar("Detune",ImGuiDataType_U8,&op.dt,&_ZERO,&_SEVEN);
if (e->song.system==DIV_SYSTEM_ARCADE) {
ImGui::SliderScalar("Detune 2",ImGuiDataType_U8,&op.dt2,&_ZERO,&_THREE);
} else {
bool ssgOn=op.ssgEnv&8;
unsigned char ssgEnv=op.ssgEnv&7;
ImGui::SliderScalar("SSG-EG",ImGuiDataType_U8,&ssgEnv,&_ZERO,&_SEVEN);
ImGui::SameLine();
if (ImGui::Checkbox("##SSGOn",&ssgOn)) {
op.ssgEnv=(op.ssgEnv&7)|(ssgOn<<3);
}
}
bool amOn=op.am;
if (ImGui::Checkbox("AM",&amOn)) op.am=amOn;
ImGui::PopID();
}
} else { // STD
ImGui::Text("STD editor here");
}
}
}
ImGui::End();
SDL_RenderClear(sdlRend);
ImGui::Render();
ImGui_ImplSDLRenderer_RenderDrawData(ImGui::GetDrawData());