src/rail_gui.cpp
changeset 7991 d6a95a5593ba
parent 7955 64310868e7aa
child 7997 df87ccd00a96
equal deleted inserted replaced
7990:63211992f5c1 7991:d6a95a5593ba
    36 static RailType _cur_railtype;
    36 static RailType _cur_railtype;
    37 static bool _remove_button_clicked;
    37 static bool _remove_button_clicked;
    38 static DiagDirection _build_depot_direction;
    38 static DiagDirection _build_depot_direction;
    39 static byte _waypoint_count = 1;
    39 static byte _waypoint_count = 1;
    40 static byte _cur_waypoint_type;
    40 static byte _cur_waypoint_type;
       
    41 static bool _convert_signal_button; // convert signal button in the signal GUI pressed
       
    42 static SignalVariant _cur_signal_variant; // set the signal variant (for signal GUI)
       
    43 static SignalType _cur_signal_type; // set the signal type (for signal GUI)
    41 
    44 
    42 static struct {
    45 static struct {
    43 	byte orientation;
    46 	byte orientation;
    44 	byte numtracks;
    47 	byte numtracks;
    45 	byte platlength;
    48 	byte platlength;
    54 
    57 
    55 static void HandleStationPlacement(TileIndex start, TileIndex end);
    58 static void HandleStationPlacement(TileIndex start, TileIndex end);
    56 static void ShowBuildTrainDepotPicker();
    59 static void ShowBuildTrainDepotPicker();
    57 static void ShowBuildWaypointPicker();
    60 static void ShowBuildWaypointPicker();
    58 static void ShowStationBuilder();
    61 static void ShowStationBuilder();
       
    62 static void ShowSignalBuilder();
    59 
    63 
    60 void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2)
    64 void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2)
    61 {
    65 {
    62 	if (success) SndPlayTileFx(SND_20_SPLAT_2, tile);
    66 	if (success) SndPlayTileFx(SND_20_SPLAT_2, tile);
    63 }
    67 }
   168 				_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation,
   172 				_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation,
   169 				CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
   173 				CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
   170 	}
   174 	}
   171 }
   175 }
   172 
   176 
       
   177 /**
       
   178  * Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp
       
   179  *
       
   180  * @param tile The tile where the signal will build or edit
       
   181  */
   173 static void GenericPlaceSignals(TileIndex tile)
   182 static void GenericPlaceSignals(TileIndex tile)
   174 {
   183 {
   175 	TrackBits trackbits = (TrackBits)GB(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0), 0, 6);
   184 	TrackBits trackbits = (TrackBits)GB(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0), 0, 6);
   176 
   185 
   177 	if (trackbits & TRACK_BIT_VERT) { // N-S direction
   186 	if (trackbits & TRACK_BIT_VERT) { // N-S direction
   186 
   195 
   187 	if (_remove_button_clicked) {
   196 	if (_remove_button_clicked) {
   188 		DoCommandP(tile, track, 0, CcPlaySound1E,
   197 		DoCommandP(tile, track, 0, CcPlaySound1E,
   189 			CMD_REMOVE_SIGNALS | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM));
   198 			CMD_REMOVE_SIGNALS | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM));
   190 	} else {
   199 	} else {
       
   200 		if (!_patches.enable_signal_gui) _cur_signal_variant = _cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC;
       
   201 
       
   202 		/* various bitstuffed elements for CmdBuildSingleSignal() */
   191 		uint32 p1 = track;
   203 		uint32 p1 = track;
   192 		SB(p1, 3, 1, _ctrl_pressed);
   204 		SB(p1, 3, 1, _ctrl_pressed);
   193 		SB(p1, 4, 1, _cur_year < _patches.semaphore_build_before);
   205 		SB(p1, 4, 1, _cur_signal_variant);
   194 
   206 		SB(p1, 5, 2, _patches.enable_signal_gui ? _cur_signal_type : SIGTYPE_NORMAL);
   195 		DoCommandP(tile, p1, 0, CcPlaySound1E,
   207 		SB(p1, 7, 1, _convert_signal_button);
   196 			CMD_BUILD_SIGNALS | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE));
   208 
       
   209 		DoCommandP(tile, p1, 0, CcPlaySound1E, CMD_BUILD_SIGNALS |
       
   210 			CMD_MSG(_convert_signal_button ? STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_1010_CAN_T_BUILD_SIGNALS_HERE));
   197 	}
   211 	}
   198 }
   212 }
   199 
   213 
   200 static void PlaceRail_Bridge(TileIndex tile)
   214 static void PlaceRail_Bridge(TileIndex tile)
   201 {
   215 {
   305 static void BuildRailClick_Station(Window *w)
   319 static void BuildRailClick_Station(Window *w)
   306 {
   320 {
   307 	if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, VHM_RECT, PlaceRail_Station)) ShowStationBuilder();
   321 	if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, VHM_RECT, PlaceRail_Station)) ShowStationBuilder();
   308 }
   322 }
   309 
   323 
       
   324 /** The "build signal"-button proc from BuildRailToolbWndProc() (start ShowSignalBuilder() and/or HandleAutoSignalPlacement()) */
   310 static void BuildRailClick_AutoSignals(Window *w)
   325 static void BuildRailClick_AutoSignals(Window *w)
   311 {
   326 {
   312 	HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals);
   327 	if (_patches.enable_signal_gui) {
       
   328 		if (HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals)) ShowSignalBuilder();
       
   329 	} else {
       
   330 		HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals);
       
   331 	}
   313 }
   332 }
   314 
   333 
   315 static void BuildRailClick_Bridge(Window *w)
   334 static void BuildRailClick_Bridge(Window *w)
   316 {
   335 {
   317 	HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, VHM_RECT, PlaceRail_Bridge);
   336 	HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, VHM_RECT, PlaceRail_Bridge);
   364 	}
   383 	}
   365 
   384 
   366 	DoRailroadTrack(trackstat);
   385 	DoRailroadTrack(trackstat);
   367 }
   386 }
   368 
   387 
       
   388 /**
       
   389  * Build new signals or remove signals or (if only one tile marked) edit a signal.
       
   390  *
       
   391  * If one tile marked abort and use GenericPlaceSignals()
       
   392  * else use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp to build many signals
       
   393  */
   369 static void HandleAutoSignalPlacement()
   394 static void HandleAutoSignalPlacement()
   370 {
   395 {
   371 	TileHighlightData *thd = &_thd;
   396 	TileHighlightData *thd = &_thd;
   372 	uint32 p2 = GB(thd->drawstyle, 0, 3); // 0..5
   397 	uint32 p2 = GB(thd->drawstyle, 0, 3); // 0..5
   373 
   398 
   461 			RaiseWindowWidget(w, RTW_REMOVE);
   486 			RaiseWindowWidget(w, RTW_REMOVE);
   462 			break;
   487 			break;
   463 	}
   488 	}
   464 }
   489 }
   465 
   490 
       
   491 /**
       
   492  * Railway toolbar window event definition
       
   493  *
       
   494  * @param w window pointer
       
   495  * @param e event been triggered
       
   496  */
   466 static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
   497 static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
   467 {
   498 {
   468 	switch (e->event) {
   499 	switch (e->event) {
   469 	case WE_CREATE: DisableWindowWidget(w, RTW_REMOVE); break;
   500 	case WE_CREATE: DisableWindowWidget(w, RTW_REMOVE); break;
   470 
   501 
   494 	case WE_PLACE_OBJ:
   525 	case WE_PLACE_OBJ:
   495 		_place_proc(e->we.place.tile);
   526 		_place_proc(e->we.place.tile);
   496 		return;
   527 		return;
   497 
   528 
   498 	case WE_PLACE_DRAG: {
   529 	case WE_PLACE_DRAG: {
       
   530 		/* no dragging if you have pressed the convert button */
       
   531 		if (_convert_signal_button && IsWindowWidgetLowered(w, RTW_BUILD_SIGNALS)) return;
       
   532 
   499 		VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
   533 		VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
   500 		return;
   534 		return;
   501 	}
   535 	}
   502 
   536 
   503 	case WE_PLACE_MOUSEUP:
   537 	case WE_PLACE_MOUSEUP:
   546 	case WE_ABORT_PLACE_OBJ:
   580 	case WE_ABORT_PLACE_OBJ:
   547 		RaiseWindowButtons(w);
   581 		RaiseWindowButtons(w);
   548 		DisableWindowWidget(w, RTW_REMOVE);
   582 		DisableWindowWidget(w, RTW_REMOVE);
   549 		InvalidateWidget(w, RTW_REMOVE);
   583 		InvalidateWidget(w, RTW_REMOVE);
   550 
   584 
       
   585 		w = FindWindowById(WC_BUILD_SIGNAL, 0);
       
   586 		if (w != NULL) WP(w, def_d).close = true;
   551 		w = FindWindowById(WC_BUILD_STATION, 0);
   587 		w = FindWindowById(WC_BUILD_STATION, 0);
   552 		if (w != NULL) WP(w,def_d).close = true;
   588 		if (w != NULL) WP(w, def_d).close = true;
   553 		w = FindWindowById(WC_BUILD_DEPOT, 0);
   589 		w = FindWindowById(WC_BUILD_DEPOT, 0);
   554 		if (w != NULL) WP(w,def_d).close = true;
   590 		if (w != NULL) WP(w, def_d).close = true;
   555 		break;
   591 		break;
   556 
   592 
   557 	case WE_PLACE_PRESIZE: {
   593 	case WE_PLACE_PRESIZE: {
   558 		TileIndex tile = e->we.place.tile;
   594 		TileIndex tile = e->we.place.tile;
   559 
   595 
   750 	case WE_PAINT: {
   786 	case WE_PAINT: {
   751 		bool newstations = _railstation.newstations;
   787 		bool newstations = _railstation.newstations;
   752 		DrawPixelInfo tmp_dpi, *old_dpi;
   788 		DrawPixelInfo tmp_dpi, *old_dpi;
   753 		const StationSpec *statspec = newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
   789 		const StationSpec *statspec = newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
   754 
   790 
   755 		if (WP(w,def_d).close) return;
   791 		if (WP(w, def_d).close) return;
   756 
   792 
   757 		if (_railstation.dragdrop) {
   793 		if (_railstation.dragdrop) {
   758 			SetTileSelectSize(1, 1);
   794 			SetTileSelectSize(1, 1);
   759 		} else {
   795 		} else {
   760 			int x = _railstation.numtracks;
   796 			int x = _railstation.numtracks;
   993 		SndPlayFx(SND_15_BEEP);
  1029 		SndPlayFx(SND_15_BEEP);
   994 		SetWindowDirty(w);
  1030 		SetWindowDirty(w);
   995 		break;
  1031 		break;
   996 
  1032 
   997 	case WE_MOUSELOOP:
  1033 	case WE_MOUSELOOP:
   998 		if (WP(w,def_d).close) {
  1034 		if (WP(w, def_d).close) {
   999 			DeleteWindow(w);
  1035 			DeleteWindow(w);
  1000 			return;
  1036 			return;
  1001 		}
  1037 		}
  1002 		CheckRedrawStationCoverage(w);
  1038 		CheckRedrawStationCoverage(w);
  1003 		break;
  1039 		break;
  1004 
  1040 
  1005 	case WE_DESTROY:
  1041 	case WE_DESTROY:
  1006 		if (!WP(w,def_d).close) ResetObjectToPlace();
  1042 		if (!WP(w, def_d).close) ResetObjectToPlace();
  1007 		break;
  1043 		break;
  1008 	}
  1044 	}
  1009 }
  1045 }
  1010 
  1046 
  1011 /** Widget definition of the standard build rail station window */
  1047 /** Widget definition of the standard build rail station window */
  1103 
  1139 
  1104 		w->vscroll.count = _railstation.station_count;
  1140 		w->vscroll.count = _railstation.station_count;
  1105 		w->vscroll.cap   = 5;
  1141 		w->vscroll.cap   = 5;
  1106 		w->vscroll.pos   = Clamp(_railstation.station_type - 2, 0, w->vscroll.count - w->vscroll.cap);
  1142 		w->vscroll.pos   = Clamp(_railstation.station_type - 2, 0, w->vscroll.count - w->vscroll.cap);
  1107 	}
  1143 	}
       
  1144 }
       
  1145 
       
  1146 /** Enum referring to the widgets of the signal window */
       
  1147 enum BuildSignalWidgets {
       
  1148 	BSW_CLOSEBOX = 0,
       
  1149 	BSW_CAPTION,
       
  1150 	BSW_SEMAPHORE_NORM,
       
  1151 	BSW_SEMAPHORE_ENTRY,
       
  1152 	BSW_SEMAPHORE_EXIT,
       
  1153 	BSW_SEMAPHORE_COMBO,
       
  1154 	BSW_ELECTRIC_NORM,
       
  1155 	BSW_ELECTRIC_ENTRY,
       
  1156 	BSW_ELECTRIC_EXIT,
       
  1157 	BSW_ELECTRIC_COMBO,
       
  1158 	BSW_CONVERT,
       
  1159 	BSW_DRAG_SIGNALS_DENSITY,
       
  1160 	BSW_DRAG_SIGNALS_DENSITY_DECREASE,
       
  1161 	BSW_DRAG_SIGNALS_DENSITY_INCREASE,
       
  1162 };
       
  1163 
       
  1164 /**
       
  1165  * Draw dynamic a signal-sprite in a button in the signal GUI
       
  1166  * Draw the sprite +1px to the right and down if the button is lowered and change the sprite to sprite + 1 (red to green light)
       
  1167  *
       
  1168  * @param w            Window on which the widget is located
       
  1169  * @param widget_index index of this widget in the window
       
  1170  * @param image        the sprite to draw
       
  1171  * @param xrel         the relativ x value of the sprite in the grf
       
  1172  * @param xsize        the width of the sprite
       
  1173  */
       
  1174 static const void DrawSignalSprite(const Window *w, byte widget_index, SpriteID image, int8 xrel, uint8 xsize)
       
  1175 {
       
  1176 	DrawSprite(image + IsWindowWidgetLowered(w, widget_index), PAL_NONE,
       
  1177 			w->widget[widget_index].left + (w->widget[widget_index].right - w->widget[widget_index].left) / 2 - xrel - xsize / 2 +
       
  1178 			IsWindowWidgetLowered(w, widget_index), w->widget[widget_index].bottom - 3 + IsWindowWidgetLowered(w, widget_index));
       
  1179 }
       
  1180 
       
  1181 /**
       
  1182  * Signal selection window event definition
       
  1183  *
       
  1184  * @param w window pointer
       
  1185  * @param e event been triggered
       
  1186  */
       
  1187 static void SignalBuildWndProc(Window *w, WindowEvent *e)
       
  1188 {
       
  1189 	switch (e->event) {
       
  1190 		case WE_PAINT:
       
  1191 			LowerWindowWidget(w, (_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
       
  1192 
       
  1193 			SetWindowWidgetLoweredState(w, BSW_CONVERT, _convert_signal_button);
       
  1194 
       
  1195 			SetWindowWidgetDisabledState(w, BSW_DRAG_SIGNALS_DENSITY_DECREASE, _patches.drag_signals_density == 1);
       
  1196 			SetWindowWidgetDisabledState(w, BSW_DRAG_SIGNALS_DENSITY_INCREASE, _patches.drag_signals_density == 20);
       
  1197 
       
  1198 			DrawWindowWidgets(w);
       
  1199 
       
  1200 			/* The 'hardcoded' off sets are needed because they are reused sprites. */
       
  1201 			DrawSignalSprite(w, BSW_SEMAPHORE_NORM,  SPR_IMG_SIGNAL_SEMAPHORE_NORM,   0, 12); // xsize of sprite + 1 ==  9
       
  1202 			DrawSignalSprite(w, BSW_SEMAPHORE_ENTRY, SPR_IMG_SIGNAL_SEMAPHORE_ENTRY, -1, 13); // xsize of sprite + 1 == 10
       
  1203 			DrawSignalSprite(w, BSW_SEMAPHORE_EXIT,  SPR_IMG_SIGNAL_SEMAPHORE_EXIT,   0, 12); // xsize of sprite + 1 ==  9
       
  1204 			DrawSignalSprite(w, BSW_SEMAPHORE_COMBO, SPR_IMG_SIGNAL_SEMAPHORE_COMBO,  0, 12); // xsize of sprite + 1 ==  9
       
  1205 			DrawSignalSprite(w, BSW_ELECTRIC_NORM,   SPR_IMG_SIGNAL_ELECTRIC_NORM,   -1,  4);
       
  1206 			DrawSignalSprite(w, BSW_ELECTRIC_ENTRY,  SPR_IMG_SIGNAL_ELECTRIC_ENTRY,  -2,  6);
       
  1207 			DrawSignalSprite(w, BSW_ELECTRIC_EXIT,   SPR_IMG_SIGNAL_ELECTRIC_EXIT,   -2,  6);
       
  1208 			DrawSignalSprite(w, BSW_ELECTRIC_COMBO,  SPR_IMG_SIGNAL_ELECTRIC_COMBO,  -2,  6);
       
  1209 
       
  1210 			/* Draw dragging signal density value in the BSW_DRAG_SIGNALS_DENSITY widget */
       
  1211 			SetDParam(0, _patches.drag_signals_density);
       
  1212 			DrawStringCentered(w->widget[BSW_DRAG_SIGNALS_DENSITY].left + (w->widget[BSW_DRAG_SIGNALS_DENSITY].right -
       
  1213 					w->widget[BSW_DRAG_SIGNALS_DENSITY].left) / 2 + 1,
       
  1214 					w->widget[BSW_DRAG_SIGNALS_DENSITY].top + 2, STR_JUST_INT, TC_ORANGE);
       
  1215 			break;
       
  1216 
       
  1217 		case WE_CLICK:
       
  1218 			switch (e->we.click.widget) {
       
  1219 				case BSW_SEMAPHORE_NORM:
       
  1220 				case BSW_SEMAPHORE_ENTRY:
       
  1221 				case BSW_SEMAPHORE_EXIT:
       
  1222 				case BSW_SEMAPHORE_COMBO:
       
  1223 				case BSW_ELECTRIC_NORM:
       
  1224 				case BSW_ELECTRIC_ENTRY:
       
  1225 				case BSW_ELECTRIC_EXIT:
       
  1226 				case BSW_ELECTRIC_COMBO:
       
  1227 					RaiseWindowWidget(w, (_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
       
  1228 
       
  1229 					_cur_signal_type = (SignalType)((uint)((e->we.click.widget - BSW_SEMAPHORE_NORM) % (SIGTYPE_COMBO + 1)));
       
  1230 					_cur_signal_variant = e->we.click.widget >= BSW_ELECTRIC_NORM ? SIG_ELECTRIC : SIG_SEMAPHORE;
       
  1231 					break;
       
  1232 
       
  1233 				case BSW_CONVERT:
       
  1234 					_convert_signal_button = !_convert_signal_button;
       
  1235 					break;
       
  1236 
       
  1237 				case BSW_DRAG_SIGNALS_DENSITY_DECREASE:
       
  1238 					if (_patches.drag_signals_density > 1) _patches.drag_signals_density--;
       
  1239 					break;
       
  1240 
       
  1241 				case BSW_DRAG_SIGNALS_DENSITY_INCREASE:
       
  1242 					if (_patches.drag_signals_density < 20) _patches.drag_signals_density++;
       
  1243 					break;
       
  1244 
       
  1245 				default: break;
       
  1246 			}
       
  1247 
       
  1248 			SetWindowDirty(w);
       
  1249 			break;
       
  1250 
       
  1251 		case WE_MOUSELOOP:
       
  1252 			if (WP(w, def_d).close) DeleteWindow(w);
       
  1253 			return;
       
  1254 
       
  1255 		case WE_DESTROY:
       
  1256 			if (!WP(w, def_d).close) ResetObjectToPlace();
       
  1257 			break;
       
  1258 		}
       
  1259 }
       
  1260 
       
  1261 /** Widget definition of the build signal window */
       
  1262 static const Widget _signal_builder_widgets[] = {
       
  1263 {   WWT_CLOSEBOX,   RESIZE_NONE,  7,   0,  10,   0,  13, STR_00C5,               STR_018B_CLOSE_WINDOW},                 // BSW_CLOSEBOX
       
  1264 {    WWT_CAPTION,   RESIZE_NONE,  7,  11, 109,   0,  13, STR_SIGNAL_SELECTION,   STR_018C_WINDOW_TITLE_DRAG_THIS},       // BSW_CAPTION
       
  1265 
       
  1266 {      WWT_PANEL,   RESIZE_NONE,  7,   0,  21,  14,  40, STR_NULL,               STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP},   // BSW_SEMAPHORE_NORM
       
  1267 {      WWT_PANEL,   RESIZE_NONE,  7,  22,  43,  14,  40, STR_NULL,               STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP},  // BSW_SEMAPHORE_ENTRY
       
  1268 {      WWT_PANEL,   RESIZE_NONE,  7,  44,  65,  14,  40, STR_NULL,               STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP},   // BSW_SEMAPHORE_EXIT
       
  1269 {      WWT_PANEL,   RESIZE_NONE,  7,  66,  87,  14,  40, STR_NULL,               STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP},  // BSW_SEMAPHORE_COMBO
       
  1270 
       
  1271 {      WWT_PANEL,   RESIZE_NONE,  7,   0,  21,  41,  67, STR_NULL,               STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP},    // BSW_ELECTRIC_NORM
       
  1272 {      WWT_PANEL,   RESIZE_NONE,  7,  22,  43,  41,  67, STR_NULL,               STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP},   // BSW_ELECTRIC_ENTRY
       
  1273 {      WWT_PANEL,   RESIZE_NONE,  7,  44,  65,  41,  67, STR_NULL,               STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP},    // BSW_ELECTRIC_EXIT
       
  1274 {      WWT_PANEL,   RESIZE_NONE,  7,  66,  87,  41,  67, STR_NULL,               STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP},   // BSW_ELECTRIC_COMBO
       
  1275 
       
  1276 {     WWT_IMGBTN,   RESIZE_NONE,  7,  88, 109,  14,  40, SPR_IMG_SIGNAL_CONVERT, STR_SIGNAL_CONVERT_TIP},                // BSW_CONVERT
       
  1277 {      WWT_PANEL,   RESIZE_NONE,  7,  88, 109,  41,  67, STR_NULL,               STR_DRAG_SIGNALS_DENSITY_TIP},          // BSW_DRAG_SIGNALS_DENSITY
       
  1278 { WWT_PUSHIMGBTN,   RESIZE_NONE, 14,  90,  98,  54,  65, SPR_ARROW_LEFT,         STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP}, // BSW_DRAG_SIGNALS_DENSITY_DECREASE
       
  1279 { WWT_PUSHIMGBTN,   RESIZE_NONE, 14,  99, 107,  54,  65, SPR_ARROW_RIGHT,        STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP}, // BSW_DRAG_SIGNALS_DENSITY_INCREASE
       
  1280 
       
  1281 {   WIDGETS_END},
       
  1282 };
       
  1283 
       
  1284 /** Signal selection window description */
       
  1285 static const WindowDesc _signal_builder_desc = {
       
  1286 	WDP_AUTO, WDP_AUTO, 110, 68, 110, 68,
       
  1287 	WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR,
       
  1288 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
       
  1289 	_signal_builder_widgets,
       
  1290 	SignalBuildWndProc
       
  1291 };
       
  1292 
       
  1293 /**
       
  1294  * Open the signal selection window
       
  1295  * @pre reset all signal GUI relevant variables
       
  1296  */
       
  1297 static void ShowSignalBuilder()
       
  1298 {
       
  1299 	_convert_signal_button = false;
       
  1300 	_cur_signal_variant = _cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC;
       
  1301 	_cur_signal_type = SIGTYPE_NORMAL;
       
  1302 
       
  1303 	AllocateWindowDesc(&_signal_builder_desc);
  1108 }
  1304 }
  1109 
  1305 
  1110 /** Enum referring to the widgets of the build rail depot window */
  1306 /** Enum referring to the widgets of the build rail depot window */
  1111 enum BuildRailDepotWidgets {
  1307 enum BuildRailDepotWidgets {
  1112 	BRDW_CLOSEBOX = 0,
  1308 	BRDW_CLOSEBOX = 0,
  1147 				break;
  1343 				break;
  1148 		}
  1344 		}
  1149 		break;
  1345 		break;
  1150 
  1346 
  1151 	case WE_MOUSELOOP:
  1347 	case WE_MOUSELOOP:
  1152 		if (WP(w,def_d).close) DeleteWindow(w);
  1348 		if (WP(w, def_d).close) DeleteWindow(w);
  1153 		return;
  1349 		return;
  1154 
  1350 
  1155 	case WE_DESTROY:
  1351 	case WE_DESTROY:
  1156 		if (!WP(w,def_d).close) ResetObjectToPlace();
  1352 		if (!WP(w, def_d).close) ResetObjectToPlace();
  1157 		break;
  1353 		break;
  1158 	}
  1354 	}
  1159 }
  1355 }
  1160 
  1356 
  1161 /** Widget definition of the build rail depot window */
  1357 /** Widget definition of the build rail depot window */
  1246 		}
  1442 		}
  1247 		break;
  1443 		break;
  1248 	}
  1444 	}
  1249 
  1445 
  1250 	case WE_MOUSELOOP:
  1446 	case WE_MOUSELOOP:
  1251 		if (WP(w,def_d).close) DeleteWindow(w);
  1447 		if (WP(w, def_d).close) DeleteWindow(w);
  1252 		break;
  1448 		break;
  1253 
  1449 
  1254 	case WE_DESTROY:
  1450 	case WE_DESTROY:
  1255 		if (!WP(w,def_d).close) ResetObjectToPlace();
  1451 		if (!WP(w, def_d).close) ResetObjectToPlace();
  1256 		break;
  1452 		break;
  1257 	}
  1453 	}
  1258 }
  1454 }
  1259 
  1455 
  1260 /** Widget definition for the build NewGRF rail waypoint window */
  1456 /** Widget definition for the build NewGRF rail waypoint window */