src/group_gui.cpp
author translators
Mon, 01 Dec 2008 18:28:44 +0000
changeset 10396 7f6f37c9dc67
parent 10208 72c00af5c95d
permissions -rw-r--r--
(svn r14647) -Update: WebTranslator2 update to 2008-12-01 18:28:38
croatian - 160 changed by knovak (160)
hungarian - 2 changed by oklmernok (2)
malay - 20 fixed by SeaGates (20)
spanish - 1 fixed by eusebio (1)
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
     1
/* $Id$ */
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
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: 8974
diff changeset
     3
/** @file group_gui.cpp GUI for the group window. */
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
     4
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
     5
#include "stdafx.h"
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
     6
#include "openttd.h"
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
     7
#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
     8
#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
     9
#include "textbuf_gui.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    10
#include "command_func.h"
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    11
#include "vehicle_gui.h"
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
    12
#include "vehicle_gui_base.h"
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    13
#include "train.h"
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    14
#include "group.h"
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    15
#include "debug.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8110
diff changeset
    16
#include "strings_func.h"
8130
d2eb7d04f6e1 (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8121
diff changeset
    17
#include "core/alloc_func.hpp"
8131
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8130
diff changeset
    18
#include "window_func.h"
8144
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8140
diff changeset
    19
#include "vehicle_func.h"
8212
cf3fce5c7464 (svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents: 8179
diff changeset
    20
#include "autoreplace_gui.h"
8214
971f861d5543 (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8212
diff changeset
    21
#include "string_func.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8214
diff changeset
    22
#include "viewport_func.h"
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8214
diff changeset
    23
#include "gfx_func.h"
10208
72c00af5c95d (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents: 10207
diff changeset
    24
#include "company_func.h"
8315
bfa951865513 (svn r11880) -Codechange: Generate vehicle group action dropdown dynamically, and assign an enum for the function return codes.
peter1138
parents: 8314
diff changeset
    25
#include "widgets/dropdown_type.h"
8284
ebdc5ba08874 (svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents: 8264
diff changeset
    26
#include "widgets/dropdown_func.h"
9127
14f21c5954ee (svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents: 9116
diff changeset
    27
#include "tilehighlight_func.h"
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    28
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    29
#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
    30
#include "table/sprites.h"
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    31
9182
412cb6c0caf1 (svn r13045) -Codechange: make list_d (now GUIList) more generic and uniform.
rubidium
parents: 9143
diff changeset
    32
typedef GUIList<const Group*> GUIGroupList;
8770
ea070bc7bdad (svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium
parents: 8701
diff changeset
    33
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    34
enum GroupListWidgets {
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    35
	GRP_WIDGET_CLOSEBOX = 0,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    36
	GRP_WIDGET_CAPTION,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    37
	GRP_WIDGET_STICKY,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    38
	GRP_WIDGET_SORT_BY_ORDER,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    39
	GRP_WIDGET_SORT_BY_DROPDOWN,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    40
	GRP_WIDGET_EMPTY_TOP_RIGHT,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    41
	GRP_WIDGET_LIST_VEHICLE,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    42
	GRP_WIDGET_LIST_VEHICLE_SCROLLBAR,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    43
	GRP_WIDGET_EMPTY2,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    44
	GRP_WIDGET_AVAILABLE_VEHICLES,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    45
	GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    46
	GRP_WIDGET_STOP_ALL,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    47
	GRP_WIDGET_START_ALL,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    48
	GRP_WIDGET_EMPTY_BOTTOM_RIGHT,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    49
	GRP_WIDGET_RESIZE,
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
    50
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
    51
	GRP_WIDGET_EMPTY_TOP_LEFT,
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
    52
	GRP_WIDGET_ALL_VEHICLES,
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
    53
	GRP_WIDGET_DEFAULT_VEHICLES,
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
    54
	GRP_WIDGET_LIST_GROUP,
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
    55
	GRP_WIDGET_LIST_GROUP_SCROLLBAR,
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
    56
	GRP_WIDGET_CREATE_GROUP,
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
    57
	GRP_WIDGET_DELETE_GROUP,
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
    58
	GRP_WIDGET_RENAME_GROUP,
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
    59
	GRP_WIDGET_EMPTY1,
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
    60
	GRP_WIDGET_REPLACE_PROTECTION,
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    61
};
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    62
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    63
enum GroupActionListFunction {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    64
	GALF_REPLACE,
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    65
	GALF_SERVICE,
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    66
	GALF_DEPOT,
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    67
	GALF_ADD_SHARED,
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    68
	GALF_REMOVE_ALL,
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    69
};
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    70
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    71
/**
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    72
 * Update/redraw the group action dropdown
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    73
 * @param w   the window the dropdown belongs to
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    74
 * @param gid the currently selected group in the window
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    75
 */
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    76
static void ShowGroupActionDropdown(Window *w, GroupID gid)
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    77
{
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    78
	DropDownList *list = new DropDownList();
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    79
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    80
	list->push_back(new DropDownListStringItem(STR_REPLACE_VEHICLES,    GALF_REPLACE, false));
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    81
	list->push_back(new DropDownListStringItem(STR_SEND_FOR_SERVICING,  GALF_SERVICE, false));
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    82
	list->push_back(new DropDownListStringItem(STR_SEND_TRAIN_TO_DEPOT, GALF_DEPOT,   false));
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    83
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    84
	if (IsValidGroupID(gid)) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    85
		list->push_back(new DropDownListStringItem(STR_GROUP_ADD_SHARED_VEHICLE,  GALF_ADD_SHARED, false));
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    86
		list->push_back(new DropDownListStringItem(STR_GROUP_REMOVE_ALL_VEHICLES, GALF_REMOVE_ALL, false));
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    87
	}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    88
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    89
	ShowDropDownList(w, list, 0, GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    90
}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
    91
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    92
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
    93
static const Widget _group_widgets[] = {
9744
a1964a9acb91 (svn r13879) -Codechange: Replace numbers with Colours enum on engine, industries and group gui
belugas
parents: 9652
diff changeset
    94
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,             STR_018B_CLOSE_WINDOW},
a1964a9acb91 (svn r13879) -Codechange: Replace numbers with Colours enum on engine, industries and group gui
belugas
parents: 9652
diff changeset
    95
{    WWT_CAPTION,  RESIZE_RIGHT,  COLOUR_GREY,    11,   447,     0,    13, 0x0,                  STR_018C_WINDOW_TITLE_DRAG_THIS},
a1964a9acb91 (svn r13879) -Codechange: Replace numbers with Colours enum on engine, industries and group gui
belugas
parents: 9652
diff changeset
    96
{  WWT_STICKYBOX,     RESIZE_LR,  COLOUR_GREY,   448,   459,     0,    13, 0x0,                  STR_STICKY_BUTTON},
10119
00bd6a85b068 (svn r14303) -Codechange: make the vehicle list part of the group window look exactly like the vehicle list instead of some buttons being one pixel wider/smaller.
rubidium
parents: 10118
diff changeset
    97
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   200,   280,    14,    25, STR_SORT_BY,          STR_SORT_ORDER_TIP},
00bd6a85b068 (svn r14303) -Codechange: make the vehicle list part of the group window look exactly like the vehicle list instead of some buttons being one pixel wider/smaller.
rubidium
parents: 10118
diff changeset
    98
{   WWT_DROPDOWN,   RESIZE_NONE,  COLOUR_GREY,   281,   447,    14,    25, 0x0,                  STR_SORT_CRITERIA_TIP},
9744
a1964a9acb91 (svn r13879) -Codechange: Replace numbers with Colours enum on engine, industries and group gui
belugas
parents: 9652
diff changeset
    99
{      WWT_PANEL,  RESIZE_RIGHT,  COLOUR_GREY,   448,   459,    14,    25, 0x0,                  STR_NULL},
10119
00bd6a85b068 (svn r14303) -Codechange: make the vehicle list part of the group window look exactly like the vehicle list instead of some buttons being one pixel wider/smaller.
rubidium
parents: 10118
diff changeset
   100
{     WWT_MATRIX,     RESIZE_RB,  COLOUR_GREY,   200,   447,    26,   181, 0x701,                STR_NULL},
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   101
{  WWT_SCROLLBAR,    RESIZE_LRB,  COLOUR_GREY,   448,   459,    26,   181, 0x0,                  STR_0190_SCROLL_BAR_SCROLLS_LIST},
10119
00bd6a85b068 (svn r14303) -Codechange: make the vehicle list part of the group window look exactly like the vehicle list instead of some buttons being one pixel wider/smaller.
rubidium
parents: 10118
diff changeset
   102
{      WWT_PANEL,     RESIZE_TB,  COLOUR_GREY,   188,   199,   169,   193, 0x0,                  STR_NULL},
00bd6a85b068 (svn r14303) -Codechange: make the vehicle list part of the group window look exactly like the vehicle list instead of some buttons being one pixel wider/smaller.
rubidium
parents: 10118
diff changeset
   103
{ WWT_PUSHTXTBTN,     RESIZE_TB,  COLOUR_GREY,   200,   305,   182,   193, 0x0,                  STR_AVAILABLE_ENGINES_TIP},
00bd6a85b068 (svn r14303) -Codechange: make the vehicle list part of the group window look exactly like the vehicle list instead of some buttons being one pixel wider/smaller.
rubidium
parents: 10118
diff changeset
   104
{   WWT_DROPDOWN,     RESIZE_TB,  COLOUR_GREY,   306,   423,   182,   193, STR_MANAGE_LIST,      STR_MANAGE_LIST_TIP},
9744
a1964a9acb91 (svn r13879) -Codechange: Replace numbers with Colours enum on engine, industries and group gui
belugas
parents: 9652
diff changeset
   105
{ WWT_PUSHIMGBTN,     RESIZE_TB,  COLOUR_GREY,   424,   435,   182,   193, SPR_FLAG_VEH_STOPPED, STR_MASS_STOP_LIST_TIP},
a1964a9acb91 (svn r13879) -Codechange: Replace numbers with Colours enum on engine, industries and group gui
belugas
parents: 9652
diff changeset
   106
{ WWT_PUSHIMGBTN,     RESIZE_TB,  COLOUR_GREY,   436,   447,   182,   193, SPR_FLAG_VEH_RUNNING, STR_MASS_START_LIST_TIP},
a1964a9acb91 (svn r13879) -Codechange: Replace numbers with Colours enum on engine, industries and group gui
belugas
parents: 9652
diff changeset
   107
{      WWT_PANEL,    RESIZE_RTB,  COLOUR_GREY,   448,   447,   182,   193, 0x0,                  STR_NULL},
a1964a9acb91 (svn r13879) -Codechange: Replace numbers with Colours enum on engine, industries and group gui
belugas
parents: 9652
diff changeset
   108
{  WWT_RESIZEBOX,   RESIZE_LRTB,  COLOUR_GREY,   448,   459,   182,   193, 0x0,                  STR_RESIZE_BUTTON},
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   109
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   110
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   199,    14,    25, 0x0,                  STR_NULL},
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   111
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   199,    26,    38, 0x0,                  STR_NULL},
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   112
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   199,    39,    51, 0x0,                  STR_NULL},
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   113
{     WWT_MATRIX, RESIZE_BOTTOM,  COLOUR_GREY,     0,   187,    52,   168, 0x701,                STR_GROUPS_CLICK_ON_GROUP_FOR_TIP},
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   114
{ WWT_SCROLL2BAR, RESIZE_BOTTOM,  COLOUR_GREY,   188,   199,    52,   168, 0x0,                  STR_0190_SCROLL_BAR_SCROLLS_LIST},
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   115
{ WWT_PUSHIMGBTN,     RESIZE_TB,  COLOUR_GREY,     0,    23,   169,   193, 0x0,                  STR_GROUP_CREATE_TIP},
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   116
{ WWT_PUSHIMGBTN,     RESIZE_TB,  COLOUR_GREY,    24,    47,   169,   193, 0x0,                  STR_GROUP_DELETE_TIP},
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   117
{ WWT_PUSHIMGBTN,     RESIZE_TB,  COLOUR_GREY,    48,    71,   169,   193, 0x0,                  STR_GROUP_RENAME_TIP},
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   118
{      WWT_PANEL,     RESIZE_TB,  COLOUR_GREY,    72,   163,   169,   193, 0x0,                  STR_NULL},
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   119
{ WWT_PUSHIMGBTN,     RESIZE_TB,  COLOUR_GREY,   164,   187,   169,   193, 0x0,                  STR_GROUP_REPLACE_PROTECTION_TIP},
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   120
{   WIDGETS_END},
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   121
};
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   122
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   123
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   124
class VehicleGroupWindow : public BaseVehicleListWindow {
9369
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   125
private:
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   126
	GroupID group_sel;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   127
	VehicleID vehicle_sel;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   128
	GUIGroupList groups;
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   129
9369
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   130
	/**
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   131
	 * (Re)Build the group list.
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   132
	 *
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   133
	 * @param owner The owner of the window
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   134
	 */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   135
	void BuildGroupList(Owner owner)
9369
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   136
	{
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   137
		if (!this->groups.NeedRebuild()) return;
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   138
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   139
		this->groups.Clear();
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   140
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   141
		const Group *g;
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   142
		FOR_ALL_GROUPS(g) {
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   143
			if (g->owner == owner && g->vehicle_type == this->vehicle_type) {
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   144
				*this->groups.Append() = g;
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   145
			}
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   146
		}
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   147
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   148
		this->groups.Compact();
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   149
		this->groups.RebuildDone();
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   150
	}
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   151
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   152
	/** Sort the groups by their name */
9376
afdc4beedc99 (svn r13280) -Fix (r13276): MSVC compilation was broken
smatz
parents: 9369
diff changeset
   153
	static int CDECL GroupNameSorter(const Group* const *a, const Group* const *b)
9369
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   154
	{
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   155
		static const Group *last_group[2] = { NULL, NULL };
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   156
		static char         last_name[2][64] = { "", "" };
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   157
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   158
		if (*a != last_group[0]) {
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   159
			last_group[0] = *a;
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   160
			SetDParam(0, (*a)->index);
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   161
			GetString(last_name[0], STR_GROUP_NAME, lastof(last_name[0]));
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   162
		}
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   163
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   164
		if (*b != last_group[1]) {
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   165
			last_group[1] = *b;
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   166
			SetDParam(0, (*b)->index);
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   167
			GetString(last_name[1], STR_GROUP_NAME, lastof(last_name[1]));
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   168
		}
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   169
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   170
		int r = strcmp(last_name[0], last_name[1]); // sort by name
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   171
		if (r == 0) return (*a)->index - (*b)->index;
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   172
		return r;
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   173
	}
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   174
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   175
public:
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   176
	VehicleGroupWindow(const WindowDesc *desc, WindowNumber window_number) : BaseVehicleListWindow(desc, window_number)
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   177
	{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   178
		const Owner owner = (Owner)GB(this->window_number, 0, 8);
9212
5f56a631a668 (svn r13078) -Fix: group gui used the vehicle type before it was actually set.
rubidium
parents: 9203
diff changeset
   179
		this->vehicle_type = (VehicleType)GB(this->window_number, 11, 5);
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   180
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   181
		this->caption_color = owner;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   182
		this->resize.step_width = 1;
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   183
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   184
		switch (this->vehicle_type) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   185
			default: NOT_REACHED();
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   186
			case VEH_TRAIN:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   187
			case VEH_ROAD:
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   188
				this->vscroll2.cap = 9;
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   189
				this->vscroll.cap = 6;
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   190
				this->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_SMALL;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   191
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   192
			case VEH_SHIP:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   193
			case VEH_AIRCRAFT:
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   194
				this->vscroll2.cap = 9;
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   195
				this->vscroll.cap = 4;
10117
dd9f49319539 (svn r14301) -Codechange: give the vehicle list and group list the same relative size and the same absolute height for the vehicle list items.
rubidium
parents: 9913
diff changeset
   196
				this->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_BIG;
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   197
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   198
		}
8315
bfa951865513 (svn r11880) -Codechange: Generate vehicle group action dropdown dynamically, and assign an enum for the function return codes.
peter1138
parents: 8314
diff changeset
   199
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   200
		this->widget[GRP_WIDGET_LIST_GROUP].data = (this->vscroll2.cap << 8) + 1;
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   201
		this->widget[GRP_WIDGET_LIST_VEHICLE].data = (this->vscroll.cap << 8) + 1;
6660
b892af29d891 (svn r9891) -Fix [FS#787]: the manage list menu wasn't removed/updated when changing to another group making it able to perform "group" actions for "all vehicles", which would cause a crash.
rubidium
parents: 6643
diff changeset
   202
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   203
		switch (this->vehicle_type) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   204
			default: NOT_REACHED();
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   205
			case VEH_TRAIN:    this->sorting = &_sorting.train;    break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   206
			case VEH_ROAD:     this->sorting = &_sorting.roadveh;  break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   207
			case VEH_SHIP:     this->sorting = &_sorting.ship;     break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   208
			case VEH_AIRCRAFT: this->sorting = &_sorting.aircraft; break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   209
		}
6660
b892af29d891 (svn r9891) -Fix [FS#787]: the manage list menu wasn't removed/updated when changing to another group making it able to perform "group" actions for "all vehicles", which would cause a crash.
rubidium
parents: 6643
diff changeset
   210
9530
fba2561f33f1 (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 9408
diff changeset
   211
		this->vehicles.SetListing(*this->sorting);
fba2561f33f1 (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 9408
diff changeset
   212
		this->vehicles.ForceRebuild();
fba2561f33f1 (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 9408
diff changeset
   213
		this->vehicles.NeedResort();
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   214
9369
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   215
		this->groups.ForceRebuild();
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   216
		this->groups.NeedResort();
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   217
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   218
		this->group_sel = ALL_GROUP;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   219
		this->vehicle_sel = INVALID_VEHICLE;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   220
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   221
		switch (this->vehicle_type) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   222
			case VEH_TRAIN:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   223
				this->widget[GRP_WIDGET_LIST_VEHICLE].tooltips = STR_883D_TRAINS_CLICK_ON_TRAIN_FOR;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   224
				this->widget[GRP_WIDGET_AVAILABLE_VEHICLES].data = STR_AVAILABLE_TRAINS;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   225
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   226
				this->widget[GRP_WIDGET_CREATE_GROUP].data = SPR_GROUP_CREATE_TRAIN;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   227
				this->widget[GRP_WIDGET_RENAME_GROUP].data = SPR_GROUP_RENAME_TRAIN;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   228
				this->widget[GRP_WIDGET_DELETE_GROUP].data = SPR_GROUP_DELETE_TRAIN;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   229
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   230
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   231
			case VEH_ROAD:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   232
				this->widget[GRP_WIDGET_LIST_VEHICLE].tooltips = STR_901A_ROAD_VEHICLES_CLICK_ON;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   233
				this->widget[GRP_WIDGET_AVAILABLE_VEHICLES].data = STR_AVAILABLE_ROAD_VEHICLES;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   234
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   235
				this->widget[GRP_WIDGET_CREATE_GROUP].data = SPR_GROUP_CREATE_ROADVEH;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   236
				this->widget[GRP_WIDGET_RENAME_GROUP].data = SPR_GROUP_RENAME_ROADVEH;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   237
				this->widget[GRP_WIDGET_DELETE_GROUP].data = SPR_GROUP_DELETE_ROADVEH;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   238
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   239
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   240
			case VEH_SHIP:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   241
				this->widget[GRP_WIDGET_LIST_VEHICLE].tooltips = STR_9823_SHIPS_CLICK_ON_SHIP_FOR;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   242
				this->widget[GRP_WIDGET_AVAILABLE_VEHICLES].data = STR_AVAILABLE_SHIPS;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   243
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   244
				this->widget[GRP_WIDGET_CREATE_GROUP].data = SPR_GROUP_CREATE_SHIP;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   245
				this->widget[GRP_WIDGET_RENAME_GROUP].data = SPR_GROUP_RENAME_SHIP;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   246
				this->widget[GRP_WIDGET_DELETE_GROUP].data = SPR_GROUP_DELETE_SHIP;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   247
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   248
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   249
			case VEH_AIRCRAFT:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   250
				this->widget[GRP_WIDGET_LIST_VEHICLE].tooltips = STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   251
				this->widget[GRP_WIDGET_AVAILABLE_VEHICLES].data = STR_AVAILABLE_AIRCRAFT;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   252
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   253
				this->widget[GRP_WIDGET_CREATE_GROUP].data = SPR_GROUP_CREATE_AIRCRAFT;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   254
				this->widget[GRP_WIDGET_RENAME_GROUP].data = SPR_GROUP_RENAME_AIRCRAFT;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   255
				this->widget[GRP_WIDGET_DELETE_GROUP].data = SPR_GROUP_DELETE_AIRCRAFT;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   256
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   257
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   258
			default: NOT_REACHED();
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   259
		}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   260
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   261
		this->FindWindowPlacementAndResize(desc);
10118
6b418b016a89 (svn r14302) -Codechange: simplify and make the vehicle list and group windows behave the same w.r.t. getting wider (by default) for trains than the other vehicles.
rubidium
parents: 10117
diff changeset
   262
		if (this->vehicle_type == VEH_TRAIN) ResizeWindow(this, 65, 0);
8315
bfa951865513 (svn r11880) -Codechange: Generate vehicle group action dropdown dynamically, and assign an enum for the function return codes.
peter1138
parents: 8314
diff changeset
   263
	}
bfa951865513 (svn r11880) -Codechange: Generate vehicle group action dropdown dynamically, and assign an enum for the function return codes.
peter1138
parents: 8314
diff changeset
   264
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   265
	~VehicleGroupWindow()
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   266
	{
9530
fba2561f33f1 (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 9408
diff changeset
   267
		*this->sorting = this->vehicles.GetListing();
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   268
	}
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   269
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   270
	virtual void OnInvalidateData(int data)
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   271
	{
9369
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   272
		if (data == 0) {
9530
fba2561f33f1 (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 9408
diff changeset
   273
			this->vehicles.ForceRebuild();
9369
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   274
			this->groups.ForceRebuild();
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   275
		} else {
9530
fba2561f33f1 (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 9408
diff changeset
   276
			this->vehicles.ForceResort();
9369
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   277
			this->groups.ForceResort();
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   278
		}
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   279
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   280
		if (!(IsAllGroupID(this->group_sel) || IsDefaultGroupID(this->group_sel) || IsValidGroupID(this->group_sel))) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   281
			this->group_sel = ALL_GROUP;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   282
			HideDropDownMenu(this);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   283
		}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   284
		this->SetDirty();
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   285
	}
6667
dba8ef60ffd2 (svn r9898) -Fix (r9874): Many...
peter1138
parents: 6660
diff changeset
   286
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   287
	virtual void OnPaint()
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   288
	{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   289
		const Owner owner = (Owner)GB(this->window_number, 0, 8);
9408
e9ac1e9138e1 (svn r13319) -Codechange: Remove use of imaginary horizontal scrollbar in the group vehicle list
peter1138
parents: 9376
diff changeset
   290
		int x = this->widget[GRP_WIDGET_LIST_VEHICLE].left + 2;
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   291
		int y1 = PLY_WND_PRC__OFFSET_TOP_WIDGET + 2;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   292
		int max;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   293
		int i;
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   294
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   295
		/* If we select the all vehicles, this->list will contain all vehicles of the owner
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   296
		 * else this->list will contain all vehicles which belong to the selected group */
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   297
		this->BuildVehicleList(owner, this->group_sel, IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST);
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   298
		this->SortVehicleList();
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   299
9369
1c3d22cfdeb5 (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 9368
diff changeset
   300
		this->BuildGroupList(owner);
9376
afdc4beedc99 (svn r13280) -Fix (r13276): MSVC compilation was broken
smatz
parents: 9369
diff changeset
   301
		this->groups.Sort(&GroupNameSorter);
7890
4209769a14d8 (svn r11441) -Fix [FS#1443]: manage list dropdown menu did not "disappear" when the all vehicles are removed from the "current" group.
rubidium
parents: 7889
diff changeset
   302
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   303
		SetVScroll2Count(this, this->groups.Length());
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   304
		SetVScrollCount(this, this->vehicles.Length());
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   305
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   306
		/* The drop down menu is out, *but* it may not be used, retract it. */
9365
95e9cbc0257e (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 9317
diff changeset
   307
		if (this->vehicles.Length() == 0 && this->IsWidgetLowered(GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN)) {
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   308
			this->RaiseWidget(GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   309
			HideDropDownMenu(this);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   310
		}
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   311
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   312
		/* Disable all lists management button when the list is empty */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   313
		this->SetWidgetsDisabledState(this->vehicles.Length() == 0 || _local_company != owner,
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   314
				GRP_WIDGET_STOP_ALL,
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   315
				GRP_WIDGET_START_ALL,
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   316
				GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN,
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   317
				WIDGET_LIST_END);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   318
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   319
		/* Disable the group specific function when we select the default group or all vehicles */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   320
		this->SetWidgetsDisabledState(IsDefaultGroupID(this->group_sel) || IsAllGroupID(this->group_sel) || _local_company != owner,
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   321
				GRP_WIDGET_DELETE_GROUP,
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   322
				GRP_WIDGET_RENAME_GROUP,
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   323
				GRP_WIDGET_REPLACE_PROTECTION,
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   324
				WIDGET_LIST_END);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   325
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   326
		/* Disable remaining buttons for non-local companies
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   327
		 * Needed while changing _local_company, eg. by cheats
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   328
		 * All procedures (eg. move vehicle to another group)
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   329
		 *  verify, whether you are the owner of the vehicle,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   330
		 *  so it doesn't have to be disabled
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   331
		 */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   332
		this->SetWidgetsDisabledState(_local_company != owner,
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   333
				GRP_WIDGET_CREATE_GROUP,
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   334
				GRP_WIDGET_AVAILABLE_VEHICLES,
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   335
				WIDGET_LIST_END);
7547
93b6e6de2898 (svn r11067) -Codechange: also make it possible to use the advanced vehicle list for other players. Patch by SmatZ.
rubidium
parents: 7490
diff changeset
   336
93b6e6de2898 (svn r11067) -Codechange: also make it possible to use the advanced vehicle list for other players. Patch by SmatZ.
rubidium
parents: 7490
diff changeset
   337
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   338
		/* If selected_group == DEFAULT_GROUP || ALL_GROUP, draw the standard caption
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   339
				We list all vehicles or ungrouped vehicles */
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   340
		if (IsDefaultGroupID(this->group_sel) || IsAllGroupID(this->group_sel)) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   341
			SetDParam(0, owner);
9365
95e9cbc0257e (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 9317
diff changeset
   342
			SetDParam(1, this->vehicles.Length());
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   343
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   344
			switch (this->vehicle_type) {
7258
8ea218277d00 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7134
diff changeset
   345
				case VEH_TRAIN:
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   346
					this->widget[GRP_WIDGET_CAPTION].data = STR_881B_TRAINS;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   347
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = SPR_GROUP_REPLACE_OFF_TRAIN;
7258
8ea218277d00 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7134
diff changeset
   348
					break;
8ea218277d00 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7134
diff changeset
   349
				case VEH_ROAD:
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   350
					this->widget[GRP_WIDGET_CAPTION].data = STR_9001_ROAD_VEHICLES;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   351
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = SPR_GROUP_REPLACE_OFF_ROADVEH;
7258
8ea218277d00 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7134
diff changeset
   352
					break;
8ea218277d00 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7134
diff changeset
   353
				case VEH_SHIP:
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   354
					this->widget[GRP_WIDGET_CAPTION].data = STR_9805_SHIPS;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   355
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = SPR_GROUP_REPLACE_OFF_SHIP;
7258
8ea218277d00 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7134
diff changeset
   356
					break;
8ea218277d00 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7134
diff changeset
   357
				case VEH_AIRCRAFT:
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   358
					this->widget[GRP_WIDGET_CAPTION].data =  STR_A009_AIRCRAFT;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   359
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = SPR_GROUP_REPLACE_OFF_AIRCRAFT;
7258
8ea218277d00 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7134
diff changeset
   360
					break;
8970
da7261f48b7e (svn r12762) -Fix: tabs after the first non-tab character are generally not okay (or lines starting with a space and then tabs).
rubidium
parents: 8962
diff changeset
   361
				default: NOT_REACHED();
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   362
			}
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   363
		} else {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   364
			const Group *g = GetGroup(this->group_sel);
8349
e61105cb1f87 (svn r11915) -Codechange: Add a function to draw a sort button's up/down arrow. Arrows are now drawn in a consistent position based on the widget, instead of randomly positioned by pixel.
peter1138
parents: 8338
diff changeset
   365
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   366
			SetDParam(0, g->index);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   367
			SetDParam(1, g->num_vehicle);
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   368
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   369
			switch (this->vehicle_type) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   370
				case VEH_TRAIN:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   371
					this->widget[GRP_WIDGET_CAPTION].data = STR_GROUP_TRAINS_CAPTION;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   372
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = (g->replace_protection) ? SPR_GROUP_REPLACE_ON_TRAIN : SPR_GROUP_REPLACE_OFF_TRAIN;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   373
					break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   374
				case VEH_ROAD:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   375
					this->widget[GRP_WIDGET_CAPTION].data = STR_GROUP_ROADVEH_CAPTION;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   376
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = (g->replace_protection) ? SPR_GROUP_REPLACE_ON_ROADVEH : SPR_GROUP_REPLACE_OFF_ROADVEH;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   377
					break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   378
				case VEH_SHIP:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   379
					this->widget[GRP_WIDGET_CAPTION].data = STR_GROUP_SHIPS_CAPTION;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   380
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = (g->replace_protection) ? SPR_GROUP_REPLACE_ON_SHIP : SPR_GROUP_REPLACE_OFF_SHIP;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   381
					break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   382
				case VEH_AIRCRAFT:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   383
					this->widget[GRP_WIDGET_CAPTION].data = STR_GROUP_AIRCRAFTS_CAPTION;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   384
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = (g->replace_protection) ? SPR_GROUP_REPLACE_ON_AIRCRAFT : SPR_GROUP_REPLACE_OFF_AIRCRAFT;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   385
					break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   386
				default: NOT_REACHED();
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   387
			}
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   388
		}
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   389
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   390
		/* Set text of sort by dropdown */
9563
c75bee824deb (svn r13587) -Codechange: make some globals members of VehicleListBase since they are used as such
skidd13
parents: 9530
diff changeset
   391
		this->widget[GRP_WIDGET_SORT_BY_DROPDOWN].data = this->vehicle_sorter_names[this->vehicles.SortType()];
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   392
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9212
diff changeset
   393
		this->DrawWidgets();
7258
8ea218277d00 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7134
diff changeset
   394
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   395
		/* Draw Matrix Group
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   396
			* The selected group is drawn in white */
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   397
		StringID str_all_veh, str_no_group_veh;
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   398
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   399
		switch (this->vehicle_type) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   400
			case VEH_TRAIN:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   401
				str_all_veh = STR_GROUP_ALL_TRAINS;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   402
				str_no_group_veh = STR_GROUP_DEFAULT_TRAINS;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   403
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   404
			case VEH_ROAD:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   405
				str_all_veh = STR_GROUP_ALL_ROADS;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   406
				str_no_group_veh = STR_GROUP_DEFAULT_ROADS;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   407
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   408
			case VEH_SHIP:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   409
				str_all_veh = STR_GROUP_ALL_SHIPS;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   410
				str_no_group_veh = STR_GROUP_DEFAULT_SHIPS;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   411
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   412
			case VEH_AIRCRAFT:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   413
				str_all_veh = STR_GROUP_ALL_AIRCRAFTS;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   414
				str_no_group_veh = STR_GROUP_DEFAULT_AIRCRAFTS;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   415
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   416
			default: NOT_REACHED();
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   417
		}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   418
		DrawString(10, y1, str_all_veh, IsAllGroupID(this->group_sel) ? TC_WHITE : TC_BLACK);
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   419
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   420
		y1 += 13;
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   421
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   422
		DrawString(10, y1, str_no_group_veh, IsDefaultGroupID(this->group_sel) ? TC_WHITE : TC_BLACK);
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   423
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   424
		max = min(this->vscroll2.pos + this->vscroll2.cap, this->groups.Length());
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   425
		for (i = this->vscroll2.pos ; i < max ; ++i) {
9365
95e9cbc0257e (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 9317
diff changeset
   426
			const Group *g = this->groups[i];
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   427
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   428
			assert(g->owner == owner);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   429
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   430
			y1 += PLY_WND_PRC__SIZE_OF_ROW_TINY;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   431
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   432
			/* draw the selected group in white, else we draw it in black */
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   433
			SetDParam(0, g->index);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   434
			DrawString(10, y1, STR_GROUP_NAME, (this->group_sel == g->index) ? TC_WHITE : TC_BLACK);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   435
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   436
			/* draw the number of vehicles of the group */
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   437
			SetDParam(0, g->num_vehicle);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   438
			DrawStringRightAligned(187, y1 + 1, STR_GROUP_TINY_NUM, (this->group_sel == g->index) ? TC_WHITE : TC_BLACK);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   439
		}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   440
9530
fba2561f33f1 (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 9408
diff changeset
   441
		this->DrawSortButtonState(GRP_WIDGET_SORT_BY_ORDER, this->vehicles.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   442
10143
38ea4e64508a (svn r14329) -Fix (r14306): selections in the group GUI weren't shown anymore.
rubidium
parents: 10122
diff changeset
   443
		this->DrawVehicleListItems(x, this->vehicle_sel);
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   444
	}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   445
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   446
	virtual void OnClick(Point pt, int widget)
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   447
	{
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   448
		if (widget != GRP_WIDGET_SORT_BY_DROPDOWN && widget != GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN) HideDropDownMenu(this);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   449
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   450
		switch(widget) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   451
			case GRP_WIDGET_SORT_BY_ORDER: // Flip sorting method ascending/descending
9530
fba2561f33f1 (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 9408
diff changeset
   452
				this->vehicles.ToggleSortOrder();
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   453
				this->SetDirty();
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   454
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   455
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   456
			case GRP_WIDGET_SORT_BY_DROPDOWN: // Select sorting criteria dropdown menu
9563
c75bee824deb (svn r13587) -Codechange: make some globals members of VehicleListBase since they are used as such
skidd13
parents: 9530
diff changeset
   457
				ShowDropDownMenu(this, this->vehicle_sorter_names, this->vehicles.SortType(),  GRP_WIDGET_SORT_BY_DROPDOWN, 0, (this->vehicle_type == VEH_TRAIN || this->vehicle_type == VEH_ROAD) ? 0 : (1 << 10));
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   458
				return;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   459
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   460
			case GRP_WIDGET_ALL_VEHICLES: // All vehicles button
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   461
				if (!IsAllGroupID(this->group_sel)) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   462
					this->group_sel = ALL_GROUP;
9530
fba2561f33f1 (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 9408
diff changeset
   463
					this->vehicles.ForceRebuild();
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   464
					this->SetDirty();
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   465
				}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   466
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   467
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   468
			case GRP_WIDGET_DEFAULT_VEHICLES: // Ungrouped vehicles button
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   469
				if (!IsDefaultGroupID(this->group_sel)) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   470
					this->group_sel = DEFAULT_GROUP;
9530
fba2561f33f1 (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 9408
diff changeset
   471
					this->vehicles.ForceRebuild();
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   472
					this->SetDirty();
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   473
				}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   474
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   475
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   476
			case GRP_WIDGET_LIST_GROUP: { // Matrix Group
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   477
				uint16 id_g = (pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET - 26) / PLY_WND_PRC__SIZE_OF_ROW_TINY;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   478
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   479
				if (id_g >= this->vscroll2.cap) return;
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   480
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   481
				id_g += this->vscroll2.pos;
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   482
9365
95e9cbc0257e (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 9317
diff changeset
   483
				if (id_g >= this->groups.Length()) return;
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   484
9365
95e9cbc0257e (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 9317
diff changeset
   485
				this->group_sel = this->groups[id_g]->index;;
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   486
9530
fba2561f33f1 (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 9408
diff changeset
   487
				this->vehicles.ForceRebuild();
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   488
				this->SetDirty();
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   489
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   490
			}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   491
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   492
			case GRP_WIDGET_LIST_VEHICLE: { // Matrix Vehicle
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   493
				uint32 id_v = (pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / (int)this->resize.step_height;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   494
				const Vehicle *v;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   495
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   496
				if (id_v >= this->vscroll.cap) return; // click out of bounds
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   497
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   498
				id_v += this->vscroll.pos;
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   499
9365
95e9cbc0257e (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 9317
diff changeset
   500
				if (id_v >= this->vehicles.Length()) return; // click out of list bound
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   501
9365
95e9cbc0257e (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 9317
diff changeset
   502
				v = this->vehicles[id_v];
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   503
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   504
				this->vehicle_sel = v->index;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   505
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   506
				if (v->IsValid()) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   507
					SetObjectToPlaceWnd(v->GetImage(DIR_W), GetVehiclePalette(v), VHM_DRAG, this);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   508
					_cursor.vehchain = true;
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   509
				}
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   510
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   511
				this->SetDirty();
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   512
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   513
			}
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   514
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   515
			case GRP_WIDGET_CREATE_GROUP: // Create a new group
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   516
				DoCommandP(0, this->vehicle_type, 0, NULL, CMD_CREATE_GROUP | CMD_MSG(STR_GROUP_CAN_T_CREATE));
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   517
				break;
6667
dba8ef60ffd2 (svn r9898) -Fix (r9874): Many...
peter1138
parents: 6660
diff changeset
   518
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   519
			case GRP_WIDGET_DELETE_GROUP: { // Delete the selected group
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   520
				GroupID group = this->group_sel;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   521
				this->group_sel = ALL_GROUP;
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   522
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   523
				DoCommandP(0, group, 0, NULL, CMD_DELETE_GROUP | CMD_MSG(STR_GROUP_CAN_T_DELETE));
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   524
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   525
			}
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   526
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   527
			case GRP_WIDGET_RENAME_GROUP: { // Rename the selected roup
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   528
				assert(IsValidGroupID(this->group_sel));
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   529
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   530
				const Group *g = GetGroup(this->group_sel);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   531
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   532
				SetDParam(0, g->index);
10148
ad8e8a65f6a2 (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents: 10145
diff changeset
   533
				ShowQueryString(STR_GROUP_NAME, STR_GROUP_RENAME_CAPTION, MAX_LENGTH_GROUP_NAME_BYTES, MAX_LENGTH_GROUP_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   534
			} break;
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   535
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   536
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   537
			case GRP_WIDGET_AVAILABLE_VEHICLES:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   538
				ShowBuildVehicleWindow(0, this->vehicle_type);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   539
				break;
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   540
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   541
			case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   542
				ShowGroupActionDropdown(this, this->group_sel);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   543
				break;
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   544
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   545
			case GRP_WIDGET_START_ALL:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   546
			case GRP_WIDGET_STOP_ALL: { // Start/stop all vehicles of the list
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   547
				DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK)
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   548
													| (1 << 6)
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   549
													| (widget == GRP_WIDGET_START_ALL ? (1 << 5) : 0)
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   550
													| this->vehicle_type, NULL, CMD_MASS_START_STOP);
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   551
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   552
				break;
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   553
			}
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   554
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   555
			case GRP_WIDGET_REPLACE_PROTECTION:
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   556
				if (IsValidGroupID(this->group_sel)) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   557
					const Group *g = GetGroup(this->group_sel);
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   558
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   559
					DoCommandP(0, this->group_sel, !g->replace_protection, NULL, CMD_SET_GROUP_REPLACE_PROTECTION);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   560
				}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   561
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   562
		}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   563
	}
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   564
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   565
	virtual void OnDragDrop(Point pt, int widget)
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   566
	{
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   567
		switch (widget) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   568
			case GRP_WIDGET_ALL_VEHICLES: // All vehicles
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   569
			case GRP_WIDGET_DEFAULT_VEHICLES: // Ungrouped vehicles
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   570
				DoCommandP(0, DEFAULT_GROUP, this->vehicle_sel, NULL, CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_GROUP_CAN_T_ADD_VEHICLE));
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   571
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   572
				this->vehicle_sel = INVALID_VEHICLE;
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   573
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   574
				this->SetDirty();
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   575
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   576
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   577
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   578
			case GRP_WIDGET_LIST_GROUP: { // Maxtrix group
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   579
				uint16 id_g = (pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET - 26) / PLY_WND_PRC__SIZE_OF_ROW_TINY;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   580
				const VehicleID vindex = this->vehicle_sel;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   581
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   582
				this->vehicle_sel = INVALID_VEHICLE;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   583
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   584
				this->SetDirty();
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   585
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   586
				if (id_g >= this->vscroll2.cap) return;
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   587
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   588
				id_g += this->vscroll2.pos;
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   589
9365
95e9cbc0257e (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 9317
diff changeset
   590
				if (id_g >= this->groups.Length()) return;
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   591
9365
95e9cbc0257e (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 9317
diff changeset
   592
				DoCommandP(0, this->groups[id_g]->index, vindex, NULL, CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_GROUP_CAN_T_ADD_VEHICLE));
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   593
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   594
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   595
			}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   596
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   597
			case GRP_WIDGET_LIST_VEHICLE: { // Maxtrix vehicle
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   598
				uint32 id_v = (pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / (int)this->resize.step_height;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   599
				const Vehicle *v;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   600
				const VehicleID vindex = this->vehicle_sel;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   601
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   602
				this->vehicle_sel = INVALID_VEHICLE;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   603
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   604
				this->SetDirty();
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   605
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   606
				if (id_v >= this->vscroll.cap) return; // click out of bounds
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   607
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   608
				id_v += this->vscroll.pos;
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   609
9365
95e9cbc0257e (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 9317
diff changeset
   610
				if (id_v >= this->vehicles.Length()) return; // click out of list bound
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   611
9365
95e9cbc0257e (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 9317
diff changeset
   612
				v = this->vehicles[id_v];
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   613
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   614
				if (vindex == v->index) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   615
					ShowVehicleViewWindow(v);
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   616
				}
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   617
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   618
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   619
			}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   620
		}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   621
		_cursor.vehchain = false;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   622
	}
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   623
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   624
	virtual void OnQueryTextFinished(char *str)
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   625
	{
10148
ad8e8a65f6a2 (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents: 10145
diff changeset
   626
		if (str == NULL) return;
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   627
10148
ad8e8a65f6a2 (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents: 10145
diff changeset
   628
		_cmd_text = str;
ad8e8a65f6a2 (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents: 10145
diff changeset
   629
		DoCommandP(0, this->group_sel, 0, NULL, CMD_RENAME_GROUP | CMD_MSG(STR_GROUP_CAN_T_RENAME));
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   630
	}
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   631
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   632
	virtual void OnResize(Point new_size, Point delta)
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   633
	{
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   634
		this->vscroll2.cap += delta.y / PLY_WND_PRC__SIZE_OF_ROW_TINY;
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   635
		this->vscroll.cap += delta.y / (int)this->resize.step_height;
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   636
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   637
		this->widget[GRP_WIDGET_LIST_GROUP].data = (this->vscroll2.cap << 8) + 1;
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   638
		this->widget[GRP_WIDGET_LIST_VEHICLE].data = (this->vscroll.cap << 8) + 1;
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   639
	}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   640
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   641
	virtual void OnDropdownSelect(int widget, int index)
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   642
	{
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   643
		switch (widget) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   644
			case GRP_WIDGET_SORT_BY_DROPDOWN:
9530
fba2561f33f1 (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 9408
diff changeset
   645
				this->vehicles.SetSortType(index);
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   646
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   647
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   648
			case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN:
9365
95e9cbc0257e (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 9317
diff changeset
   649
				assert(this->vehicles.Length() != 0);
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   650
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   651
				switch (index) {
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   652
					case GALF_REPLACE: // Replace window
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   653
						ShowReplaceGroupVehicleWindow(this->group_sel, this->vehicle_type);
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   654
						break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   655
					case GALF_SERVICE: // Send for servicing
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   656
						DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK)
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   657
									| DEPOT_MASS_SEND
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   658
									| DEPOT_SERVICE, NULL, GetCmdSendToDepot(this->vehicle_type));
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   659
						break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   660
					case GALF_DEPOT: // Send to Depots
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   661
						DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK)
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   662
									| DEPOT_MASS_SEND, NULL, GetCmdSendToDepot(this->vehicle_type));
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   663
						break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   664
					case GALF_ADD_SHARED: // Add shared Vehicles
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   665
						assert(IsValidGroupID(this->group_sel));
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   666
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   667
						DoCommandP(0, this->group_sel, this->vehicle_type, NULL, CMD_ADD_SHARED_VEHICLE_GROUP | CMD_MSG(STR_GROUP_CAN_T_ADD_SHARED_VEHICLE));
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   668
						break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   669
					case GALF_REMOVE_ALL: // Remove all Vehicles from the selected group
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   670
						assert(IsValidGroupID(this->group_sel));
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   671
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   672
						DoCommandP(0, this->group_sel, this->vehicle_type, NULL, CMD_REMOVE_ALL_VEHICLES_GROUP | CMD_MSG(STR_GROUP_CAN_T_REMOVE_ALL_VEHICLES));
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   673
						break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   674
					default: NOT_REACHED();
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   675
				}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   676
				break;
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   677
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   678
			default: NOT_REACHED();
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   679
		}
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   680
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   681
		this->SetDirty();
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   682
	}
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   683
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   684
	virtual void OnTick()
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   685
	{
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   686
		if (_pause_game != 0) return;
9530
fba2561f33f1 (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 9408
diff changeset
   687
		if (this->groups.NeedResort() || this->vehicles.NeedResort()) {
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   688
			this->SetDirty();
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   689
		}
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   690
	}
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   691
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   692
	virtual void OnPlaceObjectAbort()
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   693
	{
10122
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   694
		/* abort drag & drop */
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   695
		this->vehicle_sel = INVALID_VEHICLE;
c524226103f1 (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium
parents: 10119
diff changeset
   696
		this->InvalidateWidget(GRP_WIDGET_LIST_VEHICLE);
8179
60c4282e6de6 (svn r11742) -Codechange [FS#1319]: Run window tick events when paused, so that news pop-ups and the about window still progress. For other windows the events are ignored when paused.
peter1138
parents: 8144
diff changeset
   697
	}
9183
6e749ab7d680 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 9182
diff changeset
   698
};
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   699
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   700
10118
6b418b016a89 (svn r14302) -Codechange: simplify and make the vehicle list and group windows behave the same w.r.t. getting wider (by default) for trains than the other vehicles.
rubidium
parents: 10117
diff changeset
   701
static WindowDesc _group_desc = {
6b418b016a89 (svn r14302) -Codechange: simplify and make the vehicle list and group windows behave the same w.r.t. getting wider (by default) for trains than the other vehicles.
rubidium
parents: 10117
diff changeset
   702
	WDP_AUTO, WDP_AUTO, 460, 194, 460, 246,
6b418b016a89 (svn r14302) -Codechange: simplify and make the vehicle list and group windows behave the same w.r.t. getting wider (by default) for trains than the other vehicles.
rubidium
parents: 10117
diff changeset
   703
	WC_INVALID, WC_NONE,
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   704
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   705
	_group_widgets,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   706
};
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   707
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   708
void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type)
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   709
{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   710
	if (!IsValidCompanyID(company)) return;
7407
a0e8d497e161 (svn r10780) -Fix: assertion when opening the advanced vehicle list with the shortcut when being a spectator.
rubidium
parents: 7387
diff changeset
   711
10118
6b418b016a89 (svn r14302) -Codechange: simplify and make the vehicle list and group windows behave the same w.r.t. getting wider (by default) for trains than the other vehicles.
rubidium
parents: 10117
diff changeset
   712
	_group_desc.cls = GetWindowClassForVehicleType(vehicle_type);
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10148
diff changeset
   713
	WindowNumber num = (vehicle_type << 11) | VLW_GROUP_LIST | company;
10118
6b418b016a89 (svn r14302) -Codechange: simplify and make the vehicle list and group windows behave the same w.r.t. getting wider (by default) for trains than the other vehicles.
rubidium
parents: 10117
diff changeset
   714
	AllocateWindowDescFront<VehicleGroupWindow>(&_group_desc, num);
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   715
}