summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-12-05 14:18:58 +0000
committerpeter1138 <peter1138@openttd.org>2006-12-05 14:18:58 +0000
commitcc2c2a0fb178b9a3158db8f01eab1b7ba85e1388 (patch)
tree59bb2105b79484171483f922b627be53022a4727
parent9218fc16e6fff350e6209b6b90b8597fc431f00f (diff)
downloadopenttd-cc2c2a0fb178b9a3158db8f01eab1b7ba85e1388.tar.xz
(svn r7373) -Codechange: when removing a GRF from the list, make the next one selected, or the previous file if the last item is being removed. This makes clearing the list easier.
-rw-r--r--newgrf_gui.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/newgrf_gui.c b/newgrf_gui.c
index 7d7eb4f2c..ae14401a9 100644
--- a/newgrf_gui.c
+++ b/newgrf_gui.c
@@ -331,15 +331,24 @@ static void NewGRFWndProc(Window *w, WindowEvent *e)
}
case 4: { /* Remove GRF */
- GRFConfig **pc, *c;
+ GRFConfig **pc, *c, *newsel;
+
+ /* Choose the next GRF file to be the selected file */
+ newsel = WP(w, newgrf_d).sel->next;
+
for (pc = WP(w, newgrf_d).list; (c = *pc) != NULL; pc = &c->next) {
+ /* If the new selection is empty (i.e. we're deleting the last item
+ * in the list, pick the file just before the selected file */
+ if (newsel == NULL && c->next == WP(w, newgrf_d).sel) newsel = c;
+
if (c == WP(w, newgrf_d).sel) {
*pc = c->next;
free(c);
break;
}
}
- WP(w, newgrf_d).sel = NULL;
+
+ WP(w, newgrf_d).sel = newsel;
SetupNewGRFWindow(w);
SetWindowDirty(w);
break;