FS#6599 - Can still click on buy button in vehicle selection window even if no vehicle is selected

Attached to Project: OpenTTD
Opened by James (james1101) - Thursday, 10 August 2017, 20:40 GMT
Last edited by andythenorth (andythenorth) - Friday, 01 September 2017, 10:09 GMT
Type Bug
Category Core
Status With patch
Assigned To No-one
Operating System Windows
Severity Medium
Priority Normal
Reported Version 1.7.1
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No


To Reproduce:
1. Open a depot window and click the 'New Vehicles' button.
2. Deselect the vehicle by doing the following:
3. Select a vehicle. (Example: a locomotive without any capacity)
4. Filter the list such that the selected vehicle disappears. (Example: Show only vehicles that can carry <cargo name>.)
5. Click the 'Buy Vehicle' button in the vehicle selection window.
-> Nothing happens. The button is not greyed out, but it does nothing. Please fix this.
This task depends upon

Comment by andythenorth (andythenorth) - Saturday, 12 August 2017, 15:00 GMT
Confirmed - can reproduce this using steps described.
Comment by Grzegorz Duczyński (adf88) - Saturday, 19 August 2017, 10:13 GMT
I have something for this, and more.

Fixes the issue (disables/enables the button when needed).

Enable auto-selecting first available engine also in train lists (currently, when the selected train is being filtered out, nothing gets selected). Also remove some duplicated code.

Remove duplicated code and use GUIList class for sorting engine lists.

Remove duplicated code and use GUIList class for filtering engine lists.

Remove useless caching of "list-view mode" in BuildVehicleWindow class.

Remove useless caching of cargoes and cargo names in BuildVehicleWindow class.
Comment by Grzegorz Duczyński (adf88) - Saturday, 19 August 2017, 12:42 GMT
Sorry, a mistake got in. I'm uploading a fixed patch #3. Now I tried harder at testing ;)