From 2258fdac3ff5f8daf0a7b4a74eb69bf7929ca34f Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sun, 14 Feb 2016 12:40:56 +0000 Subject: [PATCH] Disable new template refit button when no train. --- src/tbtr_template_gui_create.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/tbtr_template_gui_create.cpp b/src/tbtr_template_gui_create.cpp index 79f8a808af..9e4cce687b 100644 --- a/src/tbtr_template_gui_create.cpp +++ b/src/tbtr_template_gui_create.cpp @@ -165,6 +165,8 @@ public: } this->resize.step_height = 1; + + UpdateButtonState(); } ~TemplateCreateWindow() @@ -188,6 +190,7 @@ public: } virtual_train = train; + UpdateButtonState(); } virtual void OnResize() @@ -203,6 +206,7 @@ public: virtual void OnInvalidateData(int data = 0, bool gui_scope = true) { virtualTrainChangedNotice = true; + UpdateButtonState(); } virtual void OnClick(Point pt, int widget, int click_count) @@ -326,6 +330,7 @@ public: if (virtualTrainChangedNotice) { this->SetDirty(); virtualTrainChangedNotice = false; + UpdateButtonState(); } } @@ -367,6 +372,7 @@ public: this->sel = INVALID_VEHICLE; this->SetDirty(); + UpdateButtonState(); break; } default: @@ -527,6 +533,12 @@ public: { 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)