mirror of https://github.com/RPCS3/rpcs3.git
Make trophy dialog smarter and not need the silly file. Can load all games by default now.
This commit is contained in:
parent
3d0dced4bd
commit
47bacc0ef0
|
@ -195,9 +195,6 @@ error_code sceNpTrophyCreateContext(vm::ptr<u32> context, vm::cptr<SceNpCommunic
|
|||
name = fmt::format("%s_%02d", commId->data, commId->num);
|
||||
}
|
||||
|
||||
// Let the UI know about this commid for the trophy manager.
|
||||
Emu.GetCallbacks().register_trophy_commid_to_ui(name);
|
||||
|
||||
// open trophy pack file
|
||||
fs::file stream(vfs::get("/app_home/../TROPDIR/" + name + "/TROPHY.TRP"));
|
||||
|
||||
|
|
|
@ -166,7 +166,6 @@ struct EmuCallbacks
|
|||
std::function<std::shared_ptr<class MsgDialogBase>()> get_msg_dialog;
|
||||
std::function<std::unique_ptr<class SaveDialogBase>()> get_save_dialog;
|
||||
std::function<std::unique_ptr<class TrophyNotificationBase>()> get_trophy_notification_dialog;
|
||||
std::function<void(const std::string&)> register_trophy_commid_to_ui;
|
||||
};
|
||||
|
||||
class Emulator final
|
||||
|
|
|
@ -249,24 +249,6 @@ void rpcs3_app::InitializeCallbacks()
|
|||
return std::make_unique<trophy_notification_helper>(gameWindow);
|
||||
};
|
||||
|
||||
callbacks.register_trophy_commid_to_ui = [=](const std::string& name)
|
||||
{
|
||||
// This callback writes a mapping between the trophy folder and the game itself. This is used by the trophy manager.
|
||||
YAML::Node trophy_map = YAML::Load(fs::file{ fs::get_config_dir() + "/trophy_mapping.yml", fs::read + fs::create }.to_string());
|
||||
|
||||
if (!trophy_map.IsMap())
|
||||
{
|
||||
trophy_map.reset();
|
||||
}
|
||||
if (!trophy_map[name])
|
||||
{
|
||||
trophy_map[name] = Emu.GetTitle();
|
||||
YAML::Emitter out;
|
||||
out << trophy_map;
|
||||
fs::file(fs::get_config_dir() + "/trophy_mapping.yml", fs::rewrite).write(out.c_str(), out.size());
|
||||
}
|
||||
};
|
||||
|
||||
callbacks.on_run = [=]() { OnEmulatorRun(); };
|
||||
callbacks.on_pause = [=]() { OnEmulatorPause(); };
|
||||
callbacks.on_resume = [=]() { OnEmulatorResume(); };
|
||||
|
|
|
@ -63,19 +63,17 @@ trophy_manager_dialog::trophy_manager_dialog() : QWidget(), m_sort_column(0), m_
|
|||
m_trophy_tree->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
// Populate the trophy database
|
||||
YAML::Node trophy_map = YAML::Load(fs::file{ fs::get_config_dir() + "/trophy_mapping.yml", fs::read + fs::create }.to_string());
|
||||
if (trophy_map.IsMap())
|
||||
QDirIterator dir_iter(qstr(vfs::get(m_TROPHY_DIR)));
|
||||
while (dir_iter.hasNext())
|
||||
{
|
||||
QDirIterator dir_iter(qstr(vfs::get(m_TROPHY_DIR)));
|
||||
while (dir_iter.hasNext())
|
||||
if (dir_iter.fileName() == "" || dir_iter.fileName() == "." || dir_iter.fileName() == ".." || dir_iter.fileName() == ".gitignore")
|
||||
{
|
||||
std::string dirName = sstr(dir_iter.fileName());
|
||||
if (auto game = trophy_map[dirName])
|
||||
{
|
||||
LoadTrophyFolderToDB(dirName, game.Scalar());
|
||||
}
|
||||
dir_iter.next();
|
||||
continue;
|
||||
}
|
||||
std::string dirName = sstr(dir_iter.fileName());
|
||||
LoadTrophyFolderToDB(dirName);
|
||||
dir_iter.next();
|
||||
}
|
||||
|
||||
PopulateUI();
|
||||
|
@ -115,15 +113,8 @@ trophy_manager_dialog::trophy_manager_dialog() : QWidget(), m_sort_column(0), m_
|
|||
settings_layout->addStretch(0);
|
||||
settings->setLayout(settings_layout);
|
||||
|
||||
QVBoxLayout* side_layout = new QVBoxLayout();
|
||||
side_layout->addWidget(settings);
|
||||
QLabel* disclaimer_label = new QLabel(tr("Please note the game must first be played to be displayed."));
|
||||
disclaimer_label->setWordWrap(true);
|
||||
disclaimer_label->setAlignment(Qt::AlignCenter);
|
||||
side_layout->addWidget(disclaimer_label);
|
||||
|
||||
QHBoxLayout* all_layout = new QHBoxLayout(this);
|
||||
all_layout->addLayout(side_layout);
|
||||
all_layout->addWidget(settings);
|
||||
all_layout->addWidget(m_trophy_tree);
|
||||
setLayout(all_layout);
|
||||
|
||||
|
@ -154,14 +145,13 @@ trophy_manager_dialog::trophy_manager_dialog() : QWidget(), m_sort_column(0), m_
|
|||
connect(m_trophy_tree, &QTableWidget::customContextMenuRequested, this, &trophy_manager_dialog::ShowContextMenu);
|
||||
}
|
||||
|
||||
bool trophy_manager_dialog::LoadTrophyFolderToDB(const std::string& trop_name, const std::string& game_name)
|
||||
bool trophy_manager_dialog::LoadTrophyFolderToDB(const std::string& trop_name)
|
||||
{
|
||||
std::string trophyPath = m_TROPHY_DIR + trop_name;
|
||||
|
||||
// Populate GameTrophiesData
|
||||
std::unique_ptr<GameTrophiesData> game_trophy_data = std::make_unique<GameTrophiesData>();
|
||||
|
||||
game_trophy_data->game_name = game_name;
|
||||
game_trophy_data->path = vfs::get(trophyPath + "/");
|
||||
game_trophy_data->trop_usr.reset(new TROPUSRLoader());
|
||||
std::string trophyUsrPath = trophyPath + "/TROPUSR.DAT";
|
||||
|
@ -198,8 +188,24 @@ bool trophy_manager_dialog::LoadTrophyFolderToDB(const std::string& trop_name, c
|
|||
game_trophy_data->trophy_images.emplace_back(std::move(trophy_icon));
|
||||
}
|
||||
|
||||
// Get game name
|
||||
game_trophy_data->trop_config.Read(config.to_string());
|
||||
std::shared_ptr<rXmlNode> trophy_base = game_trophy_data->trop_config.GetRoot();
|
||||
if (trophy_base->GetChildren()->GetName() == "trophyconf")
|
||||
{
|
||||
trophy_base = trophy_base->GetChildren();
|
||||
}
|
||||
for (std::shared_ptr<rXmlNode> n = trophy_base->GetChildren(); n; n = n->GetNext())
|
||||
{
|
||||
if (n->GetName() == "title-name")
|
||||
{
|
||||
game_trophy_data->game_name = n->GetNodeContent();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_trophies_db.push_back(std::move(game_trophy_data));
|
||||
|
||||
config.release();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ private:
|
|||
/** Loads a trophy folder.
|
||||
Returns true if successful. Does not attempt to install if failure occurs, like sceNpTrophy.
|
||||
*/
|
||||
bool LoadTrophyFolderToDB(const std::string& trop_name, const std::string& game_name);
|
||||
bool LoadTrophyFolderToDB(const std::string& trop_name);
|
||||
|
||||
/** Fills UI with information.
|
||||
Takes results from LoadTrophyFolderToDB and puts it into the UI.
|
||||
|
|
Loading…
Reference in New Issue