105 static void PlaceRoad_DemolishArea(TileIndex tile) |
105 static void PlaceRoad_DemolishArea(TileIndex tile) |
106 { |
106 { |
107 VpStartPlaceSizing(tile, 4); |
107 VpStartPlaceSizing(tile, 4); |
108 } |
108 } |
109 |
109 |
|
110 |
|
111 enum { |
|
112 RTW_ROAD_X = 3, |
|
113 RTW_ROAD_Y = 4, |
|
114 RTW_DEMOLISH = 5, |
|
115 RTW_DEPOT = 6, |
|
116 RTW_BUS_STATION = 7, |
|
117 RTW_TRUCK_STATION = 8, |
|
118 RTW_BUILD_BRIDGE = 9, |
|
119 RTW_BUILD_TUNNEL = 10, |
|
120 RTW_REMOVE = 11 |
|
121 }; |
|
122 |
|
123 |
110 typedef void OnButtonClick(Window *w); |
124 typedef void OnButtonClick(Window *w); |
111 |
125 |
112 static void BuildRoadClick_NE(Window *w) |
126 static void BuildRoadClick_NE(Window *w) |
113 { |
127 { |
114 HandlePlacePushButton(w, 3, SPR_CURSOR_ROAD_NESW, 1, PlaceRoad_NE); |
128 HandlePlacePushButton(w, RTW_ROAD_X, SPR_CURSOR_ROAD_NESW, 1, PlaceRoad_NE); |
115 } |
129 } |
116 |
130 |
117 static void BuildRoadClick_NW(Window *w) |
131 static void BuildRoadClick_NW(Window *w) |
118 { |
132 { |
119 HandlePlacePushButton(w, 4, SPR_CURSOR_ROAD_NWSE, 1, PlaceRoad_NW); |
133 HandlePlacePushButton(w, RTW_ROAD_Y, SPR_CURSOR_ROAD_NWSE, 1, PlaceRoad_NW); |
120 } |
134 } |
121 |
135 |
122 |
136 |
123 static void BuildRoadClick_Demolish(Window *w) |
137 static void BuildRoadClick_Demolish(Window *w) |
124 { |
138 { |
125 HandlePlacePushButton(w, 5, ANIMCURSOR_DEMOLISH, 1, PlaceRoad_DemolishArea); |
139 HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, 1, PlaceRoad_DemolishArea); |
126 } |
140 } |
127 |
141 |
128 static void BuildRoadClick_Depot(Window *w) |
142 static void BuildRoadClick_Depot(Window *w) |
129 { |
143 { |
130 if (_game_mode == GM_EDITOR) return; |
144 if (_game_mode == GM_EDITOR) return; |
131 if (HandlePlacePushButton(w, 6, SPR_CURSOR_ROAD_DEPOT, 1, PlaceRoad_Depot)) ShowRoadDepotPicker(); |
145 if (HandlePlacePushButton(w, RTW_DEPOT, SPR_CURSOR_ROAD_DEPOT, 1, PlaceRoad_Depot)) ShowRoadDepotPicker(); |
132 } |
146 } |
133 |
147 |
134 static void BuildRoadClick_BusStation(Window *w) |
148 static void BuildRoadClick_BusStation(Window *w) |
135 { |
149 { |
136 if (_game_mode == GM_EDITOR) return; |
150 if (_game_mode == GM_EDITOR) return; |
137 if (HandlePlacePushButton(w, 7, SPR_CURSOR_BUS_STATION, 1, PlaceRoad_BusStation)) ShowBusStationPicker(); |
151 if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, 1, PlaceRoad_BusStation)) ShowBusStationPicker(); |
138 } |
152 } |
139 |
153 |
140 static void BuildRoadClick_TruckStation(Window *w) |
154 static void BuildRoadClick_TruckStation(Window *w) |
141 { |
155 { |
142 if (_game_mode == GM_EDITOR) return; |
156 if (_game_mode == GM_EDITOR) return; |
143 if (HandlePlacePushButton(w, 8, SPR_CURSOR_TRUCK_STATION, 1, PlaceRoad_TruckStation)) ShowTruckStationPicker(); |
157 if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, 1, PlaceRoad_TruckStation)) ShowTruckStationPicker(); |
144 } |
158 } |
145 |
159 |
146 static void BuildRoadClick_Bridge(Window *w) |
160 static void BuildRoadClick_Bridge(Window *w) |
147 { |
161 { |
148 HandlePlacePushButton(w, 9, SPR_CURSOR_BRIDGE, 1, PlaceRoad_Bridge); |
162 HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, 1, PlaceRoad_Bridge); |
149 } |
163 } |
150 |
164 |
151 static void BuildRoadClick_Tunnel(Window *w) |
165 static void BuildRoadClick_Tunnel(Window *w) |
152 { |
166 { |
153 HandlePlacePushButton(w, 10, SPR_CURSOR_ROAD_TUNNEL, 3, PlaceRoad_Tunnel); |
167 HandlePlacePushButton(w, RTW_BUILD_TUNNEL, SPR_CURSOR_ROAD_TUNNEL, 3, PlaceRoad_Tunnel); |
154 } |
168 } |
155 |
169 |
156 static void BuildRoadClick_Remove(Window *w) |
170 static void BuildRoadClick_Remove(Window *w) |
157 { |
171 { |
158 if (IsWindowWidgetDisabled(w, 11)) return; |
172 if (IsWindowWidgetDisabled(w, RTW_REMOVE)) return; |
159 SetWindowDirty(w); |
173 SetWindowDirty(w); |
160 SndPlayFx(SND_15_BEEP); |
174 SndPlayFx(SND_15_BEEP); |
161 ToggleWidgetLoweredState(w, 11); |
175 ToggleWidgetLoweredState(w, RTW_REMOVE); |
162 SetSelectionRed(IsWindowWidgetLowered(w, 11)); |
176 SetSelectionRed(IsWindowWidgetLowered(w, RTW_REMOVE)); |
163 } |
177 } |
164 |
178 |
165 static void BuildRoadClick_Landscaping(Window *w) |
179 static void BuildRoadClick_Landscaping(Window *w) |
166 { |
180 { |
167 ShowTerraformToolbar(); |
181 ShowTerraformToolbar(); |
213 MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection |
227 MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection |
214 e->we.keypress.cont = false; |
228 e->we.keypress.cont = false; |
215 break; |
229 break; |
216 |
230 |
217 case WE_PLACE_OBJ: |
231 case WE_PLACE_OBJ: |
218 _remove_button_clicked = IsWindowWidgetLowered(w, 11); |
232 _remove_button_clicked = IsWindowWidgetLowered(w, RTW_REMOVE); |
219 _place_proc(e->we.place.tile); |
233 _place_proc(e->we.place.tile); |
220 break; |
234 break; |
221 |
235 |
222 case WE_ABORT_PLACE_OBJ: |
236 case WE_ABORT_PLACE_OBJ: |
223 RaiseWindowButtons(w); |
237 RaiseWindowButtons(w); |
224 DisableWindowWidget(w, 11); |
238 DisableWindowWidget(w, RTW_REMOVE); |
225 InvalidateWidget(w, 11); |
239 InvalidateWidget(w, RTW_REMOVE); |
226 |
240 |
227 w = FindWindowById(WC_BUS_STATION, 0); |
241 w = FindWindowById(WC_BUS_STATION, 0); |
228 if (w != NULL) WP(w,def_d).close = true; |
242 if (w != NULL) WP(w,def_d).close = true; |
229 w = FindWindowById(WC_TRUCK_STATION, 0); |
243 w = FindWindowById(WC_TRUCK_STATION, 0); |
230 if (w != NULL) WP(w,def_d).close = true; |
244 if (w != NULL) WP(w,def_d).close = true; |