the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at master 147 lines 5.2 kB view raw
1#pragma once 2 3#include "UIScene.h" 4// #include "..\Leaderboards\LeaderboardManager.h" 5#include "..\Leaderboards\LeaderboardInterface.h" 6 7class UIScene_LeaderboardsMenu : public UIScene, public LeaderboardReadListener 8{ 9private: 10 // 4J Stu - Because the kills leaderboard doesn't a peaceful entry there are some special 11 // handling to make it skip that. We have re-arranged the order of the leaderboards so 12 // I am making this in case we do it again. 13 // 4J Stu - Made it a member of the class, rather than a #define 14 static const int LEADERBOARD_KILLS_POSITION = 3; 15 16 static const int NUM_LEADERBOARDS = 4;//6; //Number of leaderboards 17 static const int NUM_ENTRIES = 101; //Cache up to this many entries 18 static const int READ_SIZE = 15; //Read this many entries at a time 19 20 struct LeaderboardDescriptor { 21 unsigned int m_columnCount; 22 bool m_isDistanceLeaderboard; 23 unsigned int m_title; 24 25 LeaderboardDescriptor(unsigned int columnCount, bool isDistanceLeaderboard, unsigned int title) 26 { 27 m_columnCount = columnCount; 28 m_isDistanceLeaderboard = isDistanceLeaderboard; 29 m_title = title; 30 } 31 }; 32 33 static const LeaderboardDescriptor LEADERBOARD_DESCRIPTORS[NUM_LEADERBOARDS][4]; 34 static const int TitleIcons[NUM_LEADERBOARDS][7]; 35 36 struct LeaderboardEntry { 37 PlayerUID m_xuid; 38 unsigned int m_row; // Row identifier for passing to Iggy as a unique identifier 39 DWORD m_rank; 40 WCHAR m_wcRank[12]; 41 WCHAR m_gamerTag[XUSER_NAME_SIZE+1]; 42 //int m_locale; 43 unsigned int m_columns[7]; 44 WCHAR m_wcColumns[7][12]; 45 bool m_bPlayer; //Is the player 46 bool m_bOnline; //Is online 47 bool m_bFriend; //Is friend 48 bool m_bRequestedFriend; //Friend request sent but not answered 49 int m_idsErrorMessage; // 4J-JEV: Non-zero if this entry has an error message instead of results. 50 }; 51 52 struct Leaderboard { 53 DWORD m_totalEntryCount; //Either total number of entries in leaderboard, or total number of results for a friends query 54 vector<LeaderboardEntry> m_entries; 55 DWORD m_numColumns; 56 }; 57 58 Leaderboard m_leaderboard; //All leaderboard data for the currently selected filter 59 60 unsigned int m_currentLeaderboard; //The current leaderboard selected for view 61 LeaderboardManager::EFilterMode m_currentFilter; //The current filter selected 62 unsigned int m_currentDifficulty; //The current difficulty selected 63 64 unsigned int m_newEntryIndex; //Index of the first entry being read 65 unsigned int m_newReadSize; //Number of entries in the current read operation 66 67 unsigned int m_newEntriesCount; // Number of new entries in this update 68 69 int m_newTop; //Index of the element that should be at the top of the list 70 int m_newSel; //Index of the element that should be selected in the list 71 72 bool m_isProcessingStatsRead; 73 bool m_bPopulatedOnce; 74 bool m_bReady; 75 76 LeaderboardInterface m_interface; 77 78 UIControl_LeaderboardList m_listEntries; 79 UIControl_Label m_labelFilter, m_labelLeaderboard, m_labelEntries, m_labelInfo; 80 UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) 81 UI_MAP_ELEMENT( m_listEntries, "Gamers") 82 83 UI_MAP_ELEMENT( m_labelFilter, "Filter") 84 UI_MAP_ELEMENT( m_labelLeaderboard, "Leaderboard") 85 UI_MAP_ELEMENT( m_labelEntries, "Entries") 86 UI_MAP_ELEMENT( m_labelInfo, "Info") 87 UI_END_MAP_ELEMENTS_AND_NAMES() 88 89 static int ExitLeaderboards(void *pParam,int iPad,C4JStorage::EMessageResult result); 90 91public: 92 UIScene_LeaderboardsMenu(int iPad, void *initData, UILayer *parentLayer); 93 ~UIScene_LeaderboardsMenu(); 94 95 virtual void updateTooltips(); 96 virtual void updateComponents(); 97 98 virtual EUIScene getSceneType() { return eUIScene_LeaderboardsMenu;} 99 100 // Returns true if this scene has focus for the pad passed in 101 virtual bool hasFocus(int iPad) { return bHasFocus; } 102 virtual void handleTimerComplete(int id); 103 104private: 105 int GetEntryStartIndex(); 106 107protected: 108 virtual wstring getMoviePath(); 109 110public: 111 virtual void tick(); 112 virtual void handleReload(); 113 114 // INPUT 115 virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled); 116 117private: 118 //Start a read request with the current parameters 119 void ReadStats(int startIndex); 120 121 //Copy the stats from the raw m_stats structure into the m_leaderboards structure 122 int m_numStats; 123 LeaderboardManager::ViewOut m_stats; 124 bool RetrieveStats(); 125 126 // Copy a leaderboard entry from the stats row 127 void CopyLeaderboardEntry(LeaderboardManager::ReadScore *statsRow, int leaderboardEntryIndex, bool isDistanceLeaderboard); 128 129 //Populate the XUI leaderboard with the contents of m_leaderboards 130 void PopulateLeaderboard(LeaderboardManager::eStatsReturn ret); 131 132 //Set the header text of the leaderboard 133 void SetLeaderboardHeader(); 134 135 // Set the title icons 136 int SetLeaderboardTitleIcons(); 137 138 //Callback function called when stats read completes, userdata contains pointer to instance of CScene_Leaderboards 139 virtual bool OnStatsReadComplete(LeaderboardManager::eStatsReturn ret, int numResults, LeaderboardManager::ViewOut results); 140 141 virtual void customDraw(IggyCustomDrawCallbackRegion *region); 142 143 virtual void handleSelectionChanged(F64 selectedId); 144 virtual void handleRequestMoreData(F64 startIndex, bool up); 145 146 bool m_bIgnoreInput; 147};