src/group_gui.cpp
author rubidium
Sat, 17 May 2008 12:48:06 +0000
changeset 10595 7957c71b0dfe
parent 10534 da1bea97f733
child 10621 3edd349d9c14
permissions -rw-r--r--
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
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);
10534
da1bea97f733 (svn r13078) -Fix: group gui used the vehicle type before it was actually set.
rubidium
parents: 10525
diff changeset
   193
		this->vehicle_type = (VehicleType)GB(this->window_number, 11, 5);
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   194
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   195
		this->caption_color = owner;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   196
		this->hscroll.cap = 224;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   197
		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
   198
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   199
		switch (this->vehicle_type) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   200
			default: NOT_REACHED();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   201
			case VEH_TRAIN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   202
			case VEH_ROAD:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   203
				this->vscroll.cap = 9;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   204
				this->vscroll2.cap = 6;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   205
				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
   206
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   207
			case VEH_SHIP:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   208
			case VEH_AIRCRAFT:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   209
				this->vscroll.cap = 9;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   210
				this->vscroll2.cap = 4;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   211
				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
   212
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   213
		}
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
   214
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   215
		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
   216
		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
   217
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   218
		switch (this->vehicle_type) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   219
			default: NOT_REACHED();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   220
			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
   221
			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
   222
			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
   223
			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
   224
		}
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
   225
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   226
		this->vehicles.sort_list = NULL;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   227
		this->vehicles.sort_type = this->sorting->criteria;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   228
		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
   229
		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
   230
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   231
		this->groups.sort_list = NULL;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   232
		this->groups.flags = VL_REBUILD | VL_NONE;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   233
		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
   234
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   235
		this->group_sel = ALL_GROUP;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   236
		this->vehicle_sel = INVALID_VEHICLE;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   237
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   238
		switch (this->vehicle_type) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   239
			case VEH_TRAIN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   240
				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
   241
				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
   242
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   243
				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
   244
				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
   245
				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
   246
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   247
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   248
			case VEH_ROAD:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   249
				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
   250
				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
   251
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   252
				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
   253
				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
   254
				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
   255
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   256
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   257
			case VEH_SHIP:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   258
				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
   259
				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
   260
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   261
				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
   262
				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
   263
				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
   264
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   265
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   266
			case VEH_AIRCRAFT:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   267
				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
   268
				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
   269
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   270
				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
   271
				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
   272
				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
   273
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   274
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   275
			default: NOT_REACHED();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   276
		}
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
		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
   279
	}
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
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   281
	~VehicleGroupWindow()
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   282
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   283
		free((void*)this->vehicles.sort_list);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   284
		free((void*)this->groups.sort_list);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   285
	}
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
   286
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   287
	virtual void OnInvalidateData(int data)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   288
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   289
		this->vehicles.flags |= VL_REBUILD;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   290
		this->groups.flags |= VL_REBUILD;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   291
		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
   292
			this->group_sel = ALL_GROUP;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   293
			HideDropDownMenu(this);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   294
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   295
		this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   296
	}
7163
09e65bfbc08b (svn r9898) -Fix (r9874): Many...
peter1138
parents: 7156
diff changeset
   297
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   298
	virtual void OnPaint()
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   299
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   300
		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
   301
		int x = 203;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   302
		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
   303
		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
   304
		int max;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   305
		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
   306
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   307
		/* 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
   308
			* 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
   309
		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
   310
		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
   311
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups 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
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   313
		BuildGroupList(&this->groups, owner, this->vehicle_type);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   314
		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
   315
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   316
		SetVScrollCount(this, this->groups.list_length);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   317
		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
   318
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   319
		/* 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
   320
		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
   321
			this->RaiseWidget(GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   322
			HideDropDownMenu(this);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   323
		}
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
   324
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   325
		/* 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
   326
		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
   327
				GRP_WIDGET_STOP_ALL,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   328
				GRP_WIDGET_START_ALL,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   329
				GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   330
				WIDGET_LIST_END);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   331
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   332
		/* 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
   333
		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
   334
				GRP_WIDGET_DELETE_GROUP,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   335
				GRP_WIDGET_RENAME_GROUP,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   336
				GRP_WIDGET_REPLACE_PROTECTION,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   337
				WIDGET_LIST_END);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   338
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   339
		/* Disable remaining buttons for non-local player
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   340
			* 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
   341
			* 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
   342
			*  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
   343
			*  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
   344
			*/
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   345
		this->SetWidgetsDisabledState(_local_player != owner,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   346
				GRP_WIDGET_CREATE_GROUP,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   347
				GRP_WIDGET_AVAILABLE_VEHICLES,
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   348
				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
   349
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
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   351
		/* 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
   352
				We list all vehicles or ungrouped vehicles */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   353
		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
   354
			SetDParam(0, owner);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   355
			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
   356
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   357
			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
   358
				case VEH_TRAIN:
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   359
					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
   360
					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
   361
					break;
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   362
				case VEH_ROAD:
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   363
					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
   364
					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
   365
					break;
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   366
				case VEH_SHIP:
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   367
					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
   368
					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
   369
					break;
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   370
				case VEH_AIRCRAFT:
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   371
					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
   372
					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
   373
					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
   374
				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
   375
			}
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   376
		} else {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   377
			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
   378
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   379
			SetDParam(0, g->index);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   380
			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
   381
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   382
			switch (this->vehicle_type) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   383
				case VEH_TRAIN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   384
					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
   385
					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
   386
					break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   387
				case VEH_ROAD:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   388
					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
   389
					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
   390
					break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   391
				case VEH_SHIP:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   392
					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
   393
					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
   394
					break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   395
				case VEH_AIRCRAFT:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   396
					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
   397
					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
   398
					break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   399
				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
   400
			}
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups 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
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   403
		/* Set text of sort by dropdown */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   404
		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
   405
10595
7957c71b0dfe (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 10534
diff changeset
   406
		this->DrawWidgets();
7754
8e7205edd6c7 (svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
rubidium
parents: 7630
diff changeset
   407
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   408
		/* Draw Matrix Group
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   409
			* The selected group is drawn in white */
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   410
		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
   411
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   412
		switch (this->vehicle_type) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   413
			case VEH_TRAIN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   414
				str_all_veh = STR_GROUP_ALL_TRAINS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   415
				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
   416
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   417
			case VEH_ROAD:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   418
				str_all_veh = STR_GROUP_ALL_ROADS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   419
				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
   420
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   421
			case VEH_SHIP:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   422
				str_all_veh = STR_GROUP_ALL_SHIPS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   423
				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
   424
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   425
			case VEH_AIRCRAFT:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   426
				str_all_veh = STR_GROUP_ALL_AIRCRAFTS;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   427
				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
   428
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   429
			default: NOT_REACHED();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   430
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   431
		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
   432
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   433
		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
   434
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   435
		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
   436
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   437
		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
   438
		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
   439
			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
   440
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   441
			assert(g->owner == owner);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   442
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   443
			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
   444
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   445
			/* 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
   446
			SetDParam(0, g->index);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   447
			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
   448
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   449
			/* 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
   450
			SetDParam(0, g->num_vehicle);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   451
			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
   452
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   453
10595
7957c71b0dfe (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 10534
diff changeset
   454
		this->DrawSortButtonState(GRP_WIDGET_SORT_BY_ORDER, this->vehicles.flags & VL_DESC ? SBS_DOWN : SBS_UP);
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   455
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   456
		/* 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
   457
		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
   458
		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
   459
			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
   460
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   461
			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
   462
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   463
			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
   464
			DrawVehicleProfitButton(v, x, y2 + 13);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   465
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   466
			SetDParam(0, v->unitnumber);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   467
			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
   468
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   469
			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
   470
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   471
			SetDParam(0, v->GetDisplayProfitThisYear());
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   472
			SetDParam(1, v->GetDisplayProfitLastYear());
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   473
			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
   474
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   475
			if (IsValidGroupID(v->group_id)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   476
				SetDParam(0, v->group_id);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   477
				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
   478
			}
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
			y2 += this->resize.step_height;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   481
		}
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
	virtual void OnClick(Point pt, int widget)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   485
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   486
		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
   487
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   488
		switch(widget) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   489
			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
   490
				this->vehicles.flags ^= VL_DESC;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   491
				this->vehicles.flags |= VL_RESORT;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   492
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   493
				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
   494
				this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   495
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   496
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   497
			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
   498
				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
   499
				return;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   500
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   501
			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
   502
				if (!IsAllGroupID(this->group_sel)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   503
					this->group_sel = ALL_GROUP;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   504
					this->vehicles.flags |= VL_REBUILD;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   505
					this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   506
				}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   507
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   508
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   509
			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
   510
				if (!IsDefaultGroupID(this->group_sel)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   511
					this->group_sel = DEFAULT_GROUP;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   512
					this->vehicles.flags |= VL_REBUILD;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   513
					this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   514
				}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   515
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   516
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   517
			case GRP_WIDGET_LIST_GROUP: { // Matrix Group
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   518
				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
   519
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   520
				if (id_g >= this->vscroll.cap) return;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   521
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   522
				id_g += this->vscroll.pos;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   523
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   524
				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
   525
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   526
				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
   527
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   528
				this->vehicles.flags |= VL_REBUILD;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   529
				this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   530
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   531
			}
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
			case GRP_WIDGET_LIST_VEHICLE: { // Matrix Vehicle
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   534
				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
   535
				const Vehicle *v;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   536
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   537
				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
   538
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   539
				id_v += this->vscroll2.pos;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   540
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   541
				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
   542
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   543
				v = this->vehicles.sort_list[id_v];
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   544
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   545
				this->vehicle_sel = v->index;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   546
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   547
				if (v->IsValid()) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   548
					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
   549
					_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
   550
				}
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups 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
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   552
				this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   553
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   554
			}
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
   555
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   556
			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
   557
				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
   558
				break;
7163
09e65bfbc08b (svn r9898) -Fix (r9874): Many...
peter1138
parents: 7156
diff changeset
   559
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   560
			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
   561
				GroupID group = this->group_sel;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   562
				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
   563
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   564
				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
   565
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   566
			}
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
   567
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   568
			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
   569
				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
   570
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   571
				const Group *g = GetGroup(this->group_sel);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   572
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   573
				SetDParam(0, g->index);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   574
				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
   575
			} 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
   576
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups 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
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   578
			case GRP_WIDGET_AVAILABLE_VEHICLES:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   579
				ShowBuildVehicleWindow(0, this->vehicle_type);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   580
				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
   581
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   582
			case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   583
				ShowGroupActionDropdown(this, this->group_sel);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   584
				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
   585
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   586
			case GRP_WIDGET_START_ALL:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   587
			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
   588
				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
   589
													| (1 << 6)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   590
													| (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
   591
													| 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
   592
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   593
				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
   594
			}
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
diff changeset
   595
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   596
			case GRP_WIDGET_REPLACE_PROTECTION:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   597
				if (IsValidGroupID(this->group_sel)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   598
					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
   599
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   600
					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
   601
				}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   602
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   603
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   604
	}
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
   605
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   606
	virtual void OnDragDrop(Point pt, int widget)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   607
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   608
		switch (widget) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   609
			case GRP_WIDGET_ALL_VEHICLES: // All vehicles
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   610
			case GRP_WIDGET_DEFAULT_VEHICLES: // Ungrouped vehicles
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   611
				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
   612
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   613
				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
   614
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   615
				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
   616
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   617
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   618
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   619
			case GRP_WIDGET_LIST_GROUP: { // Maxtrix group
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   620
				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
   621
				const VehicleID vindex = this->vehicle_sel;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   622
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   623
				this->vehicle_sel = INVALID_VEHICLE;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   624
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   625
				this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   626
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   627
				if (id_g >= this->vscroll.cap) return;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   628
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   629
				id_g += this->vscroll.pos;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   630
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   631
				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
   632
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   633
				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
   634
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   635
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   636
			}
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
			case GRP_WIDGET_LIST_VEHICLE: { // Maxtrix vehicle
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   639
				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
   640
				const Vehicle *v;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   641
				const VehicleID vindex = this->vehicle_sel;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   642
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   643
				this->vehicle_sel = INVALID_VEHICLE;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   644
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   645
				this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   646
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   647
				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
   648
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   649
				id_v += this->vscroll2.pos;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   650
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   651
				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
   652
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   653
				v = this->vehicles.sort_list[id_v];
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   654
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   655
				if (vindex == v->index) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   656
					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
   657
				}
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups 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
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   659
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   660
			}
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
		_cursor.vehchain = false;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   663
	}
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
   664
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   665
	virtual void OnQueryTextFinished(char *str)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   666
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   667
		if (!StrEmpty(str)) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   668
			_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
   669
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   670
			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
   671
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   672
	}
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
   673
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   674
	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
   675
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   676
		this->hscroll.cap += delta.x;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   677
		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
   678
		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
   679
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   680
		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
   681
		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
   682
	}
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
	virtual void OnDropdownSelect(int widget, int index)
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   685
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   686
		switch (widget) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   687
			case GRP_WIDGET_SORT_BY_DROPDOWN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   688
				if (this->vehicles.sort_type != index) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   689
					this->vehicles.flags |= VL_RESORT;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   690
					this->vehicles.sort_type = index;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   691
					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
   692
				}
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   693
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   694
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   695
			case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN:
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   696
				assert(this->vehicles.list_length != 0);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   697
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   698
				switch (index) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   699
					case GALF_REPLACE: // Replace window
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   700
						ShowReplaceGroupVehicleWindow(this->group_sel, this->vehicle_type);
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   701
						break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   702
					case GALF_SERVICE: // Send for servicing
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   703
						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
   704
									| DEPOT_MASS_SEND
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   705
									| DEPOT_SERVICE, NULL, GetCmdSendToDepot(this->vehicle_type));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   706
						break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   707
					case GALF_DEPOT: // Send to Depots
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   708
						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
   709
									| 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
   710
						break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   711
					case GALF_ADD_SHARED: // Add shared Vehicles
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   712
						assert(IsValidGroupID(this->group_sel));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   713
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   714
						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
   715
						break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   716
					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
   717
						assert(IsValidGroupID(this->group_sel));
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   718
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   719
						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
   720
						break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   721
					default: NOT_REACHED();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   722
				}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   723
				break;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   724
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   725
			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
   726
		}
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups 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
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   728
		this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   729
	}
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
   730
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   731
	virtual void OnTick()
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   732
	{
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   733
		if (_pause_game != 0) return;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   734
		if (--this->vehicles.resort_timer == 0) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   735
			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
   736
			this->vehicles.flags |= VL_RESORT;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   737
			this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   738
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   739
		if (--this->groups.resort_timer == 0) {
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   740
			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
   741
			this->groups.flags |= VL_RESORT;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   742
			this->SetDirty();
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   743
		}
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   744
	}
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
   745
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   746
	virtual void OnPlaceObjectAbort()
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   747
	{
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
   748
			/* abort drag & drop */
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   749
			this->vehicle_sel = INVALID_VEHICLE;
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   750
			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
   751
	}
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   752
};
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
   753
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups 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
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
   756
	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
   757
	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
   758
	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
   759
	_group_widgets,
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   760
	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
   761
};
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups 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
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
   764
{
7903
a951b023d97e (svn r10780) -Fix: assertion when opening the advanced vehicle list with the shortcut when being a spectator.
rubidium
parents: 7883
diff changeset
   765
	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
   766
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
   767
	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
   768
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups 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
	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
   770
		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
   771
		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
   772
		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
   773
		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
   774
		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
   775
	}
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups 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
	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
   778
	DeleteWindowById(wc, num);
10503
f7032c1220d9 (svn r13046) -Codechange: make classes of the VehicleListWindow and the VehicleGroupWindow.
rubidium
parents: 10502
diff changeset
   779
	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
   780
	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
   781
}