src/group_gui.cpp
author Tero Marttila <terom@fixme.fi>
Tue, 22 Jul 2008 21:51:14 +0300
changeset 11180 982e9f814f97
parent 11161 7d0fac8f14cd
permissions -rw-r--r--
scan for tarfiles in CACHE_DIR, remember what Subdirectory a tar was found in, set the GCF_FLAG on GRFs loaded from there, and hide those in the NewGRF GUI
7139
4ae3ab180d05 (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$ */
4ae3ab180d05 (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
10429
1b99254f9607 (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: 10234
diff changeset
     3
/** @file group_gui.cpp GUI for the group window. */
7139
4ae3ab180d05 (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
4ae3ab180d05 (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"
4ae3ab180d05 (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"
4ae3ab180d05 (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"
8603
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
     8
#include "window_gui.h"
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
     9
#include "textbuf_gui.h"
8612
6414fc21c2f3 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8610
diff changeset
    10
#include "command_func.h"
7139
4ae3ab180d05 (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"
4ae3ab180d05 (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
    12
#include "train.h"
4ae3ab180d05 (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 "group.h"
4ae3ab180d05 (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 "debug.h"
8610
17cc343a23dd (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8606
diff changeset
    15
#include "strings_func.h"
8626
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8617
diff changeset
    16
#include "core/alloc_func.hpp"
8627
448ebf3a8291 (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: 8626
diff changeset
    17
#include "window_func.h"
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
    18
#include "vehicle_func.h"
8708
0c29fbc79be4 (svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents: 8675
diff changeset
    19
#include "autoreplace_gui.h"
8710
52015340050c (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8708
diff changeset
    20
#include "string_func.h"
8720
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8710
diff changeset
    21
#include "viewport_func.h"
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8710
diff changeset
    22
#include "gfx_func.h"
8750
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8733
diff changeset
    23
#include "player_func.h"
8811
cf734ff178bf (svn r11880) -Codechange: Generate vehicle group action dropdown dynamically, and assign an enum for the function return codes.
peter1138
parents: 8810
diff changeset
    24
#include "widgets/dropdown_type.h"
8780
6f3f3ec6c69a (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: 8760
diff changeset
    25
#include "widgets/dropdown_func.h"
10445
2dd7d9d0a957 (svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents: 10434
diff changeset
    26
#include "tilehighlight_func.h"
7139
4ae3ab180d05 (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
    27
8760
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    28
#include "table/strings.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    29
#include "table/sprites.h"
7139
4ae3ab180d05 (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
    30
10502
996d9308d650 (svn r13045) -Codechange: make list_d (now GUIList) more generic and uniform.
rubidium
parents: 10462
diff changeset
    31
typedef GUIList<const Group*> GUIGroupList;
9266
416385a64dcb (svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium
parents: 9197
diff changeset
    32
7139
4ae3ab180d05 (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
    33
enum GroupListWidgets {
4ae3ab180d05 (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
	GRP_WIDGET_CLOSEBOX = 0,
4ae3ab180d05 (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_CAPTION,
4ae3ab180d05 (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_STICKY,
4ae3ab180d05 (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_EMPTY_TOP_LEFT,
4ae3ab180d05 (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_ALL_VEHICLES,
7754
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
    39
	GRP_WIDGET_DEFAULT_VEHICLES,
7139
4ae3ab180d05 (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_LIST_GROUP,
4ae3ab180d05 (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_GROUP_SCROLLBAR,
4ae3ab180d05 (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_SORT_BY_ORDER,
4ae3ab180d05 (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_SORT_BY_DROPDOWN,
4ae3ab180d05 (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_EMPTY_TOP_RIGHT,
4ae3ab180d05 (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_LIST_VEHICLE,
4ae3ab180d05 (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_LIST_VEHICLE_SCROLLBAR,
4ae3ab180d05 (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_CREATE_GROUP,
4ae3ab180d05 (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_DELETE_GROUP,
4ae3ab180d05 (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_RENAME_GROUP,
4ae3ab180d05 (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
    50
	GRP_WIDGET_EMPTY1,
4ae3ab180d05 (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
    51
	GRP_WIDGET_REPLACE_PROTECTION,
4ae3ab180d05 (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
    52
	GRP_WIDGET_EMPTY2,
4ae3ab180d05 (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
    53
	GRP_WIDGET_AVAILABLE_VEHICLES,
4ae3ab180d05 (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
    54
	GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN,
4ae3ab180d05 (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
    55
	GRP_WIDGET_STOP_ALL,
4ae3ab180d05 (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
    56
	GRP_WIDGET_START_ALL,
4ae3ab180d05 (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
    57
	GRP_WIDGET_EMPTY_BOTTOM_RIGHT,
4ae3ab180d05 (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
    58
	GRP_WIDGET_RESIZE,
4ae3ab180d05 (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
    59
};
4ae3ab180d05 (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
    60
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    61
enum GroupActionListFunction {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    62
	GALF_REPLACE,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    63
	GALF_SERVICE,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    64
	GALF_DEPOT,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    65
	GALF_ADD_SHARED,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    66
	GALF_REMOVE_ALL,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    67
};
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    68
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    69
/**
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    70
 * Update/redraw the group action dropdown
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    71
 * @param w   the window the dropdown belongs to
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    72
 * @param gid the currently selected group in the window
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    73
 */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    74
static void ShowGroupActionDropdown(Window *w, GroupID gid)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    75
{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    76
	DropDownList *list = new DropDownList();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    77
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    78
	list->push_back(new DropDownListStringItem(STR_REPLACE_VEHICLES,    GALF_REPLACE, false));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    79
	list->push_back(new DropDownListStringItem(STR_SEND_FOR_SERVICING,  GALF_SERVICE, false));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    80
	list->push_back(new DropDownListStringItem(STR_SEND_TRAIN_TO_DEPOT, GALF_DEPOT,   false));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    81
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    82
	if (IsValidGroupID(gid)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    83
		list->push_back(new DropDownListStringItem(STR_GROUP_ADD_SHARED_VEHICLE,  GALF_ADD_SHARED, false));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    84
		list->push_back(new DropDownListStringItem(STR_GROUP_REMOVE_ALL_VEHICLES, GALF_REMOVE_ALL, false));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    85
	}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    86
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    87
	ShowDropDownList(w, list, 0, GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    88
}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
    89
7139
4ae3ab180d05 (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
    90
4ae3ab180d05 (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
    91
static const Widget _group_widgets[] = {
4ae3ab180d05 (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
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,             STR_018B_CLOSE_WINDOW},
7843
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
    93
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   447,     0,    13, 0x0,                  STR_018C_WINDOW_TITLE_DRAG_THIS},
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
    94
{  WWT_STICKYBOX,     RESIZE_LR,    14,   448,   459,     0,    13, 0x0,                  STR_STICKY_BUTTON},
7139
4ae3ab180d05 (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
    95
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   200,    14,    25, 0x0,                  STR_NULL},
7754
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
    96
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   200,    26,    38, 0x0,                  STR_NULL},
8421
9cd504b58efb (svn r11478) -Fix: two small layout issues with the vehicle grouping GUI.
rubidium
parents: 8406
diff changeset
    97
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   200,    39,    51, 0x0,                  STR_NULL},
7843
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
    98
{     WWT_MATRIX, RESIZE_BOTTOM,    14,     0,   188,    52,   168, 0x701,                STR_GROUPS_CLICK_ON_GROUP_FOR_TIP},
8421
9cd504b58efb (svn r11478) -Fix: two small layout issues with the vehicle grouping GUI.
rubidium
parents: 8406
diff changeset
    99
{  WWT_SCROLLBAR, RESIZE_BOTTOM,    14,   189,   200,    52,   168, 0x0,                  STR_0190_SCROLL_BAR_SCROLLS_LIST},
7139
4ae3ab180d05 (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
   100
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   201,   281,    14,    25, STR_SORT_BY,          STR_SORT_ORDER_TIP},
8834
ef15cacd6894 (svn r11904) -Codechange: use dropdown widget in 3 more windows, build vehicle, group vehicle list and station list.
peter1138
parents: 8822
diff changeset
   101
{   WWT_DROPDOWN,   RESIZE_NONE,    14,   282,   447,    14,    25, 0x0,                  STR_SORT_CRITERIA_TIP},
7843
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
   102
{      WWT_PANEL,  RESIZE_RIGHT,    14,   448,   459,    14,    25, 0x0,                  STR_NULL},
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
   103
{     WWT_MATRIX,     RESIZE_RB,    14,   201,   447,    26,   181, 0x701,                STR_NULL},
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
   104
{ WWT_SCROLL2BAR,    RESIZE_LRB,    14,   448,   459,    26,   181, 0x0,                  STR_0190_SCROLL_BAR_SCROLLS_LIST},
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
   105
{ WWT_PUSHIMGBTN,     RESIZE_TB,    14,     0,    23,   169,   193, 0x0,                  STR_GROUP_CREATE_TIP},
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
   106
{ WWT_PUSHIMGBTN,     RESIZE_TB,    14,    24,    47,   169,   193, 0x0,                  STR_GROUP_DELETE_TIP},
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
   107
{ WWT_PUSHIMGBTN,     RESIZE_TB,    14,    48,    71,   169,   193, 0x0,                  STR_GROUP_RENAME_TIP},
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
   108
{      WWT_PANEL,     RESIZE_TB,    14,    72,   164,   169,   193, 0x0,                  STR_NULL},
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
   109
{ WWT_PUSHIMGBTN,     RESIZE_TB,    14,   165,   188,   169,   193, 0x0,                  STR_GROUP_REPLACE_PROTECTION_TIP},
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
   110
{      WWT_PANEL,     RESIZE_TB,    14,   189,   200,   169,   193, 0x0,                  STR_NULL},
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
   111
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   201,   306,   182,   193, 0x0,                  STR_AVAILABLE_ENGINES_TIP},
8834
ef15cacd6894 (svn r11904) -Codechange: use dropdown widget in 3 more windows, build vehicle, group vehicle list and station list.
peter1138
parents: 8822
diff changeset
   112
{   WWT_DROPDOWN,     RESIZE_TB,    14,   307,   423,   182,   193, STR_MANAGE_LIST,      STR_MANAGE_LIST_TIP},
7843
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
   113
{ WWT_PUSHIMGBTN,     RESIZE_TB,    14,   424,   435,   182,   193, SPR_FLAG_VEH_STOPPED, STR_MASS_STOP_LIST_TIP},
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
   114
{ WWT_PUSHIMGBTN,     RESIZE_TB,    14,   436,   447,   182,   193, SPR_FLAG_VEH_RUNNING, STR_MASS_START_LIST_TIP},
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
   115
{      WWT_PANEL,    RESIZE_RTB,    14,   448,   447,   182,   193, 0x0,                  STR_NULL},
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
   116
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   448,   459,   182,   193, 0x0,                  STR_RESIZE_BUTTON},
7139
4ae3ab180d05 (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
   117
{   WIDGETS_END},
4ae3ab180d05 (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
   118
};
4ae3ab180d05 (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
   119
4ae3ab180d05 (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
10721
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   121
class VehicleGroupWindow : public Window, public VehicleListBase {
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   122
private:
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   123
	GroupID group_sel;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   124
	VehicleID vehicle_sel;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   125
	GUIGroupList groups;
7139
4ae3ab180d05 (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
   126
10721
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   127
	/**
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   128
	 * (Re)Build the group list.
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   129
	 *
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   130
	 * @param owner The owner of the window
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   131
	 */
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   132
	void BuildGroupList(PlayerID owner)
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   133
	{
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   134
		if (!this->groups.NeedRebuild()) return;
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   135
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   136
		this->groups.Clear();
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   137
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   138
		const Group *g;
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   139
		FOR_ALL_GROUPS(g) {
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   140
			if (g->owner == owner && g->vehicle_type == this->vehicle_type) {
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   141
				*this->groups.Append() = g;
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   142
			}
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   143
		}
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   144
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   145
		this->groups.Compact();
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   146
		this->groups.RebuildDone();
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   147
	}
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   148
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   149
	/** Sort the groups by their name */
10730
40906a6f031e (svn r13280) -Fix (r13276): MSVC compilation was broken
smatz
parents: 10721
diff changeset
   150
	static int CDECL GroupNameSorter(const Group* const *a, const Group* const *b)
10721
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   151
	{
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   152
		static const Group *last_group[2] = { NULL, NULL };
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   153
		static char         last_name[2][64] = { "", "" };
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   154
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   155
		if (*a != last_group[0]) {
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   156
			last_group[0] = *a;
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   157
			SetDParam(0, (*a)->index);
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   158
			GetString(last_name[0], STR_GROUP_NAME, lastof(last_name[0]));
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   159
		}
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   160
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   161
		if (*b != last_group[1]) {
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   162
			last_group[1] = *b;
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   163
			SetDParam(0, (*b)->index);
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   164
			GetString(last_name[1], STR_GROUP_NAME, lastof(last_name[1]));
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   165
		}
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   166
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   167
		int r = strcmp(last_name[0], last_name[1]); // sort by name
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   168
		if (r == 0) return (*a)->index - (*b)->index;
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   169
		return r;
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   170
	}
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   171
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   172
public:
10525
da5bc725cda4 (svn r13069) -Codechange: it is no longer needed to pass a void *data pointer with the WE_CREATE message because nothing uses it anymore.
rubidium
parents: 10503
diff changeset
   173
	VehicleGroupWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   174
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   175
		const PlayerID owner = (PlayerID)GB(this->window_number, 0, 8);
10534
da1bea97f733 (svn r13078) -Fix: group gui used the vehicle type before it was actually set.
rubidium
parents: 10525
diff changeset
   176
		this->vehicle_type = (VehicleType)GB(this->window_number, 11, 5);
7139
4ae3ab180d05 (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
   177
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   178
		this->caption_color = owner;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   179
		this->resize.step_width = 1;
7139
4ae3ab180d05 (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
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   181
		switch (this->vehicle_type) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   182
			default: NOT_REACHED();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   183
			case VEH_TRAIN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   184
			case VEH_ROAD:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   185
				this->vscroll.cap = 9;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   186
				this->vscroll2.cap = 6;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   187
				this->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_SMALL;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   188
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   189
			case VEH_SHIP:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   190
			case VEH_AIRCRAFT:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   191
				this->vscroll.cap = 9;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   192
				this->vscroll2.cap = 4;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   193
				this->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_BIG2;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   194
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   195
		}
8811
cf734ff178bf (svn r11880) -Codechange: Generate vehicle group action dropdown dynamically, and assign an enum for the function return codes.
peter1138
parents: 8810
diff changeset
   196
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   197
		this->widget[GRP_WIDGET_LIST_GROUP].data = (this->vscroll.cap << 8) + 1;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   198
		this->widget[GRP_WIDGET_LIST_VEHICLE].data = (this->vscroll2.cap << 8) + 1;
7156
68de47bdcb80 (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: 7139
diff changeset
   199
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   200
		switch (this->vehicle_type) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   201
			default: NOT_REACHED();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   202
			case VEH_TRAIN:    this->sorting = &_sorting.train;    break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   203
			case VEH_ROAD:     this->sorting = &_sorting.roadveh;  break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   204
			case VEH_SHIP:     this->sorting = &_sorting.ship;     break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   205
			case VEH_AIRCRAFT: this->sorting = &_sorting.aircraft; break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   206
		}
7156
68de47bdcb80 (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: 7139
diff changeset
   207
10980
5281330a77da (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 10769
diff changeset
   208
		this->vehicles.SetListing(*this->sorting);
5281330a77da (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 10769
diff changeset
   209
		this->vehicles.ForceRebuild();
5281330a77da (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 10769
diff changeset
   210
		this->vehicles.NeedResort();
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   211
10721
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   212
		this->groups.ForceRebuild();
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   213
		this->groups.NeedResort();
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   214
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   215
		this->group_sel = ALL_GROUP;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   216
		this->vehicle_sel = INVALID_VEHICLE;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   217
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   218
		switch (this->vehicle_type) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   219
			case VEH_TRAIN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   220
				this->widget[GRP_WIDGET_LIST_VEHICLE].tooltips = STR_883D_TRAINS_CLICK_ON_TRAIN_FOR;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   221
				this->widget[GRP_WIDGET_AVAILABLE_VEHICLES].data = STR_AVAILABLE_TRAINS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   222
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   223
				this->widget[GRP_WIDGET_CREATE_GROUP].data = SPR_GROUP_CREATE_TRAIN;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   224
				this->widget[GRP_WIDGET_RENAME_GROUP].data = SPR_GROUP_RENAME_TRAIN;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   225
				this->widget[GRP_WIDGET_DELETE_GROUP].data = SPR_GROUP_DELETE_TRAIN;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   226
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   227
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   228
			case VEH_ROAD:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   229
				this->widget[GRP_WIDGET_LIST_VEHICLE].tooltips = STR_901A_ROAD_VEHICLES_CLICK_ON;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   230
				this->widget[GRP_WIDGET_AVAILABLE_VEHICLES].data = STR_AVAILABLE_ROAD_VEHICLES;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   231
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   232
				this->widget[GRP_WIDGET_CREATE_GROUP].data = SPR_GROUP_CREATE_ROADVEH;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   233
				this->widget[GRP_WIDGET_RENAME_GROUP].data = SPR_GROUP_RENAME_ROADVEH;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   234
				this->widget[GRP_WIDGET_DELETE_GROUP].data = SPR_GROUP_DELETE_ROADVEH;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   235
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   236
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   237
			case VEH_SHIP:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   238
				this->widget[GRP_WIDGET_LIST_VEHICLE].tooltips = STR_9823_SHIPS_CLICK_ON_SHIP_FOR;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   239
				this->widget[GRP_WIDGET_AVAILABLE_VEHICLES].data = STR_AVAILABLE_SHIPS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   240
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   241
				this->widget[GRP_WIDGET_CREATE_GROUP].data = SPR_GROUP_CREATE_SHIP;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   242
				this->widget[GRP_WIDGET_RENAME_GROUP].data = SPR_GROUP_RENAME_SHIP;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   243
				this->widget[GRP_WIDGET_DELETE_GROUP].data = SPR_GROUP_DELETE_SHIP;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   244
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   245
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   246
			case VEH_AIRCRAFT:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   247
				this->widget[GRP_WIDGET_LIST_VEHICLE].tooltips = STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   248
				this->widget[GRP_WIDGET_AVAILABLE_VEHICLES].data = STR_AVAILABLE_AIRCRAFT;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   249
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   250
				this->widget[GRP_WIDGET_CREATE_GROUP].data = SPR_GROUP_CREATE_AIRCRAFT;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   251
				this->widget[GRP_WIDGET_RENAME_GROUP].data = SPR_GROUP_RENAME_AIRCRAFT;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   252
				this->widget[GRP_WIDGET_DELETE_GROUP].data = SPR_GROUP_DELETE_AIRCRAFT;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   253
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   254
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   255
			default: NOT_REACHED();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   256
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   257
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   258
		this->FindWindowPlacementAndResize(desc);
8811
cf734ff178bf (svn r11880) -Codechange: Generate vehicle group action dropdown dynamically, and assign an enum for the function return codes.
peter1138
parents: 8810
diff changeset
   259
	}
cf734ff178bf (svn r11880) -Codechange: Generate vehicle group action dropdown dynamically, and assign an enum for the function return codes.
peter1138
parents: 8810
diff changeset
   260
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   261
	~VehicleGroupWindow()
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   262
	{
10980
5281330a77da (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 10769
diff changeset
   263
		*this->sorting = this->vehicles.GetListing();
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   264
	}
7139
4ae3ab180d05 (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
   265
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   266
	virtual void OnInvalidateData(int data)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   267
	{
10721
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   268
		if (data == 0) {
10980
5281330a77da (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 10769
diff changeset
   269
			this->vehicles.ForceRebuild();
10721
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   270
			this->groups.ForceRebuild();
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   271
		} else {
10980
5281330a77da (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 10769
diff changeset
   272
			this->vehicles.ForceResort();
10721
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   273
			this->groups.ForceResort();
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   274
		}
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   275
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   276
		if (!(IsAllGroupID(this->group_sel) || IsDefaultGroupID(this->group_sel) || IsValidGroupID(this->group_sel))) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   277
			this->group_sel = ALL_GROUP;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   278
			HideDropDownMenu(this);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   279
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   280
		this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   281
	}
7163
09e65bfbc08b (svn r9898) -Fix (r9874): Many...
peter1138
parents: 7156
diff changeset
   282
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   283
	virtual void OnPaint()
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   284
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   285
		const PlayerID owner = (PlayerID)GB(this->window_number, 0, 8);
10769
a005e45d1f09 (svn r13319) -Codechange: Remove use of imaginary horizontal scrollbar in the group vehicle list
peter1138
parents: 10730
diff changeset
   286
		int x = this->widget[GRP_WIDGET_LIST_VEHICLE].left + 2;
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   287
		int y2 = PLY_WND_PRC__OFFSET_TOP_WIDGET;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   288
		int y1 = PLY_WND_PRC__OFFSET_TOP_WIDGET + 2;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   289
		int max;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   290
		int i;
7139
4ae3ab180d05 (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
   291
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   292
		/* If we select the all vehicles, this->list will contain all vehicles of the player
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   293
			* else this->list will contain all vehicles which belong to the selected group */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   294
		BuildVehicleList(this, owner, this->group_sel, IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   295
		SortVehicleList(this);
7139
4ae3ab180d05 (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
   296
10721
e6c323cb3fac (svn r13271) -Codechange: groups sorting uses GUILists Sort() now
skidd13
parents: 10720
diff changeset
   297
		this->BuildGroupList(owner);
10730
40906a6f031e (svn r13280) -Fix (r13276): MSVC compilation was broken
smatz
parents: 10721
diff changeset
   298
		this->groups.Sort(&GroupNameSorter);
8386
b2b1080100aa (svn r11441) -Fix [FS#1443]: manage list dropdown menu did not "disappear" when the all vehicles are removed from the "current" group.
rubidium
parents: 8385
diff changeset
   299
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   300
		SetVScrollCount(this, this->groups.Length());
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   301
		SetVScroll2Count(this, this->vehicles.Length());
7139
4ae3ab180d05 (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
   302
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   303
		/* The drop down menu is out, *but* it may not be used, retract it. */
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   304
		if (this->vehicles.Length() == 0 && this->IsWidgetLowered(GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN)) {
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   305
			this->RaiseWidget(GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   306
			HideDropDownMenu(this);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   307
		}
7139
4ae3ab180d05 (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
   308
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   309
		/* Disable all lists management button when the list is empty */
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   310
		this->SetWidgetsDisabledState(this->vehicles.Length() == 0 || _local_player != owner,
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   311
				GRP_WIDGET_STOP_ALL,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   312
				GRP_WIDGET_START_ALL,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   313
				GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   314
				WIDGET_LIST_END);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   315
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   316
		/* Disable the group specific function when we select the default group or all vehicles */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   317
		this->SetWidgetsDisabledState(IsDefaultGroupID(this->group_sel) || IsAllGroupID(this->group_sel) || _local_player != owner,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   318
				GRP_WIDGET_DELETE_GROUP,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   319
				GRP_WIDGET_RENAME_GROUP,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   320
				GRP_WIDGET_REPLACE_PROTECTION,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   321
				WIDGET_LIST_END);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   322
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   323
		/* Disable remaining buttons for non-local player
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   324
			* Needed while changing _local_player, eg. by cheats
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   325
			* All procedures (eg. move vehicle to another group)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   326
			*  verify, whether you are the owner of the vehicle,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   327
			*  so it doesn't have to be disabled
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   328
			*/
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   329
		this->SetWidgetsDisabledState(_local_player != owner,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   330
				GRP_WIDGET_CREATE_GROUP,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   331
				GRP_WIDGET_AVAILABLE_VEHICLES,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   332
				WIDGET_LIST_END);
8043
be5076cc40ef (svn r11067) -Codechange: also make it possible to use the advanced vehicle list for other players. Patch by SmatZ.
rubidium
parents: 7986
diff changeset
   333
be5076cc40ef (svn r11067) -Codechange: also make it possible to use the advanced vehicle list for other players. Patch by SmatZ.
rubidium
parents: 7986
diff changeset
   334
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   335
		/* If selected_group == DEFAULT_GROUP || ALL_GROUP, draw the standard caption
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   336
				We list all vehicles or ungrouped vehicles */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   337
		if (IsDefaultGroupID(this->group_sel) || IsAllGroupID(this->group_sel)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   338
			SetDParam(0, owner);
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   339
			SetDParam(1, this->vehicles.Length());
7139
4ae3ab180d05 (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
   340
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   341
			switch (this->vehicle_type) {
7754
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   342
				case VEH_TRAIN:
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   343
					this->widget[GRP_WIDGET_CAPTION].data = STR_881B_TRAINS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   344
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = SPR_GROUP_REPLACE_OFF_TRAIN;
7754
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   345
					break;
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   346
				case VEH_ROAD:
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   347
					this->widget[GRP_WIDGET_CAPTION].data = STR_9001_ROAD_VEHICLES;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   348
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = SPR_GROUP_REPLACE_OFF_ROADVEH;
7754
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   349
					break;
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   350
				case VEH_SHIP:
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   351
					this->widget[GRP_WIDGET_CAPTION].data = STR_9805_SHIPS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   352
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = SPR_GROUP_REPLACE_OFF_SHIP;
7754
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   353
					break;
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   354
				case VEH_AIRCRAFT:
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   355
					this->widget[GRP_WIDGET_CAPTION].data =  STR_A009_AIRCRAFT;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   356
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = SPR_GROUP_REPLACE_OFF_AIRCRAFT;
7754
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   357
					break;
10230
bf81856a1101 (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: 10222
diff changeset
   358
				default: NOT_REACHED();
7139
4ae3ab180d05 (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
   359
			}
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   360
		} else {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   361
			const Group *g = GetGroup(this->group_sel);
8845
e0eac76d3d16 (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: 8834
diff changeset
   362
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   363
			SetDParam(0, g->index);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   364
			SetDParam(1, g->num_vehicle);
7139
4ae3ab180d05 (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
   365
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   366
			switch (this->vehicle_type) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   367
				case VEH_TRAIN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   368
					this->widget[GRP_WIDGET_CAPTION].data = STR_GROUP_TRAINS_CAPTION;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   369
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = (g->replace_protection) ? SPR_GROUP_REPLACE_ON_TRAIN : SPR_GROUP_REPLACE_OFF_TRAIN;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   370
					break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   371
				case VEH_ROAD:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   372
					this->widget[GRP_WIDGET_CAPTION].data = STR_GROUP_ROADVEH_CAPTION;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   373
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = (g->replace_protection) ? SPR_GROUP_REPLACE_ON_ROADVEH : SPR_GROUP_REPLACE_OFF_ROADVEH;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   374
					break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   375
				case VEH_SHIP:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   376
					this->widget[GRP_WIDGET_CAPTION].data = STR_GROUP_SHIPS_CAPTION;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   377
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = (g->replace_protection) ? SPR_GROUP_REPLACE_ON_SHIP : SPR_GROUP_REPLACE_OFF_SHIP;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   378
					break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   379
				case VEH_AIRCRAFT:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   380
					this->widget[GRP_WIDGET_CAPTION].data = STR_GROUP_AIRCRAFTS_CAPTION;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   381
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = (g->replace_protection) ? SPR_GROUP_REPLACE_ON_AIRCRAFT : SPR_GROUP_REPLACE_OFF_AIRCRAFT;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   382
					break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   383
				default: NOT_REACHED();
7139
4ae3ab180d05 (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
   384
			}
4ae3ab180d05 (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
   385
		}
4ae3ab180d05 (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
   386
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   387
		/* Set text of sort by dropdown */
11031
ff45fd174578 (svn r13587) -Codechange: make some globals members of VehicleListBase since they are used as such
skidd13
parents: 10980
diff changeset
   388
		this->widget[GRP_WIDGET_SORT_BY_DROPDOWN].data = this->vehicle_sorter_names[this->vehicles.SortType()];
7139
4ae3ab180d05 (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
10595
7957c71b0dfe (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 10534
diff changeset
   390
		this->DrawWidgets();
7754
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   391
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   392
		/* Draw Matrix Group
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   393
			* The selected group is drawn in white */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   394
		StringID str_all_veh, str_no_group_veh;
7139
4ae3ab180d05 (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
   395
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   396
		switch (this->vehicle_type) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   397
			case VEH_TRAIN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   398
				str_all_veh = STR_GROUP_ALL_TRAINS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   399
				str_no_group_veh = STR_GROUP_DEFAULT_TRAINS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   400
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   401
			case VEH_ROAD:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   402
				str_all_veh = STR_GROUP_ALL_ROADS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   403
				str_no_group_veh = STR_GROUP_DEFAULT_ROADS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   404
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   405
			case VEH_SHIP:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   406
				str_all_veh = STR_GROUP_ALL_SHIPS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   407
				str_no_group_veh = STR_GROUP_DEFAULT_SHIPS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   408
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   409
			case VEH_AIRCRAFT:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   410
				str_all_veh = STR_GROUP_ALL_AIRCRAFTS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   411
				str_no_group_veh = STR_GROUP_DEFAULT_AIRCRAFTS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   412
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   413
			default: NOT_REACHED();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   414
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   415
		DrawString(10, y1, str_all_veh, IsAllGroupID(this->group_sel) ? TC_WHITE : TC_BLACK);
7139
4ae3ab180d05 (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
   416
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   417
		y1 += 13;
7139
4ae3ab180d05 (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
   418
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   419
		DrawString(10, y1, str_no_group_veh, IsDefaultGroupID(this->group_sel) ? TC_WHITE : TC_BLACK);
7139
4ae3ab180d05 (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
   420
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   421
		max = min(this->vscroll.pos + this->vscroll.cap, this->groups.Length());
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   422
		for (i = this->vscroll.pos ; i < max ; ++i) {
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   423
			const Group *g = this->groups[i];
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   424
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   425
			assert(g->owner == owner);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   426
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   427
			y1 += PLY_WND_PRC__SIZE_OF_ROW_TINY;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   428
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   429
			/* draw the selected group in white, else we draw it in black */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   430
			SetDParam(0, g->index);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   431
			DrawString(10, y1, STR_GROUP_NAME, (this->group_sel == g->index) ? TC_WHITE : TC_BLACK);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   432
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   433
			/* draw the number of vehicles of the group */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   434
			SetDParam(0, g->num_vehicle);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   435
			DrawStringRightAligned(187, y1 + 1, STR_GROUP_TINY_NUM, (this->group_sel == g->index) ? TC_WHITE : TC_BLACK);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   436
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   437
10980
5281330a77da (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 10769
diff changeset
   438
		this->DrawSortButtonState(GRP_WIDGET_SORT_BY_ORDER, this->vehicles.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   439
10769
a005e45d1f09 (svn r13319) -Codechange: Remove use of imaginary horizontal scrollbar in the group vehicle list
peter1138
parents: 10730
diff changeset
   440
		int list_width = this->widget[GRP_WIDGET_LIST_VEHICLE].right - this->widget[GRP_WIDGET_LIST_VEHICLE].left - 20;
a005e45d1f09 (svn r13319) -Codechange: Remove use of imaginary horizontal scrollbar in the group vehicle list
peter1138
parents: 10730
diff changeset
   441
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   442
		/* Draw Matrix Vehicle according to the vehicle list built before */
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   443
		max = min(this->vscroll2.pos + this->vscroll2.cap, this->vehicles.Length());
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   444
		for (i = this->vscroll2.pos ; i < max ; ++i) {
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   445
			const Vehicle* v = this->vehicles[i];
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   446
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   447
			assert(v->type == this->vehicle_type && v->owner == owner);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   448
10769
a005e45d1f09 (svn r13319) -Codechange: Remove use of imaginary horizontal scrollbar in the group vehicle list
peter1138
parents: 10730
diff changeset
   449
			DrawVehicleImage(v, x + 19, y2 + 6, this->vehicle_sel, list_width, 0);
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   450
			DrawVehicleProfitButton(v, x, y2 + 13);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   451
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   452
			SetDParam(0, v->unitnumber);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   453
			DrawString(x, y2 + 2, v->IsInDepot() ? STR_021F : (v->age > v->max_age - 366 ? STR_00E3 : STR_00E2), TC_FROMSTRING);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   454
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   455
			if (this->resize.step_height == PLY_WND_PRC__SIZE_OF_ROW_BIG2) DrawSmallOrderList(v, x + 138, y2);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   456
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   457
			SetDParam(0, v->GetDisplayProfitThisYear());
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   458
			SetDParam(1, v->GetDisplayProfitLastYear());
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   459
			DrawString(x + 19, y2 + this->resize.step_height - 8, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, TC_FROMSTRING);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   460
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   461
			if (IsValidGroupID(v->group_id)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   462
				SetDParam(0, v->group_id);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   463
				DrawString(x + 19, y2, STR_GROUP_TINY_NAME, TC_BLACK);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   464
			}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   465
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   466
			y2 += this->resize.step_height;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   467
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   468
	}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   469
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   470
	virtual void OnClick(Point pt, int widget)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   471
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   472
		if (widget != GRP_WIDGET_SORT_BY_DROPDOWN && widget != GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN) HideDropDownMenu(this);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   473
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   474
		switch(widget) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   475
			case GRP_WIDGET_SORT_BY_ORDER: // Flip sorting method ascending/descending
10980
5281330a77da (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 10769
diff changeset
   476
				this->vehicles.ToggleSortOrder();
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   477
				this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   478
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   479
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   480
			case GRP_WIDGET_SORT_BY_DROPDOWN: // Select sorting criteria dropdown menu
11031
ff45fd174578 (svn r13587) -Codechange: make some globals members of VehicleListBase since they are used as such
skidd13
parents: 10980
diff changeset
   481
				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));
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   482
				return;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   483
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   484
			case GRP_WIDGET_ALL_VEHICLES: // All vehicles button
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   485
				if (!IsAllGroupID(this->group_sel)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   486
					this->group_sel = ALL_GROUP;
10980
5281330a77da (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 10769
diff changeset
   487
					this->vehicles.ForceRebuild();
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   488
					this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   489
				}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   490
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   491
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   492
			case GRP_WIDGET_DEFAULT_VEHICLES: // Ungrouped vehicles button
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   493
				if (!IsDefaultGroupID(this->group_sel)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   494
					this->group_sel = DEFAULT_GROUP;
10980
5281330a77da (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 10769
diff changeset
   495
					this->vehicles.ForceRebuild();
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   496
					this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   497
				}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   498
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   499
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   500
			case GRP_WIDGET_LIST_GROUP: { // Matrix Group
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   501
				uint16 id_g = (pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET - 26) / PLY_WND_PRC__SIZE_OF_ROW_TINY;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   502
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   503
				if (id_g >= this->vscroll.cap) return;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   504
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   505
				id_g += this->vscroll.pos;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   506
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   507
				if (id_g >= this->groups.Length()) return;
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   508
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   509
				this->group_sel = this->groups[id_g]->index;;
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   510
10980
5281330a77da (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 10769
diff changeset
   511
				this->vehicles.ForceRebuild();
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   512
				this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   513
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   514
			}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   515
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   516
			case GRP_WIDGET_LIST_VEHICLE: { // Matrix Vehicle
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   517
				uint32 id_v = (pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / (int)this->resize.step_height;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   518
				const Vehicle *v;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   519
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   520
				if (id_v >= this->vscroll2.cap) return; // click out of bounds
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   521
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   522
				id_v += this->vscroll2.pos;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   523
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   524
				if (id_v >= this->vehicles.Length()) return; // click out of list bound
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   525
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   526
				v = this->vehicles[id_v];
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   527
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   528
				this->vehicle_sel = v->index;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   529
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   530
				if (v->IsValid()) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   531
					SetObjectToPlaceWnd(v->GetImage(DIR_W), GetVehiclePalette(v), VHM_DRAG, this);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   532
					_cursor.vehchain = true;
7139
4ae3ab180d05 (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
   533
				}
4ae3ab180d05 (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
   534
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   535
				this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   536
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   537
			}
7139
4ae3ab180d05 (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
   538
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   539
			case GRP_WIDGET_CREATE_GROUP: // Create a new group
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   540
				DoCommandP(0, this->vehicle_type, 0, NULL, CMD_CREATE_GROUP | CMD_MSG(STR_GROUP_CAN_T_CREATE));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   541
				break;
7163
09e65bfbc08b (svn r9898) -Fix (r9874): Many...
peter1138
parents: 7156
diff changeset
   542
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   543
			case GRP_WIDGET_DELETE_GROUP: { // Delete the selected group
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   544
				GroupID group = this->group_sel;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   545
				this->group_sel = ALL_GROUP;
7139
4ae3ab180d05 (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
   546
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   547
				DoCommandP(0, group, 0, NULL, CMD_DELETE_GROUP | CMD_MSG(STR_GROUP_CAN_T_DELETE));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   548
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   549
			}
7139
4ae3ab180d05 (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
   550
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   551
			case GRP_WIDGET_RENAME_GROUP: { // Rename the selected roup
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   552
				assert(IsValidGroupID(this->group_sel));
7139
4ae3ab180d05 (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
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   554
				const Group *g = GetGroup(this->group_sel);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   555
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   556
				SetDParam(0, g->index);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   557
				ShowQueryString(STR_GROUP_NAME, STR_GROUP_RENAME_CAPTION, 31, 150, this, CS_ALPHANUMERAL);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   558
			} break;
7139
4ae3ab180d05 (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
   559
4ae3ab180d05 (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
   560
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   561
			case GRP_WIDGET_AVAILABLE_VEHICLES:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   562
				ShowBuildVehicleWindow(0, this->vehicle_type);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   563
				break;
7139
4ae3ab180d05 (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
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   565
			case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   566
				ShowGroupActionDropdown(this, this->group_sel);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   567
				break;
7139
4ae3ab180d05 (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
   568
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   569
			case GRP_WIDGET_START_ALL:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   570
			case GRP_WIDGET_STOP_ALL: { // Start/stop all vehicles of the list
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   571
				DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   572
													| (1 << 6)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   573
													| (widget == GRP_WIDGET_START_ALL ? (1 << 5) : 0)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   574
													| this->vehicle_type, NULL, CMD_MASS_START_STOP);
7139
4ae3ab180d05 (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
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   576
				break;
7139
4ae3ab180d05 (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
   577
			}
4ae3ab180d05 (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
   578
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   579
			case GRP_WIDGET_REPLACE_PROTECTION:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   580
				if (IsValidGroupID(this->group_sel)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   581
					const Group *g = GetGroup(this->group_sel);
7139
4ae3ab180d05 (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
   582
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   583
					DoCommandP(0, this->group_sel, !g->replace_protection, NULL, CMD_SET_GROUP_REPLACE_PROTECTION);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   584
				}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   585
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   586
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   587
	}
7139
4ae3ab180d05 (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
   588
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   589
	virtual void OnDragDrop(Point pt, int widget)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   590
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   591
		switch (widget) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   592
			case GRP_WIDGET_ALL_VEHICLES: // All vehicles
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   593
			case GRP_WIDGET_DEFAULT_VEHICLES: // Ungrouped vehicles
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   594
				DoCommandP(0, DEFAULT_GROUP, this->vehicle_sel, NULL, CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_GROUP_CAN_T_ADD_VEHICLE));
7139
4ae3ab180d05 (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
   595
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   596
				this->vehicle_sel = INVALID_VEHICLE;
7139
4ae3ab180d05 (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
   597
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   598
				this->SetDirty();
7139
4ae3ab180d05 (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
   599
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   600
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   601
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   602
			case GRP_WIDGET_LIST_GROUP: { // Maxtrix group
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   603
				uint16 id_g = (pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET - 26) / PLY_WND_PRC__SIZE_OF_ROW_TINY;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   604
				const VehicleID vindex = this->vehicle_sel;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   605
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   606
				this->vehicle_sel = INVALID_VEHICLE;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   607
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   608
				this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   609
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   610
				if (id_g >= this->vscroll.cap) return;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   611
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   612
				id_g += this->vscroll.pos;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   613
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   614
				if (id_g >= this->groups.Length()) return;
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   615
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   616
				DoCommandP(0, this->groups[id_g]->index, vindex, NULL, CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_GROUP_CAN_T_ADD_VEHICLE));
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   617
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   618
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   619
			}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   620
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   621
			case GRP_WIDGET_LIST_VEHICLE: { // Maxtrix vehicle
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   622
				uint32 id_v = (pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / (int)this->resize.step_height;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   623
				const Vehicle *v;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   624
				const VehicleID vindex = this->vehicle_sel;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   625
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   626
				this->vehicle_sel = INVALID_VEHICLE;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   627
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   628
				this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   629
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   630
				if (id_v >= this->vscroll2.cap) return; // click out of bounds
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   631
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   632
				id_v += this->vscroll2.pos;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   633
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   634
				if (id_v >= this->vehicles.Length()) return; // click out of list bound
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   635
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   636
				v = this->vehicles[id_v];
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   637
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   638
				if (vindex == v->index) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   639
					ShowVehicleViewWindow(v);
7139
4ae3ab180d05 (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
   640
				}
4ae3ab180d05 (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
   641
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   642
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   643
			}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   644
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   645
		_cursor.vehchain = false;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   646
	}
7139
4ae3ab180d05 (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
   647
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   648
	virtual void OnQueryTextFinished(char *str)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   649
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   650
		if (!StrEmpty(str)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   651
			_cmd_text = str;
7139
4ae3ab180d05 (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
   652
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   653
			DoCommandP(0, this->group_sel, 0, NULL, CMD_RENAME_GROUP | CMD_MSG(STR_GROUP_CAN_T_RENAME));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   654
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   655
	}
7139
4ae3ab180d05 (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
   656
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   657
	virtual void OnResize(Point new_size, Point delta)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   658
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   659
		this->vscroll.cap += delta.y / PLY_WND_PRC__SIZE_OF_ROW_TINY;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   660
		this->vscroll2.cap += delta.y / (int)this->resize.step_height;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   661
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   662
		this->widget[GRP_WIDGET_LIST_GROUP].data = (this->vscroll.cap << 8) + 1;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   663
		this->widget[GRP_WIDGET_LIST_VEHICLE].data = (this->vscroll2.cap << 8) + 1;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   664
	}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   665
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   666
	virtual void OnDropdownSelect(int widget, int index)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   667
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   668
		switch (widget) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   669
			case GRP_WIDGET_SORT_BY_DROPDOWN:
10980
5281330a77da (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 10769
diff changeset
   670
				this->vehicles.SetSortType(index);
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   671
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   672
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   673
			case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN:
10716
2406d1520245 (svn r13266) -Codechange: Use SmallVector in GUIList
peter1138
parents: 10641
diff changeset
   674
				assert(this->vehicles.Length() != 0);
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   675
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   676
				switch (index) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   677
					case GALF_REPLACE: // Replace window
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   678
						ShowReplaceGroupVehicleWindow(this->group_sel, this->vehicle_type);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   679
						break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   680
					case GALF_SERVICE: // Send for servicing
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   681
						DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   682
									| DEPOT_MASS_SEND
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   683
									| DEPOT_SERVICE, NULL, GetCmdSendToDepot(this->vehicle_type));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   684
						break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   685
					case GALF_DEPOT: // Send to Depots
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   686
						DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   687
									| DEPOT_MASS_SEND, NULL, GetCmdSendToDepot(this->vehicle_type));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   688
						break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   689
					case GALF_ADD_SHARED: // Add shared Vehicles
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   690
						assert(IsValidGroupID(this->group_sel));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   691
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   692
						DoCommandP(0, this->group_sel, this->vehicle_type, NULL, CMD_ADD_SHARED_VEHICLE_GROUP | CMD_MSG(STR_GROUP_CAN_T_ADD_SHARED_VEHICLE));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   693
						break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   694
					case GALF_REMOVE_ALL: // Remove all Vehicles from the selected group
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   695
						assert(IsValidGroupID(this->group_sel));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   696
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   697
						DoCommandP(0, this->group_sel, this->vehicle_type, NULL, CMD_REMOVE_ALL_VEHICLES_GROUP | CMD_MSG(STR_GROUP_CAN_T_REMOVE_ALL_VEHICLES));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   698
						break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   699
					default: NOT_REACHED();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   700
				}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   701
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   702
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   703
			default: NOT_REACHED();
7139
4ae3ab180d05 (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
		}
4ae3ab180d05 (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
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   706
		this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   707
	}
7139
4ae3ab180d05 (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
   708
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   709
	virtual void OnTick()
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   710
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   711
		if (_pause_game != 0) return;
10980
5281330a77da (svn r13534) -Codechange: Replace the main part of VehiclesListBase sorting with GUIList function calls
skidd13
parents: 10769
diff changeset
   712
		if (this->groups.NeedResort() || this->vehicles.NeedResort()) {
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   713
			this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   714
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   715
	}
7139
4ae3ab180d05 (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
   716
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   717
	virtual void OnPlaceObjectAbort()
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   718
	{
9081
4c47047836f3 (svn r12166) -Fix [FS#337]: when drag&drop mode was cancelled by keyboard input, depot/group window wasn't updated (original patch by GrimRC)
smatz
parents: 9052
diff changeset
   719
			/* abort drag & drop */
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   720
			this->vehicle_sel = INVALID_VEHICLE;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   721
			this->InvalidateWidget(GRP_WIDGET_LIST_VEHICLE);
8675
5ff307aa5048 (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: 8640
diff changeset
   722
	}
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   723
};
7139
4ae3ab180d05 (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
   724
4ae3ab180d05 (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
   725
4ae3ab180d05 (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
   726
static const WindowDesc _group_desc = {
7843
ec16ba9480c5 (svn r10710) -Codechange: allow automatic downsizing of the group window. Same as idea as for the previous commits, i.e. you could already do so but the button would be out of reach.
rubidium
parents: 7837
diff changeset
   727
	WDP_AUTO, WDP_AUTO, 460, 194, 526, 246,
7139
4ae3ab180d05 (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
   728
	WC_TRAINS_LIST, WC_NONE,
4ae3ab180d05 (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
   729
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
4ae3ab180d05 (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
   730
	_group_widgets,
4ae3ab180d05 (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
   731
};
4ae3ab180d05 (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
   732
4ae3ab180d05 (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
   733
void ShowPlayerGroup(PlayerID player, VehicleType vehicle_type)
4ae3ab180d05 (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
   734
{
11161
7d0fac8f14cd (svn r13719) -Codechange: rename IsValidPlayer to IsValidPlayerID in line with all other structs/classes that are in a pool.
rubidium
parents: 11031
diff changeset
   735
	if (!IsValidPlayerID(player)) return;
7903
a951b023d97e (svn r10780) -Fix: assertion when opening the advanced vehicle list with the shortcut when being a spectator.
rubidium
parents: 7883
diff changeset
   736
7139
4ae3ab180d05 (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
   737
	WindowClass wc;
4ae3ab180d05 (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
   738
4ae3ab180d05 (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
   739
	switch (vehicle_type) {
4ae3ab180d05 (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
   740
		default: NOT_REACHED();
4ae3ab180d05 (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
   741
		case VEH_TRAIN:    wc = WC_TRAINS_LIST;   break;
4ae3ab180d05 (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
   742
		case VEH_ROAD:     wc = WC_ROADVEH_LIST;  break;
4ae3ab180d05 (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
   743
		case VEH_SHIP:     wc = WC_SHIPS_LIST;    break;
4ae3ab180d05 (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
   744
		case VEH_AIRCRAFT: wc = WC_AIRCRAFT_LIST; break;
4ae3ab180d05 (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
   745
	}
4ae3ab180d05 (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
   746
4ae3ab180d05 (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
   747
	WindowNumber num = (vehicle_type << 11) | VLW_GROUP_LIST | player;
4ae3ab180d05 (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
   748
	DeleteWindowById(wc, num);
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   749
	Window *w = new VehicleGroupWindow(&_group_desc, num);
7139
4ae3ab180d05 (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
   750
	w->window_class = wc;
4ae3ab180d05 (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
   751
}