Fix engine selection from click in new train purchase window

See: #287, #296, #297
This commit is contained in:
Jonathan G Rennison
2021-07-09 18:13:29 +01:00
parent f9bb004b05
commit 0d80b4450d

View File

@@ -2274,7 +2274,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase {
case WID_BV_LIST_LOCO: { case WID_BV_LIST_LOCO: {
const uint i = this->loco.vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BV_LIST_LOCO); const uint i = this->loco.vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BV_LIST_LOCO);
const size_t num_items = this->loco.eng_list.size(); const size_t num_items = this->loco.eng_list.size();
this->loco.sel_engine = (i < num_items) ? this->loco.eng_list[i] : INVALID_ENGINE; this->SelectEngine(this->loco, (i < num_items) ? this->loco.eng_list[i] : INVALID_ENGINE);
this->SetDirty(); this->SetDirty();
if (_ctrl_pressed) { if (_ctrl_pressed) {
@@ -2341,7 +2341,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase {
case WID_BV_LIST_WAGON: { case WID_BV_LIST_WAGON: {
const uint i = this->wagon.vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BV_LIST_WAGON); const uint i = this->wagon.vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BV_LIST_WAGON);
const size_t num_items = this->wagon.eng_list.size(); const size_t num_items = this->wagon.eng_list.size();
this->wagon.sel_engine = (i < num_items) ? this->wagon.eng_list[i] : INVALID_ENGINE; this->SelectEngine(this->wagon, (i < num_items) ? this->wagon.eng_list[i] : INVALID_ENGINE);
this->SetDirty(); this->SetDirty();
if (_ctrl_pressed) { if (_ctrl_pressed) {