Changeset - r24318:80ad08d131d8
[Not reviewed]
master
0 1 0
Abdurrahmaan Iqbal - 4 years ago 2020-06-23 19:50:41
abdurrahmaaniqbal@hotmail.com
Fix #7772: Show destination on mouseover when vehicle stopped (and not in depot)
1 file changed with 11 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/vehicle_gui.cpp
Show inline comments
 
@@ -2421,24 +2421,25 @@ struct VehicleViewWindow : Window {
 
private:
 
	/** Display planes available in the vehicle view window. */
 
	enum PlaneSelections {
 
		SEL_DC_GOTO_DEPOT,  ///< Display 'goto depot' button in #WID_VV_SELECT_DEPOT_CLONE stacked widget.
 
		SEL_DC_CLONE,       ///< Display 'clone vehicle' button in #WID_VV_SELECT_DEPOT_CLONE stacked widget.
 

	
 
		SEL_RT_REFIT,       ///< Display 'refit' button in #WID_VV_SELECT_REFIT_TURN stacked widget.
 
		SEL_RT_TURN_AROUND, ///< Display 'turn around' button in #WID_VV_SELECT_REFIT_TURN stacked widget.
 

	
 
		SEL_DC_BASEPLANE = SEL_DC_GOTO_DEPOT, ///< First plane of the #WID_VV_SELECT_DEPOT_CLONE stacked widget.
 
		SEL_RT_BASEPLANE = SEL_RT_REFIT,      ///< First plane of the #WID_VV_SELECT_REFIT_TURN stacked widget.
 
	};
 
	bool mouse_over_start_stop = false;
 

	
 
	/**
 
	 * Display a plane in the window.
 
	 * @param plane Plane to show.
 
	 */
 
	void SelectPlane(PlaneSelections plane)
 
	{
 
		switch (plane) {
 
			case SEL_DC_GOTO_DEPOT:
 
			case SEL_DC_CLONE:
 
				this->GetWidget<NWidgetStacked>(WID_VV_SELECT_DEPOT_CLONE)->SetDisplayedPlane(plane - SEL_DC_BASEPLANE);
 
				break;
 
@@ -2566,25 +2567,25 @@ public:
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		if (widget != WID_VV_START_STOP) return;
 

	
 
		const Vehicle *v = Vehicle::Get(this->window_number);
 
		StringID str;
 
		if (v->vehstatus & VS_CRASHED) {
 
			str = STR_VEHICLE_STATUS_CRASHED;
 
		} else if (v->type != VEH_AIRCRAFT && v->breakdown_ctr == 1) { // check for aircraft necessary?
 
			str = STR_VEHICLE_STATUS_BROKEN_DOWN;
 
		} else if (v->vehstatus & VS_STOPPED) {
 
		} else if (v->vehstatus & VS_STOPPED && (!mouse_over_start_stop || v->IsStoppedInDepot())) {
 
			if (v->type == VEH_TRAIN) {
 
				if (v->cur_speed == 0) {
 
					if (Train::From(v)->gcache.cached_power == 0) {
 
						str = STR_VEHICLE_STATUS_TRAIN_NO_POWER;
 
					} else {
 
						str = STR_VEHICLE_STATUS_STOPPED;
 
					}
 
				} else {
 
					SetDParam(0, v->GetDisplaySpeed());
 
					str = STR_VEHICLE_STATUS_TRAIN_STOPPING_VEL;
 
				}
 
			} else { // no train
 
@@ -2722,24 +2723,33 @@ public:
 
			case WID_VV_TURN_AROUND: // turn around
 
				assert(v->IsGroundVehicle());
 
				DoCommandP(v->tile, v->index, 0,
 
										_vehicle_command_translation_table[VCT_CMD_TURN_AROUND][v->type]);
 
				break;
 
			case WID_VV_FORCE_PROCEED: // force proceed
 
				assert(v->type == VEH_TRAIN);
 
				DoCommandP(v->tile, v->index, 0, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_ERROR_CAN_T_MAKE_TRAIN_PASS_SIGNAL));
 
				break;
 
		}
 
	}
 

	
 
	void OnMouseOver(Point pt, int widget) override
 
	{
 
		bool start_stop = widget == WID_VV_START_STOP;
 
		if (start_stop != mouse_over_start_stop) {
 
			mouse_over_start_stop = start_stop;
 
			this->SetWidgetDirty(WID_VV_START_STOP);
 
		}
 
	}
 

	
 
	void OnResize() override
 
	{
 
		if (this->viewport != nullptr) {
 
			NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_VV_VIEWPORT);
 
			nvp->UpdateViewportCoordinates(this);
 
		}
 
	}
 

	
 
	void UpdateButtonStatus()
 
	{
 
		const Vehicle *v = Vehicle::Get(this->window_number);
 
		bool veh_stopped = v->IsStoppedInDepot();
0 comments (0 inline, 0 general)