author | rubidium |
Sun, 02 Dec 2007 14:29:48 +0000 | |
changeset 8493 | 3ab458f7cff4 |
parent 8424 | 4a488a90ccab |
child 8514 | b3ae8cdf13c0 |
permissions | -rw-r--r-- |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
1 |
/* $Id$ */ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
2 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
3 |
/** @file newgrf_gui.cpp */ |
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
4 |
|
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
6 |
#include "openttd.h" |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
7 |
#include "functions.h" |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
8 |
#include "variables.h" |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
9 |
#include "gfx.h" |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
10 |
#include "gui.h" |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
11 |
#include "window.h" |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
12 |
#include "table/strings.h" |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
13 |
#include "table/sprites.h" |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
14 |
#include "newgrf.h" |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
15 |
#include "newgrf_config.h" |
6465
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6429
diff
changeset
|
16 |
#include "strings.h" |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
17 |
#include "helpers.hpp" |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
18 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
19 |
/** Parse an integerlist string and set each found value |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
20 |
* @param p the string to be parsed. Each element in the list is seperated by a |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
21 |
* comma or a space character |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
22 |
* @param items pointer to the integerlist-array that will be filled with values |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
23 |
* @param maxitems the maximum number of elements the integerlist-array has |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
24 |
* @return returns the number of items found, or -1 on an error */ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
25 |
static int parse_intlist(const char *p, int *items, int maxitems) |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
26 |
{ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
27 |
int n = 0, v; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
28 |
char *end; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
29 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
30 |
for (;;) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
31 |
v = strtol(p, &end, 0); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
32 |
if (p == end || n == maxitems) return -1; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
33 |
p = end; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
34 |
items[n++] = v; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
35 |
if (*p == '\0') break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
36 |
if (*p != ',' && *p != ' ') return -1; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
37 |
p++; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
38 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
39 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
40 |
return n; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
41 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
42 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
43 |
|
6703
9ddfcb1849e4
(svn r9449) -Fix: Truncate the newgrf information text in the newgrf gui if it's too long.
maedhros
parents:
6674
diff
changeset
|
44 |
static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, uint bottom, bool show_params) |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
45 |
{ |
5885
262234e81333
(svn r8093) -Codechange: Add a function to get a string representation of an MD5SUM and use it.
Darkvater
parents:
5860
diff
changeset
|
46 |
char buff[256]; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
47 |
|
6429
02c062eb2c74
(svn r8838) -Feature: Show newgrf error messages loaded in Action B in the newgrf gui
maedhros
parents:
6144
diff
changeset
|
48 |
if (c->error != NULL) { |
6465
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6429
diff
changeset
|
49 |
SetDParamStr(0, c->filename); |
7369
26325201d4d7
(svn r10114) -Fix: Only load newgrf error messages if the language matches the current
maedhros
parents:
7279
diff
changeset
|
50 |
SetDParamStr(1, c->error->data); |
6465
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6429
diff
changeset
|
51 |
for (uint i = 0; i < c->error->num_params; i++) { |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6429
diff
changeset
|
52 |
uint32 param = 0; |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6429
diff
changeset
|
53 |
byte param_number = c->error->param_number[i]; |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6429
diff
changeset
|
54 |
|
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6429
diff
changeset
|
55 |
if (param_number < c->num_params) param = c->param[param_number]; |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6429
diff
changeset
|
56 |
|
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6429
diff
changeset
|
57 |
SetDParam(2 + i, param); |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6429
diff
changeset
|
58 |
} |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6429
diff
changeset
|
59 |
|
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6429
diff
changeset
|
60 |
char message[512]; |
7369
26325201d4d7
(svn r10114) -Fix: Only load newgrf error messages if the language matches the current
maedhros
parents:
7279
diff
changeset
|
61 |
GetString(message, c->error->custom_message != NULL ? BindCString(c->error->custom_message) : c->error->message, lastof(message)); |
6465
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6429
diff
changeset
|
62 |
|
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6429
diff
changeset
|
63 |
SetDParamStr(0, message); |
6703
9ddfcb1849e4
(svn r9449) -Fix: Truncate the newgrf information text in the newgrf gui if it's too long.
maedhros
parents:
6674
diff
changeset
|
64 |
y += DrawStringMultiLine(x, y, c->error->severity, w, bottom - y); |
6429
02c062eb2c74
(svn r8838) -Feature: Show newgrf error messages loaded in Action B in the newgrf gui
maedhros
parents:
6144
diff
changeset
|
65 |
} |
02c062eb2c74
(svn r8838) -Feature: Show newgrf error messages loaded in Action B in the newgrf gui
maedhros
parents:
6144
diff
changeset
|
66 |
|
5339
7573f179efe8
(svn r7505) -Feature: show NewGRFs used on a game server, show which NewGRFs you do and do not have.
rubidium
parents:
5329
diff
changeset
|
67 |
/* Draw filename or not if it is not known (GRF sent over internet) */ |
7573f179efe8
(svn r7505) -Feature: show NewGRFs used on a game server, show which NewGRFs you do and do not have.
rubidium
parents:
5329
diff
changeset
|
68 |
if (c->filename != NULL) { |
7573f179efe8
(svn r7505) -Feature: show NewGRFs used on a game server, show which NewGRFs you do and do not have.
rubidium
parents:
5329
diff
changeset
|
69 |
SetDParamStr(0, c->filename); |
6703
9ddfcb1849e4
(svn r9449) -Fix: Truncate the newgrf information text in the newgrf gui if it's too long.
maedhros
parents:
6674
diff
changeset
|
70 |
y += DrawStringMultiLine(x, y, STR_NEWGRF_FILENAME, w, bottom - y); |
5339
7573f179efe8
(svn r7505) -Feature: show NewGRFs used on a game server, show which NewGRFs you do and do not have.
rubidium
parents:
5329
diff
changeset
|
71 |
} |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
72 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
73 |
/* Prepare and draw GRF ID */ |
5894
eb5ff472c10f
(svn r8102) -Cleanup: Remove unreachable code (r8096), useless cast
Darkvater
parents:
5889
diff
changeset
|
74 |
snprintf(buff, lengthof(buff), "%08X", BSWAP32(c->grfid)); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
75 |
SetDParamStr(0, buff); |
6703
9ddfcb1849e4
(svn r9449) -Fix: Truncate the newgrf information text in the newgrf gui if it's too long.
maedhros
parents:
6674
diff
changeset
|
76 |
y += DrawStringMultiLine(x, y, STR_NEWGRF_GRF_ID, w, bottom - y); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
77 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
78 |
/* Prepare and draw MD5 sum */ |
5885
262234e81333
(svn r8093) -Codechange: Add a function to get a string representation of an MD5SUM and use it.
Darkvater
parents:
5860
diff
changeset
|
79 |
md5sumToString(buff, lastof(buff), c->md5sum); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
80 |
SetDParamStr(0, buff); |
6703
9ddfcb1849e4
(svn r9449) -Fix: Truncate the newgrf information text in the newgrf gui if it's too long.
maedhros
parents:
6674
diff
changeset
|
81 |
y += DrawStringMultiLine(x, y, STR_NEWGRF_MD5SUM, w, bottom - y); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
82 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
83 |
/* Show GRF parameter list */ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
84 |
if (show_params) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
85 |
if (c->num_params > 0) { |
5308
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5248
diff
changeset
|
86 |
GRFBuildParamList(buff, c, lastof(buff)); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
87 |
SetDParamStr(0, buff); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
88 |
} else { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
89 |
SetDParam(0, STR_01A9_NONE); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
90 |
} |
6703
9ddfcb1849e4
(svn r9449) -Fix: Truncate the newgrf information text in the newgrf gui if it's too long.
maedhros
parents:
6674
diff
changeset
|
91 |
y += DrawStringMultiLine(x, y, STR_NEWGRF_PARAMETER, w, bottom - y); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
92 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
93 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
94 |
/* Show flags */ |
6703
9ddfcb1849e4
(svn r9449) -Fix: Truncate the newgrf information text in the newgrf gui if it's too long.
maedhros
parents:
6674
diff
changeset
|
95 |
if (c->status == GCS_NOT_FOUND) y += DrawStringMultiLine(x, y, STR_NEWGRF_NOT_FOUND, w, bottom - y); |
9ddfcb1849e4
(svn r9449) -Fix: Truncate the newgrf information text in the newgrf gui if it's too long.
maedhros
parents:
6674
diff
changeset
|
96 |
if (c->status == GCS_DISABLED) y += DrawStringMultiLine(x, y, STR_NEWGRF_DISABLED, w, bottom - y); |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8378
diff
changeset
|
97 |
if (HasBit(c->flags, GCF_COMPATIBLE)) y += DrawStringMultiLine(x, y, STR_NEWGRF_COMPATIBLE_LOADED, w, bottom - y); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
98 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
99 |
/* Draw GRF info if it exists */ |
5889
272800d151ac
(svn r8097) Replace strlen() {==,!=,>} 0 by the more concise {,!}StrEmpty(). Additionally the test takes O(1) instead of O(n) now
tron
parents:
5886
diff
changeset
|
100 |
if (c->info != NULL && !StrEmpty(c->info)) { |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
101 |
SetDParamStr(0, c->info); |
6703
9ddfcb1849e4
(svn r9449) -Fix: Truncate the newgrf information text in the newgrf gui if it's too long.
maedhros
parents:
6674
diff
changeset
|
102 |
y += DrawStringMultiLine(x, y, STR_02BD, w, bottom - y); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
103 |
} else { |
6703
9ddfcb1849e4
(svn r9449) -Fix: Truncate the newgrf information text in the newgrf gui if it's too long.
maedhros
parents:
6674
diff
changeset
|
104 |
y += DrawStringMultiLine(x, y, STR_NEWGRF_NO_INFO, w, bottom - y); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
105 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
106 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
107 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
108 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
109 |
/* Dialogue for adding NewGRF files to the selection */ |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6555
diff
changeset
|
110 |
struct newgrf_add_d { |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
111 |
GRFConfig **list; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
112 |
const GRFConfig *sel; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6555
diff
changeset
|
113 |
}; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
114 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
115 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
116 |
static void NewGRFAddDlgWndProc(Window *w, WindowEvent *e) |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
117 |
{ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
118 |
switch (e->event) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
119 |
case WE_PAINT: { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
120 |
const GRFConfig *c; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
121 |
int y; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
122 |
int n = 0; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
123 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
124 |
/* Count the number of GRFs */ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
125 |
for (c = _all_grfs; c != NULL; c = c->next) n++; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
126 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
127 |
w->vscroll.cap = (w->widget[3].bottom - w->widget[3].top) / 10; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
128 |
SetVScrollCount(w, n); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
129 |
|
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
130 |
w->SetWidgetDisabledState(6, WP(w, newgrf_add_d).sel == NULL || WP(w, newgrf_add_d).sel->IsOpenTTDBaseGRF()); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
131 |
DrawWindowWidgets(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
132 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
133 |
GfxFillRect(w->widget[3].left + 1, w->widget[3].top + 1, w->widget[3].right, w->widget[3].bottom, 0xD7); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
134 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
135 |
n = 0; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
136 |
y = w->widget[3].top + 1; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
137 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
138 |
for (c = _all_grfs; c != NULL; c = c->next) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
139 |
if (n >= w->vscroll.pos && n < w->vscroll.pos + w->vscroll.cap) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
140 |
bool h = c == WP(w, newgrf_add_d).sel; |
5889
272800d151ac
(svn r8097) Replace strlen() {==,!=,>} 0 by the more concise {,!}StrEmpty(). Additionally the test takes O(1) instead of O(n) now
tron
parents:
5886
diff
changeset
|
141 |
const char *text = (c->name != NULL && !StrEmpty(c->name)) ? c->name : c->filename; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
142 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
143 |
/* Draw selection background */ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
144 |
if (h) GfxFillRect(3, y, w->width - 15, y + 9, 156); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8275
diff
changeset
|
145 |
DoDrawStringTruncated(text, 4, y, h ? TC_WHITE : TC_ORANGE, w->width - 18); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
146 |
y += 10; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
147 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
148 |
n++; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
149 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
150 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
151 |
if (WP(w, newgrf_add_d).sel != NULL) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
152 |
const Widget *wi = &w->widget[5]; |
6703
9ddfcb1849e4
(svn r9449) -Fix: Truncate the newgrf information text in the newgrf gui if it's too long.
maedhros
parents:
6674
diff
changeset
|
153 |
ShowNewGRFInfo(WP(w, newgrf_add_d).sel, wi->left + 2, wi->top + 2, wi->right - wi->left - 2, wi->bottom, false); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
154 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
155 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
156 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
157 |
|
7507
c287e5e93517
(svn r10267) -Add: enable double clic to add in 'add newgrf' window
glx
parents:
7452
diff
changeset
|
158 |
case WE_DOUBLE_CLICK: |
c287e5e93517
(svn r10267) -Add: enable double clic to add in 'add newgrf' window
glx
parents:
7452
diff
changeset
|
159 |
if (e->we.click.widget != 3) break; |
c287e5e93517
(svn r10267) -Add: enable double clic to add in 'add newgrf' window
glx
parents:
7452
diff
changeset
|
160 |
e->we.click.widget = 6; |
c287e5e93517
(svn r10267) -Add: enable double clic to add in 'add newgrf' window
glx
parents:
7452
diff
changeset
|
161 |
/* Fall through */ |
c287e5e93517
(svn r10267) -Add: enable double clic to add in 'add newgrf' window
glx
parents:
7452
diff
changeset
|
162 |
|
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
163 |
case WE_CLICK: |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
164 |
switch (e->we.click.widget) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
165 |
case 3: { |
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
166 |
/* Get row... */ |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
167 |
const GRFConfig *c; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
168 |
uint i = (e->we.click.pt.y - w->widget[3].top) / 10 + w->vscroll.pos; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
169 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
170 |
for (c = _all_grfs; c != NULL && i > 0; c = c->next, i--); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
171 |
WP(w, newgrf_add_d).sel = c; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
172 |
SetWindowDirty(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
173 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
174 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
175 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
176 |
case 6: // Add selection to list |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
177 |
if (WP(w, newgrf_add_d).sel != NULL) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
178 |
const GRFConfig *src = WP(w, newgrf_add_d).sel; |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5838
diff
changeset
|
179 |
GRFConfig **list; |
5243
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
180 |
|
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
181 |
/* Find last entry in the list, checking for duplicate grfid on the way */ |
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
182 |
for (list = WP(w, newgrf_add_d).list; *list != NULL; list = &(*list)->next) { |
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
183 |
if ((*list)->grfid == src->grfid) { |
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
184 |
ShowErrorMessage(INVALID_STRING_ID, STR_NEWGRF_DUPLICATE_GRFID, 0, 0); |
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
185 |
return; |
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
186 |
} |
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
187 |
} |
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
188 |
|
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
189 |
/* Copy GRF details from scanned list */ |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5838
diff
changeset
|
190 |
GRFConfig *c = CallocT<GRFConfig>(1); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
191 |
*c = *src; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
192 |
c->filename = strdup(src->filename); |
7279
cbc7fe26facf
(svn r10021) -Fix (r9560): memory "corruption" that could lead to a failure to load newgrfs.
rubidium
parents:
6984
diff
changeset
|
193 |
if (src->name != NULL) c->name = strdup(src->name); |
cbc7fe26facf
(svn r10021) -Fix (r9560): memory "corruption" that could lead to a failure to load newgrfs.
rubidium
parents:
6984
diff
changeset
|
194 |
if (src->info != NULL) c->info = strdup(src->info); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
195 |
c->next = NULL; |
5243
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
196 |
|
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
197 |
/* Append GRF config to configuration list */ |
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
198 |
*list = c; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
199 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
200 |
DeleteWindowByClass(WC_SAVELOAD); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
201 |
InvalidateWindowData(WC_GAME_OPTIONS, 0); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
202 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
203 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
204 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
205 |
case 7: // Rescan list |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
206 |
WP(w, newgrf_add_d).sel = NULL; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
207 |
ScanNewGRFFiles(); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
208 |
SetWindowDirty(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
209 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
210 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
211 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
212 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
213 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
214 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
215 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
216 |
static const Widget _newgrf_add_dlg_widgets[] = { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
217 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
218 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 306, 0, 13, STR_NEWGRF_ADD_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
219 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
220 |
/* List of files */ |
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7530
diff
changeset
|
221 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 294, 14, 121, 0x0, STR_NULL }, |
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7530
diff
changeset
|
222 |
{ WWT_INSET, RESIZE_RB, 14, 2, 292, 16, 119, 0x0, STR_NULL }, |
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7530
diff
changeset
|
223 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 295, 306, 14, 121, 0x0, STR_NULL }, |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
224 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
225 |
/* NewGRF file info */ |
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7530
diff
changeset
|
226 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 306, 122, 224, 0x0, STR_NULL }, |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
227 |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7530
diff
changeset
|
228 |
{ WWT_PUSHTXTBTN, RESIZE_RTB, 14, 0, 146, 225, 236, STR_NEWGRF_ADD_FILE, STR_NEWGRF_ADD_FILE_TIP }, |
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7530
diff
changeset
|
229 |
{ WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 147, 294, 225, 236, STR_NEWGRF_RESCAN_FILES, STR_NEWGRF_RESCAN_FILES_TIP }, |
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7530
diff
changeset
|
230 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 295, 306, 225, 236, 0x0, STR_RESIZE_BUTTON }, |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
231 |
{ WIDGETS_END }, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
232 |
}; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
233 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
234 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
235 |
static const WindowDesc _newgrf_add_dlg_desc = { |
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7530
diff
changeset
|
236 |
WDP_CENTER, WDP_CENTER, 307, 237, 307, 337, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5919
diff
changeset
|
237 |
WC_SAVELOAD, WC_NONE, |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
238 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
239 |
_newgrf_add_dlg_widgets, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
240 |
NewGRFAddDlgWndProc, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
241 |
}; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
242 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
243 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
244 |
/* 'NewGRF Settings' dialogue */ |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6555
diff
changeset
|
245 |
struct newgrf_d { |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
246 |
GRFConfig **orig_list; ///< grf list the window is shown with |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
247 |
GRFConfig **list; ///< temporary grf list to which changes are made |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
248 |
GRFConfig *sel; ///< selected grf item |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
249 |
bool editable; ///< is the window editable |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
250 |
bool show_params; ///< are the grf-parameters shown in the info-panel |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
251 |
bool execute; ///< on pressing 'apply changes' are grf changes applied immediately, or only list is updated |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6555
diff
changeset
|
252 |
}; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
253 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(newgrf_d)); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
254 |
|
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
255 |
|
5345
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
256 |
enum ShowNewGRFStateWidgets { |
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
257 |
SNGRFS_ADD = 3, |
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
258 |
SNGRFS_REMOVE, |
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
259 |
SNGRFS_MOVE_UP, |
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
260 |
SNGRFS_MOVE_DOWN, |
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
261 |
SNGRFS_FILE_LIST = 7, |
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
262 |
SNGRFS_NEWGRF_INFO = 9, |
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
263 |
SNGRFS_SET_PARAMETERS, |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
264 |
SNGRFS_APPLY_CHANGES, |
5345
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
265 |
}; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
266 |
|
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
267 |
|
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
268 |
static void SetupNewGRFState(Window *w) |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
269 |
{ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
270 |
bool disable_all = WP(w, newgrf_d).sel == NULL || !WP(w, newgrf_d).editable; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
271 |
|
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
272 |
w->SetWidgetDisabledState(3, !WP(w, newgrf_d).editable); |
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
273 |
w->SetWidgetsDisabledState(disable_all, |
5345
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
274 |
SNGRFS_REMOVE, |
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
275 |
SNGRFS_MOVE_UP, |
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
276 |
SNGRFS_MOVE_DOWN, |
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
277 |
WIDGET_LIST_END |
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
278 |
); |
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
279 |
w->SetWidgetDisabledState(SNGRFS_SET_PARAMETERS, !WP(w, newgrf_d).show_params || disable_all); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
280 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
281 |
if (!disable_all) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
282 |
/* All widgets are now enabled, so disable widgets we can't use */ |
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
283 |
if (WP(w, newgrf_d).sel == *WP(w, newgrf_d).list) w->DisableWidget(SNGRFS_MOVE_UP); |
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
284 |
if (WP(w, newgrf_d).sel->next == NULL) w->DisableWidget(SNGRFS_MOVE_DOWN); |
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
285 |
if (WP(w, newgrf_d).sel->IsOpenTTDBaseGRF()) w->DisableWidget(SNGRFS_REMOVE); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
286 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
287 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
288 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
289 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
290 |
static void SetupNewGRFWindow(Window *w) |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
291 |
{ |
5345
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
292 |
const GRFConfig *c; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
293 |
int i; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
294 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
295 |
for (c = *WP(w, newgrf_d).list, i = 0; c != NULL; c = c->next, i++); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
296 |
|
5345
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
297 |
w->vscroll.cap = (w->widget[SNGRFS_FILE_LIST].bottom - w->widget[SNGRFS_FILE_LIST].top) / 14 + 1; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
298 |
SetVScrollCount(w, i); |
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
299 |
w->SetWidgetDisabledState(SNGRFS_APPLY_CHANGES, !WP(w, newgrf_d).editable); |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
300 |
} |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
301 |
|
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
302 |
|
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
303 |
/** Callback function for the newgrf 'apply changes' confirmation window |
6984
045168d13eef
(svn r9669) -Documentation: some more doxygen fixes
belugas
parents:
6703
diff
changeset
|
304 |
* @param w Window which is calling this callback |
045168d13eef
(svn r9669) -Documentation: some more doxygen fixes
belugas
parents:
6703
diff
changeset
|
305 |
* @param confirmed boolean value, true when yes was clicked, false otherwise |
045168d13eef
(svn r9669) -Documentation: some more doxygen fixes
belugas
parents:
6703
diff
changeset
|
306 |
*/ |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5552
diff
changeset
|
307 |
static void NewGRFConfirmationCallback(Window *w, bool confirmed) |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
308 |
{ |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5552
diff
changeset
|
309 |
if (confirmed) { |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
310 |
newgrf_d *nd = &WP(w, newgrf_d); |
5886
5e0f0faf50fc
(svn r8094) -Feature/Fix (r7523): Show the activated status of the GRF list after pressing 'apply'
Darkvater
parents:
5885
diff
changeset
|
311 |
GRFConfig *c; |
5e0f0faf50fc
(svn r8094) -Feature/Fix (r7523): Show the activated status of the GRF list after pressing 'apply'
Darkvater
parents:
5885
diff
changeset
|
312 |
int i = 0; |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
313 |
|
7452
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7369
diff
changeset
|
314 |
CopyGRFConfigList(nd->orig_list, *nd->list, false); |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
315 |
ReloadNewGRFData(); |
5886
5e0f0faf50fc
(svn r8094) -Feature/Fix (r7523): Show the activated status of the GRF list after pressing 'apply'
Darkvater
parents:
5885
diff
changeset
|
316 |
|
5e0f0faf50fc
(svn r8094) -Feature/Fix (r7523): Show the activated status of the GRF list after pressing 'apply'
Darkvater
parents:
5885
diff
changeset
|
317 |
/* Show new, updated list */ |
5e0f0faf50fc
(svn r8094) -Feature/Fix (r7523): Show the activated status of the GRF list after pressing 'apply'
Darkvater
parents:
5885
diff
changeset
|
318 |
for (c = *nd->list; c != NULL && c != nd->sel; c = c->next, i++); |
7452
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7369
diff
changeset
|
319 |
CopyGRFConfigList(nd->list, *nd->orig_list, false); |
5886
5e0f0faf50fc
(svn r8094) -Feature/Fix (r7523): Show the activated status of the GRF list after pressing 'apply'
Darkvater
parents:
5885
diff
changeset
|
320 |
for (c = *nd->list; c != NULL && i > 0; c = c->next, i--); |
5e0f0faf50fc
(svn r8094) -Feature/Fix (r7523): Show the activated status of the GRF list after pressing 'apply'
Darkvater
parents:
5885
diff
changeset
|
321 |
nd->sel = c; |
5e0f0faf50fc
(svn r8094) -Feature/Fix (r7523): Show the activated status of the GRF list after pressing 'apply'
Darkvater
parents:
5885
diff
changeset
|
322 |
|
5e0f0faf50fc
(svn r8094) -Feature/Fix (r7523): Show the activated status of the GRF list after pressing 'apply'
Darkvater
parents:
5885
diff
changeset
|
323 |
SetWindowDirty(w); |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
324 |
} |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
325 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
326 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
327 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
328 |
static void NewGRFWndProc(Window *w, WindowEvent *e) |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
329 |
{ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
330 |
switch (e->event) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
331 |
case WE_PAINT: { |
5345
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
332 |
const GRFConfig *c; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
333 |
int i, y; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
334 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
335 |
SetupNewGRFState(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
336 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
337 |
DrawWindowWidgets(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
338 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
339 |
/* Draw NewGRF list */ |
5345
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
340 |
y = w->widget[SNGRFS_FILE_LIST].top; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
341 |
for (c = *WP(w, newgrf_d).list, i = 0; c != NULL; c = c->next, i++) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
342 |
if (i >= w->vscroll.pos && i < w->vscroll.pos + w->vscroll.cap) { |
5889
272800d151ac
(svn r8097) Replace strlen() {==,!=,>} 0 by the more concise {,!}StrEmpty(). Additionally the test takes O(1) instead of O(n) now
tron
parents:
5886
diff
changeset
|
343 |
const char *text = (c->name != NULL && !StrEmpty(c->name)) ? c->name : c->filename; |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5898
diff
changeset
|
344 |
SpriteID pal; |
8233
d66599f73fd1
(svn r11272) -Codechange: Truncate text describing the grf file in the NewGrf settings gui
belugas
parents:
8176
diff
changeset
|
345 |
byte txtoffset; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
346 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
347 |
/* Pick a colour */ |
6555
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
348 |
switch (c->status) { |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
349 |
case GCS_NOT_FOUND: |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
350 |
case GCS_DISABLED: |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
351 |
pal = PALETTE_TO_RED; |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
352 |
break; |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
353 |
case GCS_ACTIVATED: |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
354 |
pal = PALETTE_TO_GREEN; |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
355 |
break; |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
356 |
default: |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
357 |
pal = PALETTE_TO_BLUE; |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
358 |
break; |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
359 |
} |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
360 |
|
8275
7bb7b8b75f5a
(svn r11329) -Fix: if a NewGRF failed to load for some reason (like fatal errors), but it was a "compatible" NewGRF, it was shown with the compatible colour and not the not-loaded colour in the NewGRF list.
rubidium
parents:
8233
diff
changeset
|
361 |
/* Do not show a "not-failure" colour when it actually failed to load */ |
7bb7b8b75f5a
(svn r11329) -Fix: if a NewGRF failed to load for some reason (like fatal errors), but it was a "compatible" NewGRF, it was shown with the compatible colour and not the not-loaded colour in the NewGRF list.
rubidium
parents:
8233
diff
changeset
|
362 |
if (pal != PALETTE_TO_RED) { |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8378
diff
changeset
|
363 |
if (HasBit(c->flags, GCF_STATIC)) { |
8275
7bb7b8b75f5a
(svn r11329) -Fix: if a NewGRF failed to load for some reason (like fatal errors), but it was a "compatible" NewGRF, it was shown with the compatible colour and not the not-loaded colour in the NewGRF list.
rubidium
parents:
8233
diff
changeset
|
364 |
pal = PALETTE_TO_GREY; |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8378
diff
changeset
|
365 |
} else if (HasBit(c->flags, GCF_COMPATIBLE)) { |
8275
7bb7b8b75f5a
(svn r11329) -Fix: if a NewGRF failed to load for some reason (like fatal errors), but it was a "compatible" NewGRF, it was shown with the compatible colour and not the not-loaded colour in the NewGRF list.
rubidium
parents:
8233
diff
changeset
|
366 |
pal = PALETTE_TO_ORANGE; |
7bb7b8b75f5a
(svn r11329) -Fix: if a NewGRF failed to load for some reason (like fatal errors), but it was a "compatible" NewGRF, it was shown with the compatible colour and not the not-loaded colour in the NewGRF list.
rubidium
parents:
8233
diff
changeset
|
367 |
} |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
368 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
369 |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5898
diff
changeset
|
370 |
DrawSprite(SPR_SQUARE, pal, 5, y + 2); |
6429
02c062eb2c74
(svn r8838) -Feature: Show newgrf error messages loaded in Action B in the newgrf gui
maedhros
parents:
6144
diff
changeset
|
371 |
if (c->error != NULL) DrawSprite(SPR_WARNING_SIGN, 0, 20, y + 2); |
8233
d66599f73fd1
(svn r11272) -Codechange: Truncate text describing the grf file in the NewGrf settings gui
belugas
parents:
8176
diff
changeset
|
372 |
txtoffset = c->error != NULL ? 35 : 25; |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8275
diff
changeset
|
373 |
DoDrawStringTruncated(text, txtoffset, y + 3, WP(w, newgrf_d).sel == c ? TC_WHITE : TC_BLACK, w->width - txtoffset - 10); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
374 |
y += 14; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
375 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
376 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
377 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
378 |
if (WP(w, newgrf_d).sel != NULL) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
379 |
/* Draw NewGRF file info */ |
5345
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
380 |
const Widget *wi = &w->widget[SNGRFS_NEWGRF_INFO]; |
6703
9ddfcb1849e4
(svn r9449) -Fix: Truncate the newgrf information text in the newgrf gui if it's too long.
maedhros
parents:
6674
diff
changeset
|
381 |
ShowNewGRFInfo(WP(w, newgrf_d).sel, wi->left + 2, wi->top + 2, wi->right - wi->left - 2, wi->bottom, WP(w, newgrf_d).show_params); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
382 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
383 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
384 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
385 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
386 |
|
5241
2dafe1235308
(svn r7363) -Fix (r7357): Update count of NewGRFs when adding an file
peter1138
parents:
5237
diff
changeset
|
387 |
case WE_INVALIDATE_DATA: |
2dafe1235308
(svn r7363) -Fix (r7357): Update count of NewGRFs when adding an file
peter1138
parents:
5237
diff
changeset
|
388 |
SetupNewGRFWindow(w); |
2dafe1235308
(svn r7363) -Fix (r7357): Update count of NewGRFs when adding an file
peter1138
parents:
5237
diff
changeset
|
389 |
break; |
2dafe1235308
(svn r7363) -Fix (r7357): Update count of NewGRFs when adding an file
peter1138
parents:
5237
diff
changeset
|
390 |
|
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
391 |
case WE_CLICK: |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
392 |
switch (e->we.click.widget) { |
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
393 |
case SNGRFS_ADD: { // Add GRF |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
394 |
GRFConfig **list = WP(w, newgrf_d).list; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
395 |
Window *w; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
396 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
397 |
DeleteWindowByClass(WC_SAVELOAD); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
398 |
w = AllocateWindowDesc(&_newgrf_add_dlg_desc); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
399 |
w->resize.step_height = 10; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
400 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
401 |
WP(w, newgrf_add_d).list = list; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
402 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
403 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
404 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
405 |
case SNGRFS_REMOVE: { // Remove GRF |
5248
2aa0c4cc8f23
(svn r7373) -Codechange: when removing a GRF from the list, make the next one selected, or the previous file if the last item is being removed. This makes clearing the list easier.
peter1138
parents:
5243
diff
changeset
|
406 |
GRFConfig **pc, *c, *newsel; |
2aa0c4cc8f23
(svn r7373) -Codechange: when removing a GRF from the list, make the next one selected, or the previous file if the last item is being removed. This makes clearing the list easier.
peter1138
parents:
5243
diff
changeset
|
407 |
|
2aa0c4cc8f23
(svn r7373) -Codechange: when removing a GRF from the list, make the next one selected, or the previous file if the last item is being removed. This makes clearing the list easier.
peter1138
parents:
5243
diff
changeset
|
408 |
/* Choose the next GRF file to be the selected file */ |
2aa0c4cc8f23
(svn r7373) -Codechange: when removing a GRF from the list, make the next one selected, or the previous file if the last item is being removed. This makes clearing the list easier.
peter1138
parents:
5243
diff
changeset
|
409 |
newsel = WP(w, newgrf_d).sel->next; |
2aa0c4cc8f23
(svn r7373) -Codechange: when removing a GRF from the list, make the next one selected, or the previous file if the last item is being removed. This makes clearing the list easier.
peter1138
parents:
5243
diff
changeset
|
410 |
|
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
411 |
for (pc = WP(w, newgrf_d).list; (c = *pc) != NULL; pc = &c->next) { |
5248
2aa0c4cc8f23
(svn r7373) -Codechange: when removing a GRF from the list, make the next one selected, or the previous file if the last item is being removed. This makes clearing the list easier.
peter1138
parents:
5243
diff
changeset
|
412 |
/* If the new selection is empty (i.e. we're deleting the last item |
2aa0c4cc8f23
(svn r7373) -Codechange: when removing a GRF from the list, make the next one selected, or the previous file if the last item is being removed. This makes clearing the list easier.
peter1138
parents:
5243
diff
changeset
|
413 |
* in the list, pick the file just before the selected file */ |
2aa0c4cc8f23
(svn r7373) -Codechange: when removing a GRF from the list, make the next one selected, or the previous file if the last item is being removed. This makes clearing the list easier.
peter1138
parents:
5243
diff
changeset
|
414 |
if (newsel == NULL && c->next == WP(w, newgrf_d).sel) newsel = c; |
2aa0c4cc8f23
(svn r7373) -Codechange: when removing a GRF from the list, make the next one selected, or the previous file if the last item is being removed. This makes clearing the list easier.
peter1138
parents:
5243
diff
changeset
|
415 |
|
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
416 |
if (c == WP(w, newgrf_d).sel) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
417 |
*pc = c->next; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
418 |
free(c); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
419 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
420 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
421 |
} |
5248
2aa0c4cc8f23
(svn r7373) -Codechange: when removing a GRF from the list, make the next one selected, or the previous file if the last item is being removed. This makes clearing the list easier.
peter1138
parents:
5243
diff
changeset
|
422 |
|
2aa0c4cc8f23
(svn r7373) -Codechange: when removing a GRF from the list, make the next one selected, or the previous file if the last item is being removed. This makes clearing the list easier.
peter1138
parents:
5243
diff
changeset
|
423 |
WP(w, newgrf_d).sel = newsel; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
424 |
SetupNewGRFWindow(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
425 |
SetWindowDirty(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
426 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
427 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
428 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
429 |
case SNGRFS_MOVE_UP: { // Move GRF up |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
430 |
GRFConfig **pc, *c; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
431 |
if (WP(w, newgrf_d).sel == NULL) break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
432 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
433 |
for (pc = WP(w, newgrf_d).list; (c = *pc) != NULL; pc = &c->next) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
434 |
if (c->next == WP(w, newgrf_d).sel) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
435 |
c->next = WP(w, newgrf_d).sel->next; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
436 |
WP(w, newgrf_d).sel->next = c; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
437 |
*pc = WP(w, newgrf_d).sel; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
438 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
439 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
440 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
441 |
SetWindowDirty(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
442 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
443 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
444 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
445 |
case SNGRFS_MOVE_DOWN: { // Move GRF down |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
446 |
GRFConfig **pc, *c; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
447 |
if (WP(w, newgrf_d).sel == NULL) break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
448 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
449 |
for (pc = WP(w, newgrf_d).list; (c = *pc) != NULL; pc = &c->next) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
450 |
if (c == WP(w, newgrf_d).sel) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
451 |
*pc = c->next; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
452 |
c->next = c->next->next; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
453 |
(*pc)->next = c; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
454 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
455 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
456 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
457 |
SetWindowDirty(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
458 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
459 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
460 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
461 |
case SNGRFS_FILE_LIST: { // Select a GRF |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
462 |
GRFConfig *c; |
5345
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
463 |
uint i = (e->we.click.pt.y - w->widget[SNGRFS_FILE_LIST].top) / 14 + w->vscroll.pos; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
464 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
465 |
for (c = *WP(w, newgrf_d).list; c != NULL && i > 0; c = c->next, i--); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
466 |
WP(w, newgrf_d).sel = c; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
467 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
468 |
SetWindowDirty(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
469 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
470 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
471 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
472 |
case SNGRFS_APPLY_CHANGES: // Apply changes made to GRF list |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
473 |
if (WP(w, newgrf_d).execute) { |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
474 |
ShowQuery( |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
475 |
STR_POPUP_CAUTION_CAPTION, |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
476 |
STR_NEWGRF_CONFIRMATION_TEXT, |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5552
diff
changeset
|
477 |
w, |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5552
diff
changeset
|
478 |
NewGRFConfirmationCallback |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
479 |
); |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
480 |
} else { |
7452
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7369
diff
changeset
|
481 |
CopyGRFConfigList(WP(w, newgrf_d).orig_list, *WP(w, newgrf_d).list, true); |
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7369
diff
changeset
|
482 |
ResetGRFConfig(false); |
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7369
diff
changeset
|
483 |
ReloadNewGRFData(); |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
484 |
} |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
485 |
break; |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
486 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
487 |
case SNGRFS_SET_PARAMETERS: { // Edit parameters |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
488 |
char buff[512]; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
489 |
if (WP(w, newgrf_d).sel == NULL) break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
490 |
|
5308
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5248
diff
changeset
|
491 |
GRFBuildParamList(buff, WP(w, newgrf_d).sel, lastof(buff)); |
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5669
diff
changeset
|
492 |
ShowQueryString(BindCString(buff), STR_NEWGRF_PARAMETER_QUERY, 63, 250, w, CS_ALPHANUMERAL); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
493 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
494 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
495 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
496 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
497 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
498 |
case WE_ON_EDIT_TEXT: |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
499 |
if (e->we.edittext.str != NULL) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
500 |
/* Parse our new "int list" */ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
501 |
GRFConfig *c = WP(w, newgrf_d).sel; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
502 |
c->num_params = parse_intlist(e->we.edittext.str, (int*)c->param, lengthof(c->param)); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
503 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
504 |
/* parse_intlist returns -1 on error */ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
505 |
if (c->num_params == (byte)-1) c->num_params = 0; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
506 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
507 |
SetWindowDirty(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
508 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
509 |
|
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
510 |
case WE_DESTROY: |
6492
a1cc60b7a844
(svn r8920) -Codechange: Do not require to press 'Apply changes' in the newgrf GUI if the changes in there are not activated (this happens in the title screen)
Darkvater
parents:
6490
diff
changeset
|
511 |
if (!WP(w, newgrf_d).execute) { |
7452
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7369
diff
changeset
|
512 |
CopyGRFConfigList(WP(w, newgrf_d).orig_list, *WP(w, newgrf_d).list, true); |
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7369
diff
changeset
|
513 |
ResetGRFConfig(false); |
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7369
diff
changeset
|
514 |
ReloadNewGRFData(); |
6492
a1cc60b7a844
(svn r8920) -Codechange: Do not require to press 'Apply changes' in the newgrf GUI if the changes in there are not activated (this happens in the title screen)
Darkvater
parents:
6490
diff
changeset
|
515 |
} |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
516 |
/* Remove the temporary copy of grf-list used in window */ |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
517 |
ClearGRFConfigList(WP(w, newgrf_d).list); |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
518 |
break; |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
519 |
|
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
520 |
case WE_RESIZE: |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
521 |
w->vscroll.cap += e->we.sizing.diff.y / 14; |
5345
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
522 |
w->widget[SNGRFS_FILE_LIST].data = (w->vscroll.cap << 8) + 1; |
8176
398176695a46
(svn r11211) -Fix [FS#1302]: NewGRF GUI scrollbar does funny things when being resized.
rubidium
parents:
7837
diff
changeset
|
523 |
SetupNewGRFWindow(w); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
524 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
525 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
526 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
527 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
528 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
529 |
static const Widget _newgrf_widgets[] = { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
530 |
{ WWT_CLOSEBOX, RESIZE_NONE, 10, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
531 |
{ WWT_CAPTION, RESIZE_RIGHT, 10, 11, 299, 0, 13, STR_NEWGRF_SETTINGS_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
532 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
533 |
/* NewGRF file Add, Remove, Move up, Move down */ |
5345
00c5ff01191a
(svn r7516) -Codechange: Number the newgrf-gui widgets and use their symbolic names for access with some const goodness.
Darkvater
parents:
5339
diff
changeset
|
534 |
{ WWT_PANEL, RESIZE_RIGHT, 10, 0, 299, 14, 29, STR_NULL, STR_NULL }, |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
535 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 10, 79, 16, 27, STR_NEWGRF_ADD, STR_NEWGRF_ADD_TIP }, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
536 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 80, 149, 16, 27, STR_NEWGRF_REMOVE, STR_NEWGRF_REMOVE_TIP }, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
537 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 150, 219, 16, 27, STR_NEWGRF_MOVEUP, STR_NEWGRF_MOVEUP_TIP }, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
538 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 220, 289, 16, 27, STR_NEWGRF_MOVEDOWN, STR_NEWGRF_MOVEDOWN_TIP }, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
539 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
540 |
/* NewGRF file list */ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
541 |
{ WWT_MATRIX, RESIZE_RB, 10, 0, 287, 30, 99, 0x501, STR_NEWGRF_FILE_TIP }, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
542 |
{ WWT_SCROLLBAR, RESIZE_LRB, 10, 288, 299, 30, 99, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST }, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
543 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
544 |
/* NewGRF file info */ |
5552
8463cf69909c
(svn r7549) -Fix (r7357): change the size of the NewGRF GUIs so any description of a GRF that is shown in TTDPatch without overflowing, does not overflow in OpenTTD.
rubidium
parents:
5352
diff
changeset
|
545 |
{ WWT_PANEL, RESIZE_RTB, 10, 0, 299, 100, 212, STR_NULL, STR_NULL }, |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
546 |
|
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
547 |
/* Edit parameter and apply changes button... */ |
5552
8463cf69909c
(svn r7549) -Fix (r7357): change the size of the NewGRF GUIs so any description of a GRF that is shown in TTDPatch without overflowing, does not overflow in OpenTTD.
rubidium
parents:
5352
diff
changeset
|
548 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 10, 0, 143, 213, 224, STR_NEWGRF_SET_PARAMETERS, STR_NULL }, |
8463cf69909c
(svn r7549) -Fix (r7357): change the size of the NewGRF GUIs so any description of a GRF that is shown in TTDPatch without overflowing, does not overflow in OpenTTD.
rubidium
parents:
5352
diff
changeset
|
549 |
{ WWT_PUSHTXTBTN, RESIZE_RTB, 10, 144, 287, 213, 224, STR_NEWGRF_APPLY_CHANGES, STR_NULL }, |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
550 |
|
5552
8463cf69909c
(svn r7549) -Fix (r7357): change the size of the NewGRF GUIs so any description of a GRF that is shown in TTDPatch without overflowing, does not overflow in OpenTTD.
rubidium
parents:
5352
diff
changeset
|
551 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 10, 288, 299, 213, 224, 0x0, STR_RESIZE_BUTTON }, |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
552 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
553 |
{ WIDGETS_END }, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
554 |
}; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
555 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
556 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
557 |
static const WindowDesc _newgrf_desc = { |
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7530
diff
changeset
|
558 |
WDP_CENTER, WDP_CENTER, 300, 225, 300, 225, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5919
diff
changeset
|
559 |
WC_GAME_OPTIONS, WC_NONE, |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
560 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
561 |
_newgrf_widgets, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
562 |
NewGRFWndProc, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
563 |
}; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
564 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
565 |
|
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
566 |
/** Setup the NewGRF gui |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
567 |
* @param editable allow the user to make changes to the grfconfig in the window |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
568 |
* @param show_params show information about what parameters are set for the grf files |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
569 |
* @param exec_changes if changes are made to the list (editable is true), apply these |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
570 |
* changes immediately or only update the list |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
571 |
* @param config pointer to a linked-list of grfconfig's that will be shown */ |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
572 |
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config) |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
573 |
{ |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
574 |
static GRFConfig *local = NULL; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
575 |
Window *w; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
576 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
577 |
DeleteWindowByClass(WC_GAME_OPTIONS); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
578 |
w = AllocateWindowDesc(&_newgrf_desc); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
579 |
if (w == NULL) return; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
580 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
581 |
w->resize.step_height = 14; |
7452
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7369
diff
changeset
|
582 |
CopyGRFConfigList(&local, *config, false); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
583 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
584 |
/* Clear selections */ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
585 |
WP(w, newgrf_d).sel = NULL; |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
586 |
WP(w, newgrf_d).list = &local; |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
587 |
WP(w, newgrf_d).orig_list = config; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
588 |
WP(w, newgrf_d).editable = editable; |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
589 |
WP(w, newgrf_d).execute = exec_changes; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
590 |
WP(w, newgrf_d).show_params = show_params; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
591 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
592 |
SetupNewGRFWindow(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
593 |
} |