src/group_gui.cpp
author rubidium
Tue, 13 May 2008 14:43:33 +0000
changeset 10525 da5bc725cda4
parent 10503 f7032c1220d9
child 10534 da1bea97f733
permissions -rw-r--r--
(svn r13069) -Codechange: it is no longer needed to pass a void *data pointer with the WE_CREATE message because nothing uses it anymore.
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
10502
996d9308d650 (svn r13045) -Codechange: make list_d (now GUIList) more generic and uniform.
rubidium
parents: 10462
diff changeset
    33
static void BuildGroupList(GUIGroupList *gl, PlayerID owner, VehicleType vehicle_type)
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
    34
{
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
	uint n = 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
    36
10502
996d9308d650 (svn r13045) -Codechange: make list_d (now GUIList) more generic and uniform.
rubidium
parents: 10462
diff changeset
    37
	if (!(gl->flags & VL_REBUILD)) return;
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
    38
10502
996d9308d650 (svn r13045) -Codechange: make list_d (now GUIList) more generic and uniform.
rubidium
parents: 10462
diff changeset
    39
	const Group **list = MallocT<const Group*>(GetGroupArraySize());
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
10502
996d9308d650 (svn r13045) -Codechange: make list_d (now GUIList) more generic and uniform.
rubidium
parents: 10462
diff changeset
    41
	const Group *g;
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
    42
	FOR_ALL_GROUPS(g) {
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
		if (g->owner == owner && g->vehicle_type == vehicle_type) list[n++] = g;
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
	}
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
10502
996d9308d650 (svn r13045) -Codechange: make list_d (now GUIList) more generic and uniform.
rubidium
parents: 10462
diff changeset
    46
	gl->sort_list = ReallocT(gl->sort_list, n);
996d9308d650 (svn r13045) -Codechange: make list_d (now GUIList) more generic and uniform.
rubidium
parents: 10462
diff changeset
    47
	gl->list_length = n;
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
    48
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
	for (uint i = 0; i < n; ++i) gl->sort_list[i] = list[i];
10502
996d9308d650 (svn r13045) -Codechange: make list_d (now GUIList) more generic and uniform.
rubidium
parents: 10462
diff changeset
    50
	free(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
    51
10502
996d9308d650 (svn r13045) -Codechange: make list_d (now GUIList) more generic and uniform.
rubidium
parents: 10462
diff changeset
    52
	gl->flags &= ~VL_REBUILD;
996d9308d650 (svn r13045) -Codechange: make list_d (now GUIList) more generic and uniform.
rubidium
parents: 10462
diff changeset
    53
	gl->flags |= VL_RESORT;
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
    54
}
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
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
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
static int CDECL GroupNameSorter(const void *a, const void *b)
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
{
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
	static const Group *last_group[2] = { NULL, NULL };
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
	static char         last_name[2][64] = { "", "" };
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
    61
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
    62
	const Group *ga = *(const Group**)a;
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
    63
	const Group *gb = *(const Group**)b;
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
    64
	int r;
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
    65
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
    66
	if (ga != last_group[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
    67
		last_group[0] = ga;
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
    68
		SetDParam(0, ga->index);
7547
d13aad2aabd9 (svn r10316) -Codechange: (consistently) use index to refer to group names. Also the group string_id is irrelevant unless it is a custom name, so don't 'waste' a savegame string id.
peter1138
parents: 7498
diff changeset
    69
		GetString(last_name[0], STR_GROUP_NAME, lastof(last_name[0]));
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
    70
	}
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
    71
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
    72
	if (gb != last_group[1]) {
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
    73
		last_group[1] = gb;
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
    74
		SetDParam(0, gb->index);
7547
d13aad2aabd9 (svn r10316) -Codechange: (consistently) use index to refer to group names. Also the group string_id is irrelevant unless it is a custom name, so don't 'waste' a savegame string id.
peter1138
parents: 7498
diff changeset
    75
		GetString(last_name[1], STR_GROUP_NAME, lastof(last_name[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
    76
	}
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
    77
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
    78
	r = strcmp(last_name[0], last_name[1]); // sort by name
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
    79
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
    80
	if (r == 0) return ga->index - gb->index;
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
    81
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
    82
	return r;
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
    83
}
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
    84
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
    85
10502
996d9308d650 (svn r13045) -Codechange: make list_d (now GUIList) more generic and uniform.
rubidium
parents: 10462
diff changeset
    86
static void SortGroupList(GUIGroupList *gl)
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
    87
{
10502
996d9308d650 (svn r13045) -Codechange: make list_d (now GUIList) more generic and uniform.
rubidium
parents: 10462
diff changeset
    88
	if (!(gl->flags & VL_RESORT)) return;
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
    89
10502
996d9308d650 (svn r13045) -Codechange: make list_d (now GUIList) more generic and uniform.
rubidium
parents: 10462
diff changeset
    90
	qsort((void*)gl->sort_list, gl->list_length, sizeof(gl->sort_list[0]), GroupNameSorter);
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
    91
10502
996d9308d650 (svn r13045) -Codechange: make list_d (now GUIList) more generic and uniform.
rubidium
parents: 10462
diff changeset
    92
	gl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
996d9308d650 (svn r13045) -Codechange: make list_d (now GUIList) more generic and uniform.
rubidium
parents: 10462
diff changeset
    93
	gl->flags &= ~VL_RESORT;
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
    94
}
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
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
    96
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
    97
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
    98
	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
    99
	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
   100
	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
   101
	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
   102
	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
   103
	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
   104
	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
   105
	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
   106
	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
   107
	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
   108
	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
   109
	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
   110
	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
   111
	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
   112
	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
   113
	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
   114
	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
   115
	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
   116
	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
   117
	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
   118
	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
   119
	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
   120
	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
   121
	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
   122
	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
   123
};
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
   124
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   125
enum GroupActionListFunction {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   126
	GALF_REPLACE,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   127
	GALF_SERVICE,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   128
	GALF_DEPOT,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   129
	GALF_ADD_SHARED,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   130
	GALF_REMOVE_ALL,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   131
};
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   132
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   133
/**
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   134
 * Update/redraw the group action dropdown
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   135
 * @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
   136
 * @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
   137
 */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   138
static void ShowGroupActionDropdown(Window *w, GroupID gid)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   139
{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   140
	DropDownList *list = new DropDownList();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   141
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   142
	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
   143
	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
   144
	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
   145
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   146
	if (IsValidGroupID(gid)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   147
		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
   148
		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
   149
	}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   150
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   151
	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
   152
}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   153
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
   154
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
   155
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
   156
{   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
   157
{    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
   158
{  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
   159
{      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
   160
{      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
   161
{      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
   162
{     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
   163
{  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
   164
{ 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
   165
{   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
   166
{      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
   167
{     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
   168
{ 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
   169
{ 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
   170
{ 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
   171
{ 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
   172
{      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
   173
{ 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
   174
{      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
   175
{ 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
   176
{   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
   177
{ 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
   178
{ 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
   179
{      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
   180
{  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
   181
{   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
   182
};
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
   183
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
   184
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   185
struct VehicleGroupWindow : public Window, public VehicleListBase {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   186
	GroupID group_sel;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   187
	VehicleID vehicle_sel;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   188
	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
   189
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
   190
	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
   191
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   192
		const PlayerID owner = (PlayerID)GB(this->window_number, 0, 8);
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
   193
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   194
		this->caption_color = owner;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   195
		this->hscroll.cap = 224;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   196
		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
   197
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   198
		switch (this->vehicle_type) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   199
			default: NOT_REACHED();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   200
			case VEH_TRAIN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   201
			case VEH_ROAD:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   202
				this->vscroll.cap = 9;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   203
				this->vscroll2.cap = 6;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   204
				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
   205
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   206
			case VEH_SHIP:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   207
			case VEH_AIRCRAFT:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   208
				this->vscroll.cap = 9;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   209
				this->vscroll2.cap = 4;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   210
				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
   211
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   212
		}
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
   213
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   214
		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
   215
		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
   216
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   217
		switch (this->vehicle_type) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   218
			default: NOT_REACHED();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   219
			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
   220
			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
   221
			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
   222
			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
   223
		}
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
   224
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   225
		this->vehicle_type = (VehicleType)GB(this->window_number, 11, 5);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   226
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   227
		this->vehicles.sort_list = NULL;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   228
		this->vehicles.sort_type = this->sorting->criteria;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   229
		this->vehicles.flags = VL_REBUILD | (this->sorting->order ? VL_DESC : VL_NONE);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   230
		this->vehicles.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer
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->groups.sort_list = NULL;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   233
		this->groups.flags = VL_REBUILD | VL_NONE;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   234
		this->groups.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   235
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   236
		this->group_sel = ALL_GROUP;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   237
		this->vehicle_sel = INVALID_VEHICLE;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   238
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   239
		switch (this->vehicle_type) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   240
			case VEH_TRAIN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   241
				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
   242
				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
   243
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   244
				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
   245
				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
   246
				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
   247
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   248
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   249
			case VEH_ROAD:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   250
				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
   251
				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
   252
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   253
				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
   254
				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
   255
				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
   256
				break;
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
			case VEH_SHIP:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   259
				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
   260
				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
   261
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   262
				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
   263
				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
   264
				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
   265
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   266
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   267
			case VEH_AIRCRAFT:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   268
				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
   269
				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
   270
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   271
				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
   272
				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
   273
				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
   274
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   275
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   276
			default: NOT_REACHED();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   277
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   278
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   279
		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
   280
	}
cf734ff178bf (svn r11880) -Codechange: Generate vehicle group action dropdown dynamically, and assign an enum for the function return codes.
peter1138
parents: 8810
diff changeset
   281
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   282
	~VehicleGroupWindow()
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   283
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   284
		free((void*)this->vehicles.sort_list);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   285
		free((void*)this->groups.sort_list);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   286
	}
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
   287
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   288
	virtual void OnInvalidateData(int data)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   289
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   290
		this->vehicles.flags |= VL_REBUILD;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   291
		this->groups.flags |= VL_REBUILD;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   292
		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
   293
			this->group_sel = ALL_GROUP;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   294
			HideDropDownMenu(this);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   295
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   296
		this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   297
	}
7163
09e65bfbc08b (svn r9898) -Fix (r9874): Many...
peter1138
parents: 7156
diff changeset
   298
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   299
	virtual void OnPaint()
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   300
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   301
		const PlayerID owner = (PlayerID)GB(this->window_number, 0, 8);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   302
		int x = 203;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   303
		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
   304
		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
   305
		int max;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   306
		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
   307
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   308
		/* 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
   309
			* 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
   310
		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
   311
		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
   312
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
   313
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   314
		BuildGroupList(&this->groups, owner, this->vehicle_type);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   315
		SortGroupList(&this->groups);
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
   316
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   317
		SetVScrollCount(this, this->groups.list_length);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   318
		SetVScroll2Count(this, this->vehicles.list_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
   319
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   320
		/* The drop down menu is out, *but* it may not be used, retract it. */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   321
		if (this->vehicles.list_length == 0 && this->IsWidgetLowered(GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   322
			this->RaiseWidget(GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   323
			HideDropDownMenu(this);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   324
		}
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
   325
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   326
		/* Disable all lists management button when the list is empty */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   327
		this->SetWidgetsDisabledState(this->vehicles.list_length == 0 || _local_player != owner,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   328
				GRP_WIDGET_STOP_ALL,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   329
				GRP_WIDGET_START_ALL,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   330
				GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   331
				WIDGET_LIST_END);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   332
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   333
		/* 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
   334
		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
   335
				GRP_WIDGET_DELETE_GROUP,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   336
				GRP_WIDGET_RENAME_GROUP,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   337
				GRP_WIDGET_REPLACE_PROTECTION,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   338
				WIDGET_LIST_END);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   339
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   340
		/* Disable remaining buttons for non-local player
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   341
			* 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
   342
			* 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
   343
			*  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
   344
			*  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
   345
			*/
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   346
		this->SetWidgetsDisabledState(_local_player != owner,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   347
				GRP_WIDGET_CREATE_GROUP,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   348
				GRP_WIDGET_AVAILABLE_VEHICLES,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   349
				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
   350
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
   351
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   352
		/* 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
   353
				We list all vehicles or ungrouped vehicles */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   354
		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
   355
			SetDParam(0, owner);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   356
			SetDParam(1, this->vehicles.list_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
   357
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   358
			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
   359
				case VEH_TRAIN:
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   360
					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
   361
					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
   362
					break;
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   363
				case VEH_ROAD:
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   364
					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
   365
					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
   366
					break;
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   367
				case VEH_SHIP:
10503
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_9805_SHIPS;
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 = 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
   370
					break;
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   371
				case VEH_AIRCRAFT:
10503
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_A009_AIRCRAFT;
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 = 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
   374
					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
   375
				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
   376
			}
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   377
		} else {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   378
			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
   379
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   380
			SetDParam(0, g->index);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   381
			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
   382
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   383
			switch (this->vehicle_type) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   384
				case VEH_TRAIN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   385
					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
   386
					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
   387
					break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   388
				case VEH_ROAD:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   389
					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
   390
					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
   391
					break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   392
				case VEH_SHIP:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   393
					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
   394
					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
   395
					break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   396
				case VEH_AIRCRAFT:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   397
					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
   398
					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
   399
					break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   400
				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
   401
			}
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
   402
		}
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
   403
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   404
		/* Set text of sort by dropdown */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   405
		this->widget[GRP_WIDGET_SORT_BY_DROPDOWN].data = _vehicle_sort_listing[this->vehicles.sort_type];
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
   406
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   407
		DrawWindowWidgets(this);
7754
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   408
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   409
		/* Draw Matrix Group
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   410
			* The selected group is drawn in white */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   411
		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
   412
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   413
		switch (this->vehicle_type) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   414
			case VEH_TRAIN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   415
				str_all_veh = STR_GROUP_ALL_TRAINS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   416
				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
   417
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   418
			case VEH_ROAD:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   419
				str_all_veh = STR_GROUP_ALL_ROADS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   420
				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
   421
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   422
			case VEH_SHIP:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   423
				str_all_veh = STR_GROUP_ALL_SHIPS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   424
				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
   425
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   426
			case VEH_AIRCRAFT:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   427
				str_all_veh = STR_GROUP_ALL_AIRCRAFTS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   428
				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
   429
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   430
			default: NOT_REACHED();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   431
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   432
		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
   433
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   434
		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
   435
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   436
		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
   437
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   438
		max = min(this->vscroll.pos + this->vscroll.cap, this->groups.list_length);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   439
		for (i = this->vscroll.pos ; i < max ; ++i) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   440
			const Group *g = this->groups.sort_list[i];
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   441
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   442
			assert(g->owner == owner);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   443
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   444
			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
   445
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   446
			/* 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
   447
			SetDParam(0, g->index);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   448
			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
   449
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   450
			/* 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
   451
			SetDParam(0, g->num_vehicle);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   452
			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
   453
		}
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
		DrawSortButtonState(this, GRP_WIDGET_SORT_BY_ORDER, this->vehicles.flags & VL_DESC ? SBS_DOWN : SBS_UP);
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
		/* Draw Matrix Vehicle according to the vehicle list built before */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   458
		max = min(this->vscroll2.pos + this->vscroll2.cap, this->vehicles.list_length);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   459
		for (i = this->vscroll2.pos ; i < max ; ++i) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   460
			const Vehicle* v = this->vehicles.sort_list[i];
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   461
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   462
			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
   463
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   464
			DrawVehicleImage(v, x + 19, y2 + 6, this->vehicle_sel, this->hscroll.cap, 0);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   465
			DrawVehicleProfitButton(v, x, y2 + 13);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   466
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   467
			SetDParam(0, v->unitnumber);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   468
			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
   469
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   470
			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
   471
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   472
			SetDParam(0, v->GetDisplayProfitThisYear());
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   473
			SetDParam(1, v->GetDisplayProfitLastYear());
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   474
			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
   475
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   476
			if (IsValidGroupID(v->group_id)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   477
				SetDParam(0, v->group_id);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   478
				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
   479
			}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   480
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   481
			y2 += this->resize.step_height;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   482
		}
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
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   485
	virtual void OnClick(Point pt, int widget)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   486
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   487
		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
   488
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   489
		switch(widget) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   490
			case GRP_WIDGET_SORT_BY_ORDER: // Flip sorting method ascending/descending
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   491
				this->vehicles.flags ^= VL_DESC;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   492
				this->vehicles.flags |= VL_RESORT;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   493
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   494
				this->sorting->order = !!(this->vehicles.flags & VL_DESC);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   495
				this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   496
				break;
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
			case GRP_WIDGET_SORT_BY_DROPDOWN: // Select sorting criteria dropdown menu
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   499
				ShowDropDownMenu(this, _vehicle_sort_listing, this->vehicles.sort_type,  GRP_WIDGET_SORT_BY_DROPDOWN, 0, (this->vehicle_type == VEH_TRAIN || this->vehicle_type == VEH_ROAD) ? 0 : (1 << 10));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   500
				return;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   501
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   502
			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
   503
				if (!IsAllGroupID(this->group_sel)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   504
					this->group_sel = ALL_GROUP;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   505
					this->vehicles.flags |= VL_REBUILD;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   506
					this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   507
				}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   508
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   509
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   510
			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
   511
				if (!IsDefaultGroupID(this->group_sel)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   512
					this->group_sel = DEFAULT_GROUP;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   513
					this->vehicles.flags |= VL_REBUILD;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   514
					this->SetDirty();
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
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   517
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   518
			case GRP_WIDGET_LIST_GROUP: { // Matrix Group
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   519
				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
   520
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   521
				if (id_g >= this->vscroll.cap) return;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   522
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   523
				id_g += this->vscroll.pos;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   524
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   525
				if (id_g >= this->groups.list_length) return;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   526
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   527
				this->group_sel = this->groups.sort_list[id_g]->index;;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   528
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   529
				this->vehicles.flags |= VL_REBUILD;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   530
				this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   531
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   532
			}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   533
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   534
			case GRP_WIDGET_LIST_VEHICLE: { // Matrix Vehicle
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   535
				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
   536
				const Vehicle *v;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   537
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   538
				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
   539
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   540
				id_v += this->vscroll2.pos;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   541
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   542
				if (id_v >= this->vehicles.list_length) return; // click out of list bound
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   543
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   544
				v = this->vehicles.sort_list[id_v];
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   545
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   546
				this->vehicle_sel = v->index;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   547
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   548
				if (v->IsValid()) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   549
					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
   550
					_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
   551
				}
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
   552
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   553
				this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   554
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   555
			}
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
   556
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   557
			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
   558
				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
   559
				break;
7163
09e65bfbc08b (svn r9898) -Fix (r9874): Many...
peter1138
parents: 7156
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_DELETE_GROUP: { // Delete the selected group
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   562
				GroupID group = this->group_sel;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   563
				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
   564
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   565
				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
   566
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   567
			}
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_RENAME_GROUP: { // Rename the selected roup
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   570
				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
   571
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   572
				const Group *g = GetGroup(this->group_sel);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   573
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   574
				SetDParam(0, g->index);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   575
				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
   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_AVAILABLE_VEHICLES:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   580
				ShowBuildVehicleWindow(0, this->vehicle_type);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   581
				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
   582
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   583
			case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   584
				ShowGroupActionDropdown(this, this->group_sel);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   585
				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
   586
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   587
			case GRP_WIDGET_START_ALL:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   588
			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
   589
				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
   590
													| (1 << 6)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   591
													| (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
   592
													| 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
   593
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   594
				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
   595
			}
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
   596
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   597
			case GRP_WIDGET_REPLACE_PROTECTION:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   598
				if (IsValidGroupID(this->group_sel)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   599
					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
   600
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   601
					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
   602
				}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   603
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   604
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   605
	}
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
   606
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   607
	virtual void OnDragDrop(Point pt, int widget)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   608
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   609
		switch (widget) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   610
			case GRP_WIDGET_ALL_VEHICLES: // All vehicles
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   611
			case GRP_WIDGET_DEFAULT_VEHICLES: // Ungrouped vehicles
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   612
				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
   613
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   614
				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
   615
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   616
				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
   617
10503
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
			case GRP_WIDGET_LIST_GROUP: { // Maxtrix group
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   621
				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
   622
				const VehicleID vindex = this->vehicle_sel;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   623
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   624
				this->vehicle_sel = INVALID_VEHICLE;
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->SetDirty();
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
				if (id_g >= this->vscroll.cap) return;
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
				id_g += this->vscroll.pos;
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
				if (id_g >= this->groups.list_length) return;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   633
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   634
				DoCommandP(0, this->groups.sort_list[id_g]->index, vindex, NULL, CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_GROUP_CAN_T_ADD_VEHICLE));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   635
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   636
				break;
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
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   639
			case GRP_WIDGET_LIST_VEHICLE: { // Maxtrix vehicle
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   640
				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
   641
				const Vehicle *v;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   642
				const VehicleID vindex = this->vehicle_sel;
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
				this->vehicle_sel = INVALID_VEHICLE;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   645
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   646
				this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   647
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   648
				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
   649
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   650
				id_v += this->vscroll2.pos;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   651
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   652
				if (id_v >= this->vehicles.list_length) return; // click out of list bound
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   653
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   654
				v = this->vehicles.sort_list[id_v];
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   655
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   656
				if (vindex == v->index) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   657
					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
   658
				}
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
   659
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   660
				break;
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
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   663
		_cursor.vehchain = false;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   664
	}
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
   665
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   666
	virtual void OnQueryTextFinished(char *str)
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
		if (!StrEmpty(str)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   669
			_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
   670
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   671
			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
   672
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   673
	}
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
   674
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   675
	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
   676
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   677
		this->hscroll.cap += delta.x;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   678
		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
   679
		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
   680
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   681
		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
   682
		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
   683
	}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   684
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   685
	virtual void OnDropdownSelect(int widget, int index)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   686
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   687
		switch (widget) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   688
			case GRP_WIDGET_SORT_BY_DROPDOWN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   689
				if (this->vehicles.sort_type != index) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   690
					this->vehicles.flags |= VL_RESORT;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   691
					this->vehicles.sort_type = index;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   692
					this->sorting->criteria = this->vehicles.sort_type;
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
   693
				}
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   694
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   695
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   696
			case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   697
				assert(this->vehicles.list_length != 0);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   698
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   699
				switch (index) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   700
					case GALF_REPLACE: // Replace window
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   701
						ShowReplaceGroupVehicleWindow(this->group_sel, this->vehicle_type);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   702
						break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   703
					case GALF_SERVICE: // Send for servicing
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   704
						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
   705
									| DEPOT_MASS_SEND
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   706
									| DEPOT_SERVICE, NULL, GetCmdSendToDepot(this->vehicle_type));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   707
						break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   708
					case GALF_DEPOT: // Send to Depots
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   709
						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
   710
									| 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
   711
						break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   712
					case GALF_ADD_SHARED: // Add shared Vehicles
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   713
						assert(IsValidGroupID(this->group_sel));
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
						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
   716
						break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   717
					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
   718
						assert(IsValidGroupID(this->group_sel));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   719
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   720
						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
   721
						break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   722
					default: NOT_REACHED();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   723
				}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   724
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   725
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   726
			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
   727
		}
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
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   729
		this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   730
	}
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
   731
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   732
	virtual void OnTick()
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   733
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   734
		if (_pause_game != 0) return;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   735
		if (--this->vehicles.resort_timer == 0) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   736
			this->vehicles.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   737
			this->vehicles.flags |= VL_RESORT;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   738
			this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   739
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   740
		if (--this->groups.resort_timer == 0) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   741
			this->groups.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   742
			this->groups.flags |= VL_RESORT;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   743
			this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   744
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   745
	}
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
   746
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   747
	virtual void OnPlaceObjectAbort()
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   748
	{
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
   749
			/* abort drag & drop */
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   750
			this->vehicle_sel = INVALID_VEHICLE;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   751
			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
   752
	}
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   753
};
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
   754
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
   755
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
   756
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
   757
	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
   758
	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
   759
	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
   760
	_group_widgets,
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   761
	NULL
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
   762
};
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
   763
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
   764
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
   765
{
7903
a951b023d97e (svn r10780) -Fix: assertion when opening the advanced vehicle list with the shortcut when being a spectator.
rubidium
parents: 7883
diff changeset
   766
	if (!IsValidPlayer(player)) return;
a951b023d97e (svn r10780) -Fix: assertion when opening the advanced vehicle list with the shortcut when being a spectator.
rubidium
parents: 7883
diff changeset
   767
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
   768
	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
   769
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
   770
	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
   771
		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
   772
		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
   773
		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
   774
		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
   775
		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
   776
	}
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
   777
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
   778
	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
   779
	DeleteWindowById(wc, num);
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   780
	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
   781
	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
   782
}