Loading

Revision differences

Old revision #pvzyrl5w2New revision #p5qn7lvhm
10   10   
11 #include "widgets/dock_widget.h"  11 #include "widgets/dock_widget.h"  
12   12   
13@@ -403,11 +404,14 @@  13@@ -106,6 +107,7 @@
   14     ~BuildDocksToolbarWindow()
14     {  15     {  
15         this->InitNested(TRANSPORT_WATER);  15         if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
16         this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);  16+        this->OnInvalidateData();
17+        StartTempTransparency();    
18     }  18     }  
19   19   
20     virtual ~BuildDocksStationWindow()  20     /**
   21@@ -118,6 +120,18 @@
   22         if (!gui_scope) return;
   23 
   24         bool can_build = CanBuildVehicleInfrastructure(VEH_SHIP);
   25+        for (int i = WID_DT_CANAL; i < WID_DT_INVALID; i++)
   26+        {
   27+            if (_game_mode != GM_EDITOR) {
   28+                if (i != WID_DT_RIVER) {
   29+                    if (this->IsWidgetLowered(i)) StopTempTransparency();
   30+                }
   31+            } else {
   32+                if (i != WID_DT_DEPOT && i != WID_DT_STATION && i != WID_DT_BUOY) {
   33+                    if (this->IsWidgetLowered(i)) StopTempTransparency();
   34+                }
   35+            }
   36+        }
   37         this->SetWidgetsDisabledState(!can_build,
   38             WID_DT_DEPOT,
   39             WID_DT_STATION,
   40@@ -133,39 +147,45 @@
21     {  41     {  
22+         42         switch (widget) {
23         DeleteWindowById(WC_SELECT_STATION, 0);  43             case WID_DT_CANAL: // Build canal button
24+        StopTempTransparency();  44-                HandlePlacePushButton(this, WID_DT_CANAL, SPR_CURSOR_CANAL, HT_RECT);
25     }  45+                if (HandlePlacePushButton(this, WID_DT_CANAL, SPR_CURSOR_CANAL, HT_RECT)) StartTempTransparency();
26   46                 break;
27     virtual void OnPaint()  47 
   48             case WID_DT_LOCK: // Build lock button
   49-                HandlePlacePushButton(this, WID_DT_LOCK, SPR_CURSOR_LOCK, HT_SPECIAL);
   50+                if (HandlePlacePushButton(this, WID_DT_LOCK, SPR_CURSOR_LOCK, HT_SPECIAL)) StartTempTransparency();
   51                 break;
   52 
   53             case WID_DT_DEMOLISH: // Demolish aka dynamite button
   54-                HandlePlacePushButton(this, WID_DT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
   55+                if (HandlePlacePushButton(this, WID_DT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL)) StartTempTransparency();
   56                 break;
   57 
   58             case WID_DT_DEPOT: // Build depot button
   59                 if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
   60-                if (HandlePlacePushButton(this, WID_DT_DEPOT, SPR_CURSOR_SHIP_DEPOT, HT_RECT)) ShowBuildDocksDepotPicker(this);
   61+                if (HandlePlacePushButton(this, WID_DT_DEPOT, SPR_CURSOR_SHIP_DEPOT, HT_RECT)) {
   62+                    ShowBuildDocksDepotPicker(this);
   63+                    StartTempTransparency();
   64+                }
   65                 break;
   66 
   67             case WID_DT_STATION: // Build station button
   68                 if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
   69-                if (HandlePlacePushButton(this, WID_DT_STATION, SPR_CURSOR_DOCK, HT_SPECIAL)) ShowBuildDockStationPicker(this);
   70+                if (HandlePlacePushButton(this, WID_DT_STATION, SPR_CURSOR_DOCK, HT_SPECIAL)) {
   71+                    ShowBuildDockStationPicker(this);
   72+                    StartTempTransparency();
   73+                }
   74                 break;
   75 
   76             case WID_DT_BUOY: // Build buoy button
   77                 if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
   78-                HandlePlacePushButton(this, WID_DT_BUOY, SPR_CURSOR_BUOY, HT_RECT);
   79+                if (HandlePlacePushButton(this, WID_DT_BUOY, SPR_CURSOR_BUOY, HT_RECT)) StartTempTransparency();
   80                 break;
   81 
   82             case WID_DT_RIVER: // Build river button (in scenario editor)
   83                 if (_game_mode != GM_EDITOR) return;
   84-                HandlePlacePushButton(this, WID_DT_RIVER, SPR_CURSOR_RIVER, HT_RECT);
   85+                if (HandlePlacePushButton(this, WID_DT_RIVER, SPR_CURSOR_RIVER, HT_RECT)) StartTempTransparency();
   86                 break;
   87 
   88             case WID_DT_BUILD_AQUEDUCT: // Build aqueduct button
   89-                HandlePlacePushButton(this, WID_DT_BUILD_AQUEDUCT, SPR_CURSOR_AQUEDUCT, HT_SPECIAL);
   90+                if (HandlePlacePushButton(this, WID_DT_BUILD_AQUEDUCT, SPR_CURSOR_AQUEDUCT, HT_SPECIAL)) StartTempTransparency();
   91                 break;
   92 
   93             default: return;
   94@@ -248,6 +268,7 @@
   95 
   96     virtual void OnPlaceObjectAbort()
   97     {
   98+        this->OnInvalidateData();
   99         this->RaiseButtons();
   100 
   101         DeleteWindowById(WC_BUILD_STATION, TRANSPORT_WATER);
   102@@ -347,6 +368,7 @@
   103 {
   104     if (!Company::IsValidID(_local_company)) return NULL;
   105 
   106+    InvalidateWindowClassesData(WC_BUILD_TOOLBAR, 0, true);
   107     DeleteWindowByClass(WC_BUILD_TOOLBAR);
   108     return AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
   109 }
28Index: src/transparency.h  110Index: src/transparency.h  
29===================================================================  111===================================================================  
30--- src/transparency.h    (revision 27772)  112--- src/transparency.h    (revision 27772)  
31+++ src/transparency.h    (working copy)  113+++ src/transparency.h    (working copy)  
32@@ -37,7 +37,9 @@  114@@ -32,12 +32,15 @@
   115     TO_CATENARY,   ///< catenary
   116     TO_LOADING,    ///< loading indicators
   117     TO_END,
   118+    TO_TMP = TO_END,
   119     TO_INVALID,    ///< Invalid transparency option
   120 };
33   121   
34 typedef uint TransparencyOptionBits; ///< transparency option bits  122 typedef uint TransparencyOptionBits; ///< transparency option bits  
35 extern TransparencyOptionBits _transparency_opt;  123 extern TransparencyOptionBits _transparency_opt;  
  
39 extern TransparencyOptionBits _invisibility_opt;  127 extern TransparencyOptionBits _invisibility_opt;  
40 extern byte _display_opt;  128 extern byte _display_opt;  
41   129   
42@@ -71,6 +73,7 @@  42@@ -71,6 +74,7 @@
43 static inline void ToggleTransparency(TransparencyOption to)  131 static inline void ToggleTransparency(TransparencyOption to)  
44 {  132 {  
45     ToggleBit(_transparency_opt, to);  133     ToggleBit(_transparency_opt, to);  
46+    if (_transparency_opt_tmp != NULL) ToggleBit(_transparency_opt_tmp, to);  46+    if (HasBit(_transparency_opt_tmp, TO_TMP)) ToggleBit(_transparency_opt_tmp, to);
47 }  135 }  
48   136   
49 /**  137 /**  
50@@ -109,6 +112,7 @@  50@@ -109,6 +113,7 @@
51 static inline void ToggleTransparencyLock(TransparencyOption to)  139 static inline void ToggleTransparencyLock(TransparencyOption to)  
52 {  140 {  
53     ToggleBit(_transparency_lock, to);  141     ToggleBit(_transparency_lock, to);  
54+    if (_transparency_lock_tmp != NULL) ToggleBit(_transparency_lock_tmp, to);  54+    if (HasBit(_transparency_lock_tmp, TO_TMP)) ToggleBit(_transparency_lock_tmp, to);
55 }  143 }  
56   144   
57 /** Set or clear all non-locked transparency options */  145 /** Set or clear all non-locked transparency options */  
58@@ -126,4 +130,30 @@  58@@ -126,4 +131,39 @@
59     MarkWholeScreenDirty();  147     MarkWholeScreenDirty();  
60 }  148 }  
61   149   
  
65+ */  153+ */  
66+static inline void StartTempTransparency()  154+static inline void StartTempTransparency()  
67+{  155+{  
  156+    assert(!HasBit(_transparency_opt_tmp, TO_TMP));  
  157+    assert(!HasBit(_transparency_lock_tmp, TO_TMP));  
  158+  
68+    _transparency_opt_tmp = _transparency_opt;  159+    _transparency_opt_tmp = _transparency_opt;  
69+    _transparency_lock_tmp = _transparency_opt_tmp | _transparency_lock;  160+    _transparency_lock_tmp = _transparency_opt_tmp | _transparency_lock;  
70+    _transparency_opt |= GB(~_transparency_lock_tmp, 0, TO_END);  161+    _transparency_opt |= GB(~_transparency_lock_tmp, 0, TO_END);  
  162+  
  163+    SetBit(_transparency_opt_tmp, TO_TMP);  
  164+    SetBit(_transparency_lock_tmp, TO_TMP);  
71+  165+  
72+    MarkWholeScreenDirty();  166+    MarkWholeScreenDirty();  
73+}  167+}  
  
78+ */  172+ */  
79+static inline void StopTempTransparency()  173+static inline void StopTempTransparency()  
80+{  174+{  
81+    _transparency_opt &= _transparency_lock_tmp;  175+    assert(HasBit(_transparency_opt_tmp, TO_TMP));
82+    _transparency_opt_tmp = NULL;  176+    assert(HasBit(_transparency_lock_tmp, TO_TMP));
83+    _transparency_lock_tmp = NULL;  177+
   178+    _transparency_opt &= GB(_transparency_lock_tmp, 0, TO_END);
   179+    ClrBit(_transparency_opt_tmp, TO_TMP);
   180+    ClrBit(_transparency_lock_tmp, TO_TMP);
84+  181+  
85+    MarkWholeScreenDirty();  182+    MarkWholeScreenDirty();  
86+}  183+}  
  
97-TransparencyOptionBits _transparency_opt;  ///< The bits that should be transparent.  194-TransparencyOptionBits _transparency_opt;  ///< The bits that should be transparent.  
98-TransparencyOptionBits _transparency_lock; ///< Prevent these bits from flipping with X.  195-TransparencyOptionBits _transparency_lock; ///< Prevent these bits from flipping with X.  
99-TransparencyOptionBits _invisibility_opt;  ///< The bits that should be invisible.  196-TransparencyOptionBits _invisibility_opt;  ///< The bits that should be invisible.  
100+TransparencyOptionBits _transparency_opt;             ///< The bits that should be transparent.  100+TransparencyOptionBits _transparency_opt;      ///< The bits that should be transparent.
101+TransparencyOptionBits _transparency_opt_tmp = NULL;  ///< Temporary bits that should be transparent while building.  101+TransparencyOptionBits _transparency_opt_tmp;  ///< Temporary bits that should be transparent while building.
102+TransparencyOptionBits _transparency_lock;            ///< Prevent these bits from flipping with X.  102+TransparencyOptionBits _transparency_lock;     ///< Prevent these bits from flipping with X.
103+TransparencyOptionBits _transparency_lock_tmp = NULL; ///< Prevent temporary bits from flipping while building.  103+TransparencyOptionBits _transparency_lock_tmp; ///< Prevent temporary bits from flipping while building.
104+TransparencyOptionBits _invisibility_opt;             ///< The bits that should be invisible.  104+TransparencyOptionBits _invisibility_opt;      ///< The bits that should be invisible.
105 byte _display_opt; ///< What do we want to draw/do?  202 byte _display_opt; ///< What do we want to draw/do?  
106   203   
107 class TransparenciesWindow : public Window 204 class TransparenciesWindow : public Window