Old revision #p3ylqawqb | New revision #p5qn7lvhm | ||
---|---|---|---|
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 | + | 17 | + this->OnInvalidateData(); |
18 | } | 18 | } |
19 | 19 | ||
20 | /** | 20 | /** |
21 | @@ -126,6 +128,7 @@ | 21 | @@ -118,6 +120,18 @@ |
22 | if (!can_build) { | 22 | if (!gui_scope) return; |
23 | DeleteWindowById(WC_BUILD_STATION, TRANSPORT_WATER); | 23 | |
24 | DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER); | 24 | bool can_build = CanBuildVehicleInfrastructure(VEH_SHIP); |
25 | + StopTempTransparency(); | 25 | + for (int i = WID_DT_CANAL; i < WID_DT_INVALID; i++) |
26 | } | 26 | + { |
27 | } | 27 | + if (_game_mode != GM_EDITOR) { |
28 | 28 | + if (i != WID_DT_RIVER) { | |
29 | @@ -133,39 +136,45 @@ | 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 @@ | ||
30 | { | 41 | { |
31 | switch (widget) { | 42 | switch (widget) { |
32 | case WID_DT_CANAL: // Build canal button | 43 | case WID_DT_CANAL: // Build canal button | … | … |
80 | break; | 91 | break; |
81 | 92 | ||
82 | default: return; | 93 | default: return; |
83 | @@ -254,6 +263,7 @@ | 94 | @@ -248,6 +268,7 @@ |
84 | DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER); | 95 | |
85 | DeleteWindowById(WC_SELECT_STATION, 0); | 96 | virtual void OnPlaceObjectAbort() |
86 | DeleteWindowByClass(WC_BUILD_BRIDGE); | 97 | { |
87 | + StopTempTransparency(); | 98 | + this->OnInvalidateData(); |
88 | } | 99 | this->RaiseButtons(); |
89 | 100 | ||
90 | virtual void OnPlacePresize(Point pt, TileIndex tile_from) | 101 | DeleteWindowById(WC_BUILD_STATION, TRANSPORT_WATER); |
91 | @@ -348,6 +358,7 @@ | 102 | @@ -347,6 +368,7 @@ |
103 | { | ||
92 | if (!Company::IsValidID(_local_company)) return NULL; | 104 | if (!Company::IsValidID(_local_company)) return NULL; |
93 | 105 | ||
106 | + InvalidateWindowClassesData(WC_BUILD_TOOLBAR, 0, true); | ||
94 | DeleteWindowByClass(WC_BUILD_TOOLBAR); | 107 | DeleteWindowByClass(WC_BUILD_TOOLBAR); |
95 | |||
96 | return AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER); | 108 | return AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER); |
97 | } | 109 | } |
98 | |||
99 | |||
100 | |||
101 | |||
102 | |||
103 | |||
104 | |||
105 | |||
106 | |||
107 | |||
108 | |||
109 | |||
110 | |||
111 | |||
112 | |||
113 | |||
114 | |||
115 | |||
116 | |||
117 | |||
118 | |||
119 | |||
120 | |||
121 | |||
122 | |||
123 | |||
124 | |||
125 | |||
126 | |||
127 | Index: src/transparency.h | 110 | Index: src/transparency.h |
128 | =================================================================== | 111 | =================================================================== |
129 | --- src/transparency.h (revision 27772) | 112 | --- src/transparency.h (revision 27772) |
130 | +++ src/transparency.h (working copy) | 113 | +++ src/transparency.h (working copy) |
131 | @@ -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 | }; | ||
132 | 121 | ||
133 | typedef uint TransparencyOptionBits; ///< transparency option bits | 122 | typedef uint TransparencyOptionBits; ///< transparency option bits |
134 | extern TransparencyOptionBits _transparency_opt; | 123 | extern TransparencyOptionBits _transparency_opt; | … | … |
138 | extern TransparencyOptionBits _invisibility_opt; | 127 | extern TransparencyOptionBits _invisibility_opt; |
139 | extern byte _display_opt; | 128 | extern byte _display_opt; |
140 | 129 | ||
141 | @@ -71,6 +7 | 141 | @@ -71,6 +74,7 @@ |
142 | static inline void ToggleTransparency(TransparencyOption to) | 131 | static inline void ToggleTransparency(TransparencyOption to) |
143 | { | 132 | { |
144 | ToggleBit(_transparency_opt, to); | 133 | ToggleBit(_transparency_opt, to); |
145 | + if ( | 145 | + if (HasBit(_transparency_opt_tmp, TO_TMP)) ToggleBit(_transparency_opt_tmp, to); |
146 | } | 135 | } |
147 | 136 | ||
148 | /** | 137 | /** |
149 | @@ -109,6 +11 | 149 | @@ -109,6 +113,7 @@ |
150 | static inline void ToggleTransparencyLock(TransparencyOption to) | 139 | static inline void ToggleTransparencyLock(TransparencyOption to) |
151 | { | 140 | { |
152 | ToggleBit(_transparency_lock, to); | 141 | ToggleBit(_transparency_lock, to); |
153 | + if ( | 153 | + if (HasBit(_transparency_lock_tmp, TO_TMP)) ToggleBit(_transparency_lock_tmp, to); |
154 | } | 143 | } |
155 | 144 | ||
156 | /** Set or clear all non-locked transparency options */ | 145 | /** Set or clear all non-locked transparency options */ |
157 | @@ -126,4 +13 | 157 | @@ -126,4 +131,39 @@ |
158 | MarkWholeScreenDirty(); | 147 | MarkWholeScreenDirty(); |
159 | } | 148 | } |
160 | 149 | … | … |
164 | + */ | 153 | + */ |
165 | +static inline void StartTempTransparency() | 154 | +static inline void StartTempTransparency() |
166 | +{ | 155 | +{ |
156 | + assert(!HasBit(_transparency_opt_tmp, TO_TMP)); | ||
157 | + assert(!HasBit(_transparency_lock_tmp, TO_TMP)); | ||
158 | + | ||
167 | + _transparency_opt_tmp = _transparency_opt; | 159 | + _transparency_opt_tmp = _transparency_opt; |
168 | + _transparency_lock_tmp = _transparency_opt_tmp | _transparency_lock; | 160 | + _transparency_lock_tmp = _transparency_opt_tmp | _transparency_lock; |
169 | + _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); | ||
170 | + | 165 | + |
171 | + MarkWholeScreenDirty(); | 166 | + MarkWholeScreenDirty(); |
172 | +} | 167 | +} | … | … |
177 | + */ | 172 | + */ |
178 | +static inline void StopTempTransparency() | 173 | +static inline void StopTempTransparency() |
179 | +{ | 174 | +{ |
180 | + _transparency_opt &= _transparency_lock_tmp; | 175 | + assert(HasBit(_transparency_opt_tmp, TO_TMP)); |
181 | + _transparency_opt_tmp = NULL; | 176 | + assert(HasBit(_transparency_lock_tmp, TO_TMP)); |
182 | + _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); | ||
183 | + | 181 | + |
184 | + MarkWholeScreenDirty(); | 182 | + MarkWholeScreenDirty(); |
185 | +} | 183 | +} | … | … |
196 | -TransparencyOptionBits _transparency_opt; ///< The bits that should be transparent. | 194 | -TransparencyOptionBits _transparency_opt; ///< The bits that should be transparent. |
197 | -TransparencyOptionBits _transparency_lock; ///< Prevent these bits from flipping with X. | 195 | -TransparencyOptionBits _transparency_lock; ///< Prevent these bits from flipping with X. |
198 | -TransparencyOptionBits _invisibility_opt; ///< The bits that should be invisible. | 196 | -TransparencyOptionBits _invisibility_opt; ///< The bits that should be invisible. |
199 | +TransparencyOptionBits _transparency_opt; | 199 | +TransparencyOptionBits _transparency_opt; ///< The bits that should be transparent. |
200 | +TransparencyOptionBits _transparency_opt_tmp | 200 | +TransparencyOptionBits _transparency_opt_tmp; ///< Temporary bits that should be transparent while building. |
201 | +TransparencyOptionBits _transparency_lock; | 201 | +TransparencyOptionBits _transparency_lock; ///< Prevent these bits from flipping with X. |
202 | +TransparencyOptionBits _transparency_lock_tmp | 202 | +TransparencyOptionBits _transparency_lock_tmp; ///< Prevent temporary bits from flipping while building. |
203 | +TransparencyOptionBits _invisibility_opt; | 203 | +TransparencyOptionBits _invisibility_opt; ///< The bits that should be invisible. |
204 | byte _display_opt; ///< What do we want to draw/do? | 202 | byte _display_opt; ///< What do we want to draw/do? |
205 | 203 | ||
206 | class TransparenciesWindow : public Window | 204 | class TransparenciesWindow : public Window |