Changeset - r15074:dbc845b6aa54
[Not reviewed]
master
0 3 0
smatz - 14 years ago 2010-04-24 14:29:30
smatz@openttd.org
(svn r19710) -Codechange: deduplicate GUI code for starting/stopping vehicles
3 files changed with 15 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/depot_gui.cpp
Show inline comments
 
@@ -508,18 +508,9 @@ struct DepotWindow : Window {
 
				ShowVehicleViewWindow(v);
 
				break;
 

	
 
			case MODE_START_STOP: { // click start/stop flag
 
				uint command;
 

	
 
				switch (this->type) {
 
					case VEH_TRAIN:    command = CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_TRAIN);        break;
 
					case VEH_ROAD:     command = CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_ROAD_VEHICLE); break;
 
					case VEH_SHIP:     command = CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_SHIP);         break;
 
					case VEH_AIRCRAFT: command = CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_AIRCRAFT);     break;
 
					default: NOT_REACHED();
 
				}
 
				DoCommandP(v->tile, v->index, 0, command);
 
			} break;
 
			case MODE_START_STOP: // click start/stop flag
 
				StartStopVehicle(v);
 
				break;
 

	
 
			default: NOT_REACHED();
 
		}
src/vehicle_gui.cpp
Show inline comments
 
@@ -1868,6 +1868,16 @@ static const uint32 _vehicle_command_tra
 
	},
 
};
 

	
 
/**
 
 * Executes #CMD_START_STOP_VEHICLE for given vehicle.
 
 * @param v Vehicle to start/stop
 
 */
 
void StartStopVehicle(const Vehicle *v)
 
{
 
	assert(v->IsPrimaryVehicle());
 
	DoCommandP(v->tile, v->index, 0, _vehicle_command_translation_table[VCT_CMD_START_STOP][v->type]);
 
}
 

	
 
/** Checks whether the vehicle may be refitted at the moment.*/
 
static bool IsVehicleRefitable(const Vehicle *v)
 
{
 
@@ -2119,8 +2129,7 @@ public:
 
					if (tile != INVALID_TILE) ScrollMainWindowToTile(tile);
 
				} else {
 
					/* Start/Stop */
 
					DoCommandP(v->tile, v->index, 0,
 
						_vehicle_command_translation_table[VCT_CMD_START_STOP][v->type]);
 
					StartStopVehicle(v);
 
				}
 
				break;
 
			case VVW_WIDGET_CENTER_MAIN_VIEH: {// center main view
src/vehicle_gui.h
Show inline comments
 
@@ -108,6 +108,7 @@ static inline WindowClass GetWindowClass
 

	
 
/* Unified window procedure */
 
void ShowVehicleViewWindow(const Vehicle *v);
 
void StartStopVehicle(const Vehicle *v);
 

	
 
Vehicle *CheckClickOnVehicle(const struct ViewPort *vp, int x, int y);
 

	
0 comments (0 inline, 0 general)