virtual void OnClick(Point pt, int widget, int click_count) { switch (widget) { case NTW_CLOSEBOX: NewsWindow::duration = 0; delete this; _forced_news = NULL; break; case NTW_CAPTION: case NTW_VIEWPORT: break; // Ignore clicks default: if (this->ni->reftype1 == NR_VEHICLE) { const Vehicle *v = Vehicle::Get(this->ni->ref1); ScrollMainWindowTo(v->x_pos, v->y_pos, v->z_pos); } else { TileIndex tile1 = GetReferenceTile(this->ni->reftype1, this->ni->ref1); TileIndex tile2 = GetReferenceTile(this->ni->reftype2, this->ni->ref2); if (_ctrl_pressed) { if (tile1 != INVALID_TILE) ShowExtraViewPortWindow(tile1); if (tile2 != INVALID_TILE) ShowExtraViewPortWindow(tile2); } else { if ((tile1 == INVALID_TILE || !ScrollMainWindowToTile(tile1)) && tile2 != INVALID_TILE) { ScrollMainWindowToTile(tile2); } } } break; } }
NewsWindow(WindowDesc *desc, const NewsItem *ni) : Window(desc), ni(ni) { NewsWindow::duration = 555; const Window *w = FindWindowByClass(WC_SEND_NETWORK_MSG); this->chat_height = (w != NULL) ? w->height : 0; this->status_height = FindWindowById(WC_STATUS_BAR, 0)->height; this->flags |= WF_DISABLE_VP_SCROLL; 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(0); /* Initialize viewport if it exists. */ NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_N_VIEWPORT); if (nvp != NULL) { nvp->InitializeViewport(this, ni->reftype1 == NR_VEHICLE ? 0x80000000 | ni->ref1 : GetReferenceTile(ni->reftype1, ni->ref1), ZOOM_LVL_NEWS); if (this->ni->flags & NF_NO_TRANSPARENT) nvp->disp_flags |= ND_NO_TRANSPARENCY; if ((this->ni->flags & NF_INCOLOUR) == 0) { nvp->disp_flags |= ND_SHADE_GREY; } else if (this->ni->flags & NF_SHADE) { nvp->disp_flags |= ND_SHADE_DIMMED; } } PositionNewsMessage(this); }
NewsWindow(const WindowDesc *desc, const NewsItem *ni) : Window(), ni(ni) { NewsWindow::duration = 555; const Window *w = FindWindowByClass(WC_SEND_NETWORK_MSG); this->chat_height = (w != NULL) ? w->height : 0; this->status_height = FindWindowById(WC_STATUS_BAR, 0)->height; this->flags4 |= WF_DISABLE_VP_SCROLL; this->CreateNestedTree(desc); switch (this->ni->subtype) { case NS_COMPANY_TROUBLE: this->GetWidget<NWidgetCore>(NTW_TITLE)->widget_data = STR_NEWS_COMPANY_IN_TROUBLE_TITLE; break; case NS_COMPANY_MERGER: this->GetWidget<NWidgetCore>(NTW_TITLE)->widget_data = STR_NEWS_COMPANY_MERGER_TITLE; break; case NS_COMPANY_BANKRUPT: this->GetWidget<NWidgetCore>(NTW_TITLE)->widget_data = STR_NEWS_COMPANY_BANKRUPT_TITLE; break; case NS_COMPANY_NEW: this->GetWidget<NWidgetCore>(NTW_TITLE)->widget_data = STR_NEWS_COMPANY_LAUNCH_TITLE; break; default: break; } this->FinishInitNested(desc, 0); /* Initialize viewport if it exists. */ NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(NTW_VIEWPORT); if (nvp != NULL) { nvp->InitializeViewport(this, ni->reftype1 == NR_VEHICLE ? 0x80000000 | ni->ref1 : GetReferenceTile(ni->reftype1, ni->ref1), ZOOM_LVL_NEWS); if (this->ni->flags & NF_NO_TRANSPARENT) nvp->disp_flags |= ND_NO_TRANSPARENCY; if ((this->ni->flags & NF_INCOLOUR) == 0) { nvp->disp_flags |= ND_SHADE_GREY; } else if (this->ni->flags & NF_SHADE) { nvp->disp_flags |= ND_SHADE_DIMMED; } } }