Merge branch 'master' into ZSMv1

This commit is contained in:
ZeroByteOrg 2022-08-16 11:24:18 -05:00
commit 941d45ad80
141 changed files with 6303 additions and 1262 deletions

View file

@ -21,6 +21,7 @@
#include "fonts.h"
#include "../ta-log.h"
#include "../fileutils.h"
#include "../utfutils.h"
#include "util.h"
#include "guiConst.h"
#include "intConst.h"
@ -39,6 +40,13 @@
#define POWER_SAVE_DEFAULT 0
#endif
#ifdef __HAIKU__
// NFD doesn't support Haiku
#define SYS_FILE_DIALOG_DEFAULT 0
#else
#define SYS_FILE_DIALOG_DEFAULT 1
#endif
const char* mainFonts[]={
"IBM Plex Sans",
"Liberation Sans",
@ -252,9 +260,9 @@ void FurnaceGUI::drawSettings() {
ImGui::Separator();
ImGui::Text("Initial system/chips:");
ImGui::Text("Initial system:");
ImGui::SameLine();
if (ImGui::Button("Current systems")) {
if (ImGui::Button("Current system")) {
settings.initialSys.clear();
for (int i=0; i<e->song.systemLen; i++) {
settings.initialSys.push_back(e->song.system[i]);
@ -262,6 +270,7 @@ void FurnaceGUI::drawSettings() {
settings.initialSys.push_back(e->song.systemPan[i]);
settings.initialSys.push_back(e->song.systemFlags[i]);
}
settings.initialSysName=e->song.systemName;
}
ImGui::SameLine();
if (ImGui::Button("Randomize")) {
@ -282,6 +291,31 @@ void FurnaceGUI::drawSettings() {
settings.initialSys.push_back(0);
settings.initialSys.push_back(0);
}
// randomize system name
std::vector<String> wordPool[6];
for (size_t i=0; i<settings.initialSys.size()/4; i++) {
int wpPos=0;
String sName=e->getSystemName((DivSystem)settings.initialSys[i*4]);
String nameWord;
sName+=" ";
for (char& i: sName) {
if (i==' ') {
if (nameWord!="") {
wordPool[wpPos++].push_back(nameWord);
if (wpPos>=6) break;
nameWord="";
}
} else {
nameWord+=i;
}
}
}
settings.initialSysName="";
for (int i=0; i<6; i++) {
if (wordPool[i].empty()) continue;
settings.initialSysName+=wordPool[i][rand()%wordPool[i].size()];
settings.initialSysName+=" ";
}
}
ImGui::SameLine();
if (ImGui::Button("Reset to defaults")) {
@ -294,7 +328,14 @@ void FurnaceGUI::drawSettings() {
settings.initialSys.push_back(32);
settings.initialSys.push_back(0);
settings.initialSys.push_back(0);
settings.initialSysName="Sega Genesis/Mega Drive";
}
ImGui::Text("Name");
ImGui::SameLine();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
ImGui::InputText("##InitSysName",&settings.initialSysName);
for (size_t i=0; i<settings.initialSys.size(); i+=4) {
bool doRemove=false;
bool doInvert=settings.initialSys[i+1]&128;
@ -428,7 +469,7 @@ void FurnaceGUI::drawSettings() {
}
bool restartOnFlagChangeB=settings.restartOnFlagChange;
if (ImGui::Checkbox("Restart song when changing system properties",&restartOnFlagChangeB)) {
if (ImGui::Checkbox("Restart song when changing chip properties",&restartOnFlagChangeB)) {
settings.restartOnFlagChange=restartOnFlagChangeB;
}
@ -460,11 +501,24 @@ void FurnaceGUI::drawSettings() {
ImGui::SetTooltip("saves power by lowering the frame rate to 2fps when idle.\nmay cause issues under Mesa drivers!");
}
bool noThreadedInputB=settings.noThreadedInput;
if (ImGui::Checkbox("Disable threaded input (restart after changing!)",&noThreadedInputB)) {
settings.noThreadedInput=noThreadedInputB;
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("threaded input processes key presses for note preview on a separate thread (on supported platforms), which reduces latency.\nhowever, crashes have been reported when threaded input is on. enable this option if that is the case.");
}
bool blankInsB=settings.blankIns;
if (ImGui::Checkbox("New instruments are blank",&blankInsB)) {
settings.blankIns=blankInsB;
}
bool saveUnusedPatternsB=settings.saveUnusedPatterns;
if (ImGui::Checkbox("Save unused patterns",&saveUnusedPatternsB)) {
settings.saveUnusedPatterns=saveUnusedPatternsB;
}
ImGui::Text("Note preview behavior:");
if (ImGui::RadioButton("Never##npb0",settings.notePreviewBehavior==0)) {
settings.notePreviewBehavior=0;
@ -611,6 +665,11 @@ void FurnaceGUI::drawSettings() {
settings.forceMono=forceMonoB;
}
bool clampSamplesB=settings.clampSamples;
if (ImGui::Checkbox("Software clipping",&clampSamplesB)) {
settings.clampSamples=clampSamplesB;
}
TAAudioDesc& audioWant=e->getAudioDescWant();
TAAudioDesc& audioGot=e->getAudioDescGot();
@ -1028,6 +1087,15 @@ void FurnaceGUI::drawSettings() {
ImGui::Separator();
ImGui::Text("Pattern view labels:");
ImGui::InputTextWithHint("Note off (3-char)","OFF",&settings.noteOffLabel);
ImGui::InputTextWithHint("Note release (3-char)","===",&settings.noteRelLabel);
ImGui::InputTextWithHint("Macro release (3-char)","REL",&settings.macroRelLabel);
ImGui::InputTextWithHint("Empty field (3-char)","...",&settings.emptyLabel);
ImGui::InputTextWithHint("Empty field (2-char)","..",&settings.emptyLabel2);
ImGui::Separator();
ImGui::Text("Orders row number format:");
if (ImGui::RadioButton("Decimal##orbD",settings.orderRowsBase==0)) {
settings.orderRowsBase=0;
@ -1148,6 +1216,12 @@ void FurnaceGUI::drawSettings() {
ImGui::Separator();
ImGui::Text("Namco 163 chip name");
ImGui::SameLine();
ImGui::InputTextWithHint("##C163Name",DIV_C163_DEFAULT_NAME,&settings.c163Name);
ImGui::Separator();
bool insEditColorizeB=settings.insEditColorize;
if (ImGui::Checkbox("Colorize instrument editor using instrument type",&insEditColorizeB)) {
settings.insEditColorize=insEditColorizeB;
@ -1173,11 +1247,6 @@ void FurnaceGUI::drawSettings() {
}
ImGui::EndDisabled();
bool chipNamesB=settings.chipNames;
if (ImGui::Checkbox("Use chip names instead of system names",&chipNamesB)) {
settings.chipNames=chipNamesB;
}
bool oplStandardWaveNamesB=settings.oplStandardWaveNames;
if (ImGui::Checkbox("Use standard OPL waveform names",&oplStandardWaveNamesB)) {
settings.oplStandardWaveNames=oplStandardWaveNamesB;
@ -1446,7 +1515,11 @@ void FurnaceGUI::drawSettings() {
UI_COLOR_CONFIG(GUI_COLOR_INSTR_OPL,"FM (OPL)");
UI_COLOR_CONFIG(GUI_COLOR_INSTR_FDS,"FDS");
UI_COLOR_CONFIG(GUI_COLOR_INSTR_VBOY,"Virtual Boy");
UI_COLOR_CONFIG(GUI_COLOR_INSTR_N163,"Namco 163");
// special case
String c163Label=fmt::sprintf("%s##CC_GUI_COLOR_INSTR_N163",settings.c163Name);
if (ImGui::ColorEdit4(c163Label.c_str(),(float*)&uiColors[GUI_COLOR_INSTR_N163])) {
applyUISettings(false);
}
UI_COLOR_CONFIG(GUI_COLOR_INSTR_SCC,"Konami SCC");
UI_COLOR_CONFIG(GUI_COLOR_INSTR_OPZ,"FM (OPZ)");
UI_COLOR_CONFIG(GUI_COLOR_INSTR_POKEY,"POKEY");
@ -1505,12 +1578,21 @@ void FurnaceGUI::drawSettings() {
UI_COLOR_CONFIG(GUI_COLOR_PATTERN_EFFECT_SONG,"Song effect");
UI_COLOR_CONFIG(GUI_COLOR_PATTERN_EFFECT_TIME,"Time effect");
UI_COLOR_CONFIG(GUI_COLOR_PATTERN_EFFECT_SPEED,"Speed effect");
UI_COLOR_CONFIG(GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY,"Primary system effect");
UI_COLOR_CONFIG(GUI_COLOR_PATTERN_EFFECT_SYS_SECONDARY,"Secondary system effect");
UI_COLOR_CONFIG(GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY,"Primary specific effect");
UI_COLOR_CONFIG(GUI_COLOR_PATTERN_EFFECT_SYS_SECONDARY,"Secondary specific effect");
UI_COLOR_CONFIG(GUI_COLOR_PATTERN_EFFECT_MISC,"Miscellaneous");
UI_COLOR_CONFIG(GUI_COLOR_EE_VALUE,"External command output");
ImGui::TreePop();
}
if (ImGui::TreeNode("Pattern Manager")) {
UI_COLOR_CONFIG(GUI_COLOR_PAT_MANAGER_NULL,"Unallocated");
UI_COLOR_CONFIG(GUI_COLOR_PAT_MANAGER_UNUSED,"Unused");
UI_COLOR_CONFIG(GUI_COLOR_PAT_MANAGER_USED,"Used");
UI_COLOR_CONFIG(GUI_COLOR_PAT_MANAGER_OVERUSED,"Overused");
UI_COLOR_CONFIG(GUI_COLOR_PAT_MANAGER_EXTREMELY_OVERUSED,"Really overused");
UI_COLOR_CONFIG(GUI_COLOR_PAT_MANAGER_COMBO_BREAKER,"Combo Breaker");
ImGui::TreePop();
}
if (ImGui::TreeNode("Piano")) {
UI_COLOR_CONFIG(GUI_COLOR_PIANO_BACKGROUND,"Background");
UI_COLOR_CONFIG(GUI_COLOR_PIANO_KEY_TOP,"Upper key");
@ -1603,6 +1685,7 @@ void FurnaceGUI::drawSettings() {
UI_KEYBIND_CONFIG(GUI_ACTION_WINDOW_DEBUG);
UI_KEYBIND_CONFIG(GUI_ACTION_WINDOW_OSCILLOSCOPE);
UI_KEYBIND_CONFIG(GUI_ACTION_WINDOW_CHAN_OSC);
UI_KEYBIND_CONFIG(GUI_ACTION_WINDOW_EFFECT_LIST);
UI_KEYBIND_CONFIG(GUI_ACTION_WINDOW_VOL_METER);
UI_KEYBIND_CONFIG(GUI_ACTION_WINDOW_STATS);
UI_KEYBIND_CONFIG(GUI_ACTION_WINDOW_COMPAT_FLAGS);
@ -1649,7 +1732,7 @@ void FurnaceGUI::drawSettings() {
ImGui::Text("%s",SDL_GetScancodeName((SDL_Scancode)i.scan));
ImGui::TableNextColumn();
if (i.val==102) {
snprintf(id,4095,"Envelope release##SNType_%d",i.scan);
snprintf(id,4095,"Macro release##SNType_%d",i.scan);
if (ImGui::Button(id)) {
noteKeys[i.scan]=0;
}
@ -1965,6 +2048,7 @@ void FurnaceGUI::syncSettings() {
settings.audioDevice=e->getConfString("audioDevice","");
settings.midiInDevice=e->getConfString("midiInDevice","");
settings.midiOutDevice=e->getConfString("midiOutDevice","");
settings.c163Name=e->getConfString("c163Name",DIV_C163_DEFAULT_NAME);
settings.audioQuality=e->getConfInt("audioQuality",0);
settings.audioBufSize=e->getConfInt("audioBufSize",1024);
settings.audioRate=e->getConfInt("audioRate",44100);
@ -2009,7 +2093,7 @@ void FurnaceGUI::syncSettings() {
settings.insFocusesPattern=e->getConfInt("insFocusesPattern",1);
settings.stepOnInsert=e->getConfInt("stepOnInsert",0);
settings.unifiedDataView=e->getConfInt("unifiedDataView",0);
settings.sysFileDialog=e->getConfInt("sysFileDialog",1);
settings.sysFileDialog=e->getConfInt("sysFileDialog",SYS_FILE_DIALOG_DEFAULT);
settings.roundedWindows=e->getConfInt("roundedWindows",1);
settings.roundedButtons=e->getConfInt("roundedButtons",1);
settings.roundedMenus=e->getConfInt("roundedMenus",0);
@ -2056,6 +2140,15 @@ void FurnaceGUI::syncSettings() {
settings.blankIns=e->getConfInt("blankIns",0);
settings.dragMovesSelection=e->getConfInt("dragMovesSelection",2);
settings.unsignedDetune=e->getConfInt("unsignedDetune",0);
settings.noThreadedInput=e->getConfInt("noThreadedInput",0);
settings.initialSysName=e->getConfString("initialSysName","");
settings.clampSamples=e->getConfInt("clampSamples",0);
settings.noteOffLabel=e->getConfString("noteOffLabel","OFF");
settings.noteRelLabel=e->getConfString("noteRelLabel","===");
settings.macroRelLabel=e->getConfString("macroRelLabel","REL");
settings.emptyLabel=e->getConfString("emptyLabel","...");
settings.emptyLabel2=e->getConfString("emptyLabel2","..");
settings.saveUnusedPatterns=e->getConfInt("saveUnusedPatterns",0);
clampSetting(settings.mainFontSize,2,96);
clampSetting(settings.patFontSize,2,96);
@ -2142,6 +2235,9 @@ void FurnaceGUI::syncSettings() {
clampSetting(settings.blankIns,0,1);
clampSetting(settings.dragMovesSelection,0,2);
clampSetting(settings.unsignedDetune,0,1);
clampSetting(settings.noThreadedInput,0,1);
clampSetting(settings.clampSamples,0,1);
clampSetting(settings.saveUnusedPatterns,0,1);
settings.initialSys=e->decodeSysDesc(e->getConfString("initialSys",""));
if (settings.initialSys.size()<4) {
@ -2185,6 +2281,7 @@ void FurnaceGUI::commitSettings() {
e->setConf("audioDevice",settings.audioDevice);
e->setConf("midiInDevice",settings.midiInDevice);
e->setConf("midiOutDevice",settings.midiOutDevice);
e->setConf("c163Name",settings.c163Name);
e->setConf("audioQuality",settings.audioQuality);
e->setConf("audioBufSize",settings.audioBufSize);
e->setConf("audioRate",settings.audioRate);
@ -2264,6 +2361,7 @@ void FurnaceGUI::commitSettings() {
e->setConf("moveWindowTitle",settings.moveWindowTitle);
e->setConf("hiddenSystems",settings.hiddenSystems);
e->setConf("initialSys",e->encodeSysDesc(settings.initialSys));
e->setConf("initialSysName",settings.initialSysName);
e->setConf("horizontalDataView",settings.horizontalDataView);
e->setConf("noMultiSystem",settings.noMultiSystem);
e->setConf("oldMacroVSlider",settings.oldMacroVSlider);
@ -2277,6 +2375,14 @@ void FurnaceGUI::commitSettings() {
e->setConf("blankIns",settings.blankIns);
e->setConf("dragMovesSelection",settings.dragMovesSelection);
e->setConf("unsignedDetune",settings.unsignedDetune);
e->setConf("noThreadedInput",settings.noThreadedInput);
e->setConf("clampSamples",settings.clampSamples);
e->setConf("noteOffLabel",settings.noteOffLabel);
e->setConf("noteRelLabel",settings.noteRelLabel);
e->setConf("macroRelLabel",settings.macroRelLabel);
e->setConf("emptyLabel",settings.emptyLabel);
e->setConf("emptyLabel2",settings.emptyLabel2);
e->setConf("saveUnusedPatterns",settings.saveUnusedPatterns);
// colors
for (int i=0; i<GUI_COLOR_MAX; i++) {
@ -2689,6 +2795,20 @@ void FurnaceGUI::popAccentColors() {
#define SYSTEM_PAT_FONT_PATH_3 "/usr/share/fonts/ubuntu/UbuntuMono-R.ttf"
#endif
void setupLabel(const char* lStr, char* label, int len) {
memset(label,0,32);
for (int i=0, p=0; i<len; i++) {
signed char cl;
if (lStr[p]==0) {
strncat(label," ",32);
} else {
decodeUTF8((const unsigned char*)&lStr[p],cl);
memcpy(label+p,lStr+p,cl);
p+=cl;
}
}
}
void FurnaceGUI::applyUISettings(bool updateFonts) {
ImGuiStyle sty;
if (settings.guiColorsBase) {
@ -2697,6 +2817,12 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
ImGui::StyleColorsDark(&sty);
}
setupLabel(settings.noteOffLabel.c_str(),noteOffLabel,3);
setupLabel(settings.noteRelLabel.c_str(),noteRelLabel,3);
setupLabel(settings.macroRelLabel.c_str(),macroRelLabel,3);
setupLabel(settings.emptyLabel.c_str(),emptyLabel,3);
setupLabel(settings.emptyLabel2.c_str(),emptyLabel2,2);
if (settings.dpiScale>=0.5f) dpiScale=settings.dpiScale;
// colors