void CTooltipConsole::Draw(void) { if (disabled) { return; } const std::string s = mouse->GetCurrentTooltip(); glPushMatrix(); glDisable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if (!outFont) { glColor4f(0.2f, 0.2f, 0.2f, CInputReceiver::guiAlpha); glRectf(x, y, (x + w), (y + h)); } const float yScale = 0.015f; const float xScale = (yScale / gu->aspectRatio) * 1.2f; const float xPixel = 1.0f / (xScale * (float)gu->viewSizeX); const float yPixel = 1.0f / (yScale * (float)gu->viewSizeY); glTranslatef(x + 0.01f, y + 0.08f, 0.0f); glScalef(xScale, yScale, 1.0f); glColor4f(1.0f, 1.0f, 1.0f, 0.8f); glEnable(GL_TEXTURE_2D); unsigned int p = 0; while (p < s.size()) { std::string s2; for (int a = 0; a < 420; ++a) { s2 += s[p]; if ((s[p++] == '\n') || (p >= s.size())) { break; } } if (!outFont) { font->glPrintColor("%s", s2.c_str()); } else { const float color[4] = { 1.0f, 1.0f, 1.0f, 0.0f }; outlineFont.print(xPixel, yPixel, color, StripColorCodes(s2).c_str()); font->glPrintColor("%s", s2.c_str()); } glTranslatef(0.0f, -1.2f, 0.0f); } glPopMatrix(); }
void CTooltipConsole::Draw(void) { if (disabled) { return; } // GML_RECMUTEX_LOCK(quad); // getcurrenttooltip accesses guitraceray which accesses quadfield const std::string s = mouse->GetCurrentTooltip(); glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if (!outFont) { glColor4f(0.2f, 0.2f, 0.2f, CInputReceiver::guiAlpha); glRectf(x, y, (x + w), (y + h)); } const float fontScale = 1.0f; const float fontHeight = fontScale * smallFont->GetHeight(); float curX = x + 0.01f; float curY = y + 0.07f; glColor4f(1.0f, 1.0f, 1.0f, 0.8f); unsigned int p = 0; while (p < s.size()) { std::string s2; for (int a = 0; a < 420; ++a) { s2 += s[p]; if ((s[p++] == '\n') || (p >= s.size())) { break; } } if (!outFont) { smallFont->glPrintColorAt(curX, curY, fontScale, s2.c_str()); } else { const float color[4] = { 1.0f, 1.0f, 1.0f, 0.0f }; smallFont->glPrintOutlinedAt(curX, curY, fontScale, StripColorCodes(s2).c_str(), color); smallFont->glPrintColorAt(curX, curY, fontScale, s2.c_str()); } curY -= fontHeight; } }