diff --git a/source.list b/source.list
index 2e1b24c98e..b28fe8fb25 100644
--- a/source.list
+++ b/source.list
@@ -144,6 +144,7 @@ base_media_func.h
base_station_base.h
bmp.h
bridge.h
+build_confirmation_func.h
cargo_type.h
cargoaction.h
cargomonitor.h
@@ -453,6 +454,7 @@ airport_gui.cpp
autoreplace_gui.cpp
bootstrap_gui.cpp
bridge_gui.cpp
+build_confirmation_gui.cpp
build_vehicle_gui.cpp
cheat_gui.cpp
company_gui.cpp
diff --git a/src/build_confirmation_func.h b/src/build_confirmation_func.h
new file mode 100644
index 0000000000..a1cbf4dbf7
--- /dev/null
+++ b/src/build_confirmation_func.h
@@ -0,0 +1,25 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see .
+ */
+
+/** @file build_confirmation_func.h Transparent confirmation dialog for building anything on the map. */
+
+#ifndef BUILD_CONFIRMATION_FUNC_H
+#define BUILD_CONFIRMATION_FUNC_H
+
+#include "stdafx.h"
+#include "window_func.h"
+#include "widget_type.h"
+
+
+void ShowBuildConfirmationWindow();
+void HideBuildConfirmationWindow();
+bool ConfirmationWindowShown();
+
+
+#endif /* BUILD_CONFIRMATION_FUNC_H */
diff --git a/src/build_confirmation_gui.cpp b/src/build_confirmation_gui.cpp
new file mode 100644
index 0000000000..fad04cb92d
--- /dev/null
+++ b/src/build_confirmation_gui.cpp
@@ -0,0 +1,119 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see .
+ */
+
+/** @file build_confirmation_gui.cpp Transparent confirmation dialog for building anything on the map. */
+
+#include "stdafx.h"
+#include "string_func.h"
+#include "strings_func.h"
+#include "window_func.h"
+#include "widget_type.h"
+#include "window_gui.h"
+#include "gfx_func.h"
+#include "tilehighlight_func.h"
+
+#include "widgets/build_confirmation_widget.h"
+#include "build_confirmation_func.h"
+
+#include "table/strings.h"
+
+#include "safeguards.h"
+
+
+static const NWidgetPart _nested_build_confirmation_widgets[] = {
+ NWidget(NWID_VERTICAL),
+ NWidget(NWID_SPACER), SetFill(1, 1),
+ NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_BC_OK), SetDataTip(STR_BUTTON_OK, STR_NULL), SetSizingType(NWST_BUTTON),
+ NWidget(NWID_SPACER), SetFill(1, 1),
+ NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_BC_CANCEL), SetDataTip(STR_BUTTON_CANCEL, STR_NULL), SetSizingType(NWST_BUTTON),
+ NWidget(NWID_SPACER), SetFill(1, 1),
+ EndContainer(),
+};
+
+/** GUI for confirming building actions. */
+struct BuildConfirmationWindow : Window {
+
+ BuildConfirmationWindow(WindowDesc *desc) : Window(desc)
+ {
+ this->InitNested(0);
+ }
+
+ void OnClick(Point pt, int widget, int click_count)
+ {
+ switch (widget) {
+ case WID_BC_OK:
+ ConfirmPlacingObject();
+ break;
+ case WID_BC_CANCEL:
+ ResetObjectToPlace();
+ break;
+ }
+ HideBuildConfirmationWindow(); // this == NULL after this call
+ }
+
+ virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ {
+ }
+
+ /*
+ virtual void DrawWidget(const Rect &r, int widget) const
+ {
+ switch (widget) {
+ case WID_BV_LIST:
+ break;
+ }
+ }
+ */
+
+ /*
+ virtual void OnPaint()
+ {
+ this->DrawWidgets();
+ }
+ */
+};
+
+static WindowDesc _build_confirmation_desc(
+ WDP_AUTO, "build_confirmation", 100, 80,
+ WC_BUILD_CONFIRMATION, WC_NONE,
+ WDF_CONSTRUCTION,
+ _nested_build_confirmation_widgets, lengthof(_nested_build_confirmation_widgets)
+);
+
+static bool _confirmationWindowShown = false; // Just to speed up window hiding, HideBuildConfirmationWindow() is called very often
+
+/**
+ * Show build confirmation window under the mouse cursor
+*/
+void ShowBuildConfirmationWindow()
+{
+ HideBuildConfirmationWindow();
+ BuildConfirmationWindow *wnd = new BuildConfirmationWindow(&_build_confirmation_desc);
+ wnd->left = _cursor.pos.x - wnd->width / 2;
+ wnd->top = _cursor.pos.y - wnd->height / 4;
+ wnd->SetDirty();
+ _confirmationWindowShown = true;
+}
+
+/**
+ * Destory build confirmation window, this does not cancel current action
+*/
+void HideBuildConfirmationWindow()
+{
+ if (!_confirmationWindowShown) {
+ //return;
+ }
+ DeleteWindowById(WC_BUILD_CONFIRMATION, 0);
+ _confirmationWindowShown = false;
+}
+
+bool ConfirmationWindowShown()
+{
+ return _confirmationWindowShown;
+}
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 3804cb126f..552aeeba97 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -550,6 +550,7 @@ public:
virtual void OnPlaceObject(Point pt, TileIndex tile)
{
VpStartPlaceSizing(tile, VPM_SINGLE_TILE, DDSP_SINGLE_TILE);
+ MoveAllWindowsOffScreen();
}
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
@@ -562,6 +563,7 @@ public:
if (pt.x == -1) return;
assert(end_tile == start_tile);
+ MoveAllHiddenWindowsBackToScreen();
bool success = true;
/* We do not need to protect ourselves against "Random Many Industries" in this mode */
const IndustrySpec *indsp = GetIndustrySpec(this->selected_type);
@@ -624,6 +626,7 @@ public:
virtual void OnPlaceObjectAbort()
{
+ MoveAllHiddenWindowsBackToScreen();
this->RaiseButtons();
}
diff --git a/src/tilehighlight_func.h b/src/tilehighlight_func.h
index ac1567277b..c9c7ea809f 100644
--- a/src/tilehighlight_func.h
+++ b/src/tilehighlight_func.h
@@ -22,6 +22,8 @@ bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyl
void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Window *w);
void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowClass window_class, WindowNumber window_num);
void ResetObjectToPlace();
+void ConfirmPlacingObject();
+
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method);
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process);
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index f86e2a12bd..9acf17dd7c 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -1176,6 +1176,7 @@ public:
virtual void OnPlaceObject(Point pt, TileIndex tile)
{
VpStartPlaceSizing(tile, VPM_SINGLE_TILE, DDSP_SINGLE_TILE);
+ MoveAllWindowsOffScreen();
}
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
@@ -1187,10 +1188,12 @@ public:
{
assert(start_tile == end_tile);
this->ExecuteFoundTownCommand(end_tile, false, STR_ERROR_CAN_T_FOUND_TOWN_HERE, CcFoundTown);
+ MoveAllHiddenWindowsBackToScreen();
}
virtual void OnPlaceObjectAbort()
{
+ MoveAllHiddenWindowsBackToScreen();
this->RaiseButtons();
this->UpdateButtons(false);
}
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 957628de12..251bdfc0a4 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -84,6 +84,7 @@
#include "linkgraph/linkgraph_gui.h"
#include "viewport_sprite_sorter.h"
#include "bridge_map.h"
+#include "build_confirmation_func.h"
#include