Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Trophies fix #166

Merged
merged 6 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
297 changes: 159 additions & 138 deletions core/trophies/trophies.cpp

Large diffs are not rendered by default.

35 changes: 26 additions & 9 deletions core/trophies/trophies.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ITrophies {
public:
virtual ~ITrophies() = default;

enum class ErrCodes {
enum class ParserErr {
SUCCESS = 0, // No errors, we're fine
INVALID_CONTEXT, // Context is nullptr
OUT_OF_MEMORY, // Failed to allocate data array
Expand All @@ -37,6 +37,19 @@ class ITrophies {
MAX_TROPHY_REACHED, // The game hit the hard limit of 128 trophies
};

struct usr_context {
struct trophy {
int32_t id = -1;
uint32_t re = 0; // reserved
uint64_t ts = 0;
};

uint32_t label = 0;
int32_t userId = -1;

std::vector<trophy> trophies = {};
};

struct trp_grp_cb {
struct data_t {
int32_t id;
Expand Down Expand Up @@ -99,6 +112,9 @@ class ITrophies {
};

struct trp_unlock_data {
int32_t userId;
uint32_t label;

struct image {
void* pngdata;
size_t pngsize;
Expand All @@ -115,21 +131,22 @@ class ITrophies {
std::string pdescr;
};

virtual ErrCodes parseTRP(trp_context* context) = 0;
virtual const char* getError(ErrCodes ec) = 0;
virtual ParserErr parseTRP(uint32_t label, trp_context* context) = 0;
virtual const char* getError(ParserErr ec) = 0;

// Callbacks

virtual void addTrophyUnlockCallback(vvpfunc func) = 0;

//- Callbacks

virtual int32_t createContext(int32_t userId, uint32_t label) = 0;
virtual int32_t destroyContext(int32_t userId) = 0;
virtual int32_t getProgress(int32_t userId, uint32_t progress[4], uint32_t* count) = 0;
virtual uint64_t getUnlockTime(int32_t userId, int32_t trophyId) = 0;
virtual int32_t unlockTrophy(int32_t userId, int32_t trophyId, int32_t* platinumId) = 0;
virtual bool resetUserInfo(int32_t userId) = 0;
virtual int32_t createContext(int32_t userId, uint32_t label, int32_t* ctxid) = 0;
virtual usr_context* getContext(int32_t ctxid) = 0;
virtual int32_t destroyContext(usr_context* ctx) = 0;
virtual int32_t getProgress(usr_context* ctx, uint32_t progress[4], uint32_t* count) = 0;
virtual uint64_t getUnlockTime(usr_context* ctx, int32_t trophyId) = 0;
virtual int32_t unlockTrophy(usr_context* ctx, int32_t trophyId, int32_t* platinumId) = 0;
virtual int32_t resetUserInfo(usr_context* ctx) = 0;
};

#if defined(__APICALL_EXTERN)
Expand Down
2 changes: 1 addition & 1 deletion core/videoout/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ add_library(videoout OBJECT

overlay/overlay.cpp
overlay/overtrophy/overtrophy.cpp
overlay/gamemenu/gamemenu.cpp
#overlay/gamemenu/gamemenu.cpp
)

add_dependencies(videoout third_party psOff_utility initParams config_emu psoff_render)
Expand Down
4 changes: 2 additions & 2 deletions core/videoout/overlay/gamemenu/gamemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ void GameMenu::switchTo(MenuState state) {
},
};

ITrophies::ErrCodes ec;
if ((ec = accessTrophies().parseTRP(&ctx)) != ITrophies::ErrCodes::SUCCESS) {
ITrophies::ParserErr ec;
if ((ec = accessTrophies().parseTRP(&ctx)) != ITrophies::ParserErr::SUCCESS) {
m_trophyList.clear();
m_trophyList.emplace_back(0, 'e', false, "Failed to load trophies", accessTrophies().getError(ec));
}
Expand Down
8 changes: 4 additions & 4 deletions core/videoout/overlay/overlay.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "overlay.h"

#include "gamemenu/gamemenu.h"
// #include "gamemenu/gamemenu.h"
#include "logging.h"
#include "overtrophy/overtrophy.h"

Expand All @@ -16,7 +16,7 @@ class OverlayHandler: public IOverlayHandler {
std::shared_ptr<IImageHandler> m_imageHandler;

OverTrophy m_overTrophy;
GameMenu m_gameMenu;
// GameMenu m_gameMenu;

VkDescriptorPool m_descriptorPool;

Expand Down Expand Up @@ -129,7 +129,7 @@ void OverlayHandler::init(SDL_Window* window, vulkan::QueueInfo* queue, VkFormat

ImGui_ImplVulkan_Init(&initInfo);
m_overTrophy.init();
m_gameMenu.init();
// m_gameMenu.init();

m_isInit = true;
}
Expand Down Expand Up @@ -175,5 +175,5 @@ void OverlayHandler::draw() {
// ImGui::ShowDemoWindow();
auto const fps = m_imageHandler->getFPS();
m_overTrophy.draw(fps);
m_gameMenu.draw();
// m_gameMenu.draw();
}
34 changes: 18 additions & 16 deletions modules/libSceNpTrophy/codes.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@

namespace Err {
namespace NpTrophy {
constexpr int32_t SCREENSHOT_DISABLED = -2141907413;
constexpr int32_t INVALID_USER_ID = -2141907419;
constexpr int32_t EXCEEDS_MAX = -2141907422;
constexpr int32_t INVALID_NP_TITLE_ID = -2141907424;
constexpr int32_t ICON_FILE_NOT_FOUND = -2141907436;
constexpr int32_t CONTEXT_ALREADY_EXISTS = -2141907437;
constexpr int32_t INSUFFICIENT_SPACE = -2141907438;
constexpr int32_t BROKEN_DATA = -2141907439;
constexpr int32_t PLATINUM_CANNOT_UNLOCK = -2141907443;
constexpr int32_t ALREADY_UNLOCKED = -2141907444;
constexpr int32_t INVALID_GROUP_ID = -2141907445;
constexpr int32_t INVALID_TROPHY_ID = -2141907446;
constexpr int32_t INVALID_CONTEXT = -2141907447;
constexpr int32_t INSUFFICIENT_BUFFER = -2141907451;
constexpr int32_t INVALID_ARGUMENT = -2141907452;
constexpr int32_t UNKNOWN = -2141907456;
constexpr int32_t SCREENSHOT_DISABLED = -2141907413;
constexpr int32_t INVALID_USER_ID = -2141907419;
constexpr int32_t CONTEXT_EXCEEDS_MAX = -2141907421;
constexpr int32_t INVALID_NP_SERVICE_LABEL = -2141907423;
constexpr int32_t INVALID_NP_TITLE_ID = -2141907424;
constexpr int32_t ICON_FILE_NOT_FOUND = -2141907436;
constexpr int32_t CONTEXT_ALREADY_EXISTS = -2141907437;
constexpr int32_t INSUFFICIENT_SPACE = -2141907438;
constexpr int32_t BROKEN_DATA = -2141907439;
constexpr int32_t PLATINUM_CANNOT_UNLOCK = -2141907443;
constexpr int32_t ALREADY_UNLOCKED = -2141907444;
constexpr int32_t INVALID_GROUP_ID = -2141907445;
constexpr int32_t INVALID_TROPHY_ID = -2141907446;
constexpr int32_t INVALID_CONTEXT = -2141907447;
constexpr int32_t EXCEEDS_MAX = -2141907450;
constexpr int32_t INSUFFICIENT_BUFFER = -2141907451;
constexpr int32_t INVALID_ARGUMENT = -2141907452;
constexpr int32_t UNKNOWN = -2141907456;
} // namespace NpTrophy
} // namespace Err

Expand Down
Loading
Loading