author | rubidium |
Sat, 26 Apr 2008 20:54:56 +0000 | |
branch | 0.6 |
changeset 10366 | 960aae8c20e2 |
parent 9191 | ae14770c829a |
child 9245 | ea89c79affde |
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 "variables.h" |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
8 |
#include "gui.h" |
8603
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
9 |
#include "window_gui.h" |
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
10 |
#include "textbuf_gui.h" |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
11 |
#include "newgrf.h" |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
12 |
#include "newgrf_config.h" |
8610
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8603
diff
changeset
|
13 |
#include "strings_func.h" |
8627
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8626
diff
changeset
|
14 |
#include "window_func.h" |
8709
4187ad809fe7
(svn r11776) -Codechange: more header splittings to reduce the dependencies.
rubidium
parents:
8627
diff
changeset
|
15 |
#include "core/alloc_func.hpp" |
8710
52015340050c
(svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents:
8709
diff
changeset
|
16 |
#include "string_func.h" |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8710
diff
changeset
|
17 |
#include "gfx_func.h" |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
18 |
|
8760
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8720
diff
changeset
|
19 |
#include "table/strings.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8720
diff
changeset
|
20 |
#include "table/sprites.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8720
diff
changeset
|
21 |
|
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
22 |
/** 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
|
23 |
* @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
|
24 |
* comma or a space character |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
25 |
* @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
|
26 |
* @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
|
27 |
* @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
|
28 |
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
|
29 |
{ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
30 |
int n = 0, v; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
31 |
char *end; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
32 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
33 |
for (;;) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
34 |
v = strtol(p, &end, 0); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
35 |
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
|
36 |
p = end; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
37 |
items[n++] = v; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
38 |
if (*p == '\0') break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
39 |
if (*p != ',' && *p != ' ') return -1; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
40 |
p++; |
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 |
return n; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
44 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
45 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
46 |
|
6703
9ddfcb1849e4
(svn r9449) -Fix: Truncate the newgrf information text in the newgrf gui if it's too long.
maedhros
parents:
6674
diff
changeset
|
47 |
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
|
48 |
{ |
5885
262234e81333
(svn r8093) -Codechange: Add a function to get a string representation of an MD5SUM and use it.
Darkvater
parents:
5860
diff
changeset
|
49 |
char buff[256]; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
50 |
|
6429
02c062eb2c74
(svn r8838) -Feature: Show newgrf error messages loaded in Action B in the newgrf gui
maedhros
parents:
6144
diff
changeset
|
51 |
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
|
52 |
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
|
53 |
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
|
54 |
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
|
55 |
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
|
56 |
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
|
57 |
|
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 |
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
|
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 |
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
|
61 |
} |
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 |
char message[512]; |
7369
26325201d4d7
(svn r10114) -Fix: Only load newgrf error messages if the language matches the current
maedhros
parents:
7279
diff
changeset
|
64 |
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
|
65 |
|
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6429
diff
changeset
|
66 |
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
|
67 |
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
|
68 |
} |
02c062eb2c74
(svn r8838) -Feature: Show newgrf error messages loaded in Action B in the newgrf gui
maedhros
parents:
6144
diff
changeset
|
69 |
|
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
|
70 |
/* 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
|
71 |
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
|
72 |
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
|
73 |
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
|
74 |
} |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
75 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
76 |
/* Prepare and draw GRF ID */ |
5894
eb5ff472c10f
(svn r8102) -Cleanup: Remove unreachable code (r8096), useless cast
Darkvater
parents:
5889
diff
changeset
|
77 |
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
|
78 |
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
|
79 |
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
|
80 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
81 |
/* 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
|
82 |
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
|
83 |
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
|
84 |
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
|
85 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
86 |
/* Show GRF parameter list */ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
87 |
if (show_params) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
88 |
if (c->num_params > 0) { |
5308
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5248
diff
changeset
|
89 |
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
|
90 |
SetDParamStr(0, buff); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
91 |
} else { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
92 |
SetDParam(0, STR_01A9_NONE); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
93 |
} |
6703
9ddfcb1849e4
(svn r9449) -Fix: Truncate the newgrf information text in the newgrf gui if it's too long.
maedhros
parents:
6674
diff
changeset
|
94 |
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
|
95 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
96 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
97 |
/* 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
|
98 |
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
|
99 |
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
|
100 |
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
|
101 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
102 |
/* 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
|
103 |
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
|
104 |
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
|
105 |
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
|
106 |
} 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
|
107 |
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
|
108 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
109 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
110 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
111 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
112 |
/* 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
|
113 |
struct newgrf_add_d { |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
114 |
GRFConfig **list; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
115 |
const GRFConfig *sel; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6555
diff
changeset
|
116 |
}; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
117 |
|
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
118 |
/* Names of the add a newgrf window widgets */ |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
119 |
enum AddNewGRFWindowWidgets { |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
120 |
ANGRFW_CLOSEBOX = 0, |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
121 |
ANGRFW_CAPTION, |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
122 |
ANGRFW_BACKGROUND, |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
123 |
ANGRFW_GRF_LIST, |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
124 |
ANGRFW_SCROLLBAR, |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
125 |
ANGRFW_GRF_INFO, |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
126 |
ANGRFW_ADD, |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
127 |
ANGRFW_RESCAN, |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
128 |
ANGRFW_RESIZE, |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
129 |
}; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
130 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
131 |
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
|
132 |
{ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
133 |
switch (e->event) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
134 |
case WE_PAINT: { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
135 |
const GRFConfig *c; |
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
136 |
const Widget *wl = &w->widget[ANGRFW_GRF_LIST]; |
8566
94fb2c4351dd
(svn r11631) -Fix (r11585, r11626): remove MSVC warnings
glx
parents:
8521
diff
changeset
|
137 |
int n = 0; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
138 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
139 |
/* Count the number of GRFs */ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
140 |
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
|
141 |
|
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
142 |
w->vscroll.cap = (wl->bottom - wl->top) / 10; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
143 |
SetVScrollCount(w, n); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
144 |
|
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
145 |
w->SetWidgetDisabledState(ANGRFW_ADD, 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
|
146 |
DrawWindowWidgets(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
147 |
|
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
148 |
GfxFillRect(wl->left + 1, wl->top + 1, wl->right, wl->bottom, 0xD7); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
149 |
|
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
150 |
uint y = wl->top + 1; |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
151 |
for (c = _all_grfs, n = 0; c != NULL && n < (w->vscroll.pos + w->vscroll.cap); c = c->next, n++) { |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
152 |
if (n >= w->vscroll.pos) { |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
153 |
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
|
154 |
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
|
155 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
156 |
/* Draw selection background */ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
157 |
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
|
158 |
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
|
159 |
y += 10; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
160 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
161 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
162 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
163 |
if (WP(w, newgrf_add_d).sel != NULL) { |
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
164 |
const Widget *wi = &w->widget[ANGRFW_GRF_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
|
165 |
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
|
166 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
167 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
168 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
169 |
|
7507
c287e5e93517
(svn r10267) -Add: enable double clic to add in 'add newgrf' window
glx
parents:
7452
diff
changeset
|
170 |
case WE_DOUBLE_CLICK: |
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
171 |
if (e->we.click.widget != ANGRFW_GRF_LIST) break; |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
172 |
e->we.click.widget = ANGRFW_ADD; |
7507
c287e5e93517
(svn r10267) -Add: enable double clic to add in 'add newgrf' window
glx
parents:
7452
diff
changeset
|
173 |
/* Fall through */ |
c287e5e93517
(svn r10267) -Add: enable double clic to add in 'add newgrf' window
glx
parents:
7452
diff
changeset
|
174 |
|
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
175 |
case WE_CLICK: |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
176 |
switch (e->we.click.widget) { |
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
177 |
case ANGRFW_GRF_LIST: { |
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
178 |
/* Get row... */ |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
179 |
const GRFConfig *c; |
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
180 |
uint i = (e->we.click.pt.y - w->widget[ANGRFW_GRF_LIST].top) / 10 + w->vscroll.pos; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
181 |
|
9191
ae14770c829a
(svn r12368) -Codechange: use explicit body for loops and conditions and remove -Wno-empty-body from the configure script
smatz
parents:
9087
diff
changeset
|
182 |
for (c = _all_grfs; c != NULL && i > 0; c = c->next, i--) {} |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
183 |
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
|
184 |
SetWindowDirty(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
185 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
186 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
187 |
|
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
188 |
case ANGRFW_ADD: // Add selection to list |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
189 |
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
|
190 |
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
|
191 |
GRFConfig **list; |
5243
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
192 |
|
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
193 |
/* 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
|
194 |
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
|
195 |
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
|
196 |
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
|
197 |
return; |
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
198 |
} |
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
199 |
} |
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
200 |
|
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
201 |
/* 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
|
202 |
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
|
203 |
*c = *src; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
204 |
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
|
205 |
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
|
206 |
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
|
207 |
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
|
208 |
|
a564347a939b
(svn r7367) -Codechange: prevent adding files where the GRF ID is already in the list
peter1138
parents:
5241
diff
changeset
|
209 |
/* 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
|
210 |
*list = c; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
211 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
212 |
DeleteWindowByClass(WC_SAVELOAD); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
213 |
InvalidateWindowData(WC_GAME_OPTIONS, 0); |
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 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
216 |
|
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
217 |
case ANGRFW_RESCAN: // Rescan list |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
218 |
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
|
219 |
ScanNewGRFFiles(); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
220 |
SetWindowDirty(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
221 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
222 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
223 |
break; |
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 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
226 |
|
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
227 |
/* Widget definition for the add a newgrf window */ |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
228 |
static const Widget _newgrf_add_dlg_widgets[] = { |
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
229 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, // ANGRFW_CLOSEBOX |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
230 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 306, 0, 13, STR_NEWGRF_ADD_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS }, // ANGRFW_CAPTION |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
231 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 294, 14, 121, 0x0, STR_NULL }, // ANGRFW_BACKGROUND |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
232 |
{ WWT_INSET, RESIZE_RB, 14, 2, 292, 16, 119, 0x0, STR_NULL }, // ANGRFW_GRF_LIST |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
233 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 295, 306, 14, 121, 0x0, STR_NULL }, // ANGRFW_SCROLLBAR |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
234 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 306, 122, 224, 0x0, STR_NULL }, // ANGRFW_GRF_INFO |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
235 |
{ WWT_PUSHTXTBTN, RESIZE_RTB, 14, 0, 146, 225, 236, STR_NEWGRF_ADD_FILE, STR_NEWGRF_ADD_FILE_TIP }, // ANGRFW_ADD |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
236 |
{ WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 147, 294, 225, 236, STR_NEWGRF_RESCAN_FILES, STR_NEWGRF_RESCAN_FILES_TIP }, // ANGRFW_RESCAN |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
237 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 295, 306, 225, 236, 0x0, STR_RESIZE_BUTTON }, // ANGRFW_RESIZE |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
238 |
{ WIDGETS_END }, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
239 |
}; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
240 |
|
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
241 |
/* Window definition for the add a newgrf window */ |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
242 |
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
|
243 |
WDP_CENTER, WDP_CENTER, 307, 237, 307, 337, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5919
diff
changeset
|
244 |
WC_SAVELOAD, WC_NONE, |
8515
d0401d967e99
(svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents:
8514
diff
changeset
|
245 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
246 |
_newgrf_add_dlg_widgets, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
247 |
NewGRFAddDlgWndProc, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
248 |
}; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
249 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
250 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
251 |
/* 'NewGRF Settings' dialogue */ |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6555
diff
changeset
|
252 |
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
|
253 |
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
|
254 |
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
|
255 |
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
|
256 |
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
|
257 |
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
|
258 |
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
|
259 |
}; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
260 |
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
|
261 |
|
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
262 |
|
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
263 |
/* Names of the manage newgrfs window widgets */ |
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
|
264 |
enum ShowNewGRFStateWidgets { |
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
265 |
SNGRFS_CLOSEBOX = 0, |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
266 |
SNGRFS_CAPTION, |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
267 |
SNGRFS_BACKGROUND, |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
268 |
SNGRFS_ADD, |
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
|
269 |
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
|
270 |
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
|
271 |
SNGRFS_MOVE_DOWN, |
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
272 |
SNGRFS_FILE_LIST, |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
273 |
SNGRFS_SCROLLBAR, |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
274 |
SNGRFS_NEWGRF_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
|
275 |
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
|
276 |
SNGRFS_APPLY_CHANGES, |
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
277 |
SNGRFS_RESIZE, |
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
|
278 |
}; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
279 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
280 |
static void SetupNewGRFState(Window *w) |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
281 |
{ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
282 |
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
|
283 |
|
9087
c6ff1721bb00
(svn r12172) -Codechange: Allow buttons to resize in NewGRF settings window
peter1138
parents:
8760
diff
changeset
|
284 |
w->SetWidgetDisabledState(SNGRFS_ADD, !WP(w, newgrf_d).editable); |
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
285 |
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
|
286 |
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
|
287 |
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
|
288 |
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
|
289 |
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
|
290 |
); |
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
291 |
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
|
292 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
293 |
if (!disable_all) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
294 |
/* 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
|
295 |
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
|
296 |
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
|
297 |
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
|
298 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
299 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
300 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
301 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
302 |
static void SetupNewGRFWindow(Window *w) |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
303 |
{ |
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
|
304 |
const GRFConfig *c; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
305 |
int i; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
306 |
|
9191
ae14770c829a
(svn r12368) -Codechange: use explicit body for loops and conditions and remove -Wno-empty-body from the configure script
smatz
parents:
9087
diff
changeset
|
307 |
for (c = *WP(w, newgrf_d).list, i = 0; c != NULL; c = c->next, i++) {} |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
308 |
|
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
|
309 |
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
|
310 |
SetVScrollCount(w, i); |
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
311 |
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
|
312 |
} |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
313 |
|
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
314 |
|
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
315 |
/** Callback function for the newgrf 'apply changes' confirmation window |
6984
045168d13eef
(svn r9669) -Documentation: some more doxygen fixes
belugas
parents:
6703
diff
changeset
|
316 |
* @param w Window which is calling this callback |
045168d13eef
(svn r9669) -Documentation: some more doxygen fixes
belugas
parents:
6703
diff
changeset
|
317 |
* @param confirmed boolean value, true when yes was clicked, false otherwise |
045168d13eef
(svn r9669) -Documentation: some more doxygen fixes
belugas
parents:
6703
diff
changeset
|
318 |
*/ |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5552
diff
changeset
|
319 |
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
|
320 |
{ |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5552
diff
changeset
|
321 |
if (confirmed) { |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
322 |
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
|
323 |
GRFConfig *c; |
5e0f0faf50fc
(svn r8094) -Feature/Fix (r7523): Show the activated status of the GRF list after pressing 'apply'
Darkvater
parents:
5885
diff
changeset
|
324 |
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
|
325 |
|
7452
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7369
diff
changeset
|
326 |
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
|
327 |
ReloadNewGRFData(); |
5886
5e0f0faf50fc
(svn r8094) -Feature/Fix (r7523): Show the activated status of the GRF list after pressing 'apply'
Darkvater
parents:
5885
diff
changeset
|
328 |
|
5e0f0faf50fc
(svn r8094) -Feature/Fix (r7523): Show the activated status of the GRF list after pressing 'apply'
Darkvater
parents:
5885
diff
changeset
|
329 |
/* Show new, updated list */ |
9191
ae14770c829a
(svn r12368) -Codechange: use explicit body for loops and conditions and remove -Wno-empty-body from the configure script
smatz
parents:
9087
diff
changeset
|
330 |
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
|
331 |
CopyGRFConfigList(nd->list, *nd->orig_list, false); |
9191
ae14770c829a
(svn r12368) -Codechange: use explicit body for loops and conditions and remove -Wno-empty-body from the configure script
smatz
parents:
9087
diff
changeset
|
332 |
for (c = *nd->list; c != NULL && i > 0; c = c->next, i--) {} |
5886
5e0f0faf50fc
(svn r8094) -Feature/Fix (r7523): Show the activated status of the GRF list after pressing 'apply'
Darkvater
parents:
5885
diff
changeset
|
333 |
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
|
334 |
|
5e0f0faf50fc
(svn r8094) -Feature/Fix (r7523): Show the activated status of the GRF list after pressing 'apply'
Darkvater
parents:
5885
diff
changeset
|
335 |
SetWindowDirty(w); |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
336 |
} |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
337 |
} |
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 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
340 |
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
|
341 |
{ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
342 |
switch (e->event) { |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
343 |
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
|
344 |
const GRFConfig *c; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
345 |
int i, y; |
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 |
SetupNewGRFState(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
348 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
349 |
DrawWindowWidgets(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
350 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
351 |
/* 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
|
352 |
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
|
353 |
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
|
354 |
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
|
355 |
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
|
356 |
SpriteID pal; |
8233
d66599f73fd1
(svn r11272) -Codechange: Truncate text describing the grf file in the NewGrf settings gui
belugas
parents:
8176
diff
changeset
|
357 |
byte txtoffset; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
358 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
359 |
/* Pick a colour */ |
6555
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
360 |
switch (c->status) { |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
361 |
case GCS_NOT_FOUND: |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
362 |
case GCS_DISABLED: |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
363 |
pal = PALETTE_TO_RED; |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
364 |
break; |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
365 |
case GCS_ACTIVATED: |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
366 |
pal = PALETTE_TO_GREEN; |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
367 |
break; |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
368 |
default: |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
369 |
pal = PALETTE_TO_BLUE; |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
370 |
break; |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
371 |
} |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6492
diff
changeset
|
372 |
|
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
|
373 |
/* 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
|
374 |
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
|
375 |
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
|
376 |
pal = PALETTE_TO_GREY; |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8378
diff
changeset
|
377 |
} 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
|
378 |
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
|
379 |
} |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
380 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
381 |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5898
diff
changeset
|
382 |
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
|
383 |
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
|
384 |
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
|
385 |
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
|
386 |
y += 14; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
387 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
388 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
389 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
390 |
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
|
391 |
/* 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
|
392 |
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
|
393 |
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
|
394 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
395 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
396 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
397 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
398 |
|
5241
2dafe1235308
(svn r7363) -Fix (r7357): Update count of NewGRFs when adding an file
peter1138
parents:
5237
diff
changeset
|
399 |
case WE_INVALIDATE_DATA: |
2dafe1235308
(svn r7363) -Fix (r7357): Update count of NewGRFs when adding an file
peter1138
parents:
5237
diff
changeset
|
400 |
SetupNewGRFWindow(w); |
2dafe1235308
(svn r7363) -Fix (r7357): Update count of NewGRFs when adding an file
peter1138
parents:
5237
diff
changeset
|
401 |
break; |
2dafe1235308
(svn r7363) -Fix (r7357): Update count of NewGRFs when adding an file
peter1138
parents:
5237
diff
changeset
|
402 |
|
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
403 |
case WE_CLICK: |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
404 |
switch (e->we.click.widget) { |
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
405 |
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
|
406 |
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
|
407 |
Window *w; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
408 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
409 |
DeleteWindowByClass(WC_SAVELOAD); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
410 |
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
|
411 |
w->resize.step_height = 10; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
412 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
413 |
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
|
414 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
415 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
416 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
417 |
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
|
418 |
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
|
419 |
|
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
|
420 |
/* 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
|
421 |
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
|
422 |
|
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
423 |
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
|
424 |
/* 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
|
425 |
* 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
|
426 |
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
|
427 |
|
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
428 |
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
|
429 |
*pc = c->next; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
430 |
free(c); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
431 |
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 |
} |
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
|
434 |
|
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
|
435 |
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
|
436 |
SetupNewGRFWindow(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
437 |
SetWindowDirty(w); |
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 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
441 |
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
|
442 |
GRFConfig **pc, *c; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
443 |
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
|
444 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
445 |
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
|
446 |
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
|
447 |
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
|
448 |
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
|
449 |
*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
|
450 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
451 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
452 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
453 |
SetWindowDirty(w); |
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 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
457 |
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
|
458 |
GRFConfig **pc, *c; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
459 |
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
|
460 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
461 |
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
|
462 |
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
|
463 |
*pc = c->next; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
464 |
c->next = c->next->next; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
465 |
(*pc)->next = c; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
466 |
break; |
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 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
469 |
SetWindowDirty(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
470 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
471 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
472 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
473 |
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
|
474 |
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
|
475 |
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
|
476 |
|
9191
ae14770c829a
(svn r12368) -Codechange: use explicit body for loops and conditions and remove -Wno-empty-body from the configure script
smatz
parents:
9087
diff
changeset
|
477 |
for (c = *WP(w, newgrf_d).list; c != NULL && i > 0; c = c->next, i--) {} |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
478 |
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
|
479 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
480 |
SetWindowDirty(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
481 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
482 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
483 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
484 |
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
|
485 |
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
|
486 |
ShowQuery( |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
487 |
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
|
488 |
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
|
489 |
w, |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5552
diff
changeset
|
490 |
NewGRFConfirmationCallback |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
491 |
); |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
492 |
} else { |
7452
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7369
diff
changeset
|
493 |
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
|
494 |
ResetGRFConfig(false); |
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7369
diff
changeset
|
495 |
ReloadNewGRFData(); |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
496 |
} |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
497 |
break; |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
498 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6574
diff
changeset
|
499 |
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
|
500 |
char buff[512]; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
501 |
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
|
502 |
|
5308
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5248
diff
changeset
|
503 |
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
|
504 |
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
|
505 |
break; |
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 |
} |
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 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
510 |
case WE_ON_EDIT_TEXT: |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
511 |
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
|
512 |
/* Parse our new "int list" */ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
513 |
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
|
514 |
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
|
515 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
516 |
/* 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
|
517 |
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
|
518 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
519 |
SetWindowDirty(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
520 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
521 |
|
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
522 |
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
|
523 |
if (!WP(w, newgrf_d).execute) { |
7452
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7369
diff
changeset
|
524 |
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
|
525 |
ResetGRFConfig(false); |
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7369
diff
changeset
|
526 |
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
|
527 |
} |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
528 |
/* 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
|
529 |
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
|
530 |
break; |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
531 |
|
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
532 |
case WE_RESIZE: |
9087
c6ff1721bb00
(svn r12172) -Codechange: Allow buttons to resize in NewGRF settings window
peter1138
parents:
8760
diff
changeset
|
533 |
if (e->we.sizing.diff.x != 0) { |
c6ff1721bb00
(svn r12172) -Codechange: Allow buttons to resize in NewGRF settings window
peter1138
parents:
8760
diff
changeset
|
534 |
ResizeButtons(w, SNGRFS_ADD, SNGRFS_MOVE_DOWN); |
c6ff1721bb00
(svn r12172) -Codechange: Allow buttons to resize in NewGRF settings window
peter1138
parents:
8760
diff
changeset
|
535 |
ResizeButtons(w, SNGRFS_SET_PARAMETERS, SNGRFS_APPLY_CHANGES); |
c6ff1721bb00
(svn r12172) -Codechange: Allow buttons to resize in NewGRF settings window
peter1138
parents:
8760
diff
changeset
|
536 |
} |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
537 |
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
|
538 |
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
|
539 |
SetupNewGRFWindow(w); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
540 |
break; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
541 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
542 |
} |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
543 |
|
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
544 |
/* Widget definition of the manage newgrfs window */ |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
545 |
static const Widget _newgrf_widgets[] = { |
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
546 |
{ WWT_CLOSEBOX, RESIZE_NONE, 10, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, // SNGRFS_CLOSEBOX |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
547 |
{ WWT_CAPTION, RESIZE_RIGHT, 10, 11, 299, 0, 13, STR_NEWGRF_SETTINGS_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS }, // SNGRFS_CAPTION |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
548 |
{ WWT_PANEL, RESIZE_RIGHT, 10, 0, 299, 14, 29, STR_NULL, STR_NULL }, // SNGRFS_BACKGROUND |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
549 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 10, 79, 16, 27, STR_NEWGRF_ADD, STR_NEWGRF_ADD_TIP }, // SNGRFS_ADD |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
550 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 80, 149, 16, 27, STR_NEWGRF_REMOVE, STR_NEWGRF_REMOVE_TIP }, // SNGRFS_REMOVE |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
551 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 150, 219, 16, 27, STR_NEWGRF_MOVEUP, STR_NEWGRF_MOVEUP_TIP }, // SNGRFS_MOVE_UP |
9087
c6ff1721bb00
(svn r12172) -Codechange: Allow buttons to resize in NewGRF settings window
peter1138
parents:
8760
diff
changeset
|
552 |
{ WWT_PUSHTXTBTN, RESIZE_RIGHT, 3, 220, 289, 16, 27, STR_NEWGRF_MOVEDOWN, STR_NEWGRF_MOVEDOWN_TIP }, // SNGRFS_MOVE_DOWN |
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
553 |
{ WWT_MATRIX, RESIZE_RB, 10, 0, 287, 30, 99, 0x501, STR_NEWGRF_FILE_TIP }, // SNGRFS_FILE_LIST |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
554 |
{ WWT_SCROLLBAR, RESIZE_LRB, 10, 288, 299, 30, 99, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST }, // SNGRFS_SCROLLBAR |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
555 |
{ WWT_PANEL, RESIZE_RTB, 10, 0, 299, 100, 212, STR_NULL, STR_NULL }, // SNGRFS_NEWGRF_INFO |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
556 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 10, 0, 143, 213, 224, STR_NEWGRF_SET_PARAMETERS, STR_NULL }, // SNGRFS_SET_PARAMETERS |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
557 |
{ WWT_PUSHTXTBTN, RESIZE_RTB, 10, 144, 287, 213, 224, STR_NEWGRF_APPLY_CHANGES, STR_NULL }, // SNGRFS_APPLY_CHANGES |
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
558 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 10, 288, 299, 213, 224, 0x0, STR_RESIZE_BUTTON }, // SNGRFS_RESIZE |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
559 |
{ WIDGETS_END }, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
560 |
}; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
561 |
|
8521
ca9e5d1537c9
(svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there
skidd13
parents:
8515
diff
changeset
|
562 |
/* Window definition of the manage newgrfs window */ |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
563 |
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
|
564 |
WDP_CENTER, WDP_CENTER, 300, 225, 300, 225, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5919
diff
changeset
|
565 |
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
|
566 |
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
|
567 |
_newgrf_widgets, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
568 |
NewGRFWndProc, |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
569 |
}; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
570 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
571 |
|
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
572 |
/** 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
|
573 |
* @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
|
574 |
* @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
|
575 |
* @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
|
576 |
* 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
|
577 |
* @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
|
578 |
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
|
579 |
{ |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5345
diff
changeset
|
580 |
static GRFConfig *local = NULL; |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
581 |
Window *w; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
582 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
583 |
DeleteWindowByClass(WC_GAME_OPTIONS); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
584 |
w = AllocateWindowDesc(&_newgrf_desc); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
585 |
if (w == NULL) return; |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
586 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
587 |
w->resize.step_height = 14; |
7452
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7369
diff
changeset
|
588 |
CopyGRFConfigList(&local, *config, false); |
5237
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
589 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
590 |
/* Clear selections */ |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
591 |
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
|
592 |
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
|
593 |
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
|
594 |
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
|
595 |
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
|
596 |
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
|
597 |
|
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
598 |
SetupNewGRFWindow(w); |
c14c97d7030a
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
diff
changeset
|
599 |
} |