mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-29 23:41:19 -06:00
using new saving system but i can't understand the fallback mechanism
This commit is contained in:
parent
877a60fe3b
commit
11bdfd3a98
@ -4,9 +4,8 @@
|
||||
#include <fstream>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <fmt/core.h>
|
||||
#include <fmt/xchar.h> // for wstring support
|
||||
#include <toml.hpp>
|
||||
|
||||
#include "common/assert.h"
|
||||
@ -145,9 +144,6 @@ static ConfigEntry<string> isSideTrophy("right");
|
||||
static ConfigEntry<bool> isConnectedToNetwork(false);
|
||||
static bool enableDiscordRPC = false;
|
||||
static std::filesystem::path sys_modules_path = {};
|
||||
static std::filesystem::path sys_font_path = {};
|
||||
static std::string sys_font_fallback_name = {};
|
||||
static std::unordered_map<std::string, std::filesystem::path> system_font_overrides;
|
||||
|
||||
// Input
|
||||
static ConfigEntry<int> cursorState(HideCursorState::Idle);
|
||||
@ -238,44 +234,6 @@ void setSysModulesPath(const std::filesystem::path& path) {
|
||||
sys_modules_path = path;
|
||||
}
|
||||
|
||||
std::filesystem::path getSysFontPath() {
|
||||
return sys_font_path;
|
||||
}
|
||||
|
||||
void setSysFontPath(const std::filesystem::path& path) {
|
||||
sys_font_path = path;
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> getSystemFontOverride(std::string_view key) {
|
||||
if (key.empty()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
auto it = system_font_overrides.find(std::string(key));
|
||||
if (it == system_font_overrides.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
std::string getSystemFontFallbackName() {
|
||||
return sys_font_fallback_name;
|
||||
}
|
||||
|
||||
void setSystemFontFallbackName(const std::string& name) {
|
||||
sys_font_fallback_name = name;
|
||||
}
|
||||
|
||||
void setSystemFontOverride(std::string_view key, const std::filesystem::path& path) {
|
||||
if (key.empty()) {
|
||||
return;
|
||||
}
|
||||
system_font_overrides[std::string(key)] = path;
|
||||
}
|
||||
|
||||
void clearSystemFontOverrides() {
|
||||
system_font_overrides.clear();
|
||||
}
|
||||
|
||||
int getVolumeSlider() {
|
||||
return volumeSlider.get();
|
||||
}
|
||||
@ -904,10 +862,6 @@ void load(const std::filesystem::path& path, bool is_game_specific) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_game_specific) {
|
||||
system_font_overrides.clear();
|
||||
}
|
||||
|
||||
if (data.contains("General")) {
|
||||
const toml::value& general = data.at("General");
|
||||
|
||||
@ -931,43 +885,6 @@ void load(const std::filesystem::path& path, bool is_game_specific) {
|
||||
isConnectedToNetwork.setFromToml(general, "isConnectedToNetwork", is_game_specific);
|
||||
defaultControllerID.setFromToml(general, "defaultControllerID", is_game_specific);
|
||||
sys_modules_path = toml::find_fs_path_or(general, "sysModulesPath", sys_modules_path);
|
||||
// Accept alias without trailing 's'
|
||||
sys_modules_path = toml::find_fs_path_or(general, "sysModulePath", sys_modules_path);
|
||||
// Prefer 'sysFontPath'; accept 'SysFontPath' for compatibility
|
||||
sys_font_path = toml::find_fs_path_or(general, "sysFontPath", sys_font_path);
|
||||
sys_font_path = toml::find_fs_path_or(general, "SysFontPath", sys_font_path);
|
||||
}
|
||||
|
||||
if (data.contains("SystemFonts")) {
|
||||
const toml::value& fonts = data.at("SystemFonts");
|
||||
if (fonts.is_table()) {
|
||||
// Read fallback (lowercase preferred), accept 'Fallback'/'FallbackFontName' for compat
|
||||
if (fonts.contains("fallback")) {
|
||||
const auto& v = fonts.at("fallback");
|
||||
if (v.is_string()) {
|
||||
sys_font_fallback_name = toml::get<std::string>(v);
|
||||
}
|
||||
} else if (fonts.contains("Fallback")) {
|
||||
const auto& v = fonts.at("Fallback");
|
||||
if (v.is_string()) {
|
||||
sys_font_fallback_name = toml::get<std::string>(v);
|
||||
}
|
||||
} else if (fonts.contains("FallbackFontName")) {
|
||||
const auto& v = fonts.at("FallbackFontName");
|
||||
if (v.is_string()) {
|
||||
sys_font_fallback_name = toml::get<std::string>(v);
|
||||
}
|
||||
}
|
||||
for (const auto& [name, value] : fonts.as_table()) {
|
||||
if (name == "fallback" || name == "Fallback" || name == "FallbackFontName") {
|
||||
continue;
|
||||
}
|
||||
if (value.is_string()) {
|
||||
system_font_overrides[name] =
|
||||
std::filesystem::path(toml::get<std::string>(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (data.contains("Input")) {
|
||||
@ -1241,22 +1158,6 @@ void save(const std::filesystem::path& path, bool is_game_specific) {
|
||||
// Non game-specific entries
|
||||
data["General"]["enableDiscordRPC"] = enableDiscordRPC;
|
||||
data["General"]["sysModulesPath"] = string{fmt::UTF(sys_modules_path.u8string()).data};
|
||||
// Save using 'sysFontPath' to match style
|
||||
data["General"]["sysFontPath"] = string{fmt::UTF(sys_font_path.u8string()).data};
|
||||
{
|
||||
toml::table fonts_table;
|
||||
if (!sys_font_fallback_name.empty()) {
|
||||
fonts_table["fallback"] = sys_font_fallback_name;
|
||||
}
|
||||
for (const auto& [name, path_override] : system_font_overrides) {
|
||||
fonts_table[name] = string{fmt::UTF(path_override.u8string()).data};
|
||||
}
|
||||
if (!fonts_table.empty()) {
|
||||
data["SystemFonts"] = fonts_table;
|
||||
} else if (data.is_table()) {
|
||||
data.as_table().erase("SystemFonts");
|
||||
}
|
||||
}
|
||||
data["GUI"]["installDirs"] = install_dirs;
|
||||
data["GUI"]["installDirsEnabled"] = install_dirs_enabled;
|
||||
data["GUI"]["saveDataPath"] = string{fmt::UTF(save_data_path.u8string()).data};
|
||||
|
||||
@ -4,8 +4,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include "types.h"
|
||||
|
||||
@ -155,15 +153,6 @@ void setConnectedToNetwork(bool enable, bool is_game_specific = false);
|
||||
void setUserName(const std::string& name, bool is_game_specific = false);
|
||||
std::filesystem::path getSysModulesPath();
|
||||
void setSysModulesPath(const std::filesystem::path& path);
|
||||
std::filesystem::path getSysFontPath();
|
||||
void setSysFontPath(const std::filesystem::path& path);
|
||||
std::optional<std::filesystem::path> getSystemFontOverride(std::string_view key);
|
||||
std::string getSystemFontFallbackName();
|
||||
void setSystemFontFallbackName(const std::string& name);
|
||||
void setSystemFontOverride(std::string_view key, const std::filesystem::path& path);
|
||||
void clearSystemFontOverrides();
|
||||
bool getLoadAutoPatches();
|
||||
void setLoadAutoPatches(bool enable);
|
||||
|
||||
enum UsbBackendType : int { Real, SkylandersPortal, InfinityBase, DimensionsToypad };
|
||||
int getUsbDeviceBackend();
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "font_internal.h"
|
||||
@ -10,6 +10,7 @@
|
||||
#include FT_OUTLINE_H
|
||||
#include FT_TRUETYPE_TABLES_H
|
||||
|
||||
#include "core/emulator_settings.h"
|
||||
#include "core/libraries/font/fontft_internal.h"
|
||||
|
||||
namespace Libraries::Font::Internal {
|
||||
@ -1539,7 +1540,7 @@ static std::optional<std::filesystem::path> FindChildDirContainingFile(
|
||||
}
|
||||
|
||||
std::filesystem::path GetSysFontBaseDir() {
|
||||
std::filesystem::path base = Config::getSysFontPath();
|
||||
std::filesystem::path base = EmulatorSettings::GetInstance()->GetSysFontsDir();
|
||||
std::error_code ec;
|
||||
if (base.empty()) {
|
||||
LOG_ERROR(Lib_Font, "SystemFonts: SysFontPath not set");
|
||||
@ -1972,7 +1973,7 @@ std::string ReportSystemFaceRequest(FontState& st, Libraries::Font::OrbisFontHan
|
||||
}
|
||||
if (!st.system_requested) {
|
||||
st.system_requested = true;
|
||||
const auto configured = Config::getSysFontPath();
|
||||
const auto configured = EmulatorSettings::GetInstance()->GetSysFontsDir();
|
||||
return fmt::format("SystemFace: handle={} requested internal font but sysFontPath ('{}') "
|
||||
"could not be loaded",
|
||||
static_cast<const void*>(handle), configured.string());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user