Esempio n. 1
0
	BuildObjectWindow(const WindowDesc *desc, Window *w) : PickerWindowBase(w), info_height(1)
	{
		this->CreateNestedTree(desc);

		this->vscroll = this->GetScrollbar(WID_BO_SCROLLBAR);
		this->vscroll->SetCapacity(5);
		this->vscroll->SetPosition(0);
		this->vscroll->SetCount(ObjectClass::GetUIClassCount());

		this->FinishInitNested(desc, 0);

		this->SelectFirstAvailableObject(true);
		assert(ObjectClass::Get(_selected_object_class)->GetUISpecCount() > 0); // object GUI should be disables elsewise
		this->GetWidget<NWidgetMatrix>(WID_BO_OBJECT_MATRIX)->SetCount(4);

		NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BO_SELECT_MATRIX);
		matrix->SetScrollbar(this->GetScrollbar(WID_BO_SELECT_SCROLL));
		matrix->SetCount(ObjectClass::Get(_selected_object_class)->GetUISpecCount());
	}
Esempio n. 2
0
	BuildObjectWindow(WindowDesc *desc, WindowNumber number) : Window(desc), info_height(1)
	{
		this->CreateNestedTree();
		this->vscroll = this->GetScrollbar(WID_BO_SCROLLBAR);
		this->FinishInitNested(number);

		ResetObjectToPlace();

		this->vscroll->SetPosition(0);
		this->vscroll->SetCount(ObjectClass::GetUIClassCount());

		NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BO_SELECT_MATRIX);
		matrix->SetScrollbar(this->GetScrollbar(WID_BO_SELECT_SCROLL));

		this->SelectOtherClass(_selected_object_class);
		if (this->CanRestoreSelectedObject()) {
			this->SelectOtherObject(_selected_object_index);
		} else {
			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);
	}