Disable new template refit button when no train.

This commit is contained in:
Jonathan G Rennison
2016-02-14 12:40:56 +00:00
parent a92268a25c
commit 2258fdac3f

View File

@@ -165,6 +165,8 @@ public:
} }
this->resize.step_height = 1; this->resize.step_height = 1;
UpdateButtonState();
} }
~TemplateCreateWindow() ~TemplateCreateWindow()
@@ -188,6 +190,7 @@ public:
} }
virtual_train = train; virtual_train = train;
UpdateButtonState();
} }
virtual void OnResize() virtual void OnResize()
@@ -203,6 +206,7 @@ public:
virtual void OnInvalidateData(int data = 0, bool gui_scope = true) virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{ {
virtualTrainChangedNotice = true; virtualTrainChangedNotice = true;
UpdateButtonState();
} }
virtual void OnClick(Point pt, int widget, int click_count) virtual void OnClick(Point pt, int widget, int click_count)
@@ -326,6 +330,7 @@ public:
if (virtualTrainChangedNotice) { if (virtualTrainChangedNotice) {
this->SetDirty(); this->SetDirty();
virtualTrainChangedNotice = false; virtualTrainChangedNotice = false;
UpdateButtonState();
} }
} }
@@ -367,6 +372,7 @@ public:
this->sel = INVALID_VEHICLE; this->sel = INVALID_VEHICLE;
this->SetDirty(); this->SetDirty();
UpdateButtonState();
break; break;
} }
default: default:
@@ -527,6 +533,12 @@ public:
{ {
virtual_train = virtual_train->First(); virtual_train = virtual_train->First();
} }
void UpdateButtonState()
{
this->SetWidgetDisabledState(TCW_REFIT, virtual_train == NULL);
}
}; };
void ShowTemplateCreateWindow(TemplateVehicle *to_edit, bool *noticeParent, bool *createWindowOpen, int step_h) void ShowTemplateCreateWindow(TemplateVehicle *to_edit, bool *noticeParent, bool *createWindowOpen, int step_h)