src/rail_gui.cpp
changeset 8808 6296dfa53f81
parent 8785 871586967963
child 8809 e0d09d74e805
equal deleted inserted replaced
8807:6552715058e3 8808:6296dfa53f81
    43 static RailType _cur_railtype;
    43 static RailType _cur_railtype;
    44 static bool _remove_button_clicked;
    44 static bool _remove_button_clicked;
    45 static DiagDirection _build_depot_direction;
    45 static DiagDirection _build_depot_direction;
    46 static byte _waypoint_count = 1;
    46 static byte _waypoint_count = 1;
    47 static byte _cur_waypoint_type;
    47 static byte _cur_waypoint_type;
    48 static bool _convert_signal_button; // convert signal button in the signal GUI pressed
    48 static bool _convert_signal_button = false;              ///< convert signal button in the signal GUI pressed
    49 static SignalVariant _cur_signal_variant; // set the signal variant (for signal GUI)
    49 static SignalVariant _cur_signal_variant = SIG_ELECTRIC; ///< set the signal variant (for signal GUI)
    50 static SignalType _cur_signal_type; // set the signal type (for signal GUI)
    50 static SignalType _cur_signal_type = SIGTYPE_NORMAL;     ///< set the signal type (for signal GUI)
    51 
    51 
    52 static struct {
    52 static struct {
    53 	byte orientation;
    53 	byte orientation;
    54 	byte numtracks;
    54 	byte numtracks;
    55 	byte platlength;
    55 	byte platlength;
   203 
   203 
   204 	if (_remove_button_clicked) {
   204 	if (_remove_button_clicked) {
   205 		DoCommandP(tile, track, 0, CcPlaySound1E,
   205 		DoCommandP(tile, track, 0, CcPlaySound1E,
   206 			CMD_REMOVE_SIGNALS | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM));
   206 			CMD_REMOVE_SIGNALS | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM));
   207 	} else {
   207 	} else {
   208 		if (!_patches.enable_signal_gui) _cur_signal_variant = _cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC;
   208 		const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
   209 
   209 
   210 		/* various bitstuffed elements for CmdBuildSingleSignal() */
   210 		/* various bitstuffed elements for CmdBuildSingleSignal() */
   211 		uint32 p1 = track;
   211 		uint32 p1 = track;
   212 		SB(p1, 3, 1, _ctrl_pressed);
   212 
   213 		SB(p1, 4, 1, _cur_signal_variant);
   213 		if (w != NULL) {
   214 		SB(p1, 5, 2, _patches.enable_signal_gui ? _cur_signal_type : SIGTYPE_NORMAL);
   214 			/* signal GUI is used */
   215 		SB(p1, 7, 1, _convert_signal_button);
   215 			SB(p1, 3, 1, _ctrl_pressed);
       
   216 			SB(p1, 4, 1, _cur_signal_variant);
       
   217 			SB(p1, 5, 2, _cur_signal_type);
       
   218 			SB(p1, 7, 1, _convert_signal_button);
       
   219 		} else {
       
   220 			SB(p1, 3, 1, _ctrl_pressed);
       
   221 			SB(p1, 4, 1, (_cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
       
   222 			SB(p1, 5, 2, SIGTYPE_NORMAL);
       
   223 			SB(p1, 7, 1, 0);
       
   224 		}
   216 
   225 
   217 		DoCommandP(tile, p1, 0, CcPlaySound1E, CMD_BUILD_SIGNALS |
   226 		DoCommandP(tile, p1, 0, CcPlaySound1E, CMD_BUILD_SIGNALS |
   218 			CMD_MSG(_convert_signal_button ? STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_1010_CAN_T_BUILD_SIGNALS_HERE));
   227 			CMD_MSG((w != NULL && _convert_signal_button) ? STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_1010_CAN_T_BUILD_SIGNALS_HERE));
   219 	}
   228 	}
   220 }
   229 }
   221 
   230 
   222 static void PlaceRail_Bridge(TileIndex tile)
   231 static void PlaceRail_Bridge(TileIndex tile)
   223 {
   232 {
   362 }
   371 }
   363 
   372 
   364 /** The "build signal"-button proc from BuildRailToolbWndProc() (start ShowSignalBuilder() and/or HandleAutoSignalPlacement()) */
   373 /** The "build signal"-button proc from BuildRailToolbWndProc() (start ShowSignalBuilder() and/or HandleAutoSignalPlacement()) */
   365 static void BuildRailClick_AutoSignals(Window *w)
   374 static void BuildRailClick_AutoSignals(Window *w)
   366 {
   375 {
   367 	if (_patches.enable_signal_gui) {
   376 	if (_patches.enable_signal_gui != _ctrl_pressed) {
   368 		if (HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals)) ShowSignalBuilder();
   377 		if (HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals)) ShowSignalBuilder();
   369 	} else {
   378 	} else {
   370 		HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals);
   379 		HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals);
   371 	}
   380 	}
   372 }
   381 }
   452 	if (thd->drawstyle == HT_RECT) { // one tile case
   461 	if (thd->drawstyle == HT_RECT) { // one tile case
   453 		GenericPlaceSignals(TileVirtXY(thd->selend.x, thd->selend.y));
   462 		GenericPlaceSignals(TileVirtXY(thd->selend.x, thd->selend.y));
   454 		return;
   463 		return;
   455 	}
   464 	}
   456 
   465 
   457 	/* XXX Steal ctrl for autosignal function, until we get some GUI */
   466 	const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
   458 	SB(p2,  3, 1, 0);
   467 
   459 	SB(p2,  4, 1, _cur_year < _patches.semaphore_build_before);
   468 	if (w != NULL) {
   460 	SB(p2,  6, 1, _ctrl_pressed);
   469 		/* signal GUI is used */
   461 	SB(p2, 24, 8, _patches.drag_signals_density);
   470 		SB(p2,  3, 1, 0);
       
   471 		SB(p2,  4, 1, _cur_signal_variant);
       
   472 		SB(p2,  6, 1, _ctrl_pressed);
       
   473 		SB(p2, 24, 8, _patches.drag_signals_density);
       
   474 	} else {
       
   475 		SB(p2,  3, 1, 0);
       
   476 		SB(p2,  4, 1, (_cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
       
   477 		SB(p2,  6, 1, _ctrl_pressed);
       
   478 		SB(p2, 24, 8, _patches.drag_signals_density);
       
   479 	}
   462 
   480 
   463 	/* _patches.drag_signals_density is given as a parameter such that each user
   481 	/* _patches.drag_signals_density is given as a parameter such that each user
   464 	 * in a network game can specify his/her own signal density */
   482 	 * in a network game can specify his/her own signal density */
   465 	DoCommandP(
   483 	DoCommandP(
   466 		TileVirtXY(thd->selstart.x, thd->selstart.y),
   484 		TileVirtXY(thd->selstart.x, thd->selstart.y),