Index: src/dock_gui.cpp
===================================================================
--- src/dock_gui.cpp (revision 27772)
+++ src/dock_gui.cpp (working copy)
@@ -27,6 +27,7 @@
#include "hotkeys.h"
#include "gui.h"
#include "zoom_func.h"
+#include "transparency.h"
#include "widgets/dock_widget.h"
@@ -106,6 +107,7 @@
~BuildDocksToolbarWindow()
{
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
+ this->OnInvalidateData();
}
/**
@@ -117,6 +119,18 @@
{
if (!gui_scope) return;
+ for (int i = WID_DT_CANAL; i < WID_DT_INVALID; i++)
+ {
+ if (_game_mode != GM_EDITOR) {
+ if (i != WID_DT_RIVER) {
+ if (this->IsWidgetLowered(i)) StopTempTransparency();
+ }
+ } else {
+ if (i != WID_DT_DEPOT && i != WID_DT_STATION && i != WID_DT_BUOY) {
+ if (this->IsWidgetLowered(i)) StopTempTransparency();
+ }
+ }
+ }
bool can_build = CanBuildVehicleInfrastructure(VEH_SHIP);
this->SetWidgetsDisabledState(!can_build,
WID_DT_DEPOT,
@@ -125,7 +139,7 @@
WIDGET_LIST_END);
if (!can_build) {
DeleteWindowById(WC_BUILD_STATION, TRANSPORT_WATER);
- DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER);
+ DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER);
}
}
@@ -133,39 +147,45 @@
{
switch (widget) {
case WID_DT_CANAL: // Build canal button
- HandlePlacePushButton(this, WID_DT_CANAL, SPR_CURSOR_CANAL, HT_RECT);
+ if (HandlePlacePushButton(this, WID_DT_CANAL, SPR_CURSOR_CANAL, HT_RECT)) StartTempTransparency();
break;
case WID_DT_LOCK: // Build lock button
- HandlePlacePushButton(this, WID_DT_LOCK, SPR_CURSOR_LOCK, HT_SPECIAL);
+ if (HandlePlacePushButton(this, WID_DT_LOCK, SPR_CURSOR_LOCK, HT_SPECIAL)) StartTempTransparency();
break;
case WID_DT_DEMOLISH: // Demolish aka dynamite button
- HandlePlacePushButton(this, WID_DT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
+ if (HandlePlacePushButton(this, WID_DT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL)) StartTempTransparency();
break;
case WID_DT_DEPOT: // Build depot button
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
- if (HandlePlacePushButton(this, WID_DT_DEPOT, SPR_CURSOR_SHIP_DEPOT, HT_RECT)) ShowBuildDocksDepotPicker(this);
+ if (HandlePlacePushButton(this, WID_DT_DEPOT, SPR_CURSOR_SHIP_DEPOT, HT_RECT)) {
+ ShowBuildDocksDepotPicker(this);
+ StartTempTransparency();
+ }
break;
case WID_DT_STATION: // Build station button
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
- if (HandlePlacePushButton(this, WID_DT_STATION, SPR_CURSOR_DOCK, HT_SPECIAL)) ShowBuildDockStationPicker(this);
+ if (HandlePlacePushButton(this, WID_DT_STATION, SPR_CURSOR_DOCK, HT_SPECIAL)) {
+ ShowBuildDockStationPicker(this);
+ StartTempTransparency();
+ }
break;
case WID_DT_BUOY: // Build buoy button
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
- HandlePlacePushButton(this, WID_DT_BUOY, SPR_CURSOR_BUOY, HT_RECT);
+ if (HandlePlacePushButton(this, WID_DT_BUOY, SPR_CURSOR_BUOY, HT_RECT)) StartTempTransparency();
break;
case WID_DT_RIVER: // Build river button (in scenario editor)
if (_game_mode != GM_EDITOR) return;
- HandlePlacePushButton(this, WID_DT_RIVER, SPR_CURSOR_RIVER, HT_RECT);
+ if (HandlePlacePushButton(this, WID_DT_RIVER, SPR_CURSOR_RIVER, HT_RECT)) StartTempTransparency();
break;
case WID_DT_BUILD_AQUEDUCT: // Build aqueduct button
- HandlePlacePushButton(this, WID_DT_BUILD_AQUEDUCT, SPR_CURSOR_AQUEDUCT, HT_SPECIAL);
+ if (HandlePlacePushButton(this, WID_DT_BUILD_AQUEDUCT, SPR_CURSOR_AQUEDUCT, HT_SPECIAL)) StartTempTransparency();
break;
default: return;
@@ -248,6 +268,7 @@
virtual void OnPlaceObjectAbort()
{
+ this->OnInvalidateData();
this->RaiseButtons();
DeleteWindowById(WC_BUILD_STATION, TRANSPORT_WATER);
@@ -347,6 +368,7 @@
{
if (!Company::IsValidID(_local_company)) return NULL;
+ InvalidateWindowClassesData(WC_BUILD_TOOLBAR, 0, true);
DeleteWindowByClass(WC_BUILD_TOOLBAR);
return AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
}
Index: src/transparency.h
===================================================================
--- src/transparency.h (revision 27772)
+++ src/transparency.h (working copy)
@@ -32,12 +32,15 @@
TO_CATENARY, ///< catenary
TO_LOADING, ///< loading indicators
TO_END,
+ TO_TMP = TO_END,
TO_INVALID, ///< Invalid transparency option
};
typedef uint TransparencyOptionBits; ///< transparency option bits
extern TransparencyOptionBits _transparency_opt;
+extern TransparencyOptionBits _transparency_opt_tmp;
extern TransparencyOptionBits _transparency_lock;
+extern TransparencyOptionBits _transparency_lock_tmp;
extern TransparencyOptionBits _invisibility_opt;
extern byte _display_opt;
@@ -71,6 +74,7 @@
static inline void ToggleTransparency(TransparencyOption to)
{
ToggleBit(_transparency_opt, to);
+ if (HasBit(_transparency_opt_tmp, TO_TMP)) ToggleBit(_transparency_opt_tmp, to);
}
/**
@@ -109,6 +113,7 @@
static inline void ToggleTransparencyLock(TransparencyOption to)
{
ToggleBit(_transparency_lock, to);
+ if (HasBit(_transparency_lock_tmp, TO_TMP)) ToggleBit(_transparency_lock_tmp, to);
}
/** Set or clear all non-locked transparency options */
@@ -126,4 +131,39 @@
MarkWholeScreenDirty();
}
+/**
+ * Temporarily store transparency options and locks for later
+ * restoration and set all non-locked transparency options.
+ */
+static inline void StartTempTransparency()
+{
+ assert(!HasBit(_transparency_opt_tmp, TO_TMP));
+ assert(!HasBit(_transparency_lock_tmp, TO_TMP));
+
+ _transparency_opt_tmp = _transparency_opt;
+ _transparency_lock_tmp = _transparency_opt_tmp | _transparency_lock;
+ _transparency_opt |= GB(~_transparency_lock_tmp, 0, TO_END);
+
+ SetBit(_transparency_opt_tmp, TO_TMP);
+ SetBit(_transparency_lock_tmp, TO_TMP);
+
+ MarkWholeScreenDirty();
+}
+
+/**
+ * Restore transparency options and clear temporary
+ * transparency options and locks.
+ */
+static inline void StopTempTransparency()
+{
+ assert(HasBit(_transparency_opt_tmp, TO_TMP));
+ assert(HasBit(_transparency_lock_tmp, TO_TMP));
+
+ _transparency_opt &= GB(_transparency_lock_tmp, 0, TO_END);
+ ClrBit(_transparency_opt_tmp, TO_TMP);
+ ClrBit(_transparency_lock_tmp, TO_TMP);
+
+ MarkWholeScreenDirty();
+}
+
#endif /* TRANSPARENCY_H */
Index: src/transparency_gui.cpp
===================================================================
--- src/transparency_gui.cpp (revision 27772)
+++ src/transparency_gui.cpp (working copy)
@@ -22,9 +22,11 @@
#include "safeguards.h"
-TransparencyOptionBits _transparency_opt; ///< The bits that should be transparent.
-TransparencyOptionBits _transparency_lock; ///< Prevent these bits from flipping with X.
-TransparencyOptionBits _invisibility_opt; ///< The bits that should be invisible.
+TransparencyOptionBits _transparency_opt; ///< The bits that should be transparent.
+TransparencyOptionBits _transparency_opt_tmp; ///< Temporary bits that should be transparent while building.
+TransparencyOptionBits _transparency_lock; ///< Prevent these bits from flipping with X.
+TransparencyOptionBits _transparency_lock_tmp; ///< Prevent temporary bits from flipping while building.
+TransparencyOptionBits _invisibility_opt; ///< The bits that should be invisible.
byte _display_opt; ///< What do we want to draw/do?
class TransparenciesWindow : public Window