예제 #1
0
	ExtraViewportWindow(WindowDesc *desc, int window_number, TileIndex tile) : Window(desc)
	{
		this->InitNested(window_number);

		NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_EV_VIEWPORT);
		nvp->InitializeViewport(this, 0, ZOOM_LVL_VIEWPORT);
		if (_settings_client.gui.zoom_min == ZOOM_LVL_VIEWPORT) this->DisableWidget(WID_EV_ZOOM_IN);

		Point pt;
		if (tile == INVALID_TILE) {
			/* No tile? Use center of main viewport. */
			const Window *w = FindWindowById(WC_MAIN_WINDOW, 0);

			/* center on same place as main window (zoom is maximum, no adjustment needed) */
			pt.x = w->viewport->scrollpos_x + w->viewport->virtual_width / 2;
			pt.y = w->viewport->scrollpos_y + w->viewport->virtual_height / 2;
		} else {
			pt = RemapCoords(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, TileHeight(tile));
		}

		this->viewport->scrollpos_x = pt.x - this->viewport->virtual_width / 2;
		this->viewport->scrollpos_y = pt.y - this->viewport->virtual_height / 2;
		this->viewport->dest_scrollpos_x = this->viewport->scrollpos_x;
		this->viewport->dest_scrollpos_y = this->viewport->scrollpos_y;
	}
예제 #2
0
	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);
	}
예제 #3
0
    ExtraViewportWindow(const WindowDesc *desc, int window_number, TileIndex tile) : Window()
    {
        this->InitNested(desc, window_number);

        NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(EVW_VIEWPORT);
        nvp->InitializeViewport(this, 0, ZOOM_LVL_NORMAL);
        this->DisableWidget(EVW_ZOOMIN);

        Point pt;
        if (tile == INVALID_TILE) {
            /* the main window with the main view */
            const Window *w = FindWindowById(WC_MAIN_WINDOW, 0);

            /* center on same place as main window (zoom is maximum, no adjustment needed) */
            pt.x = w->viewport->scrollpos_x + w->viewport->virtual_width / 2;
            pt.y = w->viewport->scrollpos_y + w->viewport->virtual_height / 2;
        } else {
            pt = RemapCoords(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, TileHeight(tile));
        }

        this->viewport->scrollpos_x = pt.x - this->viewport->virtual_width / 2;
        this->viewport->scrollpos_y = pt.y - this->viewport->virtual_height / 2;
        this->viewport->dest_scrollpos_x = this->viewport->scrollpos_x;
        this->viewport->dest_scrollpos_y = this->viewport->scrollpos_y;
    }
예제 #4
0
	MainWindow(WindowDesc *desc) : Window(desc)
	{
		this->InitNested(0);
		CLRBITS(this->flags, WF_WHITE_BORDER);
		ResizeWindow(this, _screen.width, _screen.height);

		NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_M_VIEWPORT);
		nvp->InitializeViewport(this, TileXY(32, 32), ZOOM_LVL_VIEWPORT);

		this->viewport->overlay = new LinkGraphOverlay(this, WID_M_VIEWPORT, 0, 0, 3);
		this->refresh = LINKGRAPH_DELAY;
	}
예제 #5
0
	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;
			}
		}
	}
예제 #6
0
	BuildConfirmationWindow(WindowDesc *desc) : Window(desc)
	{
		this->InitNested(0);

		Point pt;
		const Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
		NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_BC_OK);

		pt.x = w->viewport->scrollpos_x + ScaleByZoom(_cursor.pos.x - nvp->current_x / 2, w->viewport->zoom);
		pt.y = w->viewport->scrollpos_y + ScaleByZoom(_cursor.pos.y - nvp->current_y / 4, w->viewport->zoom);

		nvp->InitializeViewport(this, 0, w->viewport->zoom);
		nvp->disp_flags |= ND_SHADE_DIMMED;

		this->viewport->scrollpos_x = pt.x;
		this->viewport->scrollpos_y = pt.y;
		this->viewport->dest_scrollpos_x = this->viewport->scrollpos_x;
		this->viewport->dest_scrollpos_y = this->viewport->scrollpos_y;

		BuildConfirmationWindow::shown = true;
	}