Mercurial > hg > openttd
changeset 19878:547bdf50d651 draft
(svn r24811) -Add: Close engine preview window when another client accepts it.
author | frosch <frosch@openttd.org> |
---|---|
date | Sun, 09 Dec 2012 16:55:21 +0000 |
parents | 784e2ae3c6ba |
children | fc6003f86e35 |
files | src/engine.cpp src/engine_gui.cpp |
diffstat | 2 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/engine.cpp +++ b/src/engine.cpp @@ -749,6 +749,13 @@ /* Update the toolbar. */ if (e->type == VEH_ROAD) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_ROAD); if (e->type == VEH_SHIP) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_WATER); + + /* Notify preview window, that it might want to close. + * Note: We cannot directly close the window. + * In singleplayer this function is called from the preview window, so + * we have to use the GUI-scope scheduling of InvalidateWindowData. + */ + InvalidateWindowData(WC_ENGINE_PREVIEW, eid); } /**
--- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -110,6 +110,14 @@ break; } } + + virtual void OnInvalidateData(int data = 0, bool gui_scope = true) + { + if (!gui_scope) return; + + EngineID engine = this->window_number; + if (Engine::Get(engine)->preview_company != _local_company) delete this; + } }; static const WindowDesc _engine_preview_desc(