///////////////////////////////////////////////////////////////////////////// // startup ///////////////////////////////////////////////////////////////////////////// BOOL CTradeOfferDialog::OnInitDialog() { int i; CHoverStatic *pStatic; CButtonST *pButton; CDC *dc; HDC hDC; CHelpDialog::OnInitDialog(); //help system m_strHelp = HELP_TRADEOFFER; //get the device context dc = GetDC(); hDC = dc->GetSafeHdc(); //set up all the hoverstatics for(i = 0; i < 31; i++) { //get the static pStatic = &m_Trade1Text + i; //set up values pStatic->SetFont(Tahoma12); pStatic->SetCenter(); } //set up all the inhand statics for(i = 0; i < 5; i++) { //get the button pStatic = &m_Inhand1Text + i; pStatic->SetText(VIEW->getResName(i)); //get the button pStatic = &m_OHand1Text + i; pStatic->SetText(VIEW->getResName(i)); //update the buttons pButton = &m_InHand1Button + i; pButton->SetBitmaps(VIEW->getResImage(i, hDC), COLOR_TRANSP, VIEW->getResImage(i, hDC), COLOR_TRANSP); //update the buttons pButton = &m_OHand1Button + i; pButton->SetBitmaps(VIEW->getResImage(i, hDC), COLOR_TRANSP, VIEW->getResImage(i, hDC), COLOR_TRANSP); } //release the device context ReleaseDC(dc); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
///////////////////////////////////////////////////////////////////////////// // update other player trade data ///////////////////////////////////////////////////////////////////////////// void CTradeOfferDialog::updateOTrade(BOOL bNew, int iPlace) { CButtonST *pButton; CHoverStatic *pText; CHoverStatic *pQty; CString str; CDC *dc; HDC hDC; //get the device context dc = GetDC(); hDC = dc->GetSafeHdc(); //set the quantity pointer pQty = &m_OTrade1Qty + iPlace; //set the quantity str.Format("%d", m_iOTrade[m_iOTradePlace[iPlace]]); pQty->SetText(str); //see if we need to add a new card if(TRUE == bNew) { //set the bitmaps and unhide pButton = &m_OTrade1Button + iPlace; pText = &m_OTrade1Text + iPlace; //set the bitmaps pButton->SetBitmaps(VIEW->getResImage(m_iOTradePlace[iPlace], hDC), COLOR_TRANSP, VIEW->getResImage(m_iOTradePlace[iPlace], hDC), COLOR_TRANSP); pButton->ShowWindow(SW_SHOW); //set the text pText->SetText(VIEW->getResName(m_iOTradePlace[iPlace])); pText->ShowWindow(SW_SHOW); //show quantity pQty->ShowWindow(SW_SHOW); } //release the device context ReleaseDC(dc); }
BOOL CDlgMatrixTag::CreateMatrixs() { CMainFrame* pMain = (CMainFrame*)AfxGetMainWnd(); //int nBtnWidth(48+10), nBtnHeight(70), nWidthGap(10), nHightGap(10); int nBtnWidth(39), nBtnHeight(41), nWidthGap(10), nHightGap(10); int nLeftMargin(10), nTopMargin(40); int nButtonSize=0; if (!m_bSetStyle) { if (CNVRBk::GetBkObject()->isNVRType()) nButtonSize=sizeof(nID)/ sizeof(int); else nButtonSize=sizeof(nIDAll)/ sizeof(int); } else { if (CNVRBk::GetBkObject()->isNVRType()) nButtonSize= sizeof(nIDSetting)/ sizeof(int); else nButtonSize=sizeof(nIDSettingAll)/ sizeof(int); } CRect rect; GetClientRect(rect); if (rect.IsRectEmpty()) { return false; } int nColumn = (rect.Width() - nLeftMargin*2) / (nBtnWidth +nWidthGap); //int nRow = (rect.Height() - nTopMargin) / nColumn + (((rect.Height() - nTopMargin) % nColumn ) ? 1 : 0); int nRow= 210 / (nBtnHeight + nHightGap); //CMainFrame::CreateMatrixPane() is set 210 if (!m_bSetStyle) { nTopMargin=60; nColumn++; } DWORD dwStyle = BS_PUSHBUTTON |BS_NOTIFY |WS_VISIBLE;//BS_PUSHBUTTON |BS_NOTIFY |WS_VISIBLE |WS_CHILD|WS_VISIBLE|BS_OWNERDRAW ; COLORREF clBG = RGB(0,0,0); int nHoveOver = (int)BTNST_AUTO_GRAY; m_btnAutioScanSetting.SetBitmaps(IDB_EMAPSETU, clBG ,nHoveOver); CRect rect2; CRect rtAutoSetting; m_ButtonAutoScan.GetWindowRect(rtAutoSetting); ScreenToClient(rtAutoSetting); m_btnAutioScanSetting.GetClientRect(rect2); //ScreenToClient(rect2); m_btnAutioScanSetting.MoveWindow(rtAutoSetting.right+5, 10, 24,24); for (int cj = 0; cj < nRow; cj++) { for (int ci = 0; ci < nColumn; ci++) { if ((cj* nColumn + ci) < nButtonSize) { int nX0 = nLeftMargin + (nBtnWidth +nWidthGap)* ci; if (!m_bSetStyle && cj == 0) nX0 -= (nBtnWidth +nWidthGap); int nX1 = nX0 +nBtnWidth; int nY0 = nTopMargin + (nBtnHeight +nHightGap)* cj; int nY1 = nY0 +nBtnHeight; CButtonST* pBtn = new CButtonST; if (cj == 0 && ci == 0 && !m_bSetStyle) { //if (CNVRBk::GetBkObject()->isNVRType()) //{ // if (nID[0] == IDB_BITMAP_FULL) // { // nX0 = nLeftMargin; // nX1 = nX0 +nBtnWidth; // nY0 = rtAutoSetting.top; // nY1 = nY0 +nBtnHeight; // } //} //else //{ if (nIDAll[0] == IDB_BITMAP_FULL) { nX0 = nLeftMargin; nX1 = nX0 +nBtnWidth; nY0 = rtAutoSetting.top-5; nY1 = nY0 +nBtnHeight; } //} } if (!m_bSetStyle) { if (CNVRBk::GetBkObject()->isNVRType()) { pBtn->Create(NULL, dwStyle, CRect(nX0, nY0, nX1, nY1), this, nID[nColumn* cj +ci]); if(mapTable[nID[nColumn* cj +ci]] == pMain->m_OrgLayoutIdx) { pBtn->SetBitmaps(nIDHot[nColumn* cj +ci], clBG); g_uIDBtnMatrix = nID[nColumn* cj +ci]; } else { pBtn->SetBitmaps(nIDHot[nColumn* cj +ci], clBG ,nHoveOver, nID[nColumn* cj +ci]); } } else { pBtn->Create(NULL, dwStyle, CRect(nX0, nY0, nX1, nY1), this, nIDAll[nColumn* cj +ci]); if(mapTable[nIDAll[nColumn* cj +ci]] == pMain->m_OrgLayoutIdx) { pBtn->SetBitmaps(nIDHotAll[nColumn* cj +ci], clBG); g_uIDBtnMatrix = nIDAll[nColumn* cj +ci]; } else { pBtn->SetBitmaps(nIDHotAll[nColumn* cj +ci], clBG ,nHoveOver, nIDAll[nColumn* cj +ci]); } } } else { if (CNVRBk::GetBkObject()->isNVRType()) { pBtn->Create(NULL, dwStyle, CRect(nX0, nY0, nX1, nY1), this, nIDSetting[nColumn* cj +ci]); if(mapTable[nIDSetting[nColumn* cj +ci]] == pMain->m_OrgLayoutIdx) { pBtn->SetBitmaps(nIDHotSetting[nColumn* cj +ci], clBG); //g_uIDBtnMatrix = nID[nColumn* cj +ci]; } else { pBtn->SetBitmaps(nIDHotSetting[nColumn* cj +ci], clBG ,nHoveOver, nIDHotSetting[nColumn* cj +ci]); } } else { pBtn->Create(NULL, dwStyle, CRect(nX0, nY0, nX1, nY1), this, nIDSettingAll[nColumn* cj +ci]); if(mapTable[nIDSettingAll[nColumn* cj +ci]] == pMain->m_OrgLayoutIdx) { pBtn->SetBitmaps(nIDHotSettingAll[nColumn* cj +ci], clBG); //g_uIDBtnMatrix = nID[nColumn* cj +ci]; } else { pBtn->SetBitmaps(nIDHotSettingAll[nColumn* cj +ci], clBG ,nHoveOver, nIDHotSettingAll[nColumn* cj +ci]); } } } m_vtBtnMatrixs.push_back(pBtn); } } } return true; }
///////////////////////////////////////////////////////////////////////////// // set offer data ///////////////////////////////////////////////////////////////////////////// void CTradeOfferDialog::setOffer(int *iTo, int *iFor, UINT uiID) { int i, j, k; int iRes; int iPlayer; BOOL bCanTrade = TRUE; BOOL bAnyTrade = FALSE; CRect rect; CRect rectClient; CString str; CDC *dc; HDC hDC; CHoverStatic *pStatic; CHoverStatic *pText; CButtonST *pButton; //reset trade counter m_iNumTrade = 0; //reset the changed flag m_bChanged = FALSE; //get the device context dc = GetDC(); hDC = dc->GetSafeHdc(); //get screen rect GetWindowRect(&rect); //get client rect GetClientRect(&rectClient); //enable counter button m_CounterButton.EnableWindow(); //set data memcpy(m_iTrade, iTo, sizeof(m_iTrade)); memcpy(m_iOTrade, iFor, sizeof(m_iOTrade)); //reset trade places memset(m_iTradePlace, -1, sizeof(m_iTradePlace)); memset(m_iOTradePlace, -1, sizeof(m_iOTradePlace)); //set trade places for(i = 0, j = 0, k = 0; i < 5; i++) { if(0 < m_iTrade[i]) { m_iTradePlace[j++] = i; } if(0 < m_iOTrade[i]) { m_iOTradePlace[k++] = i; } } //trade id m_uiTradeID = uiID; //set various text iPlayer = VIEW->getPlayer(); //set title text str.Format("%s wants to trade!", GAME->m_players[iPlayer].m_player.getName()); SetWindowText(str); //set static text str.Format("%s is offering these cards", GAME->m_players[iPlayer].m_player.getFirstName()); m_PlayerStatic.SetWindowText(str); //set player to who we are iPlayer = GAME->m_iIndex; //update statics for(i = 0; i < 4; i++) { //get controls pText = &m_Trade1Text + i; pStatic = &m_Trade1Qty + i; pButton = &m_Trade1Button + i; //get the res iRes = m_iTradePlace[i]; //show/hide from trader if(-1 != iRes) { m_iNumTrade++; pText->SetText(VIEW->getResName(iRes)); pText->ShowWindow(SW_SHOW); pButton->SetBitmaps(VIEW->getResImage(iRes, dc->GetSafeHdc()), COLOR_TRANSP, VIEW->getResImage(iRes, dc->GetSafeHdc()), COLOR_TRANSP); pButton->ShowWindow(SW_SHOW); pButton->EnableWindow(FALSE); str.Format("%d", m_iTrade[iRes]); pStatic->SetText(str); pStatic->ShowWindow(SW_SHOW); } else { pText->ShowWindow(SW_HIDE); pButton->ShowWindow(SW_HIDE); pStatic->ShowWindow(SW_HIDE); } //get controls pText = &m_OTrade1Text + i; pStatic = &m_OTrade1Qty + i; pButton = &m_OTrade1Button + i; //get the res iRes = m_iOTradePlace[i]; //show/hide if(-1 != iRes) { pText->SetText(VIEW->getResName(iRes)); pText->ShowWindow(SW_SHOW); pButton->SetBitmaps(VIEW->getResImage(iRes, dc->GetSafeHdc()), COLOR_TRANSP, VIEW->getResImage(iRes, dc->GetSafeHdc()), COLOR_TRANSP); pButton->ShowWindow(SW_SHOW); pButton->EnableWindow(FALSE); str.Format("%d", m_iOTrade[iRes]); pStatic->SetText(str); pStatic->ShowWindow(SW_SHOW); } else { pText->ShowWindow(SW_HIDE); pButton->ShowWindow(SW_HIDE); pStatic->ShowWindow(SW_HIDE); } //see if they can even do this trade if(GAME->m_players[iPlayer].m_iRes[iRes] < m_iOTrade[iRes]) { bCanTrade = FALSE; } } //reset the counteroffer buttons to be on (turned off in OnCounter) for(i = 0; i < 5; i++) { pButton = &m_OHand1Button + i; pButton->EnableWindow(); pButton = &m_InHand1Button + i; pButton->EnableWindow(); pText = &m_OHand1Text + i; pText->EnableWindow(); pText = &m_Inhand1Text + i; pText->EnableWindow(); pText = &m_Inhand1Qty + i; pText->EnableWindow(); //see if we even have the ability to counteroffer if(0 < GAME->m_players[iPlayer].m_iRes[i]) { bAnyTrade = TRUE; } } //enable/disable ability to trade m_OKButton.EnableWindow(bCanTrade); m_CounterButton.EnableWindow(bAnyTrade); //update the current player updatePlayer(); //update other player updateOPlayer(); //set auto-reject timer m_iTime = GetPrivateProfileInt(INI_GENERAL, INI_TRADE_TIMEOUT, 15, INI_FILE); m_uiReject = SetTimer(TIMER_REJECT_TRADE, 1000, NULL); //set window pos sans counter SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height() - rectClient.Height() + 105, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); //show ourselves ShowWindow(SW_SHOWNOACTIVATE); //release context ReleaseDC(dc); //set the focus to the view VIEW->SetFocus(); }
///////////////////////////////////////////////////////////////////////////// // setup ///////////////////////////////////////////////////////////////////////////// BOOL CTradeJungleDialog::OnInitDialog() { int i; int nRes = 0; int nChoice = 0; BOOL bSingles; CDC *dc; CString str; CHoverStatic *pStatic; CButtonST *pButton; HDC hDC; CHelpDialog::OnInitDialog(); //get the device context dc = GetDC(); hDC = dc->GetSafeHdc(); //set up all the statics and bitmaps for(i = 0; i < 9; i++) { //get the res switch(i / 3) { case 0: nRes = RES_WHEAT; break; case 1: nRes = RES_SHEEP; break; case 2: nRes = RES_ORE; break; } //bitmaps pButton = &m_W2Button + i; //set the bitmaps pButton->SetBitmaps(VIEW->getResImage(nRes, hDC), COLOR_TRANSP, VIEW->getResImage(nRes, hDC), COLOR_TRANSP); pButton->EnableWindow(FALSE); //statics pStatic = &m_W2Static + i; //set the properties pStatic->SetFont(Tahoma12); pStatic->SetCenter(); //set the text pStatic->SetText(VIEW->getResName(nRes)); } //release the device context ReleaseDC(dc); //determine if we show single cards or not bSingles = (1 == (m_nJungles - m_nNeeded)); //set top text str.Format("Which card%s would you like to keep?", bSingles ? "" : "s"); SetWindowText(str); //show or hide the single options showSingles(bSingles); //if we've got singles and 2 jungles, it means we have to hide the one card //choice they don't have if((TRUE == bSingles) && (2 == m_nJungles)) { //look at the player's res count for each if(0 == GAME->m_players[m_nPlayer].m_iRes[RES_WHEAT]) { m_WButton.ShowWindow(SW_HIDE); m_WStatic.ShowWindow(SW_HIDE); m_1Radio.ShowWindow(SW_HIDE); nChoice = 1; } else if(0 == GAME->m_players[m_nPlayer].m_iRes[RES_ORE]) { m_OButton.ShowWindow(SW_HIDE); m_OStatic.ShowWindow(SW_HIDE); m_2Radio.ShowWindow(SW_HIDE); } else { m_SButton.ShowWindow(SW_HIDE); m_SStatic.ShowWindow(SW_HIDE); m_3Radio.ShowWindow(SW_HIDE); } } //initial set radio selection switch(nChoice) { case 0: m_1Radio.SetCheck(TRUE); break; case 1: m_2Radio.SetCheck(TRUE); break; case 2: m_3Radio.SetCheck(TRUE); break; } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }