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