From 941aab0def0f8201e2ab276a627dfa923608d34b Mon Sep 17 00:00:00 2001 From: tildearrow Date: Wed, 30 Mar 2022 00:28:49 -0500 Subject: [PATCH] GUI: add ability to input waveform data in hex closes #327 --- src/gui/gui.cpp | 36 ++++++++++++++++++++++++++++++------ src/gui/gui.h | 6 +++--- src/gui/waveEdit.cpp | 13 +++++++++++-- 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 256cefce7..77aa687ea 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -202,22 +202,30 @@ void FurnaceGUI::encodeMMLStr(String& target, unsigned char* macro, unsigned cha } } -void FurnaceGUI::encodeMMLStr(String& target, int* macro, int macroLen, int macroLoop, int macroRel) { +void FurnaceGUI::encodeMMLStr(String& target, int* macro, int macroLen, int macroLoop, int macroRel, bool hex) { target=""; char buf[32]; for (int i=0; igetConfBool("regViewOpen",false); tempoView=e->getConfBool("tempoView",true); + waveHex=e->getConfBool("waveHex",false); syncSettings(); @@ -2703,6 +2726,7 @@ bool FurnaceGUI::finish() { e->setConf("lastWindowHeight",scrH); e->setConf("tempoView",tempoView); + e->setConf("waveHex",waveHex); for (int i=0; i& map); void decodeKeyMap(std::map& map, String source); diff --git a/src/gui/waveEdit.cpp b/src/gui/waveEdit.cpp index 60938d0a0..e1359da93 100644 --- a/src/gui/waveEdit.cpp +++ b/src/gui/waveEdit.cpp @@ -20,6 +20,7 @@ #include "gui.h" #include "plot_nolerp.h" #include "misc/cpp/imgui_stdlib.h" +#include void FurnaceGUI::drawWaveEdit() { if (nextWindow==GUI_WINDOW_WAVE_EDIT) { @@ -61,6 +62,14 @@ void FurnaceGUI::drawWaveEdit() { e->notifyWaveChange(curWave); MARK_MODIFIED; } + ImGui::SameLine(); + if (ImGui::RadioButton("Dec",!waveHex)) { + waveHex=false; + } + ImGui::SameLine(); + if (ImGui::RadioButton("Hex",waveHex)) { + waveHex=true; + } for (int i=0; ilen; i++) { if (wave->data[i]>wave->max) wave->data[i]=wave->max; wavePreview[i]=wave->data[i]; @@ -68,10 +77,10 @@ void FurnaceGUI::drawWaveEdit() { if (wave->len>0) wavePreview[wave->len]=wave->data[wave->len-1]; ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); // wavetable text input size found here if (ImGui::InputText("##MMLWave",&mmlStringW)) { - decodeMMLStrW(mmlStringW,wave->data,wave->len,wave->max); + decodeMMLStrW(mmlStringW,wave->data,wave->len,wave->max,waveHex); } if (!ImGui::IsItemActive()) { - encodeMMLStr(mmlStringW,wave->data,wave->len,-1,-1); + encodeMMLStr(mmlStringW,wave->data,wave->len,-1,-1,waveHex); } ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,ImVec2(0.0f,0.0f));