diff --git a/src/core/libraries/np_trophy/np_trophy.cpp b/src/core/libraries/np_trophy/np_trophy.cpp index 83c45a562..2c10fe299 100644 --- a/src/core/libraries/np_trophy/np_trophy.cpp +++ b/src/core/libraries/np_trophy/np_trophy.cpp @@ -542,17 +542,12 @@ int PS4_SYSV_ABI sceNpTrophyUnlockTrophy(OrbisNpTrophyContext context, OrbisNpTr if (platinumId == nullptr) return ORBIS_NP_TROPHY_ERROR_INVALID_ARGUMENT; -#ifdef _WIN32 const auto trophyDir = 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_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 *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(); it != trophyconf.children().end() && !foundTrophy; ++it) { - std::string currentTrophyId = reinterpret_cast(it->attribute("id").value()); - std::string currentTrophyName = reinterpret_cast(it->child("name").text().as_string()); + std::string currentTrophyId = + reinterpret_cast(it->attribute("id").value()); + std::string currentTrophyName = + reinterpret_cast(it->child("name").text().as_string()); std::string currentTrophyDescription = reinterpret_cast(it->child("detail").text().as_string()); std::string currentTrophyType = @@ -590,7 +587,7 @@ int PS4_SYSV_ABI sceNpTrophyUnlockTrophy(OrbisNpTrophyContext context, OrbisNpTr 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; } diff --git a/src/core/libraries/np_trophy/trophy_ui.cpp b/src/core/libraries/np_trophy/trophy_ui.cpp index ce79211f9..9ce68fe72 100644 --- a/src/core/libraries/np_trophy/trophy_ui.cpp +++ b/src/core/libraries/np_trophy/trophy_ui.cpp @@ -1,8 +1,8 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include #include +#include #include "common/assert.h" #include "imgui/imgui_std.h" #include "trophy_ui.h" @@ -15,7 +15,6 @@ TrophyUI::TrophyUI() { AddLayer(this); } - TrophyUI::~TrophyUI() { Finish(); } @@ -41,17 +40,9 @@ void TrophyUI::Draw() { const ImVec2 window_size{ 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 (!displayingTrophy) { displayingTrophy = true; @@ -68,17 +59,21 @@ void TrophyUI::Draw() { } if (trophyQueue.size() != 0) { + SetNextWindowSize(window_size); + SetNextWindowCollapsed(false); + SetNextWindowPos(ImVec2(io.DisplaySize.x - 200, 50)); + KeepNavHighlight(); + TrophyInfo currentTrophyInfo = trophyQueue[0]; if (Begin("Trophy Window", nullptr, - ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings)) { + ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings + | ImGuiWindowFlags_NoInputs)) { Text("Trophy earned!"); - Text(currentTrophyInfo.trophyName.c_str()); + TextWrapped(currentTrophyInfo.trophyName.c_str()); End(); } } } - - PopStyleColor(); first_render = false; } \ No newline at end of file diff --git a/src/core/libraries/np_trophy/trophy_ui.h b/src/core/libraries/np_trophy/trophy_ui.h index b281f516f..18755bd52 100644 --- a/src/core/libraries/np_trophy/trophy_ui.h +++ b/src/core/libraries/np_trophy/trophy_ui.h @@ -3,9 +3,9 @@ #pragma once +#include #include #include -#include #include "common/fixed_value.h" #include "common/types.h" diff --git a/src/emulator.cpp b/src/emulator.cpp index 2203b1129..08c0407fa 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -19,6 +19,7 @@ #include "core/file_format/playgo_chunk.h" #include "core/file_format/psf.h" #include "core/file_format/splash.h" +#include "core/file_format/trp.h" #include "core/file_sys/fs.h" #include "core/libraries/disc_map/disc_map.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", {}); id = std::string(param_sfo->GetString("CONTENT_ID"), 7, 9); 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 MemoryPatcher::g_game_serial = id; #endif