| author | egladil | 
| Sat, 29 Dec 2007 05:15:13 +0000 | |
| changeset 8652 | e06732646b8a | 
| parent 8636 | 2b158acb649c | 
| child 8675 | 5ff307aa5048 | 
| permissions | -rw-r--r-- | 
| 2186 | 1  | 
/* $Id$ */  | 
2  | 
||
| 
6527
 
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
 
belugas 
parents: 
6526 
diff
changeset
 | 
3  | 
/** @file industry_gui.cpp */  | 
| 
 
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
 
belugas 
parents: 
6526 
diff
changeset
 | 
4  | 
|
| 0 | 5  | 
#include "stdafx.h"  | 
| 
1891
 
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
 
Darkvater 
parents: 
1786 
diff
changeset
 | 
6  | 
#include "openttd.h"  | 
| 
1299
 
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
 
tron 
parents: 
1287 
diff
changeset
 | 
7  | 
#include "debug.h"  | 
| 
507
 
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
 
tron 
parents: 
222 
diff
changeset
 | 
8  | 
#include "table/strings.h"  | 
| 
1914
 
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
 
Darkvater 
parents: 
1891 
diff
changeset
 | 
9  | 
#include "table/sprites.h"  | 
| 
1386
 
aa5a172a8431
(svn r1890) Begin to clean up the edit box: Remove one global variable and split the combined edit/original buffer into two
 
tron 
parents: 
1309 
diff
changeset
 | 
10  | 
#include "gui.h"  | 
| 
8603
 
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
 
rubidium 
parents: 
8602 
diff
changeset
 | 
11  | 
#include "window_gui.h"  | 
| 
 
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
 
rubidium 
parents: 
8602 
diff
changeset
 | 
12  | 
#include "textbuf_gui.h"  | 
| 
8612
 
6414fc21c2f3
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
 
rubidium 
parents: 
8610 
diff
changeset
 | 
13  | 
#include "command_func.h"  | 
| 0 | 14  | 
#include "viewport.h"  | 
15  | 
#include "industry.h"  | 
|
16  | 
#include "town.h"  | 
|
| 
2159
 
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
 
tron 
parents: 
2084 
diff
changeset
 | 
17  | 
#include "variables.h"  | 
| 
6417
 
26acff62d001
(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: 
6144 
diff
changeset
 | 
18  | 
#include "cargotype.h"  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
19  | 
#include "newgrf.h"  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
20  | 
#include "newgrf_callbacks.h"  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
21  | 
#include "newgrf_industries.h"  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
22  | 
#include "newgrf_text.h"  | 
| 
8610
 
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
 
rubidium 
parents: 
8603 
diff
changeset
 | 
23  | 
#include "strings_func.h"  | 
| 
8635
 
3bbb6f87fced
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
 
rubidium 
parents: 
8627 
diff
changeset
 | 
24  | 
#include "map_func.h"  | 
| 0 | 25  | 
|
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
26  | 
bool _ignore_restrictions;  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
27  | 
|
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
28  | 
/** Names of the widgets of the dynamic place industries gui */  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
29  | 
enum DynamicPlaceIndustriesWidgets {
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
30  | 
DPIW_CLOSEBOX = 0,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
31  | 
DPIW_CAPTION,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
32  | 
DPIW_MATRIX_WIDGET,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
33  | 
DPIW_SCROLLBAR,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
34  | 
DPIW_INFOPANEL,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
35  | 
DPIW_FUND_WIDGET,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
36  | 
DPIW_RESIZE_WIDGET,  | 
| 
4995
 
e6152c0dc612
(svn r7001) -Codechange: _build_industry_trypes is now only used by industry_gui.c.  Move it there.
 
belugas 
parents: 
4939 
diff
changeset
 | 
37  | 
};  | 
| 0 | 38  | 
|
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
39  | 
/** Attached struct to the window extended data */  | 
| 
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
40  | 
struct fnd_d {
 | 
| 
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
41  | 
int index; ///< index of the element in the matrix  | 
| 
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
42  | 
IndustryType select; ///< industry corresponding to the above index  | 
| 
7779
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
43  | 
uint16 callback_timer; ///< timer counter for callback eventual verification  | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
44  | 
bool timer_enabled; ///< timer can be used  | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
45  | 
};  | 
| 
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
46  | 
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(fnd_d));  | 
| 
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
47  | 
|
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
48  | 
/** Helper struct holding the available industries for current situation */  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
49  | 
static struct IndustryData {
 | 
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
50  | 
uint16 count; ///< How many industries are loaded  | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
51  | 
IndustryType index[NUM_INDUSTRYTYPES + 1]; ///< Type of industry, in the order it was loaded  | 
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
52  | 
StringID text[NUM_INDUSTRYTYPES + 1]; ///< Text coming from CBM_IND_FUND_MORE_TEXT (if ever)  | 
| 
7779
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
53  | 
bool enabled[NUM_INDUSTRYTYPES + 1]; ///< availability state, coming from CBID_INDUSTRY_AVAILABLE (if ever)  | 
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
54  | 
} _fund_gui;  | 
| 1004 | 55  | 
|
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
56  | 
static void BuildDynamicIndustryWndProc(Window *w, WindowEvent *e)  | 
| 0 | 57  | 
{
 | 
| 2951 | 58  | 
	switch (e->event) {
 | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
59  | 
		case WE_CREATE: {
 | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
60  | 
IndustryType ind;  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
61  | 
const IndustrySpec *indsp;  | 
| 0 | 62  | 
|
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
63  | 
/* Shorten the window to the equivalant of the additionnal purchase  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
64  | 
* info coming from the callback. SO it will only be available to tis full  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
65  | 
* height when newindistries are loaded */  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
66  | 
			if (!_loaded_newgrf_features.has_newindustries) {
 | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
67  | 
w->widget[DPIW_INFOPANEL].bottom -= 44;  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
68  | 
w->widget[DPIW_FUND_WIDGET].bottom -= 44;  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
69  | 
w->widget[DPIW_FUND_WIDGET].top -= 44;  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
70  | 
w->widget[DPIW_RESIZE_WIDGET].bottom -= 44;  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
71  | 
w->widget[DPIW_RESIZE_WIDGET].top -= 44;  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
72  | 
w->resize.height = w->height -= 44;  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
73  | 
}  | 
| 0 | 74  | 
|
| 
7779
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
75  | 
WP(w, fnd_d).timer_enabled = _loaded_newgrf_features.has_newindustries;  | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
76  | 
|
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
77  | 
/* Initilialize structures */  | 
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
78  | 
memset(&_fund_gui.index, 0xFF, NUM_INDUSTRYTYPES);  | 
| 
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
79  | 
memset(&_fund_gui.text, STR_NULL, NUM_INDUSTRYTYPES);  | 
| 
7779
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
80  | 
memset(&_fund_gui.enabled, false, NUM_INDUSTRYTYPES);  | 
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
81  | 
_fund_gui.count = 0;  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
82  | 
|
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
83  | 
w->vscroll.cap = 8; // rows in grid, same in scroller  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
84  | 
w->resize.step_height = 13;  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
85  | 
|
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
86  | 
			if (_game_mode == GM_EDITOR) { // give room for the Many Random "button"
 | 
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
87  | 
_fund_gui.index[_fund_gui.count] = INVALID_INDUSTRYTYPE;  | 
| 
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
88  | 
_fund_gui.count++;  | 
| 
7779
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
89  | 
WP(w, fnd_d).timer_enabled = false;  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
90  | 
}  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
91  | 
|
| 
8204
 
8ebeee77f39c
(svn r11242) -Codechange: When displaying the industry funding gui, present the industries in the same order as they are available.
 
belugas 
parents: 
8143 
diff
changeset
 | 
92  | 
/* Fill the _fund_gui structure with industries.  | 
| 
 
8ebeee77f39c
(svn r11242) -Codechange: When displaying the industry funding gui, present the industries in the same order as they are available.
 
belugas 
parents: 
8143 
diff
changeset
 | 
93  | 
* The tests performed after the enabled allow to load the industries  | 
| 
 
8ebeee77f39c
(svn r11242) -Codechange: When displaying the industry funding gui, present the industries in the same order as they are available.
 
belugas 
parents: 
8143 
diff
changeset
 | 
94  | 
* In the same way they are inserted by grf (if any)  | 
| 
 
8ebeee77f39c
(svn r11242) -Codechange: When displaying the industry funding gui, present the industries in the same order as they are available.
 
belugas 
parents: 
8143 
diff
changeset
 | 
95  | 
*/  | 
| 
7815
 
04deaeb181ab
(svn r10675) -Codechange: unhardcode the industry types used in several locations of the source code.
 
rubidium 
parents: 
7785 
diff
changeset
 | 
96  | 
			for (ind = 0; ind < NUM_INDUSTRYTYPES; ind++) {
 | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
97  | 
indsp = GetIndustrySpec(ind);  | 
| 
8204
 
8ebeee77f39c
(svn r11242) -Codechange: When displaying the industry funding gui, present the industries in the same order as they are available.
 
belugas 
parents: 
8143 
diff
changeset
 | 
98  | 
				if (indsp->enabled){
 | 
| 
 
8ebeee77f39c
(svn r11242) -Codechange: When displaying the industry funding gui, present the industries in the same order as they are available.
 
belugas 
parents: 
8143 
diff
changeset
 | 
99  | 
/* Rule is that editor mode loads all industries.  | 
| 
 
8ebeee77f39c
(svn r11242) -Codechange: When displaying the industry funding gui, present the industries in the same order as they are available.
 
belugas 
parents: 
8143 
diff
changeset
 | 
100  | 
* In game mode, all non raw industries are loaded too  | 
| 
 
8ebeee77f39c
(svn r11242) -Codechange: When displaying the industry funding gui, present the industries in the same order as they are available.
 
belugas 
parents: 
8143 
diff
changeset
 | 
101  | 
* and raw ones are loaded only when setting allows it */  | 
| 
 
8ebeee77f39c
(svn r11242) -Codechange: When displaying the industry funding gui, present the industries in the same order as they are available.
 
belugas 
parents: 
8143 
diff
changeset
 | 
102  | 
if (_game_mode != GM_EDITOR && indsp->IsRawIndustry() && _patches.raw_industry_construction == 0) continue;  | 
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
103  | 
_fund_gui.index[_fund_gui.count] = ind;  | 
| 
8143
 
f03f8a352866
(svn r11178) -Fix: don't check newgrf callback 22 in scenario editor
 
glx 
parents: 
8141 
diff
changeset
 | 
104  | 
_fund_gui.enabled[_fund_gui.count] = (_game_mode == GM_EDITOR) || CheckIfCallBackAllowsAvailability(ind, IACT_USERCREATION);  | 
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
105  | 
_fund_gui.count++;  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
106  | 
}  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
107  | 
}  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
108  | 
|
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
109  | 
/* first indutry type is selected.  | 
| 
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
110  | 
* I'll be damned if there are none available ;) */  | 
| 
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
111  | 
WP(w, fnd_d).index = 0;  | 
| 
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
112  | 
WP(w, fnd_d).select = _fund_gui.index[0];  | 
| 
7779
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
113  | 
WP(w, fnd_d).callback_timer = DAY_TICKS;  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
114  | 
} break;  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
115  | 
|
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
116  | 
		case WE_PAINT: {
 | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
117  | 
const IndustrySpec *indsp = (WP(w, fnd_d).select == INVALID_INDUSTRYTYPE) ? NULL : GetIndustrySpec(WP(w, fnd_d).select);  | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
118  | 
int x_str = w->widget[DPIW_INFOPANEL].left + 3;  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
119  | 
int y_str = w->widget[DPIW_INFOPANEL].top + 3;  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
120  | 
const Widget *wi = &w->widget[DPIW_INFOPANEL];  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
121  | 
int max_width = wi->right - wi->left - 4;  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
122  | 
|
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
123  | 
/* Raw industries might be prospected. Show this fact by changing the string  | 
| 
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
124  | 
* In Editor, you just build, while ingame, or you fund or you prospect */  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
125  | 
			if (_game_mode == GM_EDITOR) {
 | 
| 
7779
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
126  | 
/* We've chosen many random industries but no industries have been specified */  | 
| 
7785
 
9e85a222f8fb
(svn r10637) -Fix: Enable the Random Industries in scenario editor if setting Number of Industries is not NONE.
 
belugas 
parents: 
7780 
diff
changeset
 | 
127  | 
if (indsp == NULL) _fund_gui.enabled[WP(w, fnd_d).index] = _opt.diff.number_industries != 0;  | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
128  | 
w->widget[DPIW_FUND_WIDGET].data = STR_BUILD_NEW_INDUSTRY;  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
129  | 
			} else {
 | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
130  | 
w->widget[DPIW_FUND_WIDGET].data = (_patches.raw_industry_construction == 2 && indsp->IsRawIndustry()) ? STR_PROSPECT_NEW_INDUSTRY : STR_FUND_NEW_INDUSTRY;  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
131  | 
}  | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
132  | 
w->SetWidgetDisabledState(DPIW_FUND_WIDGET, !_fund_gui.enabled[WP(w, fnd_d).index]);  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
133  | 
|
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
134  | 
SetVScrollCount(w, _fund_gui.count);  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
135  | 
|
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
136  | 
DrawWindowWidgets(w);  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
137  | 
|
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
138  | 
/* and now with the matrix painting */  | 
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
139  | 
			for (byte i = 0; i < w->vscroll.cap && ((i + w->vscroll.pos) < _fund_gui.count); i++) {
 | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
140  | 
int offset = i * 13;  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
141  | 
int x = 3;  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
142  | 
int y = 16;  | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
143  | 
bool selected = WP(w, fnd_d).index == i + w->vscroll.pos;  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
144  | 
|
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
145  | 
				if (_fund_gui.index[i + w->vscroll.pos] == INVALID_INDUSTRYTYPE) {
 | 
| 
8373
 
2281716386c5
(svn r11427) -Fix: Forgot to Truncate the string "Many Random Industries" in the funding industry window.  In some languages, it gets drawn outside of the gui.
 
belugas 
parents: 
8320 
diff
changeset
 | 
146  | 
DrawStringTruncated(20, y + offset, STR_MANY_RANDOM_INDUSTRIES, selected ? TC_WHITE : TC_ORANGE, max_width - 25);  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
147  | 
continue;  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
148  | 
}  | 
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
149  | 
const IndustrySpec *indsp = GetIndustrySpec(_fund_gui.index[i + w->vscroll.pos]);  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
150  | 
|
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
151  | 
/* Draw the name of the industry in white is selected, otherwise, in orange */  | 
| 
8320
 
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
 
belugas 
parents: 
8318 
diff
changeset
 | 
152  | 
DrawStringTruncated(20, y + offset, indsp->name, selected ? TC_WHITE : TC_ORANGE, max_width - 25);  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
153  | 
GfxFillRect(x, y + 1 + offset, x + 10, y + 7 + offset, selected ? 15 : 0);  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
154  | 
GfxFillRect(x + 1, y + 2 + offset, x + 9, y + 6 + offset, indsp->map_colour);  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
155  | 
}  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
156  | 
|
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
157  | 
			if (WP(w, fnd_d).select == INVALID_INDUSTRYTYPE) {
 | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
158  | 
DrawStringMultiLine(x_str, y_str, STR_RANDOM_INDUSTRIES_TIP, max_width, wi->bottom - wi->top - 40);  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
159  | 
break;  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
160  | 
}  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
161  | 
|
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
162  | 
			if (_game_mode != GM_EDITOR) {
 | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
163  | 
SetDParam(0, indsp->GetConstructionCost());  | 
| 
8320
 
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
 
belugas 
parents: 
8318 
diff
changeset
 | 
164  | 
DrawStringTruncated(x_str, y_str, STR_482F_COST, TC_FROMSTRING, max_width);  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
165  | 
y_str += 11;  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
166  | 
}  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
167  | 
|
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
168  | 
/* Draw the accepted cargos, if any. Otherwhise, will print "Nothing" */  | 
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
169  | 
StringID str = STR_4827_REQUIRES;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
170  | 
byte p = 0;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
171  | 
SetDParam(0, STR_00D0_NOTHING);  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
172  | 
			for (byte j = 0; j < lengthof(indsp->accepts_cargo); j++) {
 | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
173  | 
if (indsp->accepts_cargo[j] == CT_INVALID) continue;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
174  | 
if (p > 0) str++;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
175  | 
SetDParam(p++, GetCargo(indsp->accepts_cargo[j])->name);  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
176  | 
}  | 
| 
8320
 
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
 
belugas 
parents: 
8318 
diff
changeset
 | 
177  | 
DrawStringTruncated(x_str, y_str, str, TC_FROMSTRING, max_width);  | 
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
178  | 
y_str += 11;  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
179  | 
|
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
180  | 
/* Draw the produced cargos, if any. Otherwhise, will print "Nothing" */  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
181  | 
str = STR_4827_PRODUCES;  | 
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
182  | 
p = 0;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
183  | 
SetDParam(0, STR_00D0_NOTHING);  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
184  | 
			for (byte j = 0; j < lengthof(indsp->produced_cargo); j++) {
 | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
185  | 
if (indsp->produced_cargo[j] == CT_INVALID) continue;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
186  | 
if (p > 0) str++;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
187  | 
SetDParam(p++, GetCargo(indsp->produced_cargo[j])->name);  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
188  | 
}  | 
| 
8320
 
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
 
belugas 
parents: 
8318 
diff
changeset
 | 
189  | 
DrawStringTruncated(x_str, y_str, str, TC_FROMSTRING, max_width);  | 
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
190  | 
y_str += 11;  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
191  | 
|
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
192  | 
/* Get the additional purchase info text, if it has not already been */  | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
193  | 
			if (_fund_gui.text[WP(w, fnd_d).index] == STR_NULL) {   // Have i been called already?
 | 
| 
8424
 
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
 
skidd13 
parents: 
8418 
diff
changeset
 | 
194  | 
				if (HasBit(indsp->callback_flags, CBM_IND_FUND_MORE_TEXT)) {          // No. Can it be called?
 | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
195  | 
uint16 callback_res = GetIndustryCallback(CBID_INDUSTRY_FUND_MORE_TEXT, 0, 0, NULL, WP(w, fnd_d).select, INVALID_TILE);  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
196  | 
					if (callback_res != CALLBACK_FAILED) {  // Did it failed?
 | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
197  | 
StringID newtxt = GetGRFStringID(indsp->grf_prop.grffile->grfid, 0xD000 + callback_res); // No. here's the new string  | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
198  | 
_fund_gui.text[WP(w, fnd_d).index] = newtxt; // Store it for further usage  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
199  | 
}  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
200  | 
}  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
201  | 
}  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
202  | 
|
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
203  | 
/* Draw the Additional purchase text, provided by newgrf callback, if any.  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
204  | 
* Otherwhise, will print Nothing */  | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
205  | 
str = _fund_gui.text[WP(w, fnd_d).index];  | 
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
206  | 
			if (str != STR_NULL && str != STR_UNDEFINED) {
 | 
| 
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
207  | 
SetDParam(0, str);  | 
| 
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
208  | 
DrawStringMultiLine(x_str, y_str, STR_JUST_STRING, max_width, wi->bottom - wi->top - 40);  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
209  | 
}  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
210  | 
} break;  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
211  | 
|
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
212  | 
case WE_DOUBLE_CLICK:  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
213  | 
if (e->we.click.widget != DPIW_MATRIX_WIDGET) break;  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
214  | 
e->we.click.widget = DPIW_FUND_WIDGET;  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
215  | 
/* Fall through */  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
216  | 
|
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
217  | 
case WE_CLICK:  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
218  | 
			switch (e->we.click.widget) {
 | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
219  | 
				case DPIW_MATRIX_WIDGET: {
 | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
220  | 
const IndustrySpec *indsp;  | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
221  | 
int y = (e->we.click.pt.y - w->widget[DPIW_MATRIX_WIDGET].top) / 13 + w->vscroll.pos ;  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
222  | 
|
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
223  | 
					if (y >= 0 && y < _fund_gui.count) { // Is it within the boundaries of available data?
 | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
224  | 
WP(w, fnd_d).index = y;  | 
| 
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
225  | 
WP(w, fnd_d).select = _fund_gui.index[WP(w, fnd_d).index];  | 
| 
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
226  | 
indsp = (WP(w, fnd_d).select == INVALID_INDUSTRYTYPE) ? NULL : GetIndustrySpec(WP(w, fnd_d).select);  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
227  | 
|
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
228  | 
SetWindowDirty(w);  | 
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
229  | 
|
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
230  | 
if ((_game_mode != GM_EDITOR && _patches.raw_industry_construction == 2 && indsp != NULL && indsp->IsRawIndustry()) ||  | 
| 
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
231  | 
								WP(w, fnd_d).select == INVALID_INDUSTRYTYPE) {
 | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
232  | 
/* Reset the button state if going to prospecting or "build many industries" */  | 
| 
8528
 
04b4ef9abd9b
(svn r11592) -Codechange: Use the Window member RaiseButtons and remove the now useless RaiseWindowButtons function
 
belugas 
parents: 
8493 
diff
changeset
 | 
233  | 
w->RaiseButtons();  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
234  | 
ResetObjectToPlace();  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
235  | 
}  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
236  | 
}  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
237  | 
} break;  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
238  | 
|
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
239  | 
				case DPIW_FUND_WIDGET: {
 | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
240  | 
					if (WP(w, fnd_d).select == INVALID_INDUSTRYTYPE) {
 | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
241  | 
w->HandleButtonClick(DPIW_FUND_WIDGET);  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
242  | 
|
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
243  | 
						if (GetNumTowns() == 0) {
 | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
244  | 
ShowErrorMessage(STR_0286_MUST_BUILD_TOWN_FIRST, STR_CAN_T_GENERATE_INDUSTRIES, 0, 0);  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
245  | 
						} else {
 | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
246  | 
extern void GenerateIndustries();  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
247  | 
_generating_world = true;  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
248  | 
GenerateIndustries();  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
249  | 
_generating_world = false;  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
250  | 
}  | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
251  | 
					} else if (_game_mode != GM_EDITOR && _patches.raw_industry_construction == 2 && GetIndustrySpec(WP(w, fnd_d).select)->IsRawIndustry()) {
 | 
| 
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
252  | 
DoCommandP(0, WP(w, fnd_d).select, 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY));  | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
253  | 
w->HandleButtonClick(DPIW_FUND_WIDGET);  | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
254  | 
					} else {
 | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
255  | 
HandlePlacePushButton(w, DPIW_FUND_WIDGET, SPR_CURSOR_INDUSTRY, VHM_RECT, NULL);  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
256  | 
}  | 
| 
7767
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
257  | 
} break;  | 
| 
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
258  | 
}  | 
| 
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
259  | 
break;  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
260  | 
|
| 
7767
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
261  | 
		case WE_RESIZE: {
 | 
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
262  | 
/* Adjust the number of items in the matrix depending of the rezise */  | 
| 
7767
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
263  | 
w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height;  | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
264  | 
w->widget[DPIW_MATRIX_WIDGET].data = (w->vscroll.cap << 8) + 1;  | 
| 
7767
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
265  | 
} break;  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
266  | 
|
| 
7767
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
267  | 
		case WE_PLACE_OBJ: {
 | 
| 
8243
 
7af75c16f4ea
(svn r11284) -Codechange: don't reset build industry cursor if it failed
 
glx 
parents: 
8209 
diff
changeset
 | 
268  | 
bool success = true;  | 
| 
7776
 
aa072bd88690
(svn r10619) -Codechange: Use shorter variable/member names and add some code separation.
 
belugas 
parents: 
7775 
diff
changeset
 | 
269  | 
/* We do not need to protect ourselves against "Random Many Industries" in this mode */  | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
270  | 
const IndustrySpec *indsp = GetIndustrySpec(WP(w, fnd_d).select);  | 
| 
7767
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
271  | 
|
| 
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
272  | 
			if (_game_mode == GM_EDITOR) {
 | 
| 
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
273  | 
/* Show error if no town exists at all */  | 
| 
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
274  | 
				if (GetNumTowns() == 0) {
 | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
275  | 
SetDParam(0, indsp->name);  | 
| 
7767
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
276  | 
ShowErrorMessage(STR_0286_MUST_BUILD_TOWN_FIRST, STR_0285_CAN_T_BUILD_HERE, e->we.place.pt.x, e->we.place.pt.y);  | 
| 
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
277  | 
return;  | 
| 
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
278  | 
}  | 
| 
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
279  | 
|
| 
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
280  | 
_current_player = OWNER_NONE;  | 
| 
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
281  | 
_generating_world = true;  | 
| 
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
282  | 
_ignore_restrictions = true;  | 
| 
8545
 
0f083181232e
(svn r11609) -Fix [FS#1524]: wrong error messages were shown when trying to build some industries in the scenario editor.
 
rubidium 
parents: 
8543 
diff
changeset
 | 
283  | 
success = DoCommandP(e->we.place.tile, WP(w, fnd_d).select, InteractiveRandomRange(indsp->num_table), NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY));  | 
| 
8243
 
7af75c16f4ea
(svn r11284) -Codechange: don't reset build industry cursor if it failed
 
glx 
parents: 
8209 
diff
changeset
 | 
284  | 
				if (!success) {
 | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
285  | 
SetDParam(0, indsp->name);  | 
| 
7767
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
286  | 
ShowErrorMessage(_error_message, STR_0285_CAN_T_BUILD_HERE, e->we.place.pt.x, e->we.place.pt.y);  | 
| 
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
287  | 
}  | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
288  | 
|
| 
7767
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
289  | 
_ignore_restrictions = false;  | 
| 
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
290  | 
_generating_world = false;  | 
| 
8243
 
7af75c16f4ea
(svn r11284) -Codechange: don't reset build industry cursor if it failed
 
glx 
parents: 
8209 
diff
changeset
 | 
291  | 
			} else {
 | 
| 
8302
 
df1671669a80
(svn r11356) -Fix (r11305): funding industries in MP game was causing desync
 
glx 
parents: 
8286 
diff
changeset
 | 
292  | 
success = DoCommandP(e->we.place.tile, WP(w, fnd_d).select, InteractiveRandomRange(indsp->num_table), NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY));  | 
| 
8243
 
7af75c16f4ea
(svn r11284) -Codechange: don't reset build industry cursor if it failed
 
glx 
parents: 
8209 
diff
changeset
 | 
293  | 
}  | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
294  | 
|
| 
8243
 
7af75c16f4ea
(svn r11284) -Codechange: don't reset build industry cursor if it failed
 
glx 
parents: 
8209 
diff
changeset
 | 
295  | 
/* If an industry has been built, just reset the cursor and the system */  | 
| 
 
7af75c16f4ea
(svn r11284) -Codechange: don't reset build industry cursor if it failed
 
glx 
parents: 
8209 
diff
changeset
 | 
296  | 
if (success) ResetObjectToPlace();  | 
| 
7767
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
297  | 
} break;  | 
| 0 | 298  | 
|
| 
7779
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
299  | 
case WE_TICK:  | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
300  | 
if (!WP(w, fnd_d).timer_enabled) break;  | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
301  | 
			if (--WP(w, fnd_d).callback_timer == 0) {
 | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
302  | 
/* We have just passed another day.  | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
303  | 
* See if we need to update availability of currently selected industry */  | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
304  | 
WP(w, fnd_d).callback_timer = DAY_TICKS; //restart counter  | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
305  | 
|
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
306  | 
const IndustrySpec *indsp = GetIndustrySpec(WP(w, fnd_d).select);  | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
307  | 
|
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
308  | 
				if (indsp->enabled) {
 | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
309  | 
bool call_back_result = CheckIfCallBackAllowsAvailability(WP(w, fnd_d).select, IACT_USERCREATION);  | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
310  | 
|
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
311  | 
/* Only if result does match the previous state would it require a redraw. */  | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
312  | 
					if (call_back_result != _fund_gui.enabled[WP(w, fnd_d).index]) {
 | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
313  | 
_fund_gui.enabled[WP(w, fnd_d).index] = call_back_result;  | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
314  | 
SetWindowDirty(w);  | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
315  | 
}  | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
316  | 
}  | 
| 
 
ad42dbf9069d
(svn r10622) -Feature: Introduction of the CBID_INDUSTRY_AVAILABLE's handling, in fund industry window.
 
belugas 
parents: 
7778 
diff
changeset
 | 
317  | 
}  | 
| 
7767
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
318  | 
break;  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
319  | 
|
| 
7767
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
320  | 
case WE_TIMEOUT:  | 
| 
7778
 
e8ccdf216de1
(svn r10621) -Codechange: install a struct holding the user's selection from _fund_gui.
 
belugas 
parents: 
7776 
diff
changeset
 | 
321  | 
case WE_ABORT_PLACE_OBJ:  | 
| 
8528
 
04b4ef9abd9b
(svn r11592) -Codechange: Use the Window member RaiseButtons and remove the now useless RaiseWindowButtons function
 
belugas 
parents: 
8493 
diff
changeset
 | 
322  | 
w->RaiseButtons();  | 
| 
7767
 
7d8033aa8248
(svn r10600) -Codechange: code-stylising the gui switch-case code
 
belugas 
parents: 
7714 
diff
changeset
 | 
323  | 
break;  | 
| 0 | 324  | 
}  | 
325  | 
}  | 
|
326  | 
||
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
327  | 
/** Widget definition of the dynamic place industries gui */  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
328  | 
static const Widget _build_dynamic_industry_widgets[] = {
 | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
329  | 
{   WWT_CLOSEBOX,    RESIZE_NONE,    7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},            // DPIW_CLOSEBOX
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
330  | 
{    WWT_CAPTION,   RESIZE_RIGHT,    7,    11,   169,     0,    13, STR_0314_FUND_NEW_INDUSTRY,     STR_018C_WINDOW_TITLE_DRAG_THIS},  // DPIW_CAPTION
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
331  | 
{     WWT_MATRIX,      RESIZE_RB,    7,     0,   157,    14,   118, 0x801,                          STR_INDUSTRY_SELECTION_HINT},      // DPIW_MATRIX_WIDGET
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
332  | 
{  WWT_SCROLLBAR,     RESIZE_LRB,    7,   158,   169,    14,   118, 0x0,                            STR_0190_SCROLL_BAR_SCROLLS_LIST}, // DPIW_SCROLLBAR
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
333  | 
{      WWT_PANEL,     RESIZE_RTB,    7,     0,   169,   119,   199, 0x0,                            STR_NULL},                         // DPIW_INFOPANEL
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
334  | 
{    WWT_TEXTBTN,     RESIZE_RTB,    7,     0,   157,   200,   211, STR_FUND_NEW_INDUSTRY,          STR_NULL},                         // DPIW_FUND_WIDGET
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
335  | 
{  WWT_RESIZEBOX,    RESIZE_LRTB,    7,   158,   169,   200,   211, 0x0,                            STR_RESIZE_BUTTON},                // DPIW_RESIZE_WIDGET
 | 
| 
176
 
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
 
darkvater 
parents: 
164 
diff
changeset
 | 
336  | 
{   WIDGETS_END},
 | 
| 0 | 337  | 
};  | 
338  | 
||
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
339  | 
/** Window definition of the dynamic place industries gui */  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
340  | 
static const WindowDesc _build_industry_dynamic_desc = {
 | 
| 
7837
 
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
 
rubidium 
parents: 
7815 
diff
changeset
 | 
341  | 
WDP_AUTO, WDP_AUTO, 170, 212, 170, 212,  | 
| 
6144
 
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
 
rubidium 
parents: 
5860 
diff
changeset
 | 
342  | 
WC_BUILD_INDUSTRY, WC_NONE,  | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
343  | 
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
344  | 
_build_dynamic_industry_widgets,  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
345  | 
BuildDynamicIndustryWndProc,  | 
| 0 | 346  | 
};  | 
347  | 
||
| 6573 | 348  | 
void ShowBuildIndustryWindow()  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
349  | 
{
 | 
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
350  | 
if (_game_mode != GM_EDITOR && !IsValidPlayer(_current_player)) return;  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
351  | 
AllocateWindowDescFront(&_build_industry_dynamic_desc, 0);  | 
| 0 | 352  | 
}  | 
353  | 
||
| 
7714
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
354  | 
static void UpdateIndustryProduction(Industry *i);  | 
| 
 
d2060492ca03
(svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
 
belugas 
parents: 
7691 
diff
changeset
 | 
355  | 
|
| 
7780
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
356  | 
static inline bool isProductionMinimum(const Industry *i, int pt)  | 
| 
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
357  | 
{
 | 
| 
8286
 
f3d626cd1969
(svn r11340) -Fix[FS#1362]: Newindustries can provide no production at start. So the Modifying Production cheat was a bit puzzled on how to deal with it.  This will help a bit.
 
belugas 
parents: 
8246 
diff
changeset
 | 
358  | 
return i->production_rate[pt] == 0;  | 
| 
4211
 
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
 
miham 
parents: 
4194 
diff
changeset
 | 
359  | 
}  | 
| 
 
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
 
miham 
parents: 
4194 
diff
changeset
 | 
360  | 
|
| 
7780
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
361  | 
static inline bool isProductionMaximum(const Industry *i, int pt)  | 
| 
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
362  | 
{
 | 
| 
8286
 
f3d626cd1969
(svn r11340) -Fix[FS#1362]: Newindustries can provide no production at start. So the Modifying Production cheat was a bit puzzled on how to deal with it.  This will help a bit.
 
belugas 
parents: 
8246 
diff
changeset
 | 
363  | 
return i->production_rate[pt] >= 255;  | 
| 
4211
 
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
 
miham 
parents: 
4194 
diff
changeset
 | 
364  | 
}  | 
| 
 
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
 
miham 
parents: 
4194 
diff
changeset
 | 
365  | 
|
| 
4194
 
18a32dace8ba
(svn r5654) -Cleanup: Change an ugly define into a function
 
Darkvater 
parents: 
4193 
diff
changeset
 | 
366  | 
static inline bool IsProductionAlterable(const Industry *i)  | 
| 
 
18a32dace8ba
(svn r5654) -Cleanup: Change an ugly define into a function
 
Darkvater 
parents: 
4193 
diff
changeset
 | 
367  | 
{
 | 
| 
 
18a32dace8ba
(svn r5654) -Cleanup: Change an ugly define into a function
 
Darkvater 
parents: 
4193 
diff
changeset
 | 
368  | 
return ((_game_mode == GM_EDITOR || _cheats.setup_prod.value) &&  | 
| 
8141
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
369  | 
(i->accepts_cargo[0] == CT_INVALID || i->accepts_cargo[0] == CT_VALUABLES));  | 
| 
4194
 
18a32dace8ba
(svn r5654) -Cleanup: Change an ugly define into a function
 
Darkvater 
parents: 
4193 
diff
changeset
 | 
370  | 
}  | 
| 
 
18a32dace8ba
(svn r5654) -Cleanup: Change an ugly define into a function
 
Darkvater 
parents: 
4193 
diff
changeset
 | 
371  | 
|
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
372  | 
/** Names of the widgets of the view industry gui */  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
373  | 
enum IndustryViewWidgets {
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
374  | 
IVW_CLOSEBOX = 0,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
375  | 
IVW_CAPTION,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
376  | 
IVW_STICKY,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
377  | 
IVW_BACKGROUND,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
378  | 
IVW_VIEWPORT,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
379  | 
IVW_INFO,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
380  | 
IVW_GOTO,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
381  | 
IVW_SPACER,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
382  | 
};  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
383  | 
|
| 
7780
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
384  | 
/** Information to store about the industry window */  | 
| 
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
385  | 
struct indview_d : public vp_d {
 | 
| 
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
386  | 
byte editbox_line; ///< The line clicked to open the edit box  | 
| 
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
387  | 
byte clicked_line; ///< The line of the button that has been clicked  | 
| 
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
388  | 
byte clicked_button; ///< The button that has been clicked (to raise)  | 
| 
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
389  | 
byte production_offset_y; ///< The offset of the production texts/buttons  | 
| 
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
390  | 
};  | 
| 
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
391  | 
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(indview_d));  | 
| 
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
392  | 
|
| 
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
393  | 
|
| 0 | 394  | 
static void IndustryViewWndProc(Window *w, WindowEvent *e)  | 
395  | 
{
 | 
|
| 2951 | 396  | 
	switch (e->event) {
 | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
397  | 
	case WE_CREATE: {
 | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
398  | 
/* Count the number of lines that we need to resize the GUI with */  | 
| 
8141
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
399  | 
const Industry *i = GetIndustry(w->window_number);  | 
| 
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
400  | 
const IndustrySpec *ind = GetIndustrySpec(i->type);  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
401  | 
int lines = -3;  | 
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
402  | 
bool first = true;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
403  | 
bool has_accept = false;  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
404  | 
|
| 
8424
 
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
 
skidd13 
parents: 
8418 
diff
changeset
 | 
405  | 
		if (HasBit(ind->callback_flags, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(ind->callback_flags, CBM_IND_PRODUCTION_256_TICKS)) {
 | 
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
406  | 
			for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
 | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
407  | 
if (i->accepts_cargo[j] == CT_INVALID) continue;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
408  | 
has_accept = true;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
409  | 
				if (first) {
 | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
410  | 
lines++;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
411  | 
first = false;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
412  | 
}  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
413  | 
lines++;  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
414  | 
}  | 
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
415  | 
		} else {
 | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
416  | 
			for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
 | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
417  | 
if (i->accepts_cargo[j] == CT_INVALID) continue;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
418  | 
has_accept = true;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
419  | 
lines++;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
420  | 
break;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
421  | 
}  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
422  | 
}  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
423  | 
|
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
424  | 
first = true;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
425  | 
		for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
 | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
426  | 
if (i->produced_cargo[j] == CT_INVALID) continue;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
427  | 
			if (first) {
 | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
428  | 
if (has_accept) lines++;  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
429  | 
lines++;  | 
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
430  | 
first = false;  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
431  | 
}  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
432  | 
lines++;  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
433  | 
}  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
434  | 
|
| 
8424
 
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
 
skidd13 
parents: 
8418 
diff
changeset
 | 
435  | 
if (HasBit(ind->callback_flags, CBM_IND_WINDOW_MORE_TEXT)) lines += 2;  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
436  | 
|
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
437  | 
		for (byte j = 5; j <= 7; j++) {
 | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
438  | 
if (j != 5) w->widget[j].top += lines * 10;  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
439  | 
w->widget[j].bottom += lines * 10;  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
440  | 
}  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
441  | 
w->height += lines * 10;  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
442  | 
} break;  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
443  | 
|
| 1004 | 444  | 
	case WE_PAINT: {
 | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
445  | 
Industry *i = GetIndustry(w->window_number);  | 
| 
7132
 
08abbae3073e
(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: 
7120 
diff
changeset
 | 
446  | 
const IndustrySpec *ind = GetIndustrySpec(i->type);  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
447  | 
int y = 111;  | 
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
448  | 
bool first = true;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
449  | 
bool has_accept = false;  | 
| 2557 | 450  | 
|
| 
2070
 
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
 
ludde 
parents: 
2063 
diff
changeset
 | 
451  | 
SetDParam(0, w->window_number);  | 
| 0 | 452  | 
DrawWindowWidgets(w);  | 
453  | 
||
| 
8424
 
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
 
skidd13 
parents: 
8418 
diff
changeset
 | 
454  | 
		if (HasBit(ind->callback_flags, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(ind->callback_flags, CBM_IND_PRODUCTION_256_TICKS)) {
 | 
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
455  | 
			for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
 | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
456  | 
if (i->accepts_cargo[j] == CT_INVALID) continue;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
457  | 
has_accept = true;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
458  | 
				if (first) {
 | 
| 
8320
 
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
 
belugas 
parents: 
8318 
diff
changeset
 | 
459  | 
DrawString(2, y, STR_INDUSTRY_WINDOW_WAITING_FOR_PROCESSING, TC_FROMSTRING);  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
460  | 
y += 10;  | 
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
461  | 
first = false;  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
462  | 
}  | 
| 
8141
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
463  | 
SetDParam(0, i->accepts_cargo[j]);  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
464  | 
SetDParam(1, i->incoming_cargo_waiting[j]);  | 
| 
8320
 
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
 
belugas 
parents: 
8318 
diff
changeset
 | 
465  | 
DrawString(4, y, STR_INDUSTRY_WINDOW_WAITING_STOCKPILE_CARGO, TC_FROMSTRING);  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
466  | 
y += 10;  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
467  | 
}  | 
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
468  | 
		} else {
 | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
469  | 
StringID str = STR_4827_REQUIRES;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
470  | 
byte p = 0;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
471  | 
			for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
 | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
472  | 
if (i->accepts_cargo[j] == CT_INVALID) continue;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
473  | 
has_accept = true;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
474  | 
if (p > 0) str++;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
475  | 
SetDParam(p++, GetCargo(i->accepts_cargo[j])->name);  | 
| 0 | 476  | 
}  | 
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
477  | 
			if (has_accept) {
 | 
| 
8320
 
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
 
belugas 
parents: 
8318 
diff
changeset
 | 
478  | 
DrawString(2, y, str, TC_FROMSTRING);  | 
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
479  | 
y += 10;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
480  | 
}  | 
| 0 | 481  | 
}  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
482  | 
|
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
483  | 
first = true;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
484  | 
		for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
 | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
485  | 
if (i->produced_cargo[j] == CT_INVALID) continue;  | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
486  | 
			if (first) {
 | 
| 
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
487  | 
if (has_accept) y += 10;  | 
| 
8320
 
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
 
belugas 
parents: 
8318 
diff
changeset
 | 
488  | 
DrawString(2, y, STR_482A_PRODUCTION_LAST_MONTH, TC_FROMSTRING);  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
489  | 
y += 10;  | 
| 
7780
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
490  | 
WP(w, indview_d).production_offset_y = y;  | 
| 
8318
 
cf03501a4664
(svn r11372) -Fix [FS#1394]: don't stop on first invalid cargo type when displaying industry acceptance
 
glx 
parents: 
8302 
diff
changeset
 | 
491  | 
first = false;  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
492  | 
}  | 
| 0 | 493  | 
|
| 
8141
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
494  | 
SetDParam(0, i->produced_cargo[j]);  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
495  | 
SetDParam(1, i->last_month_production[j]);  | 
| 
2063
 
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
 
ludde 
parents: 
1981 
diff
changeset
 | 
496  | 
|
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
497  | 
SetDParam(2, i->last_month_pct_transported[j] * 100 >> 8);  | 
| 
8320
 
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
 
belugas 
parents: 
8318 
diff
changeset
 | 
498  | 
DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), y, STR_482B_TRANSPORTED, TC_FROMSTRING);  | 
| 
6527
 
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
 
belugas 
parents: 
6526 
diff
changeset
 | 
499  | 
/* Let's put out those buttons.. */  | 
| 
4211
 
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
 
miham 
parents: 
4194 
diff
changeset
 | 
500  | 
			if (IsProductionAlterable(i)) {
 | 
| 
7780
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
501  | 
DrawArrowButtons(5, y, 3, (WP(w, indview_d).clicked_line == j + 1) ? WP(w, indview_d).clicked_button : 0,  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
502  | 
!isProductionMinimum(i, j), !isProductionMaximum(i, j));  | 
| 
4211
 
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
 
miham 
parents: 
4194 
diff
changeset
 | 
503  | 
}  | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
504  | 
y += 10;  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
505  | 
}  | 
| 0 | 506  | 
|
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
507  | 
/* Get the extra message for the GUI */  | 
| 
8424
 
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
 
skidd13 
parents: 
8418 
diff
changeset
 | 
508  | 
		if (HasBit(ind->callback_flags, CBM_IND_WINDOW_MORE_TEXT)) {
 | 
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
509  | 
uint16 callback_res = GetIndustryCallback(CBID_INDUSTRY_WINDOW_MORE_TEXT, 0, 0, i, i->type, i->xy);  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
510  | 
			if (callback_res != CALLBACK_FAILED) {
 | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
511  | 
StringID message = GetGRFStringID(ind->grf_prop.grffile->grfid, 0xD000 + callback_res);  | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
512  | 
				if (message != STR_NULL && message != STR_UNDEFINED) {
 | 
| 
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
513  | 
y += 10;  | 
| 
8112
 
f432a920f3b7
(svn r11145) -Codechange: add support for "decoding" TTDPs string codes wrt to registers 0x100 to 0x10F.
 
rubidium 
parents: 
7837 
diff
changeset
 | 
514  | 
|
| 
8246
 
ff7b892d8a28
(svn r11287) -Codechange: add support for pushing paramaters into NewIndustries' error messages. Patch by Csaboka.
 
rubidium 
parents: 
8243 
diff
changeset
 | 
515  | 
PrepareTextRefStackUsage(6);  | 
| 
8320
 
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
 
belugas 
parents: 
8318 
diff
changeset
 | 
516  | 
DrawString(2, y, message, TC_FROMSTRING);  | 
| 
8112
 
f432a920f3b7
(svn r11145) -Codechange: add support for "decoding" TTDPs string codes wrt to registers 0x100 to 0x10F.
 
rubidium 
parents: 
7837 
diff
changeset
 | 
517  | 
StopTextRefStackUsage();  | 
| 
4211
 
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
 
miham 
parents: 
4194 
diff
changeset
 | 
518  | 
}  | 
| 0 | 519  | 
}  | 
520  | 
}  | 
|
521  | 
||
522  | 
DrawWindowViewport(w);  | 
|
| 
7691
 
64063937da38
(svn r10473) -Codechange: make the industry "window", the one that shows when you click on an industry, more flexible to allow easier integration with newindustries.
 
rubidium 
parents: 
7681 
diff
changeset
 | 
523  | 
} break;  | 
| 0 | 524  | 
|
| 1004 | 525  | 
	case WE_CLICK: {
 | 
526  | 
Industry *i;  | 
|
527  | 
||
| 
4634
 
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
 
belugas 
parents: 
4617 
diff
changeset
 | 
528  | 
		switch (e->we.click.widget) {
 | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
529  | 
		case IVW_INFO: {
 | 
| 
4193
 
ef08dda0369e
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
 
Darkvater 
parents: 
4192 
diff
changeset
 | 
530  | 
int line, x;  | 
| 1004 | 531  | 
|
532  | 
i = GetIndustry(w->window_number);  | 
|
533  | 
||
| 
6527
 
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
 
belugas 
parents: 
6526 
diff
changeset
 | 
534  | 
/* We should work if needed.. */  | 
| 
4194
 
18a32dace8ba
(svn r5654) -Cleanup: Change an ugly define into a function
 
Darkvater 
parents: 
4193 
diff
changeset
 | 
535  | 
if (!IsProductionAlterable(i)) return;  | 
| 
4634
 
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
 
belugas 
parents: 
4617 
diff
changeset
 | 
536  | 
x = e->we.click.pt.x;  | 
| 
7780
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
537  | 
line = (e->we.click.pt.y - WP(w, indview_d).production_offset_y) / 10;  | 
| 
8450
 
dce58137301f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
 
skidd13 
parents: 
8424 
diff
changeset
 | 
538  | 
			if (e->we.click.pt.y >= WP(w, indview_d).production_offset_y && IsInsideMM(line, 0, 2) && i->produced_cargo[line] != CT_INVALID) {
 | 
| 
 
dce58137301f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
 
skidd13 
parents: 
8424 
diff
changeset
 | 
539  | 
				if (IsInsideMM(x, 5, 25) ) {
 | 
| 
4193
 
ef08dda0369e
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
 
Darkvater 
parents: 
4192 
diff
changeset
 | 
540  | 
/* Clicked buttons, decrease or increase production */  | 
| 
1019
 
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
 
tron 
parents: 
1004 
diff
changeset
 | 
541  | 
					if (x < 15) {
 | 
| 
4211
 
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
 
miham 
parents: 
4194 
diff
changeset
 | 
542  | 
if (isProductionMinimum(i, line)) return;  | 
| 
8286
 
f3d626cd1969
(svn r11340) -Fix[FS#1362]: Newindustries can provide no production at start. So the Modifying Production cheat was a bit puzzled on how to deal with it.  This will help a bit.
 
belugas 
parents: 
8246 
diff
changeset
 | 
543  | 
i->production_rate[line] = max(i->production_rate[line] / 2, 0);  | 
| 1004 | 544  | 
					} else {
 | 
| 
8286
 
f3d626cd1969
(svn r11340) -Fix[FS#1362]: Newindustries can provide no production at start. So the Modifying Production cheat was a bit puzzled on how to deal with it.  This will help a bit.
 
belugas 
parents: 
8246 
diff
changeset
 | 
545  | 
/* a zero production industry is unlikely to give anything but zero, so push it a little bit */  | 
| 
 
f3d626cd1969
(svn r11340) -Fix[FS#1362]: Newindustries can provide no production at start. So the Modifying Production cheat was a bit puzzled on how to deal with it.  This will help a bit.
 
belugas 
parents: 
8246 
diff
changeset
 | 
546  | 
int new_prod = i->production_rate[line] == 0 ? 1 : i->production_rate[line] * 2;  | 
| 
4211
 
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
 
miham 
parents: 
4194 
diff
changeset
 | 
547  | 
if (isProductionMaximum(i, line)) return;  | 
| 
8286
 
f3d626cd1969
(svn r11340) -Fix[FS#1362]: Newindustries can provide no production at start. So the Modifying Production cheat was a bit puzzled on how to deal with it.  This will help a bit.
 
belugas 
parents: 
8246 
diff
changeset
 | 
548  | 
i->production_rate[line] = minu(new_prod, 255);  | 
| 1004 | 549  | 
}  | 
| 
4193
 
ef08dda0369e
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
 
Darkvater 
parents: 
4192 
diff
changeset
 | 
550  | 
|
| 1004 | 551  | 
UpdateIndustryProduction(i);  | 
552  | 
SetWindowDirty(w);  | 
|
553  | 
w->flags4 |= 5 << WF_TIMEOUT_SHL;  | 
|
| 
7780
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
554  | 
WP(w, indview_d).clicked_line = line + 1;  | 
| 
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
555  | 
WP(w, indview_d).clicked_button = (x < 15 ? 1 : 2);  | 
| 
8450
 
dce58137301f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
 
skidd13 
parents: 
8424 
diff
changeset
 | 
556  | 
				} else if (IsInsideMM(x, 34, 160)) {
 | 
| 
6527
 
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
 
belugas 
parents: 
6526 
diff
changeset
 | 
557  | 
/* clicked the text */  | 
| 
7780
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
558  | 
WP(w, indview_d).editbox_line = line;  | 
| 1004 | 559  | 
SetDParam(0, i->production_rate[line] * 8);  | 
| 
5682
 
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
 
Darkvater 
parents: 
5568 
diff
changeset
 | 
560  | 
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_GAME_PRODUCTION, 10, 100, w, CS_ALPHANUMERAL);  | 
| 1004 | 561  | 
}  | 
| 
1019
 
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
 
tron 
parents: 
1004 
diff
changeset
 | 
562  | 
}  | 
| 
4193
 
ef08dda0369e
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
 
Darkvater 
parents: 
4192 
diff
changeset
 | 
563  | 
} break;  | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
564  | 
case IVW_GOTO:  | 
| 
919
 
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
 
truelight 
parents: 
893 
diff
changeset
 | 
565  | 
i = GetIndustry(w->window_number);  | 
| 1981 | 566  | 
ScrollMainWindowToTile(i->xy + TileDiffXY(1, 1));  | 
| 
6988
 
76eba6a9cc6f
(svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
 
rubidium 
parents: 
6987 
diff
changeset
 | 
567  | 
} break;  | 
| 
4193
 
ef08dda0369e
(svn r5653) -Cleanup: Do a little cleanup of the industry gui code.
 
Darkvater 
parents: 
4192 
diff
changeset
 | 
568  | 
|
| 1004 | 569  | 
}  | 
| 0 | 570  | 
break;  | 
| 1004 | 571  | 
case WE_TIMEOUT:  | 
| 
7780
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
572  | 
WP(w, indview_d).clicked_line = 0;  | 
| 
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
573  | 
WP(w, indview_d).clicked_button = 0;  | 
| 1004 | 574  | 
SetWindowDirty(w);  | 
575  | 
break;  | 
|
576  | 
||
577  | 
case WE_ON_EDIT_TEXT:  | 
|
| 
4634
 
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
 
belugas 
parents: 
4617 
diff
changeset
 | 
578  | 
		if (e->we.edittext.str[0] != '\0') {
 | 
| 
3017
 
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
 
tron 
parents: 
2989 
diff
changeset
 | 
579  | 
Industry* i = GetIndustry(w->window_number);  | 
| 
7780
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
580  | 
int line = WP(w, indview_d).editbox_line;  | 
| 1004 | 581  | 
|
| 
8418
 
b49fc6be1ab9
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
 
skidd13 
parents: 
8385 
diff
changeset
 | 
582  | 
i->production_rate[line] = ClampU(atoi(e->we.edittext.str), 0, 255);  | 
| 1004 | 583  | 
UpdateIndustryProduction(i);  | 
584  | 
SetWindowDirty(w);  | 
|
585  | 
}  | 
|
| 0 | 586  | 
}  | 
587  | 
}  | 
|
588  | 
||
| 1004 | 589  | 
static void UpdateIndustryProduction(Industry *i)  | 
590  | 
{
 | 
|
| 
8141
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
591  | 
	for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
 | 
| 
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
592  | 
		if (i->produced_cargo[j] != CT_INVALID) {
 | 
| 
7315
 
f1b2591ad082
(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: 
7311 
diff
changeset
 | 
593  | 
i->last_month_production[j] = 8 * i->production_rate[j];  | 
| 
7132
 
08abbae3073e
(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: 
7120 
diff
changeset
 | 
594  | 
}  | 
| 
 
08abbae3073e
(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: 
7120 
diff
changeset
 | 
595  | 
}  | 
| 1004 | 596  | 
}  | 
597  | 
||
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
598  | 
/** Widget definition of the view industy gui */  | 
| 0 | 599  | 
static const Widget _industry_view_widgets[] = {
 | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
600  | 
{   WWT_CLOSEBOX,   RESIZE_NONE,     9,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},            // IVW_CLOSEBOX
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
601  | 
{    WWT_CAPTION,   RESIZE_NONE,     9,    11,   247,     0,    13, STR_4801,          STR_018C_WINDOW_TITLE_DRAG_THIS},  // IVW_CAPTION
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
602  | 
{  WWT_STICKYBOX,   RESIZE_NONE,     9,   248,   259,     0,    13, 0x0,               STR_STICKY_BUTTON},                // IVW_STICKY
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
603  | 
{      WWT_PANEL,   RESIZE_NONE,     9,     0,   259,    14,   105, 0x0,               STR_NULL},                         // IVW_BACKGROUND
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
604  | 
{      WWT_INSET,   RESIZE_NONE,     9,     2,   257,    16,   103, 0x0,               STR_NULL},                         // IVW_VIEWPORT
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
605  | 
{      WWT_PANEL,   RESIZE_NONE,     9,     0,   259,   106,   147, 0x0,               STR_NULL},                         // IVW_INFO
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
606  | 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     9,     0,   129,   148,   159, STR_00E4_LOCATION, STR_482C_CENTER_THE_MAIN_VIEW_ON}, // IVW_GOTO
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
607  | 
{      WWT_PANEL,   RESIZE_NONE,     9,   130,   259,   148,   159, 0x0,               STR_NULL},                         // IVW_SPACER
 | 
| 
176
 
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
 
darkvater 
parents: 
164 
diff
changeset
 | 
608  | 
{   WIDGETS_END},
 | 
| 0 | 609  | 
};  | 
610  | 
||
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
611  | 
/** Window definition of the view industy gui */  | 
| 0 | 612  | 
static const WindowDesc _industry_view_desc = {
 | 
| 
7837
 
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
 
rubidium 
parents: 
7815 
diff
changeset
 | 
613  | 
WDP_AUTO, WDP_AUTO, 260, 160, 260, 160,  | 
| 
6144
 
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
 
rubidium 
parents: 
5860 
diff
changeset
 | 
614  | 
WC_INDUSTRY_VIEW, WC_NONE,  | 
| 
758
 
bd9e868b9fae
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
 
darkvater 
parents: 
727 
diff
changeset
 | 
615  | 
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,  | 
| 0 | 616  | 
_industry_view_widgets,  | 
617  | 
IndustryViewWndProc  | 
|
618  | 
};  | 
|
619  | 
||
620  | 
void ShowIndustryViewWindow(int industry)  | 
|
621  | 
{
 | 
|
| 4171 | 622  | 
Window *w = AllocateWindowDescFront(&_industry_view_desc, industry);  | 
| 0 | 623  | 
|
| 2989 | 624  | 
	if (w != NULL) {
 | 
| 0 | 625  | 
w->flags4 |= WF_DISABLE_VP_SCROLL;  | 
| 
7780
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
626  | 
WP(w, indview_d).editbox_line = 0;  | 
| 
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
627  | 
WP(w, indview_d).clicked_line = 0;  | 
| 
 
205d95d3bb5b
(svn r10624) -Fix [FS#1047]: the production of banks could not be modified (either in scenario editor or with the cheat).
 
rubidium 
parents: 
7779 
diff
changeset
 | 
628  | 
WP(w, indview_d).clicked_button = 0;  | 
| 
7120
 
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
 
truelight 
parents: 
6988 
diff
changeset
 | 
629  | 
AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetIndustry(w->window_number)->xy + TileDiffXY(1, 1), ZOOM_LVL_INDUSTRY);  | 
| 0 | 630  | 
}  | 
631  | 
}  | 
|
632  | 
||
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
633  | 
/** Names of the widgets of the industry directory gui */  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
634  | 
enum IndustryDirectoryWidgets {
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
635  | 
IDW_CLOSEBOX = 0,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
636  | 
IDW_CAPTION,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
637  | 
IDW_STICKY,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
638  | 
IDW_SORTBYNAME,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
639  | 
IDW_SORTBYTYPE,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
640  | 
IDW_SORTBYPROD,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
641  | 
IDW_SORTBYTRANSPORT,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
642  | 
IDW_SPACER,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
643  | 
IDW_INDUSRTY_LIST,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
644  | 
IDW_SCROLLBAR,  | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
645  | 
IDW_RESIZE,  | 
| 
7774
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
646  | 
};  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
647  | 
|
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
648  | 
/** Widget definition of the industy directory gui */  | 
| 0 | 649  | 
static const Widget _industry_directory_widgets[] = {
 | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
650  | 
{   WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},             // IDW_CLOSEBOX
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
651  | 
{    WWT_CAPTION,   RESIZE_NONE,    13,    11,   495,     0,    13, STR_INDUSTRYDIR_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS},   // IDW_CAPTION
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
652  | 
{  WWT_STICKYBOX,   RESIZE_NONE,    13,   496,   507,     0,    13, 0x0,                     STR_STICKY_BUTTON},                 // IDW_STICKY
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
653  | 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    13,     0,   100,    14,    25, STR_SORT_BY_NAME,        STR_SORT_ORDER_TIP},                // IDW_SORTBYNAME
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
654  | 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    13,   101,   200,    14,    25, STR_SORT_BY_TYPE,        STR_SORT_ORDER_TIP},                // IDW_SORTBYTYPE
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
655  | 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    13,   201,   300,    14,    25, STR_SORT_BY_PRODUCTION,  STR_SORT_ORDER_TIP},                // IDW_SORTBYPROD
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
656  | 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    13,   301,   400,    14,    25, STR_SORT_BY_TRANSPORTED, STR_SORT_ORDER_TIP},                // IDW_SORTBYTRANSPORT
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
657  | 
{      WWT_PANEL,   RESIZE_NONE,    13,   401,   495,    14,    25, 0x0,                     STR_NULL},                          // IDW_SPACER
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
658  | 
{      WWT_PANEL, RESIZE_BOTTOM,    13,     0,   495,    26,   189, 0x0,                     STR_200A_TOWN_NAMES_CLICK_ON_NAME}, // IDW_INDUSRTY_LIST
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
659  | 
{  WWT_SCROLLBAR, RESIZE_BOTTOM,    13,   496,   507,    14,   177, 0x0,                     STR_0190_SCROLL_BAR_SCROLLS_LIST},  // IDW_SCROLLBAR
 | 
| 
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
660  | 
{  WWT_RESIZEBOX,     RESIZE_TB,    13,   496,   507,   178,   189, 0x0,                     STR_RESIZE_BUTTON},                 // IDW_RESIZE
 | 
| 
176
 
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
 
darkvater 
parents: 
164 
diff
changeset
 | 
661  | 
{   WIDGETS_END},
 | 
| 0 | 662  | 
};  | 
663  | 
||
664  | 
static uint _num_industry_sort;  | 
|
665  | 
||
666  | 
static char _bufcache[96];  | 
|
| 
4277
 
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
 
tron 
parents: 
4211 
diff
changeset
 | 
667  | 
static const Industry* _last_industry;  | 
| 0 | 668  | 
|
669  | 
static byte _industry_sort_order;  | 
|
670  | 
||
| 
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
 | 
671  | 
static int CDECL GeneralIndustrySorter(const void *a, const void *b)  | 
| 0 | 672  | 
{
 | 
| 
4277
 
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
 
tron 
parents: 
4211 
diff
changeset
 | 
673  | 
const Industry* i = *(const Industry**)a;  | 
| 
 
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
 
tron 
parents: 
4211 
diff
changeset
 | 
674  | 
const Industry* j = *(const Industry**)b;  | 
| 
4282
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
675  | 
int r;  | 
| 0 | 676  | 
|
677  | 
	switch (_industry_sort_order >> 1) {
 | 
|
| 
4282
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
678  | 
default: NOT_REACHED();  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
679  | 
case 0: /* Sort by Name (handled later) */  | 
| 0 | 680  | 
r = 0;  | 
| 
4282
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
681  | 
break;  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
682  | 
|
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
683  | 
case 1: /* Sort by Type */  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
684  | 
r = i->type - j->type;  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
685  | 
break;  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
686  | 
|
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
687  | 
case 2: /* Sort by Production */  | 
| 
8141
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
688  | 
			if (i->produced_cargo[0] == CT_INVALID) {
 | 
| 
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
689  | 
r = (j->produced_cargo[0] == CT_INVALID ? 0 : -1);  | 
| 
4282
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
690  | 
			} else {
 | 
| 
8141
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
691  | 
				if (j->produced_cargo[0] == CT_INVALID) {
 | 
| 
4282
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
692  | 
r = 1;  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
693  | 
				} else {
 | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
694  | 
r =  | 
| 
7315
 
f1b2591ad082
(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: 
7311 
diff
changeset
 | 
695  | 
(i->last_month_production[0] + i->last_month_production[1]) -  | 
| 
 
f1b2591ad082
(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: 
7311 
diff
changeset
 | 
696  | 
(j->last_month_production[0] + j->last_month_production[1]);  | 
| 
4282
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
697  | 
}  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
698  | 
}  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
699  | 
break;  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
700  | 
|
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
701  | 
case 3: /* Sort by transported fraction */  | 
| 
8141
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
702  | 
			if (i->produced_cargo[0] == CT_INVALID) {
 | 
| 
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
703  | 
r = (j->produced_cargo[0] == CT_INVALID ? 0 : -1);  | 
| 
4282
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
704  | 
			} else {
 | 
| 
8141
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
705  | 
				if (j->produced_cargo[0] == CT_INVALID) {
 | 
| 
4282
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
706  | 
r = 1;  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
707  | 
				} else {
 | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
708  | 
int pi;  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
709  | 
int pj;  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
710  | 
|
| 
7315
 
f1b2591ad082
(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: 
7311 
diff
changeset
 | 
711  | 
pi = i->last_month_pct_transported[0] * 100 >> 8;  | 
| 
8141
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
712  | 
					if (i->produced_cargo[1] != CT_INVALID) {
 | 
| 
7315
 
f1b2591ad082
(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: 
7311 
diff
changeset
 | 
713  | 
int p = i->last_month_pct_transported[1] * 100 >> 8;  | 
| 
4282
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
714  | 
if (p < pi) pi = p;  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
715  | 
}  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
716  | 
|
| 
7315
 
f1b2591ad082
(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: 
7311 
diff
changeset
 | 
717  | 
pj = j->last_month_pct_transported[0] * 100 >> 8;  | 
| 
8141
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
718  | 
					if (j->produced_cargo[1] != CT_INVALID) {
 | 
| 
7315
 
f1b2591ad082
(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: 
7311 
diff
changeset
 | 
719  | 
int p = j->last_month_pct_transported[1] * 100 >> 8;  | 
| 
4282
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
720  | 
if (p < pj) pj = p;  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
721  | 
}  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
722  | 
|
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
723  | 
r = pi - pj;  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
724  | 
}  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
725  | 
}  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
726  | 
break;  | 
| 0 | 727  | 
}  | 
728  | 
||
| 
6527
 
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
 
belugas 
parents: 
6526 
diff
changeset
 | 
729  | 
/* default to string sorting if they are otherwise equal */  | 
| 0 | 730  | 
	if (r == 0) {
 | 
| 
4282
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
731  | 
char buf1[96];  | 
| 
 
cd0af1cdc454
(svn r5912) -Fix: Sort order for produced amount and transported percentage was reversed in the industry list
 
tron 
parents: 
4277 
diff
changeset
 | 
732  | 
|
| 
2070
 
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
 
ludde 
parents: 
2063 
diff
changeset
 | 
733  | 
SetDParam(0, i->town->index);  | 
| 
4912
 
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
 
Darkvater 
parents: 
4896 
diff
changeset
 | 
734  | 
GetString(buf1, STR_TOWN, lastof(buf1));  | 
| 0 | 735  | 
|
| 
4277
 
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
 
tron 
parents: 
4211 
diff
changeset
 | 
736  | 
		if (j != _last_industry) {
 | 
| 
 
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
 
tron 
parents: 
4211 
diff
changeset
 | 
737  | 
_last_industry = j;  | 
| 
2070
 
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
 
ludde 
parents: 
2063 
diff
changeset
 | 
738  | 
SetDParam(0, j->town->index);  | 
| 
4912
 
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
 
Darkvater 
parents: 
4896 
diff
changeset
 | 
739  | 
GetString(_bufcache, STR_TOWN, lastof(_bufcache));  | 
| 0 | 740  | 
}  | 
741  | 
r = strcmp(buf1, _bufcache);  | 
|
742  | 
}  | 
|
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
743  | 
|
| 
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
744  | 
if (_industry_sort_order & 1) r = -r;  | 
| 0 | 745  | 
return r;  | 
746  | 
}  | 
|
747  | 
||
| 
6526
 
85cfa44803d0
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
 
rubidium 
parents: 
6417 
diff
changeset
 | 
748  | 
/**  | 
| 
 
85cfa44803d0
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
 
rubidium 
parents: 
6417 
diff
changeset
 | 
749  | 
* Makes a sorted industry list.  | 
| 
 
85cfa44803d0
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
 
rubidium 
parents: 
6417 
diff
changeset
 | 
750  | 
* When there are no industries, the list has to be made. This so when one  | 
| 
 
85cfa44803d0
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
 
rubidium 
parents: 
6417 
diff
changeset
 | 
751  | 
* starts a new game without industries after playing a game with industries  | 
| 
 
85cfa44803d0
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
 
rubidium 
parents: 
6417 
diff
changeset
 | 
752  | 
* the list is not populated with invalid industries from the previous game.  | 
| 
 
85cfa44803d0
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
 
rubidium 
parents: 
6417 
diff
changeset
 | 
753  | 
*/  | 
| 6573 | 754  | 
static void MakeSortedIndustryList()  | 
| 0 | 755  | 
{
 | 
| 
4277
 
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
 
tron 
parents: 
4211 
diff
changeset
 | 
756  | 
const Industry* i;  | 
| 
919
 
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
 
truelight 
parents: 
893 
diff
changeset
 | 
757  | 
int n = 0;  | 
| 
 
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
 
truelight 
parents: 
893 
diff
changeset
 | 
758  | 
|
| 
 
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
 
truelight 
parents: 
893 
diff
changeset
 | 
759  | 
/* Create array for sorting */  | 
| 
5860
 
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
 
KUDr 
parents: 
5852 
diff
changeset
 | 
760  | 
_industry_sort = ReallocT(_industry_sort, GetMaxIndustryIndex() + 1);  | 
| 0 | 761  | 
|
| 
6526
 
85cfa44803d0
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
 
rubidium 
parents: 
6417 
diff
changeset
 | 
762  | 
/* Don't attempt a sort if there are no industries */  | 
| 
 
85cfa44803d0
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
 
rubidium 
parents: 
6417 
diff
changeset
 | 
763  | 
	if (GetNumIndustries() != 0) {
 | 
| 
 
85cfa44803d0
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
 
rubidium 
parents: 
6417 
diff
changeset
 | 
764  | 
FOR_ALL_INDUSTRIES(i) _industry_sort[n++] = i;  | 
| 
 
85cfa44803d0
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
 
rubidium 
parents: 
6417 
diff
changeset
 | 
765  | 
qsort((void*)_industry_sort, n, sizeof(_industry_sort[0]), GeneralIndustrySorter);  | 
| 
 
85cfa44803d0
(svn r8980) -Fix (FS#656): the industry list should also be (re)set when the number of industries is 0.
 
rubidium 
parents: 
6417 
diff
changeset
 | 
766  | 
}  | 
| 
4346
 
3f00094f2670
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
 
truelight 
parents: 
4344 
diff
changeset
 | 
767  | 
|
| 0 | 768  | 
_num_industry_sort = n;  | 
| 
4277
 
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
 
tron 
parents: 
4211 
diff
changeset
 | 
769  | 
_last_industry = NULL; // used for "cache"  | 
| 0 | 770  | 
|
| 
5568
 
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
 
Darkvater 
parents: 
5247 
diff
changeset
 | 
771  | 
DEBUG(misc, 3, "Resorting industries list");  | 
| 0 | 772  | 
}  | 
773  | 
||
774  | 
||
775  | 
static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)  | 
|
776  | 
{
 | 
|
| 2951 | 777  | 
	switch (e->event) {
 | 
| 0 | 778  | 
	case WE_PAINT: {
 | 
779  | 
int n;  | 
|
780  | 
uint p;  | 
|
781  | 
		static const uint16 _indicator_positions[4] = {88, 187, 284, 387};
 | 
|
782  | 
||
783  | 
		if (_industry_sort_dirty) {
 | 
|
784  | 
_industry_sort_dirty = false;  | 
|
785  | 
MakeSortedIndustryList();  | 
|
786  | 
}  | 
|
787  | 
||
| 
1666
 
b36927825adb
(svn r2170) -fix: [1179457] the industry list can now no longer scroll down then the end of the list is reached (Hackykid)
 
bjarni 
parents: 
1388 
diff
changeset
 | 
788  | 
SetVScrollCount(w, _num_industry_sort);  | 
| 0 | 789  | 
|
790  | 
DrawWindowWidgets(w);  | 
|
| 
8320
 
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
 
belugas 
parents: 
8318 
diff
changeset
 | 
791  | 
DoDrawString(_industry_sort_order & 1 ? DOWNARROW : UPARROW, _indicator_positions[_industry_sort_order >> 1], 15, TC_BLACK);  | 
| 0 | 792  | 
|
793  | 
p = w->vscroll.pos;  | 
|
794  | 
n = 0;  | 
|
795  | 
||
796  | 
		while (p < _num_industry_sort) {
 | 
|
| 
4277
 
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
 
tron 
parents: 
4211 
diff
changeset
 | 
797  | 
const Industry* i = _industry_sort[p];  | 
| 2989 | 798  | 
|
| 
2070
 
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
 
ludde 
parents: 
2063 
diff
changeset
 | 
799  | 
SetDParam(0, i->index);  | 
| 
8141
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
800  | 
			if (i->produced_cargo[0] != CT_INVALID) {
 | 
| 
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
801  | 
SetDParam(1, i->produced_cargo[0]);  | 
| 
7315
 
f1b2591ad082
(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: 
7311 
diff
changeset
 | 
802  | 
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
 | 
803  | 
|
| 
8141
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
804  | 
				if (i->produced_cargo[1] != CT_INVALID) {
 | 
| 
 
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
 
glx 
parents: 
8112 
diff
changeset
 | 
805  | 
SetDParam(3, i->produced_cargo[1]);  | 
| 
7315
 
f1b2591ad082
(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: 
7311 
diff
changeset
 | 
806  | 
SetDParam(4, i->last_month_production[1]);  | 
| 
 
f1b2591ad082
(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: 
7311 
diff
changeset
 | 
807  | 
SetDParam(5, i->last_month_pct_transported[0] * 100 >> 8);  | 
| 
 
f1b2591ad082
(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: 
7311 
diff
changeset
 | 
808  | 
SetDParam(6, i->last_month_pct_transported[1] * 100 >> 8);  | 
| 
8320
 
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
 
belugas 
parents: 
8318 
diff
changeset
 | 
809  | 
DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM_TWO, TC_FROMSTRING);  | 
| 0 | 810  | 
				} else {
 | 
| 
7315
 
f1b2591ad082
(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: 
7311 
diff
changeset
 | 
811  | 
SetDParam(3, i->last_month_pct_transported[0] * 100 >> 8);  | 
| 
8320
 
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
 
belugas 
parents: 
8318 
diff
changeset
 | 
812  | 
DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM, TC_FROMSTRING);  | 
| 0 | 813  | 
}  | 
814  | 
			} else {
 | 
|
| 
8320
 
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
 
belugas 
parents: 
8318 
diff
changeset
 | 
815  | 
DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM_NOPROD, TC_FROMSTRING);  | 
| 0 | 816  | 
}  | 
817  | 
p++;  | 
|
| 2951 | 818  | 
if (++n == w->vscroll.cap) break;  | 
| 0 | 819  | 
}  | 
820  | 
} break;  | 
|
821  | 
||
822  | 
case WE_CLICK:  | 
|
| 
4634
 
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
 
belugas 
parents: 
4617 
diff
changeset
 | 
823  | 
		switch (e->we.click.widget) {
 | 
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
824  | 
			case IDW_SORTBYNAME: {
 | 
| 
7774
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
825  | 
_industry_sort_order = _industry_sort_order == 0 ? 1 : 0;  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
826  | 
_industry_sort_dirty = true;  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
827  | 
SetWindowDirty(w);  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
828  | 
} break;  | 
| 0 | 829  | 
|
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
830  | 
			case IDW_SORTBYTYPE: {
 | 
| 
7774
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
831  | 
_industry_sort_order = _industry_sort_order == 2 ? 3 : 2;  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
832  | 
_industry_sort_dirty = true;  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
833  | 
SetWindowDirty(w);  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
834  | 
} break;  | 
| 0 | 835  | 
|
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
836  | 
			case IDW_SORTBYPROD: {
 | 
| 
7774
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
837  | 
_industry_sort_order = _industry_sort_order == 4 ? 5 : 4;  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
838  | 
_industry_sort_dirty = true;  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
839  | 
SetWindowDirty(w);  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
840  | 
} break;  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
841  | 
|
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
842  | 
			case IDW_SORTBYTRANSPORT: {
 | 
| 
7774
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
843  | 
_industry_sort_order = _industry_sort_order == 6 ? 7 : 6;  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
844  | 
_industry_sort_dirty = true;  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
845  | 
SetWindowDirty(w);  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
846  | 
} break;  | 
| 0 | 847  | 
|
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
848  | 
			case IDW_INDUSRTY_LIST: {
 | 
| 
7774
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
849  | 
int y = (e->we.click.pt.y - 28) / 10;  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
850  | 
uint16 p;  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
851  | 
|
| 
8450
 
dce58137301f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
 
skidd13 
parents: 
8424 
diff
changeset
 | 
852  | 
if (!IsInsideMM(y, 0, w->vscroll.cap)) return;  | 
| 
7774
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
853  | 
p = y + w->vscroll.pos;  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
854  | 
				if (p < _num_industry_sort) {
 | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
855  | 
ScrollMainWindowToTile(_industry_sort[p]->xy);  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
856  | 
}  | 
| 
 
4fe72e9c0daa
(svn r10617) -Codechange: code style changes (removing an erroneous tab plus switch case alignment)
 
belugas 
parents: 
7767 
diff
changeset
 | 
857  | 
} break;  | 
| 0 | 858  | 
}  | 
859  | 
break;  | 
|
860  | 
||
861  | 
case WE_4:  | 
|
862  | 
SetWindowDirty(w);  | 
|
863  | 
break;  | 
|
| 
867
 
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
830 
diff
changeset
 | 
864  | 
|
| 
 
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
830 
diff
changeset
 | 
865  | 
case WE_RESIZE:  | 
| 
4634
 
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
 
belugas 
parents: 
4617 
diff
changeset
 | 
866  | 
w->vscroll.cap += e->we.sizing.diff.y / 10;  | 
| 
867
 
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
830 
diff
changeset
 | 
867  | 
break;  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
868  | 
}  | 
| 0 | 869  | 
}  | 
870  | 
||
| 
8543
 
fd72fcb5e3c4
(svn r11607) -Codechange: Enumify the industry widgets
 
skidd13 
parents: 
8536 
diff
changeset
 | 
871  | 
/** Window definition of the industy directory gui */  | 
| 0 | 872  | 
static const WindowDesc _industry_directory_desc = {
 | 
| 
7837
 
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
 
rubidium 
parents: 
7815 
diff
changeset
 | 
873  | 
WDP_AUTO, WDP_AUTO, 508, 190, 508, 190,  | 
| 
6144
 
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
 
rubidium 
parents: 
5860 
diff
changeset
 | 
874  | 
WC_INDUSTRY_DIRECTORY, WC_NONE,  | 
| 
867
 
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
830 
diff
changeset
 | 
875  | 
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,  | 
| 0 | 876  | 
_industry_directory_widgets,  | 
877  | 
IndustryDirectoryWndProc  | 
|
878  | 
};  | 
|
879  | 
||
| 6573 | 880  | 
void ShowIndustryDirectory()  | 
| 0 | 881  | 
{
 | 
| 4171 | 882  | 
Window *w = AllocateWindowDescFront(&_industry_directory_desc, 0);  | 
| 0 | 883  | 
|
| 2989 | 884  | 
	if (w != NULL) {
 | 
| 0 | 885  | 
w->vscroll.cap = 16;  | 
| 
867
 
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
830 
diff
changeset
 | 
886  | 
w->resize.height = w->height - 6 * 10; // minimum 10 items  | 
| 
 
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
830 
diff
changeset
 | 
887  | 
w->resize.step_height = 10;  | 
| 0 | 888  | 
SetWindowDirty(w);  | 
889  | 
}  | 
|
890  | 
}  |