25{
26 clear();
27
28 addNew<Wt::WText>("<h2>Hall of fame</h2>");
29
31
32 std::string yourScore;
33 if (ranking == 1)
34 yourScore = "Congratulations! You are currently leading the pack.";
35 else {
36 yourScore = "You are currently ranked number "
37 + asString(ranking).toUTF8()
38 + ". Almost there !";
39 }
40
41 WText *score = addNew<WText>("<p>" + yourScore + "</p>");
42 score->addStyleClass("score");
43
45
46 WTable *table = addNew<WTable>();
47
48 table->elementAt(0, 0)->addNew<WText>("Rank");
49 table->elementAt(0, 1)->addNew<WText>("User");
50 table->elementAt(0, 2)->addNew<WText>("Games");
51 table->elementAt(0, 3)->addNew<WText>("Score");
52 table->elementAt(0, 4)->addNew<WText>("Last game");
53 table->setHeaderCount(1);
54
55 int formerScore = -1;
56 int rank = 0;
57 for (auto& user : top) {
58
59 if (user.score != formerScore) {
60 formerScore = user.score;
61 ++rank;
62 }
63
64 int row = table->rowCount();
65 table->elementAt(row, 0)->addNew<WText>(asString(rank));
66 table->elementAt(row, 1)->addNew<WText>(user.name);
67 table->elementAt(row, 2)->addNew<WText>(asString(user.gamesPlayed));
68 table->elementAt(row, 3)->addNew<WText>(asString(user.score));
69 if (!user.lastGame.isNull())
70 table->elementAt(row, 4)->addNew<WText>(user.lastGame.timeTo(WDateTime::currentDateTime()) + " ago");
71 else
72 table->elementAt(row, 4)->addNew<WText>("---");
73
75 table->rowAt(row)->setId("self");
76 }
77
78 WText *fineprint = addNew<WText>(tr("highscore.info"));
79 fineprint->addStyleClass("fineprint");
80}
std::vector< User > topUsers(int limit)
std::string userName() const
Wt::Auth::Login & login()