mirror of https://github.com/OpenTTD/OpenTTD
Change: Invalidate build toolbars when NewGRFs are changed.
If NewGRFs are changed while a rail or road toolbar is open, the toolbar could refer to an invalid rail/road type. If so, close it.pull/13048/head
parent
6d2b93d3b3
commit
db1a1c5dd9
|
@ -468,6 +468,12 @@ struct BuildRailToolbarWindow : Window {
|
||||||
{
|
{
|
||||||
if (!gui_scope) return;
|
if (!gui_scope) return;
|
||||||
|
|
||||||
|
if (!ValParamRailType(this->railtype)) {
|
||||||
|
/* Close toolbar if rail type is not available. */
|
||||||
|
this->Close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool can_build = CanBuildVehicleInfrastructure(VEH_TRAIN);
|
bool can_build = CanBuildVehicleInfrastructure(VEH_TRAIN);
|
||||||
for (const WidgetID widget : can_build_widgets) this->SetWidgetDisabledState(widget, !can_build);
|
for (const WidgetID widget : can_build_widgets) this->SetWidgetDisabledState(widget, !can_build);
|
||||||
if (!can_build) {
|
if (!can_build) {
|
||||||
|
|
|
@ -377,6 +377,13 @@ struct BuildRoadToolbarWindow : Window {
|
||||||
void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
|
void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
|
||||||
{
|
{
|
||||||
if (!gui_scope) return;
|
if (!gui_scope) return;
|
||||||
|
|
||||||
|
if (!ValParamRoadType(this->roadtype)) {
|
||||||
|
/* Close toolbar if road type is not available. */
|
||||||
|
this->Close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
RoadTramType rtt = GetRoadTramType(this->roadtype);
|
RoadTramType rtt = GetRoadTramType(this->roadtype);
|
||||||
|
|
||||||
bool can_build = CanBuildVehicleInfrastructure(VEH_ROAD, rtt);
|
bool can_build = CanBuildVehicleInfrastructure(VEH_ROAD, rtt);
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "../safeguards.h"
|
#include "../safeguards.h"
|
||||||
|
#include "window_func.h"
|
||||||
|
|
||||||
extern Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY);
|
extern Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY);
|
||||||
|
|
||||||
|
@ -3377,6 +3378,7 @@ void ReloadNewGRFData()
|
||||||
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) InvalidateWindowData(WC_COMPANY_COLOUR, i);
|
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) InvalidateWindowData(WC_COMPANY_COLOUR, i);
|
||||||
/* Update company infrastructure counts. */
|
/* Update company infrastructure counts. */
|
||||||
InvalidateWindowClassesData(WC_COMPANY_INFRASTRUCTURE);
|
InvalidateWindowClassesData(WC_COMPANY_INFRASTRUCTURE);
|
||||||
|
InvalidateWindowClassesData(WC_BUILD_TOOLBAR);
|
||||||
/* redraw the whole screen */
|
/* redraw the whole screen */
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
CheckTrainsLengths();
|
CheckTrainsLengths();
|
||||||
|
|
Loading…
Reference in New Issue