summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-12-09 16:55:21 +0000
committerfrosch <frosch@openttd.org>2012-12-09 16:55:21 +0000
commit5c358c41735e95d14eb23667e146c10e2cea9b67 (patch)
treeb4010a3b96509e028cecf8475a19489a832bd415 /src
parent0e4b212c4539afb9d8622862d7e03bf2217058f8 (diff)
downloadopenttd-5c358c41735e95d14eb23667e146c10e2cea9b67.tar.xz
(svn r24811) -Add: Close engine preview window when another client accepts it.
Diffstat (limited to 'src')
-rw-r--r--src/engine.cpp7
-rw-r--r--src/engine_gui.cpp8
2 files changed, 15 insertions, 0 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 289549604..782f3f31a 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -749,6 +749,13 @@ static void AcceptEnginePreview(EngineID eid, CompanyID company)
/* 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);
}
/**
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index 3a1332367..a2f5b919c 100644
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -110,6 +110,14 @@ struct EnginePreviewWindow : Window {
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(