src/timetable_gui.cpp
author rubidium
Sun, 17 Aug 2008 21:07:09 +0000
changeset 9942 c3677fa5563f
parent 9778 c5dd94ed7c16
child 10093 687ec810f0a1
permissions -rw-r--r--
(svn r14097) -Fix [FS#2085]: one couldn't get a list of vehicles sharing an order when the number of orders was 0; you could see that the vehicles had a shared order though.
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     1
/* $Id$ */
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8962
diff changeset
     3
/** @file timetable_gui.cpp GUI for time tabling. */
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     4
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     5
#include "stdafx.h"
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     6
#include "openttd.h"
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     7
#include "variables.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
     8
#include "command_func.h"
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     9
#include "gui.h"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    10
#include "window_gui.h"
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    11
#include "textbuf_gui.h"
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    12
#include "cargotype.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8107
diff changeset
    13
#include "strings_func.h"
8144
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8140
diff changeset
    14
#include "vehicle_base.h"
8214
971f861d5543 (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8144
diff changeset
    15
#include "string_func.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8214
diff changeset
    16
#include "gfx_func.h"
8254
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8237
diff changeset
    17
#include "player_func.h"
8929
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8903
diff changeset
    18
#include "order_func.h"
8270
e7c342f6b14c (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8264
diff changeset
    19
#include "settings_type.h"
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    20
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    21
#include "table/strings.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    22
8722
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
    23
enum TimetableViewWindowWidgets {
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
    24
	TTV_WIDGET_CLOSEBOX = 0,
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
    25
	TTV_CAPTION,
8745
5bfa77abab47 (svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents: 8722
diff changeset
    26
	TTV_ORDER_VIEW,
8722
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
    27
	TTV_STICKY,
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
    28
	TTV_TIMETABLE_PANEL,
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
    29
	TTV_SCROLLBAR,
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
    30
	TTV_SUMMARY_PANEL,
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
    31
	TTV_CHANGE_TIME,
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
    32
	TTV_CLEAR_TIME,
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
    33
	TTV_RESET_LATENESS,
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
    34
	TTV_AUTOFILL,
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
    35
	TTV_EMPTY,
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
    36
	TTV_RESIZE,
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
    37
};
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
    38
8929
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8903
diff changeset
    39
void SetTimetableParams(int param1, int param2, uint32 time)
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    40
{
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
    41
	if (_settings_client.gui.timetable_in_ticks) {
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    42
		SetDParam(param1, STR_TIMETABLE_TICKS);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    43
		SetDParam(param2, time);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    44
	} else {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    45
		SetDParam(param1, STR_TIMETABLE_DAYS);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    46
		SetDParam(param2, time / DAY_TICKS);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    47
	}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    48
}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    49
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    50
struct TimetableWindow : Window {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    51
	int sel_index;
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    52
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    53
	TimetableWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    54
	{
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    55
		this->caption_color = GetVehicle(window_number)->owner;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    56
		this->vscroll.cap = 8;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    57
		this->resize.step_height = 10;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    58
		this->sel_index = -1;
9333
2da01b3b71d8 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 9317
diff changeset
    59
2da01b3b71d8 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 9317
diff changeset
    60
		this->FindWindowPlacementAndResize(desc);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    61
	}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    62
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    63
	int GetOrderFromTimetableWndPt(int y, const Vehicle *v)
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    64
	{
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    65
		/*
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    66
		 * Calculation description:
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    67
		 * 15 = 14 (this->widget[TTV_ORDER_VIEW].top) + 1 (frame-line)
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    68
		 * 10 = order text hight
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    69
		 */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    70
		int sel = (y - 15) / 10;
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    71
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    72
		if ((uint)sel >= this->vscroll.cap) return INVALID_ORDER;
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    73
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    74
		sel += this->vscroll.pos;
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    75
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    76
		return (sel <= v->num_orders * 2 && sel >= 0) ? sel : INVALID_ORDER;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    77
	}
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    78
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    79
	void OnPaint()
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    80
	{
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    81
		const Vehicle *v = GetVehicle(this->window_number);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    82
		int selected = this->sel_index;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    83
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    84
		SetVScrollCount(this, v->num_orders * 2);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    85
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    86
		if (v->owner == _local_player) {
9641
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
    87
			bool disable = true;
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
    88
			if (selected != -1) {
9665
dd6c07db9d32 (svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium
parents: 9641
diff changeset
    89
				const Order *order = GetVehicleOrder(v, ((selected + 1) / 2) % v->num_orders);
9641
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
    90
				if (selected % 2 == 1) {
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
    91
					disable = order != NULL && order->IsType(OT_CONDITIONAL);
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
    92
				} else {
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
    93
					disable = order == NULL || ((!order->IsType(OT_GOTO_STATION) || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)) && !order->IsType(OT_CONDITIONAL));
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
    94
				}
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
    95
			}
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    96
9641
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
    97
			this->SetWidgetDisabledState(TTV_CHANGE_TIME, disable);
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
    98
			this->SetWidgetDisabledState(TTV_CLEAR_TIME, disable);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    99
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   100
			this->EnableWidget(TTV_RESET_LATENESS);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   101
			this->EnableWidget(TTV_AUTOFILL);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   102
		} else {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   103
			this->DisableWidget(TTV_CHANGE_TIME);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   104
			this->DisableWidget(TTV_CLEAR_TIME);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   105
			this->DisableWidget(TTV_RESET_LATENESS);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   106
			this->DisableWidget(TTV_AUTOFILL);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   107
		}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   108
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   109
		this->SetWidgetLoweredState(TTV_AUTOFILL, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE));
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   110
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   111
		SetDParam(0, v->index);
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9253
diff changeset
   112
		this->DrawWidgets();
7073
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   113
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   114
		int y = 15;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   115
		int i = this->vscroll.pos;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   116
		VehicleOrderID order_id = (i + 1) / 2;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   117
		bool final_order = false;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   118
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   119
		const Order *order = GetVehicleOrder(v, order_id);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   120
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   121
		while (order != NULL) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   122
			/* Don't draw anything if it extends past the end of the window. */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   123
			if (i - this->vscroll.pos >= this->vscroll.cap) break;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   124
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   125
			if (i % 2 == 0) {
9639
58530f2b5fdc (svn r13702) -Fix: do not overflow the order/timetable window when 'long' orders are displayed.
rubidium
parents: 9605
diff changeset
   126
				DrawOrderString(v, order, order_id, y, i == selected, true, this->widget[TTV_TIMETABLE_PANEL].right - 4);
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   127
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   128
				order_id++;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   129
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   130
				if (order_id >= v->num_orders) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   131
					order = GetVehicleOrder(v, 0);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   132
					final_order = true;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   133
				} else {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   134
					order = order->next;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   135
				}
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   136
			} else {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   137
				StringID string;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   138
9641
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
   139
				if (order->IsType(OT_CONDITIONAL)) {
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
   140
					string = STR_TIMETABLE_NO_TRAVEL;
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
   141
				} else if (order->travel_time == 0) {
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   142
					string = STR_TIMETABLE_TRAVEL_NOT_TIMETABLED;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   143
				} else {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   144
					SetTimetableParams(0, 1, order->travel_time);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   145
					string = STR_TIMETABLE_TRAVEL_FOR;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   146
				}
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   147
9639
58530f2b5fdc (svn r13702) -Fix: do not overflow the order/timetable window when 'long' orders are displayed.
rubidium
parents: 9605
diff changeset
   148
				DrawStringTruncated(2, y, string, (i == selected) ? TC_WHITE : TC_BLACK, this->widget[TTV_TIMETABLE_PANEL].right - 4);
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   149
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   150
				if (final_order) break;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   151
			}
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   152
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   153
			i++;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   154
			y += 10;
7073
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   155
		}
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   156
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   157
		y = this->widget[TTV_SUMMARY_PANEL].top + 1;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   158
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   159
		{
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   160
			uint total_time = 0;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   161
			bool complete = true;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   162
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   163
			for (const Order *order = GetVehicleOrder(v, 0); order != NULL; order = order->next) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   164
				total_time += order->travel_time + order->wait_time;
9641
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
   165
				if (order->travel_time == 0 && !order->IsType(OT_CONDITIONAL)) complete = false;
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   166
				if (order->wait_time == 0 && order->IsType(OT_GOTO_STATION) && !(order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)) complete = false;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   167
			}
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   168
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   169
			if (total_time != 0) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   170
				SetTimetableParams(0, 1, total_time);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   171
				DrawString(2, y, complete ? STR_TIMETABLE_TOTAL_TIME : STR_TIMETABLE_TOTAL_TIME_INCOMPLETE, TC_BLACK);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   172
			}
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   173
		}
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   174
		y += 10;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   175
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
   176
		if (v->lateness_counter == 0 || (!_settings_client.gui.timetable_in_ticks && v->lateness_counter / DAY_TICKS == 0)) {
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   177
			DrawString(2, y, STR_TIMETABLE_STATUS_ON_TIME, TC_BLACK);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   178
		} else {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   179
			SetTimetableParams(0, 1, abs(v->lateness_counter));
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   180
			DrawString(2, y, v->lateness_counter < 0 ? STR_TIMETABLE_STATUS_EARLY : STR_TIMETABLE_STATUS_LATE, TC_BLACK);
7073
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   181
		}
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   182
	}
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   183
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   184
	static inline uint32 PackTimetableArgs(const Vehicle *v, uint selected)
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   185
	{
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   186
		uint order_number = (selected + 1) / 2;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   187
		uint is_journey   = (selected % 2 == 1) ? 1 : 0;
7066
e5d16aa8d6ca (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7057
diff changeset
   188
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   189
		if (order_number >= v->num_orders) order_number = 0;
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   190
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   191
		return v->index | (order_number << 16) | (is_journey << 24);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   192
	}
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   193
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   194
	virtual void OnClick(Point pt, int widget)
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   195
	{
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   196
		const Vehicle *v = GetVehicle(this->window_number);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   197
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   198
		switch (widget) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   199
			case TTV_ORDER_VIEW: /* Order view button */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   200
				ShowOrdersWindow(v);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   201
				break;
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   202
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   203
			case TTV_TIMETABLE_PANEL: { /* Main panel. */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   204
				int selected = GetOrderFromTimetableWndPt(pt.y, v);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   205
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   206
				if (selected == INVALID_ORDER || selected == this->sel_index) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   207
					/* Deselect clicked order */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   208
					this->sel_index = -1;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   209
				} else {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   210
					/* Select clicked order */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   211
					this->sel_index = selected;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   212
				}
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   213
			} break;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   214
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   215
			case TTV_CHANGE_TIME: { /* "Wait For" button. */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   216
				int selected = this->sel_index;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   217
				VehicleOrderID real = (selected + 1) / 2;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   218
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   219
				if (real >= v->num_orders) real = 0;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   220
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   221
				const Order *order = GetVehicleOrder(v, real);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   222
				StringID current = STR_EMPTY;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   223
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   224
				if (order != NULL) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   225
					uint time = (selected % 2 == 1) ? order->travel_time : order->wait_time;
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
   226
					if (!_settings_client.gui.timetable_in_ticks) time /= DAY_TICKS;
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   227
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   228
					if (time != 0) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   229
						SetDParam(0, time);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   230
						current = STR_CONFIG_PATCHES_INT32;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   231
					}
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   232
				}
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   233
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   234
				ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, 150, this, CS_NUMERAL);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   235
			} break;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   236
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   237
			case TTV_CLEAR_TIME: { /* Clear waiting time button. */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   238
				uint32 p1 = PackTimetableArgs(v, this->sel_index);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   239
				DoCommandP(0, p1, 0, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   240
			} break;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   241
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   242
			case TTV_RESET_LATENESS: /* Reset the vehicle's late counter. */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   243
				DoCommandP(0, v->index, 0, NULL, CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   244
				break;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   245
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   246
			case TTV_AUTOFILL: /* Autofill the timetable. */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   247
				DoCommandP(0, v->index, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE) ? 0 : 1, NULL, CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   248
				break;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   249
		}
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   250
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   251
		this->SetDirty();
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   252
	}
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   254
	virtual void OnQueryTextFinished(char *str)
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   255
	{
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   256
		if (str == NULL) return;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   257
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   258
		const Vehicle *v = GetVehicle(this->window_number);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   259
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   260
		uint32 p1 = PackTimetableArgs(v, this->sel_index);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   261
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   262
		uint64 time = StrEmpty(str) ? 0 : strtoul(str, NULL, 10);
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
   263
		if (!_settings_client.gui.timetable_in_ticks) time *= DAY_TICKS;
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   264
9605
5a1897abd925 (svn r13647) -Codechange: replace MAX_UVALUE() for std types with the equivalent constant
skidd13
parents: 9413
diff changeset
   265
		uint32 p2 = minu(time, UINT16_MAX);
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   266
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   267
		DoCommandP(0, p1, p2, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   268
	}
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   269
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   270
	virtual void OnResize(Point new_size, Point delta)
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   271
	{
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   272
		/* Update the scroll + matrix */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   273
		this->vscroll.cap = (this->widget[TTV_TIMETABLE_PANEL].bottom - this->widget[TTV_TIMETABLE_PANEL].top) / 10;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   274
	}
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   275
};
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   276
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   277
static const Widget _timetable_widgets[] = {
9778
c5dd94ed7c16 (svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents: 9665
diff changeset
   278
	{   WWT_CLOSEBOX,   RESIZE_NONE,   COLOUR_GREY,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},                // TTV_WIDGET_CLOSEBOX
c5dd94ed7c16 (svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents: 9665
diff changeset
   279
	{    WWT_CAPTION,   RESIZE_RIGHT,  COLOUR_GREY,    11,   326,     0,    13, STR_TIMETABLE_TITLE,        STR_018C_WINDOW_TITLE_DRAG_THIS},      // TTV_CAPTION
c5dd94ed7c16 (svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents: 9665
diff changeset
   280
	{ WWT_PUSHTXTBTN,   RESIZE_LR,     COLOUR_GREY,   327,   387,     0,    13, STR_ORDER_VIEW,             STR_ORDER_VIEW_TOOLTIP},               // TTV_ORDER_VIEW
c5dd94ed7c16 (svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents: 9665
diff changeset
   281
	{  WWT_STICKYBOX,   RESIZE_LR,     COLOUR_GREY,   388,   399,     0,    13, STR_NULL,                   STR_STICKY_BUTTON},                    // TTV_STICKY
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   282
9778
c5dd94ed7c16 (svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents: 9665
diff changeset
   283
	{      WWT_PANEL,   RESIZE_RB,     COLOUR_GREY,     0,   387,    14,    95, STR_NULL,                   STR_TIMETABLE_TOOLTIP},                // TTV_TIMETABLE_PANEL
c5dd94ed7c16 (svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents: 9665
diff changeset
   284
	{  WWT_SCROLLBAR,   RESIZE_LRB,    COLOUR_GREY,   388,   399,    14,    95, STR_NULL,                   STR_0190_SCROLL_BAR_SCROLLS_LIST},     // TTV_SCROLLBAR
7057
01a2a637716d (svn r10322) -Codechange: Make the timetable window smaller by default so it doesn't take up so much space on small resolutions.
maedhros
parents: 7049
diff changeset
   285
9778
c5dd94ed7c16 (svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents: 9665
diff changeset
   286
	{      WWT_PANEL,   RESIZE_RTB,    COLOUR_GREY,     0,   399,    96,   117, STR_NULL,                   STR_NULL},                             // TTV_SUMMARY_PANEL
8722
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
   287
9778
c5dd94ed7c16 (svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents: 9665
diff changeset
   288
	{ WWT_PUSHTXTBTN,   RESIZE_TB,     COLOUR_GREY,     0,   109,   118,   129, STR_TIMETABLE_CHANGE_TIME,  STR_TIMETABLE_WAIT_TIME_TOOLTIP},      // TTV_CHANGE_TIME
c5dd94ed7c16 (svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents: 9665
diff changeset
   289
	{ WWT_PUSHTXTBTN,   RESIZE_TB,     COLOUR_GREY,   110,   219,   118,   129, STR_CLEAR_TIME,             STR_TIMETABLE_CLEAR_TIME_TOOLTIP},     // TTV_CLEAR_TIME
c5dd94ed7c16 (svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents: 9665
diff changeset
   290
	{ WWT_PUSHTXTBTN,   RESIZE_TB,     COLOUR_GREY,   220,   337,   118,   129, STR_RESET_LATENESS,         STR_TIMETABLE_RESET_LATENESS_TOOLTIP}, // TTV_RESET_LATENESS
c5dd94ed7c16 (svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents: 9665
diff changeset
   291
	{ WWT_PUSHTXTBTN,   RESIZE_TB,     COLOUR_GREY,   338,   387,   118,   129, STR_TIMETABLE_AUTOFILL,     STR_TIMETABLE_AUTOFILL_TOOLTIP},       // TTV_AUTOFILL
c5dd94ed7c16 (svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents: 9665
diff changeset
   292
c5dd94ed7c16 (svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents: 9665
diff changeset
   293
	{      WWT_PANEL,   RESIZE_RTB,    COLOUR_GREY,   388,   387,   118,   129, STR_NULL,                   STR_NULL},                             // TTV_EMPTY
c5dd94ed7c16 (svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents: 9665
diff changeset
   294
	{  WWT_RESIZEBOX,   RESIZE_LRTB,   COLOUR_GREY,   388,   399,   118,   129, STR_NULL,                   STR_RESIZE_BUTTON},                    // TTV_RESIZE
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   295
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   296
	{    WIDGETS_END }
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   297
};
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   298
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   299
static const WindowDesc _timetable_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7312
diff changeset
   300
	WDP_AUTO, WDP_AUTO, 400, 130, 400, 130,
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   301
	WC_VEHICLE_TIMETABLE, WC_VEHICLE_VIEW,
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   302
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   303
	_timetable_widgets,
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   304
};
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   305
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   306
void ShowTimetableWindow(const Vehicle *v)
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   307
{
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   308
	AllocateWindowDescFront<TimetableWindow>(&_timetable_desc, v->index);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   309
}