author | rubidium |
Thu, 21 Jun 2007 17:25:17 +0000 | |
changeset 7002 | 1bf6a62b0fcb |
parent 6991 | bf9cd2a47774 |
child 7177 | f9796d5be926 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6200
diff
changeset
|
3 |
/** @file industry_gui.cpp */ |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6200
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1786
diff
changeset
|
6 |
#include "openttd.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1287
diff
changeset
|
7 |
#include "debug.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
8 |
#include "functions.h" |
1309
4403a69da4f8
(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
|
9 |
#include "strings.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
222
diff
changeset
|
10 |
#include "table/strings.h" |
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
11 |
#include "table/sprites.h" |
679
04ca2cd69420
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
534
diff
changeset
|
12 |
#include "map.h" |
1386
0de4f8541aea
(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
|
13 |
#include "gui.h" |
0 | 14 |
#include "window.h" |
15 |
#include "gfx.h" |
|
16 |
#include "command.h" |
|
17 |
#include "viewport.h" |
|
18 |
#include "industry.h" |
|
19 |
#include "town.h" |
|
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2084
diff
changeset
|
20 |
#include "variables.h" |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
21 |
#include "helpers.hpp" |
6091
c8827d9ae04a
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
5893
diff
changeset
|
22 |
#include "cargotype.h" |
0 | 23 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6200
diff
changeset
|
24 |
/* industries per climate, according to the different construction windows */ |
4995
69dbe0e096dc
(svn r7001) -Codechange: _build_industry_trypes is now only used by industry_gui.c. Move it there.
belugas
parents:
4939
diff
changeset
|
25 |
const byte _build_industry_types[4][12] = { |
69dbe0e096dc
(svn r7001) -Codechange: _build_industry_trypes is now only used by industry_gui.c. Move it there.
belugas
parents:
4939
diff
changeset
|
26 |
{ 1, 2, 4, 6, 8, 0, 3, 5, 9, 11, 18 }, |
69dbe0e096dc
(svn r7001) -Codechange: _build_industry_trypes is now only used by industry_gui.c. Move it there.
belugas
parents:
4939
diff
changeset
|
27 |
{ 1, 14, 4, 13, 7, 0, 3, 9, 11, 15 }, |
69dbe0e096dc
(svn r7001) -Codechange: _build_industry_trypes is now only used by industry_gui.c. Move it there.
belugas
parents:
4939
diff
changeset
|
28 |
{ 25, 13, 4, 23, 22, 11, 17, 10, 24, 19, 20, 21 }, |
69dbe0e096dc
(svn r7001) -Codechange: _build_industry_trypes is now only used by industry_gui.c. Move it there.
belugas
parents:
4939
diff
changeset
|
29 |
{ 27, 30, 31, 33, 26, 28, 29, 32, 34, 35, 36 }, |
69dbe0e096dc
(svn r7001) -Codechange: _build_industry_trypes is now only used by industry_gui.c. Move it there.
belugas
parents:
4939
diff
changeset
|
30 |
}; |
0 | 31 |
|
1004 | 32 |
static void UpdateIndustryProduction(Industry *i); |
33 |
||
0 | 34 |
static void BuildIndustryWndProc(Window *w, WindowEvent *e) |
35 |
{ |
|
2951 | 36 |
switch (e->event) { |
0 | 37 |
case WE_PAINT: |
38 |
DrawWindowWidgets(w); |
|
39 |
if (_thd.place_mode == 1 && _thd.window_class == WC_BUILD_INDUSTRY) { |
|
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
40 |
int ind_type = _build_industry_types[_opt_ptr->landscape][WP(w, def_d).data_1]; |
0 | 41 |
|
7002
1bf6a62b0fcb
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
6991
diff
changeset
|
42 |
SetDParam(0, (_price.build_industry >> 8) * GetIndustrySpec(ind_type)->cost_multiplier); |
0 | 43 |
DrawStringCentered(85, w->height - 21, STR_482F_COST, 0); |
44 |
} |
|
45 |
break; |
|
46 |
||
47 |
case WE_CLICK: { |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
48 |
int wid = e->we.click.widget; |
0 | 49 |
if (wid >= 3) { |
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
50 |
if (HandlePlacePushButton(w, wid, SPR_CURSOR_INDUSTRY, 1, NULL)) |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
51 |
WP(w, def_d).data_1 = wid - 3; |
0 | 52 |
} |
53 |
} break; |
|
54 |
||
55 |
case WE_PLACE_OBJ: |
|
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
56 |
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 | 57 |
ResetObjectToPlace(); |
58 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
59 |
|
0 | 60 |
case WE_ABORT_PLACE_OBJ: |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
61 |
RaiseWindowButtons(w); |
0 | 62 |
break; |
63 |
} |
|
64 |
} |
|
65 |
||
66 |
static const Widget _build_industry_land0_widgets[] = { |
|
4344
7e123fec5b0b
(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_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(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_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL}, |
7e123fec5b0b
(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
|
70 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
7e123fec5b0b
(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
|
71 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_0242_SAWMILL, STR_0264_CONSTRUCT_SAWMILL}, |
7e123fec5b0b
(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
|
72 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
7e123fec5b0b
(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
|
73 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
7e123fec5b0b
(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_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
|
75 |
{ WIDGETS_END}, |
0 | 76 |
}; |
77 |
||
78 |
static const Widget _build_industry_land1_widgets[] = { |
|
4344
7e123fec5b0b
(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_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(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_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL}, |
7e123fec5b0b
(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
|
82 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
7e123fec5b0b
(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
|
83 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024C_PAPER_MILL, STR_026E_CONSTRUCT_PAPER_MILL}, |
7e123fec5b0b
(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
|
84 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
7e123fec5b0b
(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
|
85 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_024D_FOOD_PROCESSING_PLANT, STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
7e123fec5b0b
(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_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
|
87 |
{ WIDGETS_END}, |
0 | 88 |
}; |
89 |
||
90 |
static const Widget _build_industry_land2_widgets[] = { |
|
4344
7e123fec5b0b
(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_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(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_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL}, |
7e123fec5b0b
(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
|
94 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0250_LUMBER_MILL, STR_0273_CONSTRUCT_LUMBER_MILL_TO}, |
7e123fec5b0b
(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
|
95 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024D_FOOD_PROCESSING_PLANT, STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
7e123fec5b0b
(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
|
96 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
7e123fec5b0b
(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
|
97 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
7e123fec5b0b
(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_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
|
99 |
{ WIDGETS_END}, |
0 | 100 |
}; |
101 |
||
102 |
static const Widget _build_industry_land3_widgets[] = { |
|
4344
7e123fec5b0b
(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_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(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
|
105 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL}, |
7e123fec5b0b
(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
|
106 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0258_CANDY_FACTORY, STR_027B_CONSTRUCT_CANDY_FACTORY}, |
7e123fec5b0b
(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
|
107 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_025B_TOY_SHOP, STR_027E_CONSTRUCT_TOY_SHOP}, |
7e123fec5b0b
(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
|
108 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_025C_TOY_FACTORY, STR_027F_CONSTRUCT_TOY_FACTORY}, |
7e123fec5b0b
(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_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
|
110 |
{ WIDGETS_END}, |
0 | 111 |
}; |
112 |
||
113 |
static const Widget _build_industry_land0_widgets_extra[] = { |
|
4344
7e123fec5b0b
(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_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(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_PANEL, RESIZE_NONE, 7, 0, 169, 14, 187, 0x0, STR_NULL}, |
0 | 117 |
|
4344
7e123fec5b0b
(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
|
118 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
7e123fec5b0b
(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, 29, 40, STR_0242_SAWMILL, STR_0264_CONSTRUCT_SAWMILL}, |
7e123fec5b0b
(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, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
7e123fec5b0b
(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, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
7e123fec5b0b
(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, 68, 79, STR_0247_STEEL_MILL, STR_0269_CONSTRUCT_STEEL_MILL}, |
0 | 123 |
|
4344
7e123fec5b0b
(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, 84, 95, STR_0240_COAL_MINE, STR_CONSTRUCT_COAL_MINE_TIP}, |
7e123fec5b0b
(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
|
125 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 97, 108, STR_0243_FOREST, STR_CONSTRUCT_FOREST_TIP}, |
7e123fec5b0b
(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
|
126 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 110, 121, STR_0245_OIL_RIG, STR_CONSTRUCT_OIL_RIG_TIP}, |
7e123fec5b0b
(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
|
127 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 123, 134, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP}, |
7e123fec5b0b
(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
|
128 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 136, 147, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP}, |
7e123fec5b0b
(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
|
129 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 149, 160, STR_0249_IRON_ORE_MINE, STR_CONSTRUCT_IRON_ORE_MINE_TIP}, |
0 | 130 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
131 |
{ WIDGETS_END}, |
0 | 132 |
}; |
133 |
||
134 |
static const Widget _build_industry_land1_widgets_extra[] = { |
|
4344
7e123fec5b0b
(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_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(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_PANEL, RESIZE_NONE, 7, 0, 169, 14, 174, 0x0, STR_NULL}, |
0 | 138 |
|
4344
7e123fec5b0b
(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
|
139 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
7e123fec5b0b
(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, 29, 40, STR_024C_PAPER_MILL, STR_026E_CONSTRUCT_PAPER_MILL}, |
7e123fec5b0b
(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, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
7e123fec5b0b
(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, 55, 66, STR_024D_FOOD_PROCESSING_PLANT, STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
7e123fec5b0b
(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, 68, 79, STR_024E_PRINTING_WORKS, STR_0270_CONSTRUCT_PRINTING_WORKS}, |
0 | 144 |
|
4344
7e123fec5b0b
(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
|
145 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 84, 95, STR_0240_COAL_MINE, STR_CONSTRUCT_COAL_MINE_TIP}, |
7e123fec5b0b
(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
|
146 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 97, 108, STR_0243_FOREST, STR_CONSTRUCT_FOREST_TIP}, |
7e123fec5b0b
(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
|
147 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 110, 121, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP}, |
7e123fec5b0b
(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
|
148 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 123, 134, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP}, |
7e123fec5b0b
(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_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
|
150 |
{ WIDGETS_END}, |
0 | 151 |
}; |
152 |
||
153 |
static const Widget _build_industry_land2_widgets_extra[] = { |
|
4344
7e123fec5b0b
(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_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(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_PANEL, RESIZE_NONE, 7, 0, 169, 14, 200, 0x0, STR_NULL}, |
0 | 157 |
|
4344
7e123fec5b0b
(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
|
158 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0250_LUMBER_MILL, STR_0273_CONSTRUCT_LUMBER_MILL_TO}, |
7e123fec5b0b
(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, 29, 40, STR_024D_FOOD_PROCESSING_PLANT, STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
7e123fec5b0b
(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, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
7e123fec5b0b
(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, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
7e123fec5b0b
(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, 68, 79, STR_0254_WATER_TOWER, STR_0277_CONSTRUCT_WATER_TOWER_CAN}, |
0 | 163 |
|
4344
7e123fec5b0b
(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, 84, 95, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP}, |
7e123fec5b0b
(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, 97, 108, STR_0255_DIAMOND_MINE, STR_CONSTRUCT_DIAMOND_MINE_TIP}, |
7e123fec5b0b
(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
|
166 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 110, 121, STR_0256_COPPER_ORE_MINE, STR_CONSTRUCT_COPPER_ORE_MINE_TIP}, |
7e123fec5b0b
(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
|
167 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 123, 134, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP}, |
7e123fec5b0b
(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
|
168 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 136, 147, STR_0251_FRUIT_PLANTATION, STR_CONSTRUCT_FRUIT_PLANTATION_TIP}, |
7e123fec5b0b
(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
|
169 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 149, 160, STR_0252_RUBBER_PLANTATION, STR_CONSTRUCT_RUBBER_PLANTATION_TIP}, |
7e123fec5b0b
(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_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
|
171 |
{ WIDGETS_END}, |
0 | 172 |
}; |
173 |
||
174 |
static const Widget _build_industry_land3_widgets_extra[] = { |
|
4344
7e123fec5b0b
(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_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(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_PANEL, RESIZE_NONE, 7, 0, 169, 14, 187, 0x0, STR_NULL}, |
0 | 178 |
|
4344
7e123fec5b0b
(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, 16, 27, STR_0258_CANDY_FACTORY, STR_027B_CONSTRUCT_CANDY_FACTORY}, |
7e123fec5b0b
(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, 29, 40, STR_025B_TOY_SHOP, STR_027E_CONSTRUCT_TOY_SHOP}, |
7e123fec5b0b
(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, 42, 53, STR_025C_TOY_FACTORY, STR_027F_CONSTRUCT_TOY_FACTORY}, |
7e123fec5b0b
(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, 55, 66, STR_025E_FIZZY_DRINK_FACTORY, STR_0281_CONSTRUCT_FIZZY_DRINK_FACTORY}, |
0 | 183 |
|
4344
7e123fec5b0b
(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, 71, 82, STR_0257_COTTON_CANDY_FOREST, STR_CONSTRUCT_COTTON_CANDY_TIP}, |
7e123fec5b0b
(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, 84, 95, STR_0259_BATTERY_FARM, STR_CONSTRUCT_BATTERY_FARM_TIP}, |
7e123fec5b0b
(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
|
186 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 97, 108, STR_025A_COLA_WELLS, STR_CONSTRUCT_COLA_WELLS_TIP}, |
7e123fec5b0b
(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
|
187 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 110, 121, STR_025D_PLASTIC_FOUNTAINS, STR_CONSTRUCT_PLASTIC_FOUNTAINS_TIP}, |
7e123fec5b0b
(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
|
188 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 123, 134, STR_025F_BUBBLE_GENERATOR, STR_CONSTRUCT_BUBBLE_GENERATOR_TIP}, |
7e123fec5b0b
(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
|
189 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 136, 147, STR_0260_TOFFEE_QUARRY, STR_CONSTRUCT_TOFFEE_QUARRY_TIP}, |
7e123fec5b0b
(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
|
190 |
{ 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
|
191 |
{ WIDGETS_END}, |
0 | 192 |
}; |
193 |
||
194 |
||
195 |
static const WindowDesc _build_industry_land0_desc = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
196 |
WDP_AUTO, WDP_AUTO, 170, 116, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5609
diff
changeset
|
197 |
WC_BUILD_INDUSTRY, WC_NONE, |
0 | 198 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
199 |
_build_industry_land0_widgets, |
|
200 |
BuildIndustryWndProc |
|
201 |
}; |
|
202 |
||
203 |
static const WindowDesc _build_industry_land1_desc = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
204 |
WDP_AUTO, WDP_AUTO, 170, 116, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5609
diff
changeset
|
205 |
WC_BUILD_INDUSTRY, WC_NONE, |
0 | 206 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
207 |
_build_industry_land1_widgets, |
|
208 |
BuildIndustryWndProc |
|
209 |
}; |
|
210 |
||
211 |
static const WindowDesc _build_industry_land2_desc = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
212 |
WDP_AUTO, WDP_AUTO, 170, 116, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5609
diff
changeset
|
213 |
WC_BUILD_INDUSTRY, WC_NONE, |
0 | 214 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
215 |
_build_industry_land2_widgets, |
|
216 |
BuildIndustryWndProc |
|
217 |
}; |
|
218 |
||
219 |
static const WindowDesc _build_industry_land3_desc = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
220 |
WDP_AUTO, WDP_AUTO, 170, 116, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5609
diff
changeset
|
221 |
WC_BUILD_INDUSTRY, WC_NONE, |
0 | 222 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
223 |
_build_industry_land3_widgets, |
|
224 |
BuildIndustryWndProc |
|
225 |
}; |
|
226 |
||
227 |
static const WindowDesc _build_industry_land0_desc_extra = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
228 |
WDP_AUTO, WDP_AUTO, 170, 188, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5609
diff
changeset
|
229 |
WC_BUILD_INDUSTRY, WC_NONE, |
0 | 230 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
231 |
_build_industry_land0_widgets_extra, |
|
232 |
BuildIndustryWndProc |
|
233 |
}; |
|
234 |
||
235 |
static const WindowDesc _build_industry_land1_desc_extra = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
236 |
WDP_AUTO, WDP_AUTO, 170, 175, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5609
diff
changeset
|
237 |
WC_BUILD_INDUSTRY, WC_NONE, |
0 | 238 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
239 |
_build_industry_land1_widgets_extra, |
|
240 |
BuildIndustryWndProc |
|
241 |
}; |
|
242 |
||
243 |
static const WindowDesc _build_industry_land2_desc_extra = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
244 |
WDP_AUTO, WDP_AUTO, 170, 201, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5609
diff
changeset
|
245 |
WC_BUILD_INDUSTRY, WC_NONE, |
0 | 246 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
247 |
_build_industry_land2_widgets_extra, |
|
248 |
BuildIndustryWndProc |
|
249 |
}; |
|
250 |
||
251 |
static const WindowDesc _build_industry_land3_desc_extra = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
252 |
WDP_AUTO, WDP_AUTO, 170, 188, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5609
diff
changeset
|
253 |
WC_BUILD_INDUSTRY, WC_NONE, |
0 | 254 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
255 |
_build_industry_land3_widgets_extra, |
|
256 |
BuildIndustryWndProc |
|
257 |
}; |
|
258 |
||
259 |
static const WindowDesc * const _industry_window_desc[2][4] = { |
|
260 |
{ |
|
261 |
&_build_industry_land0_desc, |
|
262 |
&_build_industry_land1_desc, |
|
263 |
&_build_industry_land2_desc, |
|
264 |
&_build_industry_land3_desc, |
|
265 |
}, |
|
266 |
{ |
|
267 |
&_build_industry_land0_desc_extra, |
|
268 |
&_build_industry_land1_desc_extra, |
|
269 |
&_build_industry_land2_desc_extra, |
|
270 |
&_build_industry_land3_desc_extra, |
|
271 |
}, |
|
272 |
}; |
|
273 |
||
6247 | 274 |
void ShowBuildIndustryWindow() |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
275 |
{ |
5005
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4995
diff
changeset
|
276 |
if (!IsValidPlayer(_current_player)) return; |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
277 |
AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt_ptr->landscape], 0); |
0 | 278 |
} |
279 |
||
4211
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
280 |
static inline bool isProductionMinimum(const Industry *i, int pt) { |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
281 |
return i->production_rate[pt] == 1; |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
282 |
} |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
283 |
|
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
284 |
static inline bool isProductionMaximum(const Industry *i, int pt) { |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
285 |
return i->production_rate[pt] == 255; |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
286 |
} |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
287 |
|
4194
7df740c3b712
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
288 |
static inline bool IsProductionAlterable(const Industry *i) |
7df740c3b712
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
289 |
{ |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
290 |
const IndustrySpec *ind = GetIndustrySpec(i->type); |
4194
7df740c3b712
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
291 |
return ((_game_mode == GM_EDITOR || _cheats.setup_prod.value) && |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
292 |
(ind->accepts_cargo[0] == CT_INVALID || ind->accepts_cargo[0] == CT_VALUABLES)); |
4194
7df740c3b712
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
293 |
} |
7df740c3b712
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
294 |
|
0 | 295 |
static void IndustryViewWndProc(Window *w, WindowEvent *e) |
296 |
{ |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6200
diff
changeset
|
297 |
/* WP(w,vp2_d).data_1 is for the editbox line |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6200
diff
changeset
|
298 |
* WP(w,vp2_d).data_2 is for the clickline |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6200
diff
changeset
|
299 |
* WP(w,vp2_d).data_3 is for the click pos (left or right) */ |
0 | 300 |
|
2951 | 301 |
switch (e->event) { |
1004 | 302 |
case WE_PAINT: { |
4171 | 303 |
const Industry *i = GetIndustry(w->window_number); |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
304 |
const IndustrySpec *ind = GetIndustrySpec(i->type); |
2557 | 305 |
|
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
306 |
SetDParam(0, w->window_number); |
0 | 307 |
DrawWindowWidgets(w); |
308 |
||
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
309 |
if (ind->accepts_cargo[0] != CT_INVALID) { |
2989 | 310 |
StringID str; |
311 |
||
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
312 |
SetDParam(0, GetCargo(ind->accepts_cargo[0])->name); |
0 | 313 |
str = STR_4827_REQUIRES; |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
314 |
if (ind->accepts_cargo[1] != CT_INVALID) { |
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
315 |
SetDParam(1, GetCargo(ind->accepts_cargo[1])->name); |
2989 | 316 |
str = STR_4828_REQUIRES; |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
317 |
if (ind->accepts_cargo[2] != CT_INVALID) { |
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
318 |
SetDParam(2, GetCargo(ind->accepts_cargo[2])->name); |
2989 | 319 |
str = STR_4829_REQUIRES; |
0 | 320 |
} |
321 |
} |
|
322 |
DrawString(2, 107, str, 0); |
|
323 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
324 |
|
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
325 |
if (ind->produced_cargo[0] != CT_INVALID) { |
0 | 326 |
DrawString(2, 117, STR_482A_PRODUCTION_LAST_MONTH, 0); |
327 |
||
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
328 |
SetDParam(0, ind->produced_cargo[0]); |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
329 |
SetDParam(1, i->last_month_production[0]); |
2063
ae866a12f2df
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
1981
diff
changeset
|
330 |
|
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
331 |
SetDParam(2, i->last_month_pct_transported[0] * 100 >> 8); |
4194
7df740c3b712
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
332 |
DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 127, STR_482B_TRANSPORTED, 0); |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6200
diff
changeset
|
333 |
/* Let's put out those buttons.. */ |
4211
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
334 |
if (IsProductionAlterable(i)) { |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
335 |
DrawArrowButtons(5, 127, 3, (WP(w, vp2_d).data_2 == 1) ? WP(w, vp2_d).data_3 : 0, |
4211
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
336 |
!isProductionMinimum(i, 0), !isProductionMaximum(i, 0)); |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
337 |
} |
0 | 338 |
|
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
339 |
if (ind->produced_cargo[1] != CT_INVALID) { |
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
340 |
SetDParam(0, ind->produced_cargo[1]); |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
341 |
SetDParam(1, i->last_month_production[1]); |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
342 |
SetDParam(2, i->last_month_pct_transported[1] * 100 >> 8); |
4194
7df740c3b712
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
343 |
DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 137, STR_482B_TRANSPORTED, 0); |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6200
diff
changeset
|
344 |
/* Let's put out those buttons.. */ |
4211
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
345 |
if (IsProductionAlterable(i)) { |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
346 |
DrawArrowButtons(5, 137, 3, (WP(w, vp2_d).data_2 == 2) ? WP(w, vp2_d).data_3 : 0, |
4211
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
347 |
!isProductionMinimum(i, 1), !isProductionMaximum(i, 1)); |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
348 |
} |
0 | 349 |
} |
350 |
} |
|
351 |
||
352 |
DrawWindowViewport(w); |
|
1004 | 353 |
} |
0 | 354 |
break; |
355 |
||
1004 | 356 |
case WE_CLICK: { |
357 |
Industry *i; |
|
358 |
||
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
359 |
switch (e->we.click.widget) { |
1004 | 360 |
case 5: { |
4193
9e82090fef58
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
Darkvater
parents:
4192
diff
changeset
|
361 |
int line, x; |
1004 | 362 |
|
363 |
i = GetIndustry(w->window_number); |
|
364 |
||
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6200
diff
changeset
|
365 |
/* We should work if needed.. */ |
4194
7df740c3b712
(svn r5654) -Cleanup: Change an ugly define into a function
Darkvater
parents:
4193
diff
changeset
|
366 |
if (!IsProductionAlterable(i)) return; |
1004 | 367 |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
368 |
x = e->we.click.pt.x; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
369 |
line = (e->we.click.pt.y - 127) / 10; |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
370 |
if (e->we.click.pt.y >= 127 && IS_INT_INSIDE(line, 0, 2) && |
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
371 |
GetIndustrySpec(i->type)->produced_cargo[line] != CT_INVALID) { |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
372 |
if (IS_INT_INSIDE(x, 5, 25) ) { |
4193
9e82090fef58
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
Darkvater
parents:
4192
diff
changeset
|
373 |
/* Clicked buttons, decrease or increase production */ |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
374 |
if (x < 15) { |
4211
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
375 |
if (isProductionMinimum(i, line)) return; |
5601
d58f82901b2f
(svn r8055) -Codechange: Replace the different max, dmax, maxu whatever macros by a simple template function max(), that requires two arguments of the same type. While I'm at it change a variable called "max" to "maxval" in a function that calls max().
celestar
parents:
5587
diff
changeset
|
376 |
i->production_rate[line] = max(i->production_rate[line] / 2, 1); |
1004 | 377 |
} else { |
4211
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4194
diff
changeset
|
378 |
if (isProductionMaximum(i, line)) return; |
4193
9e82090fef58
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
Darkvater
parents:
4192
diff
changeset
|
379 |
i->production_rate[line] = minu(i->production_rate[line] * 2, 255); |
1004 | 380 |
} |
4193
9e82090fef58
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
Darkvater
parents:
4192
diff
changeset
|
381 |
|
1004 | 382 |
UpdateIndustryProduction(i); |
383 |
SetWindowDirty(w); |
|
384 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
|
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
385 |
WP(w, vp2_d).data_2 = line + 1; |
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
386 |
WP(w, vp2_d).data_3 = (x < 15 ? 1 : 2); |
1004 | 387 |
} else if (IS_INT_INSIDE(x, 34, 160)) { |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6200
diff
changeset
|
388 |
/* clicked the text */ |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
389 |
WP(w, vp2_d).data_1 = line; |
1004 | 390 |
SetDParam(0, i->production_rate[line] * 8); |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5380
diff
changeset
|
391 |
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_GAME_PRODUCTION, 10, 100, w, CS_ALPHANUMERAL); |
1004 | 392 |
} |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
393 |
} |
4193
9e82090fef58
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
Darkvater
parents:
4192
diff
changeset
|
394 |
} break; |
758
423ae0bcba07
(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
|
395 |
case 6: |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
396 |
i = GetIndustry(w->window_number); |
1981 | 397 |
ScrollMainWindowToTile(i->xy + TileDiffXY(1, 1)); |
6492
286a52449b54
(svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents:
6491
diff
changeset
|
398 |
} break; |
4193
9e82090fef58
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
Darkvater
parents:
4192
diff
changeset
|
399 |
|
1004 | 400 |
} |
0 | 401 |
break; |
1004 | 402 |
case WE_TIMEOUT: |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
403 |
WP(w, vp2_d).data_2 = 0; |
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
404 |
WP(w, vp2_d).data_3 = 0; |
1004 | 405 |
SetWindowDirty(w); |
406 |
break; |
|
407 |
||
408 |
case WE_ON_EDIT_TEXT: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
409 |
if (e->we.edittext.str[0] != '\0') { |
3017
a75caf4efa2d
(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
|
410 |
Industry* i = GetIndustry(w->window_number); |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
411 |
int line = WP(w, vp2_d).data_1; |
1004 | 412 |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
413 |
i->production_rate[line] = clampu(atoi(e->we.edittext.str), 0, 255); |
1004 | 414 |
UpdateIndustryProduction(i); |
415 |
SetWindowDirty(w); |
|
416 |
} |
|
0 | 417 |
} |
418 |
} |
|
419 |
||
1004 | 420 |
static void UpdateIndustryProduction(Industry *i) |
421 |
{ |
|
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
422 |
const IndustrySpec *ind = GetIndustrySpec(i->type); |
1004 | 423 |
|
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
424 |
for (byte j = 0; j < lengthof(ind->produced_cargo); j++) { |
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
425 |
if (ind->produced_cargo[j] != CT_INVALID) { |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
426 |
i->last_month_production[j] = 8 * i->production_rate[j]; |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
427 |
} |
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
428 |
} |
1004 | 429 |
} |
430 |
||
0 | 431 |
static const Widget _industry_view_widgets[] = { |
4344
7e123fec5b0b
(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
|
432 |
{ WWT_CLOSEBOX, RESIZE_NONE, 9, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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
|
433 |
{ WWT_CAPTION, RESIZE_NONE, 9, 11, 247, 0, 13, STR_4801, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(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
|
434 |
{ WWT_STICKYBOX, RESIZE_NONE, 9, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
435 |
{ WWT_PANEL, RESIZE_NONE, 9, 0, 259, 14, 105, 0x0, STR_NULL}, |
4939
bef7c24a6027
(svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents:
4938
diff
changeset
|
436 |
{ WWT_INSET, RESIZE_NONE, 9, 2, 257, 16, 103, 0x0, STR_NULL}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
437 |
{ WWT_PANEL, RESIZE_NONE, 9, 0, 259, 106, 147, 0x0, STR_NULL}, |
4344
7e123fec5b0b
(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
|
438 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 9, 0, 129, 148, 159, STR_00E4_LOCATION, STR_482C_CENTER_THE_MAIN_VIEW_ON}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
439 |
{ 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
|
440 |
{ WIDGETS_END}, |
0 | 441 |
}; |
442 |
||
443 |
static const WindowDesc _industry_view_desc = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
444 |
WDP_AUTO, WDP_AUTO, 260, 160, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5609
diff
changeset
|
445 |
WC_INDUSTRY_VIEW, WC_NONE, |
758
423ae0bcba07
(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
|
446 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 447 |
_industry_view_widgets, |
448 |
IndustryViewWndProc |
|
449 |
}; |
|
450 |
||
451 |
void ShowIndustryViewWindow(int industry) |
|
452 |
{ |
|
4171 | 453 |
Window *w = AllocateWindowDescFront(&_industry_view_desc, industry); |
0 | 454 |
|
2989 | 455 |
if (w != NULL) { |
0 | 456 |
w->flags4 |= WF_DISABLE_VP_SCROLL; |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
457 |
WP(w, vp2_d).data_1 = 0; |
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
458 |
WP(w, vp2_d).data_2 = 0; |
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
459 |
WP(w, vp2_d).data_3 = 0; |
6624
880e29b1f25e
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
6492
diff
changeset
|
460 |
AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetIndustry(w->window_number)->xy + TileDiffXY(1, 1), ZOOM_LVL_INDUSTRY); |
0 | 461 |
} |
462 |
} |
|
463 |
||
464 |
static const Widget _industry_directory_widgets[] = { |
|
4344
7e123fec5b0b
(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_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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
|
466 |
{ WWT_CAPTION, RESIZE_NONE, 13, 11, 495, 0, 13, STR_INDUSTRYDIR_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(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_STICKYBOX, RESIZE_NONE, 13, 496, 507, 0, 13, 0x0, STR_STICKY_BUTTON}, |
7e123fec5b0b
(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_PUSHTXTBTN, RESIZE_NONE, 13, 0, 100, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP}, |
7e123fec5b0b
(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
|
469 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 101, 200, 14, 25, STR_SORT_BY_TYPE, STR_SORT_ORDER_TIP}, |
7e123fec5b0b
(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
|
470 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 201, 300, 14, 25, STR_SORT_BY_PRODUCTION, STR_SORT_ORDER_TIP}, |
7e123fec5b0b
(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
|
471 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 301, 400, 14, 25, STR_SORT_BY_TRANSPORTED, STR_SORT_ORDER_TIP}, |
7e123fec5b0b
(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
|
472 |
{ WWT_PANEL, RESIZE_NONE, 13, 401, 495, 14, 25, 0x0, STR_NULL}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
473 |
{ WWT_PANEL, RESIZE_BOTTOM, 13, 0, 495, 26, 189, 0x0, STR_200A_TOWN_NAMES_CLICK_ON_NAME}, |
4344
7e123fec5b0b
(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
|
474 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 13, 496, 507, 14, 177, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
7e123fec5b0b
(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
|
475 |
{ 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
|
476 |
{ WIDGETS_END}, |
0 | 477 |
}; |
478 |
||
479 |
static uint _num_industry_sort; |
|
480 |
||
481 |
static char _bufcache[96]; |
|
4277
345e1bd9525a
(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 |
static const Industry* _last_industry; |
0 | 483 |
|
484 |
static byte _industry_sort_order; |
|
485 |
||
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
|
486 |
static int CDECL GeneralIndustrySorter(const void *a, const void *b) |
0 | 487 |
{ |
4277
345e1bd9525a
(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
|
488 |
const Industry* i = *(const Industry**)a; |
345e1bd9525a
(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
|
489 |
const Industry* j = *(const Industry**)b; |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
490 |
const IndustrySpec *ind_i = GetIndustrySpec(i->type); |
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
491 |
const IndustrySpec *ind_j = GetIndustrySpec(j->type); |
4282
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
492 |
int r; |
0 | 493 |
|
494 |
switch (_industry_sort_order >> 1) { |
|
4282
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
495 |
default: NOT_REACHED(); |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
496 |
case 0: /* Sort by Name (handled later) */ |
0 | 497 |
r = 0; |
4282
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
498 |
break; |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
499 |
|
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
500 |
case 1: /* Sort by Type */ |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
501 |
r = i->type - j->type; |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
502 |
break; |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
503 |
|
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
504 |
case 2: /* Sort by Production */ |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
505 |
if (ind_i->produced_cargo[0] == CT_INVALID) { |
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
506 |
r = (ind_j->produced_cargo[0] == CT_INVALID ? 0 : -1); |
4282
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
507 |
} else { |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
508 |
if (ind_j->produced_cargo[0] == CT_INVALID) { |
4282
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
509 |
r = 1; |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
510 |
} else { |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
511 |
r = |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
512 |
(i->last_month_production[0] + i->last_month_production[1]) - |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
513 |
(j->last_month_production[0] + j->last_month_production[1]); |
4282
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
514 |
} |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
515 |
} |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
516 |
break; |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
517 |
|
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
518 |
case 3: /* Sort by transported fraction */ |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
519 |
if (ind_i->produced_cargo[0] == CT_INVALID) { |
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
520 |
r = (ind_j->produced_cargo[0] == CT_INVALID ? 0 : -1); |
4282
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
521 |
} else { |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
522 |
if (ind_j->produced_cargo[0] == CT_INVALID) { |
4282
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
523 |
r = 1; |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
524 |
} else { |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
525 |
int pi; |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
526 |
int pj; |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
527 |
|
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
528 |
pi = i->last_month_pct_transported[0] * 100 >> 8; |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
529 |
if (ind_i->produced_cargo[1] != CT_INVALID) { |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
530 |
int p = i->last_month_pct_transported[1] * 100 >> 8; |
4282
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
531 |
if (p < pi) pi = p; |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
532 |
} |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
533 |
|
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
534 |
pj = j->last_month_pct_transported[0] * 100 >> 8; |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
535 |
if (ind_j->produced_cargo[1] != CT_INVALID) { |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
536 |
int p = j->last_month_pct_transported[1] * 100 >> 8; |
4282
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
537 |
if (p < pj) pj = p; |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
538 |
} |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
539 |
|
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
540 |
r = pi - pj; |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
541 |
} |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
542 |
} |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
543 |
break; |
0 | 544 |
} |
545 |
||
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6200
diff
changeset
|
546 |
/* default to string sorting if they are otherwise equal */ |
0 | 547 |
if (r == 0) { |
4282
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
548 |
char buf1[96]; |
9394aef5b65b
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
tron
parents:
4277
diff
changeset
|
549 |
|
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
550 |
SetDParam(0, i->town->index); |
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4896
diff
changeset
|
551 |
GetString(buf1, STR_TOWN, lastof(buf1)); |
0 | 552 |
|
4277
345e1bd9525a
(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
|
553 |
if (j != _last_industry) { |
345e1bd9525a
(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
|
554 |
_last_industry = j; |
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
555 |
SetDParam(0, j->town->index); |
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4896
diff
changeset
|
556 |
GetString(_bufcache, STR_TOWN, lastof(_bufcache)); |
0 | 557 |
} |
558 |
r = strcmp(buf1, _bufcache); |
|
559 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
560 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
561 |
if (_industry_sort_order & 1) r = -r; |
0 | 562 |
return r; |
563 |
} |
|
564 |
||
6200
10efd7fb90d4
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
rubidium
parents:
6091
diff
changeset
|
565 |
/** |
10efd7fb90d4
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
rubidium
parents:
6091
diff
changeset
|
566 |
* Makes a sorted industry list. |
10efd7fb90d4
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
rubidium
parents:
6091
diff
changeset
|
567 |
* When there are no industries, the list has to be made. This so when one |
10efd7fb90d4
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
rubidium
parents:
6091
diff
changeset
|
568 |
* starts a new game without industries after playing a game with industries |
10efd7fb90d4
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
rubidium
parents:
6091
diff
changeset
|
569 |
* the list is not populated with invalid industries from the previous game. |
10efd7fb90d4
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
rubidium
parents:
6091
diff
changeset
|
570 |
*/ |
6247 | 571 |
static void MakeSortedIndustryList() |
0 | 572 |
{ |
4277
345e1bd9525a
(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 |
const Industry* i; |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
574 |
int n = 0; |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
575 |
|
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
576 |
/* Create array for sorting */ |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5601
diff
changeset
|
577 |
_industry_sort = ReallocT(_industry_sort, GetMaxIndustryIndex() + 1); |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5247
diff
changeset
|
578 |
if (_industry_sort == NULL) error("Could not allocate memory for the industry-sorting-list"); |
0 | 579 |
|
6200
10efd7fb90d4
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
rubidium
parents:
6091
diff
changeset
|
580 |
/* Don't attempt a sort if there are no industries */ |
10efd7fb90d4
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
rubidium
parents:
6091
diff
changeset
|
581 |
if (GetNumIndustries() != 0) { |
10efd7fb90d4
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
rubidium
parents:
6091
diff
changeset
|
582 |
FOR_ALL_INDUSTRIES(i) _industry_sort[n++] = i; |
10efd7fb90d4
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
rubidium
parents:
6091
diff
changeset
|
583 |
qsort((void*)_industry_sort, n, sizeof(_industry_sort[0]), GeneralIndustrySorter); |
10efd7fb90d4
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
rubidium
parents:
6091
diff
changeset
|
584 |
} |
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
585 |
|
0 | 586 |
_num_industry_sort = n; |
4277
345e1bd9525a
(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
|
587 |
_last_industry = NULL; // used for "cache" |
0 | 588 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5247
diff
changeset
|
589 |
DEBUG(misc, 3, "Resorting industries list"); |
0 | 590 |
} |
591 |
||
592 |
||
593 |
static void IndustryDirectoryWndProc(Window *w, WindowEvent *e) |
|
594 |
{ |
|
2951 | 595 |
switch (e->event) { |
0 | 596 |
case WE_PAINT: { |
597 |
int n; |
|
598 |
uint p; |
|
599 |
static const uint16 _indicator_positions[4] = {88, 187, 284, 387}; |
|
600 |
||
601 |
if (_industry_sort_dirty) { |
|
602 |
_industry_sort_dirty = false; |
|
603 |
MakeSortedIndustryList(); |
|
604 |
} |
|
605 |
||
1666
46dc094142b1
(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
|
606 |
SetVScrollCount(w, _num_industry_sort); |
0 | 607 |
|
608 |
DrawWindowWidgets(w); |
|
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
609 |
DoDrawString(_industry_sort_order & 1 ? DOWNARROW : UPARROW, _indicator_positions[_industry_sort_order >> 1], 15, 0x10); |
0 | 610 |
|
611 |
p = w->vscroll.pos; |
|
612 |
n = 0; |
|
613 |
||
614 |
while (p < _num_industry_sort) { |
|
4277
345e1bd9525a
(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
|
615 |
const Industry* i = _industry_sort[p]; |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
616 |
const IndustrySpec *ind = GetIndustrySpec(i->type); |
2989 | 617 |
|
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
618 |
SetDParam(0, i->index); |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
619 |
if (ind->produced_cargo[0] != CT_INVALID) { |
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
620 |
SetDParam(1, ind->produced_cargo[0]); |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
621 |
SetDParam(2, i->last_month_production[0]); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
622 |
|
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
623 |
if (ind->produced_cargo[1] != CT_INVALID) { |
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6624
diff
changeset
|
624 |
SetDParam(3, ind->produced_cargo[1]); |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
625 |
SetDParam(4, i->last_month_production[1]); |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
626 |
SetDParam(5, i->last_month_pct_transported[0] * 100 >> 8); |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
627 |
SetDParam(6, i->last_month_pct_transported[1] * 100 >> 8); |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
628 |
DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM_TWO, 0); |
0 | 629 |
} else { |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
630 |
SetDParam(3, i->last_month_pct_transported[0] * 100 >> 8); |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
631 |
DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM, 0); |
0 | 632 |
} |
633 |
} else { |
|
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
634 |
DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM_NOPROD, 0); |
0 | 635 |
} |
636 |
p++; |
|
2951 | 637 |
if (++n == w->vscroll.cap) break; |
0 | 638 |
} |
639 |
} break; |
|
640 |
||
641 |
case WE_CLICK: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
642 |
switch (e->we.click.widget) { |
758
423ae0bcba07
(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
|
643 |
case 3: { |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
644 |
_industry_sort_order = _industry_sort_order == 0 ? 1 : 0; |
0 | 645 |
_industry_sort_dirty = true; |
646 |
SetWindowDirty(w); |
|
647 |
} break; |
|
648 |
||
758
423ae0bcba07
(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
|
649 |
case 4: { |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
650 |
_industry_sort_order = _industry_sort_order == 2 ? 3 : 2; |
0 | 651 |
_industry_sort_dirty = true; |
652 |
SetWindowDirty(w); |
|
653 |
} break; |
|
654 |
||
758
423ae0bcba07
(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
|
655 |
case 5: { |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
656 |
_industry_sort_order = _industry_sort_order == 4 ? 5 : 4; |
0 | 657 |
_industry_sort_dirty = true; |
658 |
SetWindowDirty(w); |
|
659 |
} break; |
|
660 |
||
758
423ae0bcba07
(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
|
661 |
case 6: { |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6247
diff
changeset
|
662 |
_industry_sort_order = _industry_sort_order == 6 ? 7 : 6; |
0 | 663 |
_industry_sort_dirty = true; |
664 |
SetWindowDirty(w); |
|
665 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
666 |
|
758
423ae0bcba07
(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
|
667 |
case 8: { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
668 |
int y = (e->we.click.pt.y - 28) / 10; |
821
60524daa442c
(svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
truelight
parents:
758
diff
changeset
|
669 |
uint16 p; |
0 | 670 |
|
2989 | 671 |
if (!IS_INT_INSIDE(y, 0, w->vscroll.cap)) return; |
0 | 672 |
p = y + w->vscroll.pos; |
673 |
if (p < _num_industry_sort) { |
|
4277
345e1bd9525a
(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
|
674 |
ScrollMainWindowToTile(_industry_sort[p]->xy); |
0 | 675 |
} |
676 |
} break; |
|
677 |
} |
|
678 |
break; |
|
679 |
||
680 |
case WE_4: |
|
681 |
SetWindowDirty(w); |
|
682 |
break; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
683 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
684 |
case WE_RESIZE: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4617
diff
changeset
|
685 |
w->vscroll.cap += e->we.sizing.diff.y / 10; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
686 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
687 |
} |
0 | 688 |
} |
689 |
||
690 |
||
691 |
/* Industry List */ |
|
692 |
static const WindowDesc _industry_directory_desc = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
693 |
WDP_AUTO, WDP_AUTO, 508, 190, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5609
diff
changeset
|
694 |
WC_INDUSTRY_DIRECTORY, WC_NONE, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
695 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 696 |
_industry_directory_widgets, |
697 |
IndustryDirectoryWndProc |
|
698 |
}; |
|
699 |
||
700 |
||
6247 | 701 |
void ShowIndustryDirectory() |
0 | 702 |
{ |
4171 | 703 |
Window *w = AllocateWindowDescFront(&_industry_directory_desc, 0); |
0 | 704 |
|
2989 | 705 |
if (w != NULL) { |
0 | 706 |
w->vscroll.cap = 16; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
707 |
w->resize.height = w->height - 6 * 10; // minimum 10 items |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
708 |
w->resize.step_height = 10; |
0 | 709 |
SetWindowDirty(w); |
710 |
} |
|
711 |
} |