From e6fb6ecafeb12bab5d30740621aefef441fa308d Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sun, 18 Oct 2009 14:29:46 +0000 Subject: [PATCH] In the watching-menu, keep the same player selected even when resorting the entries. git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@493 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- dgamelaunch.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dgamelaunch.c b/dgamelaunch.c index 3cdf07e..963012f 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -383,6 +383,8 @@ inprogressmenu (int gameid) int max_height = -1; int selected = -1; + char *selectedgame = NULL; + int abs_max_height; int top_banner_hei = 5; int btm_banner_hei = 3; @@ -622,8 +624,20 @@ watchgame: } } + if (selected >= 0 && selected < len) + selectedgame = strdup(games[selected]->name); games = populate_games (gameid, &len, me); games = sort_games (games, len, sortmode); + if (selectedgame) { + selected = -1; + for (i = 0; i < len; i++) + if (!strcmp(games[i]->name, selectedgame)) { + selected = i; + break; + } + free(selectedgame); + selectedgame = NULL; + } } if (is_nhext) free(is_nhext); free_populated_games(games, len);