annotate src/company_gui.cpp @ 11494:6af9e6523c41 draft

(svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
author glx <glx@openttd.org>
date Thu, 26 Mar 2009 02:02:11 +0000
parents 4557701373cc
children 9272c49b41d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1 /* $Id$ */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
2
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
3 /** @file company_gui.cpp Company related GUIs. */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
4
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
5 #include "stdafx.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
6 #include "gui.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
7 #include "window_gui.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
8 #include "textbuf_gui.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
9 #include "viewport_func.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
10 #include "gfx_func.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
11 #include "company_func.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
12 #include "command_func.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
13 #include "network/network.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
14 #include "network/network_gui.h"
10907
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
15 #include "network/network_func.h"
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
16 #include "roadveh.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
17 #include "train.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
18 #include "aircraft.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
19 #include "newgrf.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
20 #include "company_manager_face.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
21 #include "strings_func.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
22 #include "date_func.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
23 #include "string_func.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
24 #include "widgets/dropdown_type.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
25 #include "tilehighlight_func.h"
10960
a4e5b5d2837c (svn r15299) -Cleanup: remove many redundant includes
smatz <smatz@openttd.org>
parents: 10912
diff changeset
26 #include "settings_type.h"
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
27
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
28 #include "table/strings.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
29
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
30 enum {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
31 FIRST_GUI_CALL = INT_MAX, ///< default value to specify thuis is the first call of the resizable gui
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
32 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
33
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
34 static void DoShowCompanyFinances(CompanyID company, bool show_small, bool show_stickied, int top = FIRST_GUI_CALL, int left = FIRST_GUI_CALL);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
35 static void DoSelectCompanyManagerFace(Window *parent, bool show_big, int top = FIRST_GUI_CALL, int left = FIRST_GUI_CALL);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
36
10962
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
37 /** Standard unsorted list of expenses. */
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
38 static ExpensesType _expenses_list_1[] = {
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
39 EXPENSES_CONSTRUCTION,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
40 EXPENSES_NEW_VEHICLES,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
41 EXPENSES_TRAIN_RUN,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
42 EXPENSES_ROADVEH_RUN,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
43 EXPENSES_AIRCRAFT_RUN,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
44 EXPENSES_SHIP_RUN,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
45 EXPENSES_PROPERTY,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
46 EXPENSES_TRAIN_INC,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
47 EXPENSES_ROADVEH_INC,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
48 EXPENSES_AIRCRAFT_INC,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
49 EXPENSES_SHIP_INC,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
50 EXPENSES_LOAN_INT,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
51 EXPENSES_OTHER,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
52 };
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
53
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
54 /** Grouped list of expenses. */
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
55 static ExpensesType _expenses_list_2[] = {
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
56 EXPENSES_TRAIN_INC,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
57 EXPENSES_ROADVEH_INC,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
58 EXPENSES_AIRCRAFT_INC,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
59 EXPENSES_SHIP_INC,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
60 INVALID_EXPENSES,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
61 EXPENSES_TRAIN_RUN,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
62 EXPENSES_ROADVEH_RUN,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
63 EXPENSES_AIRCRAFT_RUN,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
64 EXPENSES_SHIP_RUN,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
65 EXPENSES_PROPERTY,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
66 EXPENSES_LOAN_INT,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
67 INVALID_EXPENSES,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
68 EXPENSES_CONSTRUCTION,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
69 EXPENSES_NEW_VEHICLES,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
70 EXPENSES_OTHER,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
71 INVALID_EXPENSES,
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
72 };
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
73
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
74 /** Expense list container. */
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
75 struct ExpensesList {
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
76 const ExpensesType *et; ///< Expenses items.
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
77 const int length; ///< Number of items in list.
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
78 const int height; ///< Height of list, 10 pixels per item, plus an additional 12 pixels per subtotal. */
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
79 };
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
80
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
81 static const ExpensesList _expenses_list_types[] = {
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
82 { _expenses_list_1, lengthof(_expenses_list_1), lengthof(_expenses_list_1) * 10 },
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
83 { _expenses_list_2, lengthof(_expenses_list_2), lengthof(_expenses_list_2) * 10 + 3 * 12 },
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
84 };
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
85
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
86 static void DrawCompanyEconomyStats(const Company *c, bool small)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
87 {
10962
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
88 int type = _settings_client.gui.expenses_layout;
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
89 int x, y, i, j, year;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
90 const Money (*tbl)[EXPENSES_END];
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
91 StringID str;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
92
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
93 if (!small) { // normal sized economics window
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
94 /* draw categories */
11432
a20dd0000d96 (svn r15790) -Codechange: remove the *Centered part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11425
diff changeset
95 DrawString(0, 122, 15, STR_700F_EXPENDITURE_INCOME, TC_FROMSTRING, SA_CENTER, true);
10962
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
96
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
97 y = 27;
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
98 for (i = 0; i < _expenses_list_types[type].length; i++) {
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
99 ExpensesType et = _expenses_list_types[type].et[i];
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
100 if (et == INVALID_EXPENSES) {
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
101 y += 2;
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
102 DrawString(2, 111, y, STR_7020_TOTAL, TC_FROMSTRING, SA_RIGHT);
10962
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
103 y += 20;
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
104 } else {
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
105 DrawString(2, 111, y, STR_7011_CONSTRUCTION + et, TC_FROMSTRING);
10962
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
106 y += 10;
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
107 }
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
108 }
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
109
11433
07857d65c41a (svn r15791) -Codechange: remove the *RightAligned part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
110 DrawString(0, 111, y + 2, STR_7020_TOTAL, TC_FROMSTRING, SA_RIGHT);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
111
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
112 /* draw the price columns */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
113 year = _cur_year - 2;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
114 j = 3;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
115 x = 215;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
116 tbl = c->yearly_expenses + 2;
10962
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
117
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
118 do {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
119 if (year >= c->inaugurated_year) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
120 SetDParam(0, year);
11433
07857d65c41a (svn r15791) -Codechange: remove the *RightAligned part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
121 DrawString(x - 75, x, 15, STR_7010, TC_FROMSTRING, SA_RIGHT, true);
10962
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
122
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
123 Money sum = 0;
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
124 Money subtotal = 0;
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
125
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
126 int y = 27;
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
127
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
128 for (int i = 0; i < _expenses_list_types[type].length; i++) {
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
129 ExpensesType et = _expenses_list_types[type].et[i];
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
130 Money cost;
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
131
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
132 if (et == INVALID_EXPENSES) {
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
133 GfxFillRect(x - 75, y, x, y, 215);
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
134 cost = subtotal;
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
135 subtotal = 0;
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
136 y += 2;
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
137 } else {
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
138 cost = (*tbl)[et];
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
139 subtotal += cost;
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
140 sum += cost;
10962
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
141 }
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
142
10962
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
143 if (cost != 0 || et == INVALID_EXPENSES) {
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
144 str = STR_701E;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
145 if (cost < 0) { cost = -cost; str++; }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
146 SetDParam(0, cost);
11433
07857d65c41a (svn r15791) -Codechange: remove the *RightAligned part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
147 DrawString(x - 75, x, y, str, TC_FROMSTRING, SA_RIGHT);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
148 }
10962
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
149 y += (et == INVALID_EXPENSES) ? 20 : 10;
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
150 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
151
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
152 str = STR_701E;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
153 if (sum < 0) { sum = -sum; str++; }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
154 SetDParam(0, sum);
11433
07857d65c41a (svn r15791) -Codechange: remove the *RightAligned part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
155 DrawString(x - 75, x, y + 2, str, TC_FROMSTRING, SA_RIGHT);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
156
10962
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
157 GfxFillRect(x - 75, y, x, y, 215);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
158 x += 95;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
159 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
160 year++;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
161 tbl--;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
162 } while (--j != 0);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
163
10962
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
164 y += 14;
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
165
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
166 /* draw max loan aligned to loan below (y += 10) */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
167 SetDParam(0, _economy.max_loan);
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
168 DrawString(202, 406, y + 10, STR_MAX_LOAN, TC_FROMSTRING);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
169 } else {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
170 y = 15;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
171 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
172
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
173 DrawString(2, 182, y, STR_7026_BANK_BALANCE, TC_FROMSTRING);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
174 SetDParam(0, c->money);
11433
07857d65c41a (svn r15791) -Codechange: remove the *RightAligned part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
175 DrawString(182 - 75, 182, y, STR_7028, TC_FROMSTRING, SA_RIGHT);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
176
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
177 y += 10;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
178
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
179 DrawString(2, 182, y, STR_7027_LOAN, TC_FROMSTRING);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
180 SetDParam(0, c->current_loan);
11433
07857d65c41a (svn r15791) -Codechange: remove the *RightAligned part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
181 DrawString(182 - 75, 182, y, STR_7028, TC_FROMSTRING, SA_RIGHT);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
182
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
183 y += 12;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
184
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
185 GfxFillRect(182 - 75, y - 2, 182, y - 2, 215);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
186
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
187 SetDParam(0, c->money - c->current_loan);
11433
07857d65c41a (svn r15791) -Codechange: remove the *RightAligned part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
188 DrawString(182 - 75, 182, y, STR_7028, TC_FROMSTRING, SA_RIGHT);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
189 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
190
11494
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
191 /** Widgets of the company finances windows */
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
192 enum CompanyFinancesWindowWidgets {
11494
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
193 CFW_CLOSEBOX = 0, ///< Close the window
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
194 CFW_CAPTION, ///< Caption of the window
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
195 CFW_TOGGLE_SIZE, ///< Toggle windows size
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
196 CFW_STICKY, ///< Sticky button
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
197 CFW_EXPS_PANEL, ///< Panel for expenses
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
198 CFW_TOTAL_PANEL, ///< Panel for totals
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
199 CFW_INCREASE_LOAN, ///< Increase loan
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
200 CFW_REPAY_LOAN, ///< Decrease loan
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
201 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
202
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
203 static const Widget _company_finances_widgets[] = {
11494
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
204 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // CFW_CLOSEBOX
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
205 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 379, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS}, // CFW_CAPTION
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
206 { WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 380, 394, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, // CFW_TOGGLE_SIZE
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
207 { WWT_STICKYBOX, RESIZE_NONE, COLOUR_GREY, 395, 406, 0, 13, 0x0, STR_STICKY_BUTTON}, // CFW_STICKY
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
208 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 406, 14, 14, 0x0, STR_NULL}, // CFW_EXPS_PANEL
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
209 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 406, 14, 47, 0x0, STR_NULL}, // CFW_TOTAL_PANEL
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
210 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 202, 48, 59, STR_7029_BORROW, STR_7035_INCREASE_SIZE_OF_LOAN}, // CFW_INCREASE_LOAN
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
211 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 203, 406, 48, 59, STR_702A_REPAY, STR_7036_REPAY_PART_OF_LOAN}, // CFW_REPAY_LOAN
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
212 { WIDGETS_END},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
213 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
214
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
215 static const Widget _company_finances_small_widgets[] = {
11494
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
216 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // CFW_CLOSEBOX
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
217 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 253, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS}, // CFW_CAPTION
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
218 { WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 254, 267, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, // CFW_TOGGLE_SIZE
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
219 { WWT_STICKYBOX, RESIZE_NONE, COLOUR_GREY, 268, 279, 0, 13, 0x0, STR_STICKY_BUTTON}, // CFW_STICKY
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
220 { WWT_EMPTY, RESIZE_NONE, COLOUR_GREY, 0, 0, 0, 0, 0x0, STR_NULL}, // CFW_EXPS_PANEL
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
221 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 279, 14, 47, STR_NULL, STR_NULL}, // CFW_TOTAL_PANEL
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
222 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 139, 48, 59, STR_7029_BORROW, STR_7035_INCREASE_SIZE_OF_LOAN}, // CFW_INCREASE_LOAN
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
223 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 140, 279, 48, 59, STR_702A_REPAY, STR_7036_REPAY_PART_OF_LOAN}, // CFW_REPAY_LOAN
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
224 { WIDGETS_END},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
225 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
226
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
227 struct CompanyFinancesWindow : Window {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
228 bool small;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
229
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
230 CompanyFinancesWindow(const WindowDesc *desc, CompanyID company, bool show_small,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
231 bool show_stickied, int top, int left) :
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
232 Window(desc, company),
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
233 small(show_small)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
234 {
11084
e07c7d3925c8 (svn r15427) -Codechange: give w->caption_color a more sensible name as it holds the owner of whatever is shown in the window
rubidium <rubidium@openttd.org>
parents: 10998
diff changeset
235 this->owner = (Owner)this->window_number;
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
236
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
237 if (show_stickied) this->flags4 |= WF_STICKY;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
238
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
239 /* Check if repositioning from default is required */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
240 if (top != FIRST_GUI_CALL && left != FIRST_GUI_CALL) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
241 this->top = top;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
242 this->left = left;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
243 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
244
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
245 this->FindWindowPlacementAndResize(desc);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
246 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
247
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
248 virtual void OnPaint()
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
249 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
250 CompanyID company = (CompanyID)this->window_number;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
251 const Company *c = GetCompany(company);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
252
10962
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
253 if (!small) {
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
254 int type = _settings_client.gui.expenses_layout;
11494
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
255 int height = this->widget[CFW_EXPS_PANEL].bottom - this->widget[CFW_EXPS_PANEL].top + 1;
10962
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
256 if (_expenses_list_types[type].height + 26 != height) {
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
257 this->SetDirty();
11494
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
258 ResizeWindowForWidget(this, CFW_EXPS_PANEL, 0, _expenses_list_types[type].height - height + 26);
10962
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
259 this->SetDirty();
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
260 return;
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
261 }
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
262 }
bcb22b063237 (svn r15301) -Feature [FS#104]: Add option to group and subtotal expenses list in the company finance window. Concept from Zr40.
peter1138 <peter1138@openttd.org>
parents: 10960
diff changeset
263
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
264 /* Recheck the size of the window as it might need to be resized due to the local company changing */
11494
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
265 int new_height = this->widget[(company == _local_company) ? CFW_INCREASE_LOAN : CFW_TOTAL_PANEL].bottom + 1;
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
266 if (this->height != new_height) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
267 /* Make window dirty before and after resizing */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
268 this->SetDirty();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
269 this->height = new_height;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
270 this->SetDirty();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
271
11494
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
272 this->SetWidgetHiddenState(CFW_INCREASE_LOAN, company != _local_company);
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
273 this->SetWidgetHiddenState(CFW_REPAY_LOAN, company != _local_company);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
274 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
275
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
276 /* Borrow button only shows when there is any more money to loan */
11494
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
277 this->SetWidgetDisabledState(CFW_INCREASE_LOAN, c->current_loan == _economy.max_loan);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
278
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
279 /* Repay button only shows when there is any more money to repay */
11494
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
280 this->SetWidgetDisabledState(CFW_REPAY_LOAN, company != _local_company || c->current_loan == 0);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
281
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
282 SetDParam(0, c->index);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
283 SetDParam(1, c->index);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
284 SetDParam(2, LOAN_INTERVAL);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
285 this->DrawWidgets();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
286
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
287 DrawCompanyEconomyStats(c, this->small);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
288 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
289
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
290 virtual void OnClick(Point pt, int widget)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
291 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
292 switch (widget) {
11494
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
293 case CFW_TOGGLE_SIZE: {// toggle size
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
294 bool new_mode = !this->small;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
295 bool stickied = !!(this->flags4 & WF_STICKY);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
296 int oldtop = this->top; ///< current top position of the window before closing it
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
297 int oldleft = this->left; ///< current left position of the window before closing it
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
298 CompanyID company = (CompanyID)this->window_number;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
299
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
300 delete this;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
301 /* Open up the (toggled size) Finance window at the same position as the previous */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
302 DoShowCompanyFinances(company, new_mode, stickied, oldtop, oldleft);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
303 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
304 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
305
11494
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
306 case CFW_INCREASE_LOAN: // increase loan
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10209
diff changeset
307 DoCommandP(0, 0, _ctrl_pressed, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY));
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
308 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
309
11494
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
310 case CFW_REPAY_LOAN: // repay loan
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10209
diff changeset
311 DoCommandP(0, 0, _ctrl_pressed, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN));
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
312 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
313 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
314 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
315 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
316
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
317 static const WindowDesc _company_finances_desc(
11494
6af9e6523c41 (svn r15855) -Codechange: complete the company finances window widget enum and remove unneeded magic in large window definition
glx <glx@openttd.org>
parents: 11450
diff changeset
318 WDP_AUTO, WDP_AUTO, 407, 60, 407, 60,
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
319 WC_FINANCES, WC_NONE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
320 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
321 _company_finances_widgets
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
322 );
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
323
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
324 static const WindowDesc _company_finances_small_desc(
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
325 WDP_AUTO, WDP_AUTO, 280, 60, 280, 60,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
326 WC_FINANCES, WC_NONE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
327 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
328 _company_finances_small_widgets
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
329 );
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
330
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
331 /**
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
332 * Open the small/large finance window of the company
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
333 *
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
334 * @param company the company who's finances are requested to be seen
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
335 * @param show_small show large or small version opf the window
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
336 * @param show_stickied previous "stickyness" of the window
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
337 * @param top previous top position of the window
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
338 * @param left previous left position of the window
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
339 *
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
340 * @pre is company a valid company
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
341 */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
342 static void DoShowCompanyFinances(CompanyID company, bool show_small, bool show_stickied, int top, int left)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
343 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
344 if (!IsValidCompanyID(company)) return;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
345
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
346 if (BringWindowToFrontById(WC_FINANCES, company)) return;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
347 new CompanyFinancesWindow(show_small ? &_company_finances_small_desc : &_company_finances_desc, company, show_small, show_stickied, top, left);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
348 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
349
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
350 void ShowCompanyFinances(CompanyID company)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
351 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
352 DoShowCompanyFinances(company, false, false);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
353 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
354
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
355 /* List of colours for the livery window */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
356 static const StringID _colour_dropdown[] = {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
357 STR_00D1_DARK_BLUE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
358 STR_00D2_PALE_GREEN,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
359 STR_00D3_PINK,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
360 STR_00D4_YELLOW,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
361 STR_00D5_RED,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
362 STR_00D6_LIGHT_BLUE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
363 STR_00D7_GREEN,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
364 STR_00D8_DARK_GREEN,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
365 STR_00D9_BLUE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
366 STR_00DA_CREAM,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
367 STR_00DB_MAUVE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
368 STR_00DC_PURPLE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
369 STR_00DD_ORANGE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
370 STR_00DE_BROWN,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
371 STR_00DF_GREY,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
372 STR_00E0_WHITE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
373 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
374
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
375 /* Association of liveries to livery classes */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
376 static const LiveryClass _livery_class[LS_END] = {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
377 LC_OTHER,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
378 LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
379 LC_ROAD, LC_ROAD,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
380 LC_SHIP, LC_SHIP,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
381 LC_AIRCRAFT, LC_AIRCRAFT, LC_AIRCRAFT,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
382 LC_ROAD, LC_ROAD,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
383 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
384
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
385 class DropDownListColourItem : public DropDownListItem {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
386 public:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
387 DropDownListColourItem(int result, bool masked) : DropDownListItem(result, masked) {}
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
388
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
389 virtual ~DropDownListColourItem() {}
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
390
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
391 StringID String() const
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
392 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
393 return _colour_dropdown[this->result];
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
394 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
395
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
396 uint Height(uint width) const
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
397 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
398 return 14;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
399 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
400
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
401 bool Selectable() const
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
402 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
403 return true;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
404 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
405
11425
532a1c74074d (svn r15783) -Codechange: make the dropdown draw code pass around the left/right instead of the x and width to make drawing text at offsets easier.
rubidium <rubidium@openttd.org>
parents: 11373
diff changeset
406 void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
407 {
11425
532a1c74074d (svn r15783) -Codechange: make the dropdown draw code pass around the left/right instead of the x and width to make drawing text at offsets easier.
rubidium <rubidium@openttd.org>
parents: 11373
diff changeset
408 DrawSprite(SPR_VEH_BUS_SIDE_VIEW, PALETTE_RECOLOUR_START + this->result, left + 16, top + 7);
532a1c74074d (svn r15783) -Codechange: make the dropdown draw code pass around the left/right instead of the x and width to make drawing text at offsets easier.
rubidium <rubidium@openttd.org>
parents: 11373
diff changeset
409 DrawString(left + 32, right - 2, top + 3, this->String(), sel ? TC_WHITE : TC_BLACK);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
410 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
411 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
412
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
413 struct SelectCompanyLiveryWindow : public Window {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
414 private:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
415 uint32 sel;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
416 LiveryClass livery_class;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
417
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
418 enum SelectCompanyLiveryWindowWidgets {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
419 SCLW_WIDGET_CLOSE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
420 SCLW_WIDGET_CAPTION,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
421 SCLW_WIDGET_CLASS_GENERAL,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
422 SCLW_WIDGET_CLASS_RAIL,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
423 SCLW_WIDGET_CLASS_ROAD,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
424 SCLW_WIDGET_CLASS_SHIP,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
425 SCLW_WIDGET_CLASS_AIRCRAFT,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
426 SCLW_WIDGET_SPACER_CLASS,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
427 SCLW_WIDGET_SPACER_DROPDOWN,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
428 SCLW_WIDGET_PRI_COL_DROPDOWN,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
429 SCLW_WIDGET_SEC_COL_DROPDOWN,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
430 SCLW_WIDGET_MATRIX,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
431 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
432
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
433 void ShowColourDropDownMenu(uint32 widget)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
434 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
435 uint32 used_colours = 0;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
436 const Livery *livery;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
437 LiveryScheme scheme;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
438
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
439 /* Disallow other company colours for the primary colour */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
440 if (HasBit(this->sel, LS_DEFAULT) && widget == SCLW_WIDGET_PRI_COL_DROPDOWN) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
441 const Company *c;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
442 FOR_ALL_COMPANIES(c) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
443 if (c->index != _local_company) SetBit(used_colours, c->colour);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
444 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
445 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
446
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
447 /* Get the first selected livery to use as the default dropdown item */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
448 for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
449 if (HasBit(this->sel, scheme)) break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
450 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
451 if (scheme == LS_END) scheme = LS_DEFAULT;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
452 livery = &GetCompany((CompanyID)this->window_number)->livery[scheme];
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
453
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
454 DropDownList *list = new DropDownList();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
455 for (uint i = 0; i < lengthof(_colour_dropdown); i++) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
456 list->push_back(new DropDownListColourItem(i, HasBit(used_colours, i)));
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
457 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
458
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
459 ShowDropDownList(this, list, widget == SCLW_WIDGET_PRI_COL_DROPDOWN ? livery->colour1 : livery->colour2, widget);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
460 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
461
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
462 public:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
463 SelectCompanyLiveryWindow(const WindowDesc *desc, CompanyID company) : Window(desc, company)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
464 {
11084
e07c7d3925c8 (svn r15427) -Codechange: give w->caption_color a more sensible name as it holds the owner of whatever is shown in the window
rubidium <rubidium@openttd.org>
parents: 10998
diff changeset
465 this->owner = company;
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
466 this->livery_class = LC_OTHER;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
467 this->sel = 1;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
468 this->LowerWidget(SCLW_WIDGET_CLASS_GENERAL);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
469 this->OnInvalidateData(_loaded_newgrf_features.has_2CC);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
470 this->FindWindowPlacementAndResize(desc);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
471 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
472
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
473 virtual void OnPaint()
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
474 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
475 const Company *c = GetCompany((CompanyID)this->window_number);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
476 LiveryScheme scheme = LS_DEFAULT;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
477 int y = 51;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
478
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
479 /* Disable dropdown controls if no scheme is selected */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
480 this->SetWidgetDisabledState(SCLW_WIDGET_PRI_COL_DROPDOWN, this->sel == 0);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
481 this->SetWidgetDisabledState(SCLW_WIDGET_SEC_COL_DROPDOWN, this->sel == 0);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
482
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
483 if (this->sel != 0) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
484 for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
485 if (HasBit(this->sel, scheme)) break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
486 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
487 if (scheme == LS_END) scheme = LS_DEFAULT;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
488 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
489
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
490 SetDParam(0, STR_00D1_DARK_BLUE + c->livery[scheme].colour1);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
491 SetDParam(1, STR_00D1_DARK_BLUE + c->livery[scheme].colour2);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
492
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
493 this->DrawWidgets();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
494
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
495 for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
496 if (_livery_class[scheme] == this->livery_class) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
497 bool sel = HasBit(this->sel, scheme) != 0;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
498
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
499 if (scheme != LS_DEFAULT) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
500 DrawSprite(c->livery[scheme].in_use ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, 2, y);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
501 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
502
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
503 DrawString(15, 165, y, STR_LIVERY_DEFAULT + scheme, sel ? TC_WHITE : TC_BLACK);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
504
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
505 DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOUR(c->livery[scheme].colour1), 152, y);
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
506 DrawString(165, 290, y, STR_00D1_DARK_BLUE + c->livery[scheme].colour1, sel ? TC_WHITE : TC_GOLD);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
507
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
508 if (!this->IsWidgetHidden(SCLW_WIDGET_SEC_COL_DROPDOWN)) {
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
509 DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOUR(c->livery[scheme].colour2), 277, y);
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
510 DrawString(290, this->width, y, STR_00D1_DARK_BLUE + c->livery[scheme].colour2, sel ? TC_WHITE : TC_GOLD);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
511 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
512
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
513 y += 14;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
514 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
515 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
516 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
517
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
518 virtual void OnClick(Point pt, int widget)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
519 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
520 /* Number of liveries in each class, used to determine the height of the livery window */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
521 static const byte livery_height[] = {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
522 1,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
523 13,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
524 4,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
525 2,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
526 3,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
527 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
528
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
529 switch (widget) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
530 /* Livery Class buttons */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
531 case SCLW_WIDGET_CLASS_GENERAL:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
532 case SCLW_WIDGET_CLASS_RAIL:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
533 case SCLW_WIDGET_CLASS_ROAD:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
534 case SCLW_WIDGET_CLASS_SHIP:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
535 case SCLW_WIDGET_CLASS_AIRCRAFT: {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
536 LiveryScheme scheme;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
537
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
538 this->RaiseWidget(this->livery_class + SCLW_WIDGET_CLASS_GENERAL);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
539 this->livery_class = (LiveryClass)(widget - SCLW_WIDGET_CLASS_GENERAL);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
540 this->sel = 0;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
541 this->LowerWidget(this->livery_class + SCLW_WIDGET_CLASS_GENERAL);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
542
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
543 /* Select the first item in the list */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
544 for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
545 if (_livery_class[scheme] == this->livery_class) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
546 this->sel = 1 << scheme;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
547 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
548 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
549 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
550 this->height = 49 + livery_height[this->livery_class] * 14;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
551 this->widget[SCLW_WIDGET_MATRIX].bottom = this->height - 1;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
552 this->widget[SCLW_WIDGET_MATRIX].data = livery_height[this->livery_class] << 8 | 1;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
553 MarkWholeScreenDirty();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
554 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
555 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
556
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
557 case SCLW_WIDGET_PRI_COL_DROPDOWN: // First colour dropdown
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
558 ShowColourDropDownMenu(SCLW_WIDGET_PRI_COL_DROPDOWN);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
559 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
560
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
561 case SCLW_WIDGET_SEC_COL_DROPDOWN: // Second colour dropdown
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
562 ShowColourDropDownMenu(SCLW_WIDGET_SEC_COL_DROPDOWN);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
563 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
564
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
565 case SCLW_WIDGET_MATRIX: {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
566 LiveryScheme scheme;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
567 LiveryScheme j = (LiveryScheme)((pt.y - 48) / 14);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
568
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
569 for (scheme = LS_BEGIN; scheme <= j; scheme++) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
570 if (_livery_class[scheme] != this->livery_class) j++;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
571 if (scheme >= LS_END) return;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
572 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
573 if (j >= LS_END) return;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
574
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
575 /* If clicking on the left edge, toggle using the livery */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
576 if (pt.x < 10) {
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
577 DoCommandP(0, j | (2 << 8), !GetCompany((CompanyID)this->window_number)->livery[j].in_use, CMD_SET_COMPANY_COLOUR);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
578 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
579
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
580 if (_ctrl_pressed) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
581 ToggleBit(this->sel, j);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
582 } else {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
583 this->sel = 1 << j;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
584 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
585 this->SetDirty();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
586 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
587 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
588 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
589 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
590
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
591 virtual void OnDropdownSelect(int widget, int index)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
592 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
593 for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
594 if (HasBit(this->sel, scheme)) {
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
595 DoCommandP(0, scheme | (widget == SCLW_WIDGET_PRI_COL_DROPDOWN ? 0 : 256), index, CMD_SET_COMPANY_COLOUR);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
596 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
597 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
598 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
599
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
600 virtual void OnInvalidateData(int data = 0)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
601 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
602 static bool has2cc = true;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
603
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
604 if (has2cc == !!data) return;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
605
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
606 has2cc = !!data;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
607
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
608 int r = this->widget[has2cc ? SCLW_WIDGET_SEC_COL_DROPDOWN : SCLW_WIDGET_PRI_COL_DROPDOWN].right;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
609 this->SetWidgetHiddenState(SCLW_WIDGET_SEC_COL_DROPDOWN, !has2cc);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
610 this->widget[SCLW_WIDGET_CAPTION].right = r;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
611 this->widget[SCLW_WIDGET_SPACER_CLASS].right = r;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
612 this->widget[SCLW_WIDGET_MATRIX].right = r;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
613 this->width = r + 1;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
614 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
615 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
616
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
617 static const Widget _select_company_livery_widgets[] = {
11086
23adfa4f7d5a (svn r15429) -Change: do r15428 also for the string names.
rubidium <rubidium@openttd.org>
parents: 11085
diff changeset
618 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW },
23adfa4f7d5a (svn r15429) -Change: do r15428 also for the string names.
rubidium <rubidium@openttd.org>
parents: 11085
diff changeset
619 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 399, 0, 13, STR_7007_NEW_COLOUR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS },
23adfa4f7d5a (svn r15429) -Change: do r15428 also for the string names.
rubidium <rubidium@openttd.org>
parents: 11085
diff changeset
620 { WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 0, 21, 14, 35, SPR_IMG_COMPANY_GENERAL, STR_LIVERY_GENERAL_TIP },
23adfa4f7d5a (svn r15429) -Change: do r15428 also for the string names.
rubidium <rubidium@openttd.org>
parents: 11085
diff changeset
621 { WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 22, 43, 14, 35, SPR_IMG_TRAINLIST, STR_LIVERY_TRAIN_TIP },
23adfa4f7d5a (svn r15429) -Change: do r15428 also for the string names.
rubidium <rubidium@openttd.org>
parents: 11085
diff changeset
622 { WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 44, 65, 14, 35, SPR_IMG_TRUCKLIST, STR_LIVERY_ROADVEH_TIP },
23adfa4f7d5a (svn r15429) -Change: do r15428 also for the string names.
rubidium <rubidium@openttd.org>
parents: 11085
diff changeset
623 { WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 66, 87, 14, 35, SPR_IMG_SHIPLIST, STR_LIVERY_SHIP_TIP },
23adfa4f7d5a (svn r15429) -Change: do r15428 also for the string names.
rubidium <rubidium@openttd.org>
parents: 11085
diff changeset
624 { WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 88, 109, 14, 35, SPR_IMG_AIRPLANESLIST, STR_LIVERY_AIRCRAFT_TIP },
23adfa4f7d5a (svn r15429) -Change: do r15428 also for the string names.
rubidium <rubidium@openttd.org>
parents: 11085
diff changeset
625 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 110, 399, 14, 35, 0x0, STR_NULL },
23adfa4f7d5a (svn r15429) -Change: do r15428 also for the string names.
rubidium <rubidium@openttd.org>
parents: 11085
diff changeset
626 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 149, 36, 47, 0x0, STR_NULL },
23adfa4f7d5a (svn r15429) -Change: do r15428 also for the string names.
rubidium <rubidium@openttd.org>
parents: 11085
diff changeset
627 { WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 150, 274, 36, 47, STR_02BD, STR_LIVERY_PRIMARY_TIP },
23adfa4f7d5a (svn r15429) -Change: do r15428 also for the string names.
rubidium <rubidium@openttd.org>
parents: 11085
diff changeset
628 { WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 275, 399, 36, 47, STR_02E1, STR_LIVERY_SECONDARY_TIP },
23adfa4f7d5a (svn r15429) -Change: do r15428 also for the string names.
rubidium <rubidium@openttd.org>
parents: 11085
diff changeset
629 { WWT_MATRIX, RESIZE_NONE, COLOUR_GREY, 0, 399, 48, 48 + 1 * 14, (1 << 8) | 1, STR_LIVERY_PANEL_TIP },
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
630 { WIDGETS_END },
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
631 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
632
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
633 static const WindowDesc _select_company_livery_desc(
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
634 WDP_AUTO, WDP_AUTO, 400, 49 + 1 * 14, 400, 49 + 1 * 14,
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
635 WC_COMPANY_COLOUR, WC_NONE,
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
636 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
637 _select_company_livery_widgets
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
638 );
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
639
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
640 /**
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
641 * Draws the face of a company manager's face.
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
642 * @param cmf the company manager's face
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
643 * @param colour the (background) colour of the gradient
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
644 * @param x x-position to draw the face
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
645 * @param y y-position to draw the face
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
646 */
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
647 void DrawCompanyManagerFace(CompanyManagerFace cmf, int colour, int x, int y)
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
648 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
649 GenderEthnicity ge = (GenderEthnicity)GetCompanyManagerFaceBits(cmf, CMFV_GEN_ETHN, GE_WM);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
650
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
651 bool has_moustache = !HasBit(ge, GENDER_FEMALE) && GetCompanyManagerFaceBits(cmf, CMFV_HAS_MOUSTACHE, ge) != 0;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
652 bool has_tie_earring = !HasBit(ge, GENDER_FEMALE) || GetCompanyManagerFaceBits(cmf, CMFV_HAS_TIE_EARRING, ge) != 0;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
653 bool has_glasses = GetCompanyManagerFaceBits(cmf, CMFV_HAS_GLASSES, ge) != 0;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
654 SpriteID pal;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
655
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
656 /* Modify eye colour palette only if 2 or more valid values exist */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
657 if (_cmf_info[CMFV_EYE_COLOUR].valid_values[ge] < 2) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
658 pal = PAL_NONE;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
659 } else {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
660 switch (GetCompanyManagerFaceBits(cmf, CMFV_EYE_COLOUR, ge)) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
661 default: NOT_REACHED();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
662 case 0: pal = PALETTE_TO_BROWN; break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
663 case 1: pal = PALETTE_TO_BLUE; break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
664 case 2: pal = PALETTE_TO_GREEN; break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
665 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
666 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
667
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
668 /* Draw the gradient (background) */
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
669 DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOUR(colour), x, y);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
670
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
671 for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
672 switch (cmfv) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
673 case CMFV_MOUSTACHE: if (!has_moustache) continue; break;
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
674 case CMFV_LIPS: // FALL THROUGH
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
675 case CMFV_NOSE: if (has_moustache) continue; break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
676 case CMFV_TIE_EARRING: if (!has_tie_earring) continue; break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
677 case CMFV_GLASSES: if (!has_glasses) continue; break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
678 default: break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
679 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
680 DrawSprite(GetCompanyManagerFaceSprite(cmf, cmfv, ge), (cmfv == CMFV_EYEBROWS) ? pal : PAL_NONE, x, y);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
681 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
682 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
683
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
684 /** Widget description for the normal/simple company manager face selection dialog */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
685 static const Widget _select_company_manager_face_widgets[] = {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
686 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // SCMFW_WIDGET_CLOSEBOX
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
687 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 174, 0, 13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // SCMFW_WIDGET_CAPTION
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
688 { WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 189, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_FACE_ADVANCED_TIP}, // SCMFW_WIDGET_TOGGLE_LARGE_SMALL
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
689 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 189, 14, 150, 0x0, STR_NULL}, // SCMFW_WIDGET_SELECT_FACE
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
690 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 94, 151, 162, STR_012E_CANCEL, STR_7047_CANCEL_NEW_FACE_SELECTION}, // SCMFW_WIDGET_CANCEL
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
691 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 189, 151, 162, STR_012F_OK, STR_7048_ACCEPT_NEW_FACE_SELECTION}, // SCMFW_WIDGET_ACCEPT
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
692 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 187, 75, 86, STR_7044_MALE, STR_7049_SELECT_MALE_FACES}, // SCMFW_WIDGET_MALE
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
693 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 187, 87, 98, STR_7045_FEMALE, STR_704A_SELECT_FEMALE_FACES}, // SCMFW_WIDGET_FEMALE
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
694 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 137, 148, STR_7046_NEW_FACE, STR_704B_GENERATE_RANDOM_NEW_FACE}, // SCMFW_WIDGET_RANDOM_NEW_FACE
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
695 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 187, 16, 27, STR_FACE_ADVANCED, STR_FACE_ADVANCED_TIP}, // SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
696 { WIDGETS_END},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
697 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
698
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
699 /** Widget description for the advanced company manager face selection dialog */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
700 static const Widget _select_company_manager_face_adv_widgets[] = {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
701 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // SCMFW_WIDGET_CLOSEBOX
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
702 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 204, 0, 13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // SCMFW_WIDGET_CAPTION
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
703 { WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 205, 219, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_FACE_SIMPLE_TIP}, // SCMFW_WIDGET_TOGGLE_LARGE_SMALL
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
704 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 219, 14, 207, 0x0, STR_NULL}, // SCMFW_WIDGET_SELECT_FACE
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
705 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 94, 208, 219, STR_012E_CANCEL, STR_7047_CANCEL_NEW_FACE_SELECTION}, // SCMFW_WIDGET_CANCEL
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
706 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 219, 208, 219, STR_012F_OK, STR_7048_ACCEPT_NEW_FACE_SELECTION}, // SCMFW_WIDGET_ACCEPT
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
707 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 96, 156, 32, 43, STR_7044_MALE, STR_7049_SELECT_MALE_FACES}, // SCMFW_WIDGET_MALE
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
708 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 157, 217, 32, 43, STR_7045_FEMALE, STR_704A_SELECT_FEMALE_FACES}, // SCMFW_WIDGET_FEMALE
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
709 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 137, 148, STR_RANDOM, STR_704B_GENERATE_RANDOM_NEW_FACE}, // SCMFW_WIDGET_RANDOM_NEW_FACE
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
710 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 217, 16, 27, STR_FACE_SIMPLE, STR_FACE_SIMPLE_TIP}, // SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
711 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 158, 169, STR_FACE_LOAD, STR_FACE_LOAD_TIP}, // SCMFW_WIDGET_LOAD
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
712 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 170, 181, STR_FACE_FACECODE, STR_FACE_FACECODE_TIP}, // SCMFW_WIDGET_FACECODE
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
713 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 182, 193, STR_FACE_SAVE, STR_FACE_SAVE_TIP}, // SCMFW_WIDGET_SAVE
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
714 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 96, 156, 46, 57, STR_FACE_EUROPEAN, STR_FACE_SELECT_EUROPEAN}, // SCMFW_WIDGET_ETHNICITY_EUR
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
715 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 157, 217, 46, 57, STR_FACE_AFRICAN, STR_FACE_SELECT_AFRICAN}, // SCMFW_WIDGET_ETHNICITY_AFR
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
716 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 175, 217, 60, 71, STR_EMPTY, STR_FACE_MOUSTACHE_EARRING_TIP}, // SCMFW_WIDGET_HAS_MOUSTACHE_EARRING
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
717 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 175, 217, 72, 83, STR_EMPTY, STR_FACE_GLASSES_TIP}, // SCMFW_WIDGET_HAS_GLASSES
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
718 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 110, 121, SPR_ARROW_LEFT, STR_FACE_EYECOLOUR_TIP}, // SCMFW_WIDGET_EYECOLOUR_L
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
719 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 110, 121, STR_EMPTY, STR_FACE_EYECOLOUR_TIP}, // SCMFW_WIDGET_EYECOLOUR
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
720 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 110, 121, SPR_ARROW_RIGHT, STR_FACE_EYECOLOUR_TIP}, // SCMFW_WIDGET_EYECOLOUR_R
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
721 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 158, 169, SPR_ARROW_LEFT, STR_FACE_CHIN_TIP}, // SCMFW_WIDGET_CHIN_L
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
722 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 158, 169, STR_EMPTY, STR_FACE_CHIN_TIP}, // SCMFW_WIDGET_CHIN
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
723 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 158, 169, SPR_ARROW_RIGHT, STR_FACE_CHIN_TIP}, // SCMFW_WIDGET_CHIN_R
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
724 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 98, 109, SPR_ARROW_LEFT, STR_FACE_EYEBROWS_TIP}, // SCMFW_WIDGET_EYEBROWS_L
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
725 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 98, 109, STR_EMPTY, STR_FACE_EYEBROWS_TIP}, // SCMFW_WIDGET_EYEBROWS
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
726 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 98, 109, SPR_ARROW_RIGHT, STR_FACE_EYEBROWS_TIP}, // SCMFW_WIDGET_EYEBROWS_R
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
727 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 146, 157, SPR_ARROW_LEFT, STR_FACE_LIPS_MOUSTACHE_TIP}, // SCMFW_WIDGET_LIPS_MOUSTACHE_L
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
728 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 146, 157, STR_EMPTY, STR_FACE_LIPS_MOUSTACHE_TIP}, // SCMFW_WIDGET_LIPS_MOUSTACHE
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
729 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 146, 157, SPR_ARROW_RIGHT, STR_FACE_LIPS_MOUSTACHE_TIP}, // SCMFW_WIDGET_LIPS_MOUSTACHE_R
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
730 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 134, 145, SPR_ARROW_LEFT, STR_FACE_NOSE_TIP}, // SCMFW_WIDGET_NOSE_L
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
731 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 134, 145, STR_EMPTY, STR_FACE_NOSE_TIP}, // SCMFW_WIDGET_NOSE
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
732 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 134, 145, SPR_ARROW_RIGHT, STR_FACE_NOSE_TIP}, // SCMFW_WIDGET_NOSE_R
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
733 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 86, 97, SPR_ARROW_LEFT, STR_FACE_HAIR_TIP}, // SCMFW_WIDGET_HAIR_L
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
734 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 86, 97, STR_EMPTY, STR_FACE_HAIR_TIP}, // SCMFW_WIDGET_HAIR
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
735 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 86, 97, SPR_ARROW_RIGHT, STR_FACE_HAIR_TIP}, // SCMFW_WIDGET_HAIR_R
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
736 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 170, 181, SPR_ARROW_LEFT, STR_FACE_JACKET_TIP}, // SCMFW_WIDGET_JACKET_L
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
737 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 170, 181, STR_EMPTY, STR_FACE_JACKET_TIP}, // SCMFW_WIDGET_JACKET
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
738 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 170, 181, SPR_ARROW_RIGHT, STR_FACE_JACKET_TIP}, // SCMFW_WIDGET_JACKET_R
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
739 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 182, 193, SPR_ARROW_LEFT, STR_FACE_COLLAR_TIP}, // SCMFW_WIDGET_COLLAR_L
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
740 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 182, 193, STR_EMPTY, STR_FACE_COLLAR_TIP}, // SCMFW_WIDGET_COLLAR
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
741 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 182, 193, SPR_ARROW_RIGHT, STR_FACE_COLLAR_TIP}, // SCMFW_WIDGET_COLLAR_R
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
742 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 194, 205, SPR_ARROW_LEFT, STR_FACE_TIE_EARRING_TIP}, // SCMFW_WIDGET_TIE_EARRING_L
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
743 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 194, 205, STR_EMPTY, STR_FACE_TIE_EARRING_TIP}, // SCMFW_WIDGET_TIE_EARRING
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
744 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 194, 205, SPR_ARROW_RIGHT, STR_FACE_TIE_EARRING_TIP}, // SCMFW_WIDGET_TIE_EARRING_R
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
745 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 122, 133, SPR_ARROW_LEFT, STR_FACE_GLASSES_TIP_2}, // SCMFW_WIDGET_GLASSES_L
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
746 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 122, 133, STR_EMPTY, STR_FACE_GLASSES_TIP_2}, // SCMFW_WIDGET_GLASSES
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
747 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 122, 133, SPR_ARROW_RIGHT, STR_FACE_GLASSES_TIP_2}, // SCMFW_WIDGET_GLASSES_R
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
748 { WIDGETS_END},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
749 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
750
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
751 class SelectCompanyManagerFaceWindow : public Window
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
752 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
753 CompanyManagerFace face; ///< company manager face bits
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
754 bool advanced; ///< advanced company manager face selection window
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
755
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
756 GenderEthnicity ge;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
757 bool is_female;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
758 bool is_moust_male;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
759
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
760 /**
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
761 * Names of the widgets. Keep them in the same order as in the widget array.
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
762 * Do not change the order of the widgets from SCMFW_WIDGET_HAS_MOUSTACHE_EARRING to SCMFW_WIDGET_GLASSES_R,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
763 * this order is needed for the WE_CLICK event of DrawFaceStringLabel().
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
764 */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
765 enum SelectCompanyManagerFaceWidgets {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
766 SCMFW_WIDGET_CLOSEBOX = 0,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
767 SCMFW_WIDGET_CAPTION,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
768 SCMFW_WIDGET_TOGGLE_LARGE_SMALL,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
769 SCMFW_WIDGET_SELECT_FACE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
770 SCMFW_WIDGET_CANCEL,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
771 SCMFW_WIDGET_ACCEPT,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
772 SCMFW_WIDGET_MALE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
773 SCMFW_WIDGET_FEMALE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
774 SCMFW_WIDGET_RANDOM_NEW_FACE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
775 SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
776 /* from here is the advanced company manager face selection window */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
777 SCMFW_WIDGET_LOAD,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
778 SCMFW_WIDGET_FACECODE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
779 SCMFW_WIDGET_SAVE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
780 SCMFW_WIDGET_ETHNICITY_EUR,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
781 SCMFW_WIDGET_ETHNICITY_AFR,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
782 SCMFW_WIDGET_HAS_MOUSTACHE_EARRING,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
783 SCMFW_WIDGET_HAS_GLASSES,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
784 SCMFW_WIDGET_EYECOLOUR_L,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
785 SCMFW_WIDGET_EYECOLOUR,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
786 SCMFW_WIDGET_EYECOLOUR_R,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
787 SCMFW_WIDGET_CHIN_L,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
788 SCMFW_WIDGET_CHIN,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
789 SCMFW_WIDGET_CHIN_R,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
790 SCMFW_WIDGET_EYEBROWS_L,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
791 SCMFW_WIDGET_EYEBROWS,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
792 SCMFW_WIDGET_EYEBROWS_R,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
793 SCMFW_WIDGET_LIPS_MOUSTACHE_L,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
794 SCMFW_WIDGET_LIPS_MOUSTACHE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
795 SCMFW_WIDGET_LIPS_MOUSTACHE_R,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
796 SCMFW_WIDGET_NOSE_L,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
797 SCMFW_WIDGET_NOSE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
798 SCMFW_WIDGET_NOSE_R,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
799 SCMFW_WIDGET_HAIR_L,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
800 SCMFW_WIDGET_HAIR,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
801 SCMFW_WIDGET_HAIR_R,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
802 SCMFW_WIDGET_JACKET_L,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
803 SCMFW_WIDGET_JACKET,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
804 SCMFW_WIDGET_JACKET_R,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
805 SCMFW_WIDGET_COLLAR_L,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
806 SCMFW_WIDGET_COLLAR,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
807 SCMFW_WIDGET_COLLAR_R,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
808 SCMFW_WIDGET_TIE_EARRING_L,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
809 SCMFW_WIDGET_TIE_EARRING,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
810 SCMFW_WIDGET_TIE_EARRING_R,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
811 SCMFW_WIDGET_GLASSES_L,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
812 SCMFW_WIDGET_GLASSES,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
813 SCMFW_WIDGET_GLASSES_R,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
814 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
815 /**
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
816 * Draw dynamic a label to the left of the button and a value in the button
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
817 *
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
818 * @param widget_index index of this widget in the window
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
819 * @param str the label which will be draw
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
820 * @param val the value which will be draw
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
821 * @param is_bool_widget is it a bool button
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
822 */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
823 void DrawFaceStringLabel(byte widget_index, StringID str, uint8 val, bool is_bool_widget)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
824 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
825 /* Write the label in gold (0x2) to the left of the button. */
11433
07857d65c41a (svn r15791) -Codechange: remove the *RightAligned part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
826 DrawString(0, this->widget[widget_index].left - (is_bool_widget ? 5 : 14), this->widget[widget_index].top + 1, str, TC_GOLD, SA_RIGHT);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
827
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
828 if (!this->IsWidgetDisabled(widget_index)) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
829 if (is_bool_widget) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
830 /* if it a bool button write yes or no */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
831 str = (val != 0) ? STR_FACE_YES : STR_FACE_NO;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
832 } else {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
833 /* else write the value + 1 */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
834 SetDParam(0, val + 1);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
835 str = STR_JUST_INT;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
836 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
837
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
838 /* Draw the value/bool in white (0xC). If the button clicked adds 1px to x and y text coordinates (IsWindowWidgetLowered()). */
11432
a20dd0000d96 (svn r15790) -Codechange: remove the *Centered part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11425
diff changeset
839 DrawString(this->widget[widget_index].left + this->IsWidgetLowered(widget_index), this->widget[widget_index].right - this->IsWidgetLowered(widget_index),
a20dd0000d96 (svn r15790) -Codechange: remove the *Centered part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11425
diff changeset
840 this->widget[widget_index].top + 1 + this->IsWidgetLowered(widget_index), str, TC_WHITE, SA_CENTER);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
841 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
842 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
843
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
844 void UpdateData()
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
845 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
846 this->ge = (GenderEthnicity)GB(this->face, _cmf_info[CMFV_GEN_ETHN].offset, _cmf_info[CMFV_GEN_ETHN].length); // get the gender and ethnicity
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
847 this->is_female = HasBit(this->ge, GENDER_FEMALE); // get the gender: 0 == male and 1 == female
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
848 this->is_moust_male = !is_female && GetCompanyManagerFaceBits(this->face, CMFV_HAS_MOUSTACHE, this->ge) != 0; // is a male face with moustache
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
849 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
850
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
851 public:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
852 SelectCompanyManagerFaceWindow(const WindowDesc *desc, Window *parent, bool advanced, int top, int left) : Window(desc, parent->window_number)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
853 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
854 this->parent = parent;
11084
e07c7d3925c8 (svn r15427) -Codechange: give w->caption_color a more sensible name as it holds the owner of whatever is shown in the window
rubidium <rubidium@openttd.org>
parents: 10998
diff changeset
855 this->owner = (Owner)this->window_number;
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
856 this->face = GetCompany((CompanyID)this->window_number)->face;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
857 this->advanced = advanced;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
858
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
859 this->UpdateData();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
860
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
861 /* Check if repositioning from default is required */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
862 if (top != FIRST_GUI_CALL && left != FIRST_GUI_CALL) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
863 this->top = top;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
864 this->left = left;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
865 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
866
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
867 this->FindWindowPlacementAndResize(desc);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
868 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
869
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
870 virtual void OnPaint()
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
871 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
872 /* lower the non-selected gender button */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
873 this->SetWidgetLoweredState(SCMFW_WIDGET_MALE, !this->is_female);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
874 this->SetWidgetLoweredState(SCMFW_WIDGET_FEMALE, this->is_female);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
875
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
876 /* advanced company manager face selection window */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
877 if (this->advanced) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
878 /* lower the non-selected ethnicity button */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
879 this->SetWidgetLoweredState(SCMFW_WIDGET_ETHNICITY_EUR, !HasBit(this->ge, ETHNICITY_BLACK));
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
880 this->SetWidgetLoweredState(SCMFW_WIDGET_ETHNICITY_AFR, HasBit(this->ge, ETHNICITY_BLACK));
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
881
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
882
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
883 /* Disable dynamically the widgets which CompanyManagerFaceVariable has less than 2 options
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11086
diff changeset
884 * (or in other words you haven't any choice).
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11086
diff changeset
885 * If the widgets depend on a HAS-variable and this is false the widgets will be disabled, too. */
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
886
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
887 /* Eye colour buttons */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
888 this->SetWidgetsDisabledState(_cmf_info[CMFV_EYE_COLOUR].valid_values[this->ge] < 2,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
889 SCMFW_WIDGET_EYECOLOUR, SCMFW_WIDGET_EYECOLOUR_L, SCMFW_WIDGET_EYECOLOUR_R, WIDGET_LIST_END);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
890
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
891 /* Chin buttons */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
892 this->SetWidgetsDisabledState(_cmf_info[CMFV_CHIN].valid_values[this->ge] < 2,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
893 SCMFW_WIDGET_CHIN, SCMFW_WIDGET_CHIN_L, SCMFW_WIDGET_CHIN_R, WIDGET_LIST_END);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
894
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
895 /* Eyebrows buttons */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
896 this->SetWidgetsDisabledState(_cmf_info[CMFV_EYEBROWS].valid_values[this->ge] < 2,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
897 SCMFW_WIDGET_EYEBROWS, SCMFW_WIDGET_EYEBROWS_L, SCMFW_WIDGET_EYEBROWS_R, WIDGET_LIST_END);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
898
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
899 /* Lips or (if it a male face with a moustache) moustache buttons */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
900 this->SetWidgetsDisabledState(_cmf_info[this->is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS].valid_values[this->ge] < 2,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
901 SCMFW_WIDGET_LIPS_MOUSTACHE, SCMFW_WIDGET_LIPS_MOUSTACHE_L, SCMFW_WIDGET_LIPS_MOUSTACHE_R, WIDGET_LIST_END);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
902
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
903 /* Nose buttons | male faces with moustache haven't any nose options */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
904 this->SetWidgetsDisabledState(_cmf_info[CMFV_NOSE].valid_values[this->ge] < 2 || this->is_moust_male,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
905 SCMFW_WIDGET_NOSE, SCMFW_WIDGET_NOSE_L, SCMFW_WIDGET_NOSE_R, WIDGET_LIST_END);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
906
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
907 /* Hair buttons */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
908 this->SetWidgetsDisabledState(_cmf_info[CMFV_HAIR].valid_values[this->ge] < 2,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
909 SCMFW_WIDGET_HAIR, SCMFW_WIDGET_HAIR_L, SCMFW_WIDGET_HAIR_R, WIDGET_LIST_END);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
910
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
911 /* Jacket buttons */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
912 this->SetWidgetsDisabledState(_cmf_info[CMFV_JACKET].valid_values[this->ge] < 2,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
913 SCMFW_WIDGET_JACKET, SCMFW_WIDGET_JACKET_L, SCMFW_WIDGET_JACKET_R, WIDGET_LIST_END);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
914
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
915 /* Collar buttons */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
916 this->SetWidgetsDisabledState(_cmf_info[CMFV_COLLAR].valid_values[this->ge] < 2,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
917 SCMFW_WIDGET_COLLAR, SCMFW_WIDGET_COLLAR_L, SCMFW_WIDGET_COLLAR_R, WIDGET_LIST_END);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
918
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
919 /* Tie/earring buttons | female faces without earring haven't any earring options */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
920 this->SetWidgetsDisabledState(_cmf_info[CMFV_TIE_EARRING].valid_values[this->ge] < 2 ||
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
921 (this->is_female && GetCompanyManagerFaceBits(this->face, CMFV_HAS_TIE_EARRING, this->ge) == 0),
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
922 SCMFW_WIDGET_TIE_EARRING, SCMFW_WIDGET_TIE_EARRING_L, SCMFW_WIDGET_TIE_EARRING_R, WIDGET_LIST_END);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
923
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
924 /* Glasses buttons | faces without glasses haven't any glasses options */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
925 this->SetWidgetsDisabledState(_cmf_info[CMFV_GLASSES].valid_values[this->ge] < 2 || GetCompanyManagerFaceBits(this->face, CMFV_HAS_GLASSES, this->ge) == 0,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
926 SCMFW_WIDGET_GLASSES, SCMFW_WIDGET_GLASSES_L, SCMFW_WIDGET_GLASSES_R, WIDGET_LIST_END);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
927 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
928
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
929 this->DrawWidgets();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
930
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
931 /* Draw dynamic button value and labels for the advanced company manager face selection window */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
932 if (this->advanced) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
933 if (this->is_female) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
934 /* Only for female faces */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
935 this->DrawFaceStringLabel(SCMFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_EARRING, GetCompanyManagerFaceBits(this->face, CMFV_HAS_TIE_EARRING, this->ge), true );
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
936 this->DrawFaceStringLabel(SCMFW_WIDGET_TIE_EARRING, STR_FACE_EARRING, GetCompanyManagerFaceBits(this->face, CMFV_TIE_EARRING, this->ge), false);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
937 } else {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
938 /* Only for male faces */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
939 this->DrawFaceStringLabel(SCMFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_MOUSTACHE, GetCompanyManagerFaceBits(this->face, CMFV_HAS_MOUSTACHE, this->ge), true );
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
940 this->DrawFaceStringLabel(SCMFW_WIDGET_TIE_EARRING, STR_FACE_TIE, GetCompanyManagerFaceBits(this->face, CMFV_TIE_EARRING, this->ge), false);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
941 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
942 if (this->is_moust_male) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
943 /* Only for male faces with moustache */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
944 this->DrawFaceStringLabel(SCMFW_WIDGET_LIPS_MOUSTACHE, STR_FACE_MOUSTACHE, GetCompanyManagerFaceBits(this->face, CMFV_MOUSTACHE, this->ge), false);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
945 } else {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
946 /* Only for female faces or male faces without moustache */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
947 this->DrawFaceStringLabel(SCMFW_WIDGET_LIPS_MOUSTACHE, STR_FACE_LIPS, GetCompanyManagerFaceBits(this->face, CMFV_LIPS, this->ge), false);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
948 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
949 /* For all faces */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
950 this->DrawFaceStringLabel(SCMFW_WIDGET_HAS_GLASSES, STR_FACE_GLASSES, GetCompanyManagerFaceBits(this->face, CMFV_HAS_GLASSES, this->ge), true );
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
951 this->DrawFaceStringLabel(SCMFW_WIDGET_HAIR, STR_FACE_HAIR, GetCompanyManagerFaceBits(this->face, CMFV_HAIR, this->ge), false);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
952 this->DrawFaceStringLabel(SCMFW_WIDGET_EYEBROWS, STR_FACE_EYEBROWS, GetCompanyManagerFaceBits(this->face, CMFV_EYEBROWS, this->ge), false);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
953 this->DrawFaceStringLabel(SCMFW_WIDGET_EYECOLOUR, STR_FACE_EYECOLOUR, GetCompanyManagerFaceBits(this->face, CMFV_EYE_COLOUR, this->ge), false);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
954 this->DrawFaceStringLabel(SCMFW_WIDGET_GLASSES, STR_FACE_GLASSES, GetCompanyManagerFaceBits(this->face, CMFV_GLASSES, this->ge), false);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
955 this->DrawFaceStringLabel(SCMFW_WIDGET_NOSE, STR_FACE_NOSE, GetCompanyManagerFaceBits(this->face, CMFV_NOSE, this->ge), false);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
956 this->DrawFaceStringLabel(SCMFW_WIDGET_CHIN, STR_FACE_CHIN, GetCompanyManagerFaceBits(this->face, CMFV_CHIN, this->ge), false);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
957 this->DrawFaceStringLabel(SCMFW_WIDGET_JACKET, STR_FACE_JACKET, GetCompanyManagerFaceBits(this->face, CMFV_JACKET, this->ge), false);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
958 this->DrawFaceStringLabel(SCMFW_WIDGET_COLLAR, STR_FACE_COLLAR, GetCompanyManagerFaceBits(this->face, CMFV_COLLAR, this->ge), false);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
959 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
960
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
961 /* Draw the company manager face picture */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
962 DrawCompanyManagerFace(this->face, GetCompany((CompanyID)this->window_number)->colour, 2, 16);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
963 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
964
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
965 virtual void OnClick(Point pt, int widget)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
966 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
967 switch (widget) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
968 /* Toggle size, advanced/simple face selection */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
969 case SCMFW_WIDGET_TOGGLE_LARGE_SMALL:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
970 case SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON: {
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10209
diff changeset
971 DoCommandP(0, 0, this->face, CMD_SET_COMPANY_MANAGER_FACE);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
972
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
973 /* Backup some data before deletion */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
974 int oldtop = this->top; ///< current top position of the window before closing it
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
975 int oldleft = this->left; ///< current top position of the window before closing it
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
976 bool adv = !this->advanced;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
977 Window *parent = this->parent;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
978
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
979 delete this;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
980
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
981 /* Open up the (toggled size) Face selection window at the same position as the previous */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
982 DoSelectCompanyManagerFace(parent, adv, oldtop, oldleft);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
983 } break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
984
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
985
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
986 /* OK button */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
987 case SCMFW_WIDGET_ACCEPT:
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10209
diff changeset
988 DoCommandP(0, 0, this->face, CMD_SET_COMPANY_MANAGER_FACE);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
989 /* Fall-Through */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
990
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
991 /* Cancel button */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
992 case SCMFW_WIDGET_CANCEL:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
993 delete this;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
994 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
995
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
996 /* Load button */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
997 case SCMFW_WIDGET_LOAD:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
998 this->face = _company_manager_face;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
999 ScaleAllCompanyManagerFaceBits(this->face);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1000 ShowErrorMessage(INVALID_STRING_ID, STR_FACE_LOAD_DONE, 0, 0);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1001 this->UpdateData();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1002 this->SetDirty();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1003 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1004
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1005 /* 'Company manager face number' button, view and/or set company manager face number */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1006 case SCMFW_WIDGET_FACECODE:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1007 SetDParam(0, this->face);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1008 ShowQueryString(STR_JUST_INT, STR_FACE_FACECODE_CAPTION, 10 + 1, 0, this, CS_NUMERAL, QSF_NONE);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1009 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1010
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1011 /* Save button */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1012 case SCMFW_WIDGET_SAVE:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1013 _company_manager_face = this->face;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1014 ShowErrorMessage(INVALID_STRING_ID, STR_FACE_SAVE_DONE, 0, 0);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1015 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1016
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1017 /* Toggle gender (male/female) button */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1018 case SCMFW_WIDGET_MALE:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1019 case SCMFW_WIDGET_FEMALE:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1020 SetCompanyManagerFaceBits(this->face, CMFV_GENDER, this->ge, widget - SCMFW_WIDGET_MALE);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1021 ScaleAllCompanyManagerFaceBits(this->face);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1022 this->UpdateData();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1023 this->SetDirty();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1024 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1025
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1026 /* Randomize face button */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1027 case SCMFW_WIDGET_RANDOM_NEW_FACE:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1028 RandomCompanyManagerFaceBits(this->face, this->ge, this->advanced);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1029 this->UpdateData();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1030 this->SetDirty();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1031 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1032
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1033 /* Toggle ethnicity (european/african) button */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1034 case SCMFW_WIDGET_ETHNICITY_EUR:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1035 case SCMFW_WIDGET_ETHNICITY_AFR:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1036 SetCompanyManagerFaceBits(this->face, CMFV_ETHNICITY, this->ge, widget - SCMFW_WIDGET_ETHNICITY_EUR);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1037 ScaleAllCompanyManagerFaceBits(this->face);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1038 this->UpdateData();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1039 this->SetDirty();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1040 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1041
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1042 default:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1043 /* For all buttons from SCMFW_WIDGET_HAS_MOUSTACHE_EARRING to SCMFW_WIDGET_GLASSES_R is the same function.
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11086
diff changeset
1044 * Therefor is this combined function.
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11086
diff changeset
1045 * First it checks which CompanyManagerFaceVariable will be change and then
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11086
diff changeset
1046 * a: invert the value for boolean variables
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11086
diff changeset
1047 * or b: it checks inside of IncreaseCompanyManagerFaceBits() if a left (_L) butten is pressed and then decrease else increase the variable */
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1048 if (this->advanced && widget >= SCMFW_WIDGET_HAS_MOUSTACHE_EARRING && widget <= SCMFW_WIDGET_GLASSES_R) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1049 CompanyManagerFaceVariable cmfv; // which CompanyManagerFaceVariable shall be edited
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1050
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1051 if (widget < SCMFW_WIDGET_EYECOLOUR_L) { // Bool buttons
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1052 switch (widget - SCMFW_WIDGET_HAS_MOUSTACHE_EARRING) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1053 default: NOT_REACHED();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1054 case 0: cmfv = this->is_female ? CMFV_HAS_TIE_EARRING : CMFV_HAS_MOUSTACHE; break; // Has earring/moustache button
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1055 case 1: cmfv = CMFV_HAS_GLASSES; break; // Has glasses button
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1056 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1057 SetCompanyManagerFaceBits(this->face, cmfv, this->ge, !GetCompanyManagerFaceBits(this->face, cmfv, this->ge));
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1058 ScaleAllCompanyManagerFaceBits(this->face);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1059 } else { // Value buttons
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1060 switch ((widget - SCMFW_WIDGET_EYECOLOUR_L) / 3) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1061 default: NOT_REACHED();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1062 case 0: cmfv = CMFV_EYE_COLOUR; break; // Eye colour buttons
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1063 case 1: cmfv = CMFV_CHIN; break; // Chin buttons
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1064 case 2: cmfv = CMFV_EYEBROWS; break; // Eyebrows buttons
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1065 case 3: cmfv = this->is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS; break; // Moustache or lips buttons
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1066 case 4: cmfv = CMFV_NOSE; break; // Nose buttons
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1067 case 5: cmfv = CMFV_HAIR; break; // Hair buttons
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1068 case 6: cmfv = CMFV_JACKET; break; // Jacket buttons
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1069 case 7: cmfv = CMFV_COLLAR; break; // Collar buttons
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1070 case 8: cmfv = CMFV_TIE_EARRING; break; // Tie/earring buttons
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1071 case 9: cmfv = CMFV_GLASSES; break; // Glasses buttons
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1072 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1073 /* 0 == left (_L), 1 == middle or 2 == right (_R) - button click */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1074 IncreaseCompanyManagerFaceBits(this->face, cmfv, this->ge, (((widget - SCMFW_WIDGET_EYECOLOUR_L) % 3) != 0) ? 1 : -1);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1075 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1076 this->UpdateData();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1077 this->SetDirty();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1078 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1079 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1080 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1081 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1082
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1083 virtual void OnQueryTextFinished(char *str)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1084 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1085 if (str == NULL) return;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1086 /* Set a new company manager face number */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1087 if (!StrEmpty(str)) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1088 this->face = strtoul(str, NULL, 10);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1089 ScaleAllCompanyManagerFaceBits(this->face);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1090 ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_SET, 0, 0);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1091 this->UpdateData();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1092 this->SetDirty();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1093 } else {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1094 ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_ERR, 0, 0);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1095 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1096 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1097 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1098
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1099 /** normal/simple company manager face selection window description */
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1100 static const WindowDesc _select_company_manager_face_desc(
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1101 WDP_AUTO, WDP_AUTO, 190, 163, 190, 163,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1102 WC_COMPANY_MANAGER_FACE, WC_NONE,
10998
a1d256bf72e0 (svn r15338) -Fix [FS#2598]: close all construction related windows whenever changing company.
rubidium <rubidium@openttd.org>
parents: 10962
diff changeset
1103 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_CONSTRUCTION,
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1104 _select_company_manager_face_widgets
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1105 );
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1106
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1107 /** advanced company manager face selection window description */
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1108 static const WindowDesc _select_company_manager_face_adv_desc(
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1109 WDP_AUTO, WDP_AUTO, 220, 220, 220, 220,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1110 WC_COMPANY_MANAGER_FACE, WC_NONE,
10998
a1d256bf72e0 (svn r15338) -Fix [FS#2598]: close all construction related windows whenever changing company.
rubidium <rubidium@openttd.org>
parents: 10962
diff changeset
1111 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_CONSTRUCTION,
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1112 _select_company_manager_face_adv_widgets
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1113 );
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1114
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1115 /**
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1116 * Open the simple/advanced company manager face selection window
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1117 *
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1118 * @param parent the parent company window
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1119 * @param adv simple or advanced face selection window
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1120 * @param top previous top position of the window
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1121 * @param left previous left position of the window
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1122 */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1123 static void DoSelectCompanyManagerFace(Window *parent, bool adv, int top, int left)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1124 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1125 if (!IsValidCompanyID((CompanyID)parent->window_number)) return;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1126
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1127 if (BringWindowToFrontById(WC_COMPANY_MANAGER_FACE, parent->window_number)) return;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1128 new SelectCompanyManagerFaceWindow(adv ? &_select_company_manager_face_adv_desc : &_select_company_manager_face_desc, parent, adv, top, left); // simple or advanced window
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1129 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1130
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1131
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1132 /* Names of the widgets. Keep them in the same order as in the widget array */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1133 enum CompanyWindowWidgets {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1134 CW_WIDGET_CLOSEBOX = 0,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1135 CW_WIDGET_CAPTION,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1136 CW_WIDGET_FACE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1137 CW_WIDGET_NEW_FACE,
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
1138 CW_WIDGET_COLOUR_SCHEME,
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1139 CW_WIDGET_PRESIDENT_NAME,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1140 CW_WIDGET_COMPANY_NAME,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1141 CW_WIDGET_BUILD_VIEW_HQ,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1142 CW_WIDGET_RELOCATE_HQ,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1143 CW_WIDGET_BUY_SHARE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1144 CW_WIDGET_SELL_SHARE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1145 CW_WIDGET_COMPANY_PASSWORD,
10907
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1146 CW_WIDGET_COMPANY_JOIN,
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1147 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1148
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1149 static const Widget _company_widgets[] = {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1150 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1151 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 359, 0, 13, STR_7001, STR_018C_WINDOW_TITLE_DRAG_THIS},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1152 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 359, 14, 157, 0x0, STR_NULL},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1153 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 89, 158, 169, STR_7004_NEW_FACE, STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT},
11086
23adfa4f7d5a (svn r15429) -Change: do r15428 also for the string names.
rubidium <rubidium@openttd.org>
parents: 11085
diff changeset
1154 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 90, 179, 158, 169, STR_7005_COLOUR_SCHEME, STR_7031_CHANGE_THE_COMPANY_VEHICLE},
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1155 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 180, 269, 158, 169, STR_7009_PRESIDENT_NAME, STR_7032_CHANGE_THE_PRESIDENT_S},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1156 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 270, 359, 158, 169, STR_7008_COMPANY_NAME, STR_7033_CHANGE_THE_COMPANY_NAME},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1157 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 266, 355, 18, 29, STR_7072_VIEW_HQ, STR_7070_BUILD_COMPANY_HEADQUARTERS},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1158 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 266, 355, 32, 43, STR_RELOCATE_HQ, STR_RELOCATE_COMPANY_HEADQUARTERS},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1159 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 179, 158, 169, STR_7077_BUY_25_SHARE_IN_COMPANY, STR_7079_BUY_25_SHARE_IN_THIS_COMPANY},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1160 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 180, 359, 158, 169, STR_7078_SELL_25_SHARE_IN_COMPANY, STR_707A_SELL_25_SHARE_IN_THIS_COMPANY},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1161 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 266, 355, 138, 149, STR_COMPANY_PASSWORD, STR_COMPANY_PASSWORD_TOOLTIP},
10912
338906f990f4 (svn r15247) -Change: show a lock near the password/join button in the company window whenever the company is password protected
rubidium <rubidium@openttd.org>
parents: 10907
diff changeset
1162 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 266, 355, 138, 149, STR_COMPANY_JOIN, STR_COMPANY_JOIN_TIP},
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1163 { WIDGETS_END},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1164 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1165
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1166
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1167 /**
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1168 * Draws text "Vehicles:" and number of all vehicle types, or "(none)"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1169 * @param company ID of company to print statistics of
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1170 */
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
1171 static void DrawCompanyVehiclesAmount(CompanyID company, int right)
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1172 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1173 const int x = 110;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1174 int y = 63;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1175 const Vehicle *v;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1176 uint train = 0;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1177 uint road = 0;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1178 uint air = 0;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1179 uint ship = 0;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1180
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
1181 DrawString(x, right, y, STR_7039_VEHICLES, TC_FROMSTRING);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1182
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1183 FOR_ALL_VEHICLES(v) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1184 if (v->owner == company) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1185 switch (v->type) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1186 case VEH_TRAIN: if (IsFrontEngine(v)) train++; break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1187 case VEH_ROAD: if (IsRoadVehFront(v)) road++; break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1188 case VEH_AIRCRAFT: if (IsNormalAircraft(v)) air++; break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1189 case VEH_SHIP: ship++; break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1190 default: break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1191 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1192 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1193 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1194
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1195 if (train + road + air + ship == 0) {
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
1196 DrawString(x + 70, right, y, STR_7042_NONE, TC_FROMSTRING);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1197 } else {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1198 if (train != 0) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1199 SetDParam(0, train);
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
1200 DrawString(x + 70, right, y, STR_TRAINS, TC_FROMSTRING);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1201 y += 10;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1202 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1203
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1204 if (road != 0) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1205 SetDParam(0, road);
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
1206 DrawString(x + 70, right, y, STR_ROAD_VEHICLES, TC_FROMSTRING);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1207 y += 10;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1208 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1209
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1210 if (air != 0) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1211 SetDParam(0, air);
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
1212 DrawString(x + 70, right, y, STR_AIRCRAFT, TC_FROMSTRING);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1213 y += 10;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1214 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1215
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1216 if (ship != 0) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1217 SetDParam(0, ship);
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
1218 DrawString(x + 70, right, y, STR_SHIPS, TC_FROMSTRING);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1219 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1220 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1221 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1222
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1223 int GetAmountOwnedBy(const Company *c, Owner owner)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1224 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1225 return (c->share_owners[0] == owner) +
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1226 (c->share_owners[1] == owner) +
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1227 (c->share_owners[2] == owner) +
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1228 (c->share_owners[3] == owner);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1229 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1230
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1231 /**
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1232 * Draws list of all companies with shares
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1233 * @param c pointer to the Company structure
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1234 */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1235 static void DrawCompanyOwnerText(const Company *c)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1236 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1237 const Company *c2;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1238 uint num = 0;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1239 const byte height = GetCharacterHeight(FS_NORMAL);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1240
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1241 FOR_ALL_COMPANIES(c2) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1242 uint amt = GetAmountOwnedBy(c, c2->index);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1243 if (amt != 0) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1244 SetDParam(0, amt * 25);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1245 SetDParam(1, c2->index);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1246
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
1247 DrawString(120, 359, (num++) * height + 116, STR_707D_OWNED_BY, TC_FROMSTRING);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1248 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1249 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1250 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1251
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1252 /**
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1253 * Window with general information about a company
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1254 */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1255 struct CompanyWindow : Window
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1256 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1257 CompanyWindowWidgets query_widget;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1258
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1259 CompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1260 {
11084
e07c7d3925c8 (svn r15427) -Codechange: give w->caption_color a more sensible name as it holds the owner of whatever is shown in the window
rubidium <rubidium@openttd.org>
parents: 10998
diff changeset
1261 this->owner = (Owner)this->window_number;
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1262 this->FindWindowPlacementAndResize(desc);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1263 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1264
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1265 virtual void OnPaint()
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1266 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1267 const Company *c = GetCompany((CompanyID)this->window_number);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1268 bool local = this->window_number == _local_company;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1269
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1270 this->SetWidgetHiddenState(CW_WIDGET_NEW_FACE, !local);
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
1271 this->SetWidgetHiddenState(CW_WIDGET_COLOUR_SCHEME, !local);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1272 this->SetWidgetHiddenState(CW_WIDGET_PRESIDENT_NAME, !local);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1273 this->SetWidgetHiddenState(CW_WIDGET_COMPANY_NAME, !local);
10555
315add01cf91 (svn r14812) -Codechange: use INVALID_TILE instead of 0 to mark company without HQ
smatz <smatz@openttd.org>
parents: 10500
diff changeset
1274 this->widget[CW_WIDGET_BUILD_VIEW_HQ].data = (local && c->location_of_HQ == INVALID_TILE) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ;
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
1275 if (local && c->location_of_HQ != INVALID_TILE) this->widget[CW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // HQ is already built.
10555
315add01cf91 (svn r14812) -Codechange: use INVALID_TILE instead of 0 to mark company without HQ
smatz <smatz@openttd.org>
parents: 10500
diff changeset
1276 this->SetWidgetDisabledState(CW_WIDGET_BUILD_VIEW_HQ, !local && c->location_of_HQ == INVALID_TILE);
315add01cf91 (svn r14812) -Codechange: use INVALID_TILE instead of 0 to mark company without HQ
smatz <smatz@openttd.org>
parents: 10500
diff changeset
1277 this->SetWidgetHiddenState(CW_WIDGET_RELOCATE_HQ, !local || c->location_of_HQ == INVALID_TILE);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1278 this->SetWidgetHiddenState(CW_WIDGET_BUY_SHARE, local);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1279 this->SetWidgetHiddenState(CW_WIDGET_SELL_SHARE, local);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1280 this->SetWidgetHiddenState(CW_WIDGET_COMPANY_PASSWORD, !local || !_networking);
10907
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1281 this->SetWidgetHiddenState(CW_WIDGET_COMPANY_JOIN, local || !_networking);
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1282 this->SetWidgetDisabledState(CW_WIDGET_COMPANY_JOIN, !IsHumanCompany(c->index));
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1283
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1284 if (!local) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1285 if (_settings_game.economy.allow_shares) { // Shares are allowed
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1286 /* If all shares are owned by someone (none by nobody), disable buy button */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1287 this->SetWidgetDisabledState(CW_WIDGET_BUY_SHARE, GetAmountOwnedBy(c, INVALID_OWNER) == 0 ||
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1288 /* Only 25% left to buy. If the company is human, disable buying it up.. TODO issues! */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1289 (GetAmountOwnedBy(c, INVALID_OWNER) == 1 && !c->is_ai) ||
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1290 /* Spectators cannot do anything of course */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1291 _local_company == COMPANY_SPECTATOR);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1292
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1293 /* If the company doesn't own any shares, disable sell button */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1294 this->SetWidgetDisabledState(CW_WIDGET_SELL_SHARE, (GetAmountOwnedBy(c, _local_company) == 0) ||
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1295 /* Spectators cannot do anything of course */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1296 _local_company == COMPANY_SPECTATOR);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1297 } else { // Shares are not allowed, disable buy/sell buttons
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1298 this->DisableWidget(CW_WIDGET_BUY_SHARE);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1299 this->DisableWidget(CW_WIDGET_SELL_SHARE);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1300 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1301 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1302
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1303 SetDParam(0, c->index);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1304 SetDParam(1, c->index);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1305
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1306 this->DrawWidgets();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1307
10912
338906f990f4 (svn r15247) -Change: show a lock near the password/join button in the company window whenever the company is password protected
rubidium <rubidium@openttd.org>
parents: 10907
diff changeset
1308 #ifdef ENABLE_NETWORK
338906f990f4 (svn r15247) -Change: show a lock near the password/join button in the company window whenever the company is password protected
rubidium <rubidium@openttd.org>
parents: 10907
diff changeset
1309 if (_networking && NetworkCompanyIsPassworded(c->index)) {
338906f990f4 (svn r15247) -Change: show a lock near the password/join button in the company window whenever the company is password protected
rubidium <rubidium@openttd.org>
parents: 10907
diff changeset
1310 DrawSprite(SPR_LOCK, PAL_NONE, this->widget[CW_WIDGET_COMPANY_JOIN].left - 10, this->widget[CW_WIDGET_COMPANY_JOIN].top + 2);
338906f990f4 (svn r15247) -Change: show a lock near the password/join button in the company window whenever the company is password protected
rubidium <rubidium@openttd.org>
parents: 10907
diff changeset
1311 }
338906f990f4 (svn r15247) -Change: show a lock near the password/join button in the company window whenever the company is password protected
rubidium <rubidium@openttd.org>
parents: 10907
diff changeset
1312 #endif /* ENABLE_NETWORK */
338906f990f4 (svn r15247) -Change: show a lock near the password/join button in the company window whenever the company is password protected
rubidium <rubidium@openttd.org>
parents: 10907
diff changeset
1313
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1314 /* Company manager's face */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1315 DrawCompanyManagerFace(c->face, c->colour, 2, 16);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1316
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1317 /* "xxx (Manager)" */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1318 SetDParam(0, c->index);
11445
231379be7cf9 (svn r15803) -Codechange: use the new text drawing API for multicenter
rubidium <rubidium@openttd.org>
parents: 11433
diff changeset
1319 DrawStringMultiLine(48 - MAX_LENGTH_PRESIDENT_NAME_PIXELS / 2, 48 + MAX_LENGTH_PRESIDENT_NAME_PIXELS / 2, 135, 157, STR_7037_PRESIDENT, SA_CENTER);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1320
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1321 /* "Inaugurated:" */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1322 SetDParam(0, c->inaugurated_year);
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
1323 DrawString(110, this->width, 23, STR_7038_INAUGURATED, TC_FROMSTRING);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1324
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1325 /* "Colour scheme:" */
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
1326 DrawString(110, this->width, 43, STR_7006_COLOUR_SCHEME, TC_FROMSTRING);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1327 /* Draw company-colour bus */
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
1328 DrawSprite(SPR_VEH_BUS_SW_VIEW, COMPANY_SPRITE_COLOUR(c->index), 215, 44);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1329
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1330 /* "Vehicles:" */
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
1331 DrawCompanyVehiclesAmount((CompanyID)this->window_number, this->width);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1332
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1333 /* "Company value:" */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1334 SetDParam(0, CalculateCompanyValue(c));
11450
4557701373cc (svn r15808) -Codechange: use the new DrawString API in a number of GUIs
rubidium <rubidium@openttd.org>
parents: 11445
diff changeset
1335 DrawString(110, this->width, 106, STR_7076_COMPANY_VALUE, TC_FROMSTRING);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1336
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1337 /* Shares list */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1338 DrawCompanyOwnerText(c);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1339 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1340
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1341 virtual void OnClick(Point pt, int widget)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1342 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1343 switch (widget) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1344 case CW_WIDGET_NEW_FACE: DoSelectCompanyManagerFace(this, false); break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1345
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
1346 case CW_WIDGET_COLOUR_SCHEME:
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
1347 if (BringWindowToFrontById(WC_COMPANY_COLOUR, this->window_number)) break;
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1348 new SelectCompanyLiveryWindow(&_select_company_livery_desc, (CompanyID)this->window_number);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1349 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1350
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1351 case CW_WIDGET_PRESIDENT_NAME:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1352 this->query_widget = CW_WIDGET_PRESIDENT_NAME;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1353 SetDParam(0, this->window_number);
10209
e5c7b57fa344 (svn r14423) -Codechange: also do r14221 for the strings.
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
1354 ShowQueryString(STR_PRESIDENT_NAME, STR_700B_PRESIDENT_S_NAME, MAX_LENGTH_PRESIDENT_NAME_BYTES, MAX_LENGTH_PRESIDENT_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1355 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1356
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1357 case CW_WIDGET_COMPANY_NAME:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1358 this->query_widget = CW_WIDGET_COMPANY_NAME;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1359 SetDParam(0, this->window_number);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1360 ShowQueryString(STR_COMPANY_NAME, STR_700A_COMPANY_NAME, MAX_LENGTH_COMPANY_NAME_BYTES, MAX_LENGTH_COMPANY_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1361 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1362
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1363 case CW_WIDGET_BUILD_VIEW_HQ: {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1364 TileIndex tile = GetCompany((CompanyID)this->window_number)->location_of_HQ;
10555
315add01cf91 (svn r14812) -Codechange: use INVALID_TILE instead of 0 to mark company without HQ
smatz <smatz@openttd.org>
parents: 10500
diff changeset
1365 if (tile == INVALID_TILE) {
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1366 if ((byte)this->window_number != _local_company) return;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1367 SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, this);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1368 SetTileSelectSize(2, 2);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1369 this->LowerWidget(CW_WIDGET_BUILD_VIEW_HQ);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1370 this->InvalidateWidget(CW_WIDGET_BUILD_VIEW_HQ);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1371 } else {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1372 if (_ctrl_pressed) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1373 ShowExtraViewPortWindow(tile);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1374 } else {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1375 ScrollMainWindowToTile(tile);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1376 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1377 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1378 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1379 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1380
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1381 case CW_WIDGET_RELOCATE_HQ:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1382 SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, this);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1383 SetTileSelectSize(2, 2);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1384 this->LowerWidget(CW_WIDGET_RELOCATE_HQ);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1385 this->InvalidateWidget(CW_WIDGET_RELOCATE_HQ);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1386 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1387
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1388 case CW_WIDGET_BUY_SHARE:
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10209
diff changeset
1389 DoCommandP(0, this->window_number, 0, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS));
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1390 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1391
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1392 case CW_WIDGET_SELL_SHARE:
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10209
diff changeset
1393 DoCommandP(0, this->window_number, 0, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN));
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1394 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1395
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1396 #ifdef ENABLE_NETWORK
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1397 case CW_WIDGET_COMPANY_PASSWORD:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1398 if (this->window_number == _local_company) ShowNetworkCompanyPasswordWindow(this);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1399 break;
10907
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1400
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1401 case CW_WIDGET_COMPANY_JOIN: {
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1402 this->query_widget = CW_WIDGET_COMPANY_JOIN;
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1403 CompanyID company = (CompanyID)this->window_number;
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1404 if (_network_server) {
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1405 NetworkServerDoMove(CLIENT_ID_SERVER, company);
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1406 MarkWholeScreenDirty();
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1407 } else if (NetworkCompanyIsPassworded(company)) {
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1408 /* ask for the password */
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1409 ShowQueryString(STR_EMPTY, STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION, 20, 180, this, CS_ALPHANUMERAL, QSF_NONE);
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1410 } else {
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1411 /* just send the join command */
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1412 NetworkClientRequestMove(company);
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1413 }
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1414 break;
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1415 }
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1416 #endif /* ENABLE_NETWORK */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1417 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1418 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1419
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1420 virtual void OnHundredthTick()
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1421 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1422 /* redraw the window every now and then */
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1423 this->SetDirty();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1424 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1425
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1426 virtual void OnPlaceObject(Point pt, TileIndex tile)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1427 {
10606
4b69f32abb9d (svn r14895) -Change: move CMD_NO_WATER from all DoCommandPs to the command table
rubidium <rubidium@openttd.org>
parents: 10558
diff changeset
1428 if (DoCommandP(tile, 0, 0, CMD_BUILD_COMPANY_HQ | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS)))
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1429 ResetObjectToPlace();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1430 this->widget[CW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // this button can now behave as a normal push button
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1431 this->RaiseButtons();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1432 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1433
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1434 virtual void OnPlaceObjectAbort()
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1435 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1436 this->RaiseButtons();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1437 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1438
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1439 virtual void OnQueryTextFinished(char *str)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1440 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1441 if (str == NULL) return;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1442
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1443 switch (this->query_widget) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1444 default: NOT_REACHED();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1445
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1446 case CW_WIDGET_PRESIDENT_NAME:
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10209
diff changeset
1447 DoCommandP(0, 0, 0, CMD_RENAME_PRESIDENT | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT), NULL, str);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1448 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1449
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1450 case CW_WIDGET_COMPANY_NAME:
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10209
diff changeset
1451 DoCommandP(0, 0, 0, CMD_RENAME_COMPANY | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME), NULL, str);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1452 break;
10907
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1453
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1454 #ifdef ENABLE_NETWORK
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1455 case CW_WIDGET_COMPANY_JOIN:
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1456 NetworkClientRequestMove((CompanyID)this->window_number, str);
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1457 break;
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10606
diff changeset
1458 #endif /* ENABLE_NETWORK */
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1459 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1460 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1461 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1462
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1463 static const WindowDesc _company_desc(
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1464 WDP_AUTO, WDP_AUTO, 360, 170, 360, 170,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1465 WC_COMPANY, WC_NONE,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1466 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1467 _company_widgets
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1468 );
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1469
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1470 void ShowCompany(CompanyID company)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1471 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1472 if (!IsValidCompanyID(company)) return;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1473
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1474 AllocateWindowDescFront<CompanyWindow>(&_company_desc, company);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1475 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1476
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1477
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1478
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1479 struct BuyCompanyWindow : Window {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1480 BuyCompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1481 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1482 this->FindWindowPlacementAndResize(desc);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1483 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1484
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1485 virtual void OnPaint()
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1486 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1487 Company *c = GetCompany((CompanyID)this->window_number);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1488 SetDParam(0, STR_COMPANY_NAME);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1489 SetDParam(1, c->index);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1490 this->DrawWidgets();
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1491
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1492 DrawCompanyManagerFace(c->face, c->colour, 2, 16);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1493
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1494 SetDParam(0, c->index);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1495 SetDParam(1, c->bankrupt_value);
11445
231379be7cf9 (svn r15803) -Codechange: use the new text drawing API for multicenter
rubidium <rubidium@openttd.org>
parents: 11433
diff changeset
1496 DrawStringMultiLine(95, 333, 26, 116, STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT, SA_CENTER);
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1497 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1498
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1499 virtual void OnClick(Point pt, int widget)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1500 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1501 switch (widget) {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1502 case 3:
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1503 delete this;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1504 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1505
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1506 case 4:
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10209
diff changeset
1507 DoCommandP(0, this->window_number, 0, CMD_BUY_COMPANY | CMD_MSG(STR_7060_CAN_T_BUY_COMPANY));
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1508 break;
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1509 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1510 }
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1511 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1512
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1513 static const Widget _buy_company_widgets[] = {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1514 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_LIGHT_BLUE, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1515 { WWT_CAPTION, RESIZE_NONE, COLOUR_LIGHT_BLUE, 11, 333, 0, 13, STR_00B3_MESSAGE_FROM, STR_018C_WINDOW_TITLE_DRAG_THIS},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1516 { WWT_PANEL, RESIZE_NONE, COLOUR_LIGHT_BLUE, 0, 333, 14, 136, 0x0, STR_NULL},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1517 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_LIGHT_BLUE, 148, 207, 117, 128, STR_00C9_NO, STR_NULL},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1518 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_LIGHT_BLUE, 218, 277, 117, 128, STR_00C8_YES, STR_NULL},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1519 { WIDGETS_END},
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1520 };
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1521
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1522 static const WindowDesc _buy_company_desc(
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1523 153, 171, 334, 137, 334, 137,
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1524 WC_BUY_COMPANY, WC_NONE,
10998
a1d256bf72e0 (svn r15338) -Fix [FS#2598]: close all construction related windows whenever changing company.
rubidium <rubidium@openttd.org>
parents: 10962
diff changeset
1525 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_CONSTRUCTION,
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1526 _buy_company_widgets
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1527 );
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1528
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1529
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1530 void ShowBuyCompanyDialog(CompanyID company)
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1531 {
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1532 AllocateWindowDescFront<BuyCompanyWindow>(&_buy_company_desc, company);
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1533 }