Esempio n. 1
0
void CMenu::DrawString(char *szText, int length, int x, int y, CItem *pItem, void (*function)())
{
    // This is where we use our font image to display text to the screen.  We need to
    // go through every character and index that character into our font image.
    for(int i = 0; i < length; i++)
    {
        // Here we get the index into our font image.  We minus 32 since our font image
        // isn't set up from ASCII characters 0-32, they are ommitted (smiley faces, etc...).
        int index = (int)(szText[i]-32);
        int xOffset = (index % kCharPerLine) * kFontWidth;
        int charY = (index / kCharPerLine) * kFontHeight;

        // Next we grab the RECT offset into the font bitmap, then display that character
        RECT rCharacter = {xOffset, charY, xOffset + kFontWidth, charY + kFontHeight};
        g_Buffer.DisplayTransparentBitmap(m_fontImage, x + i*kFontWidth, y, rCharacter);
    }

    // If there is no data for a button, don't create one and return
    if(!function && !pItem) return;

    // Create a button with an associated item or function for that button.
    // We then want to add it to our vector button list.
    CButton button;
    button.SetButton(szText, length * kFontWidth, x, y, pItem, function);
    m_vButtons.push_back(button);
}
Esempio n. 2
0
void CMenu::DrawString(char *szText, int length, int x, int y, CItem *pItem, void (*function)())
{
	// Set the string colors to white text and a blue background
	WORD dialogColor = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY |
					   BACKGROUND_BLUE | BACKGROUND_INTENSITY;

	HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
	DWORD dwResult = 0;

	COORD position = {x, y};

	// Draw the text to the screen and fill the text with it's attribute
	WriteConsoleOutputCharacter(hOutput, szText, length, position, &dwResult);
	FillConsoleOutputAttribute(hOutput, dialogColor, length, position, &dwResult);

	// If there is no data for a button, don't create one and return
	if(!function && !pItem) return;

	// Create a button with an associated item or function for that button.
	// We then want to add it to our vector button list.
	CButton button;
	button.SetButton(szText, length, x, y, pItem, function);
	m_vButtons.push_back(button);
}