changeset 8896:95aa37122b68 draft

(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
author rubidium <rubidium@openttd.org>
date Fri, 11 Apr 2008 21:19:03 +0000
parents 80625432d041
children 723bed4b0900
files src/order_gui.cpp src/timetable_gui.cpp src/window_gui.h
diffstat 3 files changed, 19 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -51,6 +51,11 @@
 	ORDER_WIDGET_RESIZE,
 };
 
+struct order_d {
+	int sel;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d));
+
 /**
  * Return the memorised selected order.
  *
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -36,11 +36,16 @@
 	TTV_RESIZE,
 };
 
+struct timetable_d {
+	int sel;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(timetable_d));
+
 static int GetOrderFromTimetableWndPt(Window *w, int y, const Vehicle *v)
 {
 	/*
 	 * Calculation description:
-	 * 15 = 14 (w->widget[ORDER_WIDGET_ORDER_LIST].top) + 1 (frame-line)
+	 * 15 = 14 (w->widget[TTV_ORDER_VIEW].top) + 1 (frame-line)
 	 * 10 = order text hight
 	 */
 	int sel = (y - 15) / 10;
@@ -66,7 +71,7 @@
 static void DrawTimetableWindow(Window *w)
 {
 	const Vehicle *v = GetVehicle(w->window_number);
-	int selected = WP(w, order_d).sel;
+	int selected = WP(w, timetable_d).sel;
 
 	SetVScrollCount(w, v->num_orders * 2);
 
@@ -259,17 +264,17 @@
 				case TTV_TIMETABLE_PANEL: { /* Main panel. */
 					int selected = GetOrderFromTimetableWndPt(w, we->we.click.pt.y, v);
 
-					if (selected == INVALID_ORDER || selected == WP(w, order_d).sel) {
+					if (selected == INVALID_ORDER || selected == WP(w, timetable_d).sel) {
 						/* Deselect clicked order */
-						WP(w, order_d).sel = -1;
+						WP(w, timetable_d).sel = -1;
 					} else {
 						/* Select clicked order */
-						WP(w, order_d).sel = selected;
+						WP(w, timetable_d).sel = selected;
 					}
 				} break;
 
 				case TTV_CHANGE_TIME: { /* "Wait For" button. */
-					int selected = WP(w, order_d).sel;
+					int selected = WP(w, timetable_d).sel;
 					VehicleOrderID real = (selected + 1) / 2;
 
 					if (real >= v->num_orders) real = 0;
@@ -291,7 +296,7 @@
 				} break;
 
 				case TTV_CLEAR_TIME: { /* Clear waiting time button. */
-					uint32 p1 = PackTimetableArgs(v, WP(w, order_d).sel);
+					uint32 p1 = PackTimetableArgs(v, WP(w, timetable_d).sel);
 					DoCommandP(0, p1, 0, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
 				} break;
 
@@ -310,7 +315,7 @@
 		case WE_ON_EDIT_TEXT: {
 			const Vehicle *v = GetVehicle(w->window_number);
 
-			uint32 p1 = PackTimetableArgs(v, WP(w, order_d).sel);
+			uint32 p1 = PackTimetableArgs(v, WP(w, timetable_d).sel);
 
 			uint64 time = StrEmpty(we->we.edittext.str) ? 0 : strtoul(we->we.edittext.str, NULL, 10);
 			if (!_patches.timetable_in_ticks) time *= DAY_TICKS;
@@ -366,6 +371,6 @@
 		w->caption_color = v->owner;
 		w->vscroll.cap = 8;
 		w->resize.step_height = 10;
-		WP(w, order_d).sel = -1;
+		WP(w, timetable_d).sel = -1;
 	}
 }
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -390,11 +390,6 @@
 };
 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(depot_d));
 
-struct order_d {
-	int sel;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d));
-
 struct vehicledetails_d {
 	byte tab;
 };