author | tron |
Fri, 29 Jul 2005 18:22:04 +0000 | |
changeset 2230 | e461b07aead7 |
parent 2186 | db48cf29b983 |
child 2406 | 8c873205483a |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1786
diff
changeset
|
4 |
#include "openttd.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1287
diff
changeset
|
5 |
#include "debug.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
6 |
#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
|
7 |
#include "strings.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
222
diff
changeset
|
8 |
#include "table/strings.h" |
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
9 |
#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
|
10 |
#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
|
11 |
#include "gui.h" |
0 | 12 |
#include "window.h" |
13 |
#include "gfx.h" |
|
14 |
#include "command.h" |
|
15 |
#include "viewport.h" |
|
16 |
#include "industry.h" |
|
17 |
#include "town.h" |
|
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2084
diff
changeset
|
18 |
#include "variables.h" |
0 | 19 |
|
1786
7cfd46c3fcc4
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1666
diff
changeset
|
20 |
/* Present in table/build_industry.h" */ |
7cfd46c3fcc4
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1666
diff
changeset
|
21 |
extern const byte _build_industry_types[4][12]; |
0 | 22 |
extern const byte _industry_type_costs[37]; |
23 |
||
1004 | 24 |
static void UpdateIndustryProduction(Industry *i); |
25 |
extern void DrawArrowButtons(int x, int y, int state); |
|
26 |
||
0 | 27 |
static void BuildIndustryWndProc(Window *w, WindowEvent *e) |
28 |
{ |
|
29 |
switch(e->event) { |
|
30 |
case WE_PAINT: |
|
31 |
DrawWindowWidgets(w); |
|
32 |
if (_thd.place_mode == 1 && _thd.window_class == WC_BUILD_INDUSTRY) { |
|
1786
7cfd46c3fcc4
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1666
diff
changeset
|
33 |
int ind_type = _build_industry_types[_opt_ptr->landscape][WP(w,def_d).data_1]; |
0 | 34 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
35 |
SetDParam(0, (_price.build_industry >> 5) * _industry_type_costs[ind_type]); |
0 | 36 |
DrawStringCentered(85, w->height - 21, STR_482F_COST, 0); |
37 |
} |
|
38 |
break; |
|
39 |
||
40 |
case WE_CLICK: { |
|
41 |
int wid = e->click.widget; |
|
42 |
if (wid >= 3) { |
|
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
43 |
if (HandlePlacePushButton(w, wid, SPR_CURSOR_INDUSTRY, 1, NULL)) |
0 | 44 |
WP(w,def_d).data_1 = wid - 3; |
45 |
} |
|
46 |
} break; |
|
47 |
||
48 |
case WE_PLACE_OBJ: |
|
1786
7cfd46c3fcc4
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1666
diff
changeset
|
49 |
if (DoCommandP(e->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 | 50 |
ResetObjectToPlace(); |
51 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
52 |
|
0 | 53 |
case WE_ABORT_PLACE_OBJ: |
54 |
w->click_state = 0; |
|
55 |
SetWindowDirty(w); |
|
56 |
break; |
|
57 |
} |
|
58 |
} |
|
59 |
||
60 |
static const Widget _build_industry_land0_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
61 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
62 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
63 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
64 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
65 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 29, 40, STR_0242_SAWMILL, STR_0264_CONSTRUCT_SAWMILL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
66 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
67 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
68 |
{ WWT_CLOSEBOX, 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
|
69 |
{ WIDGETS_END}, |
0 | 70 |
}; |
71 |
||
72 |
static const Widget _build_industry_land1_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
73 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
74 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
75 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
76 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
77 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024C_PAPER_MILL, STR_026E_CONSTRUCT_PAPER_MILL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
78 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
79 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 55, 66, STR_024D_FOOD_PROCESSING_PLANT,STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
80 |
{ WWT_CLOSEBOX, 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
|
81 |
{ WIDGETS_END}, |
0 | 82 |
}; |
83 |
||
84 |
static const Widget _build_industry_land2_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
85 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
86 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
87 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
88 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0250_LUMBER_MILL, STR_0273_CONSTRUCT_LUMBER_MILL_TO}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
89 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024D_FOOD_PROCESSING_PLANT,STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
90 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
91 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
92 |
{ WWT_CLOSEBOX, 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
|
93 |
{ WIDGETS_END}, |
0 | 94 |
}; |
95 |
||
96 |
static const Widget _build_industry_land3_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
97 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
98 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
99 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
100 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0258_CANDY_FACTORY, STR_027B_CONSTRUCT_CANDY_FACTORY}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
101 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 29, 40, STR_025B_TOY_SHOP, STR_027E_CONSTRUCT_TOY_SHOP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
102 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 42, 53, STR_025C_TOY_FACTORY, STR_027F_CONSTRUCT_TOY_FACTORY}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
103 |
{ WWT_CLOSEBOX, 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
|
104 |
{ WIDGETS_END}, |
0 | 105 |
}; |
106 |
||
107 |
static const Widget _build_industry_land0_widgets_extra[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
108 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
109 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY,STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
110 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 187, 0x0, STR_NULL}, |
0 | 111 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
112 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION,STR_0263_CONSTRUCT_POWER_STATION}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
113 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 29, 40, STR_0242_SAWMILL, STR_0264_CONSTRUCT_SAWMILL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
114 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
115 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
116 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0247_STEEL_MILL, STR_0269_CONSTRUCT_STEEL_MILL}, |
0 | 117 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
118 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 84, 95, STR_0240_COAL_MINE, STR_CONSTRUCT_COAL_MINE_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
119 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 97, 108, STR_0243_FOREST, STR_CONSTRUCT_FOREST_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
120 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 110, 121, STR_0245_OIL_RIG, STR_CONSTRUCT_OIL_RIG_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
121 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 123, 134, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
122 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 136, 147, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
123 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 149, 160, STR_0249_IRON_ORE_MINE, STR_CONSTRUCT_IRON_ORE_MINE_TIP}, |
0 | 124 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
125 |
{ WIDGETS_END}, |
0 | 126 |
}; |
127 |
||
128 |
static const Widget _build_industry_land1_widgets_extra[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
129 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
130 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
131 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 174, 0x0, STR_NULL}, |
0 | 132 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
133 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
134 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024C_PAPER_MILL, STR_026E_CONSTRUCT_PAPER_MILL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
135 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
136 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 55, 66, STR_024D_FOOD_PROCESSING_PLANT,STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
137 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 68, 79, STR_024E_PRINTING_WORKS, STR_0270_CONSTRUCT_PRINTING_WORKS}, |
0 | 138 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
139 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 81+3, 92+3, STR_0240_COAL_MINE, STR_CONSTRUCT_COAL_MINE_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
140 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 94+3, 105+3, STR_0243_FOREST, STR_CONSTRUCT_FOREST_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
141 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 107+3, 118+3, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
142 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 120+3, 131+3, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
143 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 133+3, 144+3, 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
|
144 |
{ WIDGETS_END}, |
0 | 145 |
}; |
146 |
||
147 |
static const Widget _build_industry_land2_widgets_extra[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
148 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
149 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
150 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 200, 0x0, STR_NULL}, |
0 | 151 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
152 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0250_LUMBER_MILL, STR_0273_CONSTRUCT_LUMBER_MILL_TO}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
153 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024D_FOOD_PROCESSING_PLANT,STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
154 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
155 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
156 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0254_WATER_TOWER, STR_0277_CONSTRUCT_WATER_TOWER_CAN}, |
0 | 157 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
158 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 81+3, 92+3, STR_024A_OIL_WELLS,STR_CONSTRUCT_OIL_WELLS_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
159 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 94+3, 105+3, STR_0255_DIAMOND_MINE, STR_CONSTRUCT_DIAMOND_MINE_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
160 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 107+3, 118+3, STR_0256_COPPER_ORE_MINE, STR_CONSTRUCT_COPPER_ORE_MINE_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
161 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 120+3, 131+3, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
162 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 133+3, 144+3, STR_0251_FRUIT_PLANTATION, STR_CONSTRUCT_FRUIT_PLANTATION_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
163 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 146+3, 157+3, STR_0252_RUBBER_PLANTATION,STR_CONSTRUCT_RUBBER_PLANTATION_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
164 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 159+3, 170+3, 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
|
165 |
{ WIDGETS_END}, |
0 | 166 |
}; |
167 |
||
168 |
static const Widget _build_industry_land3_widgets_extra[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
169 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
170 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
171 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 187, 0x0, STR_NULL}, |
0 | 172 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
173 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0258_CANDY_FACTORY, STR_027B_CONSTRUCT_CANDY_FACTORY}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
174 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 29, 40, STR_025B_TOY_SHOP, STR_027E_CONSTRUCT_TOY_SHOP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
175 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 42, 53, STR_025C_TOY_FACTORY, STR_027F_CONSTRUCT_TOY_FACTORY}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
176 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 55, 66, STR_025E_FIZZY_DRINK_FACTORY, STR_0281_CONSTRUCT_FIZZY_DRINK_FACTORY}, |
0 | 177 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
178 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 68+3, 79+3, STR_0257_COTTON_CANDY_FOREST,STR_CONSTRUCT_COTTON_CANDY_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
179 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 81+3, 92+3, STR_0259_BATTERY_FARM, STR_CONSTRUCT_BATTERY_FARM_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
180 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 94+3, 105+3, STR_025A_COLA_WELLS, STR_CONSTRUCT_COLA_WELLS_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
181 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 107+3, 118+3, STR_025D_PLASTIC_FOUNTAINS,STR_CONSTRUCT_PLASTIC_FOUNTAINS_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
182 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 120+3, 131+3, STR_025F_BUBBLE_GENERATOR, STR_CONSTRUCT_BUBBLE_GENERATOR_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
183 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 133+3, 144+3, STR_0260_TOFFEE_QUARRY, STR_CONSTRUCT_TOFFEE_QUARRY_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
184 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 2, 167, 146+3, 157+3, 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
|
185 |
{ WIDGETS_END}, |
0 | 186 |
}; |
187 |
||
188 |
||
189 |
static const WindowDesc _build_industry_land0_desc = { |
|
190 |
-1, -1, 170, 116, |
|
191 |
WC_BUILD_INDUSTRY,0, |
|
192 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
193 |
_build_industry_land0_widgets, |
|
194 |
BuildIndustryWndProc |
|
195 |
}; |
|
196 |
||
197 |
static const WindowDesc _build_industry_land1_desc = { |
|
198 |
-1, -1, 170, 116, |
|
199 |
WC_BUILD_INDUSTRY,0, |
|
200 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
201 |
_build_industry_land1_widgets, |
|
202 |
BuildIndustryWndProc |
|
203 |
}; |
|
204 |
||
205 |
static const WindowDesc _build_industry_land2_desc = { |
|
206 |
-1, -1, 170, 116, |
|
207 |
WC_BUILD_INDUSTRY,0, |
|
208 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
209 |
_build_industry_land2_widgets, |
|
210 |
BuildIndustryWndProc |
|
211 |
}; |
|
212 |
||
213 |
static const WindowDesc _build_industry_land3_desc = { |
|
214 |
-1, -1, 170, 116, |
|
215 |
WC_BUILD_INDUSTRY,0, |
|
216 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
217 |
_build_industry_land3_widgets, |
|
218 |
BuildIndustryWndProc |
|
219 |
}; |
|
220 |
||
221 |
static const WindowDesc _build_industry_land0_desc_extra = { |
|
222 |
-1, -1, 170, 188, |
|
223 |
WC_BUILD_INDUSTRY,0, |
|
224 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
225 |
_build_industry_land0_widgets_extra, |
|
226 |
BuildIndustryWndProc |
|
227 |
}; |
|
228 |
||
229 |
static const WindowDesc _build_industry_land1_desc_extra = { |
|
230 |
-1, -1, 170, 175, |
|
231 |
WC_BUILD_INDUSTRY,0, |
|
232 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
233 |
_build_industry_land1_widgets_extra, |
|
234 |
BuildIndustryWndProc |
|
235 |
}; |
|
236 |
||
237 |
static const WindowDesc _build_industry_land2_desc_extra = { |
|
238 |
-1, -1, 170, 201, |
|
239 |
WC_BUILD_INDUSTRY,0, |
|
240 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
241 |
_build_industry_land2_widgets_extra, |
|
242 |
BuildIndustryWndProc |
|
243 |
}; |
|
244 |
||
245 |
static const WindowDesc _build_industry_land3_desc_extra = { |
|
246 |
-1, -1, 170, 188, |
|
247 |
WC_BUILD_INDUSTRY,0, |
|
248 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
249 |
_build_industry_land3_widgets_extra, |
|
250 |
BuildIndustryWndProc |
|
251 |
}; |
|
252 |
||
253 |
static const WindowDesc * const _industry_window_desc[2][4] = { |
|
254 |
{ |
|
255 |
&_build_industry_land0_desc, |
|
256 |
&_build_industry_land1_desc, |
|
257 |
&_build_industry_land2_desc, |
|
258 |
&_build_industry_land3_desc, |
|
259 |
}, |
|
260 |
{ |
|
261 |
&_build_industry_land0_desc_extra, |
|
262 |
&_build_industry_land1_desc_extra, |
|
263 |
&_build_industry_land2_desc_extra, |
|
264 |
&_build_industry_land3_desc_extra, |
|
265 |
}, |
|
266 |
}; |
|
267 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1019
diff
changeset
|
268 |
void ShowBuildIndustryWindow(void) |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
269 |
{ |
1786
7cfd46c3fcc4
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1666
diff
changeset
|
270 |
AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt_ptr->landscape],0); |
0 | 271 |
} |
272 |
||
1388
ee6b7233e4b1
(svn r1892) -Fix: [ 1117730 ] Production values of temperate-climate banks can now be altered
celestar
parents:
1386
diff
changeset
|
273 |
#define NEED_ALTERB ((_game_mode == GM_EDITOR || _cheats.setup_prod.value) && (i->accepts_cargo[0] == CT_INVALID || i->accepts_cargo[0] == CT_VALUABLES)) |
0 | 274 |
static void IndustryViewWndProc(Window *w, WindowEvent *e) |
275 |
{ |
|
1004 | 276 |
// WP(w,vp2_d).data_1 is for the editbox line |
277 |
// WP(w,vp2_d).data_2 is for the clickline |
|
278 |
// WP(w,vp2_d).data_3 is for the click pos (left or right) |
|
0 | 279 |
|
280 |
switch(e->event) { |
|
1004 | 281 |
case WE_PAINT: { |
282 |
const Industry *i; |
|
283 |
StringID str; |
|
0 | 284 |
// in editor, use bulldoze to destroy industry |
285 |
// Destroy Industry button costing money removed per request of dominik |
|
286 |
//w->disabled_state = (_patches.extra_dynamite && !_networking && _game_mode != GM_EDITOR) ? 0 : (1 << 6); |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
287 |
i = GetIndustry(w->window_number); |
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
288 |
SetDParam(0, w->window_number); |
0 | 289 |
DrawWindowWidgets(w); |
290 |
||
1004 | 291 |
if (i->accepts_cargo[0] != CT_INVALID) { |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
292 |
SetDParam(0, _cargoc.names_s[i->accepts_cargo[0]]); |
0 | 293 |
str = STR_4827_REQUIRES; |
1004 | 294 |
if (i->accepts_cargo[1] != CT_INVALID) { |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
295 |
SetDParam(1, _cargoc.names_s[i->accepts_cargo[1]]); |
0 | 296 |
str++; |
1004 | 297 |
if (i->accepts_cargo[2] != CT_INVALID) { |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
298 |
SetDParam(2, _cargoc.names_s[i->accepts_cargo[2]]); |
0 | 299 |
str++; |
300 |
} |
|
301 |
} |
|
302 |
DrawString(2, 107, str, 0); |
|
303 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
304 |
|
1004 | 305 |
if (i->produced_cargo[0] != CT_INVALID) { |
0 | 306 |
DrawString(2, 117, STR_482A_PRODUCTION_LAST_MONTH, 0); |
307 |
||
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2070
diff
changeset
|
308 |
SetDParam(0, _cargoc.names_long[i->produced_cargo[0]]); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
309 |
SetDParam(1, i->total_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
|
310 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
311 |
SetDParam(2, i->pct_transported[0] * 100 >> 8); |
1004 | 312 |
DrawString(4 + (NEED_ALTERB ? 30 : 0), 127, STR_482B_TRANSPORTED, 0); |
313 |
// Let's put out those buttons.. |
|
314 |
if (NEED_ALTERB) |
|
315 |
DrawArrowButtons(5, 127, (WP(w,vp2_d).data_2 == 1 ? WP(w,vp2_d).data_3 : 0)); |
|
0 | 316 |
|
1004 | 317 |
if (i->produced_cargo[1] != CT_INVALID) { |
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2070
diff
changeset
|
318 |
SetDParam(0, _cargoc.names_long[i->produced_cargo[1]]); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
319 |
SetDParam(1, i->total_production[1]); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
320 |
SetDParam(2, i->pct_transported[1] * 100 >> 8); |
1004 | 321 |
DrawString(4 + (NEED_ALTERB ? 30 : 0), 137, STR_482B_TRANSPORTED, 0); |
322 |
// Let's put out those buttons.. |
|
323 |
if (NEED_ALTERB) |
|
324 |
DrawArrowButtons(5, 137, (WP(w,vp2_d).data_2 == 2 ? WP(w,vp2_d).data_3 : 0)); |
|
0 | 325 |
} |
326 |
} |
|
327 |
||
328 |
DrawWindowViewport(w); |
|
1004 | 329 |
} |
0 | 330 |
break; |
331 |
||
1004 | 332 |
case WE_CLICK: { |
333 |
Industry *i; |
|
334 |
||
0 | 335 |
switch(e->click.widget) { |
1004 | 336 |
case 5: { |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
337 |
int line; |
1004 | 338 |
int x; |
339 |
byte b; |
|
340 |
||
341 |
i = GetIndustry(w->window_number); |
|
342 |
||
1176
cc9d8618620d
(svn r1678) Added cheat option for setting production of raw-material product industries in game
miham
parents:
1093
diff
changeset
|
343 |
// We should work if needed.. |
cc9d8618620d
(svn r1678) Added cheat option for setting production of raw-material product industries in game
miham
parents:
1093
diff
changeset
|
344 |
if (!NEED_ALTERB) |
1004 | 345 |
return; |
346 |
||
347 |
x = e->click.pt.x; |
|
348 |
line = (e->click.pt.y - 127) / 10; |
|
349 |
if (e->click.pt.y >= 127 && IS_INT_INSIDE(line, 0, 2) && i->produced_cargo[line]) { |
|
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
350 |
if (IS_INT_INSIDE(x, 5, 25) ) { |
1004 | 351 |
// clicked buttons |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
352 |
if (x < 15) { |
1004 | 353 |
// decrease |
354 |
i->production_rate[line] /= 2; |
|
355 |
if (i->production_rate[line] < 4) |
|
356 |
i->production_rate[line] = 4; |
|
357 |
} else { |
|
358 |
// increase |
|
359 |
b = i->production_rate[line] * 2; |
|
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
360 |
if (i->production_rate[line] >= 128) |
1004 | 361 |
b=255; |
362 |
i->production_rate[line] = b; |
|
363 |
} |
|
364 |
UpdateIndustryProduction(i); |
|
365 |
SetWindowDirty(w); |
|
366 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
|
367 |
WP(w,vp2_d).data_2 = line+1; |
|
368 |
WP(w,vp2_d).data_3 = (x < 15 ? 1 : 2); |
|
369 |
} else if (IS_INT_INSIDE(x, 34, 160)) { |
|
370 |
// clicked the text |
|
371 |
WP(w,vp2_d).data_1 = line; |
|
372 |
SetDParam(0, i->production_rate[line] * 8); |
|
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
373 |
ShowQueryString(STR_CONFIG_PATCHES_INT32, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
374 |
STR_CONFIG_GAME_PRODUCTION, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
375 |
10, 100, w->window_class, |
1004 | 376 |
w->window_number); |
377 |
} |
|
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1004
diff
changeset
|
378 |
} |
1004 | 379 |
} |
380 |
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
|
381 |
case 6: |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
382 |
i = GetIndustry(w->window_number); |
1981 | 383 |
ScrollMainWindowToTile(i->xy + TileDiffXY(1, 1)); |
0 | 384 |
break; |
385 |
} |
|
1004 | 386 |
} |
0 | 387 |
break; |
1004 | 388 |
case WE_TIMEOUT: |
389 |
WP(w,vp2_d).data_2 = 0; |
|
390 |
WP(w,vp2_d).data_3 = 0; |
|
391 |
SetWindowDirty(w); |
|
392 |
break; |
|
393 |
||
394 |
case WE_ON_EDIT_TEXT: |
|
395 |
if (*e->edittext.str) { |
|
396 |
Industry *i; |
|
397 |
int val; |
|
398 |
int line; |
|
399 |
||
400 |
i = GetIndustry(w->window_number); |
|
401 |
line = WP(w,vp2_d).data_1; |
|
402 |
val = atoi(e->edittext.str); |
|
403 |
if (!IS_INT_INSIDE(val, 32, 2040)) { |
|
404 |
if (val < 32) val = 32; |
|
405 |
else val = 2040; |
|
406 |
} |
|
407 |
i->production_rate[line] = (byte)(val / 8); |
|
408 |
UpdateIndustryProduction(i); |
|
409 |
SetWindowDirty(w); |
|
410 |
} |
|
0 | 411 |
} |
412 |
} |
|
413 |
||
1004 | 414 |
static void UpdateIndustryProduction(Industry *i) |
415 |
{ |
|
416 |
if (i->produced_cargo[0] != CT_INVALID) |
|
417 |
i->total_production[0] = 8 * i->production_rate[0]; |
|
418 |
||
419 |
if (i->produced_cargo[1] != CT_INVALID) |
|
420 |
i->total_production[1] = 8 * i->production_rate[1]; |
|
421 |
} |
|
422 |
||
0 | 423 |
static const Widget _industry_view_widgets[] = { |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
424 |
{ WWT_TEXTBTN, RESIZE_NONE, 9, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
425 |
{ WWT_CAPTION, RESIZE_NONE, 9, 11, 247, 0, 13, STR_4801, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
426 |
{ WWT_STICKYBOX, RESIZE_NONE, 9, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
427 |
{ WWT_IMGBTN, RESIZE_NONE, 9, 0, 259, 14, 105, 0x0, STR_NULL}, |
1004 | 428 |
{ WWT_6, RESIZE_NONE, 9, 2, 257, 16, 103, 0x0, STR_NULL}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
429 |
{ WWT_IMGBTN, RESIZE_NONE, 9, 0, 259, 106, 147, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
430 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 9, 0, 129, 148, 159, STR_00E4_LOCATION, STR_482C_CENTER_THE_MAIN_VIEW_ON}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
431 |
{ WWT_IMGBTN, RESIZE_NONE, 9, 130, 259, 148, 159, 0x0, STR_NULL}, |
0 | 432 |
// Destroy Industry button costing money removed per request of dominik |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
433 |
//{ WWT_PUSHTXTBTN, RESIZE_NONE, 9, 130, 259, 148, 159, STR_INDUSTRYDIR_DESTROY, STR_482C_DESTROY_INDUSTRY}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
434 |
{ WIDGETS_END}, |
0 | 435 |
}; |
436 |
||
437 |
static const WindowDesc _industry_view_desc = { |
|
438 |
-1, -1, 260, 160, |
|
439 |
WC_INDUSTRY_VIEW,0, |
|
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
|
440 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 441 |
_industry_view_widgets, |
442 |
IndustryViewWndProc |
|
443 |
}; |
|
444 |
||
445 |
void ShowIndustryViewWindow(int industry) |
|
446 |
{ |
|
447 |
Window *w; |
|
448 |
Industry *i; |
|
449 |
||
450 |
w = AllocateWindowDescFront(&_industry_view_desc, industry); |
|
451 |
if (w) { |
|
452 |
w->flags4 |= WF_DISABLE_VP_SCROLL; |
|
1004 | 453 |
WP(w,vp2_d).data_1 = 0; |
454 |
WP(w,vp2_d).data_2 = 0; |
|
455 |
WP(w,vp2_d).data_3 = 0; |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
456 |
i = GetIndustry(w->window_number); |
1981 | 457 |
AssignWindowViewport(w, 3, 17, 0xFE, 0x56, i->xy + TileDiffXY(1, 1), 1); |
0 | 458 |
} |
459 |
} |
|
460 |
||
461 |
static const Widget _industry_directory_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
462 |
{ WWT_TEXTBTN, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
463 |
{ WWT_CAPTION, RESIZE_NONE, 13, 11, 495, 0, 13, STR_INDUSTRYDIR_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
464 |
{ WWT_STICKYBOX, RESIZE_NONE, 13, 496, 507, 0, 13, 0x0, STR_STICKY_BUTTON}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
465 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 100, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
466 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 101, 200, 14, 25, STR_SORT_BY_TYPE, STR_SORT_ORDER_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
467 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 201, 300, 14, 25, STR_SORT_BY_PRODUCTION, STR_SORT_ORDER_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
468 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 301, 400, 14, 25, STR_SORT_BY_TRANSPORTED, STR_SORT_ORDER_TIP}, |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
867
diff
changeset
|
469 |
{ WWT_PANEL, RESIZE_NONE, 13, 401, 495, 14, 25, 0x0, STR_NULL}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
867
diff
changeset
|
470 |
{ WWT_IMGBTN, RESIZE_BOTTOM, 13, 0, 495, 26, 189, 0x0, STR_200A_TOWN_NAMES_CLICK_ON_NAME}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
867
diff
changeset
|
471 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 13, 496, 507, 14, 177, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
867
diff
changeset
|
472 |
{ 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
|
473 |
{ WIDGETS_END}, |
0 | 474 |
}; |
475 |
||
476 |
static uint _num_industry_sort; |
|
477 |
||
478 |
static char _bufcache[96]; |
|
821
60524daa442c
(svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
truelight
parents:
758
diff
changeset
|
479 |
static uint16 _last_industry_idx; |
0 | 480 |
|
481 |
static byte _industry_sort_order; |
|
482 |
||
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
|
483 |
static int CDECL GeneralIndustrySorter(const void *a, const void *b) |
0 | 484 |
{ |
485 |
char buf1[96]; |
|
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1176
diff
changeset
|
486 |
uint16 val; |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
487 |
Industry *i = GetIndustry(*(const uint16*)a); |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
488 |
Industry *j = GetIndustry(*(const uint16*)b); |
0 | 489 |
int r = 0; |
490 |
||
491 |
switch (_industry_sort_order >> 1) { |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
492 |
/* case 0: Sort by Name (handled later) */ |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
493 |
case 1: /* Sort by Type */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
494 |
r = i->type - j->type; |
0 | 495 |
break; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
496 |
// FIXME - Production & Transported sort need to be inversed...but, WTF it does not wanna! |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
497 |
// FIXME - And no simple --> "if (!(_industry_sort_order & 1)) r = -r;" hack at the bottom!! |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
498 |
case 2: { /* Sort by Production */ |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
499 |
if (i->produced_cargo[0] != 0xFF && j->produced_cargo[0] != 0xFF) { // both industries produce cargo? |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
500 |
if (i->produced_cargo[1] == 0xFF) // producing one or two things? |
0 | 501 |
r = j->total_production[0] - i->total_production[0]; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
502 |
else |
0 | 503 |
r = (j->total_production[0] + j->total_production[1]) / 2 - (i->total_production[0] + i->total_production[1]) / 2; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
504 |
} else if (i->produced_cargo[0] == 0xFF && j->produced_cargo[0] == 0xFF) // none of them producing anything, let them go to the name-sorting |
0 | 505 |
r = 0; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
506 |
else if (i->produced_cargo[0] == 0xFF) // end up the non-producer industry first/last in list |
0 | 507 |
r = 1; |
508 |
else |
|
509 |
r = -1; |
|
510 |
break; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
511 |
} |
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
|
512 |
case 3: /* Sort by Transported amount */ |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
513 |
if (i->produced_cargo[0] != 0xFF && j->produced_cargo[0] != 0xFF) { // both industries produce cargo? |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
514 |
if (i->produced_cargo[1] == 0xFF) // producing one or two things? |
0 | 515 |
r = (j->pct_transported[0] * 100 >> 8) - (i->pct_transported[0] * 100 >> 8); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
516 |
else |
0 | 517 |
r = ((j->pct_transported[0] * 100 >> 8) + (j->pct_transported[1] * 100 >> 8)) / 2 - ((i->pct_transported[0] * 100 >> 8) + (i->pct_transported[1] * 100 >> 8)) / 2; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
518 |
} else if (i->produced_cargo[0] == 0xFF && j->produced_cargo[0] == 0xFF) // none of them producing anything, let them go to the name-sorting |
0 | 519 |
r = 0; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
520 |
else if (i->produced_cargo[0] == 0xFF) // end up the non-producer industry first/last in list |
0 | 521 |
r = 1; |
522 |
else |
|
523 |
r = -1; |
|
524 |
break; |
|
525 |
} |
|
526 |
||
527 |
// default to string sorting if they are otherwise equal |
|
528 |
if (r == 0) { |
|
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
529 |
SetDParam(0, i->town->index); |
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
530 |
GetString(buf1, STR_TOWN); |
0 | 531 |
|
821
60524daa442c
(svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
truelight
parents:
758
diff
changeset
|
532 |
if ( (val=*(const uint16*)b) != _last_industry_idx) { |
0 | 533 |
_last_industry_idx = val; |
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
534 |
SetDParam(0, j->town->index); |
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
535 |
GetString(_bufcache, STR_TOWN); |
0 | 536 |
} |
537 |
r = strcmp(buf1, _bufcache); |
|
538 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
539 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
540 |
if (_industry_sort_order & 1) r = -r; |
0 | 541 |
return r; |
542 |
} |
|
543 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1019
diff
changeset
|
544 |
static void MakeSortedIndustryList(void) |
0 | 545 |
{ |
546 |
Industry *i; |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
547 |
int n = 0; |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
548 |
|
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
549 |
/* Create array for sorting */ |
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1176
diff
changeset
|
550 |
_industry_sort = realloc(_industry_sort, GetIndustryPoolSize() * sizeof(_industry_sort[0])); |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
551 |
if (_industry_sort == NULL) |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
552 |
error("Could not allocate memory for the industry-sorting-list"); |
0 | 553 |
|
830
36c1366367e4
(svn r1301) -Codechange: _industries finally has FOR_ALL_INDUSTRIES too
truelight
parents:
821
diff
changeset
|
554 |
FOR_ALL_INDUSTRIES(i) { |
821
60524daa442c
(svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
truelight
parents:
758
diff
changeset
|
555 |
if(i->xy) |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
556 |
_industry_sort[n++] = i->index; |
0 | 557 |
} |
558 |
_num_industry_sort = n; |
|
821
60524daa442c
(svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
truelight
parents:
758
diff
changeset
|
559 |
_last_industry_idx = 0xFFFF; // used for "cache" |
0 | 560 |
|
821
60524daa442c
(svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
truelight
parents:
758
diff
changeset
|
561 |
qsort(_industry_sort, n, sizeof(_industry_sort[0]), GeneralIndustrySorter); |
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
0
diff
changeset
|
562 |
|
69 | 563 |
DEBUG(misc, 1) ("Resorting Industries list..."); |
0 | 564 |
} |
565 |
||
566 |
||
567 |
static void IndustryDirectoryWndProc(Window *w, WindowEvent *e) |
|
568 |
{ |
|
569 |
switch(e->event) { |
|
570 |
case WE_PAINT: { |
|
571 |
int n; |
|
572 |
uint p; |
|
573 |
Industry *i; |
|
574 |
static const uint16 _indicator_positions[4] = {88, 187, 284, 387}; |
|
575 |
||
576 |
if (_industry_sort_dirty) { |
|
577 |
_industry_sort_dirty = false; |
|
578 |
MakeSortedIndustryList(); |
|
579 |
} |
|
580 |
||
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
|
581 |
SetVScrollCount(w, _num_industry_sort); |
0 | 582 |
|
583 |
DrawWindowWidgets(w); |
|
584 |
DoDrawString(_industry_sort_order & 1 ? "\xAA" : "\xA0", _indicator_positions[_industry_sort_order>>1], 15, 0x10); |
|
585 |
||
586 |
p = w->vscroll.pos; |
|
587 |
n = 0; |
|
588 |
||
589 |
while (p < _num_industry_sort) { |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
590 |
i = GetIndustry(_industry_sort[p]); |
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
591 |
SetDParam(0, i->index); |
0 | 592 |
if (i->produced_cargo[0] != 0xFF) { |
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2070
diff
changeset
|
593 |
SetDParam(1, _cargoc.names_long[i->produced_cargo[0]]); |
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
594 |
SetDParam(2, i->total_production[0]); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
595 |
|
0 | 596 |
if (i->produced_cargo[1] != 0xFF) { |
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2070
diff
changeset
|
597 |
SetDParam(3, _cargoc.names_long[i->produced_cargo[1]]); |
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
598 |
SetDParam(4, i->total_production[1]); |
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
599 |
SetDParam(5, i->pct_transported[0] * 100 >> 8); |
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
600 |
SetDParam(6, i->pct_transported[1] * 100 >> 8); |
0 | 601 |
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM_TWO, 0); |
602 |
} else { |
|
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
603 |
SetDParam(3, i->pct_transported[0] * 100 >> 8); |
0 | 604 |
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM, 0); |
605 |
} |
|
606 |
} else { |
|
607 |
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM_NOPROD, 0); |
|
608 |
} |
|
609 |
p++; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
610 |
if (++n == w->vscroll.cap) |
0 | 611 |
break; |
612 |
} |
|
613 |
} break; |
|
614 |
||
615 |
case WE_CLICK: |
|
616 |
switch(e->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
|
617 |
case 3: { |
0 | 618 |
_industry_sort_order = _industry_sort_order==0 ? 1 : 0; |
619 |
_industry_sort_dirty = true; |
|
620 |
SetWindowDirty(w); |
|
621 |
} break; |
|
622 |
||
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
|
623 |
case 4: { |
0 | 624 |
_industry_sort_order = _industry_sort_order==2 ? 3 : 2; |
625 |
_industry_sort_dirty = true; |
|
626 |
SetWindowDirty(w); |
|
627 |
} break; |
|
628 |
||
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
|
629 |
case 5: { |
0 | 630 |
_industry_sort_order = _industry_sort_order==4 ? 5 : 4; |
631 |
_industry_sort_dirty = true; |
|
632 |
SetWindowDirty(w); |
|
633 |
} break; |
|
634 |
||
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
|
635 |
case 6: { |
0 | 636 |
_industry_sort_order = _industry_sort_order==6 ? 7 : 6; |
637 |
_industry_sort_dirty = true; |
|
638 |
SetWindowDirty(w); |
|
639 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
640 |
|
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
|
641 |
case 8: { |
0 | 642 |
int y = (e->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
|
643 |
uint16 p; |
0 | 644 |
Industry *c; |
645 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
646 |
if (!IS_INT_INSIDE(y, 0, w->vscroll.cap)) |
0 | 647 |
return; |
648 |
p = y + w->vscroll.pos; |
|
649 |
if (p < _num_industry_sort) { |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
650 |
c = GetIndustry(_industry_sort[p]); |
0 | 651 |
ScrollMainWindowToTile(c->xy); |
652 |
} |
|
653 |
} break; |
|
654 |
} |
|
655 |
break; |
|
656 |
||
657 |
case WE_4: |
|
658 |
SetWindowDirty(w); |
|
659 |
break; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
660 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
661 |
case WE_RESIZE: |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
662 |
w->vscroll.cap += e->sizing.diff.y / 10; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
663 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
664 |
} |
0 | 665 |
} |
666 |
||
667 |
||
668 |
/* Industry List */ |
|
669 |
static const WindowDesc _industry_directory_desc = { |
|
670 |
-1, -1, 508, 190, |
|
671 |
WC_INDUSTRY_DIRECTORY,0, |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
830
diff
changeset
|
672 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 673 |
_industry_directory_widgets, |
674 |
IndustryDirectoryWndProc |
|
675 |
}; |
|
676 |
||
677 |
||
678 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1019
diff
changeset
|
679 |
void ShowIndustryDirectory(void) |
0 | 680 |
{ |
681 |
/* Industry List */ |
|
682 |
Window *w; |
|
683 |
||
684 |
w = AllocateWindowDescFront(&_industry_directory_desc, 0); |
|
685 |
if (w) { |
|
686 |
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
|
687 |
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
|
688 |
w->resize.step_height = 10; |
0 | 689 |
SetWindowDirty(w); |
690 |
} |
|
691 |
} |