void CCommandLineDisplay::Paint (CG32bitImage &Dest) // Paint // // Paint display { Update(); // Paint the cursor m_Buffer.Fill(m_rcCursor.left + 1, m_rcCursor.top, RectWidth(m_rcCursor) - 1, RectHeight(m_rcCursor), (((m_iCounter % 30) < 20) ? INPUT_COLOR : BACK_COLOR)); // Redraw character under cursor if ((m_iCounter % 30) >= 20 && m_iCursorPos < m_sInput.GetLength()) { CString sLine(m_sInput.GetASCIIZPointer() + m_iCursorPos, 1); m_Buffer.DrawText(m_rcCursor.left, m_rcCursor.top, m_pFonts->Console, INPUT_COLOR, sLine); } // Blt Dest.Blt(0, 0, RectWidth(m_rcRect), RectHeight(m_rcRect), 200, m_Buffer, m_rcRect.left, m_rcRect.top); m_iCounter++; }
void CButtonBarDisplay::Paint (CG32bitImage &Dest) // Paint // // Paint the bar { int i; // Fill background Dest.Fill(m_rcRect.left, m_rcRect.top, RectWidth(m_rcRect), RectHeight(m_rcRect), BAR_COLOR); // Get the images const CG32bitImage &Images = m_pButtons->GetImage(); // Paint each button for (i = 0; i < m_pButtons->GetCount(); i++) { RECT rcRect = m_pButtons->GetButtonRect(i); // Skip invisible buttons if (!m_pButtons->GetVisible(i)) continue; // Paint the image RECT rcSrc; GetImageRect(i, (i == m_iSelected), &rcSrc); Dest.Blt(rcSrc.left, rcSrc.top, RectWidth(rcSrc), RectHeight(rcSrc), Images, rcRect.left, rcRect.top); // Paint the button label int cxWidth = m_pFonts->SubTitle.MeasureText(m_pButtons->GetLabel(i), NULL); m_pFonts->SubTitle.DrawText(Dest, rcRect.left + (RectWidth(rcRect) - cxWidth) / 2, rcRect.top + BUTTON_LABEL_Y, CG32bitPixel(128,128,128), m_pButtons->GetLabel(i)); // Paint the description cxWidth = m_pFonts->Medium.MeasureText(m_pButtons->GetDescription(i), NULL); m_pFonts->Medium.DrawText(Dest, rcRect.left + (RectWidth(rcRect) - cxWidth) / 2, rcRect.top + BUTTON_DESCRIPTION_Y, CG32bitPixel(255,255,255), m_pButtons->GetDescription(i)); } }
void CExtension::CreateIcon (int cxWidth, int cyHeight, CG32bitImage **retpIcon) const // CreateIcon // // Creates a cover icon for the adventure. The caller is responsible for // freeing the result. { // Load the image CG32bitImage *pBackground = GetCoverImage(); if (pBackground == NULL || pBackground->GetWidth() == 0 || pBackground->GetHeight() == 0) { int cxSize = Min(cxWidth, cyHeight); *retpIcon = new CG32bitImage; (*retpIcon)->Create(cxSize, cxSize); return; } // Figure out the dimensions of the icon based on the image size and the // desired output. // // If the background is larger than the icon size then we need to scale it. CG32bitImage *pIcon; if (pBackground->GetWidth() > cxWidth || pBackground->GetHeight() > cyHeight) { int xSrc, ySrc, cxSrc, cySrc; Metric rScale; // If we have a widescreen cover image and we want a portrait or // square icon, then we zoom in on the key part of the cover. if (pBackground->GetWidth() > 2 * pBackground->GetHeight()) { rScale = (Metric)cyHeight / pBackground->GetHeight(); cxSrc = (int)(cxWidth / rScale); xSrc = Min(pBackground->GetWidth() - cxSrc, pBackground->GetWidth() - (RIGHT_COVER_OFFSET + (cxSrc / 2))); ySrc = 0; cySrc = pBackground->GetHeight(); } else { rScale = (Metric)cxWidth / pBackground->GetWidth(); if (rScale * pBackground->GetHeight() > (Metric)cyHeight) rScale = (Metric)cyHeight / pBackground->GetHeight(); xSrc = 0; ySrc = 0; cxSrc = pBackground->GetWidth(); cySrc = pBackground->GetHeight(); } // Create the icon pIcon = new CG32bitImage; pIcon->CreateFromImageTransformed(*pBackground, xSrc, ySrc, cxSrc, cySrc, rScale, rScale, 0.0); } // Otherwise we center the image on the icon else { // Create the icon pIcon = new CG32bitImage; pIcon->Create(cxWidth, cyHeight); // Blt pIcon->Blt(0, 0, pBackground->GetWidth(), pBackground->GetHeight(), *pBackground, (cxWidth - pBackground->GetWidth()) / 2, (cyHeight - pBackground->GetHeight()) / 2); } // Done *retpIcon = pIcon; }