Esempio n. 1
0
void UINode::renderDebug (int x, int y, int textY) const
{
	const int panelX = getRenderX();
	const int panelY = getRenderY();
	const int w = getRenderWidth(false);
	const int h = getRenderHeight(false);

	const Color* color[5];
	color[0] = &colorGreen;
	color[1] = &colorBlue;
	color[2] = &colorRed;
	color[3] = &colorYellow;
	color[4] = &colorCyan;

	const int index = (panelX * 22 * h + panelY * 23 * w) % 5;
	renderRect(x + getRenderX(false), y + getRenderY(false), w, h, *color[index]);
	if (!fequals(_padding, 0.0f)) {
		renderRect(x + panelX, y + panelY, getRenderWidth(), getRenderHeight(), *color[index]);
	}
	renderFilledRect(x + getRenderCenterX(), y + getRenderCenterY(), 4, 4, colorRed);
	renderFilledRect(x + panelX, y + panelY, 4, 4, colorBlue);

	const BitmapFontPtr& font = getFont(MEDIUM_FONT);
	int panelTextY = textY;
	for (UINodeListConstIter i = _nodes.begin(); i != _nodes.end(); ++i) {
		const UINode* nodePtr = *i;
		if (!nodePtr->hasFocus())
			continue;
		nodePtr->renderDebug(x + panelX, y + panelY, panelTextY);
		const std::string debugInfo = "[id=" + nodePtr->getId() + "]";
		_frontend->renderFilledRect(x - 1, panelTextY + 1, font->getTextWidth(debugInfo) + 2, font->getTextHeight(debugInfo) + 2, colorGrayAlpha);
		font->print(debugInfo, colorCyan, x, panelTextY);
		panelTextY += font->getTextHeight(debugInfo);
	}
}
void UINodeCheckbox::render (int x, int y) const
{
	UINodeButton::render(x, y);

	if (_label.empty())
		return;

	x += getRenderX() + getRenderWidth() + getPadding() * _frontend->getWidth();
	y += getRenderCenterY() - _font->getTextHeight(_label) / 2;
	_font->print(_label, _fontColor, x, y);
}
void UINodeBackgroundScene::renderFailedCenter (int x, int y, const MapFailedReason& reason) const
{
	FailedMap::const_iterator i = _failed.find(&reason);
	if (i == _failed.end())
		return;
	const TexturePtr& t = i->second;
	if (!t || !t->isValid())
		return;

	const int playerX = x + getRenderCenterX() - t->getWidth() / 2;
	const int playerY = y + getRenderCenterY() - t->getHeight() / 2;
	renderImage(t, playerX, playerY);
}
Esempio n. 4
0
void UINode::renderTop (int x, int y) const
{
	const int childX = x + getRenderX();
	const int childY = y + getRenderY();

	if (_renderBorder) {
		const int w = getRenderWidth(false);
		const int h = getRenderHeight(false);
		renderRect(x + getRenderX(false), y + getRenderY(false), w, h, _borderColor);
	}

	int textYOffset = 0;
	for (DelayedTextsConstIter i = _texts.begin(); i != _texts.end(); ++i) {
		const UINodeDelayedText& t = *i;
		const int fontX = t.pos.x > 0.00001f ? (t.pos.x * _frontend->getWidth()) : (getRenderCenterX() - t.font->getTextWidth(t.text) / 2.0f);
		int fontY;
		if (t.pos.y > 0.00001f) {
			fontY = t.pos.y * _frontend->getHeight();
		} else {
			const int textHeight = t.font->getTextHeight(t.text);
			fontY = textYOffset + getRenderCenterY() - textHeight / 2.0f;
			textYOffset += textHeight;
		}
		t.font->print(t.text, colorWhite, fontX, fontY);
	}

	const bool debug = Config.isDebugUI();
	const bool focus = hasFocus();
	if (debug && focus)
		renderDebug(x, y, y + 20);

	for (UINodeListConstIter i = _nodes.begin(); i != _nodes.end(); ++i) {
		const UINode* nodePtr = *i;
		if (!nodePtr->isVisible())
			continue;
		nodePtr->render(childX, childY);
	}
}