the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2
3#include "..\..\..\Minecraft.World\StringHelpers.h"
4
5#include "LeaderboardManager.h"
6
7const wstring LeaderboardManager::filterNames[eNumFilterModes] =
8 {
9 L"Friends", L"MyScore", L"TopRank"
10 };
11
12void LeaderboardManager::DeleteInstance()
13{
14 delete m_instance;
15 m_instance = NULL;
16}
17
18LeaderboardManager::LeaderboardManager()
19{
20 zeroReadParameters();
21
22 m_myXUID = INVALID_XUID;
23}
24
25void LeaderboardManager::zeroReadParameters()
26{
27 m_difficulty = -1;
28 m_statsType = eStatsType_UNDEFINED;
29 m_readListener = NULL;
30 m_startIndex = 0;
31 m_readCount = 0;
32 m_eFilterMode = eFM_UNDEFINED;
33}
34
35bool LeaderboardManager::ReadStats_Friends(LeaderboardReadListener *listener, int difficulty, EStatsType type, PlayerUID myUID, unsigned int startIndex, unsigned int readCount)
36{
37 zeroReadParameters();
38
39 m_readListener = listener;
40 m_difficulty = difficulty;
41 m_statsType = type;
42
43 m_eFilterMode = eFM_Friends;
44 return true;
45}
46
47bool LeaderboardManager::ReadStats_MyScore(LeaderboardReadListener *listener, int difficulty, EStatsType type, PlayerUID myUID, unsigned int readCount)
48{
49 zeroReadParameters();
50
51 m_readListener = listener;
52 m_difficulty = difficulty;
53 m_statsType = type;
54
55 m_readCount = readCount;
56
57 m_eFilterMode = eFM_MyScore;
58 return true;
59}
60
61bool LeaderboardManager::ReadStats_TopRank(LeaderboardReadListener *listener, int difficulty, EStatsType type, unsigned int startIndex, unsigned int readCount)
62{
63 zeroReadParameters();
64
65 m_readListener = listener;
66 m_difficulty = difficulty;
67 m_statsType = type;
68
69 m_startIndex = startIndex;
70 m_readCount = readCount;
71
72 m_eFilterMode = eFM_TopRank;
73 return true;
74}
75
76#ifndef _XBOX
77void LeaderboardManager::printStats(ReadView &view)
78{
79 app.DebugPrintf("[LeaderboardManager] Printing stats:\n"
80 "\tnumQueries=%i\n", view.m_numQueries);
81
82 for (int i=0; i<view.m_numQueries; i++)
83 {
84 ReadScore score = view.m_queries[i];
85
86 app.DebugPrintf( "\tname='%s'\n", wstringtofilename(wstring(score.m_name)) );
87 app.DebugPrintf( "\trank='%i'\n", score.m_rank );
88
89 app.DebugPrintf( "\tstatsData=[" );
90 for (int j=0; j<score.m_statsSize; j++)
91 app.DebugPrintf( " %i", score.m_statsData[j] );
92 app.DebugPrintf( "]\n" );
93 }
94}
95
96
97bool DebugReadListener::OnStatsReadComplete(LeaderboardManager::eStatsReturn success, int numResults, LeaderboardManager::ViewOut results)
98{
99 app.DebugPrintf("[DebugReadListener] OnStatsReadComplete, %s:\n", (success ? "success" : "FAILED") );
100 LeaderboardManager::printStats(results);
101
102 return true;
103}
104
105DebugReadListener *DebugReadListener::m_instance = new DebugReadListener();
106#endif