summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2014-04-10 00:48:04 -0400
committerSimon Howard2014-04-10 00:48:04 -0400
commita1b066a0eb0d2cf5d17ad68ca833fcdd21f80725 (patch)
treed7ccf1ae7ffa07f356e593d96dfa72359cb8e739
parentd832e501dd51097ff679b287bd2a5de5bb3b1799 (diff)
downloadchocolate-doom-a1b066a0eb0d2cf5d17ad68ca833fcdd21f80725.tar.gz
chocolate-doom-a1b066a0eb0d2cf5d17ad68ca833fcdd21f80725.tar.bz2
chocolate-doom-a1b066a0eb0d2cf5d17ad68ca833fcdd21f80725.zip
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).
-rw-r--r--src/setup/multiplayer.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c
index 35552349..8b461066 100644
--- a/src/setup/multiplayer.c
+++ b/src/setup/multiplayer.c
@@ -66,7 +66,7 @@ static char *iwad_labels[8];
// 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 @@ static txt_widget_t *IWADSelector(void)
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.
+
+ if (found_iwad_selected < 0 || found_iwad_selected >= num_iwads)
+ {
+ found_iwad_selected = 0;
+ }
- found_iwad_selected = 0;
IWADSelected(NULL, NULL);
return result;