Loading

Revision differences

Old revision #p3ylqawqbNew revision #p8iovjkgp
14     ~BuildDocksToolbarWindow()  14     ~BuildDocksToolbarWindow()  
15     {  15     {  
16         if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);  16         if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);  
17+        StopTempTransparency();  17+        this->OnInvalidateData();
18     }  18     }  
19   19   
20     /**  20     /**  
21@@ -126,6 +128,7 @@  21@@ -117,6 +119,18 @@
   22     {
   23         if (!gui_scope) return;
   24 
   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         bool can_build = CanBuildVehicleInfrastructure(VEH_SHIP);
   38         this->SetWidgetsDisabledState(!can_build,
   39             WID_DT_DEPOT,
   40@@ -125,7 +139,7 @@
   41             WIDGET_LIST_END);
22         if (!can_build) {  42         if (!can_build) {  
23             DeleteWindowById(WC_BUILD_STATION, TRANSPORT_WATER);  43             DeleteWindowById(WC_BUILD_STATION, TRANSPORT_WATER);  
24             DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER);  24-            DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER);
25+            StopTempTransparency();  25+            DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER);       
26         }  46         }  
27     }  47     }  
28   48   
29@@ -133,39 +136,45 @@  29@@ -133,39 +147,45 @@
30     {  50     {  
31         switch (widget) {  51         switch (widget) {  
32             case WID_DT_CANAL: // Build canal button  52             case WID_DT_CANAL: // Build canal button  
  
80                 break;  100                 break;  
81   101   
82             default: return;  102             default: return;  
83@@ -254,6 +263,7 @@  103@@ -248,6 +268,7 @@
84         DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER);  104 
85         DeleteWindowById(WC_SELECT_STATION, 0);  105     virtual void OnPlaceObjectAbort()
86         DeleteWindowByClass(WC_BUILD_BRIDGE);  106     {
87+        StopTempTransparency();  107+        this->OnInvalidateData();
88     }  108         this->RaiseButtons();
89   109 
90     virtual void OnPlacePresize(Point pt, TileIndex tile_from)  110         DeleteWindowById(WC_BUILD_STATION, TRANSPORT_WATER);
91@@ -348,6 +358,7 @@  111@@ -347,6 +368,7 @@
   112 {
92     if (!Company::IsValidID(_local_company)) return NULL;  113     if (!Company::IsValidID(_local_company)) return NULL;  
93   114   
  115+    InvalidateWindowClassesData(WC_BUILD_TOOLBAR, 0, true);  
94     DeleteWindowByClass(WC_BUILD_TOOLBAR);  116     DeleteWindowByClass(WC_BUILD_TOOLBAR);  
95+    StopTempTransparency();    
96     return AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);  117     return AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);  
97 }  118 }  
98     
99@@ -407,7 +418,9 @@    
100     
101     virtual ~BuildDocksStationWindow()    
102     {    
103+           
104         DeleteWindowById(WC_SELECT_STATION, 0);    
105+        StopTempTransparency();    
106     }    
107     
108     virtual void OnPaint()    
109@@ -502,9 +515,17 @@    
110     {    
111         this->InitNested(TRANSPORT_WATER);    
112         this->LowerWidget(_ship_depot_direction + WID_BDD_X);    
113+        StartTempTransparency();    
114         UpdateDocksDirection();    
115     }    
116     
117+    virtual ~BuildDocksDepotWindow()    
118+    {    
119+    
120+        DeleteWindowById(WC_SELECT_STATION, 0);    
121+        StopTempTransparency();    
122+    }    
123+    
124     virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)    
125     {    
126         switch (widget) {    
127Index: src/transparency.h  119Index: src/transparency.h  
128===================================================================  120===================================================================  
129--- src/transparency.h    (revision 27772)  121--- src/transparency.h    (revision 27772)  
130+++ src/transparency.h    (working copy)  122+++ src/transparency.h    (working copy)  
131@@ -37,7 +37,9 @@  123@@ -32,12 +32,15 @@
   124     TO_CATENARY,   ///< catenary
   125     TO_LOADING,    ///< loading indicators
   126     TO_END,
   127+    TO_TMP = TO_END,
   128     TO_INVALID,    ///< Invalid transparency option
   129 };
132   130   
133 typedef uint TransparencyOptionBits; ///< transparency option bits  131 typedef uint TransparencyOptionBits; ///< transparency option bits  
134 extern TransparencyOptionBits _transparency_opt;  132 extern TransparencyOptionBits _transparency_opt;  
  
138 extern TransparencyOptionBits _invisibility_opt;  136 extern TransparencyOptionBits _invisibility_opt;  
139 extern byte _display_opt;  137 extern byte _display_opt;  
140   138   
141@@ -71,6 +73,7 @@  141@@ -71,6 +74,7 @@
142 static inline void ToggleTransparency(TransparencyOption to)  140 static inline void ToggleTransparency(TransparencyOption to)  
143 {  141 {  
144     ToggleBit(_transparency_opt, to);  142     ToggleBit(_transparency_opt, to);  
145+    if (_transparency_opt_tmp != NULL) ToggleBit(_transparency_opt_tmp, to);  145+    if (HasBit(_transparency_opt_tmp, TO_TMP)) ToggleBit(_transparency_opt_tmp, to);
146 }  144 }  
147   145   
148 /**  146 /**  
149@@ -109,6 +112,7 @@  149@@ -109,6 +113,7 @@
150 static inline void ToggleTransparencyLock(TransparencyOption to)  148 static inline void ToggleTransparencyLock(TransparencyOption to)  
151 {  149 {  
152     ToggleBit(_transparency_lock, to);  150     ToggleBit(_transparency_lock, to);  
153+    if (_transparency_lock_tmp != NULL) ToggleBit(_transparency_lock_tmp, to);  153+    if (HasBit(_transparency_lock_tmp, TO_TMP)) ToggleBit(_transparency_lock_tmp, to);
154 }  152 }  
155   153   
156 /** Set or clear all non-locked transparency options */  154 /** Set or clear all non-locked transparency options */  
157@@ -126,4 +130,30 @@  157@@ -126,4 +131,39 @@
158     MarkWholeScreenDirty();  156     MarkWholeScreenDirty();  
159 }  157 }  
160   158   
  
164+ */  162+ */  
165+static inline void StartTempTransparency()  163+static inline void StartTempTransparency()  
166+{  164+{  
  165+    assert(!HasBit(_transparency_opt_tmp, TO_TMP));  
  166+    assert(!HasBit(_transparency_lock_tmp, TO_TMP));  
  167+  
167+    _transparency_opt_tmp = _transparency_opt;  168+    _transparency_opt_tmp = _transparency_opt;  
168+    _transparency_lock_tmp = _transparency_opt_tmp | _transparency_lock;  169+    _transparency_lock_tmp = _transparency_opt_tmp | _transparency_lock;  
169+    _transparency_opt |= GB(~_transparency_lock_tmp, 0, TO_END);  170+    _transparency_opt |= GB(~_transparency_lock_tmp, 0, TO_END);  
  171+  
  172+    SetBit(_transparency_opt_tmp, TO_TMP);  
  173+    SetBit(_transparency_lock_tmp, TO_TMP);  
170+  174+  
171+    MarkWholeScreenDirty();  175+    MarkWholeScreenDirty();  
172+}  176+}  
  
177+ */  181+ */  
178+static inline void StopTempTransparency()  182+static inline void StopTempTransparency()  
179+{  183+{  
180+    _transparency_opt &= _transparency_lock_tmp;  184+    assert(HasBit(_transparency_opt_tmp, TO_TMP));
181+    _transparency_opt_tmp = NULL;  185+    assert(HasBit(_transparency_lock_tmp, TO_TMP));
182+    _transparency_lock_tmp = NULL;  186+
   187+    _transparency_opt &= GB(_transparency_lock_tmp, 0, TO_END);
   188+    ClrBit(_transparency_opt_tmp, TO_TMP);
   189+    ClrBit(_transparency_lock_tmp, TO_TMP);
183+  190+  
184+    MarkWholeScreenDirty();  191+    MarkWholeScreenDirty();  
185+}  192+}  
  
196-TransparencyOptionBits _transparency_opt;  ///< The bits that should be transparent.  203-TransparencyOptionBits _transparency_opt;  ///< The bits that should be transparent.  
197-TransparencyOptionBits _transparency_lock; ///< Prevent these bits from flipping with X.  204-TransparencyOptionBits _transparency_lock; ///< Prevent these bits from flipping with X.  
198-TransparencyOptionBits _invisibility_opt;  ///< The bits that should be invisible.  205-TransparencyOptionBits _invisibility_opt;  ///< The bits that should be invisible.  
199+TransparencyOptionBits _transparency_opt;             ///< The bits that should be transparent.  199+TransparencyOptionBits _transparency_opt;      ///< The bits that should be transparent.
200+TransparencyOptionBits _transparency_opt_tmp = NULL;  ///< Temporary bits that should be transparent while building.  200+TransparencyOptionBits _transparency_opt_tmp;  ///< Temporary bits that should be transparent while building.
201+TransparencyOptionBits _transparency_lock;            ///< Prevent these bits from flipping with X.  201+TransparencyOptionBits _transparency_lock;     ///< Prevent these bits from flipping with X.
202+TransparencyOptionBits _transparency_lock_tmp = NULL; ///< Prevent temporary bits from flipping while building.  202+TransparencyOptionBits _transparency_lock_tmp; ///< Prevent temporary bits from flipping while building.
203+TransparencyOptionBits _invisibility_opt;             ///< The bits that should be invisible.  203+TransparencyOptionBits _invisibility_opt;      ///< The bits that should be invisible.
204 byte _display_opt; ///< What do we want to draw/do?  211 byte _display_opt; ///< What do we want to draw/do?  
205   212   
206 class TransparenciesWindow : public Window 213 class TransparenciesWindow : public Window