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 UINode::renderBack (int x, int y) const { const int w = getRenderWidth(false); const int h = getRenderHeight(false); if (_backgroundColor[3] > 0.001f) { renderFilledRect(x + getRenderX(false), y + getRenderY(false), w, h, _backgroundColor); } }
void UINodeSlider::render (int x, int y) const { UINode::render(x, y); x += getRenderX(); y += getRenderY(); const int w = getRenderWidth(); const int h = getRenderHeight(); const int deltaHeight = h / 2; const float steps = _max - _min + 1.0f; const float stepDelta = w / steps * (_stepWidth < 1.0f ? 1.0f : _stepWidth); const int sliderX = x + (_value - _min) / steps * w; renderLine(x, y + deltaHeight, x + w, y + deltaHeight, _lineColor); renderFilledRect(sliderX, y, stepDelta, h, _sliderColor); }
void IUINodeMap::render (int x, int y) const { renderFilledRect(getRenderX(), getRenderY(), getRenderWidth(), getRenderHeight(), colorBlack); if (_map.isActive()) _map.render(); UINode::render(0, 0); if (_map.isStarted()) return; const BitmapFontPtr& font = getFont(HUGE_FONT); y += getRenderHeight() / 10; x += getRenderWidth() / 10; y += font->print(tr("Players:"), colorWhite, x, y) + font->getCharHeight(); for (std::vector<std::string>::const_iterator i = _players.begin(); i != _players.end(); ++i) { y += font->print(*i, colorWhite, x + 10, y) + font->getCharHeight(); } }
void UINode::renderOnTop (int x, int y) const { const int relX = x + getRenderX(); const int relY = y + getRenderY(); for (UINodeListConstIter i = _nodes.begin(); i != _nodes.end(); ++i) { const UINode* nodePtr = *i; nodePtr->renderOnTop(relX, relY); } const BitmapFontPtr& font = getFont(MEDIUM_FONT); if (_tooltip.empty()) return; if (!hasFocus()) return; const int padding = 2; const int width = font->getTextWidth(_tooltip) + 2 * padding; const int height = font->getTextHeight(_tooltip) + 2 * padding; const int xTooltip = std::min(_frontend->getWidth(), x + _focusMouseX + width) - width; const int yTooltip = std::max(0, y + _focusMouseY - height); renderFilledRect(xTooltip - padding, yTooltip - padding, width, height, colorBlack); font->print(_tooltip, colorWhite, xTooltip, yTooltip); }