author | skidd13 |
Thu, 29 Nov 2007 18:27:39 +0000 | |
changeset 7983 | 3b1fec9d5e31 |
parent 7824 | 5a63d41b59ea |
child 8020 | ba100ceda5b4 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6117
6507b2a7e71d
(svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents:
5931
diff
changeset
|
3 |
/** @file bridge_gui.cpp Graphical user interface for bridge construction */ |
2262
252cfd94c54d
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2186
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1781
diff
changeset
|
6 |
#include "openttd.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
337
diff
changeset
|
7 |
#include "table/strings.h" |
7266
b16e67e992b4
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7002
diff
changeset
|
8 |
#include "strings.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
9 |
#include "functions.h" |
679
04ca2cd69420
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
543
diff
changeset
|
10 |
#include "map.h" |
0 | 11 |
#include "window.h" |
12 |
#include "gui.h" |
|
13 |
#include "viewport.h" |
|
14 |
#include "gfx.h" |
|
15 |
#include "command.h" |
|
337
cbe0c766c947
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
203
diff
changeset
|
16 |
#include "sound.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2133
diff
changeset
|
17 |
#include "variables.h" |
2262
252cfd94c54d
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2186
diff
changeset
|
18 |
#include "bridge.h" |
0 | 19 |
|
20 |
static struct BridgeData { |
|
2133 | 21 |
uint count; |
0 | 22 |
TileIndex start_tile; |
23 |
TileIndex end_tile; |
|
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
24 |
uint8 type; |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
25 |
uint8 indexes[MAX_BRIDGES]; |
6990
136a08baf0ed
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
6950
diff
changeset
|
26 |
Money costs[MAX_BRIDGES]; |
2262
252cfd94c54d
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2186
diff
changeset
|
27 |
} _bridgedata; |
0 | 28 |
|
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
29 |
void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 30 |
{ |
541 | 31 |
if (success) SndPlayTileFx(SND_27_BLACKSMITH_ANVIL, tile); |
0 | 32 |
} |
33 |
||
34 |
static void BuildBridge(Window *w, int i) |
|
35 |
{ |
|
36 |
DeleteWindow(w); |
|
2639 | 37 |
DoCommandP(_bridgedata.end_tile, _bridgedata.start_tile, |
38 |
_bridgedata.indexes[i] | (_bridgedata.type << 8), CcBuildBridge, |
|
7521
0da1e91510e4
(svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents:
7341
diff
changeset
|
39 |
CMD_BUILD_BRIDGE | CMD_MSG(STR_5015_CAN_T_BUILD_BRIDGE_HERE)); |
0 | 40 |
} |
41 |
||
42 |
static void BuildBridgeWndProc(Window *w, WindowEvent *e) |
|
43 |
{ |
|
2952 | 44 |
switch (e->event) { |
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
45 |
case WE_PAINT: { |
6204
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
46 |
DrawWindowWidgets(w); |
0 | 47 |
|
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
48 |
uint y = 15; |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
49 |
for (uint i = 0; (i < w->vscroll.cap) && ((i + w->vscroll.pos) < _bridgedata.count); i++) { |
6204
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
50 |
const Bridge *b = &_bridge[_bridgedata.indexes[i + w->vscroll.pos]]; |
0 | 51 |
|
7002
1bf6a62b0fcb
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
6991
diff
changeset
|
52 |
SetDParam(2, _bridgedata.costs[i + w->vscroll.pos]); |
6204
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
53 |
SetDParam(1, b->speed * 10 / 16); |
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
54 |
SetDParam(0, b->material); |
0 | 55 |
|
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
56 |
DrawSprite(b->sprite, b->pal, 3, y); |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
57 |
DrawString(44, y, STR_500D, TC_FROMSTRING); |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
58 |
y += w->resize.step_height; |
6204
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
59 |
} |
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
60 |
break; |
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
61 |
} |
6204
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
62 |
|
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
63 |
case WE_KEYPRESS: { |
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
64 |
const uint8 i = e->we.keypress.keycode - '1'; |
6204
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
65 |
if (i < 9 && i < _bridgedata.count) { |
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
66 |
e->we.keypress.cont = false; |
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
67 |
BuildBridge(w, i); |
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
68 |
} |
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
69 |
|
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
70 |
break; |
0 | 71 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
72 |
|
6204
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
73 |
case WE_CLICK: |
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
74 |
if (e->we.click.widget == 2) { |
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
75 |
uint ind = ((int)e->we.click.pt.y - 14) / w->resize.step_height; |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
76 |
if (ind < w->vscroll.cap) { |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
77 |
ind += w->vscroll.pos; |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
78 |
if (ind < _bridgedata.count) { |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
79 |
BuildBridge(w, ind); |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
80 |
} |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
81 |
} |
6204
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
82 |
} |
8cfc3aebfa3a
(svn r8990) -Fix: more indenting and variable scoping
peter1138
parents:
6117
diff
changeset
|
83 |
break; |
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
84 |
|
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
85 |
case WE_RESIZE: |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
86 |
w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height; |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
87 |
w->widget[2].data = (w->vscroll.cap << 8) + 1; |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
88 |
SetVScrollCount(w, _bridgedata.count); |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
89 |
break; |
0 | 90 |
} |
91 |
} |
|
92 |
||
93 |
static const Widget _build_bridge_widgets[] = { |
|
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
94 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
95 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 199, 0, 13, STR_100D_SELECT_RAIL_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
96 |
{ WWT_MATRIX, RESIZE_BOTTOM, 7, 0, 187, 14, 101, 0x401, STR_101F_BRIDGE_SELECTION_CLICK}, |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
97 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 7, 188, 199, 14, 89, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
98 |
{ WWT_RESIZEBOX, RESIZE_TB, 7, 188, 199, 90, 101, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
99 |
{ WIDGETS_END}, |
0 | 100 |
}; |
101 |
||
102 |
static const WindowDesc _build_bridge_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7266
diff
changeset
|
103 |
WDP_AUTO, WDP_AUTO, 200, 102, 200, 102, |
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
4634
diff
changeset
|
104 |
WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR, |
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
105 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE, |
0 | 106 |
_build_bridge_widgets, |
107 |
BuildBridgeWndProc |
|
108 |
}; |
|
109 |
||
110 |
||
111 |
static const Widget _build_road_bridge_widgets[] = { |
|
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
112 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
113 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 199, 0, 13, STR_1803_SELECT_ROAD_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
114 |
{ WWT_MATRIX, RESIZE_BOTTOM, 7, 0, 187, 14, 101, 0x401, STR_101F_BRIDGE_SELECTION_CLICK}, |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
115 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 7, 188, 199, 14, 89, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
116 |
{ WWT_RESIZEBOX, RESIZE_TB, 7, 188, 199, 90, 101, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
117 |
{ WIDGETS_END}, |
0 | 118 |
}; |
119 |
||
120 |
static const WindowDesc _build_road_bridge_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7266
diff
changeset
|
121 |
WDP_AUTO, WDP_AUTO, 200, 102, 200, 102, |
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
4634
diff
changeset
|
122 |
WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR, |
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
123 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE, |
0 | 124 |
_build_road_bridge_widgets, |
125 |
BuildBridgeWndProc |
|
126 |
}; |
|
127 |
||
128 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
129 |
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type) |
0 | 130 |
{ |
131 |
DeleteWindowById(WC_BUILD_BRIDGE, 0); |
|
132 |
||
2262
252cfd94c54d
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2186
diff
changeset
|
133 |
_bridgedata.type = bridge_type; |
252cfd94c54d
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2186
diff
changeset
|
134 |
_bridgedata.start_tile = start; |
252cfd94c54d
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2186
diff
changeset
|
135 |
_bridgedata.end_tile = end; |
0 | 136 |
|
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
137 |
/* only query bridge building possibility once, result is the same for all bridges! |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
138 |
* returns CMD_ERROR on failure, and price on success */ |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
139 |
StringID errmsg = INVALID_STRING_ID; |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
140 |
CommandCost ret = DoCommand(end, start, (bridge_type << 8), DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE); |
0 | 141 |
|
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
142 |
uint8 j = 0; |
2737
fb1556b8f5e0
(svn r3282) - Codechange: Replace tests against CMD_ERROR with CmdFailed()
peter1138
parents:
2639
diff
changeset
|
143 |
if (CmdFailed(ret)) { |
0 | 144 |
errmsg = _error_message; |
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2470
diff
changeset
|
145 |
} else { |
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
146 |
/* check which bridges can be built |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
147 |
* get absolute bridge length |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
148 |
* length of the middle parts of the bridge */ |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
149 |
const uint bridge_len = GetBridgeLength(start, end); |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
150 |
/* total length of bridge */ |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
151 |
const uint tot_bridgedata_len = CalcBridgeLenCostFactor(bridge_len + 2); |
0 | 152 |
|
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
153 |
/* loop for all bridgetypes */ |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
154 |
for (bridge_type = 0; bridge_type != MAX_BRIDGES; bridge_type++) { |
0 | 155 |
if (CheckBridge_Stuff(bridge_type, bridge_len)) { |
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
156 |
/* bridge is accepted, add to list */ |
2262
252cfd94c54d
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2186
diff
changeset
|
157 |
const Bridge *b = &_bridge[bridge_type]; |
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
158 |
/* Add to terraforming & bulldozing costs the cost of the |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
159 |
* bridge itself (not computed with DC_QUERY_COST) */ |
6950
14ecb0acdfb4
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
6943
diff
changeset
|
160 |
_bridgedata.costs[j] = ret.GetCost() + (((int64)tot_bridgedata_len * _price.build_bridge * b->price) >> 8); |
2262
252cfd94c54d
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2186
diff
changeset
|
161 |
_bridgedata.indexes[j] = bridge_type; |
0 | 162 |
j++; |
163 |
} |
|
164 |
} |
|
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
165 |
|
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
166 |
_bridgedata.count = j; |
0 | 167 |
} |
168 |
||
169 |
if (j != 0) { |
|
2262
252cfd94c54d
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2186
diff
changeset
|
170 |
Window *w = AllocateWindowDesc((_bridgedata.type & 0x80) ? &_build_road_bridge_desc : &_build_bridge_desc); |
0 | 171 |
w->vscroll.cap = 4; |
7983
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
172 |
w->vscroll.count = j; |
3b1fec9d5e31
(svn r11539) -Feature: Make the bridge selection window resizable
skidd13
parents:
7824
diff
changeset
|
173 |
w->resize.step_height = 22; |
0 | 174 |
} else { |
3422
a6eba3443452
(svn r4249) -Codechange: Replace more occurences of 16 by TILE_SIZE and of 8 by TILE_HEIGHT. Reverted one change from the previous commit because it was faulty
celestar
parents:
2952
diff
changeset
|
175 |
ShowErrorMessage(errmsg, STR_5015_CAN_T_BUILD_BRIDGE_HERE, TileX(end) * TILE_SIZE, TileY(end) * TILE_SIZE); |
0 | 176 |
} |
177 |
} |