the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at master 133 lines 3.7 kB view raw
1#pragma once 2 3#include "Common\Leaderboards\LeaderboardManager.h" 4 5#ifdef __PS3__ 6typedef CellRtcTick SonyRtcTick; 7#else 8typedef SceRtcTick SonyRtcTick; 9#endif 10 11class SonyLeaderboardManager : public LeaderboardManager 12{ 13protected: 14 enum EStatsState 15 { 16 eStatsState_Idle, 17 eStatsState_Getting, 18 eStatsState_Failed, 19 eStatsState_Ready, 20 eStatsState_Canceled, 21 eStatsState_Max 22 }; 23 24public: 25 SonyLeaderboardManager(); 26 virtual ~SonyLeaderboardManager(); 27 28protected: 29 unsigned short m_openSessions; 30 31 C4JThread *m_threadScoreboard; 32 bool m_running; 33 34 int m_titleContext; 35 int32_t m_requestId; 36 37 //SceNpId m_myNpId; 38 39 static int scoreboardThreadEntry(LPVOID lpParam); 40 void scoreboardThreadInternal(); 41 42 virtual bool getScoreByIds(); 43 virtual bool getScoreByRange(); 44 45 virtual bool setScore(); 46 47 queue<RegisterScore> m_views; 48 49 CRITICAL_SECTION m_csViewsLock; 50 51 EStatsState m_eStatsState; //State of the stats read 52 // EFilterMode m_eFilterMode; 53 54 ReadScore *m_scores; 55 unsigned int m_maxRank; 56 //SceNpScoreRankData *m_stats; 57 58public: 59 virtual void Tick(); 60 61 //Open a session 62 virtual bool OpenSession(); 63 64 //Close a session 65 virtual void CloseSession(); 66 67 //Delete a session 68 virtual void DeleteSession(); 69 70 //Write the given stats 71 //This is called synchronously and will not free any memory allocated for views when it is done 72 73 virtual bool WriteStats(unsigned int viewCount, ViewIn views); 74 75 virtual bool ReadStats_Friends(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID, unsigned int startIndex, unsigned int readCount); 76 virtual bool ReadStats_MyScore(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID, unsigned int readCount); 77 virtual bool ReadStats_TopRank(LeaderboardReadListener *callback, int difficulty, EStatsType type, unsigned int startIndex, unsigned int readCount); 78 79 //Perform a flush of the stats 80 virtual void FlushStats(); 81 82 //Cancel the current operation 83 virtual void CancelOperation(); 84 85 //Is the leaderboard manager idle. 86 virtual bool isIdle(); 87 88protected: 89 int getBoardId(int difficulty, EStatsType); 90 91 SceNpScorePlayerRankData *addPadding(unsigned int num, SceNpScoreRankData *rankData); 92 93 void convertToOutput(unsigned int &num, ReadScore *out, SceNpScorePlayerRankData *rankData, SceNpScoreComment *comm); 94 95 void toBinary(void *out, SceNpScoreComment *in); 96 void fromBinary(SceNpScoreComment **out, void *in); 97 98 void toBase32(SceNpScoreComment *out, void *in); 99 void fromBase32(void *out, SceNpScoreComment *in); 100 101 void toSymbols(char *); 102 void fromSymbols(char *); 103 104 bool test_string(string); 105 106 void initReadScoreStruct(ReadScore &out, SceNpScoreRankData &); 107 void fillReadScoreStruct(ReadScore &out, SceNpScoreComment &comment); 108 109 static bool SortByRank(const ReadScore &lhs, const ReadScore &rhs); 110 111 112protected: 113 // 4J-JEV: Interface differences: 114 115 // Sce NP score library function redirects. 116 virtual HRESULT initialiseScoreUtility() { return ERROR_SUCCESS; } 117 virtual bool scoreUtilityAlreadyInitialised(HRESULT hr) { return false; } 118 119 virtual HRESULT createTitleContext(const SceNpId &npId) = 0; 120 virtual HRESULT destroyTitleContext(int titleContext) = 0; 121 122 virtual HRESULT createTransactionContext(int titleContext) = 0; 123 virtual HRESULT abortTransactionContext(int transactionContext) = 0; 124 virtual HRESULT destroyTransactionContext(int transactionContext) = 0; 125 126 virtual HRESULT fillByIdsQuery(const SceNpId &myNpId, SceNpId* &npIds, uint32_t &len); 127 128#if (defined __ORBIS__) || (defined __PSVITA__) 129 virtual HRESULT getFriendsList(sce::Toolkit::NP::Utilities::Future<sce::Toolkit::NP::FriendsList> &friendsList) = 0; 130#endif 131 132 virtual char * getComment(SceNpScoreComment *comment) = 0; 133};