Mercurial > hg > openttd
annotate src/newgrf_gui.cpp @ 15563:011c8bee59d1 draft
(svn r20223) -Codechange: Replace scrolled row calculations by a call to GetScrolledRowFromWidget().
author | alberth <alberth@openttd.org> |
---|---|
date | Mon, 26 Jul 2010 13:08:48 +0000 (2010-07-26) |
parents | 14828f61eda6 |
children | 5f128be91f59 |
rev | line source |
---|---|
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2 |
12778
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
3 /* |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
4 * This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
8 */ |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
9 |
9111
d48433370037
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents:
8749
diff
changeset
|
10 /** @file newgrf_gui.cpp GUI to change NewGRF settings. */ |
6348
bcf98ba27bbf
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
11 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
12 #include "stdafx.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
13 #include "gui.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
14 #include "newgrf.h" |
8114
2d6af5d7a142
(svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
8107
diff
changeset
|
15 #include "strings_func.h" |
8131
e300ac8001ae
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium <rubidium@openttd.org>
parents:
8130
diff
changeset
|
16 #include "window_func.h" |
9457
267a95510fdf
(svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents:
9317
diff
changeset
|
17 #include "gamelog.h" |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
18 #include "settings_func.h" |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
19 #include "widgets/dropdown_type.h" |
10793
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
20 #include "network/network.h" |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
21 #include "network/network_content.h" |
13043
8eef3a6e299f
(svn r17541) -Feature: Filtering in Add-NewGRF dialog.
frosch <frosch@openttd.org>
parents:
13020
diff
changeset
|
22 #include "sortlist_type.h" |
8eef3a6e299f
(svn r17541) -Feature: Filtering in Add-NewGRF dialog.
frosch <frosch@openttd.org>
parents:
13020
diff
changeset
|
23 #include "querystring_gui.h" |
14258
a899d4e5ee1a
(svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, if a header require a header make it include that header
rubidium <rubidium@openttd.org>
parents:
14149
diff
changeset
|
24 #include "core/geometry_func.hpp" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
25 |
8264
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8224
diff
changeset
|
26 #include "table/strings.h" |
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8224
diff
changeset
|
27 #include "table/sprites.h" |
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8224
diff
changeset
|
28 |
13968
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
29 /** |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
30 * Show the first NewGRF error we can find. |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
31 */ |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
32 void ShowNewGRFError() |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
33 { |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
34 for (const GRFConfig *c = _grfconfig; c != NULL; c = c->next) { |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
35 /* We only want to show fatal errors */ |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
36 if (c->error == NULL || c->error->severity != STR_NEWGRF_ERROR_MSG_FATAL) continue; |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
37 |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
38 SetDParam (0, c->error->custom_message == NULL ? c->error->message : STR_JUST_RAW_STRING); |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
39 SetDParamStr(1, c->error->custom_message); |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
40 SetDParam (2, STR_JUST_RAW_STRING); |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
41 SetDParamStr(3, c->filename); |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
42 SetDParam (4, STR_JUST_RAW_STRING); |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
43 SetDParamStr(5, c->error->data); |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
44 for (uint i = 0; i < c->error->num_params; i++) { |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
45 SetDParam(6 + i, c->error->param_value[i]); |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
46 } |
14645
b7a22979b84e
(svn r19224) -Codechange: change parameters passed to ShowErrorMessage() a bit
smatz <smatz@openttd.org>
parents:
14561
diff
changeset
|
47 ShowErrorMessage(STR_NEWGRF_ERROR_FATAL_POPUP, INVALID_STRING_ID, WL_CRITICAL); |
13968
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
48 break; |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
49 } |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
50 } |
070572f1272d
(svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
51 |
13017
ab07d6d87608
(svn r17511) -Codechange: Simplify ShowNewGRFInfo() by passing 'right' instead of 'width'.
frosch <frosch@openttd.org>
parents:
12879
diff
changeset
|
52 static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint right, uint bottom, bool show_params) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
53 { |
6103
e3a3a903fa28
(svn r8838) -Feature: Show newgrf error messages loaded in Action B in the newgrf gui
maedhros <maedhros@openttd.org>
parents:
5893
diff
changeset
|
54 if (c->error != NULL) { |
9648
b53049484e44
(svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents:
9457
diff
changeset
|
55 char message[512]; |
9957
2416082e752c
(svn r14112) -Fix (r13715)[FS#2232]: Action B custom messages with parameteers were broken.
frosch <frosch@openttd.org>
parents:
9864
diff
changeset
|
56 SetDParamStr(0, c->error->custom_message); // is skipped by built-in messages |
2416082e752c
(svn r14112) -Fix (r13715)[FS#2232]: Action B custom messages with parameteers were broken.
frosch <frosch@openttd.org>
parents:
9864
diff
changeset
|
57 SetDParam (1, STR_JUST_RAW_STRING); |
2416082e752c
(svn r14112) -Fix (r13715)[FS#2232]: Action B custom messages with parameteers were broken.
frosch <frosch@openttd.org>
parents:
9864
diff
changeset
|
58 SetDParamStr(2, c->filename); |
2416082e752c
(svn r14112) -Fix (r13715)[FS#2232]: Action B custom messages with parameteers were broken.
frosch <frosch@openttd.org>
parents:
9864
diff
changeset
|
59 SetDParam (3, STR_JUST_RAW_STRING); |
2416082e752c
(svn r14112) -Fix (r13715)[FS#2232]: Action B custom messages with parameteers were broken.
frosch <frosch@openttd.org>
parents:
9864
diff
changeset
|
60 SetDParamStr(4, c->error->data); |
2416082e752c
(svn r14112) -Fix (r13715)[FS#2232]: Action B custom messages with parameteers were broken.
frosch <frosch@openttd.org>
parents:
9864
diff
changeset
|
61 for (uint i = 0; i < c->error->num_params; i++) { |
11833
e4d9da4d81eb
(svn r16223) -Fix (r8881): ActionB should use the online parameters from GRFFile instead of the initial user-specified values from GRFConfig. Also use the values as they were set when the ActionB was executed, not as they are set when the message is shown.
frosch <frosch@openttd.org>
parents:
11796
diff
changeset
|
62 SetDParam(5 + i, c->error->param_value[i]); |
6139
3c76c0f47447
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros <maedhros@openttd.org>
parents:
6103
diff
changeset
|
63 } |
9957
2416082e752c
(svn r14112) -Fix (r13715)[FS#2232]: Action B custom messages with parameteers were broken.
frosch <frosch@openttd.org>
parents:
9864
diff
changeset
|
64 GetString(message, c->error->custom_message == NULL ? c->error->message : STR_JUST_RAW_STRING, lastof(message)); |
6139
3c76c0f47447
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros <maedhros@openttd.org>
parents:
6103
diff
changeset
|
65 |
3c76c0f47447
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros <maedhros@openttd.org>
parents:
6103
diff
changeset
|
66 SetDParamStr(0, message); |
13017
ab07d6d87608
(svn r17511) -Codechange: Simplify ShowNewGRFInfo() by passing 'right' instead of 'width'.
frosch <frosch@openttd.org>
parents:
12879
diff
changeset
|
67 y = DrawStringMultiLine(x, right, y, bottom, c->error->severity); |
6103
e3a3a903fa28
(svn r8838) -Feature: Show newgrf error messages loaded in Action B in the newgrf gui
maedhros <maedhros@openttd.org>
parents:
5893
diff
changeset
|
68 } |
e3a3a903fa28
(svn r8838) -Feature: Show newgrf error messages loaded in Action B in the newgrf gui
maedhros <maedhros@openttd.org>
parents:
5893
diff
changeset
|
69 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
70 /* Draw filename or not if it is not known (GRF sent over internet) */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
71 if (c->filename != NULL) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
72 SetDParamStr(0, c->filename); |
13017
ab07d6d87608
(svn r17511) -Codechange: Simplify ShowNewGRFInfo() by passing 'right' instead of 'width'.
frosch <frosch@openttd.org>
parents:
12879
diff
changeset
|
73 y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_FILENAME); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
74 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
75 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
76 /* Prepare and draw GRF ID */ |
15201
071e920abcfb
(svn r19830) -Codechange: Move variable declarations to their first use.
alberth <alberth@openttd.org>
parents:
15200
diff
changeset
|
77 char buff[256]; |
14676
353df593bee0
(svn r19255) -Codechange: encapsulate GRFIdentifier in GRFConfig instead of subclassing it
yexo <yexo@openttd.org>
parents:
14645
diff
changeset
|
78 snprintf(buff, lengthof(buff), "%08X", BSWAP32(c->ident.grfid)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
79 SetDParamStr(0, buff); |
13017
ab07d6d87608
(svn r17511) -Codechange: Simplify ShowNewGRFInfo() by passing 'right' instead of 'width'.
frosch <frosch@openttd.org>
parents:
12879
diff
changeset
|
80 y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_GRF_ID); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
81 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
82 /* Prepare and draw MD5 sum */ |
14676
353df593bee0
(svn r19255) -Codechange: encapsulate GRFIdentifier in GRFConfig instead of subclassing it
yexo <yexo@openttd.org>
parents:
14645
diff
changeset
|
83 md5sumToString(buff, lastof(buff), c->ident.md5sum); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
84 SetDParamStr(0, buff); |
13017
ab07d6d87608
(svn r17511) -Codechange: Simplify ShowNewGRFInfo() by passing 'right' instead of 'width'.
frosch <frosch@openttd.org>
parents:
12879
diff
changeset
|
85 y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_MD5SUM); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
86 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
87 /* Show GRF parameter list */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
88 if (show_params) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
89 if (c->num_params > 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
90 GRFBuildParamList(buff, c, lastof(buff)); |
9648
b53049484e44
(svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents:
9457
diff
changeset
|
91 SetDParam(0, STR_JUST_RAW_STRING); |
b53049484e44
(svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents:
9457
diff
changeset
|
92 SetDParamStr(1, buff); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
93 } else { |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11524
diff
changeset
|
94 SetDParam(0, STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
95 } |
13017
ab07d6d87608
(svn r17511) -Codechange: Simplify ShowNewGRFInfo() by passing 'right' instead of 'width'.
frosch <frosch@openttd.org>
parents:
12879
diff
changeset
|
96 y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_PARAMETER); |
10126
c5ceca8952d5
(svn r14310) -Fix: don't show palette information in the newgrf lists of the network lobby.
rubidium <rubidium@openttd.org>
parents:
10115
diff
changeset
|
97 |
c5ceca8952d5
(svn r14310) -Fix: don't show palette information in the newgrf lists of the network lobby.
rubidium <rubidium@openttd.org>
parents:
10115
diff
changeset
|
98 /* Draw the palette of the NewGRF */ |
c5ceca8952d5
(svn r14310) -Fix: don't show palette information in the newgrf lists of the network lobby.
rubidium <rubidium@openttd.org>
parents:
10115
diff
changeset
|
99 SetDParamStr(0, c->windows_paletted ? "Windows" : "DOS"); |
13017
ab07d6d87608
(svn r17511) -Codechange: Simplify ShowNewGRFInfo() by passing 'right' instead of 'width'.
frosch <frosch@openttd.org>
parents:
12879
diff
changeset
|
100 y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_PALETTE); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
101 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
102 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
103 /* Show flags */ |
13017
ab07d6d87608
(svn r17511) -Codechange: Simplify ShowNewGRFInfo() by passing 'right' instead of 'width'.
frosch <frosch@openttd.org>
parents:
12879
diff
changeset
|
104 if (c->status == GCS_NOT_FOUND) y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_NOT_FOUND); |
ab07d6d87608
(svn r17511) -Codechange: Simplify ShowNewGRFInfo() by passing 'right' instead of 'width'.
frosch <frosch@openttd.org>
parents:
12879
diff
changeset
|
105 if (c->status == GCS_DISABLED) y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_DISABLED); |
ab07d6d87608
(svn r17511) -Codechange: Simplify ShowNewGRFInfo() by passing 'right' instead of 'width'.
frosch <frosch@openttd.org>
parents:
12879
diff
changeset
|
106 if (HasBit(c->flags, GCF_COMPATIBLE)) y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_COMPATIBLE_LOADED); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
107 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
108 /* Draw GRF info if it exists */ |
14711
74b0a8a64ff5
(svn r19295) -Codechange: introduce wrapper functions for GRFConfig::name/info
yexo <yexo@openttd.org>
parents:
14676
diff
changeset
|
109 if (!StrEmpty(c->GetDescription())) { |
9648
b53049484e44
(svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents:
9457
diff
changeset
|
110 SetDParam(0, STR_JUST_RAW_STRING); |
14711
74b0a8a64ff5
(svn r19295) -Codechange: introduce wrapper functions for GRFConfig::name/info
yexo <yexo@openttd.org>
parents:
14676
diff
changeset
|
111 SetDParamStr(1, c->GetDescription()); |
13017
ab07d6d87608
(svn r17511) -Codechange: Simplify ShowNewGRFInfo() by passing 'right' instead of 'width'.
frosch <frosch@openttd.org>
parents:
12879
diff
changeset
|
112 y = DrawStringMultiLine(x, right, y, bottom, STR_BLACK_STRING); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
113 } else { |
13017
ab07d6d87608
(svn r17511) -Codechange: Simplify ShowNewGRFInfo() by passing 'right' instead of 'width'.
frosch <frosch@openttd.org>
parents:
12879
diff
changeset
|
114 y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_NO_INFO); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
115 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
116 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
117 |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
118 static GRFPresetList _grf_preset_list; |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
119 |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
120 class DropDownListPresetItem : public DropDownListItem { |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
121 public: |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
122 DropDownListPresetItem(int result) : DropDownListItem(result, false) {} |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
123 |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
124 virtual ~DropDownListPresetItem() {} |
9864
199cb67d074d
(svn r14009) -Cleanup (r14008): Bad whitespace...
peter1138 <peter1138@openttd.org>
parents:
9863
diff
changeset
|
125 |
9863
3db7ce31355e
(svn r14008) -Fix (r14004): NewGRF preset drop down list not working
peter1138 <peter1138@openttd.org>
parents:
9760
diff
changeset
|
126 bool Selectable() const |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
127 { |
9863
3db7ce31355e
(svn r14008) -Fix (r14004): NewGRF preset drop down list not working
peter1138 <peter1138@openttd.org>
parents:
9760
diff
changeset
|
128 return true; |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
129 } |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
130 |
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
|
131 void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
132 { |
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
|
133 DrawString(left + 2, right + 2, top, _grf_preset_list[this->result], sel ? TC_WHITE : TC_BLACK); |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
134 } |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
135 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
136 |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
137 static void NewGRFConfirmationCallback(Window *w, bool confirmed); |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
138 |
11795
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
139 /** Names of the manage newgrfs window widgets. */ |
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
140 enum ShowNewGRFStateWidgets { |
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
141 SNGRFS_PRESET_LIST, |
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
142 SNGRFS_PRESET_SAVE, |
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
143 SNGRFS_PRESET_DELETE, |
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
144 SNGRFS_ADD, |
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
145 SNGRFS_REMOVE, |
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
146 SNGRFS_MOVE_UP, |
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
147 SNGRFS_MOVE_DOWN, |
15209
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
148 SNGRFS_FILTER, |
11795
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
149 SNGRFS_FILE_LIST, |
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
150 SNGRFS_SCROLLBAR, |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
151 SNGRFS_AVAIL_LIST, |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
152 SNGRFS_SCROLL2BAR, |
15204
f29231ce72e1
(svn r19833) -Change: Modify NewGRF window towards having combined lists, add captions.
alberth <alberth@openttd.org>
parents:
15203
diff
changeset
|
153 SNGRFS_NEWGRF_INFO_TITLE, |
11795
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
154 SNGRFS_NEWGRF_INFO, |
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
155 SNGRFS_SET_PARAMETERS, |
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
156 SNGRFS_TOGGLE_PALETTE, |
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
157 SNGRFS_APPLY_CHANGES, |
15211
e28e566488a9
(svn r19840) -Add: Add 'rescan' functionality to the NewGRF window.
alberth <alberth@openttd.org>
parents:
15209
diff
changeset
|
158 SNGRFS_RESCAN_FILES, |
11795
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
159 SNGRFS_CONTENT_DOWNLOAD, |
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
160 }; |
8f4775ec6562
(svn r16185) -Codechange: Moving the ShowNewGRFStateWidgets and AddNewGRFWindowWidgets widget enums outside their window structs.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
161 |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
162 /** |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
163 * Window for showing NewGRF files |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
164 */ |
15209
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
165 struct NewGRFWindow : public QueryStringBaseWindow { |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
166 typedef GUIList<const GRFConfig *> GUIGRFConfigList; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
167 |
15209
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
168 static const uint EDITBOX_MAX_SIZE = 50; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
169 static const uint EDITBOX_MAX_LENGTH = 300; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
170 |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
171 static Listing last_sorting; ///< Default sorting of #GUIGRFConfigList. |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
172 static Filtering last_filtering; ///< Default filtering of #GUIGRFConfigList. |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
173 static GUIGRFConfigList::SortFunction * const sorter_funcs[]; ///< Sort functions of the #GUIGRFConfigList. |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
174 static GUIGRFConfigList::FilterFunction * const filter_funcs[]; ///< Filter functions of the #GUIGRFConfigList. |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
175 |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
176 GUIGRFConfigList avails; ///< Available (non-active) grfs. |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
177 const GRFConfig *avail_sel; ///< Currently selected available grf. \c NULL is none is selected. |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
178 int avail_pos; ///< Index of #avail_sel if existing, else \c -1. |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
179 |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
180 GRFConfig *actives; ///< Temporary active grf list to which changes are made. |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
181 GRFConfig *active_sel; ///< Selected active grf item. |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
182 |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
183 GRFConfig **orig_list; ///< List active grfs in the game. Used as initial value, may be updated by the window. |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
184 bool editable; ///< Is the window editable? |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
185 bool show_params; ///< Are the grf-parameters shown in the info-panel? |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
186 bool execute; ///< On pressing 'apply changes' are grf changes applied immediately, or only list is updated. |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
187 int query_widget; ///< Widget that opened the last query. |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
188 int preset; ///< Selected preset. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
189 |
15209
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
190 NewGRFWindow(const WindowDesc *desc, bool editable, bool show_params, bool execute, GRFConfig **orig_list) : QueryStringBaseWindow(EDITBOX_MAX_SIZE) |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
191 { |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
192 this->avail_sel = NULL; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
193 this->avail_pos = -1; |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
194 this->active_sel = NULL; |
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
195 this->actives = NULL; |
15202
e9db5d2f634e
(svn r19831) -Codechange: Rename formal parameters of the constructor to match data member variable names.
alberth <alberth@openttd.org>
parents:
15201
diff
changeset
|
196 this->orig_list = orig_list; |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
197 this->editable = editable; |
15202
e9db5d2f634e
(svn r19831) -Codechange: Rename formal parameters of the constructor to match data member variable names.
alberth <alberth@openttd.org>
parents:
15201
diff
changeset
|
198 this->execute = execute; |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
199 this->show_params = show_params; |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
200 this->preset = -1; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
201 |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
202 CopyGRFConfigList(&this->actives, *orig_list, false); |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
203 GetGRFPresetList(&_grf_preset_list); |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
204 |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
205 this->InitNested(desc); |
15209
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
206 InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, EDITBOX_MAX_LENGTH); |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
207 this->SetFocusedWidget(SNGRFS_FILTER); |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
208 |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
209 this->avails.SetListing(this->last_sorting); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
210 this->avails.SetFiltering(this->last_filtering); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
211 this->avails.SetSortFuncs(this->sorter_funcs); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
212 this->avails.SetFilterFuncs(this->filter_funcs); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
213 this->avails.ForceRebuild(); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
214 |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
215 this->OnInvalidateData(2); |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
216 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
217 |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
218 ~NewGRFWindow() |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
219 { |
10910
9276e5a96995
(svn r15245) -Fix: don't "save" the NewGRF settings on closing the NewGRF window when the content of the window isn't editable
rubidium <rubidium@openttd.org>
parents:
10890
diff
changeset
|
220 if (this->editable && !this->execute) { |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
221 CopyGRFConfigList(this->orig_list, this->actives, true); |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
222 ResetGRFConfig(false); |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
223 ReloadNewGRFData(); |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
224 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
225 |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
226 /* Remove the temporary copy of grf-list used in window */ |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
227 ClearGRFConfigList(&this->actives); |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
228 _grf_preset_list.Clear(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
229 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
230 |
13705
8dee47e001b2
(svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents:
13704
diff
changeset
|
231 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
232 { |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
233 switch (widget) { |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
234 case SNGRFS_FILE_LIST: |
15205
0dca88008a3a
(svn r19834) -Change: Replace matrix list widget in NewGRF gui by a panel with black background.
alberth <alberth@openttd.org>
parents:
15204
diff
changeset
|
235 resize->height = max(12, FONT_HEIGHT_NORMAL + 2); |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
236 size->height = max(size->height, WD_FRAMERECT_TOP + 6 * resize->height + WD_FRAMERECT_BOTTOM); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
237 break; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
238 |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
239 case SNGRFS_AVAIL_LIST: |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
240 resize->height = max(12, FONT_HEIGHT_NORMAL + 2); |
15205
0dca88008a3a
(svn r19834) -Change: Replace matrix list widget in NewGRF gui by a panel with black background.
alberth <alberth@openttd.org>
parents:
15204
diff
changeset
|
241 size->height = max(size->height, WD_FRAMERECT_TOP + 8 * resize->height + WD_FRAMERECT_BOTTOM); |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
242 break; |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
243 |
15204
f29231ce72e1
(svn r19833) -Change: Modify NewGRF window towards having combined lists, add captions.
alberth <alberth@openttd.org>
parents:
15203
diff
changeset
|
244 case SNGRFS_NEWGRF_INFO_TITLE: { |
f29231ce72e1
(svn r19833) -Change: Modify NewGRF window towards having combined lists, add captions.
alberth <alberth@openttd.org>
parents:
15203
diff
changeset
|
245 Dimension dim = GetStringBoundingBox(STR_NEWGRF_SETTINGS_INFO_TITLE); |
f29231ce72e1
(svn r19833) -Change: Modify NewGRF window towards having combined lists, add captions.
alberth <alberth@openttd.org>
parents:
15203
diff
changeset
|
246 size->height = max(size->height, dim.height + WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM); |
f29231ce72e1
(svn r19833) -Change: Modify NewGRF window towards having combined lists, add captions.
alberth <alberth@openttd.org>
parents:
15203
diff
changeset
|
247 size->width = max(size->width, dim.width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT); |
f29231ce72e1
(svn r19833) -Change: Modify NewGRF window towards having combined lists, add captions.
alberth <alberth@openttd.org>
parents:
15203
diff
changeset
|
248 break; |
f29231ce72e1
(svn r19833) -Change: Modify NewGRF window towards having combined lists, add captions.
alberth <alberth@openttd.org>
parents:
15203
diff
changeset
|
249 } |
f29231ce72e1
(svn r19833) -Change: Modify NewGRF window towards having combined lists, add captions.
alberth <alberth@openttd.org>
parents:
15203
diff
changeset
|
250 |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
251 case SNGRFS_NEWGRF_INFO: |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
252 size->height = max(size->height, WD_FRAMERECT_TOP + 10 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM + padding.height + 2); |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
253 break; |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
254 |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
255 case SNGRFS_PRESET_LIST: { |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
256 Dimension d = GetStringBoundingBox(STR_NUM_CUSTOM); |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
257 for (uint i = 0; i < _grf_preset_list.Length(); i++) { |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
258 if (_grf_preset_list[i] != NULL) { |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
259 SetDParamStr(0, _grf_preset_list[i]); |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
260 d = maxdim(d, GetStringBoundingBox(STR_JUST_RAW_STRING)); |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
261 } |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
262 } |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
263 d.width += padding.width; |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
264 *size = maxdim(d, *size); |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
265 break; |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
266 } |
15194
2d9d9be17bbe
(svn r19823) -Fix: Ensure that both texts of the newgrf gui download button fit.
alberth <alberth@openttd.org>
parents:
15185
diff
changeset
|
267 |
2d9d9be17bbe
(svn r19823) -Fix: Ensure that both texts of the newgrf gui download button fit.
alberth <alberth@openttd.org>
parents:
15185
diff
changeset
|
268 case SNGRFS_CONTENT_DOWNLOAD: { |
2d9d9be17bbe
(svn r19823) -Fix: Ensure that both texts of the newgrf gui download button fit.
alberth <alberth@openttd.org>
parents:
15185
diff
changeset
|
269 Dimension d = GetStringBoundingBox(STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON); |
2d9d9be17bbe
(svn r19823) -Fix: Ensure that both texts of the newgrf gui download button fit.
alberth <alberth@openttd.org>
parents:
15185
diff
changeset
|
270 *size = maxdim(d, GetStringBoundingBox(STR_INTRO_ONLINE_CONTENT)); |
2d9d9be17bbe
(svn r19823) -Fix: Ensure that both texts of the newgrf gui download button fit.
alberth <alberth@openttd.org>
parents:
15185
diff
changeset
|
271 size->width += padding.width; |
2d9d9be17bbe
(svn r19823) -Fix: Ensure that both texts of the newgrf gui download button fit.
alberth <alberth@openttd.org>
parents:
15185
diff
changeset
|
272 size->height += padding.height; |
2d9d9be17bbe
(svn r19823) -Fix: Ensure that both texts of the newgrf gui download button fit.
alberth <alberth@openttd.org>
parents:
15185
diff
changeset
|
273 break; |
2d9d9be17bbe
(svn r19823) -Fix: Ensure that both texts of the newgrf gui download button fit.
alberth <alberth@openttd.org>
parents:
15185
diff
changeset
|
274 } |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
275 } |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
276 } |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
277 |
13344
04b02b2cfa2b
(svn r17853) -Codechange: remove the 'delta' parameter from OnResize; it was used in ways that aren't always wanted, causing bugs and the like. Also with nested widgets most reasons for handling OnResize have gone.
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
278 virtual void OnResize() |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
279 { |
14037
ca29deba0f1a
(svn r18580) -Codechange: Use widget information only for setting scrollbar capacity.
alberth <alberth@openttd.org>
parents:
13968
diff
changeset
|
280 this->vscroll.SetCapacityFromWidget(this, SNGRFS_FILE_LIST); |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
281 this->vscroll2.SetCapacityFromWidget(this, SNGRFS_AVAIL_LIST); |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
282 } |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
283 |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
284 virtual void SetStringParameters(int widget) const |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
285 { |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
286 switch (widget) { |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
287 case SNGRFS_PRESET_LIST: |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
288 if (this->preset == -1) { |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
289 SetDParam(0, STR_NUM_CUSTOM); |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
290 } else { |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
291 SetDParam(0, STR_JUST_RAW_STRING); |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
292 SetDParamStr(1, _grf_preset_list[this->preset]); |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
293 } |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
294 break; |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
295 } |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
296 } |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
297 |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
298 virtual void OnPaint() |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
299 { |
9273
72a6d2e60834
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents:
9207
diff
changeset
|
300 this->DrawWidgets(); |
15209
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
301 this->DrawEditBox(SNGRFS_FILTER); |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
302 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
303 |
15207
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
304 /** Pick the palette for the sprite of the grf to display. |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
305 * @param c grf to display. |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
306 * @return Palette for the sprite. |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
307 */ |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
308 FORCEINLINE PaletteID GetPalette(const GRFConfig *c) const |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
309 { |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
310 PaletteID pal; |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
311 |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
312 /* Pick a colour */ |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
313 switch (c->status) { |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
314 case GCS_NOT_FOUND: |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
315 case GCS_DISABLED: |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
316 pal = PALETTE_TO_RED; |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
317 break; |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
318 case GCS_ACTIVATED: |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
319 pal = PALETTE_TO_GREEN; |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
320 break; |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
321 default: |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
322 pal = PALETTE_TO_BLUE; |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
323 break; |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
324 } |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
325 |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
326 /* Do not show a "not-failure" colour when it actually failed to load */ |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
327 if (pal != PALETTE_TO_RED) { |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
328 if (HasBit(c->flags, GCF_STATIC)) { |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
329 pal = PALETTE_TO_GREY; |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
330 } else if (HasBit(c->flags, GCF_COMPATIBLE)) { |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
331 pal = PALETTE_TO_ORANGE; |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
332 } |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
333 } |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
334 |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
335 return pal; |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
336 } |
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
337 |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
338 virtual void DrawWidget(const Rect &r, int widget) const |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
339 { |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
340 switch (widget) { |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
341 case SNGRFS_FILE_LIST: { |
15205
0dca88008a3a
(svn r19834) -Change: Replace matrix list widget in NewGRF gui by a panel with black background.
alberth <alberth@openttd.org>
parents:
15204
diff
changeset
|
342 GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, 0xD7); |
0dca88008a3a
(svn r19834) -Change: Replace matrix list widget in NewGRF gui by a panel with black background.
alberth <alberth@openttd.org>
parents:
15204
diff
changeset
|
343 |
0dca88008a3a
(svn r19834) -Change: Replace matrix list widget in NewGRF gui by a panel with black background.
alberth <alberth@openttd.org>
parents:
15204
diff
changeset
|
344 uint step_height = this->GetWidget<NWidgetBase>(SNGRFS_FILE_LIST)->resize_y; |
0dca88008a3a
(svn r19834) -Change: Replace matrix list widget in NewGRF gui by a panel with black background.
alberth <alberth@openttd.org>
parents:
15204
diff
changeset
|
345 uint y = r.top + WD_FRAMERECT_TOP; |
15220
ef4601cbbb98
(svn r19849) -Fix: Center sprite and text seperately in the newgrf gui active list.
alberth <alberth@openttd.org>
parents:
15219
diff
changeset
|
346 int sprite_offset_y = (step_height - 10) / 2; |
ef4601cbbb98
(svn r19849) -Fix: Center sprite and text seperately in the newgrf gui active list.
alberth <alberth@openttd.org>
parents:
15219
diff
changeset
|
347 int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2; |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
348 |
13659
2c473236b6fd
(svn r18183) -Codechange: make the NewGRF window RTL aware
rubidium <rubidium@openttd.org>
parents:
13654
diff
changeset
|
349 bool rtl = _dynlang.text_dir == TD_RTL; |
2c473236b6fd
(svn r18183) -Codechange: make the NewGRF window RTL aware
rubidium <rubidium@openttd.org>
parents:
13654
diff
changeset
|
350 uint text_left = rtl ? r.left + WD_FRAMERECT_LEFT : r.left + 25; |
2c473236b6fd
(svn r18183) -Codechange: make the NewGRF window RTL aware
rubidium <rubidium@openttd.org>
parents:
13654
diff
changeset
|
351 uint text_right = rtl ? r.right - 25 : r.right - WD_FRAMERECT_RIGHT; |
2c473236b6fd
(svn r18183) -Codechange: make the NewGRF window RTL aware
rubidium <rubidium@openttd.org>
parents:
13654
diff
changeset
|
352 uint square_left = rtl ? r.right - 15 : r.left + 5; |
2c473236b6fd
(svn r18183) -Codechange: make the NewGRF window RTL aware
rubidium <rubidium@openttd.org>
parents:
13654
diff
changeset
|
353 uint warning_left = rtl ? r.right - 30 : r.left + 20; |
2c473236b6fd
(svn r18183) -Codechange: make the NewGRF window RTL aware
rubidium <rubidium@openttd.org>
parents:
13654
diff
changeset
|
354 |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
355 int i = 0; |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
356 for (const GRFConfig *c = this->actives; c != NULL; c = c->next, i++) { |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
357 if (this->vscroll.IsVisible(i)) { |
14711
74b0a8a64ff5
(svn r19295) -Codechange: introduce wrapper functions for GRFConfig::name/info
yexo <yexo@openttd.org>
parents:
14676
diff
changeset
|
358 const char *text = c->GetName(); |
15205
0dca88008a3a
(svn r19834) -Change: Replace matrix list widget in NewGRF gui by a panel with black background.
alberth <alberth@openttd.org>
parents:
15204
diff
changeset
|
359 bool h = (this->active_sel == c); |
15207
e31a7ac11eb1
(svn r19836) -Codechange: Move sprite palette selection code in NewGRF gui to its own method.
alberth <alberth@openttd.org>
parents:
15205
diff
changeset
|
360 PaletteID pal = this->GetPalette(c); |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
361 |
15205
0dca88008a3a
(svn r19834) -Change: Replace matrix list widget in NewGRF gui by a panel with black background.
alberth <alberth@openttd.org>
parents:
15204
diff
changeset
|
362 if (h) GfxFillRect(r.left + 1, y, r.right - 1, y + step_height - 1, 156); |
13696
619a107df4a1
(svn r18221) -Codechange: make the NewGRF window big font aware
rubidium <rubidium@openttd.org>
parents:
13695
diff
changeset
|
363 DrawSprite(SPR_SQUARE, pal, square_left, y + sprite_offset_y); |
619a107df4a1
(svn r18221) -Codechange: make the NewGRF window big font aware
rubidium <rubidium@openttd.org>
parents:
13695
diff
changeset
|
364 if (c->error != NULL) DrawSprite(SPR_WARNING_SIGN, 0, warning_left, y + sprite_offset_y); |
13659
2c473236b6fd
(svn r18183) -Codechange: make the NewGRF window RTL aware
rubidium <rubidium@openttd.org>
parents:
13654
diff
changeset
|
365 uint txtoffset = c->error == NULL ? 0 : 10; |
15220
ef4601cbbb98
(svn r19849) -Fix: Center sprite and text seperately in the newgrf gui active list.
alberth <alberth@openttd.org>
parents:
15219
diff
changeset
|
366 DrawString(text_left + (rtl ? 0 : txtoffset), text_right - (rtl ? txtoffset : 0), y + offset_y, text, h ? TC_WHITE : TC_ORANGE); |
15205
0dca88008a3a
(svn r19834) -Change: Replace matrix list widget in NewGRF gui by a panel with black background.
alberth <alberth@openttd.org>
parents:
15204
diff
changeset
|
367 y += step_height; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
368 } |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
369 } |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
370 } break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
371 |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
372 case SNGRFS_AVAIL_LIST: { |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
373 GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, 0xD7); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
374 |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
375 uint step_height = this->GetWidget<NWidgetBase>(SNGRFS_AVAIL_LIST)->resize_y; |
15219
861c943801ad
(svn r19848) -Fix (r19837): Center the texts of the inactive newgrfs.
alberth <alberth@openttd.org>
parents:
15216
diff
changeset
|
376 int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2; |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
377 uint y = r.top + WD_FRAMERECT_TOP; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
378 uint min_index = this->vscroll2.GetPosition(); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
379 uint max_index = min(min_index + this->vscroll2.GetCapacity(), this->avails.Length()); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
380 |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
381 for (uint i = min_index; i < max_index; i++) |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
382 { |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
383 const GRFConfig *c = this->avails[i]; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
384 bool h = (c == this->avail_sel); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
385 const char *text = c->GetName(); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
386 |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
387 if (h) GfxFillRect(r.left + 1, y, r.right - 1, y + step_height - 1, 156); |
15219
861c943801ad
(svn r19848) -Fix (r19837): Center the texts of the inactive newgrfs.
alberth <alberth@openttd.org>
parents:
15216
diff
changeset
|
388 DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y + offset_y, text, h ? TC_WHITE : TC_SILVER); |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
389 y += step_height; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
390 } |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
391 break; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
392 } |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
393 |
15204
f29231ce72e1
(svn r19833) -Change: Modify NewGRF window towards having combined lists, add captions.
alberth <alberth@openttd.org>
parents:
15203
diff
changeset
|
394 case SNGRFS_NEWGRF_INFO_TITLE: |
f29231ce72e1
(svn r19833) -Change: Modify NewGRF window towards having combined lists, add captions.
alberth <alberth@openttd.org>
parents:
15203
diff
changeset
|
395 /* Create the nice grayish rectangle at the details top. */ |
f29231ce72e1
(svn r19833) -Change: Modify NewGRF window towards having combined lists, add captions.
alberth <alberth@openttd.org>
parents:
15203
diff
changeset
|
396 GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, 157); |
15400
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15345
diff
changeset
|
397 DrawString(r.left, r.right, (r.top + r.bottom - FONT_HEIGHT_NORMAL) / 2, STR_NEWGRF_SETTINGS_INFO_TITLE, TC_FROMSTRING, SA_HOR_CENTER); |
15204
f29231ce72e1
(svn r19833) -Change: Modify NewGRF window towards having combined lists, add captions.
alberth <alberth@openttd.org>
parents:
15203
diff
changeset
|
398 break; |
f29231ce72e1
(svn r19833) -Change: Modify NewGRF window towards having combined lists, add captions.
alberth <alberth@openttd.org>
parents:
15203
diff
changeset
|
399 |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
400 case SNGRFS_NEWGRF_INFO: { |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
401 const GRFConfig *selected = this->active_sel; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
402 if (selected == NULL) selected = this->avail_sel; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
403 if (selected != NULL) { |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
404 ShowNewGRFInfo(selected, r.left + WD_FRAMERECT_LEFT, r.top + WD_FRAMERECT_TOP, r.right - WD_FRAMERECT_RIGHT, r.bottom - WD_FRAMERECT_BOTTOM, this->show_params); |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
405 } |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
406 break; |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
407 } |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
408 } |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
409 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
410 |
14409
1eaefde497fd
(svn r18966) -Codechange: Remove Window::OnDoubleClick() in favour of a parameter for OnClick().
frosch <frosch@openttd.org>
parents:
14391
diff
changeset
|
411 virtual void OnClick(Point pt, int widget, int click_count) |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
412 { |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
413 switch (widget) { |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
414 case SNGRFS_PRESET_LIST: { |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
415 DropDownList *list = new DropDownList(); |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
416 |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
417 /* Add 'None' option for clearing list */ |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
418 list->push_back(new DropDownListStringItem(STR_NONE, -1, false)); |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
419 |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
420 for (uint i = 0; i < _grf_preset_list.Length(); i++) { |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
421 if (_grf_preset_list[i] != NULL) { |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
422 list->push_back(new DropDownListPresetItem(i)); |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
423 } |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
424 } |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
425 |
15212
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
426 this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
427 ShowDropDownList(this, list, this->preset, SNGRFS_PRESET_LIST); |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
428 break; |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
429 } |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
430 |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
431 case SNGRFS_PRESET_SAVE: |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
432 this->query_widget = widget; |
12632
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12619
diff
changeset
|
433 ShowQueryString(STR_EMPTY, STR_NEWGRF_SETTINGS_PRESET_SAVE_QUERY, 32, 100, this, CS_ALPHANUMERAL, QSF_NONE); |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
434 break; |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
435 |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
436 case SNGRFS_PRESET_DELETE: |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
437 if (this->preset == -1) return; |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
438 |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
439 DeleteGRFPresetFromConfig(_grf_preset_list[this->preset]); |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
440 GetGRFPresetList(&_grf_preset_list); |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
441 this->preset = -1; |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
442 this->InvalidateData(); |
13413
a3d40c489804
(svn r17922) -Fix [FS#3291]: crash when closing NewGRF parameter window with no NewGRF selected
rubidium <rubidium@openttd.org>
parents:
13411
diff
changeset
|
443 this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
444 break; |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
445 |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
446 case SNGRFS_MOVE_UP: { // Move GRF up |
15345
52c9ee163c8f
(svn r19986) -Fix (r19841): One could add and remove Grfs from the list via doubleclicking even if editing the list is not allowed.
frosch <frosch@openttd.org>
parents:
15331
diff
changeset
|
447 if (this->active_sel == NULL || !this->editable) break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
448 |
14390
48685f9d7f68
(svn r18947) -Fix [FS#1510]: after clicking move up/move down in the newgrf/ai the selected item could be out of range
yexo <yexo@openttd.org>
parents:
14319
diff
changeset
|
449 int pos = 0; |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
450 for (GRFConfig **pc = &this->actives; *pc != NULL; pc = &(*pc)->next, pos++) { |
15200
0865df725761
(svn r19829) -Codechange: Extract assignment from the condition-check in the for statement.
alberth <alberth@openttd.org>
parents:
15194
diff
changeset
|
451 GRFConfig *c = *pc; |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
452 if (c->next == this->active_sel) { |
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
453 c->next = this->active_sel->next; |
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
454 this->active_sel->next = c; |
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
455 *pc = this->active_sel; |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
456 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
457 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
458 } |
14390
48685f9d7f68
(svn r18947) -Fix [FS#1510]: after clicking move up/move down in the newgrf/ai the selected item could be out of range
yexo <yexo@openttd.org>
parents:
14319
diff
changeset
|
459 this->vscroll.ScrollTowards(pos); |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
460 this->preset = -1; |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
461 this->InvalidateData(); |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
462 break; |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
463 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
464 |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
465 case SNGRFS_MOVE_DOWN: { // Move GRF down |
15345
52c9ee163c8f
(svn r19986) -Fix (r19841): One could add and remove Grfs from the list via doubleclicking even if editing the list is not allowed.
frosch <frosch@openttd.org>
parents:
15331
diff
changeset
|
466 if (this->active_sel == NULL || !this->editable) break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
467 |
14390
48685f9d7f68
(svn r18947) -Fix [FS#1510]: after clicking move up/move down in the newgrf/ai the selected item could be out of range
yexo <yexo@openttd.org>
parents:
14319
diff
changeset
|
468 int pos = 1; // Start at 1 as we swap the selected newgrf with the next one |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
469 for (GRFConfig **pc = &this->actives; *pc != NULL; pc = &(*pc)->next, pos++) { |
15200
0865df725761
(svn r19829) -Codechange: Extract assignment from the condition-check in the for statement.
alberth <alberth@openttd.org>
parents:
15194
diff
changeset
|
470 GRFConfig *c = *pc; |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
471 if (c == this->active_sel) { |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
472 *pc = c->next; |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
473 c->next = c->next->next; |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
474 (*pc)->next = c; |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
475 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
476 } |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
477 } |
14390
48685f9d7f68
(svn r18947) -Fix [FS#1510]: after clicking move up/move down in the newgrf/ai the selected item could be out of range
yexo <yexo@openttd.org>
parents:
14319
diff
changeset
|
478 this->vscroll.ScrollTowards(pos); |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
479 this->preset = -1; |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
480 this->InvalidateData(); |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
481 break; |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
482 } |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
483 |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
484 case SNGRFS_FILE_LIST: { // Select an active GRF. |
15563
011c8bee59d1
(svn r20223) -Codechange: Replace scrolled row calculations by a call to GetScrolledRowFromWidget().
alberth <alberth@openttd.org>
parents:
15557
diff
changeset
|
485 uint i = this->vscroll.GetScrolledRowFromWidget(pt.y, this, SNGRFS_FILE_LIST); |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
486 |
15201
071e920abcfb
(svn r19830) -Codechange: Move variable declarations to their first use.
alberth <alberth@openttd.org>
parents:
15200
diff
changeset
|
487 GRFConfig *c; |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
488 for (c = this->actives; c != NULL && i > 0; c = c->next, i--) {} |
13413
a3d40c489804
(svn r17922) -Fix [FS#3291]: crash when closing NewGRF parameter window with no NewGRF selected
rubidium <rubidium@openttd.org>
parents:
13411
diff
changeset
|
489 |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
490 if (this->active_sel != c) this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window |
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
491 this->active_sel = c; |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
492 this->avail_sel = NULL; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
493 this->avail_pos = -1; |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
494 |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
495 this->InvalidateData(); |
15212
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
496 if (click_count == 1) break; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
497 } |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
498 /* Fall through with double click. */ |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
499 case SNGRFS_REMOVE: { // Remove GRF |
15345
52c9ee163c8f
(svn r19986) -Fix (r19841): One could add and remove Grfs from the list via doubleclicking even if editing the list is not allowed.
frosch <frosch@openttd.org>
parents:
15331
diff
changeset
|
500 if (this->active_sel == NULL || !this->editable) break; |
15212
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
501 |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
502 /* Choose the next GRF file to be the selected file. */ |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
503 GRFConfig *newsel = this->active_sel->next; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
504 for (GRFConfig **pc = &this->actives; *pc != NULL; pc = &(*pc)->next) { |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
505 GRFConfig *c = *pc; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
506 /* If the new selection is empty (i.e. we're deleting the last item |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
507 * in the list, pick the file just before the selected file */ |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
508 if (newsel == NULL && c->next == this->active_sel) newsel = c; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
509 |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
510 if (c == this->active_sel) { |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
511 *pc = c->next; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
512 delete c; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
513 break; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
514 } |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
515 } |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
516 |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
517 this->active_sel = newsel; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
518 this->preset = -1; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
519 this->avail_pos = -1; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
520 this->avail_sel = NULL; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
521 this->avails.ForceRebuild(); |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
522 this->InvalidateData(2); |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
523 this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
524 break; |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
525 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
526 |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
527 case SNGRFS_AVAIL_LIST: { // Select a non-active GRF. |
15563
011c8bee59d1
(svn r20223) -Codechange: Replace scrolled row calculations by a call to GetScrolledRowFromWidget().
alberth <alberth@openttd.org>
parents:
15557
diff
changeset
|
528 uint i = this->vscroll2.GetScrolledRowFromWidget(pt.y, this, SNGRFS_AVAIL_LIST); |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
529 this->active_sel = NULL; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
530 if (i < this->avails.Length()) { |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
531 this->avail_sel = this->avails[i]; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
532 this->avail_pos = i; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
533 } |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
534 this->InvalidateData(); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
535 this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window |
15212
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
536 if (click_count == 1) break; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
537 } |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
538 /* Fall through with double click. */ |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
539 case SNGRFS_ADD: { |
15345
52c9ee163c8f
(svn r19986) -Fix (r19841): One could add and remove Grfs from the list via doubleclicking even if editing the list is not allowed.
frosch <frosch@openttd.org>
parents:
15331
diff
changeset
|
540 if (this->avail_sel == NULL || !this->editable) break; |
15212
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
541 |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
542 GRFConfig **list; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
543 /* Find last entry in the list, checking for duplicate grfid on the way */ |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
544 for (list = &this->actives; *list != NULL; list = &(*list)->next) { |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
545 if ((*list)->ident.grfid == this->avail_sel->ident.grfid) { |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
546 ShowErrorMessage(STR_NEWGRF_DUPLICATE_GRFID, INVALID_STRING_ID, WL_INFO); |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
547 return; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
548 } |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
549 } |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
550 |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
551 GRFConfig *c = DuplicateGRFConfig(this->avail_sel); // Copy GRF details from scanned list. |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
552 c->next = NULL; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
553 *list = c; // Append GRF config to configuration list. |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
554 |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
555 /* Select next (or previous, if last one) item in the list. */ |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
556 int new_pos = this->avail_pos + 1; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
557 if (new_pos >= (int)this->avails.Length()) new_pos = this->avail_pos - 1; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
558 this->avail_pos = new_pos; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
559 if (new_pos >= 0) this->avail_sel = this->avails[new_pos]; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
560 |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
561 this->avails.ForceRebuild(); |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
562 this->InvalidateData(2); |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
563 break; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
564 } |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
565 |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
566 case SNGRFS_APPLY_CHANGES: // Apply changes made to GRF list |
15345
52c9ee163c8f
(svn r19986) -Fix (r19841): One could add and remove Grfs from the list via doubleclicking even if editing the list is not allowed.
frosch <frosch@openttd.org>
parents:
15331
diff
changeset
|
567 if (!this->editable) break; |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
568 if (this->execute) { |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
569 ShowQuery( |
12632
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12619
diff
changeset
|
570 STR_NEWGRF_POPUP_CAUTION_CAPTION, |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
571 STR_NEWGRF_CONFIRMATION_TEXT, |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
572 this, |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
573 NewGRFConfirmationCallback |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
574 ); |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
575 } else { |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
576 CopyGRFConfigList(this->orig_list, this->actives, true); |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
577 ResetGRFConfig(false); |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
578 ReloadNewGRFData(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
579 } |
15212
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
580 this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
581 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
582 |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
583 case SNGRFS_SET_PARAMETERS: { // Edit parameters |
15345
52c9ee163c8f
(svn r19986) -Fix (r19841): One could add and remove Grfs from the list via doubleclicking even if editing the list is not allowed.
frosch <frosch@openttd.org>
parents:
15331
diff
changeset
|
584 if (this->active_sel == NULL || !this->editable || !this->show_params) break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
585 |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
586 this->query_widget = widget; |
9648
b53049484e44
(svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents:
9457
diff
changeset
|
587 static char buff[512]; |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
588 GRFBuildParamList(buff, this->active_sel, lastof(buff)); |
9648
b53049484e44
(svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents:
9457
diff
changeset
|
589 SetDParamStr(0, buff); |
13411
1b43d1184836
(svn r17920) -Codechange: add a 'filter' for numbers+spaces and use it for the NewGRF parameter list
rubidium <rubidium@openttd.org>
parents:
13381
diff
changeset
|
590 ShowQueryString(STR_JUST_RAW_STRING, STR_NEWGRF_SETTINGS_PARAMETER_QUERY, 63, 250, this, CS_NUMERAL_SPACE, QSF_NONE); |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
591 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
592 } |
10066
42653fe231a2
(svn r14233) -Feature/Fix [FS#2172]: save the palette of the loaded NewGRFs in the savegame, so joining with a server using Windows palette will make a client with the DOS palette do palette conversion and (thus) not cause a desync due to the different palettes disabling different NewGRFs.
rubidium <rubidium@openttd.org>
parents:
9957
diff
changeset
|
593 |
10793
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
594 case SNGRFS_TOGGLE_PALETTE: |
15345
52c9ee163c8f
(svn r19986) -Fix (r19841): One could add and remove Grfs from the list via doubleclicking even if editing the list is not allowed.
frosch <frosch@openttd.org>
parents:
15331
diff
changeset
|
595 if (this->active_sel != NULL || !this->editable) { |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
596 this->active_sel->windows_paletted ^= true; |
10066
42653fe231a2
(svn r14233) -Feature/Fix [FS#2172]: save the palette of the loaded NewGRFs in the savegame, so joining with a server using Windows palette will make a client with the DOS palette do palette conversion and (thus) not cause a desync due to the different palettes disabling different NewGRFs.
rubidium <rubidium@openttd.org>
parents:
9957
diff
changeset
|
597 this->SetDirty(); |
42653fe231a2
(svn r14233) -Feature/Fix [FS#2172]: save the palette of the loaded NewGRFs in the savegame, so joining with a server using Windows palette will make a client with the DOS palette do palette conversion and (thus) not cause a desync due to the different palettes disabling different NewGRFs.
rubidium <rubidium@openttd.org>
parents:
9957
diff
changeset
|
598 } |
42653fe231a2
(svn r14233) -Feature/Fix [FS#2172]: save the palette of the loaded NewGRFs in the savegame, so joining with a server using Windows palette will make a client with the DOS palette do palette conversion and (thus) not cause a desync due to the different palettes disabling different NewGRFs.
rubidium <rubidium@openttd.org>
parents:
9957
diff
changeset
|
599 break; |
10793
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
600 |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
601 case SNGRFS_CONTENT_DOWNLOAD: |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
602 if (!_network_available) { |
14645
b7a22979b84e
(svn r19224) -Codechange: change parameters passed to ShowErrorMessage() a bit
smatz <smatz@openttd.org>
parents:
14561
diff
changeset
|
603 ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR); |
10793
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
604 } else { |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
605 #if defined(ENABLE_NETWORK) |
15331
fcc18215652e
(svn r19972) -Change: Use the md5sum from the previous save of the game for BaNaNaS instead of the initial (when the grf was added) md5sum from the gamelog. Neither method is 'better', but this way it is independent from the gamelog.
frosch <frosch@openttd.org>
parents:
15220
diff
changeset
|
606 this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window |
15212
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
607 |
15331
fcc18215652e
(svn r19972) -Change: Use the md5sum from the previous save of the game for BaNaNaS instead of the initial (when the grf was added) md5sum from the gamelog. Neither method is 'better', but this way it is independent from the gamelog.
frosch <frosch@openttd.org>
parents:
15220
diff
changeset
|
608 /* Only show the things in the current list, or everything when nothing's selected */ |
10793
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
609 ContentVector cv; |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
610 for (const GRFConfig *c = this->actives; c != NULL; c = c->next) { |
10886
b22fa54bad95
(svn r15221) -Change [FS#2574]: only show missing NewGRFs when opening the content download window from a NewGRF list and there are missing NewGRFs, otherwise show just all NewGRFs the system knows.
rubidium <rubidium@openttd.org>
parents:
10808
diff
changeset
|
611 if (c->status != GCS_NOT_FOUND && !HasBit(c->flags, GCF_COMPATIBLE)) continue; |
b22fa54bad95
(svn r15221) -Change [FS#2574]: only show missing NewGRFs when opening the content download window from a NewGRF list and there are missing NewGRFs, otherwise show just all NewGRFs the system knows.
rubidium <rubidium@openttd.org>
parents:
10808
diff
changeset
|
612 |
10793
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
613 ContentInfo *ci = new ContentInfo(); |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
614 ci->type = CONTENT_TYPE_NEWGRF; |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
615 ci->state = ContentInfo::DOES_NOT_EXIST; |
14711
74b0a8a64ff5
(svn r19295) -Codechange: introduce wrapper functions for GRFConfig::name/info
yexo <yexo@openttd.org>
parents:
14676
diff
changeset
|
616 ttd_strlcpy(ci->name, c->GetName(), lengthof(ci->name)); |
14676
353df593bee0
(svn r19255) -Codechange: encapsulate GRFIdentifier in GRFConfig instead of subclassing it
yexo <yexo@openttd.org>
parents:
14645
diff
changeset
|
617 ci->unique_id = BSWAP32(c->ident.grfid); |
15331
fcc18215652e
(svn r19972) -Change: Use the md5sum from the previous save of the game for BaNaNaS instead of the initial (when the grf was added) md5sum from the gamelog. Neither method is 'better', but this way it is independent from the gamelog.
frosch <frosch@openttd.org>
parents:
15220
diff
changeset
|
618 memcpy(ci->md5sum, HasBit(c->flags, GCF_COMPATIBLE) ? c->original_md5sum : c->ident.md5sum, sizeof(ci->md5sum)); |
10793
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
619 *cv.Append() = ci; |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
620 } |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
621 ShowNetworkContentListWindow(cv.Length() == 0 ? NULL : &cv, CONTENT_TYPE_NEWGRF); |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
622 #endif |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
623 } |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
624 break; |
15211
e28e566488a9
(svn r19840) -Add: Add 'rescan' functionality to the NewGRF window.
alberth <alberth@openttd.org>
parents:
15209
diff
changeset
|
625 |
e28e566488a9
(svn r19840) -Add: Add 'rescan' functionality to the NewGRF window.
alberth <alberth@openttd.org>
parents:
15209
diff
changeset
|
626 case SNGRFS_RESCAN_FILES: |
e28e566488a9
(svn r19840) -Add: Add 'rescan' functionality to the NewGRF window.
alberth <alberth@openttd.org>
parents:
15209
diff
changeset
|
627 ScanNewGRFFiles(); |
e28e566488a9
(svn r19840) -Add: Add 'rescan' functionality to the NewGRF window.
alberth <alberth@openttd.org>
parents:
15209
diff
changeset
|
628 this->avail_sel = NULL; |
e28e566488a9
(svn r19840) -Add: Add 'rescan' functionality to the NewGRF window.
alberth <alberth@openttd.org>
parents:
15209
diff
changeset
|
629 this->avail_pos = -1; |
e28e566488a9
(svn r19840) -Add: Add 'rescan' functionality to the NewGRF window.
alberth <alberth@openttd.org>
parents:
15209
diff
changeset
|
630 this->avails.ForceRebuild(); |
e28e566488a9
(svn r19840) -Add: Add 'rescan' functionality to the NewGRF window.
alberth <alberth@openttd.org>
parents:
15209
diff
changeset
|
631 this->InvalidateData(1); |
15212
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
632 this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window |
15557
14828f61eda6
(svn r20217) -Fix [FS#3969]: Invalidate saveload GUI after rescanning NewGRFs.
frosch <frosch@openttd.org>
parents:
15423
diff
changeset
|
633 InvalidateWindowClassesData(WC_SAVELOAD); |
15211
e28e566488a9
(svn r19840) -Add: Add 'rescan' functionality to the NewGRF window.
alberth <alberth@openttd.org>
parents:
15209
diff
changeset
|
634 break; |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
635 } |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
636 } |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
637 |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
638 virtual void OnDropdownSelect(int widget, int index) |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
639 { |
15345
52c9ee163c8f
(svn r19986) -Fix (r19841): One could add and remove Grfs from the list via doubleclicking even if editing the list is not allowed.
frosch <frosch@openttd.org>
parents:
15331
diff
changeset
|
640 if (!this->editable) return; |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
641 if (index == -1) { |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
642 ClearGRFConfigList(&this->actives); |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
643 this->preset = -1; |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
644 } else { |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
645 GRFConfig *c = LoadGRFPresetFromConfig(_grf_preset_list[index]); |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
646 |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
647 if (c != NULL) { |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
648 this->active_sel = NULL; |
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
649 ClearGRFConfigList(&this->actives); |
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
650 this->actives = c; |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
651 this->preset = index; |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
652 this->avails.ForceRebuild(); |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
653 } |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
654 } |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
655 |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
656 this->active_sel = NULL; |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
657 this->InvalidateData(3); |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
658 } |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
659 |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
660 virtual void OnQueryTextFinished(char *str) |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
661 { |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
662 if (str == NULL) return; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
663 |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
664 switch (this->query_widget) { |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
665 default: NOT_REACHED(); |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
666 |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
667 case SNGRFS_PRESET_SAVE: |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
668 SaveGRFPresetToConfig(str, this->actives); |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
669 GetGRFPresetList(&_grf_preset_list); |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
670 |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
671 /* Switch to this preset */ |
9683
17cf35beb54b
(svn r13789) -Fix (r13781): Saved preset was not automatically selected.
peter1138 <peter1138@openttd.org>
parents:
9677
diff
changeset
|
672 for (uint i = 0; i < _grf_preset_list.Length(); i++) { |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
673 if (_grf_preset_list[i] != NULL && strcmp(_grf_preset_list[i], str) == 0) { |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
674 this->preset = i; |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
675 break; |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
676 } |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
677 } |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
678 break; |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
679 |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
680 case SNGRFS_SET_PARAMETERS: { |
15345
52c9ee163c8f
(svn r19986) -Fix (r19841): One could add and remove Grfs from the list via doubleclicking even if editing the list is not allowed.
frosch <frosch@openttd.org>
parents:
15331
diff
changeset
|
681 if (this->active_sel == NULL || !this->editable || !this->show_params) return; |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
682 |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
683 /* Parse our new "int list" */ |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
684 GRFConfig *c = this->active_sel; |
14969
9b0bb3e5357b
(svn r19577) -Codechange: apply coding style to names of functions in settings.cpp
smatz <smatz@openttd.org>
parents:
14968
diff
changeset
|
685 c->num_params = ParseIntList(str, (int*)c->param, lengthof(c->param)); |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
686 |
14969
9b0bb3e5357b
(svn r19577) -Codechange: apply coding style to names of functions in settings.cpp
smatz <smatz@openttd.org>
parents:
14968
diff
changeset
|
687 /* ParseIntList() returns -1 on error */ |
9677
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
688 if (c->num_params == (byte)-1) c->num_params = 0; |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
689 |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
690 this->preset = -1; |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
691 break; |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
692 } |
44a8397a07d4
(svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138 <peter1138@openttd.org>
parents:
9648
diff
changeset
|
693 } |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
694 |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
695 this->InvalidateData(); |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
696 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
697 |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
698 /** Calback to update internal data. |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
699 * - 0: (optionally) build availables, update button status. |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
700 * - 1: build availables, Add newly found grfs, update button status. |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
701 * - 2: (optionally) build availables, Reset preset, + 3 |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
702 * - 3: (optionally) build availables, Update active scrollbar, update button status. |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
703 * - 4: Force a rebuild of the availables, + 2 |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
704 */ |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
705 virtual void OnInvalidateData(int data = 0) |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
706 { |
10793
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
707 switch (data) { |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
708 default: NOT_REACHED(); |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
709 case 0: |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
710 /* Nothing important to do */ |
10793
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
711 break; |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
712 |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
713 case 1: |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
714 /* Search the list for items that are now found and mark them as such. */ |
15423
fa1322ffb258
(svn r20066) -Fix: When rescanning NewGRFs resp. after content download also check whether compatible grfs are available now.
frosch <frosch@openttd.org>
parents:
15400
diff
changeset
|
715 for (GRFConfig **l = &this->actives; *l != NULL; l = &(*l)->next) { |
fa1322ffb258
(svn r20066) -Fix: When rescanning NewGRFs resp. after content download also check whether compatible grfs are available now.
frosch <frosch@openttd.org>
parents:
15400
diff
changeset
|
716 GRFConfig *c = *l; |
fa1322ffb258
(svn r20066) -Fix: When rescanning NewGRFs resp. after content download also check whether compatible grfs are available now.
frosch <frosch@openttd.org>
parents:
15400
diff
changeset
|
717 bool compatible = HasBit(c->flags, GCF_COMPATIBLE); |
fa1322ffb258
(svn r20066) -Fix: When rescanning NewGRFs resp. after content download also check whether compatible grfs are available now.
frosch <frosch@openttd.org>
parents:
15400
diff
changeset
|
718 if (c->status != GCS_NOT_FOUND && !compatible) continue; |
10793
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
719 |
15423
fa1322ffb258
(svn r20066) -Fix: When rescanning NewGRFs resp. after content download also check whether compatible grfs are available now.
frosch <frosch@openttd.org>
parents:
15400
diff
changeset
|
720 const GRFConfig *f = FindGRFConfig(c->ident.grfid, compatible ? c->original_md5sum : c->ident.md5sum); |
10793
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
721 if (f == NULL) continue; |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
722 |
15423
fa1322ffb258
(svn r20066) -Fix: When rescanning NewGRFs resp. after content download also check whether compatible grfs are available now.
frosch <frosch@openttd.org>
parents:
15400
diff
changeset
|
723 *l = DuplicateGRFConfig(f); |
fa1322ffb258
(svn r20066) -Fix: When rescanning NewGRFs resp. after content download also check whether compatible grfs are available now.
frosch <frosch@openttd.org>
parents:
15400
diff
changeset
|
724 (*l)->next = c->next; |
10793
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
725 |
15423
fa1322ffb258
(svn r20066) -Fix: When rescanning NewGRFs resp. after content download also check whether compatible grfs are available now.
frosch <frosch@openttd.org>
parents:
15400
diff
changeset
|
726 if (active_sel == c) active_sel = *l; |
fa1322ffb258
(svn r20066) -Fix: When rescanning NewGRFs resp. after content download also check whether compatible grfs are available now.
frosch <frosch@openttd.org>
parents:
15400
diff
changeset
|
727 |
fa1322ffb258
(svn r20066) -Fix: When rescanning NewGRFs resp. after content download also check whether compatible grfs are available now.
frosch <frosch@openttd.org>
parents:
15400
diff
changeset
|
728 delete c; |
10793
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
729 } |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
730 /* Fall through. */ |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
731 case 4: |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
732 this->avails.ForceRebuild(); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
733 /* Fall through. */ |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
734 case 2: |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
735 this->preset = -1; |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
736 /* Fall through */ |
15201
071e920abcfb
(svn r19830) -Codechange: Move variable declarations to their first use.
alberth <alberth@openttd.org>
parents:
15200
diff
changeset
|
737 case 3: { |
071e920abcfb
(svn r19830) -Codechange: Move variable declarations to their first use.
alberth <alberth@openttd.org>
parents:
15200
diff
changeset
|
738 int i = 0; |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
739 for (const GRFConfig *c = this->actives; c != NULL; c = c->next, i++) {} |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
740 |
14037
ca29deba0f1a
(svn r18580) -Codechange: Use widget information only for setting scrollbar capacity.
alberth <alberth@openttd.org>
parents:
13968
diff
changeset
|
741 this->vscroll.SetCapacityFromWidget(this, SNGRFS_FILE_LIST); |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
742 this->vscroll.SetCount(i); |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
743 |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
744 this->vscroll2.SetCapacityFromWidget(this, SNGRFS_AVAIL_LIST); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
745 if (this->avail_pos >= 0) this->vscroll2.ScrollTowards(this->avail_pos); |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
746 break; |
15201
071e920abcfb
(svn r19830) -Codechange: Move variable declarations to their first use.
alberth <alberth@openttd.org>
parents:
15200
diff
changeset
|
747 } |
10793
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
748 } |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
749 |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
750 this->BuildAvailables(); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
751 |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
752 this->SetWidgetsDisabledState(!this->editable, |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
753 SNGRFS_PRESET_LIST, |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
754 SNGRFS_APPLY_CHANGES, |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
755 SNGRFS_TOGGLE_PALETTE, |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
756 WIDGET_LIST_END |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
757 ); |
15212
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
758 this->SetWidgetDisabledState(SNGRFS_ADD, !this->editable || this->avail_sel == NULL); |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
759 |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
760 bool disable_all = this->active_sel == NULL || !this->editable; |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
761 this->SetWidgetsDisabledState(disable_all, |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
762 SNGRFS_REMOVE, |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
763 SNGRFS_MOVE_UP, |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
764 SNGRFS_MOVE_DOWN, |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
765 WIDGET_LIST_END |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
766 ); |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
767 this->SetWidgetDisabledState(SNGRFS_SET_PARAMETERS, !this->show_params || disable_all); |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
768 this->SetWidgetDisabledState(SNGRFS_TOGGLE_PALETTE, disable_all); |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
769 |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
770 if (!disable_all) { |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
771 /* All widgets are now enabled, so disable widgets we can't use */ |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
772 if (this->active_sel == this->actives) this->DisableWidget(SNGRFS_MOVE_UP); |
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
773 if (this->active_sel->next == NULL) this->DisableWidget(SNGRFS_MOVE_DOWN); |
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
774 if (this->active_sel->IsOpenTTDBaseGRF()) this->DisableWidget(SNGRFS_REMOVE); |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
775 } |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
776 |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
777 this->SetWidgetDisabledState(SNGRFS_PRESET_DELETE, this->preset == -1); |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
778 |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
779 bool has_missing = false; |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
780 bool has_compatible = false; |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
781 for (const GRFConfig *c = this->actives; !has_missing && c != NULL; c = c->next) { |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
782 has_missing |= c->status == GCS_NOT_FOUND; |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
783 has_compatible |= HasBit(c->flags, GCF_COMPATIBLE); |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
784 } |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
785 if (has_missing || has_compatible) { |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
786 this->GetWidget<NWidgetCore>(SNGRFS_CONTENT_DOWNLOAD)->widget_data = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON; |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
787 this->GetWidget<NWidgetCore>(SNGRFS_CONTENT_DOWNLOAD)->tool_tip = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP; |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
788 } else { |
13171
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
789 this->GetWidget<NWidgetCore>(SNGRFS_CONTENT_DOWNLOAD)->widget_data = STR_INTRO_ONLINE_CONTENT; |
93c95e6c1a53
(svn r17676) -Codechange: make the NewGRF GUI nested
rubidium <rubidium@openttd.org>
parents:
13170
diff
changeset
|
790 this->GetWidget<NWidgetCore>(SNGRFS_CONTENT_DOWNLOAD)->tool_tip = STR_INTRO_TOOLTIP_ONLINE_CONTENT; |
13170
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
791 } |
c001604f4ab3
(svn r17675) -Codechange: move the 'state' changes out of the OnPaint of the newgrf window
rubidium <rubidium@openttd.org>
parents:
13168
diff
changeset
|
792 this->SetWidgetDisabledState(SNGRFS_PRESET_SAVE, has_missing); |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
793 } |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
794 |
15209
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
795 virtual void OnMouseLoop() |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
796 { |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
797 this->HandleEditBox(SNGRFS_FILTER); |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
798 } |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
799 |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
800 virtual EventState OnKeyPress(uint16 key, uint16 keycode) |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
801 { |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
802 switch (keycode) { |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
803 case WKC_UP: |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
804 /* scroll up by one */ |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
805 if (this->avail_pos > 0) this->avail_pos--; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
806 break; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
807 |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
808 case WKC_DOWN: |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
809 /* scroll down by one */ |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
810 if (this->avail_pos < (int)this->avails.Length() - 1) this->avail_pos++; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
811 break; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
812 |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
813 case WKC_PAGEUP: |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
814 /* scroll up a page */ |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
815 this->avail_pos = (this->avail_pos < this->vscroll2.GetCapacity()) ? 0 : this->avail_pos - this->vscroll2.GetCapacity(); |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
816 break; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
817 |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
818 case WKC_PAGEDOWN: |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
819 /* scroll down a page */ |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
820 this->avail_pos = min(this->avail_pos + this->vscroll2.GetCapacity(), (int)this->avails.Length() - 1); |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
821 break; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
822 |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
823 case WKC_HOME: |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
824 /* jump to beginning */ |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
825 this->avail_pos = 0; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
826 break; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
827 |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
828 case WKC_END: |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
829 /* jump to end */ |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
830 this->avail_pos = this->avails.Length() - 1; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
831 break; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
832 |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
833 default: { |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
834 /* Handle editbox input */ |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
835 EventState state = ES_NOT_HANDLED; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
836 if (this->HandleEditBoxKey(SNGRFS_FILTER, key, keycode, state) == HEBR_EDITING) { |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
837 this->OnOSKInput(SNGRFS_FILTER); |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
838 } |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
839 return state; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
840 } |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
841 } |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
842 |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
843 if (this->avails.Length() == 0) this->avail_pos = -1; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
844 if (this->avail_pos >= 0) { |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
845 this->avail_sel = this->avails[this->avail_pos]; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
846 this->vscroll2.ScrollTowards(this->avail_pos); |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
847 this->InvalidateData(0); |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
848 } |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
849 |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
850 return ES_HANDLED; |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
851 } |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
852 |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
853 virtual void OnOSKInput(int wid) |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
854 { |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
855 this->avails.SetFilterState(!StrEmpty(this->edit_str_buf)); |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
856 this->avails.ForceRebuild(); |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
857 this->InvalidateData(0); |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
858 } |
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
859 |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
860 private: |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
861 /** Sort grfs by name. */ |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
862 static int CDECL NameSorter(const GRFConfig * const *a, const GRFConfig * const *b) |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
863 { |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
864 return strcasecmp((*a)->GetName(), (*b)->GetName()); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
865 } |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
866 |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
867 /** Filter grfs by tags/name */ |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
868 static bool CDECL TagNameFilter(const GRFConfig * const *a, const char *filter_string) |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
869 { |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
870 if (strcasestr((*a)->GetName(), filter_string) != NULL) return true; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
871 if ((*a)->filename != NULL && strcasestr((*a)->filename, filter_string) != NULL) return true; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
872 if ((*a)->GetDescription() != NULL && strcasestr((*a)->GetDescription(), filter_string) != NULL) return true; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
873 return false; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
874 } |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
875 |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
876 void BuildAvailables() |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
877 { |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
878 if (!this->avails.NeedRebuild()) return; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
879 |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
880 this->avails.Clear(); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
881 |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
882 for (const GRFConfig *c = _all_grfs; c != NULL; c = c->next) { |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
883 bool found = false; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
884 for (const GRFConfig *grf = this->actives; grf != NULL && !found; grf = grf->next) found = grf->ident.HasGrfIdentifier(c->ident.grfid, c->ident.md5sum); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
885 if (!found) *this->avails.Append() = c; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
886 } |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
887 |
15209
eb71d6bac72c
(svn r19838) -Change: Add filter capability to the availables list.
alberth <alberth@openttd.org>
parents:
15208
diff
changeset
|
888 this->avails.Filter(this->edit_str_buf); |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
889 this->avails.Compact(); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
890 this->avails.RebuildDone(); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
891 this->avails.Sort(); |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
892 |
15212
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
893 if (this->avail_sel != NULL) { |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
894 this->avail_pos = this->avails.FindIndex(this->avail_sel); |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
895 if (this->avail_pos < 0) this->avail_sel = NULL; |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
896 } |
a4e976b89e90
(svn r19841) -Feature: Setup NewGRFs from a single window.
alberth <alberth@openttd.org>
parents:
15211
diff
changeset
|
897 |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
898 this->vscroll2.SetCount(this->avails.Length()); // Update the scrollbar |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
899 } |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
900 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
901 |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
902 Listing NewGRFWindow::last_sorting = {false, 0}; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
903 Filtering NewGRFWindow::last_filtering = {false, 0}; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
904 |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
905 NewGRFWindow::GUIGRFConfigList::SortFunction * const NewGRFWindow::sorter_funcs[] = { |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
906 &NameSorter, |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
907 }; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
908 |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
909 NewGRFWindow::GUIGRFConfigList::FilterFunction * const NewGRFWindow::filter_funcs[] = { |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
910 &TagNameFilter, |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
911 }; |
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
912 |
15216
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
913 /** Custom nested widget container for the NewGRF gui. |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
914 * Depending on the space in the gui, it uses either |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
915 * - two column mode, put the #acs and the #avs underneath each other and the #info next to it, or |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
916 * - three column mode, put the #avs, #acs, and #info each in its own column. |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
917 */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
918 class NWidgetNewGRFDisplay : public NWidgetContainer { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
919 public: |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
920 static const uint INTER_LIST_SPACING; ///< Empty vertical space between both lists in the 2 column mode. |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
921 static const uint INTER_COLUMN_SPACING; ///< Empty horizontal space between two columns. |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
922 static const uint MAX_EXTRA_INFO_WIDTH; ///< Maximal additional width given to the panel. |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
923 static const uint MIN_EXTRA_FOR_3_COLUMNS; ///< Minimal additional width needed before switching to 3 columns. |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
924 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
925 NWidgetBase *avs; ///< Widget with the available grfs list and buttons. |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
926 NWidgetBase *acs; ///< Widget with the active grfs list and buttons. |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
927 NWidgetBase *inf; ///< Info panel. |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
928 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
929 NWidgetNewGRFDisplay(NWidgetBase *avs, NWidgetBase *acs, NWidgetBase *inf) : NWidgetContainer(NWID_HORIZONTAL) |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
930 { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
931 this->avs = avs; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
932 this->acs = acs; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
933 this->inf = inf; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
934 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
935 this->Add(this->avs); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
936 this->Add(this->acs); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
937 this->Add(this->inf); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
938 } |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
939 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
940 virtual void SetupSmallestSize(Window *w, bool init_array) |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
941 { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
942 this->avs->SetupSmallestSize(w, init_array); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
943 this->acs->SetupSmallestSize(w, init_array); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
944 this->inf->SetupSmallestSize(w, init_array); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
945 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
946 uint min_avs_width = this->avs->smallest_x + this->avs->padding_left + this->avs->padding_right; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
947 uint min_acs_width = this->acs->smallest_x + this->acs->padding_left + this->acs->padding_right; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
948 uint min_inf_width = this->inf->smallest_x + this->inf->padding_left + this->inf->padding_right; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
949 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
950 uint min_avs_height = this->avs->smallest_y + this->avs->padding_top + this->avs->padding_bottom; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
951 uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
952 uint min_inf_height = this->inf->smallest_y + this->inf->padding_top + this->inf->padding_bottom; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
953 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
954 /* Smallest window is in two column mode. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
955 this->smallest_x = max(min_avs_width, min_acs_width) + INTER_COLUMN_SPACING + min_inf_width; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
956 this->smallest_y = max(min_inf_height, min_acs_height + INTER_LIST_SPACING + min_avs_height); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
957 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
958 /* Filling. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
959 this->fill_x = LeastCommonMultiple(this->avs->fill_x, this->acs->fill_x); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
960 if (this->inf->fill_x > 0 && (this->fill_x == 0 || this->fill_x > this->inf->fill_x)) this->fill_x = this->inf->fill_x; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
961 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
962 this->fill_y = this->avs->fill_y; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
963 if (this->acs->fill_y > 0 && (this->fill_y == 0 || this->fill_y > this->acs->fill_y)) this->fill_y = this->acs->fill_y; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
964 this->fill_y = LeastCommonMultiple(this->fill_y, this->inf->fill_y); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
965 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
966 /* Resizing. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
967 this->resize_x = LeastCommonMultiple(this->avs->resize_x, this->acs->resize_x); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
968 if (this->inf->resize_x > 0 && (this->resize_x == 0 || this->resize_x > this->inf->resize_x)) this->resize_x = this->inf->resize_x; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
969 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
970 this->resize_y = this->avs->resize_y; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
971 if (this->acs->resize_y > 0 && (this->resize_y == 0 || this->resize_y > this->acs->resize_y)) this->resize_y = this->acs->resize_y; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
972 this->resize_y = LeastCommonMultiple(this->resize_y, this->inf->resize_y); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
973 } |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
974 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
975 virtual void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
976 { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
977 this->StoreSizePosition(sizing, x, y, given_width, given_height); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
978 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
979 uint min_avs_width = this->avs->smallest_x + this->avs->padding_left + this->avs->padding_right; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
980 uint min_acs_width = this->acs->smallest_x + this->acs->padding_left + this->acs->padding_right; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
981 uint min_inf_width = this->inf->smallest_x + this->inf->padding_left + this->inf->padding_right; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
982 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
983 uint min_list_width = max(min_avs_width, min_acs_width); // Smallest width of the lists such that they have equal width (incl padding). |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
984 uint avs_extra_width = min_list_width - min_avs_width; // Additional width needed for avs to reach min_list_width. |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
985 uint acs_extra_width = min_list_width - min_acs_width; // Additional width needed for acs to reach min_list_width. |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
986 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
987 /* Use 2 or 3 colmuns? */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
988 uint min_three_columns = min_avs_width + min_acs_width + min_inf_width + 2 * INTER_COLUMN_SPACING; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
989 uint min_two_columns = min_list_width + min_inf_width + INTER_COLUMN_SPACING; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
990 bool use_three_columns = (min_three_columns + MIN_EXTRA_FOR_3_COLUMNS <= given_width); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
991 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
992 /* Info panel is a seperate column in both modes. Compute its width first. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
993 uint extra_width, inf_width; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
994 if (use_three_columns) { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
995 extra_width = given_width - min_three_columns; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
996 inf_width = min(MAX_EXTRA_INFO_WIDTH, extra_width / 2); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
997 } else { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
998 extra_width = given_width - min_two_columns; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
999 inf_width = min(MAX_EXTRA_INFO_WIDTH, extra_width / 2); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1000 } |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1001 inf_width = ComputeMaxSize(this->inf->smallest_x, this->inf->smallest_x + inf_width, this->inf->GetHorizontalStepSize(sizing)); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1002 extra_width -= inf_width - this->inf->smallest_x; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1003 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1004 uint inf_height = ComputeMaxSize(this->inf->smallest_y, given_height, this->inf->GetVerticalStepSize(sizing)); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1005 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1006 if (use_three_columns) { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1007 /* Three column display, first make both lists equally wide, then divide whatever is left between both lists. |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1008 * Only keep track of what avs gets, all other space goes to acs. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1009 uint avs_width = min(avs_extra_width, extra_width); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1010 extra_width -= avs_width; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1011 extra_width -= min(acs_extra_width, extra_width); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1012 avs_width += extra_width / 2; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1013 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1014 avs_width = ComputeMaxSize(this->avs->smallest_x, this->avs->smallest_x + avs_width, this->avs->GetHorizontalStepSize(sizing)); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1015 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1016 uint acs_width = given_width - // Remaining space, including horizontal padding. |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1017 inf_width - this->inf->padding_left - this->inf->padding_right - |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1018 avs_width - this->avs->padding_left - this->avs->padding_right - 2 * INTER_COLUMN_SPACING; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1019 acs_width = ComputeMaxSize(min_acs_width, acs_width, this->acs->GetHorizontalStepSize(sizing)) - |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1020 this->acs->padding_left - this->acs->padding_right; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1021 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1022 uint avs_height = ComputeMaxSize(this->avs->smallest_y, given_height, this->avs->GetVerticalStepSize(sizing)); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1023 uint acs_height = ComputeMaxSize(this->acs->smallest_y, given_height, this->acs->GetVerticalStepSize(sizing)); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1024 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1025 /* Assign size and position to the childs. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1026 if (rtl) { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1027 x += this->inf->padding_left; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1028 this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1029 x += inf_width + this->inf->padding_right + INTER_COLUMN_SPACING; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1030 } else { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1031 x += this->avs->padding_left; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1032 this->avs->AssignSizePosition(sizing, x, y + this->avs->padding_top, avs_width, avs_height, rtl); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1033 x += avs_width + this->avs->padding_right + INTER_COLUMN_SPACING; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1034 } |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1035 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1036 x += this->acs->padding_left; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1037 this->acs->AssignSizePosition(sizing, x, y + this->acs->padding_top, acs_width, acs_height, rtl); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1038 x += acs_width + this->acs->padding_right + INTER_COLUMN_SPACING; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1039 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1040 if (rtl) { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1041 x += this->avs->padding_left; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1042 this->avs->AssignSizePosition(sizing, x, y + this->avs->padding_top, avs_width, avs_height, rtl); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1043 } else { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1044 x += this->inf->padding_left; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1045 this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1046 } |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1047 } else { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1048 /* Two columns, all space in extra_width goes to both lists. Since the lists are underneath each other, |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1049 * the column is min_list_width wide at least. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1050 uint avs_width = ComputeMaxSize(this->avs->smallest_x, this->avs->smallest_x + avs_extra_width + extra_width, |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1051 this->avs->GetHorizontalStepSize(sizing)); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1052 uint acs_width = ComputeMaxSize(this->acs->smallest_x, this->acs->smallest_x + acs_extra_width + extra_width, |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1053 this->acs->GetHorizontalStepSize(sizing)); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1054 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1055 uint min_avs_height = this->avs->smallest_y + this->avs->padding_top + this->avs->padding_bottom; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1056 uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1057 uint extra_height = given_height - min_acs_height - min_avs_height - INTER_LIST_SPACING; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1058 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1059 uint avs_height = ComputeMaxSize(this->avs->smallest_y, this->avs->smallest_y + extra_height / 2, this->avs->GetVerticalStepSize(sizing)); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1060 extra_height -= avs_height - this->avs->smallest_y; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1061 uint acs_height = ComputeMaxSize(this->acs->smallest_y, this->acs->smallest_y + extra_height, this->acs->GetVerticalStepSize(sizing)); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1062 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1063 /* Assign size and position to the childs. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1064 if (rtl) { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1065 x += this->inf->padding_left; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1066 this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1067 x += inf_width + this->inf->padding_right + INTER_COLUMN_SPACING; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1068 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1069 uint ypos = y + this->acs->padding_top; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1070 this->acs->AssignSizePosition(sizing, x + this->acs->padding_left, ypos, acs_width, acs_height, rtl); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1071 ypos += acs_height + this->acs->padding_bottom + INTER_LIST_SPACING + this->avs->padding_top; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1072 this->avs->AssignSizePosition(sizing, x + this->avs->padding_left, ypos, avs_width, avs_height, rtl); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1073 } else { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1074 uint ypos = y + this->acs->padding_top; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1075 this->acs->AssignSizePosition(sizing, x + this->acs->padding_left, ypos, acs_width, acs_height, rtl); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1076 ypos += acs_height + this->acs->padding_bottom + INTER_LIST_SPACING + this->avs->padding_top; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1077 this->avs->AssignSizePosition(sizing, x + this->avs->padding_left, ypos, avs_width, avs_height, rtl); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1078 x += max(this->acs->current_x + this->acs->padding_left + this->acs->padding_right, |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1079 this->avs->current_x + this->avs->padding_left + this->avs->padding_right) + INTER_COLUMN_SPACING; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1080 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1081 x += this->inf->padding_left; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1082 this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1083 } |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1084 } |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1085 } |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1086 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1087 virtual NWidgetCore *GetWidgetFromPos(int x, int y) |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1088 { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1089 if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return NULL; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1090 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1091 NWidgetCore *nw = this->avs->GetWidgetFromPos(x, y); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1092 if (nw == NULL) nw = this->acs->GetWidgetFromPos(x, y); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1093 if (nw == NULL) nw = this->inf->GetWidgetFromPos(x, y); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1094 return nw; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1095 } |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1096 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1097 virtual void Draw(const Window *w) |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1098 { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1099 this->avs->Draw(w); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1100 this->acs->Draw(w); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1101 this->inf->Draw(w); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1102 } |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1103 }; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1104 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1105 const uint NWidgetNewGRFDisplay::INTER_LIST_SPACING = WD_RESIZEBOX_WIDTH + 1; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1106 const uint NWidgetNewGRFDisplay::INTER_COLUMN_SPACING = WD_RESIZEBOX_WIDTH; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1107 const uint NWidgetNewGRFDisplay::MAX_EXTRA_INFO_WIDTH = 150; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1108 const uint NWidgetNewGRFDisplay::MIN_EXTRA_FOR_3_COLUMNS = 50; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1109 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1110 static const NWidgetPart _nested_newgrf_actives_widgets[] = { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1111 /* Left side, presets. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1112 NWidget(NWID_HORIZONTAL), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1113 NWidget(WWT_TEXT, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_SETTINGS_SELECT_PRESET, STR_NULL), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1114 SetPadding(0, WD_FRAMETEXT_RIGHT, 0, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1115 NWidget(WWT_DROPDOWN, COLOUR_YELLOW, SNGRFS_PRESET_LIST), SetFill(1, 0), SetResize(1, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1116 SetDataTip(STR_JUST_STRING, STR_NEWGRF_SETTINGS_PRESET_LIST_TOOLTIP), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1117 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1118 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1119 NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, SNGRFS_PRESET_SAVE), SetFill(1, 0), SetResize(1, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1120 SetDataTip(STR_NEWGRF_SETTINGS_PRESET_SAVE, STR_NEWGRF_SETTINGS_PRESET_SAVE_TOOLTIP), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1121 NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, SNGRFS_PRESET_DELETE), SetFill(1, 0), SetResize(1, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1122 SetDataTip(STR_NEWGRF_SETTINGS_PRESET_DELETE, STR_NEWGRF_SETTINGS_PRESET_DELETE_TOOLTIP), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1123 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1124 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1125 NWidget(NWID_SPACER), SetMinimalSize(0, WD_RESIZEBOX_WIDTH), SetResize(1, 0), SetFill(1, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1126 NWidget(WWT_PANEL, COLOUR_MAUVE), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1127 NWidget(WWT_LABEL, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_SETTINGS_ACTIVE_LIST, STR_NULL), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1128 SetFill(1, 0), SetResize(1, 0), SetPadding(3, WD_FRAMETEXT_RIGHT, 0, WD_FRAMETEXT_LEFT), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1129 /* Left side, active grfs. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1130 NWidget(NWID_HORIZONTAL), SetPadding(0, 2, 0, 2), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1131 NWidget(WWT_PANEL, COLOUR_MAUVE), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1132 NWidget(WWT_INSET, COLOUR_MAUVE, SNGRFS_FILE_LIST), SetMinimalSize(100, 1), SetPadding(2, 2, 2, 2), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1133 SetFill(1, 1), SetResize(1, 1), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1134 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1135 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1136 NWidget(WWT_SCROLLBAR, COLOUR_MAUVE, SNGRFS_SCROLLBAR), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1137 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1138 /* Buttons. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1139 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPadding(2, 2, 2, 2), SetPIP(0, WD_RESIZEBOX_WIDTH, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1140 NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, SNGRFS_REMOVE), SetFill(1, 0), SetResize(1, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1141 SetDataTip(STR_NEWGRF_SETTINGS_REMOVE, STR_NEWGRF_SETTINGS_REMOVE_TOOLTIP), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1142 NWidget(NWID_VERTICAL), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1143 NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, SNGRFS_MOVE_UP), SetFill(1, 0), SetResize(1, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1144 SetDataTip(STR_NEWGRF_SETTINGS_MOVEUP, STR_NEWGRF_SETTINGS_MOVEUP_TOOLTIP), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1145 NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, SNGRFS_MOVE_DOWN), SetFill(1, 0), SetResize(1, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1146 SetDataTip(STR_NEWGRF_SETTINGS_MOVEDOWN, STR_NEWGRF_SETTINGS_MOVEDOWN_TOOLTIP), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1147 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1148 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1149 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1150 }; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1151 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1152 static const NWidgetPart _nested_newgrf_availables_widgets[] = { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1153 NWidget(WWT_PANEL, COLOUR_MAUVE), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1154 NWidget(WWT_LABEL, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_SETTINGS_INACTIVE_LIST, STR_NULL), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1155 SetFill(1, 0), SetResize(1, 0), SetPadding(3, WD_FRAMETEXT_RIGHT, 0, WD_FRAMETEXT_LEFT), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1156 /* Left side, available grfs, filter edit box. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1157 NWidget(NWID_HORIZONTAL), SetPadding(WD_TEXTPANEL_TOP, 0, WD_TEXTPANEL_BOTTOM, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1158 SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_RIGHT), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1159 NWidget(WWT_TEXT, COLOUR_MAUVE), SetFill(0, 1), SetDataTip(STR_NEWGRF_FILTER_TITLE, STR_NULL), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1160 NWidget(WWT_EDITBOX, COLOUR_MAUVE, SNGRFS_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1161 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1162 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1163 /* Left side, available grfs. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1164 NWidget(NWID_HORIZONTAL), SetPadding(0, 2, 0, 2), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1165 NWidget(WWT_PANEL, COLOUR_MAUVE), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1166 NWidget(WWT_INSET, COLOUR_MAUVE, SNGRFS_AVAIL_LIST), SetMinimalSize(100, 1), SetPadding(2, 2, 2, 2), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1167 SetFill(1, 1), SetResize(1, 1), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1168 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1169 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1170 NWidget(WWT_SCROLL2BAR, COLOUR_MAUVE, SNGRFS_SCROLL2BAR), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1171 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1172 /* Left side, available grfs, buttons. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1173 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPadding(2, 2, 2, 2), SetPIP(0, WD_RESIZEBOX_WIDTH, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1174 NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, SNGRFS_ADD), SetFill(1, 0), SetResize(1, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1175 SetDataTip(STR_NEWGRF_SETTINGS_ADD, STR_NEWGRF_SETTINGS_ADD_FILE_TOOLTIP), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1176 NWidget(NWID_VERTICAL), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1177 NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, SNGRFS_RESCAN_FILES), SetFill(1, 0), SetResize(1, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1178 SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1179 NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, SNGRFS_CONTENT_DOWNLOAD), SetFill(1, 0), SetResize(1, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1180 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1181 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1182 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1183 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1184 }; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1185 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1186 static const NWidgetPart _nested_newgrf_infopanel_widgets[] = { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1187 /* Right side, info panel. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1188 NWidget(WWT_PANEL, COLOUR_MAUVE), SetPadding(0, 0, 2, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1189 NWidget(WWT_EMPTY, COLOUR_MAUVE, SNGRFS_NEWGRF_INFO_TITLE), SetFill(1, 0), SetResize(1, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1190 NWidget(WWT_EMPTY, COLOUR_MAUVE, SNGRFS_NEWGRF_INFO), SetFill(1, 1), SetResize(1, 1), SetMinimalSize(150, 100), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1191 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1192 /* Right side, buttons. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1193 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(0, WD_RESIZEBOX_WIDTH, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1194 NWidget(NWID_VERTICAL), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1195 NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, SNGRFS_SET_PARAMETERS), SetFill(1, 0), SetResize(1, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1196 SetDataTip(STR_NEWGRF_SETTINGS_SET_PARAMETERS, STR_NULL), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1197 NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, SNGRFS_TOGGLE_PALETTE), SetFill(1, 0), SetResize(1, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1198 SetDataTip(STR_NEWGRF_SETTINGS_TOGGLE_PALETTE, STR_NEWGRF_SETTINGS_TOGGLE_PALETTE_TOOLTIP), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1199 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1200 NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, SNGRFS_APPLY_CHANGES), SetFill(1, 0), SetResize(1, 0), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1201 SetDataTip(STR_NEWGRF_SETTINGS_APPLY_CHANGES, STR_NULL), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1202 EndContainer(), |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1203 }; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1204 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1205 /** Construct nested container widget for managing the lists and the info panel of the NewGRF GUI. */ |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1206 NWidgetBase* NewGRFDisplay(int *biggest_index) |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1207 { |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1208 NWidgetBase *avs = MakeNWidgets(_nested_newgrf_availables_widgets, lengthof(_nested_newgrf_availables_widgets), biggest_index, NULL); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1209 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1210 int biggest2; |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1211 NWidgetBase *acs = MakeNWidgets(_nested_newgrf_actives_widgets, lengthof(_nested_newgrf_actives_widgets), &biggest2, NULL); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1212 *biggest_index = max(*biggest_index, biggest2); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1213 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1214 NWidgetBase *inf = MakeNWidgets(_nested_newgrf_infopanel_widgets, lengthof(_nested_newgrf_infopanel_widgets), &biggest2, NULL); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1215 *biggest_index = max(*biggest_index, biggest2); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1216 |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1217 return new NWidgetNewGRFDisplay(avs, acs, inf); |
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1218 } |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
1219 |
8025
7a501cf42789
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13 <skidd13@openttd.org>
parents:
8019
diff
changeset
|
1220 /* Widget definition of the manage newgrfs window */ |
11796
b89215528d20
(svn r16186) -Codechange: Adding nested widgets to _newgrf_desc and _newgrf_add_dlg_desc window descriptions.
alberth <alberth@openttd.org>
parents:
11795
diff
changeset
|
1221 static const NWidgetPart _nested_newgrf_widgets[] = { |
b89215528d20
(svn r16186) -Codechange: Adding nested widgets to _newgrf_desc and _newgrf_add_dlg_desc window descriptions.
alberth <alberth@openttd.org>
parents:
11795
diff
changeset
|
1222 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
1223 NWidget(WWT_CLOSEBOX, COLOUR_MAUVE), |
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
1224 NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_SETTINGS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), |
11796
b89215528d20
(svn r16186) -Codechange: Adding nested widgets to _newgrf_desc and _newgrf_add_dlg_desc window descriptions.
alberth <alberth@openttd.org>
parents:
11795
diff
changeset
|
1225 EndContainer(), |
13755
bf8a4ced15fe
(svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents:
13752
diff
changeset
|
1226 NWidget(WWT_PANEL, COLOUR_MAUVE), |
15216
7be3e18b9c57
(svn r19845) -Feature: Dynamically switch between 2 and 3 column NewGRF gui for improved user experience.
alberth <alberth@openttd.org>
parents:
15212
diff
changeset
|
1227 NWidgetFunction(NewGRFDisplay), SetPadding(WD_RESIZEBOX_WIDTH, WD_RESIZEBOX_WIDTH, 2, WD_RESIZEBOX_WIDTH), |
15211
e28e566488a9
(svn r19840) -Add: Add 'rescan' functionality to the NewGRF window.
alberth <alberth@openttd.org>
parents:
15209
diff
changeset
|
1228 /* Resize button. */ |
e28e566488a9
(svn r19840) -Add: Add 'rescan' functionality to the NewGRF window.
alberth <alberth@openttd.org>
parents:
15209
diff
changeset
|
1229 NWidget(NWID_HORIZONTAL), |
e28e566488a9
(svn r19840) -Add: Add 'rescan' functionality to the NewGRF window.
alberth <alberth@openttd.org>
parents:
15209
diff
changeset
|
1230 NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0), |
e28e566488a9
(svn r19840) -Add: Add 'rescan' functionality to the NewGRF window.
alberth <alberth@openttd.org>
parents:
15209
diff
changeset
|
1231 NWidget(WWT_RESIZEBOX, COLOUR_MAUVE), |
e28e566488a9
(svn r19840) -Add: Add 'rescan' functionality to the NewGRF window.
alberth <alberth@openttd.org>
parents:
15209
diff
changeset
|
1232 EndContainer(), |
11796
b89215528d20
(svn r16186) -Codechange: Adding nested widgets to _newgrf_desc and _newgrf_add_dlg_desc window descriptions.
alberth <alberth@openttd.org>
parents:
11795
diff
changeset
|
1233 EndContainer(), |
b89215528d20
(svn r16186) -Codechange: Adding nested widgets to _newgrf_desc and _newgrf_add_dlg_desc window descriptions.
alberth <alberth@openttd.org>
parents:
11795
diff
changeset
|
1234 }; |
b89215528d20
(svn r16186) -Codechange: Adding nested widgets to _newgrf_desc and _newgrf_add_dlg_desc window descriptions.
alberth <alberth@openttd.org>
parents:
11795
diff
changeset
|
1235 |
8025
7a501cf42789
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13 <skidd13@openttd.org>
parents:
8019
diff
changeset
|
1236 /* Window definition of the manage newgrfs window */ |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11208
diff
changeset
|
1237 static const WindowDesc _newgrf_desc( |
13796
3e68f07eb821
(svn r18322) -Codechange: remove the WDP duplication; no need to tell the same twice.
rubidium <rubidium@openttd.org>
parents:
13755
diff
changeset
|
1238 WDP_CENTER, 300, 263, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5668
diff
changeset
|
1239 WC_GAME_OPTIONS, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13705
diff
changeset
|
1240 WDF_UNCLICK_BUTTONS, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13419
diff
changeset
|
1241 _nested_newgrf_widgets, lengthof(_nested_newgrf_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11208
diff
changeset
|
1242 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1243 |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1244 /** Callback function for the newgrf 'apply changes' confirmation window |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1245 * @param w Window which is calling this callback |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1246 * @param confirmed boolean value, true when yes was clicked, false otherwise |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1247 */ |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1248 static void NewGRFConfirmationCallback(Window *w, bool confirmed) |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1249 { |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1250 if (confirmed) { |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1251 NewGRFWindow *nw = dynamic_cast<NewGRFWindow*>(w); |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1252 |
9457
267a95510fdf
(svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents:
9317
diff
changeset
|
1253 GamelogStartAction(GLAT_GRF); |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
1254 GamelogGRFUpdate(_grfconfig, nw->actives); // log GRF changes |
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
1255 CopyGRFConfigList(nw->orig_list, nw->actives, false); |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1256 ReloadNewGRFData(); |
9457
267a95510fdf
(svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents:
9317
diff
changeset
|
1257 GamelogStopAction(); |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1258 |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1259 /* Show new, updated list */ |
15201
071e920abcfb
(svn r19830) -Codechange: Move variable declarations to their first use.
alberth <alberth@openttd.org>
parents:
15200
diff
changeset
|
1260 GRFConfig *c; |
071e920abcfb
(svn r19830) -Codechange: Move variable declarations to their first use.
alberth <alberth@openttd.org>
parents:
15200
diff
changeset
|
1261 int i = 0; |
15203
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
1262 for (c = nw->actives; c != NULL && c != nw->active_sel; c = c->next, i++) {} |
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
1263 CopyGRFConfigList(&nw->actives, *nw->orig_list, false); |
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
1264 for (c = nw->actives; c != NULL && i > 0; c = c->next, i--) {} |
2ef926c44a98
(svn r19832) -Codechange: Rename variables list->actives, sel->active_sel.
alberth <alberth@openttd.org>
parents:
15202
diff
changeset
|
1265 nw->active_sel = c; |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
1266 nw->avails.ForceRebuild(); |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1267 |
15208
ebff51f3984b
(svn r19837) -Change: Display list of available (non-active) grfs in the NewGRF window.
alberth <alberth@openttd.org>
parents:
15207
diff
changeset
|
1268 w->InvalidateData(); |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1269 } |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1270 } |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1271 |
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1272 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1273 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1274 /** Setup the NewGRF gui |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1275 * @param editable allow the user to make changes to the grfconfig in the window |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1276 * @param show_params show information about what parameters are set for the grf files |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1277 * @param exec_changes if changes are made to the list (editable is true), apply these |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1278 * changes immediately or only update the list |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1279 * @param config pointer to a linked-list of grfconfig's that will be shown */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1280 void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1281 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1282 DeleteWindowByClass(WC_GAME_OPTIONS); |
9207
839a532bf0f6
(svn r13073) -Codechange: make classes of the NewGRF windows
peter1138 <peter1138@openttd.org>
parents:
9164
diff
changeset
|
1283 new NewGRFWindow(&_newgrf_desc, editable, show_params, exec_changes, config); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1284 } |