the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2#include "XUI_Helper.h"
3#include "../media/xuiscene_leaderboards.h"
4
5#include "..\Leaderboards\LeaderboardManager.h"
6
7class CXuiCtrlCraftIngredientSlot;
8
9class CScene_Leaderboards : public CXuiSceneImpl, public LeaderboardReadListener
10{
11private:
12 // 4J Stu - Because the kills leaderboard doesn't a peaceful entry there are some special
13 // handling to make it skip that. We have re-arranged the order of the leaderboards so
14 // I am making this in case we do it again.
15 // 4J Stu - Made it a member of the class, rather than a #define
16 static const int LEADERBOARD_KILLS_POSITION = 3;
17
18 static const int NUM_LEADERBOARDS = 4;//6; //Number of leaderboards
19 static const int NUM_ENTRIES = 101; //Cache up to this many entries
20 static const int READ_SIZE = 15; //Read this many entries at a time
21
22// static LPCWSTR FLAG_ICON_PATHS[37];
23 int m_iPad;
24
25 bool m_bPopulatedOnce;
26
27 static const int LEADERBOARD_HEADERS[NUM_LEADERBOARDS][4];
28
29 static const int TitleIcons[NUM_LEADERBOARDS][7];
30 static LPCWSTR m_TitleIconNameA[7];
31 static LPCWSTR m_TextColumnNameA[7];
32 HXUIOBJ m_hTextEntryA[7];
33
34 struct LeaderboardDescriptor {
35 DWORD m_viewId;
36 DWORD m_columnCount;
37 WORD m_columnIds[8];
38
39 LeaderboardDescriptor(DWORD viewId, DWORD columnCount, WORD columnId_0, WORD columnId_1, WORD columnId_2, WORD columnId_3, WORD columnId_4, WORD columnId_5, WORD columnId_6, WORD columnId_7)
40 {
41 m_viewId = viewId;
42 m_columnCount = columnCount;
43 m_columnIds[0] = columnId_0;
44 m_columnIds[1] = columnId_1;
45 m_columnIds[2] = columnId_2;
46 m_columnIds[3] = columnId_3;
47 m_columnIds[4] = columnId_4;
48 m_columnIds[5] = columnId_5;
49 m_columnIds[6] = columnId_6;
50 m_columnIds[7] = columnId_7;
51 }
52 };
53
54 static const LeaderboardDescriptor LEADERBOARD_DESCRIPTORS[NUM_LEADERBOARDS][4];
55
56 struct LeaderboardEntry {
57 PlayerUID m_xuid;
58 DWORD m_rank;
59 WCHAR m_wcRank[12];
60 WCHAR m_gamerTag[XUSER_NAME_SIZE+1];
61 //int m_locale;
62 unsigned int m_columns[7];
63 WCHAR m_wcColumns[7][12];
64 bool m_bPlayer; //Is the player
65 bool m_bOnline; //Is online
66 bool m_bFriend; //Is friend
67 bool m_bRequestedFriend; //Friend request sent but not answered
68 };
69
70 struct Leaderboard {
71 DWORD m_totalEntryCount; //Either total number of entries in leaderboard, or total number of results for a friends query
72 DWORD m_entryStartIndex; //Index of first entry
73 DWORD m_currentEntryCount; //Current number of entries
74 LeaderboardEntry m_entries[NUM_ENTRIES];
75 DWORD m_numColumns;
76 };
77
78 Leaderboard m_leaderboard; //All leaderboard data for the currently selected filter
79
80 unsigned int m_currentLeaderboard; //The current leaderboard selected for view
81
82#ifdef _XBOX
83 LeaderboardManager::EFilterMode m_currentFilter; //The current filter selected
84#endif
85 unsigned int m_currentDifficulty; //The current difficulty selected
86
87 unsigned int m_newEntryIndex; //Index of the first entry being read
88 unsigned int m_newReadSize; //Number of entries in the current read operation
89
90 int m_newTop; //Index of the element that should be at the top of the list
91 int m_newSel; //Index of the element that should be selected in the list
92
93 XONLINE_FRIEND* m_friends; //Current player's friends
94 unsigned int m_numFriends; //Count of friends
95 PlayerUID* m_filteredFriends; //List of all friend XUIDs (and player's), only counting actual friends, not pending
96 unsigned int m_numFilteredFriends; //Count of filtered friends
97
98 CXuiList m_listGamers; //The XUI list showing the leaderboard info
99 CXuiControl m_textLeaderboard; //The XUI text box showing the current leaderboard name
100 CXuiControl m_textInfo; //The XUI text box showing info messages (loading, no results, etc.)
101 CXuiControl m_textFilter; //The XUI text box showing the current filter
102 CXuiControl m_textEntries; //The XUI text box showing the total number of entries in this leaderboard
103 CXuiCtrlCraftIngredientSlot *m_pHTitleIconSlots[7];
104 float m_fTitleIconXPositions[7];
105 float m_fTextXPositions[7];
106
107 XUI_BEGIN_MSG_MAP()
108 XUI_ON_XM_INIT( OnInit )
109 XUI_ON_XM_DESTROY( OnDestroy )
110 XUI_ON_XM_KEYDOWN( OnKeyDown )
111 XUI_ON_XM_GET_ITEMCOUNT_ALL(OnGetItemCountAll)
112 XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
113 XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceDataImage)
114 XUI_ON_XM_NOTIFY_SELCHANGED(OnNotifySelChanged)
115 XUI_ON_XM_NOTIFY_SET_FOCUS(OnNotifySetFocus)
116
117 XUI_END_MSG_MAP()
118
119 BEGIN_CONTROL_MAP()
120 MAP_CONTROL(IDC_XuiListGamers, m_listGamers)
121 MAP_CONTROL(IDC_XuiTextLeaderboard, m_textLeaderboard)
122 MAP_CONTROL(IDC_XuiTextInfo, m_textInfo)
123 MAP_CONTROL(IDC_XuiTextFilter, m_textFilter)
124 MAP_CONTROL(IDC_XuiTextEntries, m_textEntries)
125 END_CONTROL_MAP()
126
127 HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
128 HRESULT OnDestroy();
129 HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& bHandled);
130 HRESULT OnGetItemCountAll(XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled);
131 HRESULT OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled);
132 HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage* pGetImage, BOOL& bHandled);
133 HRESULT OnNotifySetFocus(HXUIOBJ hObjSource, XUINotifyFocus *pNotifyFocusData, BOOL& bHandled);
134 HRESULT OnNotifySelChanged(HXUIOBJ hObjSource, XUINotifySelChanged *pNotifySelChangedData, BOOL& bHandled);
135
136 //Start a read request with the current parameters
137 void ReadStats(int startIndex);
138
139 //Callback function called when stats read completes, userdata contains pointer to instance of CScene_Leaderboards
140 virtual bool OnStatsReadComplete(bool success, int numResults, LeaderboardManager::ViewOut results);
141
142 //Copy the stats from the raw m_stats structure into the m_leaderboards structure
143 int m_numStats;
144 PXUSER_STATS_READ_RESULTS m_stats;
145 bool RetrieveStats();
146
147 //Populate the XUI leaderboard with the contents of m_leaderboards
148 void PopulateLeaderboard(bool noResults);
149
150 //Copy a leaderboard entry from the stats row
151 void CopyLeaderboardEntry(PXUSER_STATS_ROW statsRow, LeaderboardEntry* leaderboardEntry, bool isDistanceLeaderboard);
152
153 //Set the header text of the leaderboard
154 void SetLeaderboardHeader();
155
156 // Set the title icons
157 int SetLeaderboardTitleIcons();
158 void ClearLeaderboardTitlebar();
159 void Reposition(int iNumber);
160 void RepositionText(int iNumber);
161 void UpdateTooltips();
162
163protected:
164 bool m_isProcessingStatsRead;
165 bool m_bReady;
166public:
167
168 XUI_IMPLEMENT_CLASS( CScene_Leaderboards, L"CScene_Leaderboards", XUI_CLASS_SCENE )
169};