src/timetable_gui.cpp
author rubidium
Thu, 29 May 2008 15:13:28 +0000
changeset 9413 7042a8ec3fa8
parent 9354 845e07db4549
child 9605 5a1897abd925
permissions -rw-r--r--
(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.
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) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    87
			if (selected == -1) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    88
				this->DisableWidget(TTV_CHANGE_TIME);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    89
				this->DisableWidget(TTV_CLEAR_TIME);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    90
			} else if (selected % 2 == 1) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    91
				this->EnableWidget(TTV_CHANGE_TIME);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    92
				this->EnableWidget(TTV_CLEAR_TIME);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    93
			} else {
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    94
				const Order *order = GetVehicleOrder(v, (selected + 1) / 2);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    95
				bool disable = order == NULL || !order->IsType(OT_GOTO_STATION) || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    96
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
    97
				this->SetWidgetDisabledState(TTV_CHANGE_TIME, disable);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
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
			}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   100
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   101
			this->EnableWidget(TTV_RESET_LATENESS);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   102
			this->EnableWidget(TTV_AUTOFILL);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   103
		} else {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   104
			this->DisableWidget(TTV_CHANGE_TIME);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   105
			this->DisableWidget(TTV_CLEAR_TIME);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   106
			this->DisableWidget(TTV_RESET_LATENESS);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   107
			this->DisableWidget(TTV_AUTOFILL);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   108
		}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   109
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   110
		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
   111
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   112
		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
   113
		this->DrawWidgets();
7073
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   114
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   115
		int y = 15;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   116
		int i = this->vscroll.pos;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   117
		VehicleOrderID order_id = (i + 1) / 2;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   118
		bool final_order = false;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   119
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   120
		const Order *order = GetVehicleOrder(v, order_id);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   121
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   122
		while (order != NULL) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   123
			/* 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
   124
			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
   125
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   126
			if (i % 2 == 0) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   127
				DrawOrderString(v, order, order_id, y, i == selected, true);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   128
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   129
				order_id++;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   130
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   131
				if (order_id >= v->num_orders) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   132
					order = GetVehicleOrder(v, 0);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   133
					final_order = true;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   134
				} else {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   135
					order = order->next;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   136
				}
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   137
			} else {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   138
				StringID string;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   139
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   140
				if (order->travel_time == 0) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   141
					string = STR_TIMETABLE_TRAVEL_NOT_TIMETABLED;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   142
				} else {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   143
					SetTimetableParams(0, 1, order->travel_time);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   144
					string = STR_TIMETABLE_TRAVEL_FOR;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   145
				}
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
				DrawString(22, y, string, (i == selected) ? TC_WHITE : TC_BLACK);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   148
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   149
				if (final_order) break;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   150
			}
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
			i++;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   153
			y += 10;
7073
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   154
		}
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   155
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   156
		y = this->widget[TTV_SUMMARY_PANEL].top + 1;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   157
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
			uint total_time = 0;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   160
			bool complete = true;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   161
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   162
			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
   163
				total_time += order->travel_time + order->wait_time;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   164
				if (order->travel_time == 0) complete = false;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   165
				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
   166
			}
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
			if (total_time != 0) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   169
				SetTimetableParams(0, 1, total_time);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   170
				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
   171
			}
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
		y += 10;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   174
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
   175
		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
   176
			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
   177
		} else {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   178
			SetTimetableParams(0, 1, abs(v->lateness_counter));
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   179
			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
   180
		}
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   181
	}
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   182
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   183
	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
   184
	{
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   185
		uint order_number = (selected + 1) / 2;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   186
		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
   187
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   188
		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
   189
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   190
		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
   191
	}
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   192
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   193
	virtual void OnClick(Point pt, int widget)
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   194
	{
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   195
		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
   196
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   197
		switch (widget) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   198
			case TTV_ORDER_VIEW: /* Order view button */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   199
				ShowOrdersWindow(v);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   200
				break;
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   201
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   202
			case TTV_TIMETABLE_PANEL: { /* Main panel. */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   203
				int selected = GetOrderFromTimetableWndPt(pt.y, v);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   204
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   205
				if (selected == INVALID_ORDER || selected == this->sel_index) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   206
					/* Deselect clicked order */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   207
					this->sel_index = -1;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   208
				} else {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   209
					/* Select clicked order */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   210
					this->sel_index = selected;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   211
				}
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   212
			} break;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   213
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   214
			case TTV_CHANGE_TIME: { /* "Wait For" button. */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   215
				int selected = this->sel_index;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   216
				VehicleOrderID real = (selected + 1) / 2;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   217
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   218
				if (real >= v->num_orders) real = 0;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   219
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   220
				const Order *order = GetVehicleOrder(v, real);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   221
				StringID current = STR_EMPTY;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   222
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   223
				if (order != NULL) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   224
					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
   225
					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
   226
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   227
					if (time != 0) {
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   228
						SetDParam(0, time);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   229
						current = STR_CONFIG_PATCHES_INT32;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   230
					}
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
				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
   234
			} break;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   235
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   236
			case TTV_CLEAR_TIME: { /* Clear waiting time button. */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   237
				uint32 p1 = PackTimetableArgs(v, this->sel_index);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   238
				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
   239
			} break;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   240
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   241
			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
   242
				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
   243
				break;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   244
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   245
			case TTV_AUTOFILL: /* Autofill the timetable. */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   246
				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
   247
				break;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   248
		}
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
		this->SetDirty();
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   251
	}
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   252
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   253
	virtual void OnQueryTextFinished(char *str)
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   254
	{
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   255
		if (str == NULL) return;
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   256
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   257
		const Vehicle *v = GetVehicle(this->window_number);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   258
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   259
		uint32 p1 = PackTimetableArgs(v, this->sel_index);
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   260
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   261
		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
   262
		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
   263
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   264
		uint32 p2 = minu(time, MAX_UVALUE(uint16));
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   265
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   266
		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
   267
	}
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
	virtual void OnResize(Point new_size, Point delta)
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   270
	{
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   271
		/* Update the scroll + matrix */
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   272
		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
   273
	}
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   274
};
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   275
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   276
static const Widget _timetable_widgets[] = {
8722
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
   277
	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},                // TTV_WIDGET_CLOSEBOX
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
   278
	{    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   326,     0,    13, STR_TIMETABLE_TITLE,        STR_018C_WINDOW_TITLE_DRAG_THIS},      // TTV_CAPTION
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
   279
	{ WWT_PUSHTXTBTN,   RESIZE_LR,      14,   327,   387,     0,    13, STR_ORDER_VIEW,             STR_ORDER_VIEW_TOOLTIP},               // 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
   280
	{  WWT_STICKYBOX,   RESIZE_LR,      14,   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
   281
8722
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
   282
	{      WWT_PANEL,   RESIZE_RB,      14,     0,   387,    14,    95, STR_NULL,                   STR_TIMETABLE_TOOLTIP},                // TTV_TIMETABLE_PANEL
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
   283
	{  WWT_SCROLLBAR,   RESIZE_LRB,     14,   388,   399,    14,    95, STR_NULL,                   STR_0190_SCROLL_BAR_SCROLLS_LIST},     // TTV_SCROLLBAR
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   284
8722
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
   285
	{      WWT_PANEL,   RESIZE_RTB,     14,     0,   399,    96,   117, STR_NULL,                   STR_NULL},                             // TTV_SUMMARY_PANEL
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
   286
8722
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
   287
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,     0,   109,   118,   129, STR_TIMETABLE_CHANGE_TIME,  STR_TIMETABLE_WAIT_TIME_TOOLTIP},      // TTV_CHANGE_TIME
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
   288
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   110,   219,   118,   129, STR_CLEAR_TIME,             STR_TIMETABLE_CLEAR_TIME_TOOLTIP},     // TTV_CLEAR_TIME
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
   289
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   220,   337,   118,   129, STR_RESET_LATENESS,         STR_TIMETABLE_RESET_LATENESS_TOOLTIP}, // TTV_RESET_LATENESS
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
   290
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   338,   387,   118,   129, STR_TIMETABLE_AUTOFILL,     STR_TIMETABLE_AUTOFILL_TOOLTIP},       // TTV_AUTOFILL
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
   291
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
   292
	{      WWT_PANEL,   RESIZE_RTB,     14,   388,   387,   118,   129, STR_NULL,                   STR_NULL},                             // TTV_EMPTY
6c3a3816bff5 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8424
diff changeset
   293
	{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   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
   294
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   295
	{    WIDGETS_END }
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   296
};
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
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
   299
	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
   300
	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
   301
	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
   302
	_timetable_widgets,
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   303
};
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
void ShowTimetableWindow(const Vehicle *v)
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   306
{
9253
fb3bf727fc75 (svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents: 9164
diff changeset
   307
	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
   308
}