(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.

This commit is contained in:
rubidium 2008-04-11 21:19:03 +00:00
parent 02a907f306
commit 00d23c57b3
3 changed files with 19 additions and 14 deletions

View File

@ -51,6 +51,11 @@ enum OrderWindowWidgets {
ORDER_WIDGET_RESIZE, ORDER_WIDGET_RESIZE,
}; };
struct order_d {
int sel;
};
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d));
/** /**
* Return the memorised selected order. * Return the memorised selected order.
* *

View File

@ -36,11 +36,16 @@ enum TimetableViewWindowWidgets {
TTV_RESIZE, 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) static int GetOrderFromTimetableWndPt(Window *w, int y, const Vehicle *v)
{ {
/* /*
* Calculation description: * 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 * 10 = order text hight
*/ */
int sel = (y - 15) / 10; int sel = (y - 15) / 10;
@ -66,7 +71,7 @@ static inline void SetTimetableParams(int param1, int param2, uint32 time)
static void DrawTimetableWindow(Window *w) static void DrawTimetableWindow(Window *w)
{ {
const Vehicle *v = GetVehicle(w->window_number); 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); SetVScrollCount(w, v->num_orders * 2);
@ -259,17 +264,17 @@ static void TimetableWndProc(Window *w, WindowEvent *we)
case TTV_TIMETABLE_PANEL: { /* Main panel. */ case TTV_TIMETABLE_PANEL: { /* Main panel. */
int selected = GetOrderFromTimetableWndPt(w, we->we.click.pt.y, v); 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 */ /* Deselect clicked order */
WP(w, order_d).sel = -1; WP(w, timetable_d).sel = -1;
} else { } else {
/* Select clicked order */ /* Select clicked order */
WP(w, order_d).sel = selected; WP(w, timetable_d).sel = selected;
} }
} break; } break;
case TTV_CHANGE_TIME: { /* "Wait For" button. */ 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; VehicleOrderID real = (selected + 1) / 2;
if (real >= v->num_orders) real = 0; if (real >= v->num_orders) real = 0;
@ -291,7 +296,7 @@ static void TimetableWndProc(Window *w, WindowEvent *we)
} break; } break;
case TTV_CLEAR_TIME: { /* Clear waiting time button. */ 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)); DoCommandP(0, p1, 0, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
} break; } break;
@ -310,7 +315,7 @@ static void TimetableWndProc(Window *w, WindowEvent *we)
case WE_ON_EDIT_TEXT: { case WE_ON_EDIT_TEXT: {
const Vehicle *v = GetVehicle(w->window_number); 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); uint64 time = StrEmpty(we->we.edittext.str) ? 0 : strtoul(we->we.edittext.str, NULL, 10);
if (!_patches.timetable_in_ticks) time *= DAY_TICKS; if (!_patches.timetable_in_ticks) time *= DAY_TICKS;
@ -366,6 +371,6 @@ void ShowTimetableWindow(const Vehicle *v)
w->caption_color = v->owner; w->caption_color = v->owner;
w->vscroll.cap = 8; w->vscroll.cap = 8;
w->resize.step_height = 10; w->resize.step_height = 10;
WP(w, order_d).sel = -1; WP(w, timetable_d).sel = -1;
} }
} }

View File

@ -390,11 +390,6 @@ struct depot_d {
}; };
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(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 { struct vehicledetails_d {
byte tab; byte tab;
}; };