Merge branch 'master' of https://github.com/tildearrow/furnace into command-palette

This commit is contained in:
YohananDiamond 2023-08-27 13:37:57 -03:00
commit 4f83fc2e93
144 changed files with 2983 additions and 1825 deletions

View file

@ -29,6 +29,7 @@
#include "IconsFontAwesome4.h"
#include "furIcons.h"
#include "misc/cpp/imgui_stdlib.h"
#include "scaling.h"
#include <fmt/printf.h>
#include <imgui.h>
@ -1303,6 +1304,7 @@ void FurnaceGUI::drawSettings() {
ImGui::SameLine();
ImGui::Combo("##PCSOutMethod",&settings.pcSpeakerOutMethod,pcspkrOutMethods,5);
/*
ImGui::Separator();
ImGui::Text("Sample ROMs:");
@ -1332,6 +1334,7 @@ void FurnaceGUI::drawSettings() {
if (ImGui::Button(ICON_FA_FOLDER "##MU5Load")) {
openFileDialog(GUI_FILE_MU5_ROM_OPEN);
}
*/
END_SECTION;
}
@ -4066,7 +4069,20 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
setupLabel(settings.emptyLabel.c_str(),emptyLabel,3);
setupLabel(settings.emptyLabel2.c_str(),emptyLabel2,2);
if (settings.dpiScale>=0.5f) dpiScale=settings.dpiScale;
// get scale factor
const char* videoBackend=SDL_GetCurrentVideoDriver();
if (settings.dpiScale>=0.5f) {
logD("setting UI scale factor from config (%f).",settings.dpiScale);
dpiScale=settings.dpiScale;
} else {
logD("auto-detecting UI scale factor.");
dpiScale=getScaleFactor(videoBackend);
logD("scale factor: %f",dpiScale);
if (dpiScale<0.1f) {
logW("scale what?");
dpiScale=1.0f;
}
}
// colors
if (updateFonts) {
@ -4248,11 +4264,17 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
ImFontConfig fontConf;
ImFontConfig fontConfP;
ImFontConfig fontConfB;
ImFontConfig fontConfH;
fontConf.OversampleV=1;
fontConf.OversampleH=2;
fontConfP.OversampleV=1;
fontConfP.OversampleH=2;
fontConfB.OversampleV=1;
fontConfB.OversampleH=1;
fontConfH.OversampleV=1;
fontConfH.OversampleH=1;
//fontConf.RasterizerMultiply=1.5;
//fontConfP.RasterizerMultiply=1.5;
@ -4300,6 +4322,9 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
ImFontConfig fc1;
fc1.MergeMode=true;
// save memory
fc1.OversampleH=1;
fc1.OversampleV=1;
if (settings.mainFont==6) { // custom font
if ((mainFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(settings.mainFontPath.c_str(),MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fontConf,fontRange))==NULL) {
@ -4336,6 +4361,9 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
ImFontConfig fc;
fc.MergeMode=true;
fc.OversampleH=1;
fc.OversampleV=1;
fc.PixelSnapH=true;
fc.GlyphMinAdvanceX=e->getConfInt("iconSize",16)*dpiScale;
static const ImWchar fontRangeIcon[]={ICON_MIN_FA,ICON_MAX_FA,0};
if ((iconFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(iconFont_compressed_data,iconFont_compressed_size,MAX(1,e->getConfInt("iconSize",16)*dpiScale),&fc,fontRangeIcon))==NULL) {
@ -4384,7 +4412,7 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
// 0x39B = Λ
static const ImWchar bigFontRange[]={0x20,0xFF,0x39b,0x39b,0};
if ((bigFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(font_plexSans_compressed_data,font_plexSans_compressed_size,MAX(1,40*dpiScale),NULL,bigFontRange))==NULL) {
if ((bigFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(font_plexSans_compressed_data,font_plexSans_compressed_size,MAX(1,40*dpiScale),&fontConfB,bigFontRange))==NULL) {
logE("could not load big UI font!");
}
@ -4393,21 +4421,21 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
headFont=mainFont;
} else {
if (settings.headFont==6) { // custom font
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(settings.headFontPath.c_str(),MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(settings.headFontPath.c_str(),MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
logW("could not load header font! reverting to default font");
settings.headFont=0;
if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
logE("could not load header font! falling back to IBM Plex Sans.");
headFont=ImGui::GetIO().Fonts->AddFontDefault();
}
}
} else if (settings.headFont==5) { // system font
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_1,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_2,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_3,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_1,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_2,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_3,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
logW("could not load header font! reverting to default font");
settings.headFont=0;
if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
logE("could not load header font! falling back to IBM Plex Sans.");
headFont=ImGui::GetIO().Fonts->AddFontDefault();
}
@ -4415,7 +4443,7 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
}
}
} else {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
logE("could not load header font!");
headFont=ImGui::GetIO().Fonts->AddFontDefault();
}