mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
(svn r21559) -Add: Disable the refit button until a refit option is selected.
This commit is contained in:
parent
3de89fd3f9
commit
080a52faf2
@ -466,6 +466,7 @@ struct RefitWindow : public Window {
|
|||||||
|
|
||||||
RefitWindow(const WindowDesc *desc, const Vehicle *v, VehicleOrderID order) : Window()
|
RefitWindow(const WindowDesc *desc, const Vehicle *v, VehicleOrderID order) : Window()
|
||||||
{
|
{
|
||||||
|
this->sel = -1;
|
||||||
this->CreateNestedTree(desc);
|
this->CreateNestedTree(desc);
|
||||||
|
|
||||||
this->vscroll = this->GetScrollbar(VRW_SCROLLBAR);
|
this->vscroll = this->GetScrollbar(VRW_SCROLLBAR);
|
||||||
@ -479,7 +480,7 @@ struct RefitWindow : public Window {
|
|||||||
this->owner = v->owner;
|
this->owner = v->owner;
|
||||||
|
|
||||||
this->order = order;
|
this->order = order;
|
||||||
this->sel = -1;
|
this->SetWidgetDisabledState(VRW_REFITBUTTON, this->sel == -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnInit()
|
virtual void OnInit()
|
||||||
@ -505,6 +506,7 @@ struct RefitWindow : public Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->SetWidgetDisabledState(VRW_REFITBUTTON, this->sel == -1);
|
||||||
/* If the selected refit option was not found, scroll the window to the initial position. */
|
/* If the selected refit option was not found, scroll the window to the initial position. */
|
||||||
if (this->sel == -1) this->vscroll->ScrollTowards(0);
|
if (this->sel == -1) this->vscroll->ScrollTowards(0);
|
||||||
} else {
|
} else {
|
||||||
@ -614,6 +616,8 @@ struct RefitWindow : public Window {
|
|||||||
switch (widget) {
|
switch (widget) {
|
||||||
case VRW_MATRIX: { // listbox
|
case VRW_MATRIX: { // listbox
|
||||||
this->sel = this->vscroll->GetScrolledRowFromWidget(pt.y, this, VRW_MATRIX);
|
this->sel = this->vscroll->GetScrolledRowFromWidget(pt.y, this, VRW_MATRIX);
|
||||||
|
if (this->sel == INT_MAX) this->sel = -1;
|
||||||
|
this->SetWidgetDisabledState(VRW_REFITBUTTON, this->sel == -1);
|
||||||
this->InvalidateData(1);
|
this->InvalidateData(1);
|
||||||
|
|
||||||
if (click_count == 1) break;
|
if (click_count == 1) break;
|
||||||
|
Loading…
Reference in New Issue
Block a user