Emergency 20 Dokumentation  4.2.0
IngameHighscoreDatasource.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include <Rocket/Controls/DataSource.h>
14 
15 
16 //[-------------------------------------------------------]
17 //[ Forward declarations ]
18 //[-------------------------------------------------------]
19 namespace em5
20 {
21  struct HighscoreOnlinePage;
22 }
23 
24 
25 //[-------------------------------------------------------]
26 //[ Namespace ]
27 //[-------------------------------------------------------]
28 namespace em5
29 {
30 
31 
32  //[-------------------------------------------------------]
33  //[ Classes ]
34  //[-------------------------------------------------------]
39  class IngameHighscoreDatasource : public Rocket::Controls::DataSource
40  {
41 
42 
43  //[-------------------------------------------------------]
44  //[ Public methods ]
45  //[-------------------------------------------------------]
46  public:
49 
56  void setupMainEventHighscores(uint32 eventId);
59 
70  bool fetch(const uint32 currentRank);
71 
72  int getRowIndexForRank(uint32 rank) const;
73  uint32 getMaxRank() const;
74 
75 
76  //[-------------------------------------------------------]
77  //[ Public virtual Rocket::Controls::DataSource methods ]
78  //[-------------------------------------------------------]
79  public:
80  virtual void GetRow(Rocket::Core::StringList& row, const Rocket::Core::String& table, int rowIndex, const Rocket::Core::StringList& columns) override;
81  virtual int GetNumRows(const Rocket::Core::String& table) override;
82 
83 
84  //[-------------------------------------------------------]
85  //[ Private definitions ]
86  //[-------------------------------------------------------]
87  private:
88  // This struct represents one row in the highscore table
89  struct TableData
90  {
91  uint32 rankAsNumber;
94  Rocket::Core::String points;
95  };
96 
97 
98  //[-------------------------------------------------------]
99  //[ Private methods ]
100  //[-------------------------------------------------------]
101  private:
102  bool buildTableData(uint32 entryId, const std::string& highscoreId);
103 
104  void addDataToTable(const HighscoreOnlinePage& hiscorePage, uint32 firstRank, uint32 lastRank);
105  void addSpecialRow();
106  void addTopTenItems(const HighscoreOnlinePage& highscorePage);
107 
108 
109  //[-------------------------------------------------------]
110  //[ Private data ]
111  //[-------------------------------------------------------]
112  private:
113  std::vector<TableData*> mTableData;
114  std::string mHighscoreId;
115  uint32 mMaxRank;
116 
117 
118  };
119 
120 
121 //[-------------------------------------------------------]
122 //[ Namespace ]
123 //[-------------------------------------------------------]
124 } // em5
Definition: ActionPriority.h:13
unsigned int uint32
Definition: PlatformTypes.h:181
bool fetch(const uint32 currentRank)
Let the datasource fetch the highscore data from server.
void setupMainEventHighscores(uint32 eventId)
Ingame highscore datasource.
Definition: IngameHighscoreDatasource.h:39
Definition: HighscoreManager.h:71
virtual void GetRow(Rocket::Core::StringList &row, const Rocket::Core::String &table, int rowIndex, const Rocket::Core::StringList &columns) override
Definition: MiniMapWindow.h:43
virtual int GetNumRows(const Rocket::Core::String &table) override
void setupFreeplayEndlessHighscores()
Setup datasource for which highscore type data should be fetched.
int getRowIndexForRank(uint32 rank) const