Ejemplo n.º 1
0
void CardRegion::Render(HDC hdc)
{
    int cardnum = 0;
    int numtodraw;
    BOOL fDrawTips;

    Update();            //Update this stack's card count + size

    numtodraw = nNumApparentCards;

    if(nFlashCount != 0)
    {
        if(fFlashVisible == false)
            numtodraw = 0;
    }

    if(fVisible == 0) return;

    cardnum = cardstack.NumCards() - numtodraw;
    int counter;

    for(counter = 0; counter < numtodraw; counter++)
    {
        int cardval;

        int x = xoffset * counter + xpos;
        int y = yoffset * counter + ypos;

        //if about to draw last card, then actually draw the top card
        if(counter == numtodraw - 1) cardnum = cardstack.NumCards() - 1;

        Card card = cardstack.cardlist[cardnum];
        cardval = card.Idx();

        if(card.FaceDown())
            cardval = nBackCardIdx;    //card-back

        //only draw the visible part of the card
        if(counter < numtodraw - 1)
        {
            if(yoffset != 0 && xoffset != 0)
                fDrawTips = FALSE;
            else
                fDrawTips = TRUE;

            if((yoffset != 0 && abs(xoffset) == 1) || (xoffset != 0 && abs(yoffset) == 1))
                fDrawTips = TRUE;

            //draw horizontal strips
            if(yoffset > 0)
            {
                DrawHorzCardStrip(hdc, x, y, cardval, yoffset, fDrawTips);
            }
            else if(yoffset < 0)
            {
                DrawHorzCardStrip(hdc, x, y+__cardheight+yoffset, cardval, yoffset, fDrawTips);
            }

            //draw some vertical bars
            if(xoffset > 0)
            {
                DrawVertCardStrip(hdc, x, y, cardval, xoffset, fDrawTips);
            }
            else if(xoffset < 0)
            {
                DrawVertCardStrip(hdc, x+__cardwidth+xoffset, y, cardval, xoffset, fDrawTips);
            }

            if(yoffset != 0 && xoffset != 0)//fDrawTips == FALSE)
            {
                //if we didn't draw any tips, then this is a 2-dim stack
                //(i.e, it goes at a diagonal).
                //in this case, we need to fill in the small triangle in
                //each corner!
                DrawCardCorner(hdc, x, y, cardval, xoffset, yoffset);
            }
        }
        //if the top card, draw the whole thing
        else
        {
            CardBlt(hdc, x, y, cardval);
        }

        cardnum ++;

    } //end of index

    if(counter == 0)    //if the cardstack is empty, then draw it that way
    {
        int x = xpos;
        int y = ypos;

        switch(uEmptyImage)
        {
        default:
        case CS_EI_NONE:
            //this wipes the RECT variable, so watch out!
            //SetRect(&rect, x, y, x+__cardwidth, y+__cardheight);
            //PaintRect(hdc, &rect, MAKE_PALETTERGB(crBackgnd));
            parentWnd.PaintCardRgn(hdc, x, y, __cardwidth, __cardheight, x, y);
            break;

        case CS_EI_SUNK:
            DrawCard(hdc, x, y, __hdcPlaceHolder, __cardwidth, __cardheight);
            break;

        case CS_EI_CIRC:
        case CS_EI_X:
            CardBlt(hdc, x, y, uEmptyImage);
            break;
        }

    }

    return;
}