(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 b10a4f151a
commit 56e4a8c4d6
61 changed files with 488 additions and 482 deletions

View File

@@ -89,7 +89,7 @@ static const NWidgetPart _nested_normal_news_widgets[] = {
EndContainer(),
};
static const WindowDesc _normal_news_desc(
static WindowDesc _normal_news_desc(
WDP_MANUAL, 0, 0,
WC_NEWS_WINDOW, WC_NONE,
0,
@@ -116,7 +116,7 @@ static const NWidgetPart _nested_vehicle_news_widgets[] = {
EndContainer(),
};
static const WindowDesc _vehicle_news_desc(
static WindowDesc _vehicle_news_desc(
WDP_MANUAL, 0, 0,
WC_NEWS_WINDOW, WC_NONE,
0,
@@ -147,7 +147,7 @@ static const NWidgetPart _nested_company_news_widgets[] = {
EndContainer(),
};
static const WindowDesc _company_news_desc(
static WindowDesc _company_news_desc(
WDP_MANUAL, 0, 0,
WC_NEWS_WINDOW, WC_NONE,
0,
@@ -170,7 +170,7 @@ static const NWidgetPart _nested_thin_news_widgets[] = {
EndContainer(),
};
static const WindowDesc _thin_news_desc(
static WindowDesc _thin_news_desc(
WDP_MANUAL, 0, 0,
WC_NEWS_WINDOW, WC_NONE,
0,
@@ -194,7 +194,7 @@ static const NWidgetPart _nested_small_news_widgets[] = {
EndContainer(),
};
static const WindowDesc _small_news_desc(
static WindowDesc _small_news_desc(
WDP_MANUAL, 0, 0,
WC_NEWS_WINDOW, WC_NONE,
0,
@@ -204,7 +204,7 @@ static const WindowDesc _small_news_desc(
/**
* Window layouts for news items.
*/
static const WindowDesc* _news_window_layout[] = {
static WindowDesc* _news_window_layout[] = {
&_thin_news_desc, ///< NF_THIN
&_small_news_desc, ///< NF_SMALL
&_normal_news_desc, ///< NF_NORMAL
@@ -212,7 +212,7 @@ static const WindowDesc* _news_window_layout[] = {
&_company_news_desc, ///< NF_COMPANY
};
const WindowDesc* GetNewsWindowLayout(NewsFlag flags)
WindowDesc* GetNewsWindowLayout(NewsFlag flags)
{
uint layout = GB(flags, NFB_WINDOW_LAYOUT, NFB_WINDOW_LAYOUT_COUNT);
assert(layout < lengthof(_news_window_layout));
@@ -263,7 +263,7 @@ struct NewsWindow : Window {
const NewsItem *ni; ///< News item to display.
static uint duration; ///< Remaining time for showing current news message (may only be accessed while a news item is displayed).
NewsWindow(const WindowDesc *desc, const NewsItem *ni) : Window(), ni(ni)
NewsWindow(WindowDesc *desc, const NewsItem *ni) : Window(desc), ni(ni)
{
NewsWindow::duration = 555;
const Window *w = FindWindowByClass(WC_SEND_NETWORK_MSG);
@@ -272,12 +272,12 @@ struct NewsWindow : Window {
this->flags |= WF_DISABLE_VP_SCROLL;
this->CreateNestedTree(desc);
this->CreateNestedTree();
/* For company news with a face we have a separate headline in param[0] */
if (desc == &_company_news_desc) this->GetWidget<NWidgetCore>(WID_N_TITLE)->widget_data = this->ni->params[0];
this->FinishInitNested(desc, 0);
this->FinishInitNested(0);
/* Initialize viewport if it exists. */
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_N_VIEWPORT);
@@ -304,7 +304,7 @@ struct NewsWindow : Window {
GfxFillRect(r.left, r.bottom, r.right, r.bottom, PC_BLACK);
}
virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number)
virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
{
Point pt = { 0, _screen.height };
return pt;
@@ -996,11 +996,11 @@ struct MessageHistoryWindow : Window {
Scrollbar *vscroll;
MessageHistoryWindow(const WindowDesc *desc) : Window()
MessageHistoryWindow(WindowDesc *desc) : Window(desc)
{
this->CreateNestedTree(desc);
this->CreateNestedTree();
this->vscroll = this->GetScrollbar(WID_MH_SCROLLBAR);
this->FinishInitNested(desc); // Initializes 'this->line_height' and 'this->date_width'.
this->FinishInitNested(); // Initializes 'this->line_height' and 'this->date_width'.
this->OnInvalidateData(0);
}
@@ -1109,7 +1109,7 @@ static const NWidgetPart _nested_message_history[] = {
EndContainer(),
};
static const WindowDesc _message_history_desc(
static WindowDesc _message_history_desc(
WDP_AUTO, 400, 140,
WC_MESSAGE_HISTORY, WC_NONE,
0,