mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-24 05:25:12 +00:00
parent
fb70afe50d
commit
941aab0def
3 changed files with 44 additions and 11 deletions
|
@ -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; i<macroLen; i++) {
|
||||
if (i==macroLoop) target+="| ";
|
||||
if (i==macroRel) target+="/ ";
|
||||
if (i==macroLen-1) {
|
||||
snprintf(buf,31,"%d",macro[i]);
|
||||
if (hex) {
|
||||
if (i==macroLen-1) {
|
||||
snprintf(buf,31,"%.2X",macro[i]);
|
||||
} else {
|
||||
snprintf(buf,31,"%.2X ",macro[i]);
|
||||
}
|
||||
} else {
|
||||
snprintf(buf,31,"%d ",macro[i]);
|
||||
if (i==macroLen-1) {
|
||||
snprintf(buf,31,"%d",macro[i]);
|
||||
} else {
|
||||
snprintf(buf,31,"%d ",macro[i]);
|
||||
}
|
||||
}
|
||||
target+=buf;
|
||||
}
|
||||
}
|
||||
|
||||
void FurnaceGUI::decodeMMLStrW(String& source, int* macro, int& macroLen, int macroMax) {
|
||||
void FurnaceGUI::decodeMMLStrW(String& source, int* macro, int& macroLen, int macroMax, bool hex) {
|
||||
int buf=0;
|
||||
bool negaBuf=false;
|
||||
bool hasVal=false;
|
||||
|
@ -227,9 +235,23 @@ void FurnaceGUI::decodeMMLStrW(String& source, int* macro, int& macroLen, int ma
|
|||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
hasVal=true;
|
||||
buf*=10;
|
||||
buf*=hex?16:10;
|
||||
buf+=i-'0';
|
||||
break;
|
||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
||||
if (hex) {
|
||||
hasVal=true;
|
||||
buf*=16;
|
||||
buf+=10+i-'A';
|
||||
}
|
||||
break;
|
||||
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
|
||||
if (hex) {
|
||||
hasVal=true;
|
||||
buf*=16;
|
||||
buf+=10+i-'a';
|
||||
}
|
||||
break;
|
||||
case '-':
|
||||
if (!hasVal) {
|
||||
hasVal=true;
|
||||
|
@ -2546,6 +2568,7 @@ bool FurnaceGUI::init() {
|
|||
regViewOpen=e->getConfBool("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<DIV_MAX_CHANS; i++) {
|
||||
delete oldPat[i];
|
||||
|
|
|
@ -770,7 +770,7 @@ class FurnaceGUI {
|
|||
bool pianoOpen, notesOpen, channelsOpen, regViewOpen;
|
||||
SelectionPoint selStart, selEnd, cursor;
|
||||
bool selecting, curNibble, orderNibble, followOrders, followPattern, changeAllOrders;
|
||||
bool collapseWindow, demandScrollX, fancyPattern, wantPatName, firstFrame, tempoView;
|
||||
bool collapseWindow, demandScrollX, fancyPattern, wantPatName, firstFrame, tempoView, waveHex;
|
||||
FurnaceGUIWindows curWindow, nextWindow;
|
||||
float peak[2];
|
||||
float patChanX[DIV_MAX_CHANS+1];
|
||||
|
@ -1001,11 +1001,11 @@ class FurnaceGUI {
|
|||
void applyUISettings();
|
||||
void initSystemPresets();
|
||||
|
||||
void encodeMMLStr(String& target, int* macro, int macroLen, int macroLoop, int macroRel);
|
||||
void encodeMMLStr(String& target, int* macro, int macroLen, int macroLoop, int macroRel, bool hex=false);
|
||||
void encodeMMLStr(String& target, unsigned char* macro, unsigned char macroLen, signed char macroLoop, signed char macroRel);
|
||||
void decodeMMLStr(String& source, unsigned char* macro, unsigned char& macroLen, signed char& macroLoop, int macroMin, int macroMax, signed char& macroRel);
|
||||
void decodeMMLStr(String& source, int* macro, unsigned char& macroLen, signed char& macroLoop, int macroMin, int macroMax, signed char& macroRel);
|
||||
void decodeMMLStrW(String& source, int* macro, int& macroLen, int macroMax);
|
||||
void decodeMMLStrW(String& source, int* macro, int& macroLen, int macroMax, bool hex=false);
|
||||
|
||||
String encodeKeyMap(std::map<int,int>& map);
|
||||
void decodeKeyMap(std::map<int,int>& map, String source);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "gui.h"
|
||||
#include "plot_nolerp.h"
|
||||
#include "misc/cpp/imgui_stdlib.h"
|
||||
#include <imgui.h>
|
||||
|
||||
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; i<wave->len; 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));
|
||||
|
|
Loading…
Reference in a new issue