summaryrefslogtreecommitdiff
path: root/src/graph_gui.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-07-15 22:17:08 +0000
committeralberth <alberth@openttd.org>2009-07-15 22:17:08 +0000
commit92206f2d18257feb4e95ecce2e48f447bd240201 (patch)
tree8db565fa08a867000f2853bcd886ea33f3c3e66c /src/graph_gui.cpp
parentf085d7775b12e77b8012ab09ae72b850367a3237 (diff)
downloadopenttd-92206f2d18257feb4e95ecce2e48f447bd240201.tar.xz
(svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
Diffstat (limited to 'src/graph_gui.cpp')
-rw-r--r--src/graph_gui.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index 94a1a5122..3a8f03967 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -86,7 +86,13 @@ struct GraphLegendWindow : Window {
}
};
-static NWidgetBase *MakeNWidgetCompanyLines()
+/**
+ * Construct a vertical list of buttons, one for each company.
+ * @param biggest_index Storage for collecting the biggest index used in the returned tree.
+ * @return Panel with company buttons.
+ * @postcond \c *biggest_index contains the largest used index in the tree.
+ */
+static NWidgetBase *MakeNWidgetCompanyLines(int *biggest_index)
{
NWidgetVertical *vert = new NWidgetVertical();
@@ -97,6 +103,7 @@ static NWidgetBase *MakeNWidgetCompanyLines()
panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION);
vert->Add(panel);
}
+ *biggest_index = GLW_LAST_COMPANY;
return vert;
}
@@ -1195,8 +1202,12 @@ struct PerformanceRatingDetailWindow : Window {
CompanyID PerformanceRatingDetailWindow::company = INVALID_COMPANY;
-/** Make a vertical list of panels for outputting score details. */
-static NWidgetBase *MakePerformanceDetailPanels()
+/** Make a vertical list of panels for outputting score details.
+ * @param biggest_index Storage for collecting the biggest index used in the returned tree.
+ * @return Panel with performance details.
+ * @postcond \c *biggest_index contains the largest used index in the tree.
+ */
+static NWidgetBase *MakePerformanceDetailPanels(int *biggest_index)
{
const StringID performance_tips[] = {
STR_PERFORMANCE_DETAIL_VEHICLES_TIP,
@@ -1221,11 +1232,17 @@ static NWidgetBase *MakePerformanceDetailPanels()
panel->SetDataTip(0x0, performance_tips[widnum - PRW_SCORE_FIRST]);
vert->Add(panel);
}
+ *biggest_index = PRW_SCORE_LAST;
return vert;
}
-/** Make a number of rows with button-like graphics, for enabling/disabling each company. */
-static NWidgetBase *MakeCompanyButtonRows()
+/**
+ * Make a number of rows with button-like graphics, for enabling/disabling each company.
+ * @param biggest_index Storage for collecting the biggest index used in the returned tree.
+ * @return Panel with rows of company buttons.
+ * @postcond \c *biggest_index contains the largest used index in the tree.
+ */
+static NWidgetBase *MakeCompanyButtonRows(int *biggest_index)
{
static const int MAX_LENGTH = 8; // Maximal number of company buttons in one row.
NWidgetVertical *vert = NULL; // Storage for all rows.
@@ -1252,6 +1269,7 @@ static NWidgetBase *MakeCompanyButtonRows()
hor->Add(panel);
hor_length++;
}
+ *biggest_index = PRW_COMPANY_LAST;
if (vert == NULL) return hor; // All buttons fit in a single row.
if (hor_length > 0 && hor_length < MAX_LENGTH) {