Merge branch 'master' into metal

This commit is contained in:
tildearrow 2024-04-14 16:40:25 -05:00
commit e6bead147a
22 changed files with 636 additions and 175 deletions

View file

@ -71,6 +71,7 @@ const char* aboutLine[]={
"Aburtos",
"ActualNK358",
"akumanatt",
"aloelucidity",
"AmigaX",
"AquaDoesStuff",
"AURORA*FIELDS",

View file

@ -4391,7 +4391,7 @@ bool FurnaceGUI::loop() {
toggleMobileUI(!mobileUI);
}
#endif
if (ImGui::MenuItem("manage presets...",BIND_FOR(GUI_ACTION_WINDOW_USER_PRESETS))) {
if (ImGui::MenuItem("user systems...",BIND_FOR(GUI_ACTION_WINDOW_USER_PRESETS))) {
userPresetsOpen=true;
}
if (ImGui::MenuItem("settings...",BIND_FOR(GUI_ACTION_WINDOW_SETTINGS))) {

View file

@ -1265,6 +1265,7 @@ struct FurnaceGUISysDef {
String definition;
std::vector<FurnaceGUISysDefChip> orig;
std::vector<FurnaceGUISysDef> subDefs;
void bake();
FurnaceGUISysDef(const char* n, std::initializer_list<FurnaceGUISysDefChip> def, const char* e=NULL);
FurnaceGUISysDef(const char* n, const char* def, DivEngine* e);
};
@ -2089,7 +2090,7 @@ class FurnaceGUI {
displayRenderTime(0),
maxUndoSteps(100),
vibrationStrength(0.5f),
vibrationLength(100),
vibrationLength(20),
mainFontPath(""),
headFontPath(""),
patFontPath(""),

View file

@ -7469,7 +7469,7 @@ void FurnaceGUI::drawInsEdit() {
memset(oldData,0,256*sizeof(int));
memcpy(oldData,lastMacroDesc.macro->val,lastMacroDesc.macro->len*sizeof(int));
lastMacroDesc.macro->len=MIN(128,((double)lastMacroDesc.macro->len*(macroScaleX/100.0)));
lastMacroDesc.macro->len=MIN(255,((double)lastMacroDesc.macro->len*(macroScaleX/100.0)));
for (int i=0; i<lastMacroDesc.macro->len; i++) {
int val=0;

View file

@ -3102,11 +3102,9 @@ void FurnaceGUI::initSystemPresets() {
CATEGORY_END;
}
FurnaceGUISysDef::FurnaceGUISysDef(const char* n, std::initializer_list<FurnaceGUISysDefChip> def, const char* e):
name(n),
extra((e==NULL)?"":e) {
orig=def;
void FurnaceGUISysDef::bake() {
int index=0;
definition="";
for (FurnaceGUISysDefChip& i: orig) {
definition+=fmt::sprintf(
"id%d=%d\nvol%d=%f\npan%d=%f\nflags%d=%s\n",
@ -3126,12 +3124,19 @@ FurnaceGUISysDef::FurnaceGUISysDef(const char* n, std::initializer_list<FurnaceG
}
}
FurnaceGUISysDef::FurnaceGUISysDef(const char* n, std::initializer_list<FurnaceGUISysDefChip> def, const char* e):
name(n),
extra((e==NULL)?"":e) {
orig=def;
bake();
}
FurnaceGUISysDef::FurnaceGUISysDef(const char* n, const char* def, DivEngine* e):
name(n),
definition(def) {
definition(taDecodeBase64(def)) {
// extract definition
DivConfig conf;
conf.loadFromBase64(def);
conf.loadFromMemory(definition.c_str());
for (int i=0; i<DIV_MAX_CHIPS; i++) {
String nextStr=fmt::sprintf("id%d",i);
int id=conf.getInt(nextStr.c_str(),0);

View file

@ -4110,7 +4110,7 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
settings.centerPopup=conf.getInt("centerPopup",1);
settings.vibrationStrength=conf.getFloat("vibrationStrength",0.5f);
settings.vibrationLength=conf.getInt("vibrationLength",100);
settings.vibrationLength=conf.getInt("vibrationLength",20);
}
if (groups&GUI_SETTINGS_AUDIO) {

View file

@ -453,13 +453,17 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl
if (sampRate>65536) sampRate=65536;
altered=true;
} rightClickable
DivPlatformGBAMinMod* dispatch=(DivPlatformGBAMinMod*)e->getDispatch(chan);
float maxCPU=dispatch->maxCPU*100;
ImGui::Text("Actual sample rate: %d Hz", dispatch->chipClock);
if (maxCPU>90) ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_WARNING]);
ImGui::Text("Max mixer CPU usage: %.0f%%", maxCPU);
if (maxCPU>90) ImGui::PopStyleColor();
FurnaceGUI::popWarningColor();
if (chan>=0) {
DivPlatformGBAMinMod* dispatch=(DivPlatformGBAMinMod*)e->getDispatch(chan);
if (dispatch!=NULL) {
float maxCPU=dispatch->maxCPU*100;
ImGui::Text("Actual sample rate: %d Hz", dispatch->chipClock);
if (maxCPU>90) ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_WARNING]);
ImGui::Text("Max mixer CPU usage: %.0f%%",maxCPU);
if (maxCPU>90) ImGui::PopStyleColor();
FurnaceGUI::popWarningColor();
}
}
if (altered) {
e->lockSave([&]() {
flags.set("volScale",volScale);

View file

@ -453,7 +453,7 @@ struct FurnaceCV {
newHiScore(false),
playSongs(true),
pleaseInitSongs(false),
lives(3),
lives(5),
respawnTime(0),
stage(0),
shotType(0),

View file

@ -177,7 +177,7 @@ bool FurnaceGUI::loadUserPresets(bool redundancy) {
}
indent>>=1;
if (!key.empty() && !value.empty()) {
if (!key.empty()) {
std::vector<FurnaceGUISysDef>* where=digDeep(userCategory->systems,indent);
where->push_back(FurnaceGUISysDef(key.c_str(),value.c_str(),e));
}
@ -203,7 +203,7 @@ void writeSubEntries(FILE* f, std::vector<FurnaceGUISysDef>& entries, int depth)
for (int i=0; i<depth; i++) {
data+=" ";
}
data+=fmt::sprintf("%s=%s\n",safeName,i.definition);
data+=fmt::sprintf("%s=%s\n",safeName,taEncodeBase64(i.definition));
fputs(data.c_str(),f);
writeSubEntries(f,i.subDefs,depth+1);
@ -322,7 +322,7 @@ void FurnaceGUI::drawUserPresets() {
nextWindow=GUI_WINDOW_NOTHING;
}
if (!userPresetsOpen) return;
if (ImGui::Begin("User Presets",&userPresetsOpen,globalWinFlags)) {
if (ImGui::Begin("User Systems",&userPresetsOpen,globalWinFlags)) {
FurnaceGUISysCategory* userCategory=NULL;
for (FurnaceGUISysCategory& i: sysCategories) {
if (strcmp(i.name,"User")==0) {
@ -335,34 +335,173 @@ void FurnaceGUI::drawUserPresets() {
if (userCategory==NULL) {
ImGui::Text("Error! User category does not exist!");
} else if (ImGui::BeginTable("UserPresets",2,ImGuiTableFlags_BordersInnerV)) {
} else if (ImGui::BeginTable("UserPresets",2,ImGuiTableFlags_BordersInnerV,ImVec2(ImGui::GetContentRegionAvail().x,ImGui::GetContentRegionAvail().y-ImGui::GetFrameHeightWithSpacing()))) {
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch,0.25f);
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.75f);
// preset list
ImGui::TableNextRow();
ImGui::TableNextColumn();
if (ImGui::Button(ICON_FA_PLUS "##AddPreset")) {
userCategory->systems.push_back(FurnaceGUISysDef("New Preset",{}));
selectedUserPreset.clear();
selectedUserPreset.push_back(userCategory->systems.size()-1);
if (ImGui::BeginChild("UList",ImVec2(ImGui::GetContentRegionAvail().x,ImGui::GetContentRegionAvail().y-ImGui::GetFrameHeightWithSpacing()))) {
ImGui::AlignTextToFramePadding();
ImGui::Text("Systems");
ImGui::SameLine();
if (ImGui::Button(ICON_FA_PLUS "##AddPreset")) {
userCategory->systems.push_back(FurnaceGUISysDef("New Preset",{}));
selectedUserPreset.clear();
selectedUserPreset.push_back(userCategory->systems.size()-1);
}
printPresets(userCategory->systems,0,depthStack);
}
printPresets(userCategory->systems,0,depthStack);
ImGui::EndChild();
// editor
ImGui::TableNextColumn();
if (selectedUserPreset.empty()) {
ImGui::Text("select a preset");
} else {
FurnaceGUISysDef* preset=selectPreset(userCategory->systems);
if (ImGui::BeginChild("UEdit",ImVec2(ImGui::GetContentRegionAvail().x,ImGui::GetContentRegionAvail().y-ImGui::GetFrameHeightWithSpacing()))) {
if (selectedUserPreset.empty()) {
ImGui::Text("select a preset");
} else {
FurnaceGUISysDef* preset=selectPreset(userCategory->systems);
bool doRemovePreset=false;
if (preset!=NULL) {
ImGui::AlignTextToFramePadding();
ImGui::Text("Name");
ImGui::SameLine();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
ImGui::InputText("##PName",&preset->name);
ImGui::Separator();
ImGui::Text("the rest...");
if (preset!=NULL) {
ImGui::AlignTextToFramePadding();
ImGui::Text("Name");
ImGui::SameLine();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x-ImGui::CalcTextSize("Remove").x-ImGui::GetStyle().ItemSpacing.x*2.0-ImGui::GetStyle().ItemInnerSpacing.x*2.0);
ImGui::InputText("##PName",&preset->name);
ImGui::SameLine();
pushDestColor();
if (ImGui::Button("Remove##UPresetRemove")) {
doRemovePreset=true;
}
popDestColor();
ImGui::Separator();
int doRemove=-1;
bool mustBake=false;
for (size_t i=0; i<preset->orig.size(); i++) {
String tempID;
FurnaceGUISysDefChip& chip=preset->orig[i];
bool doInvert=(chip.vol<0);
float vol=fabs(chip.vol);
ImGui::PushID(i);
tempID=fmt::sprintf("%s##USystem",getSystemName(chip.sys));
ImGui::Button(tempID.c_str(),ImVec2(ImGui::GetContentRegionAvail().x-ImGui::CalcTextSize("Invert").x-ImGui::GetFrameHeightWithSpacing()*2.0-ImGui::GetStyle().ItemSpacing.x*2.0,0));
if (ImGui::BeginPopupContextItem("SysPickerCU",ImGuiPopupFlags_MouseButtonLeft)) {
DivSystem picked=systemPicker();
if (picked!=DIV_SYSTEM_NULL) {
chip.sys=picked;
mustBake=true;
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
ImGui::SameLine();
if (ImGui::Checkbox("Invert",&doInvert)) {
chip.vol=-chip.vol;
mustBake=true;
}
ImGui::SameLine();
pushDestColor();
if (ImGui::Button(ICON_FA_MINUS "##USysRemove")) {
doRemove=i;
mustBake=true;
}
popDestColor();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x-ImGui::GetFrameHeightWithSpacing()*2.0-ImGui::GetStyle().ItemSpacing.x*2.0);
if (CWSliderFloat("Volume",&vol,0.0f,3.0f)) {
if (doInvert) {
if (vol<0.0001) vol=0.0001;
}
if (vol<0) vol=0;
if (vol>10) vol=10;
chip.vol=doInvert?-vol:vol;
mustBake=true;
} rightClickable
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x-ImGui::GetFrameHeightWithSpacing()*2.0-ImGui::GetStyle().ItemSpacing.x*2.0);
if (CWSliderFloat("Panning",&chip.pan,-1.0f,1.0f)) {
if (chip.pan<-1.0f) chip.pan=-1.0f;
if (chip.pan>1.0f) chip.pan=1.0f;
mustBake=true;
} rightClickable
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x-ImGui::GetFrameHeightWithSpacing()*2.0-ImGui::GetStyle().ItemSpacing.x*2.0);
if (CWSliderFloat("Front/Rear",&chip.panFR,-1.0f,1.0f)) {
if (chip.panFR<-1.0f) chip.panFR=-1.0f;
if (chip.panFR>1.0f) chip.panFR=1.0f;
mustBake=true;
} rightClickable
if (ImGui::TreeNode("Configure")) {
DivConfig sysFlags;
sysFlags.loadFromBase64(chip.flags.c_str());
if (drawSysConf(-1,i,chip.sys,sysFlags,false)) {
chip.flags=sysFlags.toBase64();
mustBake=true;
}
ImGui::TreePop();
}
ImGui::PopID();
}
if (doRemove>=0) {
preset->orig.erase(preset->orig.begin()+doRemove);
mustBake=true;
}
ImGui::Button(ICON_FA_PLUS "##SysAddU");
if (ImGui::BeginPopupContextItem("SysPickerU",ImGuiPopupFlags_MouseButtonLeft)) {
DivSystem picked=systemPicker();
if (picked!=DIV_SYSTEM_NULL) {
preset->orig.push_back(FurnaceGUISysDefChip(picked,1.0f,0.0f,""));
mustBake=true;
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
ImGui::Separator();
ImGui::Text("Advanced");
if (ImGui::InputTextMultiline("##UExtra",&preset->extra,ImVec2(ImGui::GetContentRegionAvail().x,120.0f*dpiScale),ImGuiInputTextFlags_UndoRedo)) {
mustBake=true;
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"insert additional settings in `option=value` format.\n"
"available options:\n"
"- tickRate"
);
}
if (mustBake) preset->bake();
} else {
selectedUserPreset.clear();
}
if (doRemovePreset) {
std::vector<FurnaceGUISysDef>& items=userCategory->systems;
FurnaceGUISysDef* target=NULL;
for (size_t i=0; i<selectedUserPreset.size(); i++) {
if (selectedUserPreset[i]<0 || selectedUserPreset[i]>(int)items.size()) break;
target=&items[selectedUserPreset[i]];
if (i<selectedUserPreset.size()-1) {
items=target->subDefs;
} else {
items.erase(items.begin()+selectedUserPreset[i]);
}
}
selectedUserPreset.clear();
}
}
}
ImGui::EndChild();
ImGui::EndTable();
}