ref: a1b066a0eb0d2cf5d17ad68ca833fcdd21f80725
parent: d832e501dd51097ff679b287bd2a5de5bb3b1799
author: Simon Howard <[email protected]>
date: Wed Apr 9 20:48:04 EDT 2014
setup: Save selected game when browsing menus. Once a game type (IWAD) has been selected, remember that selection rather than resetting to the first item in the list when the window is closed and reopened. This fixes #169 (thanks Alexandre Xavier).
--- a/src/setup/multiplayer.c
+++ b/src/setup/multiplayer.c
@@ -66,7 +66,7 @@
// Index of the currently selected IWAD
-static int found_iwad_selected;
+static int found_iwad_selected = -1;
// Filename to pass to '-iwad'.
@@ -599,9 +599,15 @@
result = (txt_widget_t *) dropdown;
}
- // Select first in the list.
+ // The first time the dialog is opened, found_iwad_selected=-1,
+ // so select the first IWAD in the list. Don't lose the setting
+ // if we close and reopen the dialog.
- found_iwad_selected = 0;
+ if (found_iwad_selected < 0 || found_iwad_selected >= num_iwads)
+ {
+ found_iwad_selected = 0;
+ }
+
IWADSelected(NULL, NULL);
return result;