# HG changeset patch # User sbr # Date 1370378787 -7200 # Branch fs5567_02 # Node ID ce6908dcd23360516156f41e807eaa01e541d5d4 # Parent 5874f43c93969aa6acdfe016e708492e5b555c9f # Parent 85426bc218f813b4451a61c24b946c8b756369a6 -Change: init the object matrix before selecting the object to display. SelectOtherObject() do a call to SetClicked() on the object matrix that is ignored if the matrix isn't initialized. Instead of recalling SetClicked() at the end of the constructor, the matrix is first initialized before trying to restore the previously selected object. diff --git a/src/object_gui.cpp b/src/object_gui.cpp --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -83,6 +83,10 @@ this->FinishInitNested(0); + NWidgetMatrix *matrix = this->GetWidget(WID_BO_SELECT_MATRIX); + matrix->SetScrollbar(this->GetScrollbar(WID_BO_SELECT_SCROLL)); + matrix->SetCount(ObjectClass::Get(_selected_object_class)->GetUISpecCount()); + if (this->CanRestoreSelectedObject()) { this->SelectOtherObject(_selected_object_index); } else { @@ -92,10 +96,6 @@ this->EnsureSelectedObjectClassIsVisible(); this->GetWidget(WID_BO_OBJECT_MATRIX)->SetCount(4); - NWidgetMatrix *matrix = this->GetWidget(WID_BO_SELECT_MATRIX); - matrix->SetScrollbar(this->GetScrollbar(WID_BO_SELECT_SCROLL)); - matrix->SetCount(ObjectClass::Get(_selected_object_class)->GetUISpecCount()); - /* If needed restore the window previous size with the stored values.*/ uint default_num_cols = this->GetMatrixColumnCount(); uint default_num_rows = this->vscroll->GetCapacity(); @@ -108,8 +108,6 @@ * matrix columns are visible. */ this->FindWindowPlacementAndResize(this->width, this->height); } - - if (_selected_object_index != -1) matrix->SetClicked(ObjectClass::Get(_selected_object_class)->GetUIFromIndex(_selected_object_index)); } virtual ~BuildObjectWindow() @@ -427,6 +425,7 @@ const ObjectSpec *spec = objclass->GetSpec(i); if (spec->IsAvailable()) { _selected_object_class = j; + this->GetWidget(WID_BO_SELECT_MATRIX)->SetCount(ObjectClass::Get(_selected_object_class)->GetUISpecCount()); this->SelectOtherObject(i); return; }