add "Other" category

include all categories to list and filters
This commit is contained in:
Megamouse 2017-06-18 17:43:46 +02:00 committed by Ivan
parent d11bb71a17
commit a1c72de1eb
9 changed files with 201 additions and 90 deletions

BIN
rpcs3/Icons/other_blue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

BIN
rpcs3/Icons/other_gray.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View file

@ -21,5 +21,7 @@
<file>Icons/media_gray.png</file>
<file>Icons/unknown_blue.png</file>
<file>Icons/unknown_gray.png</file>
<file>Icons/other_blue.png</file>
<file>Icons/other_gray.png</file>
</qresource>
</RCC>

View file

@ -65,29 +65,33 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> settings, Render_
// ToolBar Actions
m_catActHDD = { new QAction(""), QIcon(":/Icons/hdd_blue.png"), QIcon(":/Icons/hdd_gray.png") };
m_catActHDD.action->setIcon(xgui_settings->GetValue(GUI::cat_hdd_game).toBool() ? m_catActHDD.colored : m_catActHDD.gray);
m_catActHDD.action->setToolTip(tr("Show HDD Category"));
m_catActHDD.action->setToolTip(tr("Show HDD Categories"));
m_catActDisc = { new QAction(""), QIcon(":/Icons/disc_blue.png"), QIcon(":/Icons/disc_gray.png") };
m_catActDisc.action->setIcon(xgui_settings->GetValue(GUI::cat_disc_game).toBool() ? m_catActDisc.colored : m_catActDisc.gray);
m_catActDisc.action->setToolTip(tr("Show Disc Category"));
m_catActDisc.action->setToolTip(tr("Show Disc Categories"));
m_catActHome = { new QAction(""), QIcon(":/Icons/home_blue.png"), QIcon(":/Icons/home_gray.png") };
m_catActHome.action->setIcon(xgui_settings->GetValue(GUI::cat_home).toBool() ? m_catActHome.colored : m_catActHome.gray);
m_catActHome.action->setToolTip(tr("Show Home Category"));
m_catActHome.action->setToolTip(tr("Show Home Categories"));
m_catActAudioVideo = { new QAction(""), QIcon(":/Icons/media_blue.png"), QIcon(":/Icons/media_gray.png") };
m_catActAudioVideo.action->setIcon(xgui_settings->GetValue(GUI::cat_audio_video).toBool() ? m_catActAudioVideo.colored : m_catActAudioVideo.gray);
m_catActAudioVideo.action->setToolTip(tr("Show Audio/Video Category"));
m_catActAudioVideo.action->setToolTip(tr("Show Audio/Video Categories"));
m_catActGameData = { new QAction(""), QIcon(":/Icons/data_blue.png"), QIcon(":/Icons/data_gray.png") };
m_catActGameData.action->setIcon(xgui_settings->GetValue(GUI::cat_game_data).toBool() ? m_catActGameData.colored : m_catActGameData.gray);
m_catActGameData.action->setToolTip(tr("Show GameData Category"));
m_catActGameData.action->setToolTip(tr("Show GameData Categories"));
m_catActUnknown = { new QAction(""), QIcon(":/Icons/unknown_blue.png"), QIcon(":/Icons/unknown_gray.png") };
m_catActUnknown.action->setIcon(xgui_settings->GetValue(GUI::cat_unknown).toBool() ? m_catActUnknown.colored : m_catActUnknown.gray);
m_catActUnknown.action->setToolTip(tr("Show Unknown Category"));
m_catActUnknown.action->setToolTip(tr("Show Unknown Categories"));
m_categoryButtons = { m_catActHDD , m_catActDisc, m_catActHome, m_catActAudioVideo, m_catActGameData, m_catActUnknown };
m_catActOther = { new QAction(""), QIcon(":/Icons/other_blue.png"), QIcon(":/Icons/other_gray.png") };
m_catActOther.action->setIcon(xgui_settings->GetValue(GUI::cat_other).toBool() ? m_catActOther.colored : m_catActOther.gray);
m_catActOther.action->setToolTip(tr("Show Other Categories"));
m_categoryButtons = { m_catActHDD , m_catActDisc, m_catActHome, m_catActAudioVideo, m_catActGameData, m_catActUnknown, m_catActOther };
m_categoryActs = new QActionGroup(m_Tool_Bar);
m_categoryActs->addAction(m_catActHDD.action);
@ -96,6 +100,7 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> settings, Render_
m_categoryActs->addAction(m_catActAudioVideo.action);
m_categoryActs->addAction(m_catActGameData.action);
m_categoryActs->addAction(m_catActUnknown.action);
m_categoryActs->addAction(m_catActOther.action);
m_categoryActs->setEnabled(m_isListLayout);
m_modeActList = { new QAction(""), QIcon(":/Icons/list_blue.png"), QIcon(":/Icons/list_gray.png") };
@ -357,35 +362,35 @@ void game_list_frame::Refresh(bool fromDrive)
game.resolution = psf::get_integer(psf, "RESOLUTION");
game.sound_format = psf::get_integer(psf, "SOUND_FORMAT");
if (game.category == "HG")
bool bootable = false;
auto cat = category::cat_boot.find(game.category);
if (cat != category::cat_boot.end())
{
game.category = sstr(category::hdd_Game);
game.icon_path = dir + "/ICON0.PNG";
if (game.category == "DG")
{
game.icon_path = dir + "/PS3_GAME/ICON0.PNG";
}
else
{
game.icon_path = dir + "/ICON0.PNG";
}
game.category = sstr(cat->second);
bootable = true;
}
else if (game.category == "DG")
else if ((cat = category::cat_data.find(game.category)) != category::cat_data.end())
{
game.category = sstr(category::disc_Game);
game.icon_path = dir + "/PS3_GAME/ICON0.PNG";
}
else if (game.category == "HM")
{
game.category = sstr(category::home);
game.icon_path = dir + "/ICON0.PNG";
}
else if (game.category == "AV")
{
game.category = sstr(category::audio_Video);
game.icon_path = dir + "/ICON0.PNG";
}
else if (game.category == "GD")
{
game.category = sstr(category::game_Data);
game.icon_path = dir + "/ICON0.PNG";
game.category = sstr(cat->second);
}
else if (game.category == "unknown")
{
game.category = sstr(category::unknown);
}
else
{
game.category = sstr(category::other);
}
// Load Image
QImage img;
@ -405,7 +410,7 @@ void game_list_frame::Refresh(bool fromDrive)
pxmap = QPixmap::fromImage(img);
}
m_game_data.push_back({ game, img, pxmap });
m_game_data.push_back({ game, img, pxmap, bootable });
}
auto op = [](const GUI_GameInfo& game1, const GUI_GameInfo& game2) {
@ -450,9 +455,10 @@ void game_list_frame::Refresh(bool fromDrive)
}
}
void game_list_frame::ToggleCategoryFilter(QString category, bool show)
void game_list_frame::ToggleCategoryFilter(const QStringList& categories, bool show)
{
if (show) { m_categoryFilters.append(category); } else { m_categoryFilters.removeAll(category); }
if (show) { m_categoryFilters.append(categories); }
else { for (auto cat : categories) m_categoryFilters.removeAll(cat); }
Refresh();
}
@ -497,11 +503,9 @@ void game_list_frame::doubleClickedSlot(const QModelIndex& index)
{
i = m_xgrid->item(index.row(), index.column())->data(Qt::ItemDataRole::UserRole).toInt();
}
QString category = qstr(m_game_data[i].info.category);
// Boot these categories
if (category != category::game_Data)
// enable boot for bootable categories only
if (m_game_data[i].bootable)
{
const std::string& path = Emu.GetGameDir() + m_game_data[i].info.root;
RequestIconPathSet(path);
@ -610,7 +614,7 @@ void game_list_frame::ShowSpecifiedContextMenu(const QPoint &pos, int row)
{
removeGame->setEnabled(false);
}
else if (category == category::game_Data)
else if (category::non_disc_games.contains(qstr(m_game_data[row].info.category)))
{
boot->setEnabled(false), f.setBold(false), boot->setFont(f);
configure->setEnabled(false);

View file

@ -17,14 +17,89 @@
#include <memory>
namespace category
enum Category
{
const QString hdd_Game = QObject::tr("HDD Game");
const QString disc_Game = QObject::tr("Disc Game");
const QString home = QObject::tr("Home");
const QString audio_Video = QObject::tr("Audio/Video");
const QString game_Data = QObject::tr("Game Data");
const QString unknown = QObject::tr("Unknown");
Disc_Game,
Non_Disc_Game,
Home,
Media,
Data,
Unknown_Cat,
Others,
};
namespace category // (see PARAM.SFO in psdevwiki.com) TODO: Disc Categories
{
// PS3 bootable
const QString app_Music = QObject::tr("App Music");
const QString app_Photo = QObject::tr("App Photo");
const QString app_TV = QObject::tr("App TV");
const QString app_Video = QObject::tr("App Video");
const QString bc_Video = QObject::tr("Broadcast Video");
const QString disc_Game = QObject::tr("Disc Game");
const QString hdd_Game = QObject::tr("HDD Game");
const QString home = QObject::tr("Home");
const QString network = QObject::tr("Network");
const QString store_FE = QObject::tr("Store");
const QString web_TV = QObject::tr("Web TV");
// PS2 bootable
const QString ps2_game = QObject::tr("PS2 Classics");
const QString ps2_inst = QObject::tr("PS2 Game");
// PS1 bootable
const QString ps1_game = QObject::tr("PS1 Classics");
// PSP bootable
const QString psp_game = QObject::tr("PSP Game");
const QString psp_mini = QObject::tr("PSP Minis");
const QString psp_rema = QObject::tr("PSP Remasters");
// Data
const QString ps3_Data = QObject::tr("PS3 Game Data");
const QString ps2_Data = QObject::tr("PS2 Emulator Data");
// Save
const QString ps3_Save = QObject::tr("PS3 Save Data");
const QString psp_Save = QObject::tr("PSP Minis Save Data");
// others
const QString trophy = QObject::tr("Trophy");
const QString unknown = QObject::tr("Unknown");
const QString other = QObject::tr("Other");
const q_from_char cat_boot =
{
{ "AM",app_Music }, // media
{ "AP",app_Photo }, // media
{ "AT",app_TV }, // media
{ "AV",app_Video }, // media
{ "BV",bc_Video }, // media
{ "DG",disc_Game }, // disc_Game
{ "HG",hdd_Game }, // non_disc_games
{ "HM",home }, // home
{ "CB",network }, // other
{ "SF",store_FE }, // other
{ "WT",web_TV }, // media
{ "2P",ps2_game }, // non_disc_games
{ "2G",ps2_inst }, // non_disc_games
{ "1P",ps1_game }, // non_disc_games
{ "PP",psp_game }, // non_disc_games
{ "MN",psp_mini }, // non_disc_games
{ "PE",psp_rema } // non_disc_games
};
const q_from_char cat_data =
{
{ "GD",ps3_Data }, // data
{ "2D",ps2_Data }, // data
{ "SD",ps3_Save }, // data
{ "MS",psp_Save } // data
};
const QStringList non_disc_games = { hdd_Game, ps2_game, ps2_inst, ps1_game, psp_game, psp_mini, psp_rema };
const QStringList media = { app_Photo, app_Video, bc_Video, app_Music, app_TV, web_TV };
const QStringList data = { ps3_Data, ps2_Data, ps3_Save, psp_Save };
const QStringList others = { network, store_FE, trophy, other };
}
/* Having the icons associated with the game info simplifies logic internally */
@ -33,6 +108,7 @@ typedef struct GUI_GameInfo
GameInfo info;
QImage icon;
QPixmap pxmap;
bool bootable;
};
typedef struct Tool_Bar_Button
@ -49,7 +125,7 @@ public:
explicit game_list_frame(std::shared_ptr<gui_settings> settings, Render_Creator r_Creator, QWidget *parent = nullptr);
~game_list_frame();
void Refresh(const bool fromDrive = false);
void ToggleCategoryFilter(QString category, bool show);
void ToggleCategoryFilter(const QStringList& categories, bool show);
/** Loads from settings. Public so that main frame can easily reset these settings if needed. */
void LoadSettings();
@ -119,6 +195,7 @@ private:
Tool_Bar_Button m_catActGameData;
Tool_Bar_Button m_catActAudioVideo;
Tool_Bar_Button m_catActUnknown;
Tool_Bar_Button m_catActOther;
QList<Tool_Bar_Button> m_categoryButtons;

View file

@ -88,48 +88,67 @@ void gui_settings::SetValue(const GUI_SAVE& entry, const QVariant& value)
QStringList gui_settings::GetGameListCategoryFilters()
{
QStringList filterList;
if (GetCategoryVisibility(category::hdd_Game)) filterList.append(category::hdd_Game);
if (GetCategoryVisibility(category::disc_Game)) filterList.append(category::disc_Game);
if (GetCategoryVisibility(category::home)) filterList.append(category::home);
if (GetCategoryVisibility(category::audio_Video)) filterList.append(category::audio_Video);
if (GetCategoryVisibility(category::game_Data)) filterList.append(category::game_Data);
if (GetCategoryVisibility(category::unknown)) filterList.append(category::unknown);
if (GetCategoryVisibility(Category::Non_Disc_Game)) filterList.append(category::non_disc_games);
if (GetCategoryVisibility(Category::Disc_Game)) filterList.append(category::disc_Game);
if (GetCategoryVisibility(Category::Home)) filterList.append(category::home);
if (GetCategoryVisibility(Category::Media)) filterList.append(category::media);
if (GetCategoryVisibility(Category::Data)) filterList.append(category::data);
if (GetCategoryVisibility(Category::Unknown_Cat)) filterList.append(category::unknown);
if (GetCategoryVisibility(Category::Others)) filterList.append(category::others);
return filterList;
}
bool gui_settings::GetCategoryVisibility(QString cat)
bool gui_settings::GetCategoryVisibility(int cat)
{
GUI_SAVE value;
if (cat == category::hdd_Game) value = GUI::cat_hdd_game;
else if (cat == category::disc_Game) value = GUI::cat_disc_game;
else if (cat == category::home) value = GUI::cat_home;
else if (cat == category::audio_Video) value = GUI::cat_audio_video;
else if (cat == category::game_Data) value = GUI::cat_game_data;
else if (cat == category::unknown) value = GUI::cat_unknown;
else
switch (cat)
{
value = GUI::cat_other;
LOG_WARNING(GENERAL, "Category %s is unknown. Entry %s was loaded", sstr(cat), sstr(value.name));
case Category::Non_Disc_Game:
value = GUI::cat_hdd_game; break;
case Category::Disc_Game:
value = GUI::cat_disc_game; break;
case Category::Home:
value = GUI::cat_home; break;
case Category::Media:
value = GUI::cat_audio_video; break;
case Category::Data:
value = GUI::cat_game_data; break;
case Category::Unknown_Cat:
value = GUI::cat_unknown; break;
case Category::Others:
value = GUI::cat_other; break;
default:
LOG_WARNING(GENERAL, "GetCategoryVisibility: wrong cat <%d>", cat);
break;
}
return GetValue(value).toBool();
}
void gui_settings::SetCategoryVisibility(const QString& cat, const bool& val)
void gui_settings::SetCategoryVisibility(int cat, const bool& val)
{
GUI_SAVE value;
if (cat == category::hdd_Game) value = GUI::cat_hdd_game;
else if (cat == category::disc_Game) value = GUI::cat_disc_game;
else if (cat == category::home) value = GUI::cat_home;
else if (cat == category::audio_Video) value = GUI::cat_audio_video;
else if (cat == category::game_Data) value = GUI::cat_game_data;
else if (cat == category::unknown) value = GUI::cat_unknown;
else
switch (cat)
{
value = GUI::cat_other;
LOG_WARNING(GENERAL, "Category %s is unknown. Entry %s has been set to %d", sstr(cat), sstr(value.name), val);
case Category::Non_Disc_Game:
value = GUI::cat_hdd_game; break;
case Category::Disc_Game:
value = GUI::cat_disc_game; break;
case Category::Home:
value = GUI::cat_home; break;
case Category::Media:
value = GUI::cat_audio_video; break;
case Category::Data:
value = GUI::cat_game_data; break;
case Category::Unknown_Cat:
value = GUI::cat_unknown; break;
case Category::Others:
value = GUI::cat_other; break;
default:
LOG_WARNING(GENERAL, "SetCategoryVisibility: wrong cat <%d>", cat);
break;
}
SetValue(value, val);

View file

@ -25,7 +25,7 @@ typedef struct GUI_SAVE
};
};
typedef std::map<const QString, const QSize> icon_size;
typedef std::map<std::string, const QString> q_from_char;
typedef QPair<QString, QString> q_string_pair;
typedef QPair<QString, QSize> q_size_pair;
typedef QList<q_string_pair> q_pair_list;
@ -118,7 +118,7 @@ public:
/** Changes the settings file to the destination preset*/
void ChangeToConfig(const QString& destination);
bool GetCategoryVisibility(QString cat);
bool GetCategoryVisibility(int cat);
QVariant GetValue(const GUI_SAVE& entry);
QVariant List2Var(const q_pair_list& list);
q_pair_list Var2List(const QVariant &var);
@ -139,7 +139,7 @@ public Q_SLOTS:
void SetValue(const GUI_SAVE& entry, const QVariant& value);
/** Sets the visibility of the chosen category. */
void SetCategoryVisibility(const QString& cat, const bool& val);
void SetCategoryVisibility(int cat, const bool& val);
void SetGamelistColVisibility(int col, bool val);

View file

@ -1040,18 +1040,21 @@ void main_window::CreateActions()
showCatDiscGameAct = new QAction(category::disc_Game, this);
showCatDiscGameAct->setCheckable(true);
showCatHomeAct = new QAction(category::home, this);
showCatHomeAct = new QAction(tr("Home"), this);
showCatHomeAct->setCheckable(true);
showCatAudioVideoAct = new QAction(category::audio_Video, this);
showCatAudioVideoAct = new QAction(tr("Audio/Video"), this);
showCatAudioVideoAct->setCheckable(true);
showCatGameDataAct = new QAction(category::game_Data, this);
showCatGameDataAct = new QAction(tr("GameData"), this);
showCatGameDataAct->setCheckable(true);
showCatUnknownAct = new QAction(category::unknown, this);
showCatUnknownAct->setCheckable(true);
showCatOtherAct = new QAction(category::other, this);
showCatOtherAct->setCheckable(true);
categoryVisibleActGroup = new QActionGroup(this);
categoryVisibleActGroup->addAction(showCatHDDGameAct);
categoryVisibleActGroup->addAction(showCatDiscGameAct);
@ -1059,6 +1062,7 @@ void main_window::CreateActions()
categoryVisibleActGroup->addAction(showCatAudioVideoAct);
categoryVisibleActGroup->addAction(showCatGameDataAct);
categoryVisibleActGroup->addAction(showCatUnknownAct);
categoryVisibleActGroup->addAction(showCatOtherAct);
categoryVisibleActGroup->setExclusive(false);
setIconSizeTinyAct = new QAction(tr("Tiny"), this);
@ -1208,19 +1212,22 @@ void main_window::CreateConnects()
});
connect(categoryVisibleActGroup, &QActionGroup::triggered, [=](QAction* act)
{
QString cat;
QStringList categories;
int id;
const bool& checked = act->isChecked();
if (act == showCatHDDGameAct) cat = category::hdd_Game;
else if (act == showCatDiscGameAct) cat = category::disc_Game;
else if (act == showCatHomeAct) cat = category::home;
else if (act == showCatAudioVideoAct) cat = category::audio_Video;
else if (act == showCatGameDataAct) cat = category::game_Data;
else if (act == showCatUnknownAct) cat = category::unknown;
if (act == showCatHDDGameAct) categories += category::non_disc_games, id = Category::Non_Disc_Game;
else if (act == showCatDiscGameAct) categories += category::disc_Game, id = Category::Disc_Game;
else if (act == showCatHomeAct) categories += category::home, id = Category::Home;
else if (act == showCatAudioVideoAct) categories += category::media, id = Category::Media;
else if (act == showCatGameDataAct) categories += category::data, id = Category::Data;
else if (act == showCatUnknownAct) categories += category::unknown, id = Category::Unknown_Cat;
else if (act == showCatOtherAct) categories += category::others, id = Category::Others;
else LOG_WARNING(GENERAL, "categoryVisibleActGroup: category action not found");
gameListFrame->SetCategoryActIcon(categoryVisibleActGroup->actions().indexOf(act), checked);
gameListFrame->ToggleCategoryFilter(cat, checked);
guiSettings->SetCategoryVisibility(cat, checked);
gameListFrame->ToggleCategoryFilter(categories, checked);
guiSettings->SetCategoryVisibility(id, checked);
});
connect(aboutAct, &QAction::triggered, this, &main_window::About);
connect(aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt);
@ -1442,12 +1449,13 @@ void main_window::ConfigureGuiFromSettings(bool configureAll)
showGameListToolBarAct->setChecked(guiSettings->GetValue(GUI::gl_toolBarVisible).toBool());
guiSettings->GetValue(GUI::mw_controls).toBool() ? controls->show() : controls->hide();
showCatHDDGameAct->setChecked(guiSettings->GetCategoryVisibility(category::hdd_Game));
showCatDiscGameAct->setChecked(guiSettings->GetCategoryVisibility(category::disc_Game));
showCatHomeAct->setChecked(guiSettings->GetCategoryVisibility(category::home));
showCatAudioVideoAct->setChecked(guiSettings->GetCategoryVisibility(category::audio_Video));
showCatGameDataAct->setChecked(guiSettings->GetCategoryVisibility(category::game_Data));
showCatUnknownAct->setChecked(guiSettings->GetCategoryVisibility(category::unknown));
showCatHDDGameAct->setChecked(guiSettings->GetCategoryVisibility(Category::Non_Disc_Game));
showCatDiscGameAct->setChecked(guiSettings->GetCategoryVisibility(Category::Disc_Game));
showCatHomeAct->setChecked(guiSettings->GetCategoryVisibility(Category::Home));
showCatAudioVideoAct->setChecked(guiSettings->GetCategoryVisibility(Category::Media));
showCatGameDataAct->setChecked(guiSettings->GetCategoryVisibility(Category::Data));
showCatUnknownAct->setChecked(guiSettings->GetCategoryVisibility(Category::Unknown_Cat));
showCatOtherAct->setChecked(guiSettings->GetCategoryVisibility(Category::Others));
QString key = guiSettings->GetValue(GUI::gl_iconSize).toString();
if (key == GUI::gl_icon_key_large) setIconSizeLargeAct->setChecked(true);

View file

@ -134,6 +134,7 @@ private:
QAction* showCatAudioVideoAct;
QAction* showCatGameDataAct;
QAction* showCatUnknownAct;
QAction* showCatOtherAct;
QAction* setIconSizeTinyAct;
QAction* setIconSizeSmallAct;
QAction* setIconSizeMediumAct;