mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-23 10:35:03 +00:00
gui language
This commit is contained in:
parent
1a31c9e4dd
commit
5a331f755f
@ -83,7 +83,6 @@ std::filesystem::path settings_addon_install_dir = {};
|
||||
std::filesystem::path save_data_path = {};
|
||||
u32 mw_themes = 0;
|
||||
std::vector<std::string> m_elf_viewer;
|
||||
std::string emulator_language = "en_US";
|
||||
static bool isFullscreen = false;
|
||||
static std::string fullscreenMode = "Windowed";
|
||||
static bool isHDRAllowed = false;
|
||||
@ -492,10 +491,6 @@ void setElfViewer(const std::vector<std::string>& elfList) {
|
||||
m_elf_viewer = elfList;
|
||||
}
|
||||
|
||||
void setEmulatorLanguage(std::string language) {
|
||||
emulator_language = language;
|
||||
}
|
||||
|
||||
void setGameInstallDirs(const std::vector<std::filesystem::path>& dirs_config) {
|
||||
settings_install_dirs.clear();
|
||||
for (const auto& dir : dirs_config) {
|
||||
@ -545,10 +540,6 @@ std::vector<std::string> getElfViewer() {
|
||||
return m_elf_viewer;
|
||||
}
|
||||
|
||||
std::string getEmulatorLanguage() {
|
||||
return emulator_language;
|
||||
}
|
||||
|
||||
u32 GetLanguage() {
|
||||
return m_language;
|
||||
}
|
||||
@ -684,7 +675,6 @@ void load(const std::filesystem::path& path) {
|
||||
|
||||
settings_addon_install_dir = toml::find_fs_path_or(gui, "addonInstallDir", {});
|
||||
m_elf_viewer = toml::find_or<std::vector<std::string>>(gui, "elfDirs", {});
|
||||
emulator_language = toml::find_or<std::string>(gui, "emulatorLanguage", "en_US");
|
||||
}
|
||||
|
||||
if (data.contains("Settings")) {
|
||||
@ -697,19 +687,6 @@ void load(const std::filesystem::path& path) {
|
||||
const toml::value& keys = data.at("Keys");
|
||||
trophyKey = toml::find_or<std::string>(keys, "TrophyKey", "");
|
||||
}
|
||||
|
||||
// Check if the loaded language is in the allowed list
|
||||
const std::vector<std::string> allowed_languages = {
|
||||
"ar_SA", "da_DK", "de_DE", "el_GR", "en_US", "es_ES", "fa_IR", "fi_FI",
|
||||
"fr_FR", "hu_HU", "id_ID", "it_IT", "ja_JP", "ko_KR", "lt_LT", "nb_NO",
|
||||
"nl_NL", "pl_PL", "pt_BR", "pt_PT", "ro_RO", "ru_RU", "sq_AL", "sv_SE",
|
||||
"tr_TR", "uk_UA", "vi_VN", "zh_CN", "zh_TW", "ca_ES", "sr_CS"};
|
||||
|
||||
if (std::find(allowed_languages.begin(), allowed_languages.end(), emulator_language) ==
|
||||
allowed_languages.end()) {
|
||||
emulator_language = "en_US"; // Default to en_US if not in the list
|
||||
save(path);
|
||||
}
|
||||
}
|
||||
|
||||
void sortTomlSections(toml::ordered_value& data) {
|
||||
@ -844,7 +821,6 @@ void save(const std::filesystem::path& path) {
|
||||
|
||||
data["GUI"]["addonInstallDir"] =
|
||||
std::string{fmt::UTF(settings_addon_install_dir.u8string()).data};
|
||||
data["GUI"]["emulatorLanguage"] = emulator_language;
|
||||
data["Settings"]["consoleLanguage"] = m_language;
|
||||
|
||||
// Sorting of TOML sections
|
||||
@ -925,7 +901,6 @@ void setDefaultValues() {
|
||||
vkHostMarkers = false;
|
||||
vkGuestMarkers = false;
|
||||
rdocEnable = false;
|
||||
emulator_language = "en_US";
|
||||
m_language = 1;
|
||||
gpuId = -1;
|
||||
compatibilityData = false;
|
||||
|
@ -131,15 +131,12 @@ void setGameInstallDirEnabled(const std::filesystem::path& dir, bool enabled);
|
||||
void setAddonInstallDir(const std::filesystem::path& dir);
|
||||
void setMainWindowTheme(u32 theme);
|
||||
void setElfViewer(const std::vector<std::string>& elfList);
|
||||
void setRecentFiles(const std::vector<std::string>& recentFiles);
|
||||
void setEmulatorLanguage(std::string language);
|
||||
|
||||
const std::vector<std::filesystem::path> getGameInstallDirs();
|
||||
const std::vector<bool> getGameInstallDirsEnabled();
|
||||
std::filesystem::path getAddonInstallDir();
|
||||
u32 getMainWindowTheme();
|
||||
std::vector<std::string> getElfViewer();
|
||||
std::string getEmulatorLanguage();
|
||||
|
||||
void setDefaultValues();
|
||||
|
||||
|
@ -71,7 +71,7 @@ fs::path SaveInstance::GetParamSFOPath(const fs::path& dir_path) {
|
||||
|
||||
void SaveInstance::SetupDefaultParamSFO(PSF& param_sfo, std::string dir_name,
|
||||
std::string game_serial) {
|
||||
std::string locale = Config::getEmulatorLanguage();
|
||||
std::string locale = Config::GetLanguage();
|
||||
if (!default_title.contains(locale)) {
|
||||
locale = "en_US";
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ const gui_value gen_showChangeLog = gui_value(general_settings, "showChangeLog",
|
||||
const gui_value gen_updateChannel = gui_value(general_settings, "updateChannel", "Release");
|
||||
const gui_value gen_recentFiles =
|
||||
gui_value(main_window, "recentFiles", QVariant::fromValue(QList<QString>()));
|
||||
const gui_value gen_guiLanguage = gui_value(general_settings, "guiLanguage", "en_US");
|
||||
|
||||
// main window settings
|
||||
const gui_value mw_geometry = gui_value(main_window, "geometry", QByteArray());
|
||||
|
@ -771,7 +771,7 @@ void MainWindow::CreateConnects() {
|
||||
|
||||
QString gameName = QString::fromStdString(firstGame.name);
|
||||
TrophyViewer* trophyViewer =
|
||||
new TrophyViewer(trophyPath, gameTrpPath, gameName, allTrophyGames);
|
||||
new TrophyViewer(m_gui_settings, trophyPath, gameTrpPath, gameName, allTrophyGames);
|
||||
trophyViewer->show();
|
||||
});
|
||||
|
||||
@ -1164,7 +1164,7 @@ void MainWindow::CreateRecentGameActions() {
|
||||
}
|
||||
|
||||
void MainWindow::LoadTranslation() {
|
||||
auto language = QString::fromStdString(Config::getEmulatorLanguage());
|
||||
auto language = m_gui_settings->GetValue(gui::gen_guiLanguage).toString();
|
||||
|
||||
const QString base_dir = QStringLiteral(":/translations");
|
||||
QString base_path = QStringLiteral("%1/%2.qm").arg(base_dir).arg(language);
|
||||
@ -1190,7 +1190,7 @@ void MainWindow::LoadTranslation() {
|
||||
}
|
||||
|
||||
void MainWindow::OnLanguageChanged(const std::string& locale) {
|
||||
Config::setEmulatorLanguage(locale);
|
||||
m_gui_settings->SetValue(gui::gen_guiLanguage, locale);
|
||||
|
||||
LoadTranslation();
|
||||
}
|
||||
|
@ -886,4 +886,5 @@ void SettingsDialog::setDefaultValues() {
|
||||
} else {
|
||||
m_gui_settings->SetValue(gui::gen_updateChannel, "Nightly");
|
||||
}
|
||||
m_gui_settings->SetValue(gui::gen_guiLanguage, "en_US");
|
||||
}
|
@ -111,7 +111,7 @@ TrophyViewer::TrophyViewer(QString trophyPath, QString gameTrpPath, QString game
|
||||
this->setAttribute(Qt::WA_DeleteOnClose);
|
||||
tabWidget = new QTabWidget(this);
|
||||
|
||||
auto lan = Config::getEmulatorLanguage();
|
||||
auto lan = m_gui_settings->GetValue(gui::gen_guiLanguage).toString();
|
||||
if (lan == "en_US" || lan == "zh_CN" || lan == "zh_TW" || lan == "ja_JP" || lan == "ko_KR" ||
|
||||
lan == "lt_LT" || lan == "nb_NO" || lan == "nl_NL") {
|
||||
useEuropeanDateFormat = false;
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "common/types.h"
|
||||
#include "core/file_format/trp.h"
|
||||
#include "gui_settings.h"
|
||||
|
||||
struct TrophyGameInfo {
|
||||
QString name;
|
||||
@ -34,7 +35,8 @@ class TrophyViewer : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TrophyViewer(
|
||||
QString trophyPath, QString gameTrpPath, QString gameName = "",
|
||||
std::shared_ptr<gui_settings> gui_settings, QString trophyPath, QString gameTrpPath,
|
||||
QString gameName = "",
|
||||
const QVector<TrophyGameInfo>& allTrophyGames = QVector<TrophyGameInfo>());
|
||||
|
||||
void updateTrophyInfo();
|
||||
@ -77,4 +79,5 @@ private:
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
std::shared_ptr<gui_settings> m_gui_settings;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user