(svn r25287) -Codechange: Keep a reference to the WindowDesc in the Window after construction.

This commit is contained in:
frosch
2013-05-26 19:23:42 +00:00
parent 5e7603154d
commit 25adefca23
61 changed files with 488 additions and 482 deletions

View File

@@ -43,9 +43,9 @@ static const uint INVALID_DATAPOINT_POS = UINT_MAX; // Used to determine if the
/****************/
struct GraphLegendWindow : Window {
GraphLegendWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
GraphLegendWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
{
this->InitNested(desc, window_number);
this->InitNested(window_number);
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
if (!HasBit(_legend_excluded_companies, c)) this->LowerWidget(c + WID_GL_FIRST_COMPANY);
@@ -140,7 +140,7 @@ static const NWidgetPart _nested_graph_legend_widgets[] = {
EndContainer(),
};
static const WindowDesc _graph_legend_desc(
static WindowDesc _graph_legend_desc(
WDP_AUTO, 0, 0,
WC_GRAPH_LEGEND, WC_NONE,
0,
@@ -463,8 +463,8 @@ protected:
}
BaseGraphWindow(int widget, StringID format_str_y_axis) :
Window(),
BaseGraphWindow(WindowDesc *desc, int widget, StringID format_str_y_axis) :
Window(desc),
format_str_y_axis(format_str_y_axis)
{
SetWindowDirty(WC_GRAPH_LEGEND, 0);
@@ -472,12 +472,12 @@ protected:
this->graph_widget = widget;
}
void InitializeWindow(const WindowDesc *desc, WindowNumber number)
void InitializeWindow(WindowNumber number)
{
/* Initialise the dataset */
this->UpdateStatistics(true);
this->InitNested(desc, number);
this->InitNested(number);
}
public:
@@ -611,10 +611,10 @@ public:
/********************/
struct OperatingProfitGraphWindow : BaseGraphWindow {
OperatingProfitGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
BaseGraphWindow(WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT)
OperatingProfitGraphWindow(WindowDesc *desc, WindowNumber window_number) :
BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT)
{
this->InitializeWindow(desc, window_number);
this->InitializeWindow(window_number);
}
virtual OverflowSafeInt64 GetGraphData(const Company *c, int j)
@@ -642,7 +642,7 @@ static const NWidgetPart _nested_operating_profit_widgets[] = {
EndContainer(),
};
static const WindowDesc _operating_profit_desc(
static WindowDesc _operating_profit_desc(
WDP_AUTO, 0, 0,
WC_OPERATING_PROFIT, WC_NONE,
0,
@@ -661,10 +661,10 @@ void ShowOperatingProfitGraph()
/****************/
struct IncomeGraphWindow : BaseGraphWindow {
IncomeGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
BaseGraphWindow(WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT)
IncomeGraphWindow(WindowDesc *desc, WindowNumber window_number) :
BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT)
{
this->InitializeWindow(desc, window_number);
this->InitializeWindow(window_number);
}
virtual OverflowSafeInt64 GetGraphData(const Company *c, int j)
@@ -692,7 +692,7 @@ static const NWidgetPart _nested_income_graph_widgets[] = {
EndContainer(),
};
static const WindowDesc _income_graph_desc(
static WindowDesc _income_graph_desc(
WDP_AUTO, 0, 0,
WC_INCOME_GRAPH, WC_NONE,
0,
@@ -709,10 +709,10 @@ void ShowIncomeGraph()
/*******************/
struct DeliveredCargoGraphWindow : BaseGraphWindow {
DeliveredCargoGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
BaseGraphWindow(WID_CV_GRAPH, STR_JUST_COMMA)
DeliveredCargoGraphWindow(WindowDesc *desc, WindowNumber window_number) :
BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_COMMA)
{
this->InitializeWindow(desc, window_number);
this->InitializeWindow(window_number);
}
virtual OverflowSafeInt64 GetGraphData(const Company *c, int j)
@@ -740,7 +740,7 @@ static const NWidgetPart _nested_delivered_cargo_graph_widgets[] = {
EndContainer(),
};
static const WindowDesc _delivered_cargo_graph_desc(
static WindowDesc _delivered_cargo_graph_desc(
WDP_AUTO, 0, 0,
WC_DELIVERED_CARGO, WC_NONE,
0,
@@ -757,10 +757,10 @@ void ShowDeliveredCargoGraph()
/***********************/
struct PerformanceHistoryGraphWindow : BaseGraphWindow {
PerformanceHistoryGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
BaseGraphWindow(WID_PHG_GRAPH, STR_JUST_COMMA)
PerformanceHistoryGraphWindow(WindowDesc *desc, WindowNumber window_number) :
BaseGraphWindow(desc, WID_PHG_GRAPH, STR_JUST_COMMA)
{
this->InitializeWindow(desc, window_number);
this->InitializeWindow(window_number);
}
virtual OverflowSafeInt64 GetGraphData(const Company *c, int j)
@@ -795,7 +795,7 @@ static const NWidgetPart _nested_performance_history_widgets[] = {
EndContainer(),
};
static const WindowDesc _performance_history_desc(
static WindowDesc _performance_history_desc(
WDP_AUTO, 0, 0,
WC_PERFORMANCE_HISTORY, WC_NONE,
0,
@@ -812,10 +812,10 @@ void ShowPerformanceHistoryGraph()
/*****************/
struct CompanyValueGraphWindow : BaseGraphWindow {
CompanyValueGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
BaseGraphWindow(WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT)
CompanyValueGraphWindow(WindowDesc *desc, WindowNumber window_number) :
BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT)
{
this->InitializeWindow(desc, window_number);
this->InitializeWindow(window_number);
}
virtual OverflowSafeInt64 GetGraphData(const Company *c, int j)
@@ -843,7 +843,7 @@ static const NWidgetPart _nested_company_value_graph_widgets[] = {
EndContainer(),
};
static const WindowDesc _company_value_graph_desc(
static WindowDesc _company_value_graph_desc(
WDP_AUTO, 0, 0,
WC_COMPANY_VALUE, WC_NONE,
0,
@@ -861,8 +861,8 @@ void ShowCompanyValueGraph()
struct PaymentRatesGraphWindow : BaseGraphWindow {
bool first_init; ///< This value is true until the first initialization of the window has finished.
PaymentRatesGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
BaseGraphWindow(WID_CPR_GRAPH, STR_JUST_CURRENCY_SHORT)
PaymentRatesGraphWindow(WindowDesc *desc, WindowNumber window_number) :
BaseGraphWindow(desc, WID_CPR_GRAPH, STR_JUST_CURRENCY_SHORT)
{
this->first_init = true;
this->num_on_x_axis = 20;
@@ -874,7 +874,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
/* Initialise the dataset */
this->OnHundredthTick();
this->InitNested(desc, window_number);
this->InitNested(window_number);
this->UpdateLoweredWidgets();
}
@@ -1073,7 +1073,7 @@ static const NWidgetPart _nested_cargo_payment_rates_widgets[] = {
EndContainer(),
};
static const WindowDesc _cargo_payment_rates_desc(
static WindowDesc _cargo_payment_rates_desc(
WDP_AUTO, 0, 0,
WC_PAYMENT_RATES, WC_NONE,
0,
@@ -1147,9 +1147,9 @@ private:
}
public:
CompanyLeagueWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
CompanyLeagueWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
{
this->InitNested(desc, window_number);
this->InitNested(window_number);
this->companies.ForceRebuild();
this->companies.NeedResort();
}
@@ -1262,7 +1262,7 @@ static const NWidgetPart _nested_company_league_widgets[] = {
NWidget(WWT_PANEL, COLOUR_GREY, WID_CL_BACKGROUND), SetMinimalSize(400, 0), SetMinimalTextLines(15, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM),
};
static const WindowDesc _company_league_desc(
static WindowDesc _company_league_desc(
WDP_AUTO, 0, 0,
WC_COMPANY_LEAGUE, WC_NONE,
0,
@@ -1282,11 +1282,11 @@ struct PerformanceRatingDetailWindow : Window {
static CompanyID company;
int timeout;
PerformanceRatingDetailWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
PerformanceRatingDetailWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
{
this->UpdateCompanyStats();
this->InitNested(desc, window_number);
this->InitNested(window_number);
this->OnInvalidateData(INVALID_COMPANY);
}
@@ -1561,7 +1561,7 @@ static const NWidgetPart _nested_performance_rating_detail_widgets[] = {
NWidgetFunction(MakePerformanceDetailPanels),
};
static const WindowDesc _performance_rating_detail_desc(
static WindowDesc _performance_rating_detail_desc(
WDP_AUTO, 0, 0,
WC_PERFORMANCE_DETAIL, WC_NONE,
0,