Esempio n. 1
0
void BaseStage::begin()
{
	changeBase();

	textFunds = form->findControlTyped<Label>("TEXT_FUNDS");
	textFunds->setText(state->getPlayerBalance());

	int b = 0;
	for (auto &pair : state->player_bases)
	{
		auto &viewBase = pair.second;
		auto viewName = format("BUTTON_BASE_%d", ++b);
		auto view = form->findControlTyped<GraphicButton>(viewName);
		if (!view)
		{
			// This screen doesn't have miniviews
			return;
		}
		if (state->current_base == viewBase)
		{
			currentView = view;
		}
		view->setData(viewBase);
		auto viewImage = drawMiniBase(viewBase, viewHighlight, viewFacility);
		view->setImage(viewImage);
		view->setDepressedImage(viewImage);
		wp<GraphicButton> weakView(view);
		view->addCallback(FormEventType::ButtonClick, [this, weakView](FormsEvent *e) {
			auto base = e->forms().RaisedBy->getData<Base>();
			if (this->state->current_base != base)
			{
				this->changeBase(base);
				this->currentView = weakView.lock();
			}
		});
		view->addCallback(FormEventType::MouseEnter, [this](FormsEvent *e) {
			auto base = e->forms().RaisedBy->getData<Base>();
			this->textViewBase->setVisible(true);
			this->textViewBase->setText(base->name);
		});
		view->addCallback(FormEventType::MouseLeave, [this](FormsEvent *) {
			this->textViewBase->setText("");
			this->textViewBase->setVisible(false);
		});
		miniViews.push_back(view);
	}
	textViewBase = form->findControlTyped<Label>("TEXT_BUTTON_BASE");
	this->textViewBase->setVisible(false);
}
Esempio n. 2
0
void BaseStage::refreshView()
{
	auto viewImage = drawMiniBase(state->current_base, viewHighlight, viewFacility);
	currentView->setImage(viewImage);
	currentView->setDepressedImage(viewImage);
}