src/timetable_gui.cpp
author peter1138
Tue, 22 Jan 2008 07:27:06 +0000
changeset 8374 7a1b6c89cb89
parent 8302 ed068d41cf1e
child 8424 c3477565c975
permissions -rw-r--r--
(svn r11940) -Codechange: Store short filename once per open file instead of once per sprite cache entry. Not all file types need this, but most of the time no sprite cache entry needed it either.
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
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     3
/** @file timetable_gui.cpp */
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 "engine.h"
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    10
#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
    11
#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
    12
#include "textbuf_gui.h"
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    13
#include "cargotype.h"
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    14
#include "depot.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8107
diff changeset
    15
#include "strings_func.h"
8144
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8140
diff changeset
    16
#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
    17
#include "string_func.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8214
diff changeset
    18
#include "gfx_func.h"
8254
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8237
diff changeset
    19
#include "player_func.h"
8270
e7c342f6b14c (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8264
diff changeset
    20
#include "settings_type.h"
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    21
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    22
#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
    23
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    24
static int GetOrderFromTimetableWndPt(Window *w, int y, const Vehicle *v)
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    25
{
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    26
	/*
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    27
	 * Calculation description:
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    28
	 * 15 = 14 (w->widget[ORDER_WIDGET_ORDER_LIST].top) + 1 (frame-line)
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    29
	 * 10 = order text hight
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    30
	 */
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    31
	int sel = (y - 15) / 10;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    32
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    33
	if ((uint)sel >= w->vscroll.cap) return INVALID_ORDER;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    34
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    35
	sel += w->vscroll.pos;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    36
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    37
	return (sel <= v->num_orders * 2 && sel >= 0) ? sel : INVALID_ORDER;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    38
}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    39
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    40
static inline void SetTimetableParams(int param1, int param2, uint32 time)
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    41
{
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    42
	if (_patches.timetable_in_ticks) {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    43
		SetDParam(param1, STR_TIMETABLE_TICKS);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    44
		SetDParam(param2, time);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    45
	} else {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    46
		SetDParam(param1, STR_TIMETABLE_DAYS);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    47
		SetDParam(param2, time / DAY_TICKS);
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
}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    50
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    51
static void DrawTimetableWindow(Window *w)
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    52
{
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    53
	const Vehicle *v = GetVehicle(w->window_number);
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
    54
	int selected = WP(w, order_d).sel;
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    55
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    56
	SetVScrollCount(w, v->num_orders * 2);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    57
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    58
	if (v->owner == _local_player) {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    59
		if (selected == -1) {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7928
diff changeset
    60
			w->DisableWidget(6);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7928
diff changeset
    61
			w->DisableWidget(7);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    62
		} else if (selected % 2 == 1) {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7928
diff changeset
    63
			w->EnableWidget(6);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7928
diff changeset
    64
			w->EnableWidget(7);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    65
		} else {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    66
			const Order *order = GetVehicleOrder(v, (selected + 1) / 2);
8302
ed068d41cf1e (svn r11866) -Codechange: swap OFB_* and OF_* so it conceptually in sync with other cases of *B_* vs *_* like VETSB_* and VETS_*.
rubidium
parents: 8270
diff changeset
    67
			bool disable = order == NULL || order->type != OT_GOTO_STATION || (_patches.new_nonstop && (order->flags & OFB_NON_STOP));
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    68
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7928
diff changeset
    69
			w->SetWidgetDisabledState(6, disable);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7928
diff changeset
    70
			w->SetWidgetDisabledState(7, disable);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    71
		}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    72
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7928
diff changeset
    73
		w->EnableWidget(8);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7928
diff changeset
    74
		w->EnableWidget(9);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    75
	} else {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7928
diff changeset
    76
		w->DisableWidget(6);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7928
diff changeset
    77
		w->DisableWidget(7);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7928
diff changeset
    78
		w->DisableWidget(8);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7928
diff changeset
    79
		w->DisableWidget(9);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    80
	}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    81
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7928
diff changeset
    82
	w->SetWidgetLoweredState(9, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE));
7066
e5d16aa8d6ca (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7057
diff changeset
    83
7049
0ebe47348074 (svn r10314) -Codechange: Refer to vehicle names by index
peter1138
parents: 6983
diff changeset
    84
	SetDParam(0, v->index);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    85
	DrawWindowWidgets(w);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    86
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    87
	int y = 15;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    88
	int i = w->vscroll.pos;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    89
	VehicleOrderID order_id = (i + 1) / 2;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    90
	bool final_order = false;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    91
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    92
	const Order *order = GetVehicleOrder(v, order_id);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    93
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    94
	while (order != NULL) {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    95
		/* Don't draw anything if it extends past the end of the window. */
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    96
		if (i - w->vscroll.pos >= w->vscroll.cap) break;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    97
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    98
		if (i % 2 == 0) {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    99
			SetDParam(2, STR_EMPTY);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   100
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   101
			switch (order->type) {
7312
9e89be4bc9a2 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7266
diff changeset
   102
				case OT_DUMMY:
9e89be4bc9a2 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7266
diff changeset
   103
					SetDParam(0, STR_INVALID_ORDER);
9e89be4bc9a2 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7266
diff changeset
   104
					break;
9e89be4bc9a2 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7266
diff changeset
   105
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   106
				case OT_GOTO_STATION:
8302
ed068d41cf1e (svn r11866) -Codechange: swap OFB_* and OF_* so it conceptually in sync with other cases of *B_* vs *_* like VETSB_* and VETS_*.
rubidium
parents: 8270
diff changeset
   107
					SetDParam(0, (order->flags & OFB_NON_STOP) ? STR_880C_GO_NON_STOP_TO : STR_8806_GO_TO);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   108
					SetDParam(1, order->dest);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   109
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   110
					if (order->wait_time > 0) {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   111
						SetDParam(2, STR_TIMETABLE_STAY_FOR);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   112
						SetTimetableParams(3, 4, order->wait_time);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   113
					}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   114
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   115
					break;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   116
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   117
				case OT_GOTO_DEPOT: {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   118
					StringID string = STR_EMPTY;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   119
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   120
					if (v->type == VEH_AIRCRAFT) {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   121
						string = STR_GO_TO_AIRPORT_HANGAR;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   122
						SetDParam(1, order->dest);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   123
					} else {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   124
						SetDParam(1, GetDepot(order->dest)->town_index);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   125
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   126
						switch (v->type) {
8302
ed068d41cf1e (svn r11866) -Codechange: swap OFB_* and OF_* so it conceptually in sync with other cases of *B_* vs *_* like VETSB_* and VETS_*.
rubidium
parents: 8270
diff changeset
   127
							case VEH_TRAIN: string = (order->flags & OFB_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   128
							case VEH_ROAD:  string = STR_9038_GO_TO_ROADVEH_DEPOT; break;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   129
							case VEH_SHIP:  string = STR_GO_TO_SHIP_DEPOT; break;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   130
							default: break;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   131
						}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   132
					}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   133
8302
ed068d41cf1e (svn r11866) -Codechange: swap OFB_* and OF_* so it conceptually in sync with other cases of *B_* vs *_* like VETSB_* and VETS_*.
rubidium
parents: 8270
diff changeset
   134
					if (order->flags & OFB_FULL_LOAD) string++; // Service at orders
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   135
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   136
					SetDParam(0, string);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   137
				} break;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   138
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   139
				case OT_GOTO_WAYPOINT:
8302
ed068d41cf1e (svn r11866) -Codechange: swap OFB_* and OF_* so it conceptually in sync with other cases of *B_* vs *_* like VETSB_* and VETS_*.
rubidium
parents: 8270
diff changeset
   140
					SetDParam(0, (order->flags & OFB_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   141
					SetDParam(1, order->dest);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   142
					break;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   143
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   144
				default: break;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   145
			}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   146
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   147
			DrawString(2, y, STR_TIMETABLE_GO_TO, (i == selected) ? TC_WHITE : TC_BLACK);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   148
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   149
			order_id++;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   150
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   151
			if (order_id >= v->num_orders) {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   152
				order = GetVehicleOrder(v, 0);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   153
				final_order = true;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   154
			} else {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   155
				order = order->next;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   156
			}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   157
		} else {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   158
			StringID string;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   159
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   160
			if (order->travel_time == 0) {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   161
				string = STR_TIMETABLE_TRAVEL_NOT_TIMETABLED;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   162
			} else {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   163
				SetTimetableParams(0, 1, order->travel_time);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   164
				string = STR_TIMETABLE_TRAVEL_FOR;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   165
			}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   166
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   167
			DrawString(12, y, string, (i == selected) ? TC_WHITE : TC_BLACK);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   168
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   169
			if (final_order) break;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   170
		}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   171
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   172
		i++;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   173
		y += 10;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   174
	}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   175
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   176
	y = w->widget[5].top + 1;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   177
7073
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   178
	{
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   179
		uint total_time = 0;
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   180
		bool complete = true;
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
		for (const Order *order = GetVehicleOrder(v, 0); order != NULL; order = order->next) {
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   183
			total_time += order->travel_time + order->wait_time;
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   184
			if (order->travel_time == 0) complete = false;
8302
ed068d41cf1e (svn r11866) -Codechange: swap OFB_* and OF_* so it conceptually in sync with other cases of *B_* vs *_* like VETSB_* and VETS_*.
rubidium
parents: 8270
diff changeset
   185
			if (order->wait_time == 0 && order->type == OT_GOTO_STATION && !(_patches.new_nonstop && (order->flags & OFB_NON_STOP))) complete = false;
7073
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   186
		}
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   187
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   188
		if (total_time != 0) {
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   189
			SetTimetableParams(0, 1, total_time);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   190
			DrawString(2, y, complete ? STR_TIMETABLE_TOTAL_TIME : STR_TIMETABLE_TOTAL_TIME_INCOMPLETE, TC_BLACK);
7073
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   191
		}
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   192
	}
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   193
	y += 10;
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   194
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   195
	if (v->lateness_counter == 0 || (!_patches.timetable_in_ticks && v->lateness_counter / DAY_TICKS == 0)) {
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   196
		DrawString(2, y, STR_TIMETABLE_STATUS_ON_TIME, TC_BLACK);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   197
	} else {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   198
		SetTimetableParams(0, 1, abs(v->lateness_counter));
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   199
		DrawString(2, y, v->lateness_counter < 0 ? STR_TIMETABLE_STATUS_EARLY : STR_TIMETABLE_STATUS_LATE, TC_BLACK);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   200
	}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   201
}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   202
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   203
static inline uint32 PackTimetableArgs(const Vehicle *v, uint selected)
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   204
{
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   205
	uint order_number = (selected + 1) / 2;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   206
	uint is_journey   = (selected % 2 == 1) ? 1 : 0;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   207
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   208
	if (order_number >= v->num_orders) order_number = 0;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   209
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   210
	return v->index | (order_number << 16) | (is_journey << 24);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   211
}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   212
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   213
static void TimetableWndProc(Window *w, WindowEvent *we)
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   214
{
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   215
	switch (we->event) {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   216
		case WE_PAINT:
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   217
			DrawTimetableWindow(w);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   218
			break;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   219
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   220
		case WE_CLICK: {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   221
			const Vehicle *v = GetVehicle(w->window_number);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   222
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   223
			switch (we->we.click.widget) {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   224
				case 3: { /* Main panel. */
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   225
					int selected = GetOrderFromTimetableWndPt(w, we->we.click.pt.y, v);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   226
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
   227
					if (selected == INVALID_ORDER || selected == WP(w, order_d).sel) {
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   228
						/* Deselect clicked order */
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
   229
						WP(w, order_d).sel = -1;
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   230
					} else {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   231
						/* Select clicked order */
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
   232
						WP(w, order_d).sel = selected;
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   233
					}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   234
				} break;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   235
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   236
				case 6: { /* "Wait For" button. */
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
   237
					int selected = WP(w, order_d).sel;
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   238
					VehicleOrderID real = (selected + 1) / 2;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   239
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   240
					if (real >= v->num_orders) real = 0;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   241
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   242
					const Order *order = GetVehicleOrder(v, real);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   243
					StringID current = STR_EMPTY;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   244
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   245
					if (order != NULL) {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   246
						uint time = (selected % 2 == 1) ? order->travel_time : order->wait_time;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   247
						if (!_patches.timetable_in_ticks) time /= DAY_TICKS;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   248
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   249
						if (time != 0) {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   250
							SetDParam(0, time);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   251
							current = STR_CONFIG_PATCHES_INT32;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   252
						}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   253
					}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   254
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   255
					ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, 150, w, CS_NUMERAL);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   256
				} break;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   257
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   258
				case 7: { /* Clear waiting time button. */
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
   259
					uint32 p1 = PackTimetableArgs(v, WP(w, order_d).sel);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   260
					DoCommandP(0, p1, 0, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   261
				} break;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   262
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   263
				case 8: /* Reset the vehicle's late counter. */
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   264
					DoCommandP(0, v->index, 0, NULL, CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   265
					break;
7066
e5d16aa8d6ca (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7057
diff changeset
   266
e5d16aa8d6ca (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7057
diff changeset
   267
				case 9: /* Autofill the timetable. */
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7824
diff changeset
   268
					DoCommandP(0, v->index, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE) ? 0 : 1, NULL, CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
7066
e5d16aa8d6ca (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7057
diff changeset
   269
					break;
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   270
			}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   271
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   272
			SetWindowDirty(w);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   273
		} break;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   274
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   275
		case WE_ON_EDIT_TEXT: {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   276
			const Vehicle *v = GetVehicle(w->window_number);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   277
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
   278
			uint32 p1 = PackTimetableArgs(v, WP(w, order_d).sel);
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   279
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   280
			uint64 time = StrEmpty(we->we.edittext.str) ? 0 : strtoul(we->we.edittext.str, NULL, 10);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   281
			if (!_patches.timetable_in_ticks) time *= DAY_TICKS;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   282
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   283
			uint32 p2 = minu(time, MAX_UVALUE(uint16));
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   284
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   285
			DoCommandP(0, p1, p2, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   286
		} break;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   287
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   288
		case WE_RESIZE:
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   289
			/* Update the scroll + matrix */
6982
d114b3a8d5b8 (svn r10238) -Fix (r10236): Resizing the timetable window caused it to think it could only show one line at a time.
maedhros
parents: 6981
diff changeset
   290
			w->vscroll.cap = (w->widget[3].bottom - w->widget[3].top) / 10;
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   291
			break;
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   292
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   293
	}
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
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   296
static const Widget _timetable_widgets[] = {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   297
	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},
7066
e5d16aa8d6ca (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7057
diff changeset
   298
	{    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   387,     0,    13, STR_TIMETABLE_TITLE,        STR_018C_WINDOW_TITLE_DRAG_THIS},
e5d16aa8d6ca (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7057
diff changeset
   299
	{  WWT_STICKYBOX,   RESIZE_LR,      14,   388,   399,     0,    13, STR_NULL,                   STR_STICKY_BUTTON},
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   300
7066
e5d16aa8d6ca (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7057
diff changeset
   301
	{      WWT_PANEL,   RESIZE_RB,      14,     0,   387,    14,    95, STR_NULL,                   STR_TIMETABLE_TOOLTIP},
e5d16aa8d6ca (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7057
diff changeset
   302
	{  WWT_SCROLLBAR,   RESIZE_LRB,     14,   388,   399,    14,    95, STR_NULL,                   STR_0190_SCROLL_BAR_SCROLLS_LIST},
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   303
7073
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   304
	{      WWT_PANEL,   RESIZE_RTB,     14,     0,   399,    96,   117, STR_NULL,                   STR_NULL},
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   305
7073
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   306
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,     0,   109,   118,   129, STR_TIMETABLE_CHANGE_TIME,  STR_TIMETABLE_WAIT_TIME_TOOLTIP},
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   307
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   110,   219,   118,   129, STR_CLEAR_TIME,             STR_TIMETABLE_CLEAR_TIME_TOOLTIP},
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   308
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   220,   337,   118,   129, STR_RESET_LATENESS,         STR_TIMETABLE_RESET_LATENESS_TOOLTIP},
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   309
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   338,   387,   118,   129, STR_TIMETABLE_AUTOFILL,     STR_TIMETABLE_AUTOFILL_TOOLTIP},
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
   310
7073
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   311
	{      WWT_PANEL,   RESIZE_RTB,     14,   388,   387,   118,   129, STR_NULL,                   STR_NULL},
ca7cb4b5c5e2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7066
diff changeset
   312
	{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   388,   399,   118,   129, STR_NULL,                   STR_RESIZE_BUTTON},
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   313
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   314
	{    WIDGETS_END }
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   315
};
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   316
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   317
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
   318
	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
   319
	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
   320
	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
   321
	_timetable_widgets,
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   322
	TimetableWndProc
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   323
};
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   324
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   325
void ShowTimetableWindow(const Vehicle *v)
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   326
{
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   327
	Window *w = AllocateWindowDescFront(&_timetable_desc, v->index);
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   328
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   329
	if (w != NULL) {
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   330
		w->caption_color = v->owner;
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
   331
		w->vscroll.cap = 8;
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   332
		w->resize.step_height = 10;
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
   333
		WP(w, order_d).sel = -1;
6981
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   334
	}
9af49f50fe33 (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   335
}