From 8216903e7cf482e47803eb61dbe115e9745597f4 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Mon, 23 Feb 2015 13:36:41 +0100 Subject: [PATCH] contrib/nitrpg: add GamesListPanel to display the list of active games Signed-off-by: Alexandre Terrasa --- contrib/nitrpg/src/templates/panels.nit | 66 +++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/contrib/nitrpg/src/templates/panels.nit b/contrib/nitrpg/src/templates/panels.nit index a792703..e4e7f8f 100644 --- a/contrib/nitrpg/src/templates/panels.nit +++ b/contrib/nitrpg/src/templates/panels.nit @@ -113,6 +113,72 @@ class MDPanel end end +# Display a list of active game. +# +# Used for NitRPG homepage. +class GamesShortListPanel + super Panel + + # Root url used for links. + var root_url: String + + # List of NitRPG games to display. + var games: Array[Game] + + redef fun render_title do + add "  " + add "Active games" + end + + redef fun render_body do + if games.is_empty then + add "No game yet..." + return + end + var sorted = games.to_a + (new GamePlayersComparator).sort(sorted) + for game in sorted do + add "{game.link} ({game.load_players.length} players)
" + end + end +end + +# A panel that display a list of player in a repo. +class GamesListPanel + super GamesShortListPanel + super TablePanel + + redef fun render_title do + add "  " + add "Active games" + end + + redef fun render_body do + if games.is_empty then + add "
" + add "No player yet..." + add "
" + return + end + var sorted = games.to_a + (new GamePlayersComparator).sort(sorted) + add """ + + + + + """ + for game in sorted do + add "" + add " " + add " " + add " " + add "" + end + add "
GamePlayersAchievements
{game.link}{game.load_players.length}{game.load_achievements.length}
" + end +end + # A panel that display repo statistics. class GameStatusPanel super Panel -- 1.7.9.5