(svn r6607) - Fix (r6601): Fix selection of refit type when the list is scrolled.
authorpeter1138
Sun, 01 Oct 2006 14:55:53 +0000
changeset 4697 67032d30eab0
parent 4696 ec607a44f79c
child 4698 b787a418296f
(svn r6607) - Fix (r6601): Fix selection of refit type when the list is scrolled.
vehicle_gui.c
--- a/vehicle_gui.c	Sun Oct 01 14:48:22 2006 +0000
+++ b/vehicle_gui.c	Sun Oct 01 14:55:53 2006 +0000
@@ -294,14 +294,14 @@
 	uint i;
 
 	/* Draw the list, and find the selected cargo (by its position in list) */
-	for (i = pos; i < num_lines && i < pos + rows; i++) {
+	for (i = 0; i < num_lines; i++) {
 		byte colour = 16;
 		if (sel == 0) {
 			selected = &refit[i];
 			colour = 12;
 		}
 
-		if (i >= pos && y < rows * 10) {
+		if (i >= pos && i < pos + rows) {
 			/* Draw the cargo name */
 			int last_x = DrawString(2, y, _cargoc.names_s[_local_cargo_id_ctype[refit[i].cargo]], colour);
 
@@ -367,7 +367,7 @@
 				case 3: { // listbox
 					int y = e->we.click.pt.y - w->widget[3].top;
 					if (y >= 0) {
-						WP(w,refit_d).sel = y / (int)w->resize.step_height;
+						WP(w,refit_d).sel = (y / (int)w->resize.step_height) + w->vscroll.pos;
 						SetWindowDirty(w);
 					}
 				} break;