mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-03 16:02:26 +00:00
extract trophy info on game start + various fixes
This commit is contained in:
parent
794770f94e
commit
315afc52fa
@ -542,17 +542,12 @@ int PS4_SYSV_ABI sceNpTrophyUnlockTrophy(OrbisNpTrophyContext context, OrbisNpTr
|
|||||||
if (platinumId == nullptr)
|
if (platinumId == nullptr)
|
||||||
return ORBIS_NP_TROPHY_ERROR_INVALID_ARGUMENT;
|
return ORBIS_NP_TROPHY_ERROR_INVALID_ARGUMENT;
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
const auto trophyDir =
|
const auto trophyDir =
|
||||||
Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) / game_serial / "TrophyFiles";
|
Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) / game_serial / "TrophyFiles";
|
||||||
#else
|
|
||||||
const auto trophyDir =
|
|
||||||
Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) / game_serial / "TrophyFiles";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pugi::xml_document doc;
|
pugi::xml_document doc;
|
||||||
pugi::xml_parse_result result =
|
pugi::xml_parse_result result =
|
||||||
doc.load_file((trophyDir.string() + "\\trophy00\\Xml\\TROP.XML").c_str());
|
doc.load_file((trophyDir.string() + "/trophy00/Xml/TROP.XML").c_str());
|
||||||
|
|
||||||
// only do this if platinum is not unlocked
|
// only do this if platinum is not unlocked
|
||||||
*platinumId = ORBIS_NP_TROPHY_INVALID_TROPHY_ID;
|
*platinumId = ORBIS_NP_TROPHY_INVALID_TROPHY_ID;
|
||||||
@ -564,8 +559,10 @@ int PS4_SYSV_ABI sceNpTrophyUnlockTrophy(OrbisNpTrophyContext context, OrbisNpTr
|
|||||||
for (pugi::xml_node_iterator it = trophyconf.children().begin();
|
for (pugi::xml_node_iterator it = trophyconf.children().begin();
|
||||||
it != trophyconf.children().end() && !foundTrophy; ++it) {
|
it != trophyconf.children().end() && !foundTrophy; ++it) {
|
||||||
|
|
||||||
std::string currentTrophyId = reinterpret_cast<const char*>(it->attribute("id").value());
|
std::string currentTrophyId =
|
||||||
std::string currentTrophyName = reinterpret_cast<const char*>(it->child("name").text().as_string());
|
reinterpret_cast<const char*>(it->attribute("id").value());
|
||||||
|
std::string currentTrophyName =
|
||||||
|
reinterpret_cast<const char*>(it->child("name").text().as_string());
|
||||||
std::string currentTrophyDescription =
|
std::string currentTrophyDescription =
|
||||||
reinterpret_cast<const char*>(it->child("detail").text().as_string());
|
reinterpret_cast<const char*>(it->child("detail").text().as_string());
|
||||||
std::string currentTrophyType =
|
std::string currentTrophyType =
|
||||||
@ -590,7 +587,7 @@ int PS4_SYSV_ABI sceNpTrophyUnlockTrophy(OrbisNpTrophyContext context, OrbisNpTr
|
|||||||
|
|
||||||
g_trophy_ui.AddTrophyToQueue(trophyId, currentTrophyName, TrophyType::BRONZE);
|
g_trophy_ui.AddTrophyToQueue(trophyId, currentTrophyName, TrophyType::BRONZE);
|
||||||
|
|
||||||
//doc.save_file((trophyDir.string() + "\\trophy00\\Xml\\TROP.XML").c_str());
|
//doc.save_file((trophyDir.string() + "/trophy00/Xml/TROP.XML").c_str());
|
||||||
}
|
}
|
||||||
foundTrophy = true;
|
foundTrophy = true;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <imgui.h>
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <imgui.h>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "imgui/imgui_std.h"
|
#include "imgui/imgui_std.h"
|
||||||
#include "trophy_ui.h"
|
#include "trophy_ui.h"
|
||||||
@ -15,7 +15,6 @@ TrophyUI::TrophyUI() {
|
|||||||
AddLayer(this);
|
AddLayer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TrophyUI::~TrophyUI() {
|
TrophyUI::~TrophyUI() {
|
||||||
Finish();
|
Finish();
|
||||||
}
|
}
|
||||||
@ -41,17 +40,9 @@ void TrophyUI::Draw() {
|
|||||||
|
|
||||||
const ImVec2 window_size{
|
const ImVec2 window_size{
|
||||||
std::min(io.DisplaySize.x, 200.f),
|
std::min(io.DisplaySize.x, 200.f),
|
||||||
std::min(io.DisplaySize.y, 125.f),
|
std::min(io.DisplaySize.y, 75.f),
|
||||||
};
|
};
|
||||||
|
|
||||||
CentralizeWindow();
|
|
||||||
SetNextWindowSize(window_size);
|
|
||||||
SetNextWindowFocus();
|
|
||||||
SetNextWindowCollapsed(false);
|
|
||||||
SetNextWindowPos(ImVec2(io.DisplaySize.x - 200, 50));
|
|
||||||
PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0));
|
|
||||||
KeepNavHighlight();
|
|
||||||
|
|
||||||
if (trophyQueue.size() != 0) {
|
if (trophyQueue.size() != 0) {
|
||||||
if (!displayingTrophy) {
|
if (!displayingTrophy) {
|
||||||
displayingTrophy = true;
|
displayingTrophy = true;
|
||||||
@ -68,17 +59,21 @@ void TrophyUI::Draw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (trophyQueue.size() != 0) {
|
if (trophyQueue.size() != 0) {
|
||||||
|
SetNextWindowSize(window_size);
|
||||||
|
SetNextWindowCollapsed(false);
|
||||||
|
SetNextWindowPos(ImVec2(io.DisplaySize.x - 200, 50));
|
||||||
|
KeepNavHighlight();
|
||||||
|
|
||||||
TrophyInfo currentTrophyInfo = trophyQueue[0];
|
TrophyInfo currentTrophyInfo = trophyQueue[0];
|
||||||
if (Begin("Trophy Window", nullptr,
|
if (Begin("Trophy Window", nullptr,
|
||||||
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings)) {
|
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings
|
||||||
|
| ImGuiWindowFlags_NoInputs)) {
|
||||||
Text("Trophy earned!");
|
Text("Trophy earned!");
|
||||||
Text(currentTrophyInfo.trophyName.c_str());
|
TextWrapped(currentTrophyInfo.trophyName.c_str());
|
||||||
|
|
||||||
End();
|
End();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PopStyleColor();
|
|
||||||
first_render = false;
|
first_render = false;
|
||||||
}
|
}
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "common/fixed_value.h"
|
#include "common/fixed_value.h"
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "core/file_format/playgo_chunk.h"
|
#include "core/file_format/playgo_chunk.h"
|
||||||
#include "core/file_format/psf.h"
|
#include "core/file_format/psf.h"
|
||||||
#include "core/file_format/splash.h"
|
#include "core/file_format/splash.h"
|
||||||
|
#include "core/file_format/trp.h"
|
||||||
#include "core/file_sys/fs.h"
|
#include "core/file_sys/fs.h"
|
||||||
#include "core/libraries/disc_map/disc_map.h"
|
#include "core/libraries/disc_map/disc_map.h"
|
||||||
#include "core/libraries/kernel/thread_management.h"
|
#include "core/libraries/kernel/thread_management.h"
|
||||||
@ -101,6 +102,14 @@ void Emulator::Run(const std::filesystem::path& file) {
|
|||||||
param_sfo->open(sce_sys_folder.string() + "/param.sfo", {});
|
param_sfo->open(sce_sys_folder.string() + "/param.sfo", {});
|
||||||
id = std::string(param_sfo->GetString("CONTENT_ID"), 7, 9);
|
id = std::string(param_sfo->GetString("CONTENT_ID"), 7, 9);
|
||||||
Libraries::NpTrophy::game_serial = id;
|
Libraries::NpTrophy::game_serial = id;
|
||||||
|
const auto trophyDir = Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) /
|
||||||
|
id / "TrophyFiles";
|
||||||
|
if (!std::filesystem::exists(trophyDir)) {
|
||||||
|
TRP trp;
|
||||||
|
if (!trp.Extract(file.parent_path())) {
|
||||||
|
LOG_ERROR(Loader, "Couldn't extract trophies");
|
||||||
|
}
|
||||||
|
}
|
||||||
#ifdef ENABLE_QT_GUI
|
#ifdef ENABLE_QT_GUI
|
||||||
MemoryPatcher::g_game_serial = id;
|
MemoryPatcher::g_game_serial = id;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user