Ejemplo n.º 1
0
/**
 * This is the Callback method after the cloning attempt of a vehicle
 * @param success indicates completion (or not) of the operation
 * @param tile unused
 * @param p1 unused
 * @param p2 unused
 */
void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
	if (!success) return;

	const Vehicle *v = Vehicle::Get(_new_vehicle_id);

	ShowVehicleViewWindow(v);
}
Ejemplo n.º 2
0
/**
 * This is the Callback method after the cloning attempt of a vehicle
 * @param result the result of the cloning command
 * @param tile unused
 * @param p1 unused
 * @param p2 unused
 */
void CcCloneVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
	if (result.Failed()) return;

	const Vehicle *v = Vehicle::Get(_new_vehicle_id);

	ShowVehicleViewWindow(v);
}
Ejemplo n.º 3
0
void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
	if (!success) return;

	const Vehicle *v = Vehicle::Get(_new_vehicle_id);
	if (tile == _backup_orders_tile) {
		_backup_orders_tile = 0;
		RestoreVehicleOrders(v);
	}
	ShowVehicleViewWindow(v);
}
Ejemplo n.º 4
0
	virtual void OnClick(Point pt, int widget, int click_count)
	{
		switch (widget) {
			case WID_N_CLOSEBOX:
				NewsWindow::duration = 0;
				delete this;
				_forced_news = NULL;
				break;

			case WID_N_CAPTION:
				if (this->ni->reftype1 == NR_VEHICLE) {
					const Vehicle *v = Vehicle::Get(this->ni->ref1);
					ShowVehicleViewWindow(v);
				}
				break;

			case WID_N_VIEWPORT:
				break; // Ignore clicks

			default:
				if (this->ni->reftype1 == NR_VEHICLE) {
					const Vehicle *v = Vehicle::Get(this->ni->ref1);
					ScrollMainWindowTo(v->x_pos, v->y_pos, v->z_pos);
				} else {
					TileIndex tile1 = GetReferenceTile(this->ni->reftype1, this->ni->ref1);
					TileIndex tile2 = GetReferenceTile(this->ni->reftype2, this->ni->ref2);
					if (_ctrl_pressed) {
						if (tile1 != INVALID_TILE) ShowExtraViewPortWindow(tile1);
						if (tile2 != INVALID_TILE) ShowExtraViewPortWindow(tile2);
					} else {
						if ((tile1 == INVALID_TILE || !ScrollMainWindowToTile(tile1)) && tile2 != INVALID_TILE) {
							ScrollMainWindowToTile(tile2);
						}
					}
				}
				break;
		}
	}
Ejemplo n.º 5
0
	virtual void OnClick(Point pt, int widget, int click_count)
	{
		switch (widget) {
			case WID_DB_SHOW_TRAINS:   // Show trains to this station
			case WID_DB_SHOW_ROADVEHS: // Show road vehicles to this station
			case WID_DB_SHOW_SHIPS:    // Show ships to this station
			case WID_DB_SHOW_PLANES:   // Show aircraft to this station
				this->show_types[widget - WID_DB_SHOW_TRAINS] = !this->show_types[widget - WID_DB_SHOW_TRAINS];
				if (this->show_types[widget - WID_DB_SHOW_TRAINS]) {
					this->LowerWidget(widget);
				} else {
					this->RaiseWidget(widget);
				}
				/* We need to recompute the departures list. */
				this->calc_tick_countdown = 0;
				/* We need to redraw the button that was pressed. */
				this->SetWidgetDirty(widget);
				break;

			case WID_DB_SHOW_DEPS:
			case WID_DB_SHOW_ARRS:
				if (_settings_client.gui.departure_show_both) break;
				/* FALL THROUGH */

			case WID_DB_SHOW_VIA:

				this->departure_types[widget - WID_DB_SHOW_DEPS] = !this->departure_types[widget - WID_DB_SHOW_DEPS];
				if (this->departure_types[widget - WID_DB_SHOW_DEPS]) {
					this->LowerWidget(widget);
				} else {
					this->RaiseWidget(widget);
				}

				if (!this->departure_types[0]) {
					this->RaiseWidget(WID_DB_SHOW_VIA);
					this->DisableWidget(WID_DB_SHOW_VIA);
				} else {
					this->EnableWidget(WID_DB_SHOW_VIA);

					if (this->departure_types[2]) {
						this->LowerWidget(WID_DB_SHOW_VIA);
					}
				}
				/* We need to recompute the departures list. */
				this->calc_tick_countdown = 0;
				/* We need to redraw the button that was pressed. */
				this->SetWidgetDirty(widget);
				break;

			case WID_DB_LIST:   // Matrix to show departures
				/* We need to find the departure corresponding to where the user clicked. */
				uint32 id_v = (pt.y - this->GetWidget<NWidgetBase>(WID_DB_LIST)->pos_y) / this->entry_height;

				if (id_v >= this->vscroll->GetCapacity()) return; // click out of bounds

				id_v += this->vscroll->GetPosition();

				if (id_v >= (this->departures->Length() + this->arrivals->Length())) return; // click out of list bound

				uint departure = 0;
				uint arrival = 0;

				/* Draw each departure. */
				for (uint i = 0; i <= id_v; ++i) {
					const Departure *d;

					if (arrival == this->arrivals->Length()) {
						d = (*(this->departures))[departure++];
					} else if (departure == this->departures->Length()) {
						d = (*(this->arrivals))[arrival++];
					} else {
						d = (*(this->departures))[departure];
						const Departure *a = (*(this->arrivals))[arrival];

						if (a->scheduled_date < d->scheduled_date) {
							d = a;
							arrival++;
						} else {
							departure++;
						}
					}

					if (i == id_v) {
						ShowVehicleViewWindow(d->vehicle);
						break;
					}
				}

				break;
		}
	}