File diff r23123:aa31147b532e → r23124:8fa6d269005b
src/main_gui.cpp
Show inline comments
 
@@ -214,69 +214,70 @@ enum {
 
	GHK_CONSOLE,
 
	GHK_BOUNDING_BOXES,
 
	GHK_DIRTY_BLOCKS,
 
	GHK_CENTER,
 
	GHK_CENTER_ZOOM,
 
	GHK_RESET_OBJECT_TO_PLACE,
 
	GHK_DELETE_WINDOWS,
 
	GHK_DELETE_NONVITAL_WINDOWS,
 
	GHK_REFRESH_SCREEN,
 
	GHK_CRASH,
 
	GHK_MONEY,
 
	GHK_UPDATE_COORDS,
 
	GHK_TOGGLE_TRANSPARENCY,
 
	GHK_TOGGLE_INVISIBILITY = GHK_TOGGLE_TRANSPARENCY + 9,
 
	GHK_TRANSPARENCY_TOOLBAR = GHK_TOGGLE_INVISIBILITY + 8,
 
	GHK_TRANSPARANCY,
 
	GHK_CHAT,
 
	GHK_CHAT_ALL,
 
	GHK_CHAT_COMPANY,
 
	GHK_CHAT_SERVER,
 
};
 

	
 
struct MainWindow : Window
 
{
 
	uint refresh;
 
	int refresh;
 

	
 
	static const uint LINKGRAPH_REFRESH_PERIOD = 0xff;
 
	static const uint LINKGRAPH_DELAY = 0xf;
 
	/* Refresh times in milliseconds */
 
	static const uint LINKGRAPH_REFRESH_PERIOD = 7650;
 
	static const uint LINKGRAPH_DELAY = 450;
 

	
 
	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;
 
	}
 

	
 
	virtual void OnTick()
 
	virtual void OnRealtimeTick(uint delta_ms)
 
	{
 
		if (--this->refresh > 0) return;
 
		if (!TimerElapsed(this->refresh, delta_ms)) return;
 

	
 
		this->refresh = LINKGRAPH_REFRESH_PERIOD;
 

	
 
		if (this->viewport->overlay->GetCargoMask() == 0 ||
 
				this->viewport->overlay->GetCompanyMask() == 0) {
 
			return;
 
		}
 

	
 
		this->viewport->overlay->RebuildCache();
 
		this->GetWidget<NWidgetBase>(WID_M_VIEWPORT)->SetDirty(this);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		this->DrawWidgets();
 
		if (_game_mode == GM_MENU) {
 
			static const SpriteID title_sprites[] = {SPR_OTTD_O, SPR_OTTD_P, SPR_OTTD_E, SPR_OTTD_N, SPR_OTTD_T, SPR_OTTD_T, SPR_OTTD_D};
 
			static const uint LETTER_SPACING = 10;
 
			int name_width = (lengthof(title_sprites) - 1) * LETTER_SPACING;
 

	
 
			for (uint i = 0; i < lengthof(title_sprites); i++) {
 
				name_width += GetSpriteSize(title_sprites[i]).width;
 
			}
 
			int off_x = (this->width - name_width) / 2;