/// @cond ignore //------------------------------------------------------------------------ static CCoord getFontCapHeight (CFontRef font) { CCoord c = font->getSize (); IPlatformFont* pf = font->getPlatformFont (); if (pf) { CCoord capHeight = pf->getCapHeight (); if (capHeight <= 0) capHeight = pf->getAscent (); if (capHeight > 0) c = capHeight; } return c; }
//----------------------------------------------------------------------------- CTextKickButton::CTextKickButton(const CRect& size, CControlListener* listener, long tag, CBitmap* background, const char *txt, CFontRef font) : CControl(size, listener, tag, background) , text(NULL) { mLabelFont = font; font->remember(); setText(txt); }
//----------------------------------------------------------------------------- void CDrawContext::setFont (const CFontRef newFont, const CCoord& size, const int32_t& style) { if (newFont == 0) return; if ((size > 0 && newFont->getSize () != size) || (style != -1 && newFont->getStyle () != style)) { OwningPointer<CFontDesc> font = (CFontRef)newFont->newCopy (); currentState.font = font; if (size > 0) currentState.font->setSize (size); if (style != -1) currentState.font->setStyle (style); } else { currentState.font = newFont; } }
//----------------------------------------------------------------------------- void CTabView::setTabFontStyle (const CFontRef font, CCoord fontSize, CColor selectedColor, CColor deselectedColor) { CFontRef tabFont = (CFontRef)font->newCopy (); tabFont->setSize (fontSize); CTabChildView* v = firstChild; while (v) { CTabButton* button = dynamic_cast<CTabButton*>(v->button); if (button) { button->setTextFont (tabFont); button->setActiveTextColor (selectedColor); button->setInactiveTextColor (deselectedColor); } v = v->next; } tabFont->forget (); }
//----------------------------------------------------------------------------- void CDrawContext::setFont (const CFontRef newFont, const CCoord& size, const int32_t& style) { if (newFont == 0) return; if (currentState.font) currentState.font->forget (); if ((size > 0 && newFont->getSize () != size) || (style != -1 && newFont->getStyle () != style)) { currentState.font = (CFontRef)newFont->newCopy (); if (size > 0) currentState.font->setSize (size); if (style != -1) currentState.font->setStyle (style); } else { currentState.font = newFont; currentState.font->remember (); } }
void doGraphics() { bool screenshot = singleScreen || batchScreen; LightingParameters lighting(G3D::toSeconds(10, 00, 00, AM)); // Some models have part of their geometry stored in the "weapon" file. // Darth Maul, for example, has his lower half in the weapon. const double footy = 0.98 * min(model.boundingBox(MD2Model::STAND).getCorner(0).y, weapon.boundingBox(MD2Model::STAND).getCorner(0).y); renderDevice->beginFrame(); renderDevice->clear(true, true, true); renderDevice->pushState(); camera->setProjectionAndCameraMatrix(); beginLighting(lighting); int n = 1; if (!screenshot) { // Draw a bunch of characters for (int z = 0; z < 6; ++z) { for (int x = -2; x <= 2; ++x) { drawCharByParams(x, z, footy, n); ++n; } } } // Draw the main character { CoordinateFrame cframe(Vector3(0, -footy, -8)); if (modelTexture.size() > 0) { renderDevice->setTexture(0, modelTexture.last()); } // use global pose variable drawCharWithShadow(cframe, pose); } endLighting(); renderDevice->setObjectToWorldMatrix(CoordinateFrame()); // Ground plane (to hide parts of characters that stick through ground) renderDevice->setColor(Color3::WHITE); renderDevice->beginPrimitive(RenderDevice::QUADS); renderDevice->sendVertex(Vector3(-50, -.01, 50)); renderDevice->sendVertex(Vector3(50, -.01, 50)); renderDevice->sendVertex(Vector3(50, -.01, -50)); renderDevice->sendVertex(Vector3(-50, -.01, -50)); renderDevice->endPrimitive(); renderDevice->popState(); renderDevice->push2D(); double x = 10; double y = 10; double f = 16; int fontSize = (batchScreen) ? (22) : (30); font->draw2DString(model.name, renderDevice->getWidth()/2, renderDevice->getHeight() - 45, fontSize, Color3::BLACK, Color3::WHITE, GFont::XALIGN_CENTER); if (!screenshot) { font->draw2DString(format("%d fps", iRound(renderDevice->getFrameRate())), x, y, 20, Color3::YELLOW, Color3::BLACK); y += 30; font->draw2DString(format("%d characters", n), x, y, f, Color3::CYAN, Color3::BLACK); y += f * 1.5; font->draw2DString(format("%1.1f MB", model.mainMemorySize() / 1e6), x, y, f, Color3::CYAN, Color3::BLACK); y += f * 1.5; font->draw2DString(format("%1.0f Mtris/sec", renderDevice->getTriangleRate() / 1e6), x, y, f, Color3::CYAN, Color3::BLACK); y += f * 1.5; x = renderDevice->getWidth() - 130; y = 10; f = 12; font->draw2DString("CLICK attack", x, y, f, Color3::CYAN, Color3::BLACK); y += f * 1.5; font->draw2DString("SPACE jump", x, y, f, Color3::CYAN, Color3::BLACK); y += f * 1.5; font->draw2DString("CTRL crouch", x, y, f, Color3::CYAN, Color3::BLACK); y += f * 1.5; font->draw2DString("1 . . 5 taunt", x, y, f, Color3::CYAN, Color3::BLACK); y += f * 1.5; font->draw2DString("6 . . 8 die", x, y, f, Color3::CYAN, Color3::BLACK); y += f * 1.5; font->draw2DString("9 . . - pain", x, y, f, Color3::CYAN, Color3::BLACK); y += f * 1.5; font->draw2DString("R/T run/back", x, y, f, Color3::CYAN, Color3::BLACK); y += f * 1.5; font->draw2DString("E new character", x, y, f, Color3::CYAN, Color3::BLACK); y += f * 1.5; font->draw2DString("Z single screen", x, y, f, Color3::CYAN, Color3::BLACK); y += f * 1.5; } renderDevice->pop2D(); renderDevice->endFrame(); }
//----------------------------------------------------------------------------- Win32TextEdit::Win32TextEdit (HWND parent, IPlatformTextEditCallback* textEdit) : IPlatformTextEdit (textEdit) , platformControl (0) , platformFont (0) , platformBackColor (0) , oldWndProcEdit (0) { CRect rect = textEdit->platformGetSize (); CFontRef fontID = textEdit->platformGetFont (); CHoriTxtAlign horiTxtAlign = textEdit->platformGetHoriTxtAlign (); int wstyle = 0; if (horiTxtAlign == kLeftText) wstyle |= ES_LEFT; else if (horiTxtAlign == kRightText) wstyle |= ES_RIGHT; else wstyle |= ES_CENTER; CPoint textInset = textEdit->platformGetTextInset (); rect.offset (textInset.x, textInset.y); rect.right -= textInset.x*2; rect.bottom -= textInset.y*2; // get/set the current font LOGFONT logfont = {0}; CCoord fontH = fontID->getSize (); if (fontH > rect.getHeight ()) fontH = rect.getHeight () - 3; if (fontH < rect.getHeight ()) { CCoord adjust = (rect.getHeight () - (fontH + 3)) / (CCoord)2; rect.top += adjust; rect.bottom -= adjust; } UTF8StringHelper stringHelper (textEdit->platformGetText ()); text = stringHelper; DWORD wxStyle = 0; if (getD2DFactory () == 0 && getSystemVersion ().dwMajorVersion >= 6) // Vista and above wxStyle = WS_EX_COMPOSITED; wstyle |= WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL; platformControl = CreateWindowEx (wxStyle, TEXT("EDIT"), stringHelper, wstyle, (int)rect.left, (int)rect.top, (int)rect.getWidth (), (int)rect.getHeight (), parent, NULL, GetInstance (), 0); logfont.lfWeight = FW_NORMAL; logfont.lfHeight = (LONG)-fontH; logfont.lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS; UTF8StringHelper fontNameHelper (fontID->getName ()); VSTGUI_STRCPY (logfont.lfFaceName, fontNameHelper); logfont.lfClipPrecision = CLIP_STROKE_PRECIS; logfont.lfOutPrecision = OUT_STRING_PRECIS; logfont.lfQuality = DEFAULT_QUALITY; logfont.lfCharSet = ANSI_CHARSET; platformFont = CreateFontIndirect (&logfont); SetWindowLongPtr (platformControl, GWLP_USERDATA, (__int3264)(LONG_PTR)this); SendMessage (platformControl, WM_SETFONT, (WPARAM)platformFont, true); SendMessage (platformControl, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, MAKELONG (0, 0)); SendMessage (platformControl, EM_SETSEL, 0, -1); SendMessage (platformControl, EM_LIMITTEXT, 255, 0); SetFocus (platformControl); oldWndProcEdit = (WINDOWSPROC)(LONG_PTR)SetWindowLongPtr (platformControl, GWLP_WNDPROC, (__int3264)(LONG_PTR)procEdit); CColor backColor = textEdit->platformGetBackColor (); platformBackColor = CreateSolidBrush (RGB (backColor.red, backColor.green, backColor.blue)); }