mirror of https://github.com/PCSX2/pcsx2.git
Qt: Add option to prefer English titles in Game List
This commit is contained in:
parent
c9099f3a2f
commit
4136545b6b
|
@ -179,7 +179,7 @@ void GameListModel::loadOrGenerateCover(const GameList::Entry* ge)
|
|||
// while there's outstanding jobs, the old jobs won't proceed (at the wrong size), or get added into the grid.
|
||||
const u32 counter = m_cover_scale_counter.load(std::memory_order_acquire);
|
||||
|
||||
QFuture<QPixmap> future = QtConcurrent::run([this, path = ge->path, title = ge->title, serial = ge->serial, counter]() -> QPixmap {
|
||||
QFuture<QPixmap> future = QtConcurrent::run([this, path = ge->path, title = ge->GetTitle(m_prefer_english_titles), serial = ge->serial, counter]() -> QPixmap {
|
||||
QPixmap image;
|
||||
if (m_cover_scale_counter.load(std::memory_order_acquire) == counter)
|
||||
{
|
||||
|
@ -294,7 +294,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
|
|||
return QString::fromStdString(ge->serial);
|
||||
|
||||
case Column_Title:
|
||||
return QString::fromStdString(ge->title);
|
||||
return QString::fromStdString(ge->GetTitle(m_prefer_english_titles));
|
||||
|
||||
case Column_FileTitle:
|
||||
return QtUtils::StringViewToQString(Path::GetFileTitle(ge->path));
|
||||
|
@ -319,7 +319,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
|
|||
case Column_Cover:
|
||||
{
|
||||
if (m_show_titles_for_covers)
|
||||
return QString::fromStdString(ge->title);
|
||||
return QString::fromStdString(ge->GetTitle(m_prefer_english_titles));
|
||||
else
|
||||
return {};
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
|
|||
|
||||
case Column_Title:
|
||||
case Column_Cover:
|
||||
return QString::fromStdString(ge->GetTitleSort());
|
||||
return QString::fromStdString(ge->GetTitleSort(m_prefer_english_titles));
|
||||
|
||||
case Column_FileTitle:
|
||||
return QtUtils::StringViewToQString(Path::GetFileTitle(ge->path));
|
||||
|
@ -424,6 +424,7 @@ QVariant GameListModel::headerData(int section, Qt::Orientation orientation, int
|
|||
|
||||
void GameListModel::refresh()
|
||||
{
|
||||
m_prefer_english_titles = Host::GetBaseBoolSettingValue("UI", "PreferEnglishGameList", false);
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
}
|
||||
|
@ -438,7 +439,8 @@ bool GameListModel::titlesLessThan(int left_row, int right_row) const
|
|||
|
||||
const GameList::Entry* left = GameList::GetEntryByIndex(left_row);
|
||||
const GameList::Entry* right = GameList::GetEntryByIndex(right_row);
|
||||
return QtHost::LocaleSensitiveCompare(QString::fromStdString(left->GetTitleSort()), QString::fromStdString(right->GetTitleSort())) < 0;
|
||||
return QtHost::LocaleSensitiveCompare(QString::fromStdString(left->GetTitleSort(m_prefer_english_titles)),
|
||||
QString::fromStdString(right->GetTitleSort(m_prefer_english_titles))) < 0;
|
||||
}
|
||||
|
||||
bool GameListModel::lessThan(const QModelIndex& left_index, const QModelIndex& right_index, int column) const
|
||||
|
|
|
@ -96,6 +96,7 @@ private:
|
|||
float m_cover_scale = 0.0f;
|
||||
std::atomic<u32> m_cover_scale_counter{0};
|
||||
bool m_show_titles_for_covers = false;
|
||||
bool m_prefer_english_titles = false;
|
||||
|
||||
std::array<QString, Column_Count> m_column_display_names;
|
||||
std::array<QPixmap, static_cast<u32>(GameList::EntryType::Count)> m_type_pixmaps;
|
||||
|
|
|
@ -87,7 +87,8 @@ public:
|
|||
if (!m_filter_name.isEmpty() &&
|
||||
!QString::fromStdString(entry->path).contains(m_filter_name, Qt::CaseInsensitive) &&
|
||||
!QString::fromStdString(entry->serial).contains(m_filter_name, Qt::CaseInsensitive) &&
|
||||
!QString::fromStdString(entry->title).contains(m_filter_name, Qt::CaseInsensitive))
|
||||
!QString::fromStdString(entry->title).contains(m_filter_name, Qt::CaseInsensitive) &&
|
||||
!QString::fromStdString(entry->title_en).contains(m_filter_name, Qt::CaseInsensitive))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -2299,6 +2299,9 @@ SettingsWindow* MainWindow::getSettingsWindow()
|
|||
g_main_window->doSettings("Interface");
|
||||
});
|
||||
});
|
||||
connect(m_setings_window->getGameListSettingsWidget(), &GameListSettingsWidget::preferEnglishGameListChanged, this, []{
|
||||
g_main_window->m_game_list_widget->refreshGridCovers();
|
||||
});
|
||||
}
|
||||
|
||||
return m_setings_window;
|
||||
|
|
|
@ -1296,6 +1296,7 @@ void Host::SetDefaultUISettings(SettingsInterface& si)
|
|||
si.SetBoolValue("UI", "RenderToSeparateWindow", false);
|
||||
si.SetBoolValue("UI", "HideMainWindowWhenRunning", false);
|
||||
si.SetBoolValue("UI", "DisableWindowResize", false);
|
||||
si.SetBoolValue("UI", "PreferEnglishGameList", false);
|
||||
si.SetStringValue("UI", "Theme", QtHost::GetDefaultThemeName());
|
||||
}
|
||||
|
||||
|
|
|
@ -30,12 +30,21 @@
|
|||
#include "MainWindow.h"
|
||||
#include "QtHost.h"
|
||||
#include "QtUtils.h"
|
||||
#include "SettingWidgetBinder.h"
|
||||
|
||||
GameListSettingsWidget::GameListSettingsWidget(SettingsWindow* dialog, QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
SettingsInterface* sif = dialog->getSettingsInterface();
|
||||
|
||||
m_ui.setupUi(this);
|
||||
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.preferEnglishGameList, "UI", "PreferEnglishGameList", false);
|
||||
connect(m_ui.preferEnglishGameList, &QCheckBox::stateChanged, [this]{ emit preferEnglishGameListChanged(); });
|
||||
|
||||
dialog->registerWidgetHelp(m_ui.preferEnglishGameList, tr("Prefer English Titles"), tr("Unchecked"),
|
||||
tr("For games with both a title in the game's native language and one in English, prefer the English title."));
|
||||
|
||||
m_ui.searchDirectoryList->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_ui.searchDirectoryList->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_ui.searchDirectoryList->setAlternatingRowColors(true);
|
||||
|
|
|
@ -32,6 +32,9 @@ public:
|
|||
bool addExcludedPath(const std::string& path);
|
||||
void refreshExclusionList();
|
||||
|
||||
Q_SIGNALS:
|
||||
void preferEnglishGameListChanged();
|
||||
|
||||
public Q_SLOTS:
|
||||
void addSearchDirectory(QWidget* parent_widget);
|
||||
|
||||
|
|
|
@ -23,6 +23,22 @@
|
|||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gameListGroup">
|
||||
<property name="title">
|
||||
<string>Display</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_gameList">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="preferEnglishGameList">
|
||||
<property name="text">
|
||||
<string>Prefer English Titles</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
|
|
|
@ -97,8 +97,17 @@ namespace GameList
|
|||
std::time_t last_played_time = 0;
|
||||
std::time_t total_played_time = 0;
|
||||
|
||||
const std::string& GetTitleEN() const { return title_en.empty() ? title : title_en; }
|
||||
const std::string& GetTitleSort() const { return title_sort.empty() ? title : title_sort; }
|
||||
const std::string& GetTitle(bool force_en = false) const
|
||||
{
|
||||
return title_en.empty() || !force_en ? title : title_en;
|
||||
}
|
||||
const std::string& GetTitleSort(bool force_en = false) const
|
||||
{
|
||||
// If there's a separate EN title, then title_sort is in the wrong language and we can't use it
|
||||
if (force_en && !title_en.empty())
|
||||
return title_en;
|
||||
return title_sort.empty() ? title : title_sort;
|
||||
}
|
||||
|
||||
u32 crc = 0;
|
||||
|
||||
|
|
|
@ -2460,7 +2460,7 @@ void FullscreenUI::DrawSettingsWindow()
|
|||
if (s_game_settings_entry)
|
||||
{
|
||||
NavTitle(SmallString::from_fmt(
|
||||
"{} ({})", Host::TranslateToCString(TR_CONTEXT, titles[static_cast<u32>(pages[index])]), s_game_settings_entry->GetTitleEN()));
|
||||
"{} ({})", Host::TranslateToCString(TR_CONTEXT, titles[static_cast<u32>(pages[index])]), s_game_settings_entry->GetTitle(true)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2575,8 +2575,8 @@ void FullscreenUI::DrawSummarySettingsPage()
|
|||
|
||||
if (s_game_settings_entry)
|
||||
{
|
||||
if (MenuButton(FSUI_ICONSTR(ICON_FA_WINDOW_MAXIMIZE, "Title"), s_game_settings_entry->GetTitleEN().c_str(), true))
|
||||
CopyTextToClipboard(FSUI_STR("Game title copied to clipboard."), s_game_settings_entry->GetTitleEN());
|
||||
if (MenuButton(FSUI_ICONSTR(ICON_FA_WINDOW_MAXIMIZE, "Title"), s_game_settings_entry->GetTitle(true).c_str(), true))
|
||||
CopyTextToClipboard(FSUI_STR("Game title copied to clipboard."), s_game_settings_entry->GetTitle(true));
|
||||
if (MenuButton(FSUI_ICONSTR(ICON_FA_PAGER, "Serial"), s_game_settings_entry->serial.c_str(), true))
|
||||
CopyTextToClipboard(FSUI_STR("Game serial copied to clipboard."), s_game_settings_entry->serial);
|
||||
if (MenuButton(FSUI_ICONSTR(ICON_FA_CODE, "CRC"), fmt::format("{:08X}", s_game_settings_entry->crc).c_str(), true))
|
||||
|
@ -5438,7 +5438,7 @@ void FullscreenUI::PopulateGameListEntryList()
|
|||
}
|
||||
|
||||
// fallback to title when all else is equal
|
||||
const int res = StringUtil::Strcasecmp(lhs->GetTitleEN().c_str(), rhs->GetTitleEN().c_str());
|
||||
const int res = StringUtil::Strcasecmp(lhs->GetTitleSort(true).c_str(), rhs->GetTitleSort(true).c_str());
|
||||
return reverse ? (res > 0) : (res < 0);
|
||||
});
|
||||
}
|
||||
|
@ -5575,7 +5575,7 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
|
|||
|
||||
ImGui::PushFont(g_large_font);
|
||||
// TODO: Fix font fallback issues and enable native-language titles
|
||||
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, entry->GetTitleEN().c_str(), entry->GetTitleEN().c_str() + entry->GetTitleEN().size(), nullptr,
|
||||
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, entry->GetTitle(true).c_str(), entry->GetTitle(true).c_str() + entry->GetTitle(true).size(), nullptr,
|
||||
ImVec2(0.0f, 0.0f), &title_bb);
|
||||
ImGui::PopFont();
|
||||
|
||||
|
@ -5635,11 +5635,11 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
|
|||
{
|
||||
// title
|
||||
ImGui::PushFont(g_large_font);
|
||||
const std::string_view title(std::string_view(selected_entry->GetTitleEN()).substr(0, 37));
|
||||
const std::string_view title(std::string_view(selected_entry->GetTitle(true)).substr(0, 37));
|
||||
text_width = ImGui::CalcTextSize(title.data(), title.data() + title.length(), false, work_width).x;
|
||||
ImGui::SetCursorPosX((work_width - text_width) / 2.0f);
|
||||
ImGui::TextWrapped(
|
||||
"%.*s%s", static_cast<int>(title.size()), title.data(), (title.length() == selected_entry->GetTitleEN().length()) ? "" : "...");
|
||||
"%.*s%s", static_cast<int>(title.size()), title.data(), (title.length() == selected_entry->GetTitle(true).length()) ? "" : "...");
|
||||
ImGui::PopFont();
|
||||
|
||||
ImGui::PushFont(g_medium_font);
|
||||
|
@ -5785,9 +5785,9 @@ void FullscreenUI::DrawGameGrid(const ImVec2& heading_size)
|
|||
ImVec2(1.0f, 1.0f), IM_COL32(255, 255, 255, 255));
|
||||
|
||||
const ImRect title_bb(ImVec2(bb.Min.x, bb.Min.y + image_height + title_spacing), bb.Max);
|
||||
const std::string_view title(std::string_view(entry->GetTitleEN()).substr(0, 31));
|
||||
const std::string_view title(std::string_view(entry->GetTitle(true)).substr(0, 31));
|
||||
draw_title.clear();
|
||||
fmt::format_to(std::back_inserter(draw_title), "{}{}", title, (title.length() == entry->GetTitleEN().length()) ? "" : "...");
|
||||
fmt::format_to(std::back_inserter(draw_title), "{}{}", title, (title.length() == entry->GetTitle(true).length()) ? "" : "...");
|
||||
ImGui::PushFont(g_medium_font);
|
||||
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, draw_title.c_str(), draw_title.c_str() + draw_title.length(), nullptr,
|
||||
ImVec2(0.5f, 0.0f), &title_bb);
|
||||
|
@ -5841,7 +5841,7 @@ void FullscreenUI::HandleGameListOptions(const GameList::Entry* entry)
|
|||
};
|
||||
|
||||
const bool has_resume_state = VMManager::HasSaveStateInSlot(entry->serial.c_str(), entry->crc, -1);
|
||||
OpenChoiceDialog(entry->GetTitleEN().c_str(), false, std::move(options),
|
||||
OpenChoiceDialog(entry->GetTitle(true).c_str(), false, std::move(options),
|
||||
[has_resume_state, entry_path = entry->path, entry_serial = entry->serial](s32 index, const std::string& title, bool checked) {
|
||||
switch (index)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue