author | KUDr |
Mon, 01 Jan 2007 10:26:12 +0000 | |
branch | custombridgeheads |
changeset 5620 | 3b40a41f90d2 |
parent 5568 | 75f13d7bfaed |
child 5623 | ef2a8a524a95 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1786
diff
changeset
|
4 |
#include "openttd.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1287
diff
changeset
|
5 |
#include "debug.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
6 |
#include "functions.h" |
1309
dab90d4cbf2d
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
1299
diff
changeset
|
7 |
#include "strings.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
222
diff
changeset
|
8 |
#include "table/strings.h" |
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
9 |
#include "table/sprites.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
534
diff
changeset
|
10 |
#include "map.h" |
1386
aa5a172a8431
(svn r1890) Begin to clean up the edit box: Remove one global variable and split the combined edit/original buffer into two
tron
parents:
1309
diff
changeset
|
11 |
#include "gui.h" |
0 | 12 |
#include "window.h" |
13 |
#include "gfx.h" |
|
14 |
#include "command.h" |
|
15 |
#include "viewport.h" |
|
16 |
#include "industry.h" |
|
17 |
#include "town.h" |
|
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2084
diff
changeset
|
18 |
#include "variables.h" |
0 | 19 |
|
4995
e6152c0dc612
(svn r7001) -Codechange: _build_industry_trypes is now only used by industry_gui.c. Move it there.
belugas
parents:
4939
diff
changeset
|
20 |
const byte _build_industry_types[4][12] = { |
e6152c0dc612
(svn r7001) -Codechange: _build_industry_trypes is now only used by industry_gui.c. Move it there.
belugas
parents:
4939
diff
changeset
|
21 |
{ 1, 2, 4, 6, 8, 0, 3, 5, 9, 11, 18 }, |
e6152c0dc612
(svn r7001) -Codechange: _build_industry_trypes is now only used by industry_gui.c. Move it there.
belugas
parents:
4939
diff
changeset
|
22 |
{ 1, 14, 4, 13, 7, 0, 3, 9, 11, 15 }, |
e6152c0dc612
(svn r7001) -Codechange: _build_industry_trypes is now only used by industry_gui.c. Move it there.
belugas
parents:
4939
diff
changeset
|
23 |
{ 25, 13, 4, 23, 22, 11, 17, 10, 24, 19, 20, 21 }, |
e6152c0dc612
(svn r7001) -Codechange: _build_industry_trypes is now only used by industry_gui.c. Move it there.
belugas
parents:
4939
diff
changeset
|
24 |
{ 27, 30, 31, 33, 26, 28, 29, 32, 34, 35, 36 }, |
e6152c0dc612
(svn r7001) -Codechange: _build_industry_trypes is now only used by industry_gui.c. Move it there.
belugas
parents:
4939
diff
changeset
|
25 |
}; |
0 | 26 |
|
1004 | 27 |
static void UpdateIndustryProduction(Industry *i); |
28 |
||
0 | 29 |
static void BuildIndustryWndProc(Window *w, WindowEvent *e) |
30 |
{ |
|
2951 | 31 |
switch (e->event) { |
0 | 32 |
case WE_PAINT: |
33 |
DrawWindowWidgets(w); |
|
34 |
if (_thd.place_mode == 1 && _thd.window_class == WC_BUILD_INDUSTRY) { |
|
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1666
diff
changeset
|
35 |
int ind_type = _build_industry_types[_opt_ptr->landscape][WP(w,def_d).data_1]; |
0 | 36 |
|
3689
db67c356f44b
(svn r4614) CodeChange : Cleanup of industry_cmd (Step-4).
belugas
parents:
3107
diff
changeset
|
37 |
SetDParam(0, (_price.build_industry >> 5) * GetIndustrySpec(ind_type)->cost_multiplier); |
0 | 38 |
DrawStringCentered(85, w->height - 21, STR_482F_COST, 0); |
39 |
} |
|
40 |
break; |
|
41 |
||
42 |
case WE_CLICK: { |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
43 |
int wid = e->we.click.widget; |
0 | 44 |
if (wid >= 3) { |
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
45 |
if (HandlePlacePushButton(w, wid, SPR_CURSOR_INDUSTRY, 1, NULL)) |
0 | 46 |
WP(w,def_d).data_1 = wid - 3; |
47 |
} |
|
48 |
} break; |
|
49 |
||
50 |
case WE_PLACE_OBJ: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
51 |
if (DoCommandP(e->we.place.tile, _build_industry_types[_opt_ptr->landscape][WP(w,def_d).data_1], 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY))) |
0 | 52 |
ResetObjectToPlace(); |
53 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
54 |
|
0 | 55 |
case WE_ABORT_PLACE_OBJ: |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
56 |
RaiseWindowButtons(w); |
0 | 57 |
break; |
58 |
} |
|
59 |
} |
|
60 |
||
61 |
static const Widget _build_industry_land0_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
62 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
63 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
64 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
65 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
66 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_0242_SAWMILL, STR_0264_CONSTRUCT_SAWMILL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
67 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
68 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
69 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0247_STEEL_MILL, STR_0269_CONSTRUCT_STEEL_MILL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
70 |
{ WIDGETS_END}, |
0 | 71 |
}; |
72 |
||
73 |
static const Widget _build_industry_land1_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
74 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
75 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
76 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
77 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
78 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024C_PAPER_MILL, STR_026E_CONSTRUCT_PAPER_MILL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
79 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
80 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_024D_FOOD_PROCESSING_PLANT, STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
81 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_024E_PRINTING_WORKS, STR_0270_CONSTRUCT_PRINTING_WORKS}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
82 |
{ WIDGETS_END}, |
0 | 83 |
}; |
84 |
||
85 |
static const Widget _build_industry_land2_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
86 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
87 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
88 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
89 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0250_LUMBER_MILL, STR_0273_CONSTRUCT_LUMBER_MILL_TO}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
90 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024D_FOOD_PROCESSING_PLANT, STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
91 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
92 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
93 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0254_WATER_TOWER, STR_0277_CONSTRUCT_WATER_TOWER_CAN}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
94 |
{ WIDGETS_END}, |
0 | 95 |
}; |
96 |
||
97 |
static const Widget _build_industry_land3_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
98 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
99 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
100 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
101 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0258_CANDY_FACTORY, STR_027B_CONSTRUCT_CANDY_FACTORY}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
102 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_025B_TOY_SHOP, STR_027E_CONSTRUCT_TOY_SHOP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
103 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_025C_TOY_FACTORY, STR_027F_CONSTRUCT_TOY_FACTORY}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
104 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_025E_FIZZY_DRINK_FACTORY, STR_0281_CONSTRUCT_FIZZY_DRINK_FACTORY}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
105 |
{ WIDGETS_END}, |
0 | 106 |
}; |
107 |
||
108 |
static const Widget _build_industry_land0_widgets_extra[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
109 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
110 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
111 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 187, 0x0, STR_NULL}, |
0 | 112 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
113 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
114 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_0242_SAWMILL, STR_0264_CONSTRUCT_SAWMILL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
115 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
116 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
117 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0247_STEEL_MILL, STR_0269_CONSTRUCT_STEEL_MILL}, |
0 | 118 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
119 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 84, 95, STR_0240_COAL_MINE, STR_CONSTRUCT_COAL_MINE_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
120 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 97, 108, STR_0243_FOREST, STR_CONSTRUCT_FOREST_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
121 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 110, 121, STR_0245_OIL_RIG, STR_CONSTRUCT_OIL_RIG_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
122 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 123, 134, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
123 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 136, 147, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
124 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 149, 160, STR_0249_IRON_ORE_MINE, STR_CONSTRUCT_IRON_ORE_MINE_TIP}, |
0 | 125 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
126 |
{ WIDGETS_END}, |
0 | 127 |
}; |
128 |
||
129 |
static const Widget _build_industry_land1_widgets_extra[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
130 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
131 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
132 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 174, 0x0, STR_NULL}, |
0 | 133 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
134 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
135 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024C_PAPER_MILL, STR_026E_CONSTRUCT_PAPER_MILL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
136 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
137 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_024D_FOOD_PROCESSING_PLANT, STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
138 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_024E_PRINTING_WORKS, STR_0270_CONSTRUCT_PRINTING_WORKS}, |
0 | 139 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
140 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 84, 95, STR_0240_COAL_MINE, STR_CONSTRUCT_COAL_MINE_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
141 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 97, 108, STR_0243_FOREST, STR_CONSTRUCT_FOREST_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
142 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 110, 121, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
143 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 123, 134, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
144 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 136, 147, STR_024F_GOLD_MINE, STR_CONSTRUCT_GOLD_MINE_TIP}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
145 |
{ WIDGETS_END}, |
0 | 146 |
}; |
147 |
||
148 |
static const Widget _build_industry_land2_widgets_extra[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
149 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
150 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
151 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 200, 0x0, STR_NULL}, |
0 | 152 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
153 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0250_LUMBER_MILL, STR_0273_CONSTRUCT_LUMBER_MILL_TO}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
154 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024D_FOOD_PROCESSING_PLANT, STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
155 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
156 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
157 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0254_WATER_TOWER, STR_0277_CONSTRUCT_WATER_TOWER_CAN}, |
0 | 158 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
159 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 84, 95, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
160 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 97, 108, STR_0255_DIAMOND_MINE, STR_CONSTRUCT_DIAMOND_MINE_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
161 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 110, 121, STR_0256_COPPER_ORE_MINE, STR_CONSTRUCT_COPPER_ORE_MINE_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
162 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 123, 134, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
163 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 136, 147, STR_0251_FRUIT_PLANTATION, STR_CONSTRUCT_FRUIT_PLANTATION_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
164 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 149, 160, STR_0252_RUBBER_PLANTATION, STR_CONSTRUCT_RUBBER_PLANTATION_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
165 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 162, 173, STR_0253_WATER_SUPPLY, STR_CONSTRUCT_WATER_SUPPLY_TIP}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
166 |
{ WIDGETS_END}, |
0 | 167 |
}; |
168 |
||
169 |
static const Widget _build_industry_land3_widgets_extra[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
170 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
171 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
172 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 187, 0x0, STR_NULL}, |
0 | 173 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
174 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0258_CANDY_FACTORY, STR_027B_CONSTRUCT_CANDY_FACTORY}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
175 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_025B_TOY_SHOP, STR_027E_CONSTRUCT_TOY_SHOP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
176 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_025C_TOY_FACTORY, STR_027F_CONSTRUCT_TOY_FACTORY}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
177 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_025E_FIZZY_DRINK_FACTORY, STR_0281_CONSTRUCT_FIZZY_DRINK_FACTORY}, |
0 | 178 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
179 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 71, 82, STR_0257_COTTON_CANDY_FOREST, STR_CONSTRUCT_COTTON_CANDY_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
180 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 84, 95, STR_0259_BATTERY_FARM, STR_CONSTRUCT_BATTERY_FARM_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
181 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 97, 108, STR_025A_COLA_WELLS, STR_CONSTRUCT_COLA_WELLS_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
182 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 110, 121, STR_025D_PLASTIC_FOUNTAINS, STR_CONSTRUCT_PLASTIC_FOUNTAINS_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
183 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 123, 134, STR_025F_BUBBLE_GENERATOR, STR_CONSTRUCT_BUBBLE_GENERATOR_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
184 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 136, 147, STR_0260_TOFFEE_QUARRY, STR_CONSTRUCT_TOFFEE_QUARRY_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
185 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 149, 160, STR_0261_SUGAR_MINE, STR_CONSTRUCT_SUGAR_MINE_TIP}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
186 |
{ WIDGETS_END}, |
0 | 187 |
}; |
188 |
||
189 |
||
190 |
static const WindowDesc _build_industry_land0_desc = { |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
191 |
WDP_AUTO, WDP_AUTO, 170, 116, |
0 | 192 |
WC_BUILD_INDUSTRY,0, |
193 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
194 |
_build_industry_land0_widgets, |
|
195 |
BuildIndustryWndProc |
|
196 |
}; |
|
197 |
||
198 |
static const WindowDesc _build_industry_land1_desc = { |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
199 |
WDP_AUTO, WDP_AUTO, 170, 116, |
0 | 200 |
WC_BUILD_INDUSTRY,0, |
201 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
202 |
_build_industry_land1_widgets, |
|
203 |
BuildIndustryWndProc |
|
204 |
}; |
|
205 |
||
206 |
static const WindowDesc _build_industry_land2_desc = { |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
207 |
WDP_AUTO, WDP_AUTO, 170, 116, |
0 | 208 |
WC_BUILD_INDUSTRY,0, |
209 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
210 |
_build_industry_land2_widgets, |
|
211 |
BuildIndustryWndProc |
|
212 |
}; |
|
213 |
||
214 |
static const WindowDesc _build_industry_land3_desc = { |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
215 |
WDP_AUTO, WDP_AUTO, 170, 116, |
0 | 216 |
WC_BUILD_INDUSTRY,0, |
217 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
218 |
_build_industry_land3_widgets, |
|
219 |
BuildIndustryWndProc |
|
220 |
}; |
|
221 |
||
222 |
static const WindowDesc _build_industry_land0_desc_extra = { |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
223 |
WDP_AUTO, WDP_AUTO, 170, 188, |
0 | 224 |
WC_BUILD_INDUSTRY,0, |
225 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
226 |
_build_industry_land0_widgets_extra, |
|
227 |
BuildIndustryWndProc |
|
228 |
}; |
|
229 |
||
230 |
static const WindowDesc _build_industry_land1_desc_extra = { |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
231 |
WDP_AUTO, WDP_AUTO, 170, 175, |
0 | 232 |
WC_BUILD_INDUSTRY,0, |
233 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
234 |
_build_industry_land1_widgets_extra, |
|
235 |
BuildIndustryWndProc |
|
236 |
}; |
|
237 |
||
238 |
static const WindowDesc _build_industry_land2_desc_extra = { |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
239 |
WDP_AUTO, WDP_AUTO, 170, 201, |
0 | 240 |
WC_BUILD_INDUSTRY,0, |
241 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
242 |
_build_industry_land2_widgets_extra, |
|
243 |
BuildIndustryWndProc |
|
244 |
}; |
|
245 |
||
246 |
static const WindowDesc _build_industry_land3_desc_extra = { |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
247 |
WDP_AUTO, WDP_AUTO, 170, 188, |
0 | 248 |
WC_BUILD_INDUSTRY,0, |
249 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
250 |
_build_industry_land3_widgets_extra, |
|
251 |
BuildIndustryWndProc |
|
252 |
}; |
|
253 |
||
254 |
static const WindowDesc * const _industry_window_desc[2][4] = { |
|
255 |
{ |
|
256 |
&_build_industry_land0_desc, |
|
257 |
&_build_industry_land1_desc, |
|
258 |
&_build_industry_land2_desc, |
|
259 |
&_build_industry_land3_desc, |
|
260 |
}, |
|
261 |
{ |
|
262 |
&_build_industry_land0_desc_extra, |
|
263 |
&_build_industry_land1_desc_extra, |
|
264 |
&_build_industry_land2_desc_extra, |
|
265 |
&_build_industry_land3_desc_extra, |
|
266 |
}, |
|
267 |
}; |
|
268 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1019
diff
changeset
|
269 |
void ShowBuildIndustryWindow(void) |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
270 |
{ |
5005
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4995
diff
changeset
|
271 |
if (!IsValidPlayer(_current_player)) return; |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1666
diff
changeset
|
272 |
AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt_ptr->landscape],0); |
0 | 273 |
} |
274 |
||
4211
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
275 |
static inline bool isProductionMinimum(const Industry *i, int pt) { |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
276 |
return i->production_rate[pt] == 1; |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
277 |
} |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
278 |
|
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
279 |
static inline bool isProductionMaximum(const Industry *i, int pt) { |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
280 |
return i->production_rate[pt] == 255; |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
281 |
} |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
282 |
|
4194
18a32dace8ba
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
283 |
static inline bool IsProductionAlterable(const Industry *i) |
18a32dace8ba
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
284 |
{ |
18a32dace8ba
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
285 |
return ((_game_mode == GM_EDITOR || _cheats.setup_prod.value) && |
18a32dace8ba
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
286 |
(i->accepts_cargo[0] == CT_INVALID || i->accepts_cargo[0] == CT_VALUABLES)); |
18a32dace8ba
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
287 |
} |
18a32dace8ba
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
288 |
|
0 | 289 |
static void IndustryViewWndProc(Window *w, WindowEvent *e) |
290 |
{ |
|
1004 | 291 |
// WP(w,vp2_d).data_1 is for the editbox line |
292 |
// WP(w,vp2_d).data_2 is for the clickline |
|
293 |
// WP(w,vp2_d).data_3 is for the click pos (left or right) |
|
0 | 294 |
|
2951 | 295 |
switch (e->event) { |
1004 | 296 |
case WE_PAINT: { |
4171 | 297 |
const Industry *i = GetIndustry(w->window_number); |
2557 | 298 |
|
2070
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
299 |
SetDParam(0, w->window_number); |
0 | 300 |
DrawWindowWidgets(w); |
301 |
||
1004 | 302 |
if (i->accepts_cargo[0] != CT_INVALID) { |
2989 | 303 |
StringID str; |
304 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
305 |
SetDParam(0, _cargoc.names_s[i->accepts_cargo[0]]); |
0 | 306 |
str = STR_4827_REQUIRES; |
1004 | 307 |
if (i->accepts_cargo[1] != CT_INVALID) { |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
308 |
SetDParam(1, _cargoc.names_s[i->accepts_cargo[1]]); |
2989 | 309 |
str = STR_4828_REQUIRES; |
1004 | 310 |
if (i->accepts_cargo[2] != CT_INVALID) { |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
311 |
SetDParam(2, _cargoc.names_s[i->accepts_cargo[2]]); |
2989 | 312 |
str = STR_4829_REQUIRES; |
0 | 313 |
} |
314 |
} |
|
315 |
DrawString(2, 107, str, 0); |
|
316 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
317 |
|
1004 | 318 |
if (i->produced_cargo[0] != CT_INVALID) { |
0 | 319 |
DrawString(2, 117, STR_482A_PRODUCTION_LAST_MONTH, 0); |
320 |
||
4896
72d7a8614580
(svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
peter1138
parents:
4848
diff
changeset
|
321 |
SetDParam(0, i->produced_cargo[0]); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
322 |
SetDParam(1, i->total_production[0]); |
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
1981
diff
changeset
|
323 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
324 |
SetDParam(2, i->pct_transported[0] * 100 >> 8); |
4194
18a32dace8ba
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
325 |
DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 127, STR_482B_TRANSPORTED, 0); |
1004 | 326 |
// Let's put out those buttons.. |
4211
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
327 |
if (IsProductionAlterable(i)) { |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
328 |
DrawArrowButtons(5, 127, 3, (WP(w,vp2_d).data_2 == 1) ? WP(w,vp2_d).data_3 : 0, |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
329 |
!isProductionMinimum(i, 0), !isProductionMaximum(i, 0)); |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
330 |
} |
0 | 331 |
|
1004 | 332 |
if (i->produced_cargo[1] != CT_INVALID) { |
4896
72d7a8614580
(svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
peter1138
parents:
4848
diff
changeset
|
333 |
SetDParam(0, i->produced_cargo[1]); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
334 |
SetDParam(1, i->total_production[1]); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
335 |
SetDParam(2, i->pct_transported[1] * 100 >> 8); |
4194
18a32dace8ba
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
336 |
DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 137, STR_482B_TRANSPORTED, 0); |
1004 | 337 |
// Let's put out those buttons.. |
4211
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
338 |
if (IsProductionAlterable(i)) { |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
339 |
DrawArrowButtons(5, 137, 3, (WP(w,vp2_d).data_2 == 2) ? WP(w,vp2_d).data_3 : 0, |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
340 |
!isProductionMinimum(i, 1), !isProductionMaximum(i, 1)); |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
341 |
} |
0 | 342 |
} |
343 |
} |
|
344 |
||
345 |
DrawWindowViewport(w); |
|
1004 | 346 |
} |
0 | 347 |
break; |
348 |
||
1004 | 349 |
case WE_CLICK: { |
350 |
Industry *i; |
|
351 |
||
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
352 |
switch (e->we.click.widget) { |
1004 | 353 |
case 5: { |
4193
ef08dda0369e
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
Darkvater
parents:
4192
diff
changeset
|
354 |
int line, x; |
1004 | 355 |
|
356 |
i = GetIndustry(w->window_number); |
|
357 |
||
1176
46d14419c1dd
(svn r1678) Added cheat option for setting production of raw-material product industries in game
miham
parents:
1093
diff
changeset
|
358 |
// We should work if needed.. |
4194
18a32dace8ba
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
359 |
if (!IsProductionAlterable(i)) return; |
1004 | 360 |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
361 |
x = e->we.click.pt.x; |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
362 |
line = (e->we.click.pt.y - 127) / 10; |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
363 |
if (e->we.click.pt.y >= 127 && IS_INT_INSIDE(line, 0, 2) && i->produced_cargo[line] != CT_INVALID) { |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
364 |
if (IS_INT_INSIDE(x, 5, 25) ) { |
4193
ef08dda0369e
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
Darkvater
parents:
4192
diff
changeset
|
365 |
/* Clicked buttons, decrease or increase production */ |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
366 |
if (x < 15) { |
4211
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
367 |
if (isProductionMinimum(i, line)) return; |
4193
ef08dda0369e
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
Darkvater
parents:
4192
diff
changeset
|
368 |
i->production_rate[line] = maxu(i->production_rate[line] / 2, 1); |
1004 | 369 |
} else { |
4211
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
370 |
if (isProductionMaximum(i, line)) return; |
4193
ef08dda0369e
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
Darkvater
parents:
4192
diff
changeset
|
371 |
i->production_rate[line] = minu(i->production_rate[line] * 2, 255); |
1004 | 372 |
} |
4193
ef08dda0369e
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
Darkvater
parents:
4192
diff
changeset
|
373 |
|
1004 | 374 |
UpdateIndustryProduction(i); |
375 |
SetWindowDirty(w); |
|
376 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
|
377 |
WP(w,vp2_d).data_2 = line+1; |
|
378 |
WP(w,vp2_d).data_3 = (x < 15 ? 1 : 2); |
|
379 |
} else if (IS_INT_INSIDE(x, 34, 160)) { |
|
380 |
// clicked the text |
|
381 |
WP(w,vp2_d).data_1 = line; |
|
382 |
SetDParam(0, i->production_rate[line] * 8); |
|
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
383 |
ShowQueryString(STR_CONFIG_PATCHES_INT32, |
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
384 |
STR_CONFIG_GAME_PRODUCTION, |
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
385 |
10, 100, w->window_class, |
4299
b86602eaaff1
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4282
diff
changeset
|
386 |
w->window_number, CS_ALPHANUMERAL); |
1004 | 387 |
} |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
388 |
} |
4193
ef08dda0369e
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
Darkvater
parents:
4192
diff
changeset
|
389 |
} break; |
758
bd9e868b9fae
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
727
diff
changeset
|
390 |
case 6: |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
391 |
i = GetIndustry(w->window_number); |
1981 | 392 |
ScrollMainWindowToTile(i->xy + TileDiffXY(1, 1)); |
4193
ef08dda0369e
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
Darkvater
parents:
4192
diff
changeset
|
393 |
} break; |
ef08dda0369e
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
Darkvater
parents:
4192
diff
changeset
|
394 |
|
1004 | 395 |
} |
0 | 396 |
break; |
1004 | 397 |
case WE_TIMEOUT: |
398 |
WP(w,vp2_d).data_2 = 0; |
|
399 |
WP(w,vp2_d).data_3 = 0; |
|
400 |
SetWindowDirty(w); |
|
401 |
break; |
|
402 |
||
403 |
case WE_ON_EDIT_TEXT: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
404 |
if (e->we.edittext.str[0] != '\0') { |
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
405 |
Industry* i = GetIndustry(w->window_number); |
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
406 |
int line = WP(w,vp2_d).data_1; |
1004 | 407 |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
408 |
i->production_rate[line] = clampu(atoi(e->we.edittext.str), 0, 255); |
1004 | 409 |
UpdateIndustryProduction(i); |
410 |
SetWindowDirty(w); |
|
411 |
} |
|
0 | 412 |
} |
413 |
} |
|
414 |
||
1004 | 415 |
static void UpdateIndustryProduction(Industry *i) |
416 |
{ |
|
417 |
if (i->produced_cargo[0] != CT_INVALID) |
|
418 |
i->total_production[0] = 8 * i->production_rate[0]; |
|
419 |
||
420 |
if (i->produced_cargo[1] != CT_INVALID) |
|
421 |
i->total_production[1] = 8 * i->production_rate[1]; |
|
422 |
} |
|
423 |
||
0 | 424 |
static const Widget _industry_view_widgets[] = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
425 |
{ WWT_CLOSEBOX, RESIZE_NONE, 9, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
426 |
{ WWT_CAPTION, RESIZE_NONE, 9, 11, 247, 0, 13, STR_4801, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
427 |
{ WWT_STICKYBOX, RESIZE_NONE, 9, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
428 |
{ WWT_PANEL, RESIZE_NONE, 9, 0, 259, 14, 105, 0x0, STR_NULL}, |
4939
ede0f6777b3c
(svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents:
4938
diff
changeset
|
429 |
{ WWT_INSET, RESIZE_NONE, 9, 2, 257, 16, 103, 0x0, STR_NULL}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
430 |
{ WWT_PANEL, RESIZE_NONE, 9, 0, 259, 106, 147, 0x0, STR_NULL}, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
431 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 9, 0, 129, 148, 159, STR_00E4_LOCATION, STR_482C_CENTER_THE_MAIN_VIEW_ON}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
432 |
{ WWT_PANEL, RESIZE_NONE, 9, 130, 259, 148, 159, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
433 |
{ WIDGETS_END}, |
0 | 434 |
}; |
435 |
||
436 |
static const WindowDesc _industry_view_desc = { |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
437 |
WDP_AUTO, WDP_AUTO, 260, 160, |
0 | 438 |
WC_INDUSTRY_VIEW,0, |
758
bd9e868b9fae
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
727
diff
changeset
|
439 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 440 |
_industry_view_widgets, |
441 |
IndustryViewWndProc |
|
442 |
}; |
|
443 |
||
444 |
void ShowIndustryViewWindow(int industry) |
|
445 |
{ |
|
4171 | 446 |
Window *w = AllocateWindowDescFront(&_industry_view_desc, industry); |
0 | 447 |
|
2989 | 448 |
if (w != NULL) { |
0 | 449 |
w->flags4 |= WF_DISABLE_VP_SCROLL; |
1004 | 450 |
WP(w,vp2_d).data_1 = 0; |
451 |
WP(w,vp2_d).data_2 = 0; |
|
452 |
WP(w,vp2_d).data_3 = 0; |
|
2989 | 453 |
AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetIndustry(w->window_number)->xy + TileDiffXY(1, 1), 1); |
0 | 454 |
} |
455 |
} |
|
456 |
||
457 |
static const Widget _industry_directory_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
458 |
{ WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
459 |
{ WWT_CAPTION, RESIZE_NONE, 13, 11, 495, 0, 13, STR_INDUSTRYDIR_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
460 |
{ WWT_STICKYBOX, RESIZE_NONE, 13, 496, 507, 0, 13, 0x0, STR_STICKY_BUTTON}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
461 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 100, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
462 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 101, 200, 14, 25, STR_SORT_BY_TYPE, STR_SORT_ORDER_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
463 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 201, 300, 14, 25, STR_SORT_BY_PRODUCTION, STR_SORT_ORDER_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
464 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 301, 400, 14, 25, STR_SORT_BY_TRANSPORTED, STR_SORT_ORDER_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
465 |
{ WWT_PANEL, RESIZE_NONE, 13, 401, 495, 14, 25, 0x0, STR_NULL}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
466 |
{ WWT_PANEL, RESIZE_BOTTOM, 13, 0, 495, 26, 189, 0x0, STR_200A_TOWN_NAMES_CLICK_ON_NAME}, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
467 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 13, 496, 507, 14, 177, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
468 |
{ WWT_RESIZEBOX, RESIZE_TB, 13, 496, 507, 178, 189, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
469 |
{ WIDGETS_END}, |
0 | 470 |
}; |
471 |
||
472 |
static uint _num_industry_sort; |
|
473 |
||
474 |
static char _bufcache[96]; |
|
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4211
diff
changeset
|
475 |
static const Industry* _last_industry; |
0 | 476 |
|
477 |
static byte _industry_sort_order; |
|
478 |
||
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
479 |
static int CDECL GeneralIndustrySorter(const void *a, const void *b) |
0 | 480 |
{ |
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4211
diff
changeset
|
481 |
const Industry* i = *(const Industry**)a; |
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4211
diff
changeset
|
482 |
const Industry* j = *(const Industry**)b; |
4282
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
483 |
int r; |
0 | 484 |
|
485 |
switch (_industry_sort_order >> 1) { |
|
4282
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
486 |
default: NOT_REACHED(); |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
487 |
case 0: /* Sort by Name (handled later) */ |
0 | 488 |
r = 0; |
4282
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
489 |
break; |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
490 |
|
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
491 |
case 1: /* Sort by Type */ |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
492 |
r = i->type - j->type; |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
493 |
break; |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
494 |
|
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
495 |
case 2: /* Sort by Production */ |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
496 |
if (i->produced_cargo[0] == CT_INVALID) { |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
497 |
r = (j->produced_cargo[0] == CT_INVALID ? 0 : -1); |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
498 |
} else { |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
499 |
if (j->produced_cargo[0] == CT_INVALID) { |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
500 |
r = 1; |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
501 |
} else { |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
502 |
r = |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
503 |
(i->total_production[0] + i->total_production[1]) - |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
504 |
(j->total_production[0] + j->total_production[1]); |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
505 |
} |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
506 |
} |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
507 |
break; |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
508 |
|
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
509 |
case 3: /* Sort by transported fraction */ |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
510 |
if (i->produced_cargo[0] == CT_INVALID) { |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
511 |
r = (j->produced_cargo[0] == CT_INVALID ? 0 : -1); |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
512 |
} else { |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
513 |
if (j->produced_cargo[0] == CT_INVALID) { |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
514 |
r = 1; |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
515 |
} else { |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
516 |
int pi; |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
517 |
int pj; |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
518 |
|
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
519 |
pi = i->pct_transported[0] * 100 >> 8; |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
520 |
if (i->produced_cargo[1] != CT_INVALID) { |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
521 |
int p = i->pct_transported[1] * 100 >> 8; |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
522 |
if (p < pi) pi = p; |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
523 |
} |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
524 |
|
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
525 |
pj = j->pct_transported[0] * 100 >> 8; |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
526 |
if (j->produced_cargo[1] != CT_INVALID) { |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
527 |
int p = j->pct_transported[1] * 100 >> 8; |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
528 |
if (p < pj) pj = p; |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
529 |
} |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
530 |
|
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
531 |
r = pi - pj; |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
532 |
} |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
533 |
} |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
534 |
break; |
0 | 535 |
} |
536 |
||
537 |
// default to string sorting if they are otherwise equal |
|
538 |
if (r == 0) { |
|
4282
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
539 |
char buf1[96]; |
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
540 |
|
2070
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
541 |
SetDParam(0, i->town->index); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4896
diff
changeset
|
542 |
GetString(buf1, STR_TOWN, lastof(buf1)); |
0 | 543 |
|
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4211
diff
changeset
|
544 |
if (j != _last_industry) { |
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4211
diff
changeset
|
545 |
_last_industry = j; |
2070
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
546 |
SetDParam(0, j->town->index); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4896
diff
changeset
|
547 |
GetString(_bufcache, STR_TOWN, lastof(_bufcache)); |
0 | 548 |
} |
549 |
r = strcmp(buf1, _bufcache); |
|
550 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
551 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
552 |
if (_industry_sort_order & 1) r = -r; |
0 | 553 |
return r; |
554 |
} |
|
555 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1019
diff
changeset
|
556 |
static void MakeSortedIndustryList(void) |
0 | 557 |
{ |
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4211
diff
changeset
|
558 |
const Industry* i; |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
559 |
int n = 0; |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
560 |
|
4617
9711576cf148
(svn r6475) - Fix (r6055): Don't try to sort industries when there are none. Thanks to 'Delboy'
peter1138
parents:
4354
diff
changeset
|
561 |
/* Don't attempt a sort if there are no industries */ |
5247
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5070
diff
changeset
|
562 |
if (GetNumIndustries() == 0) return; |
4617
9711576cf148
(svn r6475) - Fix (r6055): Don't try to sort industries when there are none. Thanks to 'Delboy'
peter1138
parents:
4354
diff
changeset
|
563 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
564 |
/* Create array for sorting */ |
5247
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5070
diff
changeset
|
565 |
_industry_sort = realloc((void *)_industry_sort, (GetMaxIndustryIndex() + 1) * sizeof(_industry_sort[0])); |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5247
diff
changeset
|
566 |
if (_industry_sort == NULL) error("Could not allocate memory for the industry-sorting-list"); |
0 | 567 |
|
4346
3f00094f2670
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
568 |
FOR_ALL_INDUSTRIES(i) _industry_sort[n++] = i; |
3f00094f2670
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
569 |
|
0 | 570 |
_num_industry_sort = n; |
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4211
diff
changeset
|
571 |
_last_industry = NULL; // used for "cache" |
0 | 572 |
|
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4211
diff
changeset
|
573 |
qsort((void*)_industry_sort, n, sizeof(_industry_sort[0]), GeneralIndustrySorter); |
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
0
diff
changeset
|
574 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5247
diff
changeset
|
575 |
DEBUG(misc, 3, "Resorting industries list"); |
0 | 576 |
} |
577 |
||
578 |
||
579 |
static void IndustryDirectoryWndProc(Window *w, WindowEvent *e) |
|
580 |
{ |
|
2951 | 581 |
switch (e->event) { |
0 | 582 |
case WE_PAINT: { |
583 |
int n; |
|
584 |
uint p; |
|
585 |
static const uint16 _indicator_positions[4] = {88, 187, 284, 387}; |
|
586 |
||
587 |
if (_industry_sort_dirty) { |
|
588 |
_industry_sort_dirty = false; |
|
589 |
MakeSortedIndustryList(); |
|
590 |
} |
|
591 |
||
1666
b36927825adb
(svn r2170) -fix: [1179457] the industry list can now no longer scroll down then the end of the list is reached (Hackykid)
bjarni
parents:
1388
diff
changeset
|
592 |
SetVScrollCount(w, _num_industry_sort); |
0 | 593 |
|
594 |
DrawWindowWidgets(w); |
|
2406
be5cfb8cd20d
(svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents:
2186
diff
changeset
|
595 |
DoDrawString(_industry_sort_order & 1 ? DOWNARROW : UPARROW, _indicator_positions[_industry_sort_order>>1], 15, 0x10); |
0 | 596 |
|
597 |
p = w->vscroll.pos; |
|
598 |
n = 0; |
|
599 |
||
600 |
while (p < _num_industry_sort) { |
|
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4211
diff
changeset
|
601 |
const Industry* i = _industry_sort[p]; |
2989 | 602 |
|
2070
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
603 |
SetDParam(0, i->index); |
2469
1bfbb0dc0b75
(svn r2995) Replace 0xFF/0xFFFF with CT_INVALID/OWNER_SPECTATOR/INVALID_STATION where appropriate
tron
parents:
2406
diff
changeset
|
604 |
if (i->produced_cargo[0] != CT_INVALID) { |
4896
72d7a8614580
(svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
peter1138
parents:
4848
diff
changeset
|
605 |
SetDParam(1, i->produced_cargo[0]); |
2070
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
606 |
SetDParam(2, i->total_production[0]); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
607 |
|
2469
1bfbb0dc0b75
(svn r2995) Replace 0xFF/0xFFFF with CT_INVALID/OWNER_SPECTATOR/INVALID_STATION where appropriate
tron
parents:
2406
diff
changeset
|
608 |
if (i->produced_cargo[1] != CT_INVALID) { |
4896
72d7a8614580
(svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
peter1138
parents:
4848
diff
changeset
|
609 |
SetDParam(3, i->produced_cargo[1]); |
2070
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
610 |
SetDParam(4, i->total_production[1]); |
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
611 |
SetDParam(5, i->pct_transported[0] * 100 >> 8); |
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
612 |
SetDParam(6, i->pct_transported[1] * 100 >> 8); |
0 | 613 |
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM_TWO, 0); |
614 |
} else { |
|
2070
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
615 |
SetDParam(3, i->pct_transported[0] * 100 >> 8); |
0 | 616 |
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM, 0); |
617 |
} |
|
618 |
} else { |
|
619 |
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM_NOPROD, 0); |
|
620 |
} |
|
621 |
p++; |
|
2951 | 622 |
if (++n == w->vscroll.cap) break; |
0 | 623 |
} |
624 |
} break; |
|
625 |
||
626 |
case WE_CLICK: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
627 |
switch (e->we.click.widget) { |
758
bd9e868b9fae
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
727
diff
changeset
|
628 |
case 3: { |
0 | 629 |
_industry_sort_order = _industry_sort_order==0 ? 1 : 0; |
630 |
_industry_sort_dirty = true; |
|
631 |
SetWindowDirty(w); |
|
632 |
} break; |
|
633 |
||
758
bd9e868b9fae
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
727
diff
changeset
|
634 |
case 4: { |
0 | 635 |
_industry_sort_order = _industry_sort_order==2 ? 3 : 2; |
636 |
_industry_sort_dirty = true; |
|
637 |
SetWindowDirty(w); |
|
638 |
} break; |
|
639 |
||
758
bd9e868b9fae
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
727
diff
changeset
|
640 |
case 5: { |
0 | 641 |
_industry_sort_order = _industry_sort_order==4 ? 5 : 4; |
642 |
_industry_sort_dirty = true; |
|
643 |
SetWindowDirty(w); |
|
644 |
} break; |
|
645 |
||
758
bd9e868b9fae
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
727
diff
changeset
|
646 |
case 6: { |
0 | 647 |
_industry_sort_order = _industry_sort_order==6 ? 7 : 6; |
648 |
_industry_sort_dirty = true; |
|
649 |
SetWindowDirty(w); |
|
650 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
651 |
|
758
bd9e868b9fae
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
727
diff
changeset
|
652 |
case 8: { |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
653 |
int y = (e->we.click.pt.y - 28) / 10; |
821
4af53631a47a
(svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
truelight
parents:
758
diff
changeset
|
654 |
uint16 p; |
0 | 655 |
|
2989 | 656 |
if (!IS_INT_INSIDE(y, 0, w->vscroll.cap)) return; |
0 | 657 |
p = y + w->vscroll.pos; |
658 |
if (p < _num_industry_sort) { |
|
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4211
diff
changeset
|
659 |
ScrollMainWindowToTile(_industry_sort[p]->xy); |
0 | 660 |
} |
661 |
} break; |
|
662 |
} |
|
663 |
break; |
|
664 |
||
665 |
case WE_4: |
|
666 |
SetWindowDirty(w); |
|
667 |
break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
668 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
669 |
case WE_RESIZE: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
670 |
w->vscroll.cap += e->we.sizing.diff.y / 10; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
671 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
672 |
} |
0 | 673 |
} |
674 |
||
675 |
||
676 |
/* Industry List */ |
|
677 |
static const WindowDesc _industry_directory_desc = { |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
678 |
WDP_AUTO, WDP_AUTO, 508, 190, |
0 | 679 |
WC_INDUSTRY_DIRECTORY,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
680 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 681 |
_industry_directory_widgets, |
682 |
IndustryDirectoryWndProc |
|
683 |
}; |
|
684 |
||
685 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1019
diff
changeset
|
686 |
void ShowIndustryDirectory(void) |
0 | 687 |
{ |
4171 | 688 |
Window *w = AllocateWindowDescFront(&_industry_directory_desc, 0); |
0 | 689 |
|
2989 | 690 |
if (w != NULL) { |
0 | 691 |
w->vscroll.cap = 16; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
692 |
w->resize.height = w->height - 6 * 10; // minimum 10 items |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
693 |
w->resize.step_height = 10; |
0 | 694 |
SetWindowDirty(w); |
695 |
} |
|
696 |
} |