summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-11 21:19:03 +0000
committerrubidium <rubidium@openttd.org>2008-04-11 21:19:03 +0000
commit00d23c57b3686b4ee07683dadd74d42708386fec (patch)
tree1661f6eed42f8c6bc72dfa3d80cc8ecb304bc82e /src
parent02a907f3060b89d461d6286af7f1528742114ea5 (diff)
downloadopenttd-00d23c57b3686b4ee07683dadd74d42708386fec.tar.xz
(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
Diffstat (limited to 'src')
-rw-r--r--src/order_gui.cpp5
-rw-r--r--src/timetable_gui.cpp23
-rw-r--r--src/window_gui.h5
3 files changed, 19 insertions, 14 deletions
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index 46ed659bd..28f3f04f0 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -51,6 +51,11 @@ enum OrderWindowWidgets {
ORDER_WIDGET_RESIZE,
};
+struct order_d {
+ int sel;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d));
+
/**
* Return the memorised selected order.
*
diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp
index 372897841..63cc962e9 100644
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -36,11 +36,16 @@ enum TimetableViewWindowWidgets {
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 inline void SetTimetableParams(int param1, int param2, uint32 time)
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 @@ static void TimetableWndProc(Window *w, WindowEvent *we)
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 @@ static void TimetableWndProc(Window *w, WindowEvent *we)
} 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 @@ static void TimetableWndProc(Window *w, WindowEvent *we)
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 @@ void ShowTimetableWindow(const Vehicle *v)
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;
}
}
diff --git a/src/window_gui.h b/src/window_gui.h
index 990bed27b..dc28614b0 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -390,11 +390,6 @@ struct depot_d {
};
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;
};