// // Double-click on the deck // Move 3 cards to the face-up pile // void CARDLIBPROC DeckClickProc(CardRegion &stackobj, int iNumClicked) { TRACE("ENTER DeckClickProc()\n"); CardStack cardstack = stackobj.GetCardStack(); CardStack pile = pPile->GetCardStack(); fGameStarted = true; //reset the face-up pile to represent 3 cards if(dwOptions & OPTION_THREE_CARDS) pPile->SetOffsets(CS_DEFXOFF, 1); if(cardstack.NumCards() == 0) { pile.Clear(); activepile.Reverse(); cardstack.Push(activepile); activepile.Clear(); } else { int numcards = min((dwOptions & OPTION_THREE_CARDS) ? 3 : 1, cardstack.NumCards()); //make a "visible" copy of these cards CardStack temp; temp = cardstack.Pop(numcards); temp.Reverse(); if(dwOptions & OPTION_THREE_CARDS) pile.Clear(); pile.Push(temp); //remove the top 3 from deck activepile.Push(temp); } activepile.Print(); pDeck->SetCardStack(cardstack); pPile->SetCardStack(pile); SolWnd.Redraw(); TRACE("EXIT DeckClickProc()\n"); }
void NewGame(void) { TRACE("ENTER NewGame()\n"); int i, j; SolWnd.EmptyStacks(); //create a new card-stack CardStack deck; deck.NewDeck(); deck.Shuffle(); activepile.Clear(); //deal to each row stack.. for(i = 0; i < NUM_ROW_STACKS; i++) { CardStack temp; temp.Clear(); pRowStack[i]->SetFaceDirection(CS_FACE_DOWNUP, i); for(j = 0; j <= i; j++) { temp.Push(deck.Pop()); } pRowStack[i]->SetCardStack(temp); } //put the other cards onto the deck pDeck->SetCardStack(deck); pDeck->Update(); // For the 1-card-mode, all cards need to be completely overlapped if(!(dwOptions & OPTION_THREE_CARDS)) pPile->SetOffsets(0, 0); SolWnd.Redraw(); fGameStarted = false; TRACE("EXIT NewGame()\n"); }
void CreateSol() { int i; // hbmBitmap = (HBITMAP)LoadImage(0,"test.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE); // SolWnd.SetBackImage(hbmBitmap); activepile.Clear(); // Compute the value for yRowStackCardOffset based on the height of the card, so the card number isn't hidden on larger cards yRowStackCardOffset = (int)(__cardheight / 6.7); pDeck = SolWnd.CreateRegion(DECK_ID, true, X_BORDER, Y_BORDER, 2, 1); pDeck->SetEmptyImage(CS_EI_CIRC); pDeck->SetThreedCount(6); pDeck->SetDragRule(CS_DRAG_NONE, 0); pDeck->SetDropRule(CS_DROP_NONE, 0); pDeck->SetClickProc(DeckClickProc); pDeck->SetDblClickProc(DeckClickProc); pDeck->SetFaceDirection(CS_FACE_DOWN, 0); pPile = SolWnd.CreateRegion(PILE_ID, true, X_BORDER + __cardwidth + X_PILE_BORDER, Y_BORDER, CS_DEFXOFF, 1); pPile->SetEmptyImage(CS_EI_NONE); pPile->SetDragRule(CS_DRAG_TOP, 0); pPile->SetDropRule(CS_DROP_NONE, 0); pPile->SetDblClickProc(PileDblClickProc); pPile->SetRemoveCardProc(PileRemoveProc); // // Create the suit stacks // for(i = 0; i < 4; i++) { pSuitStack[i] = SolWnd.CreateRegion(SUIT_ID+i, true, 0, Y_BORDER, 0, 0); pSuitStack[i]->SetEmptyImage(CS_EI_SUNK); pSuitStack[i]->SetPlacement(CS_XJUST_CENTER, 0, i * (__cardwidth + X_SUITSTACK_BORDER) , 0); pSuitStack[i]->SetDropRule(CS_DROP_CALLBACK, SuitStackDropProc); pSuitStack[i]->SetDragRule(CS_DRAG_TOP); pSuitStack[i]->SetAddCardProc(SuitStackAddProc); } // // Create the row stacks // for(i = 0; i < NUM_ROW_STACKS; i++) { pRowStack[i] = SolWnd.CreateRegion(ROW_ID+i, true, 0, Y_BORDER + __cardheight + Y_ROWSTACK_BORDER, 0, yRowStackCardOffset); pRowStack[i]->SetEmptyImage(CS_EI_SUNK); pRowStack[i]->SetFaceDirection(CS_FACE_DOWNUP, i); pRowStack[i]->SetPlacement(CS_XJUST_CENTER, 0, (i - NUM_ROW_STACKS/2) * (__cardwidth + X_ROWSTACK_BORDER), 0); pRowStack[i]->SetEmptyImage(CS_EI_NONE); pRowStack[i]->SetDragRule(CS_DRAG_CALLBACK, RowStackDragProc); pRowStack[i]->SetDropRule(CS_DROP_CALLBACK, RowStackDropProc); pRowStack[i]->SetClickProc(RowStackClickProc); pRowStack[i]->SetDblClickProc(RowStackDblClickProc); } }