Mercurial > hg > openttd
changeset 6204:3a0d0f50833d draft
(svn r8990) -Fix: more indenting and variable scoping
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Sat, 03 Mar 2007 10:48:25 +0000 |
parents | 60d5fce9d6b0 |
children | 0f975e6cc2c0 |
files | src/bridge_gui.cpp |
diffstat | 1 files changed, 29 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -41,40 +41,38 @@ static void BuildBridgeWndProc(Window *w, WindowEvent *e) { switch (e->event) { - case WE_PAINT: { - uint i; + case WE_PAINT: + DrawWindowWidgets(w); - DrawWindowWidgets(w); + for (uint i = 0; i < 4 && i + w->vscroll.pos < _bridgedata.count; i++) { + const Bridge *b = &_bridge[_bridgedata.indexes[i + w->vscroll.pos]]; - for (i = 0; i < 4 && i + w->vscroll.pos < _bridgedata.count; i++) { - const Bridge *b = &_bridge[_bridgedata.indexes[i + w->vscroll.pos]]; + SetDParam(2, _bridgedata.costs[i + w->vscroll.pos]); + SetDParam(1, b->speed * 10 / 16); + SetDParam(0, b->material); + DrawSprite(b->sprite, b->pal, 3, 15 + i * 22); - SetDParam(2, _bridgedata.costs[i + w->vscroll.pos]); - SetDParam(1, b->speed * 10 / 16); - SetDParam(0, b->material); - DrawSprite(b->sprite, b->pal, 3, 15 + i * 22); + DrawString(44, 15 + i * 22 , STR_500D, 0); + } + break; - DrawString(44, 15 + i * 22 , STR_500D, 0); - } - } break; + case WE_KEYPRESS: { + uint i = e->we.keypress.keycode - '1'; + if (i < 9 && i < _bridgedata.count) { + e->we.keypress.cont = false; + BuildBridge(w, i); + } - case WE_KEYPRESS: { - uint i = e->we.keypress.keycode - '1'; - if (i < 9 && i < _bridgedata.count) { - e->we.keypress.cont = false; - BuildBridge(w, i); + break; } - break; - } - - case WE_CLICK: - if (e->we.click.widget == 2) { - uint ind = ((int)e->we.click.pt.y - 14) / 22; - if (ind < 4 && (ind += w->vscroll.pos) < _bridgedata.count) - BuildBridge(w, ind); - } - break; + case WE_CLICK: + if (e->we.click.widget == 2) { + uint ind = ((int)e->we.click.pt.y - 14) / 22; + if (ind < 4 && (ind += w->vscroll.pos) < _bridgedata.count) + BuildBridge(w, ind); + } + break; } } @@ -134,12 +132,11 @@ errmsg = _error_message; } else { // check which bridges can be built - int bridge_len; // length of the middle parts of the bridge - int tot_bridgedata_len; // total length of bridge - // get absolute bridge length - bridge_len = GetBridgeLength(start, end); - tot_bridgedata_len = bridge_len + 2; + // length of the middle parts of the bridge + int bridge_len = GetBridgeLength(start, end); + // total length of bridge + int tot_bridgedata_len = bridge_len + 2; tot_bridgedata_len = CalcBridgeLenCostFactor(tot_bridgedata_len);