diff options
author | alberth <alberth@openttd.org> | 2015-07-28 18:18:59 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2015-07-28 18:18:59 +0000 |
commit | a62468bed666efa2cdae8e2a34f31c760ddaa40a (patch) | |
tree | b845b7d28160a913728f3ade705b5d2a8be4cdb1 | |
parent | 3cd390b2ce2c399492832dc598d9ac1314a20ca8 (diff) | |
download | openttd-a62468bed666efa2cdae8e2a34f31c760ddaa40a.tar.xz |
(svn r27345) -Fix-ish: Hide selected view if no object selected.
-rw-r--r-- | src/object_gui.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 25856c172..c31915d57 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -337,10 +337,7 @@ public: _selected_object_view = 0; } - this->GetWidget<NWidgetMatrix>(WID_BO_OBJECT_MATRIX)->SetClicked(_selected_object_view); - this->GetWidget<NWidgetMatrix>(WID_BO_SELECT_MATRIX)->SetClicked(_selected_object_index != -1 ? ObjectClass::Get(_selected_object_class)->GetUIFromIndex(_selected_object_index) : -1); - this->UpdateSelectSize(); - this->SetDirty(); + this->UpdateButtons(_selected_object_class, _selected_object_index, _selected_object_view); } void UpdateSelectSize() @@ -355,6 +352,29 @@ public: } } + /** + * Update buttons to show the selection to the user. + * @param sel_class The class of the selected object. + * @param sel_index Index of the object to select, or \c -1 . + * @param sel_view View of the object to select. + */ + void UpdateButtons(ObjectClassID sel_class, int sel_index, uint sel_view) + { + int view_number, object_number; + if (sel_index == -1) { + view_number = -1; // If no object selected, also hide the selected view. + object_number = -1; + } else { + view_number = sel_view; + object_number = ObjectClass::Get(sel_class)->GetUIFromIndex(sel_index); + } + + this->GetWidget<NWidgetMatrix>(WID_BO_OBJECT_MATRIX)->SetClicked(view_number); + this->GetWidget<NWidgetMatrix>(WID_BO_SELECT_MATRIX)->SetClicked(object_number); + this->UpdateSelectSize(); + this->SetDirty(); + } + virtual void OnResize() { this->vscroll->SetCapacityFromWidget(this, WID_BO_CLASS_LIST); |