author | tron |
Thu, 02 Dec 2004 22:53:07 +0000 | |
changeset 534 | 17ab2f22ff74 |
parent 507 | 8aa8100b0b22 |
child 679 | e959706a3e4d |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
222
diff
changeset
|
3 |
#include "table/strings.h" |
0 | 4 |
//#include "gui.h" |
5 |
#include "window.h" |
|
6 |
#include "gfx.h" |
|
7 |
#include "command.h" |
|
8 |
#include "viewport.h" |
|
9 |
#include "industry.h" |
|
10 |
#include "town.h" |
|
11 |
||
12 |
static const byte _build_industry_types[4][12] = { |
|
13 |
{ 1, 2, 4, 6, 8, 0, 3, 5, 9, 11, 18 }, |
|
14 |
{ 1, 14, 4, 13, 7, 0, 3, 9, 11, 15 }, |
|
15 |
{ 25, 13, 4, 23, 22, 11, 17, 10, 24, 19, 20, 21 }, |
|
16 |
{ 27, 30, 31, 33, 26, 28, 29, 32, 34, 35, 36 }, |
|
17 |
}; |
|
18 |
||
19 |
extern const byte _industry_type_costs[37]; |
|
20 |
||
21 |
static void BuildIndustryWndProc(Window *w, WindowEvent *e) |
|
22 |
{ |
|
23 |
switch(e->event) { |
|
24 |
case WE_PAINT: |
|
25 |
DrawWindowWidgets(w); |
|
26 |
if (_thd.place_mode == 1 && _thd.window_class == WC_BUILD_INDUSTRY) { |
|
27 |
int ind_type = _build_industry_types[_opt.landscape][WP(w,def_d).data_1]; |
|
28 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
29 |
SetDParam(0, (_price.build_industry >> 5) * _industry_type_costs[ind_type]); |
0 | 30 |
DrawStringCentered(85, w->height - 21, STR_482F_COST, 0); |
31 |
} |
|
32 |
break; |
|
33 |
||
34 |
case WE_CLICK: { |
|
35 |
int wid = e->click.widget; |
|
36 |
if (wid >= 3) { |
|
37 |
if (HandlePlacePushButton(w, wid, 0xFF1, 1, NULL)) |
|
38 |
WP(w,def_d).data_1 = wid - 3; |
|
39 |
} |
|
40 |
} break; |
|
41 |
||
42 |
case WE_PLACE_OBJ: |
|
43 |
if (DoCommandP(e->place.tile, _build_industry_types[_opt.landscape][WP(w,def_d).data_1], 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY))) |
|
44 |
ResetObjectToPlace(); |
|
45 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
46 |
|
0 | 47 |
case WE_ABORT_PLACE_OBJ: |
48 |
w->click_state = 0; |
|
49 |
SetWindowDirty(w); |
|
50 |
break; |
|
51 |
} |
|
52 |
} |
|
53 |
||
54 |
static const Widget _build_industry_land0_widgets[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
55 |
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
56 |
{ WWT_CAPTION, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
57 |
{ WWT_PANEL, 7, 0, 169, 14, 115, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
58 |
{ WWT_CLOSEBOX, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
59 |
{ WWT_CLOSEBOX, 14, 2, 167, 29, 40, STR_0242_SAWMILL, STR_0264_CONSTRUCT_SAWMILL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
60 |
{ WWT_CLOSEBOX, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
61 |
{ WWT_CLOSEBOX, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
62 |
{ WWT_CLOSEBOX, 14, 2, 167, 68, 79, STR_0247_STEEL_MILL, STR_0269_CONSTRUCT_STEEL_MILL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
63 |
{ WIDGETS_END}, |
0 | 64 |
}; |
65 |
||
66 |
static const Widget _build_industry_land1_widgets[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
67 |
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
68 |
{ WWT_CAPTION, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
69 |
{ WWT_PANEL, 7, 0, 169, 14, 115, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
70 |
{ WWT_CLOSEBOX, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
71 |
{ WWT_CLOSEBOX, 14, 2, 167, 29, 40, STR_024C_PAPER_MILL, STR_026E_CONSTRUCT_PAPER_MILL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
72 |
{ WWT_CLOSEBOX, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
0 | 73 |
{ WWT_CLOSEBOX, 14, 2, 167, 55, 66, STR_024D_FOOD_PROCESSING_PLANT,STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
74 |
{ WWT_CLOSEBOX, 14, 2, 167, 68, 79, STR_024E_PRINTING_WORKS, STR_0270_CONSTRUCT_PRINTING_WORKS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
75 |
{ WIDGETS_END}, |
0 | 76 |
}; |
77 |
||
78 |
static const Widget _build_industry_land2_widgets[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
79 |
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
80 |
{ WWT_CAPTION, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
81 |
{ WWT_PANEL, 7, 0, 169, 14, 115, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
82 |
{ WWT_CLOSEBOX, 14, 2, 167, 16, 27, STR_0250_LUMBER_MILL, STR_0273_CONSTRUCT_LUMBER_MILL_TO}, |
0 | 83 |
{ WWT_CLOSEBOX, 14, 2, 167, 29, 40, STR_024D_FOOD_PROCESSING_PLANT,STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
84 |
{ WWT_CLOSEBOX, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
85 |
{ WWT_CLOSEBOX, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
86 |
{ WWT_CLOSEBOX, 14, 2, 167, 68, 79, STR_0254_WATER_TOWER, STR_0277_CONSTRUCT_WATER_TOWER_CAN}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
87 |
{ WIDGETS_END}, |
0 | 88 |
}; |
89 |
||
90 |
static const Widget _build_industry_land3_widgets[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
91 |
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
92 |
{ WWT_CAPTION, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
93 |
{ WWT_PANEL, 7, 0, 169, 14, 115, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
94 |
{ WWT_CLOSEBOX, 14, 2, 167, 16, 27, STR_0258_CANDY_FACTORY, STR_027B_CONSTRUCT_CANDY_FACTORY}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
95 |
{ WWT_CLOSEBOX, 14, 2, 167, 29, 40, STR_025B_TOY_SHOP, STR_027E_CONSTRUCT_TOY_SHOP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
96 |
{ WWT_CLOSEBOX, 14, 2, 167, 42, 53, STR_025C_TOY_FACTORY, STR_027F_CONSTRUCT_TOY_FACTORY}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
97 |
{ WWT_CLOSEBOX, 14, 2, 167, 55, 66, STR_025E_FIZZY_DRINK_FACTORY, STR_0281_CONSTRUCT_FIZZY_DRINK_FACTORY}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
98 |
{ WIDGETS_END}, |
0 | 99 |
}; |
100 |
||
101 |
static const Widget _build_industry_land0_widgets_extra[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
102 |
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
0 | 103 |
{ WWT_CAPTION, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY,STR_018C_WINDOW_TITLE_DRAG_THIS}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
104 |
{ WWT_PANEL, 7, 0, 169, 14, 187, 0x0, STR_NULL}, |
0 | 105 |
|
106 |
{ WWT_CLOSEBOX, 14, 2, 167, 16, 27, STR_0241_POWER_STATION,STR_0263_CONSTRUCT_POWER_STATION}, |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
107 |
{ WWT_CLOSEBOX, 14, 2, 167, 29, 40, STR_0242_SAWMILL, STR_0264_CONSTRUCT_SAWMILL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
108 |
{ WWT_CLOSEBOX, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
109 |
{ WWT_CLOSEBOX, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
110 |
{ WWT_CLOSEBOX, 14, 2, 167, 68, 79, STR_0247_STEEL_MILL, STR_0269_CONSTRUCT_STEEL_MILL}, |
0 | 111 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
112 |
{ WWT_CLOSEBOX, 14, 2, 167, 84, 95, STR_0240_COAL_MINE, STR_CONSTRUCT_COAL_MINE_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
113 |
{ WWT_CLOSEBOX, 14, 2, 167, 97, 108, STR_0243_FOREST, STR_CONSTRUCT_FOREST_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
114 |
{ WWT_CLOSEBOX, 14, 2, 167, 110, 121, STR_0245_OIL_RIG, STR_CONSTRUCT_OIL_RIG_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
115 |
{ WWT_CLOSEBOX, 14, 2, 167, 123, 134, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
116 |
{ WWT_CLOSEBOX, 14, 2, 167, 136, 147, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
117 |
{ WWT_CLOSEBOX, 14, 2, 167, 149, 160, STR_0249_IRON_ORE_MINE, STR_CONSTRUCT_IRON_ORE_MINE_TIP}, |
0 | 118 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
119 |
{ WIDGETS_END}, |
0 | 120 |
}; |
121 |
||
122 |
static const Widget _build_industry_land1_widgets_extra[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
123 |
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
124 |
{ WWT_CAPTION, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
125 |
{ WWT_PANEL, 7, 0, 169, 14, 174, 0x0, STR_NULL}, |
0 | 126 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
127 |
{ WWT_CLOSEBOX, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
128 |
{ WWT_CLOSEBOX, 14, 2, 167, 29, 40, STR_024C_PAPER_MILL, STR_026E_CONSTRUCT_PAPER_MILL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
129 |
{ WWT_CLOSEBOX, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
0 | 130 |
{ WWT_CLOSEBOX, 14, 2, 167, 55, 66, STR_024D_FOOD_PROCESSING_PLANT,STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
131 |
{ WWT_CLOSEBOX, 14, 2, 167, 68, 79, STR_024E_PRINTING_WORKS, STR_0270_CONSTRUCT_PRINTING_WORKS}, |
0 | 132 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
133 |
{ WWT_CLOSEBOX, 14, 2, 167, 81+3, 92+3, STR_0240_COAL_MINE, STR_CONSTRUCT_COAL_MINE_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
134 |
{ WWT_CLOSEBOX, 14, 2, 167, 94+3, 105+3, STR_0243_FOREST, STR_CONSTRUCT_FOREST_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
135 |
{ WWT_CLOSEBOX, 14, 2, 167, 107+3, 118+3, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
136 |
{ WWT_CLOSEBOX, 14, 2, 167, 120+3, 131+3, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
137 |
{ WWT_CLOSEBOX, 14, 2, 167, 133+3, 144+3, STR_024F_GOLD_MINE, STR_CONSTRUCT_GOLD_MINE_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
138 |
{ WIDGETS_END}, |
0 | 139 |
}; |
140 |
||
141 |
static const Widget _build_industry_land2_widgets_extra[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
142 |
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
143 |
{ WWT_CAPTION, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
144 |
{ WWT_PANEL, 7, 0, 169, 14, 200, 0x0, STR_NULL}, |
0 | 145 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
146 |
{ WWT_CLOSEBOX, 14, 2, 167, 16, 27, STR_0250_LUMBER_MILL, STR_0273_CONSTRUCT_LUMBER_MILL_TO}, |
0 | 147 |
{ WWT_CLOSEBOX, 14, 2, 167, 29, 40, STR_024D_FOOD_PROCESSING_PLANT,STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
148 |
{ WWT_CLOSEBOX, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
149 |
{ WWT_CLOSEBOX, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
150 |
{ WWT_CLOSEBOX, 14, 2, 167, 68, 79, STR_0254_WATER_TOWER, STR_0277_CONSTRUCT_WATER_TOWER_CAN}, |
0 | 151 |
|
152 |
{ WWT_CLOSEBOX, 14, 2, 167, 81+3, 92+3, STR_024A_OIL_WELLS,STR_CONSTRUCT_OIL_WELLS_TIP}, |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
153 |
{ WWT_CLOSEBOX, 14, 2, 167, 94+3, 105+3, STR_0255_DIAMOND_MINE, STR_CONSTRUCT_DIAMOND_MINE_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
154 |
{ WWT_CLOSEBOX, 14, 2, 167, 107+3, 118+3, STR_0256_COPPER_ORE_MINE, STR_CONSTRUCT_COPPER_ORE_MINE_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
155 |
{ WWT_CLOSEBOX, 14, 2, 167, 120+3, 131+3, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
156 |
{ WWT_CLOSEBOX, 14, 2, 167, 133+3, 144+3, STR_0251_FRUIT_PLANTATION, STR_CONSTRUCT_FRUIT_PLANTATION_TIP}, |
0 | 157 |
{ WWT_CLOSEBOX, 14, 2, 167, 146+3, 157+3, STR_0252_RUBBER_PLANTATION,STR_CONSTRUCT_RUBBER_PLANTATION_TIP}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
158 |
{ WWT_CLOSEBOX, 14, 2, 167, 159+3, 170+3, STR_0253_WATER_SUPPLY, STR_CONSTRUCT_WATER_SUPPLY_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
159 |
{ WIDGETS_END}, |
0 | 160 |
}; |
161 |
||
162 |
static const Widget _build_industry_land3_widgets_extra[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
163 |
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
164 |
{ WWT_CAPTION, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
165 |
{ WWT_PANEL, 7, 0, 169, 14, 187, 0x0, STR_NULL}, |
0 | 166 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
167 |
{ WWT_CLOSEBOX, 14, 2, 167, 16, 27, STR_0258_CANDY_FACTORY, STR_027B_CONSTRUCT_CANDY_FACTORY}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
168 |
{ WWT_CLOSEBOX, 14, 2, 167, 29, 40, STR_025B_TOY_SHOP, STR_027E_CONSTRUCT_TOY_SHOP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
169 |
{ WWT_CLOSEBOX, 14, 2, 167, 42, 53, STR_025C_TOY_FACTORY, STR_027F_CONSTRUCT_TOY_FACTORY}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
170 |
{ WWT_CLOSEBOX, 14, 2, 167, 55, 66, STR_025E_FIZZY_DRINK_FACTORY, STR_0281_CONSTRUCT_FIZZY_DRINK_FACTORY}, |
0 | 171 |
|
172 |
{ WWT_CLOSEBOX, 14, 2, 167, 68+3, 79+3, STR_0257_COTTON_CANDY_FOREST,STR_CONSTRUCT_COTTON_CANDY_TIP}, |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
173 |
{ WWT_CLOSEBOX, 14, 2, 167, 81+3, 92+3, STR_0259_BATTERY_FARM, STR_CONSTRUCT_BATTERY_FARM_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
174 |
{ WWT_CLOSEBOX, 14, 2, 167, 94+3, 105+3, STR_025A_COLA_WELLS, STR_CONSTRUCT_COLA_WELLS_TIP}, |
0 | 175 |
{ WWT_CLOSEBOX, 14, 2, 167, 107+3, 118+3, STR_025D_PLASTIC_FOUNTAINS,STR_CONSTRUCT_PLASTIC_FOUNTAINS_TIP}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
176 |
{ WWT_CLOSEBOX, 14, 2, 167, 120+3, 131+3, STR_025F_BUBBLE_GENERATOR, STR_CONSTRUCT_BUBBLE_GENERATOR_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
177 |
{ WWT_CLOSEBOX, 14, 2, 167, 133+3, 144+3, STR_0260_TOFFEE_QUARRY, STR_CONSTRUCT_TOFFEE_QUARRY_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
178 |
{ WWT_CLOSEBOX, 14, 2, 167, 146+3, 157+3, STR_0261_SUGAR_MINE, STR_CONSTRUCT_SUGAR_MINE_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
179 |
{ WIDGETS_END}, |
0 | 180 |
}; |
181 |
||
182 |
||
183 |
static const WindowDesc _build_industry_land0_desc = { |
|
184 |
-1, -1, 170, 116, |
|
185 |
WC_BUILD_INDUSTRY,0, |
|
186 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
187 |
_build_industry_land0_widgets, |
|
188 |
BuildIndustryWndProc |
|
189 |
}; |
|
190 |
||
191 |
static const WindowDesc _build_industry_land1_desc = { |
|
192 |
-1, -1, 170, 116, |
|
193 |
WC_BUILD_INDUSTRY,0, |
|
194 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
195 |
_build_industry_land1_widgets, |
|
196 |
BuildIndustryWndProc |
|
197 |
}; |
|
198 |
||
199 |
static const WindowDesc _build_industry_land2_desc = { |
|
200 |
-1, -1, 170, 116, |
|
201 |
WC_BUILD_INDUSTRY,0, |
|
202 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
203 |
_build_industry_land2_widgets, |
|
204 |
BuildIndustryWndProc |
|
205 |
}; |
|
206 |
||
207 |
static const WindowDesc _build_industry_land3_desc = { |
|
208 |
-1, -1, 170, 116, |
|
209 |
WC_BUILD_INDUSTRY,0, |
|
210 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
211 |
_build_industry_land3_widgets, |
|
212 |
BuildIndustryWndProc |
|
213 |
}; |
|
214 |
||
215 |
static const WindowDesc _build_industry_land0_desc_extra = { |
|
216 |
-1, -1, 170, 188, |
|
217 |
WC_BUILD_INDUSTRY,0, |
|
218 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
219 |
_build_industry_land0_widgets_extra, |
|
220 |
BuildIndustryWndProc |
|
221 |
}; |
|
222 |
||
223 |
static const WindowDesc _build_industry_land1_desc_extra = { |
|
224 |
-1, -1, 170, 175, |
|
225 |
WC_BUILD_INDUSTRY,0, |
|
226 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
227 |
_build_industry_land1_widgets_extra, |
|
228 |
BuildIndustryWndProc |
|
229 |
}; |
|
230 |
||
231 |
static const WindowDesc _build_industry_land2_desc_extra = { |
|
232 |
-1, -1, 170, 201, |
|
233 |
WC_BUILD_INDUSTRY,0, |
|
234 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
235 |
_build_industry_land2_widgets_extra, |
|
236 |
BuildIndustryWndProc |
|
237 |
}; |
|
238 |
||
239 |
static const WindowDesc _build_industry_land3_desc_extra = { |
|
240 |
-1, -1, 170, 188, |
|
241 |
WC_BUILD_INDUSTRY,0, |
|
242 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
243 |
_build_industry_land3_widgets_extra, |
|
244 |
BuildIndustryWndProc |
|
245 |
}; |
|
246 |
||
247 |
static const WindowDesc * const _industry_window_desc[2][4] = { |
|
248 |
{ |
|
249 |
&_build_industry_land0_desc, |
|
250 |
&_build_industry_land1_desc, |
|
251 |
&_build_industry_land2_desc, |
|
252 |
&_build_industry_land3_desc, |
|
253 |
}, |
|
254 |
{ |
|
255 |
&_build_industry_land0_desc_extra, |
|
256 |
&_build_industry_land1_desc_extra, |
|
257 |
&_build_industry_land2_desc_extra, |
|
258 |
&_build_industry_land3_desc_extra, |
|
259 |
}, |
|
260 |
}; |
|
261 |
||
262 |
void ShowBuildIndustryWindow() |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
263 |
{ |
0 | 264 |
AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt.landscape],0); |
265 |
} |
|
266 |
||
267 |
static void IndustryViewWndProc(Window *w, WindowEvent *e) |
|
268 |
{ |
|
269 |
Industry *i; |
|
270 |
StringID str; |
|
271 |
||
272 |
switch(e->event) { |
|
273 |
case WE_PAINT: |
|
274 |
// in editor, use bulldoze to destroy industry |
|
275 |
// Destroy Industry button costing money removed per request of dominik |
|
276 |
//w->disabled_state = (_patches.extra_dynamite && !_networking && _game_mode != GM_EDITOR) ? 0 : (1 << 6); |
|
277 |
i = DEREF_INDUSTRY(w->window_number); |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
278 |
SetDParam(0, i->town->index); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
279 |
SetDParam(1, i->type + STR_4802_COAL_MINE); |
0 | 280 |
DrawWindowWidgets(w); |
281 |
||
282 |
if (i->accepts_cargo[0] != 0xFF) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
283 |
SetDParam(0, _cargoc.names_s[i->accepts_cargo[0]]); |
0 | 284 |
str = STR_4827_REQUIRES; |
285 |
if (i->accepts_cargo[1] != 0xFF) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
286 |
SetDParam(1, _cargoc.names_s[i->accepts_cargo[1]]); |
0 | 287 |
str++; |
288 |
if (i->accepts_cargo[2] != 0xFF) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
289 |
SetDParam(2, _cargoc.names_s[i->accepts_cargo[2]]); |
0 | 290 |
str++; |
291 |
} |
|
292 |
} |
|
293 |
DrawString(2, 107, str, 0); |
|
294 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
295 |
|
0 | 296 |
if (i->produced_cargo[0] != 0xFF) { |
297 |
DrawString(2, 117, STR_482A_PRODUCTION_LAST_MONTH, 0); |
|
298 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
299 |
SetDParam(1, i->total_production[0]); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
300 |
SetDParam(0, _cargoc.names_long_s[i->produced_cargo[0]] + ((i->total_production[0]!=1)<<5)); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
301 |
SetDParam(2, i->pct_transported[0] * 100 >> 8); |
0 | 302 |
DrawString(4, 127, STR_482B_TRANSPORTED, 0); |
303 |
||
304 |
if (i->produced_cargo[1] != 0xFF) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
305 |
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
|
306 |
SetDParam(0, _cargoc.names_long_s[i->produced_cargo[1]] + ((i->total_production[1]!=1)<<5)); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
307 |
SetDParam(2, i->pct_transported[1] * 100 >> 8); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
308 |
DrawString(4, 137, STR_482B_TRANSPORTED, 0); |
0 | 309 |
} |
310 |
} |
|
311 |
||
312 |
DrawWindowViewport(w); |
|
313 |
break; |
|
314 |
||
315 |
case WE_CLICK: |
|
316 |
switch(e->click.widget) { |
|
317 |
case 5: |
|
318 |
i = DEREF_INDUSTRY(w->window_number); |
|
319 |
ScrollMainWindowToTile(i->xy + TILE_XY(1,1)); |
|
320 |
break; |
|
321 |
case 6: |
|
322 |
// Destroy Industry button costing money removed per request of dominik |
|
323 |
//i = DEREF_INDUSTRY(w->window_number); |
|
324 |
/* passing only i->xy is not safe if industry has a weird shape like: |
|
325 |
_ X X |
|
326 |
X X X |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
327 |
_ <--- grass, no industry, but i->xy points there (first top-left tile)!, |
0 | 328 |
so passing i->xy to destroy industry will fail in called procedure |
329 |
*/ |
|
330 |
//DoCommandP(i->xy, w->window_number, 0, CcPlaySound10, CMD_DESTROY_INDUSTRY | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); |
|
331 |
break; |
|
332 |
} |
|
333 |
break; |
|
334 |
} |
|
335 |
} |
|
336 |
||
337 |
static const Widget _industry_view_widgets[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
338 |
{ WWT_TEXTBTN, 9, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
339 |
{ WWT_CAPTION, 9, 11, 259, 0, 13, STR_4801, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
340 |
{ WWT_IMGBTN, 9, 0, 259, 14, 105, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
341 |
{ WWT_6, 9, 2, 257, 16, 103, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
342 |
{ WWT_IMGBTN, 9, 0, 259, 106, 147, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
343 |
{ WWT_PUSHTXTBTN, 9, 0, 129, 148, 159, STR_00E4_LOCATION, STR_482C_CENTER_THE_MAIN_VIEW_ON}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
344 |
{ WWT_IMGBTN, 9, 130, 259, 148, 159, 0x0, STR_NULL}, |
0 | 345 |
// Destroy Industry button costing money removed per request of dominik |
346 |
//{ WWT_PUSHTXTBTN, 9, 130, 259, 148, 159, STR_INDUSTRYDIR_DESTROY, STR_482C_DESTROY_INDUSTRY}, |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
347 |
{ WIDGETS_END}, |
0 | 348 |
}; |
349 |
||
350 |
static const WindowDesc _industry_view_desc = { |
|
351 |
-1, -1, 260, 160, |
|
352 |
WC_INDUSTRY_VIEW,0, |
|
353 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
354 |
_industry_view_widgets, |
|
355 |
IndustryViewWndProc |
|
356 |
}; |
|
357 |
||
358 |
void ShowIndustryViewWindow(int industry) |
|
359 |
{ |
|
360 |
Window *w; |
|
361 |
Industry *i; |
|
362 |
||
363 |
w = AllocateWindowDescFront(&_industry_view_desc, industry); |
|
364 |
if (w) { |
|
365 |
w->flags4 |= WF_DISABLE_VP_SCROLL; |
|
366 |
i = DEREF_INDUSTRY(w->window_number); |
|
367 |
AssignWindowViewport(w, 3, 17, 0xFE, 0x56, i->xy + TILE_XY(1,1), 1); |
|
368 |
} |
|
369 |
} |
|
370 |
||
371 |
static const Widget _industry_directory_widgets[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
372 |
{ WWT_TEXTBTN, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
373 |
{ WWT_CAPTION, 13, 11, 507, 0, 13, STR_INDUSTRYDIR_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
374 |
{ WWT_PUSHTXTBTN, 13, 0, 100, 14, 25, STR_SORT_BY_NAME, STR_SORT_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
375 |
{ WWT_PUSHTXTBTN, 13, 101, 200, 14, 25, STR_SORT_BY_TYPE, STR_SORT_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
376 |
{ WWT_PUSHTXTBTN, 13, 201, 300, 14, 25, STR_SORT_BY_PRODUCTION, STR_SORT_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
377 |
{ WWT_PUSHTXTBTN, 13, 301, 400, 14, 25, STR_SORT_BY_TRANSPORTED, STR_SORT_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
378 |
{ WWT_PANEL, 13, 401, 496, 14, 25, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
379 |
{ WWT_IMGBTN, 13, 0, 496, 26, 189, 0x0, STR_200A_TOWN_NAMES_CLICK_ON_NAME}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
380 |
{ WWT_SCROLLBAR, 13, 497, 507, 14, 189, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
381 |
{ WIDGETS_END}, |
0 | 382 |
}; |
383 |
||
384 |
static byte _industry_sort[lengthof(_industries)]; |
|
385 |
static uint _num_industry_sort; |
|
386 |
||
387 |
static char _bufcache[96]; |
|
388 |
static byte _last_industry_idx; |
|
389 |
||
390 |
static byte _industry_sort_order; |
|
391 |
||
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
|
392 |
static int CDECL GeneralIndustrySorter(const void *a, const void *b) |
0 | 393 |
{ |
394 |
char buf1[96]; |
|
395 |
byte val; |
|
222
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
197
diff
changeset
|
396 |
Industry *i = DEREF_INDUSTRY(*(const byte*)a); |
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
197
diff
changeset
|
397 |
Industry *j = DEREF_INDUSTRY(*(const byte*)b); |
0 | 398 |
int r = 0; |
399 |
||
400 |
switch (_industry_sort_order >> 1) { |
|
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
|
401 |
/* case 0: Sort by Name (handled later) */ |
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
|
402 |
case 1: /* Sort by Type */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
403 |
r = i->type - j->type; |
0 | 404 |
break; |
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
|
405 |
// FIXME - Production & Transported sort need to be inversed...but, WTF it does not wanna! |
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
|
406 |
// FIXME - And no simple --> "if (!(_industry_sort_order & 1)) r = -r;" hack at the bottom!! |
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
|
407 |
case 2: { /* Sort by Production */ |
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
|
408 |
if (i->produced_cargo[0] != 0xFF && j->produced_cargo[0] != 0xFF) { // both industries produce cargo? |
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
|
409 |
if (i->produced_cargo[1] == 0xFF) // producing one or two things? |
0 | 410 |
r = j->total_production[0] - i->total_production[0]; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
411 |
else |
0 | 412 |
r = (j->total_production[0] + j->total_production[1]) / 2 - (i->total_production[0] + i->total_production[1]) / 2; |
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
|
413 |
} else if (i->produced_cargo[0] == 0xFF && j->produced_cargo[0] == 0xFF) // none of them producing anything, let them go to the name-sorting |
0 | 414 |
r = 0; |
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
|
415 |
else if (i->produced_cargo[0] == 0xFF) // end up the non-producer industry first/last in list |
0 | 416 |
r = 1; |
417 |
else |
|
418 |
r = -1; |
|
419 |
break; |
|
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
|
420 |
} |
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
|
421 |
case 3: /* Sort by Transported amount */ |
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
|
422 |
if (i->produced_cargo[0] != 0xFF && j->produced_cargo[0] != 0xFF) { // both industries produce cargo? |
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
|
423 |
if (i->produced_cargo[1] == 0xFF) // producing one or two things? |
0 | 424 |
r = (j->pct_transported[0] * 100 >> 8) - (i->pct_transported[0] * 100 >> 8); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
425 |
else |
0 | 426 |
r = ((j->pct_transported[0] * 100 >> 8) + (j->pct_transported[1] * 100 >> 8)) / 2 - ((i->pct_transported[0] * 100 >> 8) + (i->pct_transported[1] * 100 >> 8)) / 2; |
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
|
427 |
} else if (i->produced_cargo[0] == 0xFF && j->produced_cargo[0] == 0xFF) // none of them producing anything, let them go to the name-sorting |
0 | 428 |
r = 0; |
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
|
429 |
else if (i->produced_cargo[0] == 0xFF) // end up the non-producer industry first/last in list |
0 | 430 |
r = 1; |
431 |
else |
|
432 |
r = -1; |
|
433 |
break; |
|
434 |
} |
|
435 |
||
436 |
// default to string sorting if they are otherwise equal |
|
437 |
if (r == 0) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
438 |
SetDParam(0, i->town->townnameparts); |
0 | 439 |
GetString(buf1, i->town->townnametype); |
440 |
||
222
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
197
diff
changeset
|
441 |
if ( (val=*(const byte*)b) != _last_industry_idx) { |
0 | 442 |
_last_industry_idx = val; |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
443 |
SetDParam(0, j->town->townnameparts); |
0 | 444 |
GetString(_bufcache, j->town->townnametype); |
445 |
} |
|
446 |
r = strcmp(buf1, _bufcache); |
|
447 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
448 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
449 |
if (_industry_sort_order & 1) r = -r; |
0 | 450 |
return r; |
451 |
} |
|
452 |
||
453 |
static void MakeSortedIndustryList() |
|
454 |
{ |
|
455 |
Industry *i; |
|
456 |
int n = 0, index = 0; |
|
457 |
||
458 |
for(i=_industries; i != endof(_industries); i++) { |
|
459 |
if(i->xy) _industry_sort[n++] = index; |
|
460 |
index++; |
|
461 |
} |
|
462 |
_num_industry_sort = n; |
|
463 |
_last_industry_idx = 255; // used for "cache" |
|
464 |
||
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
|
465 |
qsort(_industry_sort, n, 1, GeneralIndustrySorter); |
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
0
diff
changeset
|
466 |
|
69 | 467 |
DEBUG(misc, 1) ("Resorting Industries list..."); |
0 | 468 |
} |
469 |
||
470 |
||
471 |
static void IndustryDirectoryWndProc(Window *w, WindowEvent *e) |
|
472 |
{ |
|
473 |
switch(e->event) { |
|
474 |
case WE_PAINT: { |
|
475 |
int n; |
|
476 |
uint p; |
|
477 |
Industry *i; |
|
478 |
static const uint16 _indicator_positions[4] = {88, 187, 284, 387}; |
|
479 |
||
480 |
if (_industry_sort_dirty) { |
|
481 |
_industry_sort_dirty = false; |
|
482 |
MakeSortedIndustryList(); |
|
483 |
} |
|
484 |
||
485 |
w->vscroll.count = _num_industry_sort; |
|
486 |
||
487 |
DrawWindowWidgets(w); |
|
488 |
DoDrawString(_industry_sort_order & 1 ? "\xAA" : "\xA0", _indicator_positions[_industry_sort_order>>1], 15, 0x10); |
|
489 |
||
490 |
p = w->vscroll.pos; |
|
491 |
n = 0; |
|
492 |
||
493 |
while (p < _num_industry_sort) { |
|
494 |
i = DEREF_INDUSTRY(_industry_sort[p]); |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
495 |
SetDParam(0, i->town->index); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
496 |
SetDParam(1, i->type + STR_4802_COAL_MINE); |
0 | 497 |
if (i->produced_cargo[0] != 0xFF) { |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
498 |
SetDParam(3, i->total_production[0]); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
499 |
SetDParam(2, _cargoc.names_long_s[i->produced_cargo[0]] + ((i->total_production[0]!=1)<<5)); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
500 |
|
0 | 501 |
if (i->produced_cargo[1] != 0xFF) { |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
502 |
SetDParam(5, i->total_production[1]); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
503 |
SetDParam(4, _cargoc.names_long_s[i->produced_cargo[1]] + ((i->total_production[1]!=1)<<5)); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
504 |
SetDParam(6, i->pct_transported[0] * 100 >> 8); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
505 |
SetDParam(7, i->pct_transported[1] * 100 >> 8); |
0 | 506 |
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM_TWO, 0); |
507 |
} else { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
508 |
SetDParam(4, i->pct_transported[0] * 100 >> 8); |
0 | 509 |
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM, 0); |
510 |
} |
|
511 |
} else { |
|
512 |
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM_NOPROD, 0); |
|
513 |
} |
|
514 |
p++; |
|
515 |
if (++n == 16) |
|
516 |
break; |
|
517 |
} |
|
518 |
} break; |
|
519 |
||
520 |
case WE_CLICK: |
|
521 |
switch(e->click.widget) { |
|
522 |
case 2: { |
|
523 |
_industry_sort_order = _industry_sort_order==0 ? 1 : 0; |
|
524 |
_industry_sort_dirty = true; |
|
525 |
SetWindowDirty(w); |
|
526 |
} break; |
|
527 |
||
528 |
case 3: { |
|
529 |
_industry_sort_order = _industry_sort_order==2 ? 3 : 2; |
|
530 |
_industry_sort_dirty = true; |
|
531 |
SetWindowDirty(w); |
|
532 |
} break; |
|
533 |
||
534 |
case 4: { |
|
535 |
_industry_sort_order = _industry_sort_order==4 ? 5 : 4; |
|
536 |
_industry_sort_dirty = true; |
|
537 |
SetWindowDirty(w); |
|
538 |
} break; |
|
539 |
||
540 |
case 5: { |
|
541 |
_industry_sort_order = _industry_sort_order==6 ? 7 : 6; |
|
542 |
_industry_sort_dirty = true; |
|
543 |
SetWindowDirty(w); |
|
544 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
545 |
|
0 | 546 |
case 7: { |
547 |
int y = (e->click.pt.y - 28) / 10; |
|
548 |
byte p; |
|
549 |
Industry *c; |
|
550 |
||
551 |
if (!IS_INT_INSIDE(y, 0, 16)) |
|
552 |
return; |
|
553 |
p = y + w->vscroll.pos; |
|
554 |
if (p < _num_industry_sort) { |
|
555 |
c = DEREF_INDUSTRY(_industry_sort[p]); |
|
556 |
ScrollMainWindowToTile(c->xy); |
|
557 |
} |
|
558 |
} break; |
|
559 |
} |
|
560 |
break; |
|
561 |
||
562 |
case WE_4: |
|
563 |
SetWindowDirty(w); |
|
564 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
565 |
} |
0 | 566 |
} |
567 |
||
568 |
||
569 |
/* Industry List */ |
|
570 |
static const WindowDesc _industry_directory_desc = { |
|
571 |
-1, -1, 508, 190, |
|
572 |
WC_INDUSTRY_DIRECTORY,0, |
|
573 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
574 |
_industry_directory_widgets, |
|
575 |
IndustryDirectoryWndProc |
|
576 |
}; |
|
577 |
||
578 |
||
579 |
||
580 |
void ShowIndustryDirectory() |
|
581 |
{ |
|
582 |
/* Industry List */ |
|
583 |
Window *w; |
|
584 |
||
585 |
w = AllocateWindowDescFront(&_industry_directory_desc, 0); |
|
586 |
if (w) { |
|
587 |
w->vscroll.cap = 16; |
|
588 |
SetWindowDirty(w); |
|
589 |
} |
|
590 |
} |