#ifndef KYTY_COMMON_TROPHIES_H_ #define KYTY_COMMON_TROPHIES_H_ #include #include #include #include #include #include #include #include #include #include #include namespace Common::Trophies { inline constexpr char PackageDirectory[] = "sce_sys/trophy2"; inline constexpr uint64_t UnixEpochTick = 62135596800000000ULL; enum class Comparison { None, GreaterEqual, Greater, LessEqual, Less }; struct Trophy { int id = 0; int group_id = -1; int platinum_id = -1; int grade = 0; std::optional target; std::optional uds_stat_id; Comparison comparison = Comparison::None; bool progressive = false; std::string name; std::string description; std::string reward; std::vector icon_png; bool hidden = false; bool has_reward = false; }; struct UdsRule { uint64_t stat_id; std::string input; bool is_uint32; }; using UdsRules = std::map>; using UdsInteger = std::variant; struct Package { std::string title; std::map groups; std::map trophies; UdsRules event_rules; }; struct UnlockData { std::set unlocked; std::map timestamps; }; struct Progress { std::array total_grade {}; std::array earned_grade {}; uint32_t total = 0; uint32_t earned = 0; [[nodiscard]] uint32_t Percentage() const; }; [[nodiscard]] Progress GetProgress(const Package& package, const UnlockData& unlocks, std::optional group = std::nullopt); [[nodiscard]] Package LoadPackage(const std::filesystem::path& path, int console_language); [[nodiscard]] std::filesystem::path PackagePath(uint32_t service_label); [[nodiscard]] std::filesystem::path UdsPackagePath(uint32_t service_label); [[nodiscard]] UdsRules LoadUdsRules(const std::filesystem::path& path); [[nodiscard]] std::vector FindUdsTrophies(const Package& package, std::string_view event_name, const std::map& properties); [[nodiscard]] std::filesystem::path UnlocksPath(const std::filesystem::path& root, std::string_view title_id, int user_id, uint32_t service_label); [[nodiscard]] UnlockData LoadUnlockData(const std::filesystem::path& path); [[nodiscard]] bool SaveUnlockData(const std::filesystem::path& path, const UnlockData& unlocks); } // namespace Common::Trophies #endif // KYTY_COMMON_TROPHIES_H_