GUI: work on chip manager

This commit is contained in:
tildearrow 2022-08-26 18:51:17 -05:00
parent 897a61db85
commit be9385f701
3 changed files with 55 additions and 34 deletions

View file

@ -4161,6 +4161,16 @@ bool FurnaceGUI::loop() {
ImGui::CloseCurrentPopup();
}
break;
case GUI_WARN_SYSTEM_DEL:
if (ImGui::Button("Yes")) {
e->removeSystem(sysToDelete,preserveChanPos);
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if (ImGui::Button("No")) {
ImGui::CloseCurrentPopup();
}
break;
case GUI_WARN_GENERIC:
if (ImGui::Button("OK")) {
ImGui::CloseCurrentPopup();
@ -4956,6 +4966,8 @@ FurnaceGUI::FurnaceGUI():
eventTimeEnd(0),
eventTimeDelta(0),
chanToMove(-1),
sysToMove(-1),
sysToDelete(-1),
transposeAmount(0),
randomizeMin(0),
randomizeMax(255),

View file

@ -310,6 +310,7 @@ enum FurnaceGUIWarnings {
GUI_WARN_CLOSE_SETTINGS,
GUI_WARN_CLEAR,
GUI_WARN_SUBSONG_DEL,
GUI_WARN_SYSTEM_DEL,
GUI_WARN_GENERIC
};
@ -1433,7 +1434,7 @@ class FurnaceGUI {
int renderTimeBegin, renderTimeEnd, renderTimeDelta;
int eventTimeBegin, eventTimeEnd, eventTimeDelta;
int chanToMove;
int chanToMove, sysToMove, sysToDelete;
ImVec2 patWindowPos, patWindowSize;

View file

@ -20,11 +20,9 @@
#include "gui.h"
#include "misc/cpp/imgui_stdlib.h"
#include "IconsFontAwesome4.h"
#include <fmt/printf.h>
#include <imgui.h>
static int _src, _dest;
static bool _preserveOrder;
void FurnaceGUI::drawSysManager() {
if (nextWindow==GUI_WINDOW_SYS_MANAGER) {
sysManagerOpen=true;
@ -33,61 +31,71 @@ void FurnaceGUI::drawSysManager() {
}
if (!sysManagerOpen) return;
if (ImGui::Begin("Chip Manager",&sysManagerOpen,globalWinFlags)) {
ImGui::Text("Call swapSystem() with arguments:");
ImGui::InputInt("src",&_src);
ImGui::InputInt("dest",&_dest);
ImGui::Checkbox("preserveOrder",&_preserveOrder);
if (ImGui::Button("Call")) {
if (!e->swapSystem(_src,_dest,_preserveOrder)) {
showError(e->getLastError());
}
}
ImGui::Checkbox("Preserve channel order",&preserveChanPos);
if (ImGui::BeginTable("SystemList",3)) {
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthFixed,0.0);
ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch,0.0);
ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthFixed,48.0f*dpiScale);
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthFixed);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableNextColumn();
ImGui::Text("Visible");
ImGui::TableNextColumn();
ImGui::Text("Name");
for (int i=0; i<e->getTotalChannelCount(); i++) {
ImGui::TableNextColumn();
ImGui::Text("Actions");
for (unsigned char i=0; i<e->song.systemLen; i++) {
ImGui::PushID(i);
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Checkbox("##Visible",&e->curSubSong->chanShow[i]);
ImGui::SameLine();
if (ImGui::Button(ICON_FA_ARROWS)) {
}
if (ImGui::BeginDragDropSource()) {
chanToMove=i;
ImGui::SetDragDropPayload("FUR_CHAN",NULL,0,ImGuiCond_Once);
ImGui::Button(ICON_FA_ARROWS "##ChanDrag");
sysToMove=i;
ImGui::SetDragDropPayload("FUR_SYS",NULL,0,ImGuiCond_Once);
ImGui::Button(ICON_FA_ARROWS "##SysDrag");
ImGui::EndDragDropSource();
} else if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("%s #%d\n(drag to swap channels)",e->getSystemName(e->sysOfChan[i]),e->dispatchChanOfChan[i]);
ImGui::SetTooltip("(drag to swap chips)");
}
if (ImGui::BeginDragDropTarget()) {
const ImGuiPayload* dragItem=ImGui::AcceptDragDropPayload("FUR_CHAN");
const ImGuiPayload* dragItem=ImGui::AcceptDragDropPayload("FUR_SYS");
if (dragItem!=NULL) {
if (dragItem->IsDataType("FUR_CHAN")) {
if (chanToMove!=i && chanToMove>=0) {
e->swapChannelsP(chanToMove,i);
if (dragItem->IsDataType("FUR_SYS")) {
if (sysToMove!=i && sysToMove>=0) {
e->swapSystem(sysToMove,i,preserveChanPos);
}
chanToMove=-1;
sysToMove=-1;
}
}
ImGui::EndDragDropTarget();
}
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
ImGui::InputTextWithHint("##ChanName",e->getChannelName(i),&e->curSubSong->chanName[i]);
if (ImGui::TreeNode(fmt::sprintf("%d. %s##_SYSM%d",i+1,getSystemName(e->song.system[i]),i).c_str())) {
drawSysConf(i,e->song.system[i],e->song.systemFlags[i],true);
ImGui::TreePop();
}
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
ImGui::InputTextWithHint("##ChanShortName",e->getChannelShortName(i),&e->curSubSong->chanShortName[i]);
ImGui::Button(ICON_FA_CHEVRON_DOWN "##SysChange");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Change");
}
ImGui::SameLine();
ImGui::BeginDisabled(e->song.systemLen<=1);
if (ImGui::Button(ICON_FA_TIMES "##SysRemove")) {
sysToDelete=i;
showWarning("Are you sure you want to remove this chip?",GUI_WARN_SYSTEM_DEL);
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Remove");
}
ImGui::EndDisabled();
ImGui::PopID();
}
if (e->song.systemLen<32) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TableNextColumn();
ImGui::Button(ICON_FA_PLUS "##SysAdd");
}
ImGui::EndTable();
}
}