diff options
author | alberth <alberth@openttd.org> | 2013-05-24 19:08:35 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2013-05-24 19:08:35 +0000 |
commit | ca5b64a433dc552eb80c4396aa09b18466bfb435 (patch) | |
tree | 1be226aa79ab37636bf7895ea167092bdf557a25 | |
parent | 5a420d843516261e34e2a78d81960922f9459a85 (diff) | |
download | openttd-ca5b64a433dc552eb80c4396aa09b18466bfb435.tar.xz |
(svn r25281) -Add: When opening the object-build window, make the last selected class visible in the class selector (sbr).
-rw-r--r-- | src/object_gui.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 2938e3b5b..35c395891 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -33,6 +33,17 @@ class BuildObjectWindow : public PickerWindowBase { int info_height; ///< The height of the info box. Scrollbar *vscroll; ///< The scrollbar. + /** Scroll #WID_BO_CLASS_LIST so that the selected object class is visible. */ + void EnsureSelectedObjectClassIsVisible() + { + uint pos = 0; + for (int i = 0; i < _selected_object_class; i++) { + if (ObjectClass::Get((ObjectClassID) i)->GetUISpecCount() == 0) continue; + pos++; + } + this->vscroll->ScrollTowards(pos); + } + public: BuildObjectWindow(const WindowDesc *desc, Window *w) : PickerWindowBase(w), info_height(1) { @@ -47,6 +58,7 @@ public: this->SelectFirstAvailableObject(true); assert(ObjectClass::Get(_selected_object_class)->GetUISpecCount() > 0); // object GUI should be disables elsewise + this->EnsureSelectedObjectClassIsVisible(); this->GetWidget<NWidgetMatrix>(WID_BO_OBJECT_MATRIX)->SetCount(4); NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BO_SELECT_MATRIX); |