src/timetable_gui.cpp
author rubidium
Wed, 09 Jan 2008 21:27:39 +0000
changeset 8733 9e2d2a2619ff
parent 8720 4e60c30e2006
child 8750 fdd6054e7bae
permissions -rw-r--r--
(svn r11801) -Codechange: remove some unneeded includes from some header files.
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     1
/* $Id$ */
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     2
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     3
/** @file timetable_gui.cpp */
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     4
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     5
#include "stdafx.h"
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     6
#include "openttd.h"
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     7
#include "variables.h"
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     8
#include "table/strings.h"
8612
6414fc21c2f3 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8610
diff changeset
     9
#include "command_func.h"
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    10
#include "engine.h"
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    11
#include "gui.h"
8603
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
    12
#include "window_gui.h"
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
    13
#include "textbuf_gui.h"
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    14
#include "cargotype.h"
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    15
#include "depot.h"
8610
17cc343a23dd (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8603
diff changeset
    16
#include "strings_func.h"
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
    17
#include "vehicle_base.h"
8710
52015340050c (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8640
diff changeset
    18
#include "string_func.h"
8720
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8710
diff changeset
    19
#include "gfx_func.h"
8733
9e2d2a2619ff (svn r11801) -Codechange: remove some unneeded includes from some header files.
rubidium
parents: 8720
diff changeset
    20
#include "player.h"
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    21
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    22
static int GetOrderFromTimetableWndPt(Window *w, int y, const Vehicle *v)
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    23
{
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    24
	/*
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    25
	 * Calculation description:
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    26
	 * 15 = 14 (w->widget[ORDER_WIDGET_ORDER_LIST].top) + 1 (frame-line)
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    27
	 * 10 = order text hight
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    28
	 */
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    29
	int sel = (y - 15) / 10;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    30
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    31
	if ((uint)sel >= w->vscroll.cap) return INVALID_ORDER;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    32
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    33
	sel += w->vscroll.pos;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    34
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    35
	return (sel <= v->num_orders * 2 && sel >= 0) ? sel : INVALID_ORDER;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    36
}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    37
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    38
static inline void SetTimetableParams(int param1, int param2, uint32 time)
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    39
{
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    40
	if (_patches.timetable_in_ticks) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    41
		SetDParam(param1, STR_TIMETABLE_TICKS);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    42
		SetDParam(param2, time);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    43
	} else {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    44
		SetDParam(param1, STR_TIMETABLE_DAYS);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    45
		SetDParam(param2, time / DAY_TICKS);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    46
	}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    47
}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    48
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    49
static void DrawTimetableWindow(Window *w)
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    50
{
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    51
	const Vehicle *v = GetVehicle(w->window_number);
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
    52
	int selected = WP(w, order_d).sel;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    53
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    54
	SetVScrollCount(w, v->num_orders * 2);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    55
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    56
	if (v->owner == _local_player) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    57
		if (selected == -1) {
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8424
diff changeset
    58
			w->DisableWidget(6);
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8424
diff changeset
    59
			w->DisableWidget(7);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    60
		} else if (selected % 2 == 1) {
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8424
diff changeset
    61
			w->EnableWidget(6);
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8424
diff changeset
    62
			w->EnableWidget(7);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    63
		} else {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    64
			const Order *order = GetVehicleOrder(v, (selected + 1) / 2);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    65
			bool disable = order == NULL || order->type != OT_GOTO_STATION || (_patches.new_nonstop && (order->flags & OF_NON_STOP));
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    66
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8424
diff changeset
    67
			w->SetWidgetDisabledState(6, disable);
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8424
diff changeset
    68
			w->SetWidgetDisabledState(7, disable);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    69
		}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    70
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8424
diff changeset
    71
		w->EnableWidget(8);
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8424
diff changeset
    72
		w->EnableWidget(9);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    73
	} else {
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8424
diff changeset
    74
		w->DisableWidget(6);
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8424
diff changeset
    75
		w->DisableWidget(7);
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8424
diff changeset
    76
		w->DisableWidget(8);
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8424
diff changeset
    77
		w->DisableWidget(9);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    78
	}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    79
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8424
diff changeset
    80
	w->SetWidgetLoweredState(9, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE));
7562
f6f62814907b (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7553
diff changeset
    81
7545
9a4834d48970 (svn r10314) -Codechange: Refer to vehicle names by index
peter1138
parents: 7479
diff changeset
    82
	SetDParam(0, v->index);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    83
	DrawWindowWidgets(w);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    84
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    85
	int y = 15;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    86
	int i = w->vscroll.pos;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    87
	VehicleOrderID order_id = (i + 1) / 2;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    88
	bool final_order = false;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    89
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    90
	const Order *order = GetVehicleOrder(v, order_id);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    91
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    92
	while (order != NULL) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    93
		/* Don't draw anything if it extends past the end of the window. */
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    94
		if (i - w->vscroll.pos >= w->vscroll.cap) break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    95
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    96
		if (i % 2 == 0) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    97
			SetDParam(2, STR_EMPTY);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    98
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    99
			switch (order->type) {
7808
70bb84732406 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7762
diff changeset
   100
				case OT_DUMMY:
70bb84732406 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7762
diff changeset
   101
					SetDParam(0, STR_INVALID_ORDER);
70bb84732406 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7762
diff changeset
   102
					break;
70bb84732406 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7762
diff changeset
   103
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   104
				case OT_GOTO_STATION:
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   105
					SetDParam(0, (order->flags & OF_NON_STOP) ? STR_880C_GO_NON_STOP_TO : STR_8806_GO_TO);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   106
					SetDParam(1, order->dest);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   107
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   108
					if (order->wait_time > 0) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   109
						SetDParam(2, STR_TIMETABLE_STAY_FOR);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   110
						SetTimetableParams(3, 4, order->wait_time);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   111
					}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   112
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   113
					break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   114
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   115
				case OT_GOTO_DEPOT: {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   116
					StringID string = STR_EMPTY;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   117
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   118
					if (v->type == VEH_AIRCRAFT) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   119
						string = STR_GO_TO_AIRPORT_HANGAR;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   120
						SetDParam(1, order->dest);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   121
					} else {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   122
						SetDParam(1, GetDepot(order->dest)->town_index);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   123
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   124
						switch (v->type) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   125
							case VEH_TRAIN: string = (order->flags & OF_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   126
							case VEH_ROAD:  string = STR_9038_GO_TO_ROADVEH_DEPOT; break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   127
							case VEH_SHIP:  string = STR_GO_TO_SHIP_DEPOT; break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   128
							default: break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   129
						}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   130
					}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   131
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   132
					if (order->flags & OF_FULL_LOAD) string++; // Service at orders
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   133
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   134
					SetDParam(0, string);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   135
				} break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   136
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   137
				case OT_GOTO_WAYPOINT:
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   138
					SetDParam(0, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   139
					SetDParam(1, order->dest);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   140
					break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   141
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   142
				default: break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   143
			}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   144
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7837
diff changeset
   145
			DrawString(2, y, STR_TIMETABLE_GO_TO, (i == selected) ? TC_WHITE : TC_BLACK);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   146
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   147
			order_id++;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   148
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   149
			if (order_id >= v->num_orders) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   150
				order = GetVehicleOrder(v, 0);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   151
				final_order = true;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   152
			} else {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   153
				order = order->next;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   154
			}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   155
		} else {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   156
			StringID string;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   157
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   158
			if (order->travel_time == 0) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   159
				string = STR_TIMETABLE_TRAVEL_NOT_TIMETABLED;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   160
			} else {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   161
				SetTimetableParams(0, 1, order->travel_time);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   162
				string = STR_TIMETABLE_TRAVEL_FOR;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   163
			}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   164
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7837
diff changeset
   165
			DrawString(12, y, string, (i == selected) ? TC_WHITE : TC_BLACK);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   166
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   167
			if (final_order) break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   168
		}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   169
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   170
		i++;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   171
		y += 10;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   172
	}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   173
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   174
	y = w->widget[5].top + 1;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   175
7569
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   176
	{
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   177
		uint total_time = 0;
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   178
		bool complete = true;
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   179
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   180
		for (const Order *order = GetVehicleOrder(v, 0); order != NULL; order = order->next) {
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   181
			total_time += order->travel_time + order->wait_time;
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   182
			if (order->travel_time == 0) complete = false;
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   183
			if (order->wait_time == 0 && order->type == OT_GOTO_STATION && !(_patches.new_nonstop && (order->flags & OF_NON_STOP))) complete = false;
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   184
		}
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   185
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   186
		if (total_time != 0) {
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   187
			SetTimetableParams(0, 1, total_time);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7837
diff changeset
   188
			DrawString(2, y, complete ? STR_TIMETABLE_TOTAL_TIME : STR_TIMETABLE_TOTAL_TIME_INCOMPLETE, TC_BLACK);
7569
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   189
		}
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   190
	}
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   191
	y += 10;
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   192
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   193
	if (v->lateness_counter == 0 || (!_patches.timetable_in_ticks && v->lateness_counter / DAY_TICKS == 0)) {
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7837
diff changeset
   194
		DrawString(2, y, STR_TIMETABLE_STATUS_ON_TIME, TC_BLACK);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   195
	} else {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   196
		SetTimetableParams(0, 1, abs(v->lateness_counter));
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7837
diff changeset
   197
		DrawString(2, y, v->lateness_counter < 0 ? STR_TIMETABLE_STATUS_EARLY : STR_TIMETABLE_STATUS_LATE, TC_BLACK);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   198
	}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   199
}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   200
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   201
static inline uint32 PackTimetableArgs(const Vehicle *v, uint selected)
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   202
{
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   203
	uint order_number = (selected + 1) / 2;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   204
	uint is_journey   = (selected % 2 == 1) ? 1 : 0;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   205
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   206
	if (order_number >= v->num_orders) order_number = 0;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   207
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   208
	return v->index | (order_number << 16) | (is_journey << 24);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   209
}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   210
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   211
static void TimetableWndProc(Window *w, WindowEvent *we)
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   212
{
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   213
	switch (we->event) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   214
		case WE_PAINT:
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   215
			DrawTimetableWindow(w);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   216
			break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   217
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   218
		case WE_CLICK: {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   219
			const Vehicle *v = GetVehicle(w->window_number);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   220
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   221
			switch (we->we.click.widget) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   222
				case 3: { /* Main panel. */
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   223
					int selected = GetOrderFromTimetableWndPt(w, we->we.click.pt.y, v);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   224
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
   225
					if (selected == INVALID_ORDER || selected == WP(w, order_d).sel) {
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   226
						/* Deselect clicked order */
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
   227
						WP(w, order_d).sel = -1;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   228
					} else {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   229
						/* Select clicked order */
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
   230
						WP(w, order_d).sel = selected;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   231
					}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   232
				} break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   233
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   234
				case 6: { /* "Wait For" button. */
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
   235
					int selected = WP(w, order_d).sel;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   236
					VehicleOrderID real = (selected + 1) / 2;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   237
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   238
					if (real >= v->num_orders) real = 0;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   239
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   240
					const Order *order = GetVehicleOrder(v, real);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   241
					StringID current = STR_EMPTY;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   242
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   243
					if (order != NULL) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   244
						uint time = (selected % 2 == 1) ? order->travel_time : order->wait_time;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   245
						if (!_patches.timetable_in_ticks) time /= DAY_TICKS;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   246
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   247
						if (time != 0) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   248
							SetDParam(0, time);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   249
							current = STR_CONFIG_PATCHES_INT32;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   250
						}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   251
					}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   252
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   253
					ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, 150, w, CS_NUMERAL);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   254
				} break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   255
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   256
				case 7: { /* Clear waiting time button. */
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
   257
					uint32 p1 = PackTimetableArgs(v, WP(w, order_d).sel);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   258
					DoCommandP(0, p1, 0, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   259
				} break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   260
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   261
				case 8: /* Reset the vehicle's late counter. */
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   262
					DoCommandP(0, v->index, 0, NULL, CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   263
					break;
7562
f6f62814907b (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7553
diff changeset
   264
f6f62814907b (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7553
diff changeset
   265
				case 9: /* Autofill the timetable. */
8424
4a488a90ccab (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 8320
diff changeset
   266
					DoCommandP(0, v->index, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE) ? 0 : 1, NULL, CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
7562
f6f62814907b (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7553
diff changeset
   267
					break;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   268
			}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   269
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   270
			SetWindowDirty(w);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   271
		} break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   272
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   273
		case WE_ON_EDIT_TEXT: {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   274
			const Vehicle *v = GetVehicle(w->window_number);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   275
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
   276
			uint32 p1 = PackTimetableArgs(v, WP(w, order_d).sel);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   277
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   278
			uint64 time = StrEmpty(we->we.edittext.str) ? 0 : strtoul(we->we.edittext.str, NULL, 10);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   279
			if (!_patches.timetable_in_ticks) time *= DAY_TICKS;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   280
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   281
			uint32 p2 = minu(time, MAX_UVALUE(uint16));
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   282
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   283
			DoCommandP(0, p1, p2, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   284
		} break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   285
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   286
		case WE_RESIZE:
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   287
			/* Update the scroll + matrix */
7478
e66a0d39b87d (svn r10238) -Fix (r10236): Resizing the timetable window caused it to think it could only show one line at a time.
maedhros
parents: 7477
diff changeset
   288
			w->vscroll.cap = (w->widget[3].bottom - w->widget[3].top) / 10;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   289
			break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   290
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   291
	}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   292
}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   293
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   294
static const Widget _timetable_widgets[] = {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   295
	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},
7562
f6f62814907b (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7553
diff changeset
   296
	{    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   387,     0,    13, STR_TIMETABLE_TITLE,        STR_018C_WINDOW_TITLE_DRAG_THIS},
f6f62814907b (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7553
diff changeset
   297
	{  WWT_STICKYBOX,   RESIZE_LR,      14,   388,   399,     0,    13, STR_NULL,                   STR_STICKY_BUTTON},
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   298
7562
f6f62814907b (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7553
diff changeset
   299
	{      WWT_PANEL,   RESIZE_RB,      14,     0,   387,    14,    95, STR_NULL,                   STR_TIMETABLE_TOOLTIP},
f6f62814907b (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7553
diff changeset
   300
	{  WWT_SCROLLBAR,   RESIZE_LRB,     14,   388,   399,    14,    95, STR_NULL,                   STR_0190_SCROLL_BAR_SCROLLS_LIST},
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   301
7569
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   302
	{      WWT_PANEL,   RESIZE_RTB,     14,     0,   399,    96,   117, STR_NULL,                   STR_NULL},
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   303
7569
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   304
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,     0,   109,   118,   129, STR_TIMETABLE_CHANGE_TIME,  STR_TIMETABLE_WAIT_TIME_TOOLTIP},
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   305
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   110,   219,   118,   129, STR_CLEAR_TIME,             STR_TIMETABLE_CLEAR_TIME_TOOLTIP},
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   306
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   220,   337,   118,   129, STR_RESET_LATENESS,         STR_TIMETABLE_RESET_LATENESS_TOOLTIP},
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   307
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   338,   387,   118,   129, STR_TIMETABLE_AUTOFILL,     STR_TIMETABLE_AUTOFILL_TOOLTIP},
7553
bb88bdf61f6d (svn r10322) -Codechange: Make the timetable window smaller by default so it doesn't take up so much space on small resolutions.
maedhros
parents: 7545
diff changeset
   308
7569
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   309
	{      WWT_PANEL,   RESIZE_RTB,     14,   388,   387,   118,   129, STR_NULL,                   STR_NULL},
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   310
	{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   388,   399,   118,   129, STR_NULL,                   STR_RESIZE_BUTTON},
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   311
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   312
	{    WIDGETS_END }
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   313
};
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   314
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   315
static const WindowDesc _timetable_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7808
diff changeset
   316
	WDP_AUTO, WDP_AUTO, 400, 130, 400, 130,
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   317
	WC_VEHICLE_TIMETABLE, WC_VEHICLE_VIEW,
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   318
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   319
	_timetable_widgets,
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   320
	TimetableWndProc
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   321
};
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   322
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   323
void ShowTimetableWindow(const Vehicle *v)
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   324
{
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   325
	Window *w = AllocateWindowDescFront(&_timetable_desc, v->index);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   326
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   327
	if (w != NULL) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   328
		w->caption_color = v->owner;
7553
bb88bdf61f6d (svn r10322) -Codechange: Make the timetable window smaller by default so it doesn't take up so much space on small resolutions.
maedhros
parents: 7545
diff changeset
   329
		w->vscroll.cap = 8;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   330
		w->resize.step_height = 10;
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
   331
		WP(w, order_d).sel = -1;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   332
	}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   333
}