summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-08-08 11:02:57 +0000
committeralberth <alberth@openttd.org>2010-08-08 11:02:57 +0000
commite1e8e245a0aea0155a5a96ab16b3a8eca3d7fa85 (patch)
treea1f4b697eb93c0fe8c1a75d02b482aac1dd05646
parent3da3d131c6a1e17db81d08c161b944c2c00533da (diff)
downloadopenttd-e1e8e245a0aea0155a5a96ab16b3a8eca3d7fa85.tar.xz
(svn r20412) -Codechange: Replace an if by a switch in IndustryCargoesWindow::OnClick.
-rw-r--r--src/industry_gui.cpp49
1 files changed, 26 insertions, 23 deletions
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 8d98f9662..c3837160b 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -2346,33 +2346,36 @@ struct IndustryCargoesWindow : public Window {
virtual void OnClick(Point pt, int widget, int click_count)
{
- if (widget != ICW_PANEL) return;
-
- Point fieldxy, xy;
- if (!CalculatePositionInWidget(pt, &fieldxy, &xy)) return;
-
- const CargoesField *fld = this->fields[fieldxy.y].columns + fieldxy.x;
- switch (fld->type) {
- case CFT_INDUSTRY:
- if (fld->u.industry.ind_type < NUM_INDUSTRYTYPES) this->ComputeIndustryDisplay(fld->u.industry.ind_type);
- break;
+ switch (widget) {
+ case ICW_PANEL: {
+ Point fieldxy, xy;
+ if (!CalculatePositionInWidget(pt, &fieldxy, &xy)) return;
+
+ const CargoesField *fld = this->fields[fieldxy.y].columns + fieldxy.x;
+ switch (fld->type) {
+ case CFT_INDUSTRY:
+ if (fld->u.industry.ind_type < NUM_INDUSTRYTYPES) this->ComputeIndustryDisplay(fld->u.industry.ind_type);
+ break;
+
+ case CFT_CARGO: {
+ CargoesField *lft = (fieldxy.x > 0) ? this->fields[fieldxy.y].columns + fieldxy.x - 1 : NULL;
+ CargoesField *rgt = (fieldxy.x < 4) ? this->fields[fieldxy.y].columns + fieldxy.x + 1 : NULL;
+ CargoID cid = fld->CargoClickedAt(lft, rgt, xy);
+ if (cid != INVALID_CARGO) this->ComputeCargoDisplay(cid);
+ break;
+ }
- case CFT_CARGO: {
- CargoesField *lft = (fieldxy.x > 0) ? this->fields[fieldxy.y].columns + fieldxy.x - 1 : NULL;
- CargoesField *rgt = (fieldxy.x < 4) ? this->fields[fieldxy.y].columns + fieldxy.x + 1 : NULL;
- CargoID cid = fld->CargoClickedAt(lft, rgt, xy);
- if (cid != INVALID_CARGO) this->ComputeCargoDisplay(cid);
- break;
- }
+ case CFT_CARGO_LABEL: {
+ CargoID cid = fld->CargoLabelClickedAt(xy);
+ if (cid != INVALID_CARGO) this->ComputeCargoDisplay(cid);
+ break;
+ }
- case CFT_CARGO_LABEL: {
- CargoID cid = fld->CargoLabelClickedAt(xy);
- if (cid != INVALID_CARGO) this->ComputeCargoDisplay(cid);
+ default:
+ break;
+ }
break;
}
-
- default:
- break;
}
}