ui: customizable UI scale factor. rescan content button

This commit is contained in:
Flyinghead 2023-11-15 20:48:00 +01:00
parent df83ca436c
commit ef321d81a4
5 changed files with 29 additions and 2 deletions

View File

@ -40,6 +40,7 @@ Option<int, false> SavestateSlot("Dreamcast.SavestateSlot");
Option<bool> ForceFreePlay("ForceFreePlay", true);
Option<bool, false> FetchBoxart("FetchBoxart", true);
Option<bool, false> BoxartDisplayMode("BoxartDisplayMode", true);
Option<int, false> UIScaling("UIScaling", 100);
// Sound

View File

@ -373,6 +373,7 @@ extern Option<int, false> SavestateSlot;
extern Option<bool> ForceFreePlay;
extern Option<bool, false> FetchBoxart;
extern Option<bool, false> BoxartDisplayMode;
extern Option<int, false> UIScaling;
// Sound

View File

@ -77,6 +77,7 @@ static double osd_message_end;
static std::mutex osd_message_mutex;
static void (*showOnScreenKeyboard)(bool show);
static bool keysUpNextFrame[512];
static bool uiUserScaleUpdated;
static int map_system = 0;
static void reset_vmus();
@ -184,6 +185,7 @@ void gui_initFonts()
if (settings.display.width <= 640 || settings.display.height <= 480)
settings.display.uiScale = std::min(1.4f, settings.display.uiScale);
#endif
settings.display.uiScale *= config::UIScaling / 100.f;
if (settings.display.uiScale == uiScale && ImGui::GetIO().Fonts->IsBuilt())
return;
uiScale = settings.display.uiScale;
@ -1423,6 +1425,11 @@ static void gui_display_settings()
if (ImGui::Button("Done", ScaledVec2(100, 30)))
{
if (uiUserScaleUpdated)
{
uiUserScaleUpdated = false;
mainui_reinit();
}
if (game_started)
gui_setState(GuiState::Commands);
else
@ -1544,6 +1551,9 @@ static void gui_display_settings()
return true;
});
#endif
ImGui::SameLine();
if (ImGui::Button("Rescan Content"))
scanner.refresh();
ImGui::PopStyleVar();
scrollWhenDraggingOnVoid();
@ -1599,6 +1609,17 @@ static void gui_display_settings()
"Display game cover art in the game list.");
OptionCheckbox("Fetch Box Art", config::FetchBoxart,
"Fetch cover images from TheGamesDB.net.");
if (OptionSlider("UI Scaling", config::UIScaling, 50, 200, "Adjust the size of UI elements and fonts.", "%d%%"))
uiUserScaleUpdated = true;
if (uiUserScaleUpdated)
{
ImGui::SameLine();
if (ImGui::Button("Apply")) {
mainui_reinit();
uiUserScaleUpdated = false;
}
}
if (OptionCheckbox("Hide Legacy Naomi Roms", config::HideLegacyNaomiRoms,
"Hide .bin, .dat and .lst files from the content browser"))
scanner.refresh();

View File

@ -495,7 +495,8 @@ bool OptionCheckbox(const char *name, config::Option<bool, PerGameOption>& optio
template bool OptionCheckbox(const char *name, config::Option<bool, true>& option, const char *help);
template bool OptionCheckbox(const char *name, config::Option<bool, false>& option, const char *help);
bool OptionSlider(const char *name, config::Option<int>& option, int min, int max, const char *help, const char *format)
template<bool PerGameOption>
bool OptionSlider(const char *name, config::Option<int, PerGameOption>& option, int min, int max, const char *help, const char *format)
{
bool valueChanged;
{
@ -513,6 +514,8 @@ bool OptionSlider(const char *name, config::Option<int>& option, int min, int ma
}
return valueChanged;
}
template bool OptionSlider(const char *name, config::Option<int, true>& option, int min, int max, const char *help, const char *format);
template bool OptionSlider(const char *name, config::Option<int, false>& option, int min, int max, const char *help, const char *format);
bool OptionArrowButtons(const char *name, config::Option<int>& option, int min, int max, const char *help)
{

View File

@ -44,7 +44,8 @@ IMGUI_API const ImWchar* GetGlyphRangesChineseTraditionalOfficial();// Defaul
void ShowHelpMarker(const char* desc);
template<bool PerGameOption>
bool OptionCheckbox(const char *name, config::Option<bool, PerGameOption>& option, const char *help = nullptr);
bool OptionSlider(const char *name, config::Option<int>& option, int min, int max, const char *help = nullptr, const char *format = nullptr);
template<bool PerGameOption>
bool OptionSlider(const char *name, config::Option<int, PerGameOption>& option, int min, int max, const char *help = nullptr, const char *format = nullptr);
template<typename T>
bool OptionRadioButton(const char *name, config::Option<T>& option, T value, const char *help = nullptr);
void OptionComboBox(const char *name, config::Option<int>& option, const char *values[], int count,